From 9ce92fa036c56bb8270b49b9d2eb76df4eb5e93d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 25 Aug 2018 00:11:24 -0700 Subject: [PATCH] iris: Skip primitive ID overrides if the shader wrote a custom value Fixes glsl-1.50/execution/geometry/primitive-id-out --- src/gallium/drivers/iris/iris_state.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index b9fbed8abba..5f17b067a58 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -2400,6 +2400,7 @@ iris_emit_sbe_swiz(struct iris_batch *batch, struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) *attr = &attr_overrides[input_index]; + int slot = vue_map->varying_to_slot[fs_attr]; /* Viewport and Layer are stored in the VUE header. We need to override * them to zero if earlier stages didn't write them, as GL requires that @@ -2419,12 +2420,15 @@ iris_emit_sbe_swiz(struct iris_batch *batch, continue; case VARYING_SLOT_PRIMITIVE_ID: - attr->ComponentOverrideX = true; - attr->ComponentOverrideY = true; - attr->ComponentOverrideZ = true; - attr->ComponentOverrideW = true; - attr->ConstantSource = PRIM_ID; - continue; + /* Override if the previous shader stage didn't write gl_PrimitiveID. */ + if (slot == -1) { + attr->ComponentOverrideX = true; + attr->ComponentOverrideY = true; + attr->ComponentOverrideZ = true; + attr->ComponentOverrideW = true; + attr->ConstantSource = PRIM_ID; + continue; + } default: break; @@ -2433,8 +2437,6 @@ iris_emit_sbe_swiz(struct iris_batch *batch, if (sprite_coord_enables & (1 << input_index)) continue; - int slot = vue_map->varying_to_slot[fs_attr]; - /* If there was only a back color written but not front, use back * as the color instead of undefined. */ -- 2.30.2