anv: simplify SBE emission

Using 3DSTATE_SBE_SWIZ for providing the implicit PrimitiveID value
(when not written by the previous stage) seems to be the legacy way of
doing things on Gfx7 and prior.

On Gfx8+ we got this new
3DSTATE_SBE::PrimitiveIDOverrideAttributeSelect to get the HW to write
the value wherever we want.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36665>
This commit is contained in:
Lionel Landwerlin 2025-03-28 12:39:31 +02:00 committed by Marge Bot
parent 7b8a6af222
commit 33abaf2d0e

View file

@ -523,7 +523,7 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline)
*/
if (anv_pipeline_is_primitive(pipeline)) {
for (uint8_t idx = 0; idx < wm_prog_data->urb_setup_attribs_count; idx++) {
uint8_t attr = wm_prog_data->urb_setup_attribs[idx];
gl_varying_slot attr = wm_prog_data->urb_setup_attribs[idx];
int input_index = wm_prog_data->urb_setup[attr];
assert(0 <= input_index);
@ -534,22 +534,8 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline)
}
const int slot = vue_map->varying_to_slot[attr];
if (slot == -1) {
/* This attribute does not exist in the VUE--that means that
* the vertex shader did not write to it. It could be that it's
* a regular varying read by the fragment shader but not
* written by the vertex shader or it's gl_PrimitiveID. In the
* first case the value is undefined, in the second it needs to
* be gl_PrimitiveID.
*/
swiz.Attribute[input_index].ConstantSource = PRIM_ID;
swiz.Attribute[input_index].ComponentOverrideX = true;
swiz.Attribute[input_index].ComponentOverrideY = true;
swiz.Attribute[input_index].ComponentOverrideZ = true;
swiz.Attribute[input_index].ComponentOverrideW = true;
if (slot == -1)
continue;
}
/* We have to subtract two slots to account for the URB entry
* output read offset in the VS and GS stages.