glsl: define gl_LightSource members in ARB_vertex_program order
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 26 Jun 2020 08:54:56 +0000 (18:54 +1000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 30 Jun 2020 01:29:43 +0000 (01:29 +0000)
GLSL shares functionality with ARB_vertex_program but the GLSL
spec defines the gl_LightSource builtin with a member order that
is different from the packing expected in ARB_vertex_program.
This difference introduces a need for specialist lowering code
when handling builtin structs that is not required for normal
uniform structs due to member location mismatches.

Since gl_LightSource can't be redefined it shouldn't matter if
we add the members in the order listed in the spec, just so long
as we add them all. So here we rearrange the definition of the
glsl builtin to reflex our internal layout and that of
ARB_vertex_program. This required for the following patch.

CC: <stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5656>

src/compiler/glsl/builtin_types.cpp
src/compiler/glsl/builtin_variables.cpp

index d3a28acf27bc55592678e986c9e615517d9be5b4..f9588e6d43f0ea689fbbdb72217eedc225c46c15 100644 (file)
@@ -83,12 +83,12 @@ static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
    glsl_struct_field(glsl_type::vec4_type, "position"),
    glsl_struct_field(glsl_type::vec4_type, "halfVector"),
    glsl_struct_field(glsl_type::vec3_type, "spotDirection"),
-   glsl_struct_field(glsl_type::float_type, "spotExponent"),
-   glsl_struct_field(glsl_type::float_type, "spotCutoff"),
    glsl_struct_field(glsl_type::float_type, "spotCosCutoff"),
    glsl_struct_field(glsl_type::float_type, "constantAttenuation"),
    glsl_struct_field(glsl_type::float_type, "linearAttenuation"),
    glsl_struct_field(glsl_type::float_type, "quadraticAttenuation"),
+   glsl_struct_field(glsl_type::float_type, "spotExponent"),
+   glsl_struct_field(glsl_type::float_type, "spotCutoff"),
 };
 
 static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
index c9fdac84666b7843b7389ec3575c5a3292ce8795..a5f88d9b06980a209abc21a8047c2c7121150d2d 100644 (file)
@@ -100,12 +100,12 @@ static const struct gl_builtin_uniform_element gl_LightSource_elements[] = {
                  SWIZZLE_Y,
                  SWIZZLE_Z,
                  SWIZZLE_Z)},
-   {"spotExponent", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW},
-   {"spotCutoff", {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX},
    {"spotCosCutoff", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW},
    {"constantAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX},
    {"linearAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY},
    {"quadraticAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ},
+   {"spotExponent", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW},
+   {"spotCutoff", {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX},
 };
 
 static const struct gl_builtin_uniform_element gl_LightModel_elements[] = {