From ddf2778269e4a5315964ee043abace895084aaa2 Mon Sep 17 00:00:00 2001 From: Andrii Simiklit Date: Fri, 31 Jul 2020 14:53:25 +0300 Subject: [PATCH] glsl: add member's location layout qualifier rules for `arrayed` in/out blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec: "For some blocks declared as arrays, the location can only be applied at the block level: When a block is declared as an array where additional locations are needed for each member for each block array element, it is a compile-time error to specify locations on the block members. That is, when locations would be under specified by applying them on block members, they are not allowed on block members. For arrayed interfaces (those generally having an extra level of arrayness due to interface expansion), the outer array is stripped before applying this rule" From Section 1.2.1 (Changes from Revision 6 of GLSL Version) of the GLSL 4.50 spec: "Private Bug 15678: Don’t allow location = on block members where the block needs an array of locations" From Section 4.4.1 (Input Layout Qualifiers) of the GLSL ES 3.20 spec "If an input is declared as an array of blocks, excluding per-vertex-arrays as required for tessellation, it is an error to declare a member of the block with a location qualifier" From Section 1.1.3 (Changes from GLSL ES 3.2 revision 3) of the GLSL ES 3.20 spec: "Arrayed blocks cannot have layout location qualifiers on members" Reviewed-by: Timothy Arceri Signed-off-by: Andrii Simiklit Part-of: --- src/compiler/glsl/ast_to_hir.cpp | 53 +++++++++++++++++++ .../drivers/llvmpipe/ci/llvmpipe-fails.txt | 2 - .../radeonsi/ci/navi10-piglit-quick-fail.csv | 2 - .../radeonsi/ci/raven-piglit-quick-fail.csv | 2 - .../ci/sienna_cichlid-piglit-quick-fail.csv | 2 - .../radeonsi/ci/vega20-piglit-quick-fail.csv | 2 - .../drivers/zink/ci/zink-radv-fails.txt | 2 - 7 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 9684203fb0d..2a93a7fd401 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -8389,6 +8389,59 @@ ast_interface_block::hir(exec_list *instructions, const glsl_type *block_array_type = process_array_type(&loc, block_type, this->array_specifier, state); + /* From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec: + * + * "For some blocks declared as arrays, the location can only be applied + * at the block level: When a block is declared as an array where + * additional locations are needed for each member for each block array + * element, it is a compile-time error to specify locations on the block + * members. That is, when locations would be under specified by applying + * them on block members, they are not allowed on block members. For + * arrayed interfaces (those generally having an extra level of + * arrayness due to interface expansion), the outer array is stripped + * before applying this rule" + * + * From 4.4.1 (Input Layout Qualifiers) and + * 4.4.2 (Output Layout Qualifiers) of GLSL ES 3.20 + * + * "If an input is declared as an array of blocks, excluding + * per-vertex-arrays as required for tessellation, it is an error + * to declare a member of the block with a location qualifier." + * + * "If an output is declared as an array of blocks, excluding + * per-vertex-arrays as required for tessellation, it is an error + * to declare a member of the block with a location qualifier." + */ + if (!redeclaring_per_vertex && + (state->has_enhanced_layouts() || state->has_shader_io_blocks())) { + bool allow_location; + switch (state->stage) + { + case MESA_SHADER_TESS_CTRL: + allow_location = this->array_specifier->is_single_dimension(); + break; + case MESA_SHADER_TESS_EVAL: + case MESA_SHADER_GEOMETRY: + allow_location = (this->array_specifier->is_single_dimension() + && var_mode == ir_var_shader_in); + break; + default: + allow_location = false; + break; + } + + if (!allow_location) { + for (unsigned i = 0; i < num_variables; i++) { + if (fields[i].location != -1) { + _mesa_glsl_error(&loc, state, + "explicit member locations are not allowed in " + "blocks declared as arrays %s shader", + _mesa_shader_stage_to_string(state->stage)); + } + } + } + } + /* Section 4.3.7 (Interface Blocks) of the GLSL 1.50 spec says: * * For uniform blocks declared an array, each individual array diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt index 6e9fb356550..7c9f03921e0 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt @@ -36,8 +36,6 @@ dEQP-GLES31.functional.primitive_bounding_box.wide_points.tessellation_set_per_p # Got wrong error code: GL_INVALID_OPERATION, expected: GL_INVALID_VALUE after step 0 at glcCompressedFormatTests.cpp:1463 (Fail) KHR-GLES31.core.compressed_format.api.invalid_teximage_with_compressed_format,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@glsl-1.20@compiler@invalid-vec4-array-to-vec3-array-conversion.vert,Fail spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail diff --git a/src/gallium/drivers/radeonsi/ci/navi10-piglit-quick-fail.csv b/src/gallium/drivers/radeonsi/ci/navi10-piglit-quick-fail.csv index ef65cd083d0..960e56867de 100644 --- a/src/gallium/drivers/radeonsi/ci/navi10-piglit-quick-fail.csv +++ b/src/gallium/drivers/radeonsi/ci/navi10-piglit-quick-fail.csv @@ -37,8 +37,6 @@ spec@!opengl 3.2@gl-3.2-adj-prims line cull-front pv-first,Fail spec@!opengl 3.2@gl-3.2-adj-prims pv-first,Fail spec@arb_bindless_texture@compiler@images@arith-bound-image.frag,Crash spec@arb_bindless_texture@compiler@samplers@arith-bound-sampler-texture2d.frag,Crash -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2-mat2,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x3-mat2x3,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x4-mat2x4,Fail diff --git a/src/gallium/drivers/radeonsi/ci/raven-piglit-quick-fail.csv b/src/gallium/drivers/radeonsi/ci/raven-piglit-quick-fail.csv index 5a67d197786..4cb33831ae3 100644 --- a/src/gallium/drivers/radeonsi/ci/raven-piglit-quick-fail.csv +++ b/src/gallium/drivers/radeonsi/ci/raven-piglit-quick-fail.csv @@ -56,8 +56,6 @@ spec@arb_bindless_texture@compiler@samplers@arith-bound-sampler-texture2d.frag,C spec@arb_bindless_texture@illegal,Fail spec@arb_bindless_texture@illegal@Call glCopyTexImage* when a texture handle is referenced,Fail spec@arb_bindless_texture@illegal@Call glTexImage* when a texture handle is referenced,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@arb_gl_spirv@execution@ssbo@aoa,Fail spec@arb_gl_spirv@execution@ssbo@aoa-2,Fail spec@arb_gl_spirv@execution@ssbo@array,Fail diff --git a/src/gallium/drivers/radeonsi/ci/sienna_cichlid-piglit-quick-fail.csv b/src/gallium/drivers/radeonsi/ci/sienna_cichlid-piglit-quick-fail.csv index a576fdcccd5..0e670f49de0 100644 --- a/src/gallium/drivers/radeonsi/ci/sienna_cichlid-piglit-quick-fail.csv +++ b/src/gallium/drivers/radeonsi/ci/sienna_cichlid-piglit-quick-fail.csv @@ -37,8 +37,6 @@ spec@!opengl 3.2@gl-3.2-adj-prims line cull-front pv-first,Fail spec@!opengl 3.2@gl-3.2-adj-prims pv-first,Fail spec@arb_bindless_texture@compiler@images@arith-bound-image.frag,Crash spec@arb_bindless_texture@compiler@samplers@arith-bound-sampler-texture2d.frag,Crash -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2-mat2,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x3-mat2x3,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x4-mat2x4,Fail diff --git a/src/gallium/drivers/radeonsi/ci/vega20-piglit-quick-fail.csv b/src/gallium/drivers/radeonsi/ci/vega20-piglit-quick-fail.csv index 2fd6268a73f..77c5e9d53d2 100644 --- a/src/gallium/drivers/radeonsi/ci/vega20-piglit-quick-fail.csv +++ b/src/gallium/drivers/radeonsi/ci/vega20-piglit-quick-fail.csv @@ -48,8 +48,6 @@ spec@!opengl 3.2@gl-3.2-adj-prims pv-first,Fail spec@!opengl 3.2@gl-3.2-adj-prims pv-last,Fail spec@arb_bindless_texture@compiler@images@arith-bound-image.frag,Crash spec@arb_bindless_texture@compiler@samplers@arith-bound-sampler-texture2d.frag,Crash -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2-mat2,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x3-mat2x3,Fail spec@arb_gpu_shader_fp64@execution@conversion@frag-conversion-explicit-dmat2x4-mat2x4,Fail diff --git a/src/gallium/drivers/zink/ci/zink-radv-fails.txt b/src/gallium/drivers/zink/ci/zink-radv-fails.txt index 47ece7c0882..9b59e840099 100644 --- a/src/gallium/drivers/zink/ci/zink-radv-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-radv-fails.txt @@ -1345,8 +1345,6 @@ spec@arb_depth_texture@texwrap formats offset@GL_DEPTH_COMPONENT24- swizzled,Fai spec@arb_depth_texture@texwrap formats offset@GL_DEPTH_COMPONENT32,Fail spec@arb_depth_texture@texwrap formats offset@GL_DEPTH_COMPONENT32- NPOT,Fail spec@arb_depth_texture@texwrap formats offset@GL_DEPTH_COMPONENT32- swizzled,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.frag,Fail -spec@arb_enhanced_layouts@compiler@block-member-locations@arrayed-block-member-location.vert,Fail spec@arb_enhanced_layouts@execution@component-layout@vs-fs-array-dvec3,Crash spec@arb_enhanced_layouts@execution@component-layout@vs-gs-fs-double,Fail spec@arb_es2_compatibility@texwrap formats bordercolor-swizzled,Fail