Not sure this is 100% the correct way to do this, since it may be a change
at the glsl->tgsi level that is required, either way open discussions!

fixes piglit tests/spec/glsl-1.50/execution/geometry/primitive-id-in.shader_test
with llvmpipe with fake MSAA

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 5 +++++
 src/gallium/auxiliary/tgsi/tgsi_scan.c          | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 6d8dc8c..de2c64f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1173,6 +1173,10 @@ emit_fetch_gs_input(
    LLVMValueRef swizzle_index = lp_build_const_int32(gallivm, swizzle);
    LLVMValueRef res;
 
+   if (bld_base->info->input_semantic_name[reg->Register.Index] == 
TGSI_SEMANTIC_PRIMID) {
+      res = bld->system_values.prim_id;
+      goto out;
+   }
    if (reg->Register.Indirect) {
       attrib_index = get_indirect_index(bld,
                                         reg->Register.File,
@@ -1200,6 +1204,7 @@ emit_fetch_gs_input(
 
    assert(res);
 
+ out:
    if (stype == TGSI_TYPE_UNSIGNED) {
       res = LLVMBuildBitCast(builder, res, bld_base->uint_bld.vec_type, "");
    } else if (stype == TGSI_TYPE_SIGNED) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 0f10556..ce1f7b6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -198,6 +198,9 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                         info->uses_primid = TRUE;
                      else if (semName == TGSI_SEMANTIC_FACE)
                         info->uses_frontface = TRUE;
+                  } else if (procType == TGSI_PROCESSOR_GEOMETRY) {
+                     if (semName == TGSI_SEMANTIC_PRIMID)
+                        info->uses_primid = TRUE;
                   }
                }
                else if (file == TGSI_FILE_SYSTEM_VALUE) {
-- 
1.8.4.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to