From 20ab7046c09e0ff419b984d31bdc7fcdf8e6c617 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 12 Apr 2022 11:23:31 +1000 Subject: [PATCH] glsl/st: use nir pass to lower indirect rather than GLSL IR Will allow us to drop more GLSL IR code in future once we switch all drivers to NIR. Also stops the need for all drivers to call this pass to remove indirect temps that may have been added during the NIR varying linking lowering/optimisations. This patch fixes some tests on i915, d3d12, lima and vc4. Reviewed-by: Emma Anholt Part-of: --- src/broadcom/ci/broadcom-rpi3-fails.txt | 10 ------- .../drivers/d3d12/ci/d3d12-quick_shader.txt | 17 +++--------- .../drivers/i915/ci/i915-g33-fails.txt | 6 +---- src/gallium/drivers/lima/ci/lima-fails.txt | 27 ------------------- src/mesa/state_tracker/st_glsl_to_ir.cpp | 5 ++-- src/mesa/state_tracker/st_glsl_to_nir.cpp | 21 +++++++++++++++ 6 files changed, 28 insertions(+), 58 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi3-fails.txt b/src/broadcom/ci/broadcom-rpi3-fails.txt index ee9f187bbcd..430b381c44b 100644 --- a/src/broadcom/ci/broadcom-rpi3-fails.txt +++ b/src/broadcom/ci/broadcom-rpi3-fails.txt @@ -1557,8 +1557,6 @@ spec@glsl-1.10@execution@samplers@glsl-fs-sampler-numbering-2,Fail spec@glsl-1.10@execution@samplers@glsl-fs-sampler-numbering-3,Fail spec@glsl-1.10@execution@samplers@in-parameter-array,Fail spec@glsl-1.10@execution@texture3d,Fail -spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail -spec@glsl-1.10@execution@variable-indexing@vs-temp-array-mat4-index-col-row-wr,Fail spec@glsl-1.20@built-in constants,Fail spec@glsl-1.20@built-in constants@gl_MaxVertexAttribs,Fail spec@glsl-1.20@execution@fs-nan-builtin-max,Fail @@ -1589,14 +1587,6 @@ spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj(bias) 2d,Fail spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj(bias) 2d_projvec4,Fail spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj(bias) 2dshadow,Fail spec@glsl-1.20@execution@tex-miplevel-selection gl2:textureproj(bias) 3d,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-col-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-col-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-wr,Fail spec@glsl-1.20@execution@vs-nan-builtin-max,Fail spec@glsl-1.20@execution@vs-nan-builtin-min,Fail spec@intel_performance_query@intel_performance_query-issue_2235,Fail diff --git a/src/gallium/drivers/d3d12/ci/d3d12-quick_shader.txt b/src/gallium/drivers/d3d12/ci/d3d12-quick_shader.txt index 799a9581f3d..a19a14151f3 100644 --- a/src/gallium/drivers/d3d12/ci/d3d12-quick_shader.txt +++ b/src/gallium/drivers/d3d12/ci/d3d12-quick_shader.txt @@ -1,4 +1,3 @@ -shaders/glsl-predication-on-large-array: fail spec/amd_shader_trinary_minmax/execution/built-in-functions/cs-max3-float-float-float: skip spec/amd_shader_trinary_minmax/execution/built-in-functions/cs-max3-int-int-int: skip spec/amd_shader_trinary_minmax/execution/built-in-functions/cs-max3-ivec2-ivec2-ivec2: skip @@ -274,14 +273,9 @@ spec/arb_gl_spirv/execution/xfb/vs_two_sets_struct: skip spec/arb_gl_spirv/linker/uniform/multisampler: skip spec/arb_gl_spirv/linker/uniform/multisampler-array: skip spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatcentroid-array-of-structs: crash -spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatcentroid-block-array: crash spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatcentroid-struct: crash spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatcentroid-struct2: crash -spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatoffset-block-array: crash spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatoffset-struct: crash -spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatsample-array-nonuniform: crash -spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatsample-array-of-array: crash -spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatsample-block-array: crash spec/arb_gpu_shader5/execution/built-in-functions/fs-interpolateatsample-struct: crash spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-nested-struct-arrays-nonconst: fail spec/arb_gpu_shader5/execution/sampler_array_indexing/fs-struct-nonconst-multiple-samplers: fail @@ -320,7 +314,6 @@ spec/arb_gpu_shader_fp64/execution/conversion/vert-conversion-explicit-double-ui spec/arb_gpu_shader_fp64/execution/conversion/vert-conversion-explicit-dvec2-uvec2: fail spec/arb_gpu_shader_fp64/execution/conversion/vert-conversion-explicit-dvec3-uvec3: fail spec/arb_gpu_shader_fp64/execution/conversion/vert-conversion-explicit-dvec4-uvec4: fail -spec/arb_gpu_shader_fp64/execution/fs-indirect-temp-double-dst: fail spec/arb_gpu_shader_fp64/execution/inout/vs-out-fs-in-s1/2-s2/2-s3/2-double-location-0: crash spec/arb_gpu_shader_fp64/execution/vs-fs-explicit-locations: crash spec/arb_gpu_shader_int64/execution/built-in-functions/cs-abs-i64vec2: skip @@ -611,10 +604,6 @@ spec/arb_tessellation_shader/execution/tcs-output-unmatched: crash spec/arb_tessellation_shader/execution/tcs-tes-max-in-out-patch-components: crash spec/arb_tessellation_shader/execution/tes-primitiveid: fail spec/arb_tessellation_shader/execution/variable-indexing/tcs-input-array-dvec4-index-rd: crash -spec/arb_tessellation_shader/execution/variable-indexing/tcs-input-array-float-index-rd: crash -spec/arb_tessellation_shader/execution/variable-indexing/tcs-input-array-vec2-index-rd: crash -spec/arb_tessellation_shader/execution/variable-indexing/tcs-input-array-vec3-index-rd: crash -spec/arb_tessellation_shader/execution/variable-indexing/tcs-input-array-vec4-index-rd: crash spec/arb_tessellation_shader/execution/variable-indexing/tcs-output-array-dvec4-index-wr: crash spec/arb_tessellation_shader/execution/variable-indexing/tcs-output-array-float-index-rd-after-barrier: crash spec/arb_tessellation_shader/execution/variable-indexing/tcs-output-array-float-index-wr-before-barrier: crash @@ -4107,9 +4096,9 @@ spec/oes_viewport_array/viewport-gs-writes-out-of-range: skip summary: name: results ---- -------- - pass: 16135 - fail: 1053 - crash: 103 + pass: 16146 + fail: 1051 + crash: 94 skip: 2925 timeout: 0 warn: 25 diff --git a/src/gallium/drivers/i915/ci/i915-g33-fails.txt b/src/gallium/drivers/i915/ci/i915-g33-fails.txt index 3be3a515544..fb63cabeb34 100644 --- a/src/gallium/drivers/i915/ci/i915-g33-fails.txt +++ b/src/gallium/drivers/i915/ci/i915-g33-fails.txt @@ -164,8 +164,6 @@ shaders@glsl-uniform-interstage-limits@520 vs- 1 fs,Fail shaders@glsl-uniform-interstage-limits@subdivide 5,Fail shaders@glsl-uniform-interstage-limits@subdivide 5- statechanges,Fail -shaders@glsl-predication-on-large-array,Fail - shaders@ssa@fs-if-def-else-break,Fail shaders@ssa@fs-lost-copy-problem,Fail shaders@ssa@fs-swap-problem,Fail @@ -894,6 +892,7 @@ spec@glsl-1.10@execution@variable-indexing@fs-input-array-vec2-index-rd,Fail spec@glsl-1.10@execution@variable-indexing@fs-input-array-vec3-index-rd,Fail spec@glsl-1.10@execution@variable-indexing@fs-input-array-vec4-index-rd,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat3-index-col-row-wr,Fail +spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat3-index-col-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-array-mat4-index-col-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-uniform-array-mat4-index-col-row-rd,Fail @@ -1057,8 +1056,6 @@ spec@glsl-1.20@execution@built-in-functions@fs-outerproduct-vec3-vec4,Fail spec@glsl-1.20@execution@built-in-functions@fs-outerproduct-vec4-vec2,Fail spec@glsl-1.20@execution@built-in-functions@fs-outerproduct-vec4-vec3,Fail spec@glsl-1.20@execution@built-in-functions@fs-outerproduct-vec4-vec4,Fail -spec@glsl-1.20@execution@fs-const-array-of-struct,Fail -spec@glsl-1.20@execution@fs-const-array-of-struct-of-array,Fail spec@glsl-1.20@execution@fs-function-inout-array-of-structs,Fail spec@glsl-1.20@execution@fs-nan-builtin-max,Fail spec@glsl-1.20@execution@fs-nan-builtin-min,Fail @@ -1110,7 +1107,6 @@ spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat3-index-col-row-wr,F spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat3-index-col-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-col-wr,Fail -spec@glsl-1.20@execution@variable-indexing@fs-temp-array-mat4-index-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-uniform-array-mat4-index-col-row-rd,Fail spec@glsl-1.20@execution@variable-indexing@fs-varying-array-mat3-index-col-rd,Fail spec@glsl-1.20@execution@variable-indexing@fs-varying-array-mat3-index-col-row-rd,Fail diff --git a/src/gallium/drivers/lima/ci/lima-fails.txt b/src/gallium/drivers/lima/ci/lima-fails.txt index 1c38180cad3..2dc2dc311df 100644 --- a/src/gallium/drivers/lima/ci/lima-fails.txt +++ b/src/gallium/drivers/lima/ci/lima-fails.txt @@ -28,25 +28,6 @@ dEQP-GLES2.functional.fragment_ops.depth_stencil.random.7,Fail dEQP-GLES2.functional.fragment_ops.depth_stencil.random.8,Fail dEQP-GLES2.functional.fragment_ops.depth_stencil.random.9,Fail dEQP-GLES2.functional.fragment_ops.depth_stencil.write_mask.stencil,Fail -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat4_dynamic_loop_write_dynamic_loop_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat4_dynamic_loop_write_dynamic_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat4_dynamic_loop_write_static_loop_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat4_dynamic_loop_write_static_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_dynamic_loop_write_dynamic_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_dynamic_loop_write_static_loop_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_dynamic_loop_write_static_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_dynamic_loop_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_dynamic_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_static_loop_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_static_read_vertex,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec3_dynamic_loop_write_dynamic_loop_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec3_dynamic_loop_write_dynamic_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec3_dynamic_loop_write_static_loop_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec3_dynamic_loop_write_static_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_dynamic_loop_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_dynamic_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_static_loop_read,Fail -dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_static_read,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2d_bias,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec3_bias,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec4_bias,Fail @@ -442,10 +423,6 @@ spec@glsl-1.10@execution@variable-indexing@fs-temp-mat4-col-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-mat4-col-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-mat4-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@fs-temp-mat4-wr,Fail -spec@glsl-1.10@execution@variable-indexing@vs-temp-array-mat4-index-col-row-wr,Fail -spec@glsl-1.10@execution@variable-indexing@vs-temp-array-mat4-index-col-wr,Fail -spec@glsl-1.10@execution@variable-indexing@vs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.10@execution@variable-indexing@vs-temp-array-mat4-index-wr,Fail spec@glsl-1.10@execution@variable-indexing@vs-varying-array-mat2-col-row-wr,Fail spec@glsl-1.10@execution@variable-indexing@vs-varying-array-mat2-col-wr,Fail spec@glsl-1.10@execution@variable-indexing@vs-varying-array-mat2-index-col-row-wr,Fail @@ -537,10 +514,6 @@ spec@glsl-1.20@execution@variable-indexing@fs-temp-mat4-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-mat4-col-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-mat4-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@fs-temp-mat4-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-col-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-col-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-row-wr,Fail -spec@glsl-1.20@execution@variable-indexing@vs-temp-array-mat4-index-wr,Fail spec@glsl-1.20@execution@variable-indexing@vs-varying-array-mat2-col-row-wr,Fail spec@glsl-1.20@execution@variable-indexing@vs-varying-array-mat2-col-wr,Fail spec@glsl-1.20@execution@variable-indexing@vs-varying-array-mat2-index-col-row-wr,Fail diff --git a/src/mesa/state_tracker/st_glsl_to_ir.cpp b/src/mesa/state_tracker/st_glsl_to_ir.cpp index 2c4d2ce8a53..304ba1122bc 100644 --- a/src/mesa/state_tracker/st_glsl_to_ir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_ir.cpp @@ -82,8 +82,9 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) /* If there are forms of indirect addressing that the driver * cannot handle, perform the lowering pass. */ - if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput || - options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) { + if (!use_nir && + (options->EmitNoIndirectInput || options->EmitNoIndirectOutput || + options->EmitNoIndirectTemp || options->EmitNoIndirectUniform)) { lower_variable_index_to_cond_assign(stage, ir, options->EmitNoIndirectInput, options->EmitNoIndirectOutput, diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 4d485ff843b..a4d071771d8 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -788,6 +788,27 @@ st_link_nir(struct gl_context *ctx, for (unsigned i = 0; i < num_shaders; i++) { struct gl_linked_shader *shader = linked_shader[i]; nir_shader *nir = shader->Program->nir; + gl_shader_stage stage = shader->Stage; + const struct gl_shader_compiler_options *options = + &ctx->Const.ShaderCompilerOptions[stage]; + + /* If there are forms of indirect addressing that the driver + * cannot handle, perform the lowering pass. + */ + if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput || + options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) { + nir_variable_mode mode = options->EmitNoIndirectInput ? + nir_var_shader_in : (nir_variable_mode)0; + mode |= options->EmitNoIndirectOutput ? + nir_var_shader_out : (nir_variable_mode)0; + mode |= options->EmitNoIndirectTemp ? + nir_var_function_temp : (nir_variable_mode)0; + mode |= options->EmitNoIndirectUniform ? + nir_var_uniform | nir_var_mem_ubo | nir_var_mem_ssbo : + (nir_variable_mode)0; + + nir_lower_indirect_derefs(nir, mode, UINT32_MAX); + } /* don't infer ACCESS_NON_READABLE so that Program->sh.ImageAccess is * correct: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3278