Bug 32000

Summary: [glsl] Texture value get's corrupt as soon as it appears in if statement
Product: Mesa Reporter: Sandro Mani <manisandro>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: medium    
Version: 7.9   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Shadow Mapping demo

Description Sandro Mani 2010-11-30 05:44:54 UTC
Created attachment 40668 [details]
Shadow Mapping demo

Attached is a simple shadow mapping demo.
Problem:
In the fragment shader, as soon as the distanceFromLight variable or any variable which had distanceFromLight as (part of) it's rvalue is placed inside _any_ if statement, it's value becomes corrupt. distanceFromLight is the value read via texture2D from a GL_DEPTH_ATTACHMENT texture.

Details:
See FragmentShader.glsl, where 5 main observations are made.

Notes:
- The program works fine with the nvidia proprietary driver
- glxinfo: 
OpenGL vendor string: Tungsten Graphics, Inc
OpenGL renderer string: Mesa DRI Mobile IntelĀ® GM45 Express Chipset GEM 20100330 DEVELOPMENT 
OpenGL version string: 2.1 Mesa 7.9
OpenGL shading language version string: 1.20

- driver: xorg-x11-drv-intel-2.12.0-6.fc14.1.x86_64
Comment 1 Ian Romanick 2011-06-09 11:24:21 UTC
The shader code incorrectly uses GLSL 1.30 'in' and 'out' for varyings.  In GLSL 1.20 and earlier, you must use 'varying'.  Our compiler currently generates the following error:

Vertex shader errors / warnings in file VertexShader.glsl:
0:3(21): error: `out' qualifier in declaration of `ShadowCoord' only valid for function parameters in GLSL 1.20.

NVIDIA is very sloppy and lets all kinds of invalid code through.

Changing 'in' and 'out' to 'varying' makes this demo produce what I believe are correct results on the current 7.10 branch (which will soon be the 7.10.3 release) and on master.  It seems unlikely that there will ever be another 7.9 release.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.