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>
This commit is contained in:

committed by
Marge Bot

parent
845f5eca27
commit
23601d6632
@@ -633,7 +633,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
|
||||
@@ -681,5 +680,4 @@ 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
|
||||
spec@ext_framebuffer_multisample@interpolation 6 non-centroid-deriv-disabled,Fail
|
||||
|
@@ -557,9 +557,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,9 +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@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
|
||||
@@ -167,7 +166,3 @@ spec@ext_framebuffer_multisample@interpolation 8 non-centroid-disabled,Fail
|
||||
|
||||
# Regression noticed in https://gitlab.freedesktop.org/mesa/mesa/-/pipelines/891104
|
||||
spec@arb_viewport_array@display-list,Fail
|
||||
|
||||
# zink_create_quads_emulation_gs doesn't write primitive ID
|
||||
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/12214
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,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
|
||||
@@ -201,7 +200,3 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_yuv420,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_yvu420,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_yvyu,Fail
|
||||
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-transcode-nv12-as-r8-gr88,Fail
|
||||
|
||||
# zink_create_quads_emulation_gs doesn't write primitive ID
|
||||
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/12214
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,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
|
||||
@@ -598,7 +597,3 @@ spec@ext_texture_array@copyteximage 1d_array samples=2,Fail
|
||||
spec@ext_texture_array@copyteximage 1d_array samples=4,Fail
|
||||
spec@ext_texture_array@copyteximage 1d_array samples=6,Fail
|
||||
spec@ext_texture_array@copyteximage 1d_array samples=8,Fail
|
||||
|
||||
# zink_create_quads_emulation_gs doesn't write primitive ID
|
||||
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/12214
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,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
|
||||
@@ -170,7 +169,3 @@ spec@ext_framebuffer_multisample@interpolation 8 non-centroid-disabled,Fail
|
||||
|
||||
# Regression noticed in https://gitlab.freedesktop.org/mesa/mesa/-/pipelines/891104
|
||||
spec@arb_viewport_array@display-list,Fail
|
||||
|
||||
# zink_create_quads_emulation_gs doesn't write primitive ID
|
||||
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/12214
|
||||
spec@glsl-1.50@execution@primitive-id-no-gs-quads,Fail
|
||||
|
@@ -492,8 +492,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,8 +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@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);
|
||||
|
Reference in New Issue
Block a user