radeonsi: Handle TGSI_SEMANTIC_PRIMID
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 9 Jan 2014 03:55:26 +0000 (12:55 +0900)
committerMichel Dänzer <michel@daenzer.net>
Wed, 29 Jan 2014 02:07:11 +0000 (11:07 +0900)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_draw.c

index 42a3fc6a73b778509ae105c7215e564c2f3dcff0..6788255f62b9850b0aa3f6569c4afefd8d1b7eff 100644 (file)
@@ -169,6 +169,7 @@ static int si_store_shader_io_attribs(struct si_shader *shader,
                assert(i < Elements(shader->input));
                shader->input[i].name = d->Semantic.Name;
                shader->input[i].sid = d->Semantic.Index;
+               shader->input[i].index = d->Range.First;
                shader->input[i].interpolate = d->Interp.Interpolate;
                shader->input[i].centroid = d->Interp.Centroid;
                return -1;
@@ -258,7 +259,9 @@ static void declare_input_gs(
        struct si_shader *shader = &si_shader_ctx->shader->shader;
 
        si_store_shader_io_attribs(shader, decl);
-       shader->input[input_index].param_offset = shader->nparam++;
+
+       if (decl->Semantic.Name != TGSI_SEMANTIC_PRIMID)
+               shader->input[input_index].param_offset = shader->nparam++;
 }
 
 static LLVMValueRef fetch_input_gs(
@@ -279,6 +282,15 @@ static LLVMValueRef fetch_input_gs(
        LLVMValueRef args[9];
        unsigned vtx_offset_param;
 
+       if (swizzle != ~0 &&
+           shader->input[reg->Register.Index].name == TGSI_SEMANTIC_PRIMID) {
+               if (swizzle == 0)
+                       return LLVMGetParam(si_shader_ctx->radeon_bld.main_fn,
+                                           SI_PARAM_PRIMITIVE_ID);
+               else
+                       return uint->zero;
+       }
+
        if (!reg->Register.Dimension)
                return NULL;
 
@@ -1040,6 +1052,7 @@ handle_semantic:
                case TGSI_SEMANTIC_CLIPVERTEX:
                        si_llvm_emit_clipvertex(bld_base, pos_args, outputs[i].values);
                        continue;
+               case TGSI_SEMANTIC_PRIMID:
                case TGSI_SEMANTIC_FOG:
                case TGSI_SEMANTIC_GENERIC:
                        target = V_008DFC_SQ_EXP_PARAM + param_count;
index 32999066cc5ebe58470dfa79b3a3156ecf1d66b2..d11d34646ac0c79c0bc259b5e3edfca1ed1782c0 100644 (file)
@@ -93,6 +93,7 @@ struct si_shader_input {
        unsigned                name;
        int                     sid;
        unsigned                param_offset;
+       unsigned                index;
        unsigned                interpolate;
        bool                    centroid;
 };
index 66b7ef3e04638b02a14cf8ada29ddd888f662241..e770edd7f45b57880a739f80717b7a2421c02060 100644 (file)
@@ -122,7 +122,7 @@ static void si_pipe_shader_gs(struct pipe_context *ctx, struct si_pipe_shader *s
        si_pm4_set_reg(pm4, R_028A68_VGT_GSVS_RING_OFFSET_3, gsvs_itemsize);
 
        si_pm4_set_reg(pm4, R_028AAC_VGT_ESGS_RING_ITEMSIZE,
-                      shader->shader.ninput * (16 >> 2));
+                      shader->shader.nparam * (16 >> 2));
        si_pm4_set_reg(pm4, R_028AB0_VGT_GSVS_RING_ITEMSIZE, gsvs_itemsize);
 
        si_pm4_set_reg(pm4, R_028B38_VGT_GS_MAX_VERT_OUT, gs_max_vert_out);