mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 17:58:26 +02:00
zink: fix gl_PrimitiveID reads with quads
Zink emulates quads with a GS, which imposes requirements for gl_PrimitiveID. Handle them here. Previously Zink went out of spec. Fixes spec@glsl-1.50@execution@primitive-id-no-gs-quads and spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Antonino Maniscalco <antomani103@gmail.com> Fixes:e2220ee55e("zink: filled quad emulation gs generation function") Closes: #12214 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32397> (cherry picked from commit23601d6632) Conflicts: src/gallium/drivers/zink/ci/zink-anv-adl-fails.txt src/gallium/drivers/zink/ci/zink-lvp-fails.txt src/gallium/drivers/zink/ci/zink-radv-vangogh-fails.txt src/gallium/drivers/zink/ci/zink-venus-lvp-fails.txt
This commit is contained in:
parent
9078a8becf
commit
5019b21f0e
12 changed files with 34 additions and 22 deletions
|
|
@ -774,7 +774,7 @@
|
|||
"description": "zink: fix gl_PrimitiveID reads with quads",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "e2220ee55e40ec5e1ef0d8f74ff6e7d7bb5db16a",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -634,7 +634,6 @@ dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_min_revers
|
|||
dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_mag_reverse_src_x,Fail
|
||||
dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_min_reverse_src_x,Fail
|
||||
wayland-dEQP-EGL.functional.resize.surface_size.shrink,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
dEQP-GLES3.functional.fbo.multiview.samples_1,Fail
|
||||
spec@arb_gpu_shader_fp64@uniform_buffers@fs-ubo-load.indirect.3,Fail
|
||||
dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_min_reverse_src_dst_y,Fail
|
||||
|
|
@ -682,4 +681,3 @@ spec@ext_framebuffer_multisample@interpolation 8 centroid-deriv-disabled,Fail
|
|||
wayland-dEQP-EGL.functional.resize.surface_size.grow,Fail
|
||||
dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_mag_reverse_dst_x,Fail
|
||||
dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_out_of_bounds_min_reverse_dst_x,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
|
|
|
|||
|
|
@ -558,9 +558,6 @@ spec@ext_transform_feedback@tessellation triangle_fan flat_first,Fail
|
|||
spec@ext_transform_feedback@tessellation quad_strip wireframe,Fail
|
||||
spec@ext_transform_feedback@tessellation quads wireframe,Fail
|
||||
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
|
||||
spec@khr_texture_compression_astc@miptree-gl srgb-fp,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gl srgb-fp@sRGB decode full precision,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -123,10 +123,6 @@ spec@!opengl 1.0@rasterpos,Fail
|
|||
spec@!opengl 1.0@rasterpos@glsl_vs_gs_linked,Fail
|
||||
spec@!opengl 1.0@rasterpos@glsl_vs_tes_linked,Fail
|
||||
|
||||
spec@arb_tessellation_shader@execution@gs-primitiveid-instanced,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
|
||||
spec@ext_transform_feedback@tessellation quads wireframe,Fail
|
||||
|
||||
# Debian 12 CI update, see https://gitlab.freedesktop.org/mesa/mesa/-/issues/9072
|
||||
|
|
|
|||
|
|
@ -461,8 +461,6 @@ spec@ext_transform_feedback@immediate-reuse-uniform-buffer,Fail
|
|||
spec@ext_transform_feedback@tessellation quad_strip wireframe,Fail
|
||||
spec@ext_transform_feedback@tessellation quads wireframe,Fail
|
||||
spec@glsl-1.10@execution@samplers@glsl-fs-lots-of-tex,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@fs-packhalf2x16,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@vs-packhalf2x16,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gl srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ spec@glsl-1.10@execution@samplers@glsl-fs-shadow2d-clamp-z,Fail
|
|||
|
||||
spec@glsl-1.20@compiler@invalid-vec4-array-to-vec3-array-conversion.vert,Fail
|
||||
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@fs-packhalf2x16,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@vs-packhalf2x16,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ spec@glsl-1.10@execution@samplers@glsl-fs-shadow2d-clamp-z,Fail
|
|||
|
||||
spec@glsl-1.20@compiler@invalid-vec4-array-to-vec3-array-conversion.vert,Fail
|
||||
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@fs-packhalf2x16,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@vs-packhalf2x16,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ spec@glsl-1.10@execution@samplers@glsl-fs-shadow2d-clamp-z,Fail
|
|||
|
||||
spec@glsl-1.20@compiler@invalid-vec4-array-to-vec3-array-conversion.vert,Fail
|
||||
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@fs-packhalf2x16,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@vs-packhalf2x16,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ spec@glsl-1.10@execution@samplers@glsl-fs-shadow2d-clamp-z,Fail
|
|||
|
||||
spec@glsl-1.20@compiler@invalid-vec4-array-to-vec3-array-conversion.vert,Fail
|
||||
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@fs-packhalf2x16,Fail
|
||||
spec@glsl-es-3.00@execution@built-in-functions@vs-packhalf2x16,Fail
|
||||
spec@khr_texture_compression_astc@miptree-gles srgb-fp,Fail
|
||||
|
|
|
|||
|
|
@ -493,8 +493,6 @@ spec@glsl-1.50@built-in constants@gl_MaxFragmentInputComponents,Fail
|
|||
spec@glsl-1.50@execution@geometry@point-size-out,Fail
|
||||
spec@glsl-1.50@execution@geometry@primitive-id-restart gl_line_strip_adjacency other,Crash
|
||||
spec@glsl-1.50@execution@interface-blocks-complex-vs-fs,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
spec@glsl-1.50@execution@redeclare-pervertex-out-subset-gs,Fail
|
||||
spec@glsl-1.50@execution@variable-indexing@gs-output-array-vec4-index-wr,Fail
|
||||
spec@glsl-3.30@built-in constants,Fail
|
||||
|
|
|
|||
|
|
@ -142,9 +142,6 @@ spec@arb_arrays_of_arrays@execution@image_store@basic-imagestore-mixed-const-non
|
|||
spec@arb_arrays_of_arrays@execution@image_store@basic-imagestore-mixed-const-non-const-uniform-index2,Fail
|
||||
spec@arb_arrays_of_arrays@execution@image_store@basic-imagestore-non-const-uniform-index,Fail
|
||||
spec@arb_gpu_shader_fp64@execution@conversion,Fail
|
||||
spec@arb_tessellation_shader@execution@gs-primitiveid-instanced,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quad-strip,Fail
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
spec@glsl-4.00@execution@conversion,Fail
|
||||
|
||||
spec@ext_transform_feedback@tessellation quads wireframe,Fail
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "nir_opcodes.h"
|
||||
#include "shader_enums.h"
|
||||
#include "zink_context.h"
|
||||
#include "zink_compiler.h"
|
||||
#include "zink_descriptors.h"
|
||||
|
|
@ -1096,6 +1097,8 @@ zink_create_quads_emulation_gs(const nir_shader_compiler_options *options,
|
|||
/* Create input/output variables. */
|
||||
nir_foreach_shader_out_variable(var, prev_stage) {
|
||||
assert(!var->data.patch);
|
||||
assert(var->data.location != VARYING_SLOT_PRIMITIVE_ID &&
|
||||
"not a VS output");
|
||||
|
||||
/* input vars can't be created for those */
|
||||
if (var->data.location == VARYING_SLOT_LAYER ||
|
||||
|
|
@ -1132,6 +1135,30 @@ zink_create_quads_emulation_gs(const nir_shader_compiler_options *options,
|
|||
out_vars[num_vars++] = out;
|
||||
}
|
||||
|
||||
/* When a geometry shader is not used, a fragment shader may read primitive
|
||||
* ID and get an implicit value without the vertex shader writing an ID. This
|
||||
* case needs to work even when we inject a GS internally.
|
||||
*
|
||||
* However, if a geometry shader precedes a fragment shader that reads
|
||||
* primitive ID, Vulkan requires that the geometry shader write primitive ID.
|
||||
* To handle this case correctly, we must write primitive ID, copying the
|
||||
* fixed-function gl_PrimitiveIDIn input which matches what the fragment
|
||||
* shader will expect.
|
||||
*
|
||||
* If the fragment shader doesn't read primitive ID, this copy will likely be
|
||||
* optimized out at link-time by the Vulkan driver. Unless this is
|
||||
* non-monolithic -- in which case we don't know whether the fragment shader
|
||||
* will read primitive ID either. In both cases, the right thing for Zink
|
||||
* to do is copy primitive ID unconditionally.
|
||||
*/
|
||||
in_vars[num_vars] = nir_create_variable_with_location(
|
||||
nir, nir_var_shader_in, VARYING_SLOT_PRIMITIVE_ID, glsl_int_type());
|
||||
|
||||
out_vars[num_vars] = nir_create_variable_with_location(
|
||||
nir, nir_var_shader_out, VARYING_SLOT_PRIMITIVE_ID, glsl_int_type());
|
||||
|
||||
num_vars++;
|
||||
|
||||
int mapping_first[] = {0, 1, 2, 0, 2, 3};
|
||||
int mapping_last[] = {0, 1, 3, 1, 2, 3};
|
||||
nir_def *last_pv_vert_def = nir_load_provoking_last(&b);
|
||||
|
|
@ -1146,7 +1173,12 @@ zink_create_quads_emulation_gs(const nir_shader_compiler_options *options,
|
|||
if (in_vars[j]->data.location == VARYING_SLOT_EDGE) {
|
||||
continue;
|
||||
}
|
||||
nir_deref_instr *in_value = nir_build_deref_array(&b, nir_build_deref_var(&b, in_vars[j]), idx);
|
||||
|
||||
/* gl_PrimitiveIDIn is not arrayed, all other inputs are */
|
||||
nir_deref_instr *in_value = nir_build_deref_var(&b, in_vars[j]);
|
||||
if (in_vars[j]->data.location != VARYING_SLOT_PRIMITIVE_ID)
|
||||
in_value = nir_build_deref_array(&b, in_value, idx);
|
||||
|
||||
copy_vars(&b, nir_build_deref_var(&b, out_vars[j]), in_value);
|
||||
}
|
||||
nir_emit_vertex(&b, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue