summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/radeonsi_shader.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2013-03-21 18:02:52 +0100
committerChristian König <[email protected]>2013-04-02 13:01:43 +0200
commite4ed58763ab6e948a20d6e66a54d10466dd0c4cc (patch)
tree1a4f36cbd62796526257d9a86297f0724193f205 /src/gallium/drivers/radeonsi/radeonsi_shader.c
parent83df955ca9f331965107c424c2e90f27e9161e3a (diff)
radeonsi: add instanceid support
Signed-off-by: Christian König <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Tested-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/radeonsi_shader.c')
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 840537a69b2..62f478e1300 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -141,7 +141,7 @@ static void declare_input_vs(
/* Load the buffer index, which is always stored in VGPR0
* for Vertex Shaders */
- buffer_index_reg = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, SI_PARAM_VERTEX_INDEX);
+ buffer_index_reg = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, SI_PARAM_VERTEX_ID);
vec4_type = LLVMVectorType(base->elem_type, 4);
args[0] = t_list;
@@ -346,6 +346,30 @@ static void declare_input(
}
}
+static void declare_system_value(
+ struct radeon_llvm_context * radeon_bld,
+ unsigned index,
+ const struct tgsi_full_declaration *decl)
+{
+ LLVMValueRef value = 0;
+
+ switch (decl->Semantic.Name) {
+ case TGSI_SEMANTIC_INSTANCEID:
+ value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_INSTANCE_ID);
+ break;
+
+ case TGSI_SEMANTIC_VERTEXID:
+ value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_VERTEX_ID);
+ break;
+
+ default:
+ assert(!"unknown system value");
+ return;
+ }
+
+ radeon_bld->system_values[index] = value;
+}
+
static LLVMValueRef fetch_constant(
struct lp_build_tgsi_context * bld_base,
const struct tgsi_full_src_register *reg,
@@ -939,8 +963,11 @@ static void create_function(struct si_shader_context *si_shader_ctx)
if (si_shader_ctx->type == TGSI_PROCESSOR_VERTEX) {
params[SI_PARAM_VERTEX_BUFFER] = params[SI_PARAM_SAMPLER];
- params[SI_PARAM_VERTEX_INDEX] = i32;
- radeon_llvm_create_func(&si_shader_ctx->radeon_bld, params, 5);
+ params[SI_PARAM_VERTEX_ID] = i32;
+ params[SI_PARAM_DUMMY_0] = i32;
+ params[SI_PARAM_DUMMY_1] = i32;
+ params[SI_PARAM_INSTANCE_ID] = i32;
+ radeon_llvm_create_func(&si_shader_ctx->radeon_bld, params, 8);
} else {
params[SI_PARAM_PRIM_MASK] = i32;
@@ -1064,6 +1091,7 @@ int si_pipe_shader_create(
tgsi_scan_shader(sel->tokens, &shader_info);
shader->shader.uses_kill = shader_info.uses_kill;
+ shader->shader.uses_instanceid = shader_info.uses_instanceid;
bld_base->info = &shader_info;
bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
bld_base->emit_epilogue = si_llvm_emit_epilogue;
@@ -1074,6 +1102,7 @@ int si_pipe_shader_create(
bld_base->op_actions[TGSI_OPCODE_TXP] = tex_action;
si_shader_ctx.radeon_bld.load_input = declare_input;
+ si_shader_ctx.radeon_bld.load_system_value = declare_system_value;
si_shader_ctx.tokens = sel->tokens;
tgsi_parse_init(&si_shader_ctx.parse, si_shader_ctx.tokens);
si_shader_ctx.shader = shader;