[Mesa-dev] [PATCH] mesa: set GLSL 1.20 for the fixed-function fragment shader

Marek Olšák maraeo at gmail.com
Sat Jan 7 18:11:18 UTC 2017


On Sat, Jan 7, 2017 at 5:23 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> Am 07.01.2017 um 15:51 schrieb Marek Olšák:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> This fixes broken depth texturing after:
>>
>> commit 22639a6e19f95902aef23474ad672bf489231ea7
>> Author: Timothy Arceri <timothy.arceri at collabora.com>
>> Date:   Mon Nov 21 00:29:29 2016 +1100
>>
>>     st/mesa: get Version from gl_program rather than gl_shader_program
>> ---
>>  src/mesa/main/ff_fragment_shader.cpp | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
>> index 48b84e8..a13a5de 100644
>> --- a/src/mesa/main/ff_fragment_shader.cpp
>> +++ b/src/mesa/main/ff_fragment_shader.cpp
>> @@ -1215,21 +1215,22 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
>>     p.shader_program = _mesa_new_shader_program(0);
>>
>>     /* Tell the linker to ignore the fact that we're building a
>>      * separate shader, in case we're in a GLES2 context that would
>>      * normally reject that.  The real problem is that we're building a
>>      * fixed function program in a GLES2 context at all, but that's a
>>      * big mess to clean up.
>>      */
>>     p.shader_program->SeparateShader = GL_TRUE;
>>
>> -   state->language_version = 130;
>> +   /* Don't use 1.30, because depth texturing behaves differently there. */
> Could you elaborate on this?

Yeah it wasn't a completely accurate statement. IIRC (off the top of
my head), the legacy GLSL shadow functions follow the depth texture
mode and return vec4. The GLSL 1.30 shadow functions return float and
ignore the depth texture mode. That's a shader and state dependency
that's difficult to deal with. st/mesa uses a simple but not
completely correct solution: if the shader declares GLSL >= 1.30 and
the depth texture mode is GL_ALPHA (000X), it sets the XXXX swizzle
instead. Thus, the GLSL 1.30 shadow function will get the result in .x
and legacy shadow functions will get it in .w as expected. It's an
acceptable deviation from the spec considering how rare the GL_ALPHA
setting is, but one piglit test checking GL_ALPHA showed an obvious
failure there.

Marek


More information about the mesa-dev mailing list