summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.c8
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.h39
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c7
3 files changed, 29 insertions, 25 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 88fc0400a83..3aa271ea832 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -570,11 +570,14 @@ static void si_alpha_test(struct lp_build_tgsi_context *bld_base,
if (si_shader_ctx->shader->key.ps.alpha_func != PIPE_FUNC_NEVER) {
LLVMValueRef out_ptr = si_shader_ctx->radeon_bld.soa.outputs[index][3];
+ LLVMValueRef alpha_ref = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn,
+ SI_PARAM_ALPHA_REF);
+
LLVMValueRef alpha_pass =
lp_build_cmp(&bld_base->base,
si_shader_ctx->shader->key.ps.alpha_func,
LLVMBuildLoad(gallivm->builder, out_ptr, ""),
- lp_build_const_float(gallivm, si_shader_ctx->shader->key.ps.alpha_ref));
+ alpha_ref);
LLVMValueRef arg =
lp_build_select(&bld_base->base,
alpha_pass,
@@ -1569,7 +1572,7 @@ static void create_function(struct si_shader_context *si_shader_ctx)
{
struct lp_build_tgsi_context *bld_base = &si_shader_ctx->radeon_bld.soa.bld_base;
struct gallivm_state *gallivm = bld_base->base.gallivm;
- LLVMTypeRef params[20], f32, i8, i32, v2i32, v3i32;
+ LLVMTypeRef params[21], f32, i8, i32, v2i32, v3i32;
unsigned i, last_sgpr, num_params;
i8 = LLVMInt8TypeInContext(gallivm->context);
@@ -1614,6 +1617,7 @@ static void create_function(struct si_shader_context *si_shader_ctx)
break;
case TGSI_PROCESSOR_FRAGMENT:
+ params[SI_PARAM_ALPHA_REF] = f32;
params[SI_PARAM_PRIM_MASK] = i32;
last_sgpr = SI_PARAM_PRIM_MASK;
params[SI_PARAM_PERSP_SAMPLE] = v2i32;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index 1db8bb8d8ee..c9e851a899c 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -37,9 +37,10 @@
#define SI_SGPR_VERTEX_BUFFER 6 /* VS only */
#define SI_SGPR_SO_BUFFER 8 /* VS only, stream-out */
#define SI_SGPR_START_INSTANCE 10 /* VS only */
+#define SI_SGPR_ALPHA_REF 6 /* PS only */
#define SI_VS_NUM_USER_SGPR 11
-#define SI_PS_NUM_USER_SGPR 6
+#define SI_PS_NUM_USER_SGPR 7
/* LLVM function parameter indices */
#define SI_PARAM_CONST 0
@@ -53,23 +54,24 @@
/* the other VS parameters are assigned dynamically */
/* PS only parameters */
-#define SI_PARAM_PRIM_MASK 3
-#define SI_PARAM_PERSP_SAMPLE 4
-#define SI_PARAM_PERSP_CENTER 5
-#define SI_PARAM_PERSP_CENTROID 6
-#define SI_PARAM_PERSP_PULL_MODEL 7
-#define SI_PARAM_LINEAR_SAMPLE 8
-#define SI_PARAM_LINEAR_CENTER 9
-#define SI_PARAM_LINEAR_CENTROID 10
-#define SI_PARAM_LINE_STIPPLE_TEX 11
-#define SI_PARAM_POS_X_FLOAT 12
-#define SI_PARAM_POS_Y_FLOAT 13
-#define SI_PARAM_POS_Z_FLOAT 14
-#define SI_PARAM_POS_W_FLOAT 15
-#define SI_PARAM_FRONT_FACE 16
-#define SI_PARAM_ANCILLARY 17
-#define SI_PARAM_SAMPLE_COVERAGE 18
-#define SI_PARAM_POS_FIXED_PT 19
+#define SI_PARAM_ALPHA_REF 3
+#define SI_PARAM_PRIM_MASK 4
+#define SI_PARAM_PERSP_SAMPLE 5
+#define SI_PARAM_PERSP_CENTER 6
+#define SI_PARAM_PERSP_CENTROID 7
+#define SI_PARAM_PERSP_PULL_MODEL 8
+#define SI_PARAM_LINEAR_SAMPLE 9
+#define SI_PARAM_LINEAR_CENTER 10
+#define SI_PARAM_LINEAR_CENTROID 11
+#define SI_PARAM_LINE_STIPPLE_TEX 12
+#define SI_PARAM_POS_X_FLOAT 13
+#define SI_PARAM_POS_Y_FLOAT 14
+#define SI_PARAM_POS_Z_FLOAT 15
+#define SI_PARAM_POS_W_FLOAT 16
+#define SI_PARAM_FRONT_FACE 17
+#define SI_PARAM_ANCILLARY 18
+#define SI_PARAM_SAMPLE_COVERAGE 19
+#define SI_PARAM_POS_FIXED_PT 20
struct si_shader_io {
unsigned name;
@@ -124,7 +126,6 @@ union si_shader_key {
unsigned alpha_func:3;
unsigned flatshade:1;
unsigned alpha_to_one:1;
- float alpha_ref;
} ps;
struct {
unsigned instance_divisors[PIPE_MAX_ATTRIBS];
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 3e771b297be..da7c3d0ab0c 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -744,6 +744,9 @@ static void *si_create_dsa_state(struct pipe_context *ctx,
if (state->alpha.enabled) {
dsa->alpha_func = state->alpha.func;
dsa->alpha_ref = state->alpha.ref_value;
+
+ si_pm4_set_reg(pm4, R_00B030_SPI_SHADER_USER_DATA_PS_0 +
+ SI_SGPR_ALPHA_REF * 4, fui(dsa->alpha_ref));
} else {
dsa->alpha_func = PIPE_FUNC_ALWAYS;
}
@@ -2116,10 +2119,6 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
rctx->framebuffer.cbufs[0] &&
util_format_is_pure_integer(rctx->framebuffer.cbufs[0]->texture->format))
key->ps.alpha_func = PIPE_FUNC_ALWAYS;
-
- if (key->ps.alpha_func != PIPE_FUNC_ALWAYS &&
- key->ps.alpha_func != PIPE_FUNC_NEVER)
- key->ps.alpha_ref = rctx->queued.named.dsa->alpha_ref;
} else {
key->ps.alpha_func = PIPE_FUNC_ALWAYS;
}