[Mesa-dev] [PATCH 07/10] radeonsi: move default tess level constant buffer to RW buffers
Marek Olšák
maraeo at gmail.com
Wed Apr 20 15:47:10 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/drivers/radeonsi/si_shader.c | 19 +++++++++++++++++++
src/gallium/drivers/radeonsi/si_shader.h | 6 ++++++
src/gallium/drivers/radeonsi/si_state.c | 4 ++--
src/gallium/drivers/radeonsi/si_state.h | 1 +
src/gallium/drivers/radeonsi/si_state_shaders.c | 15 +++++++--------
5 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index c3a9120..5f76560 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1280,6 +1280,25 @@ static void declare_system_value(
break;
}
+ case TGSI_SEMANTIC_DEFAULT_TESSOUTER_SI:
+ case TGSI_SEMANTIC_DEFAULT_TESSINNER_SI:
+ {
+ LLVMValueRef buf, slot, val[4];
+ int i, offset;
+
+ slot = lp_build_const_int32(gallivm, SI_HS_CONST_DEFAULT_TESS_LEVELS);
+ buf = LLVMGetParam(ctx->radeon_bld.main_fn, SI_PARAM_RW_BUFFERS);
+ buf = build_indexed_load_const(ctx, buf, slot);
+ offset = decl->Semantic.Name == TGSI_SEMANTIC_DEFAULT_TESSINNER_SI ? 4 : 0;
+
+ for (i = 0; i < 4; i++)
+ val[i] = buffer_load_const(gallivm->builder, buf,
+ lp_build_const_int32(gallivm, (offset + i) * 4),
+ ctx->f32);
+ value = lp_build_gather_values(gallivm, val, 4);
+ break;
+ }
+
case TGSI_SEMANTIC_PRIMID:
value = get_primitive_id(&radeon_bld->soa.bld_base, 0);
break;
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 6ea849d..a16e2a0 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -210,6 +210,12 @@ enum {
SI_NUM_PARAMS = SI_PARAM_POS_FIXED_PT + 9, /* +8 for COLOR[0..1] */
};
+/* SI-specific system values. */
+enum {
+ TGSI_SEMANTIC_DEFAULT_TESSOUTER_SI = TGSI_SEMANTIC_COUNT,
+ TGSI_SEMANTIC_DEFAULT_TESSINNER_SI,
+};
+
struct si_shader;
/* A shader selector is a gallium CSO and contains shader variants and
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 56f484a..5e9decc 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3395,8 +3395,8 @@ static void si_set_tess_state(struct pipe_context *ctx,
(void*)array, sizeof(array),
&cb.buffer_offset);
- ctx->set_constant_buffer(ctx, PIPE_SHADER_TESS_CTRL,
- SI_DRIVER_STATE_CONST_BUF, &cb);
+ si_set_constant_buffer(sctx, &sctx->rw_buffers,
+ SI_HS_CONST_DEFAULT_TESS_LEVELS, &cb);
pipe_resource_reference(&cb.buffer, NULL);
}
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index 159bdea..a961fbb 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -178,6 +178,7 @@ enum {
SI_VS_STREAMOUT_BUF2,
SI_VS_STREAMOUT_BUF3,
+ SI_HS_CONST_DEFAULT_TESS_LEVELS,
SI_VS_CONST_CLIP_PLANES,
SI_PS_CONST_POLY_STIPPLE,
SI_PS_CONST_SAMPLE_POSITIONS,
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 0318850..3bec4e9 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1804,7 +1804,7 @@ static void si_init_tess_factor_ring(struct si_context *sctx)
*/
static void si_generate_fixed_func_tcs(struct si_context *sctx)
{
- struct ureg_src const0, const1;
+ struct ureg_src outer, inner;
struct ureg_dst tessouter, tessinner;
struct ureg_program *ureg = ureg_create(TGSI_PROCESSOR_TESS_CTRL);
@@ -1813,17 +1813,16 @@ static void si_generate_fixed_func_tcs(struct si_context *sctx)
assert(!sctx->fixed_func_tcs_shader.cso);
- ureg_DECL_constant2D(ureg, 0, 1, SI_DRIVER_STATE_CONST_BUF);
- const0 = ureg_src_dimension(ureg_src_register(TGSI_FILE_CONSTANT, 0),
- SI_DRIVER_STATE_CONST_BUF);
- const1 = ureg_src_dimension(ureg_src_register(TGSI_FILE_CONSTANT, 1),
- SI_DRIVER_STATE_CONST_BUF);
+ outer = ureg_DECL_system_value(ureg,
+ TGSI_SEMANTIC_DEFAULT_TESSOUTER_SI, 0);
+ inner = ureg_DECL_system_value(ureg,
+ TGSI_SEMANTIC_DEFAULT_TESSINNER_SI, 0);
tessouter = ureg_DECL_output(ureg, TGSI_SEMANTIC_TESSOUTER, 0);
tessinner = ureg_DECL_output(ureg, TGSI_SEMANTIC_TESSINNER, 0);
- ureg_MOV(ureg, tessouter, const0);
- ureg_MOV(ureg, tessinner, const1);
+ ureg_MOV(ureg, tessouter, outer);
+ ureg_MOV(ureg, tessinner, inner);
ureg_END(ureg);
sctx->fixed_func_tcs_shader.cso =
--
2.5.0
More information about the mesa-dev
mailing list