[Mesa-dev] [PATCH] spirv/nir: Fix the stream ID when emitting a primitive or vertex

Neil Roberts nroberts at igalia.com
Mon Jan 22 15:38:19 UTC 2018


According to the SPIR-V spec:

“Stream must be an <id> of a constant instruction with a scalar
 integer type. That constant is the output-primitive stream number.”

The previous code was treating it as an integer literal.
---

This is part of the GL SPIR-V branch to enable streams for transform
feedback but seeing as it is a standalone fix for existing code I
thought it might be worth posting seperately.

 src/compiler/spirv/spirv_to_nir.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index c6df764682e..c71ed51e4cf 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2983,8 +2983,12 @@ vtn_handle_barrier(struct vtn_builder *b, SpvOp opcode,
    nir_intrinsic_instr *intrin =
       nir_intrinsic_instr_create(b->shader, intrinsic_op);
 
-   if (opcode == SpvOpEmitStreamVertex || opcode == SpvOpEndStreamPrimitive)
-      nir_intrinsic_set_stream_id(intrin, w[1]);
+   if (opcode == SpvOpEmitStreamVertex || opcode == SpvOpEndStreamPrimitive) {
+      struct vtn_value *stream_value =
+         vtn_value(b, w[1], vtn_value_type_constant);
+      unsigned stream = stream_value->constant->values[0].u32[0];
+      nir_intrinsic_set_stream_id(intrin, stream);
+   }
 
    nir_builder_instr_insert(&b->nb, &intrin->instr);
 }
-- 
2.14.3



More information about the mesa-dev mailing list