From 3c4e28cdf4acdccda04510dbc91f9e61e7e0abba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Tue, 28 Mar 2023 19:07:22 +0300 Subject: [PATCH] anv: use primitive ID override when shader does not supply it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch moves over this fix from iris driver. Fixes following test on DG2: dEQP-VK.rasterization.culling.primitive_id Cc: mesa-stable Signed-off-by: Tapani Pälli Reviewed-by: Ivan Briano [v1] Reviewed-by: Lionel Landwerlin Part-of: (cherry picked from commit ca4ec49b0e0f51a3245c924ab50379673f11abfb) --- .pick_status.json | 2 +- src/intel/vulkan/genX_pipeline.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index fc5b7e2e637..ee7c8b29c85 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3208,7 +3208,7 @@ "description": "anv: use primitive ID override when shader does not supply it", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index 7a69ae5059e..b2d7ff55a06 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -498,6 +498,19 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline) sbe.VertexURBEntryReadLength = DIV_ROUND_UP(max_source_attr + 1, 2); sbe.ForceVertexURBEntryReadOffset = true; sbe.ForceVertexURBEntryReadLength = true; + + /* Ask the hardware to supply PrimitiveID if the fragment shader + * reads it but a previous stage didn't write one. + */ + if ((wm_prog_data->inputs & VARYING_BIT_PRIMITIVE_ID) && + fs_input_map->varying_to_slot[VARYING_SLOT_PRIMITIVE_ID] == -1) { + sbe.PrimitiveIDOverrideAttributeSelect = + wm_prog_data->urb_setup[VARYING_SLOT_PRIMITIVE_ID]; + sbe.PrimitiveIDOverrideComponentX = true; + sbe.PrimitiveIDOverrideComponentY = true; + sbe.PrimitiveIDOverrideComponentZ = true; + sbe.PrimitiveIDOverrideComponentW = true; + } } else { assert(anv_pipeline_is_mesh(pipeline)); #if GFX_VERx10 >= 125