aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-10-03 16:22:58 -0400
committerErik Faye-Lund <[email protected]>2019-10-17 10:41:36 +0200
commit6d7e02e37da5335d2be11ca1d4bfa002e73c5770 (patch)
tree11ec3d42693df45d342601ad70a9d28c4dd31b1f /src/compiler
parentfdc4450c285d21251a6a1de3f0765a934ea0567c (diff)
nir: allow passing alpha-ref state to lowering-code
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h3
-rw-r--r--src/compiler/nir/nir_lower_alpha_test.c21
2 files changed, 20 insertions, 4 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index fd7f3635cbe..3732b038630 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3683,7 +3683,8 @@ bool nir_lower_constant_initializers(nir_shader *shader,
bool nir_move_vec_src_uses_to_dest(nir_shader *shader);
bool nir_lower_vec_to_movs(nir_shader *shader);
void nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
- bool alpha_to_one);
+ bool alpha_to_one,
+ const gl_state_index16 *alpha_ref_state_tokens);
bool nir_lower_alu(nir_shader *shader);
bool nir_lower_flrp(nir_shader *shader, unsigned lowering_mask,
diff --git a/src/compiler/nir/nir_lower_alpha_test.c b/src/compiler/nir/nir_lower_alpha_test.c
index ddd815765bd..b652fb796be 100644
--- a/src/compiler/nir/nir_lower_alpha_test.c
+++ b/src/compiler/nir/nir_lower_alpha_test.c
@@ -37,7 +37,8 @@
void
nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
- bool alpha_to_one)
+ bool alpha_to_one,
+ const gl_state_index16 *alpha_ref_state_tokens)
{
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
@@ -93,9 +94,23 @@ nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
3);
}
+ nir_ssa_def *alpha_ref;
+ if (alpha_ref_state_tokens) {
+ nir_variable *var = nir_variable_create(shader,
+ nir_var_uniform,
+ glsl_float_type(),
+ "gl_AlphaRefMESA");
+ var->num_state_slots = 1;
+ var->state_slots = ralloc_array(var, nir_state_slot, 1);
+ memcpy(var->state_slots[0].tokens,
+ alpha_ref_state_tokens,
+ sizeof(var->state_slots[0].tokens));
+ alpha_ref = nir_load_var(&b, var);
+ } else
+ alpha_ref = nir_load_alpha_ref_float(&b);
+
nir_ssa_def *condition =
- nir_compare_func(&b, func,
- alpha, nir_load_alpha_ref_float(&b));
+ nir_compare_func(&b, func, alpha, alpha_ref);
nir_intrinsic_instr *discard =
nir_intrinsic_instr_create(b.shader,