aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2014-01-09 15:33:34 +0900
committerMichel Dänzer <[email protected]>2014-01-29 11:06:58 +0900
commit7c7d7380f13d5863de846fef60d80ad13836634e (patch)
treec4f7feb50d9d2f51bcafc3d93c299b350257f592 /src/gallium
parentf07a96dad1c6ad802ef11efb213ee3984646fbab (diff)
radeonsi: Generalize counting of shader parameters
Now it covers ES->GS as well as VS->PS. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c82
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_state_draw.c2
3 files changed, 48 insertions, 38 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 8696d03ca92..42a3fc6a73b 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -158,6 +158,34 @@ static LLVMValueRef get_instance_index_for_fetch(
return result;
}
+static int si_store_shader_io_attribs(struct si_shader *shader,
+ const struct tgsi_full_declaration *d)
+{
+ int i = -1;
+
+ switch (d->Declaration.File) {
+ case TGSI_FILE_INPUT:
+ i = shader->ninput++;
+ assert(i < Elements(shader->input));
+ shader->input[i].name = d->Semantic.Name;
+ shader->input[i].sid = d->Semantic.Index;
+ shader->input[i].interpolate = d->Interp.Interpolate;
+ shader->input[i].centroid = d->Interp.Centroid;
+ return -1;
+
+ case TGSI_FILE_OUTPUT:
+ i = shader->noutput++;
+ assert(i < Elements(shader->output));
+ shader->output[i].name = d->Semantic.Name;
+ shader->output[i].sid = d->Semantic.Index;
+ shader->output[i].index = d->Range.First;
+ shader->output[i].usage = d->Declaration.UsageMask;
+ break;
+ }
+
+ return i;
+}
+
static void declare_input_vs(
struct radeon_llvm_context *radeon_bld,
unsigned input_index,
@@ -225,7 +253,12 @@ static void declare_input_gs(
unsigned input_index,
const struct tgsi_full_declaration *decl)
{
- /* Nothing to do, inputs are handled in fetch_input_gs() below */
+ struct si_shader_context *si_shader_ctx =
+ si_shader_context(&radeon_bld->soa.bld_base);
+ struct si_shader *shader = &si_shader_ctx->shader->shader;
+
+ si_store_shader_io_attribs(shader, decl);
+ shader->input[input_index].param_offset = shader->nparam++;
}
static LLVMValueRef fetch_input_gs(
@@ -236,6 +269,7 @@ static LLVMValueRef fetch_input_gs(
{
struct lp_build_context *base = &bld_base->base;
struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
+ struct si_shader *shader = &si_shader_ctx->shader->shader;
struct lp_build_context *uint = &si_shader_ctx->radeon_bld.soa.bld_base.uint_bld;
struct gallivm_state *gallivm = base->gallivm;
LLVMTypeRef i32 = LLVMInt32TypeInContext(gallivm->context);
@@ -280,7 +314,8 @@ static LLVMValueRef fetch_input_gs(
args[0] = t_list;
args[1] = vtx_offset;
args[2] = lp_build_const_int32(gallivm,
- ((reg->Register.Index * 4) + swizzle) * 256);
+ ((shader->input[reg->Register.Index].param_offset * 4) +
+ swizzle) * 256);
args[3] = uint->zero;
args[4] = uint->one; /* OFFEN */
args[5] = uint->zero; /* IDXEN */
@@ -368,7 +403,7 @@ static void declare_input_fs(
return;
}
- shader->input[input_index].param_offset = shader->ninterp++;
+ shader->input[input_index].param_offset = shader->nparam++;
attr_number = lp_build_const_int32(gallivm,
shader->input[input_index].param_offset);
@@ -447,7 +482,7 @@ static void declare_input_fs(
"");
}
- shader->ninterp++;
+ shader->nparam++;
} else if (decl->Semantic.Name == TGSI_SEMANTIC_FOG) {
LLVMValueRef args[4];
@@ -939,34 +974,6 @@ static void si_llvm_emit_streamout(struct si_shader_context *shader)
}
-static int si_store_shader_io_attribs(struct si_shader *shader,
- struct tgsi_full_declaration *d)
-{
- int i = -1;
-
- switch (d->Declaration.File) {
- case TGSI_FILE_INPUT:
- i = shader->ninput++;
- assert(i < Elements(shader->input));
- shader->input[i].name = d->Semantic.Name;
- shader->input[i].sid = d->Semantic.Index;
- shader->input[i].interpolate = d->Interp.Interpolate;
- shader->input[i].centroid = d->Interp.Centroid;
- return -1;
-
- case TGSI_FILE_OUTPUT:
- i = shader->noutput++;
- assert(i < Elements(shader->output));
- shader->output[i].name = d->Semantic.Name;
- shader->output[i].sid = d->Semantic.Index;
- shader->output[i].index = d->Range.First;
- shader->output[i].usage = d->Declaration.UsageMask;
- break;
- }
-
- return i;
-}
-
/* Generate export instructions for hardware VS shader stage */
static void si_llvm_export_vs(struct lp_build_tgsi_context *bld_base,
struct si_shader_output_values *outputs,
@@ -1877,9 +1884,12 @@ static void si_llvm_emit_vertex(
while (!tgsi_parse_end_of_tokens(parse)) {
tgsi_parse_token(parse);
- if (parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_DECLARATION)
- si_store_shader_io_attribs(shader,
- &parse->FullToken.FullDeclaration);
+ if (parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_DECLARATION) {
+ struct tgsi_full_declaration *d = &parse->FullToken.FullDeclaration;
+
+ if (d->Declaration.File == TGSI_FILE_OUTPUT)
+ si_store_shader_io_attribs(shader, d);
+ }
}
}
@@ -2397,7 +2407,7 @@ int si_pipe_shader_create(
bool dump = r600_can_dump_shader(&sctx->screen->b, shader->selector->tokens);
assert(shader->shader.noutput == 0);
- assert(shader->shader.ninterp == 0);
+ assert(shader->shader.nparam == 0);
assert(shader->shader.ninput == 0);
memset(&si_shader_ctx, 0, sizeof(si_shader_ctx));
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 19bad44c9e1..32999066cc5 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -136,7 +136,7 @@ struct si_shader {
unsigned gs_output_prim;
unsigned gs_max_out_vertices;
- unsigned ninterp;
+ unsigned nparam;
bool uses_kill;
bool uses_instanceid;
bool fs_write_all;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index c5a59750390..66b7ef3e046 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -287,7 +287,7 @@ static void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *s
exports_ps = 2;
}
- spi_ps_in_control = S_0286D8_NUM_INTERP(shader->shader.ninterp) |
+ spi_ps_in_control = S_0286D8_NUM_INTERP(shader->shader.nparam) |
S_0286D8_BC_OPTIMIZE_DISABLE(1);
si_pm4_set_reg(pm4, R_0286E0_SPI_BARYC_CNTL, spi_baryc_cntl);