[Mesa-dev] [PATCH 04/16] radeonsi: Generalize counting of shader parameters
Michel Dänzer
michel at daenzer.net
Fri Jan 24 01:33:16 PST 2014
From: Michel Dänzer <michel.daenzer at amd.com>
Now it covers ES->GS as well as VS->PS.
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/gallium/drivers/radeonsi/si_shader.c | 82 ++++++++++++++++------------
src/gallium/drivers/radeonsi/si_shader.h | 2 +-
src/gallium/drivers/radeonsi/si_state_draw.c | 2 +-
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 4bdf5df..62ebf13 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -166,6 +166,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,
@@ -235,7 +263,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(
@@ -246,6 +279,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);
@@ -290,7 +324,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 */
@@ -380,7 +415,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);
@@ -459,7 +494,7 @@ static void declare_input_fs(
"");
}
- shader->ninterp++;
+ shader->nparam++;
} else if (decl->Semantic.Name == TGSI_SEMANTIC_FOG) {
LLVMValueRef args[4];
@@ -951,34 +986,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,
@@ -1895,9 +1902,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);
+ }
}
}
@@ -2429,7 +2439,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 19bad44..3299906 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 8392fdb..3fc5074 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -315,7 +315,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);
--
1.8.5.3
More information about the mesa-dev
mailing list