aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2019-10-03 16:51:03 -0400
committerErik Faye-Lund <[email protected]>2019-10-17 10:41:36 +0200
commit011d692a52b60bbbb73395e403bcb6c7cbe61a06 (patch)
tree30e41f7f7eb7af87c2ee4da41b46486105f527a6 /src/compiler
parent3b4fc2401bc71051ed0f4bae967d6f9405a315ab (diff)
nir: support derefs in two-sided lighting lowering
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_two_sided_color.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c
index d1eb32a1887..8fd0c0a264a 100644
--- a/src/compiler/nir/nir_lower_two_sided_color.c
+++ b/src/compiler/nir/nir_lower_two_sided_color.c
@@ -138,18 +138,28 @@ nir_lower_two_sided_color_block(nir_block *block,
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- if (intr->intrinsic != nir_intrinsic_load_input)
- continue;
-
int idx;
- for (idx = 0; idx < state->colors_count; idx++) {
- unsigned drvloc =
- state->colors[idx].front->data.driver_location;
- if (nir_intrinsic_base(intr) == drvloc) {
- assert(nir_src_is_const(intr->src[0]));
- break;
+ if (intr->intrinsic == nir_intrinsic_load_input) {
+ for (idx = 0; idx < state->colors_count; idx++) {
+ unsigned drvloc =
+ state->colors[idx].front->data.driver_location;
+ if (nir_intrinsic_base(intr) == drvloc) {
+ assert(nir_src_is_const(intr->src[0]));
+ break;
+ }
}
- }
+ } else if (intr->intrinsic == nir_intrinsic_load_deref) {
+ nir_variable *var = nir_intrinsic_get_var(intr, 0);
+ if (var->data.mode != nir_var_shader_in)
+ continue;
+
+ for (idx = 0; idx < state->colors_count; idx++) {
+ unsigned loc = state->colors[idx].front->data.location;
+ if (var->data.location == loc)
+ break;
+ }
+ } else
+ continue;
if (idx == state->colors_count)
continue;
@@ -162,8 +172,14 @@ nir_lower_two_sided_color_block(nir_block *block,
* 32-bit value by default.
*/
nir_ssa_def *face = nir_load_front_face(b, 1);
- nir_ssa_def *front = load_input(b, state->colors[idx].front);
- nir_ssa_def *back = load_input(b, state->colors[idx].back);
+ nir_ssa_def *front, *back;
+ if (intr->intrinsic == nir_intrinsic_load_deref) {
+ front = nir_load_var(b, state->colors[idx].front);
+ back = nir_load_var(b, state->colors[idx].back);
+ } else {
+ front = load_input(b, state->colors[idx].front);
+ back = load_input(b, state->colors[idx].back);
+ }
nir_ssa_def *color = nir_bcsel(b, face, front, back);
assert(intr->dest.is_ssa);