radeonsi: move default tess level constant buffer to RW buffers
authorMarek Olšák <marek.olsak@amd.com>
Tue, 19 Apr 2016 00:09:55 +0000 (02:09 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 21 Apr 2016 23:14:14 +0000 (01:14 +0200)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 57bc7d3eb8aa178b6381fea25dbba51be74e0ea1..e6a4f3d28e3e029b8b17b36635059478446be50b 100644 (file)
@@ -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;
index 857a6829e017bafdbef78151ef5b7cbbf3626b0b..0470890be7f901357651d86aba8ac6d730eb053a 100644 (file)
@@ -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
index 2e488fe089eb0a40b18b92cad4daa5e2f21e6cba..3f74176d04110df4ad404c1c313aa08fe57f2278 100644 (file)
@@ -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);
 }
 
index 2b566bf25a0322f3b81139df25c06c360e34518f..80a5983f2ef25b3794554673bb73a178a5188f33 100644 (file)
@@ -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,
index 5c923cb80c1e573294e99db4bd0cd7c992a7979c..d02ce8f74dd5b13871a09943def4c21a66462391 100644 (file)
@@ -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 =