summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2016-07-19 20:35:26 -0700
committerFrancisco Jerez <currojerez@riseup.net>2016-08-25 18:33:29 -0700
commitaee3d8f0d940a87dba7eae86c9462a3cb3a7d702 (patch)
tree5cce8b0be6675e7d841f183dc12f64fb674d4040 /src/compiler/nir
parent97ac3eba58a7d11e171475f4a209cfdb3578b21d (diff)
downloadexternal_mesa3d-aee3d8f0d940a87dba7eae86c9462a3cb3a7d702.tar.gz
external_mesa3d-aee3d8f0d940a87dba7eae86c9462a3cb3a7d702.tar.bz2
external_mesa3d-aee3d8f0d940a87dba7eae86c9462a3cb3a7d702.zip
nir: Handle FB fetch outputs correctly in nir_lower_io_to_temporaries.
This requires emitting a series of copies at the top of the program from each output variable to the corresponding temporary. The initial copy can be skipped for non-framebuffer fetch outputs whose initial value is undefined, and the final copy needs to be skipped for read-only outputs (i.e. gl_LastFragData), since it would be illegal to emit a store output intrinsic for it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_lower_io_to_temporaries.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c
index 3153a49b7b..c8f94ff6eb 100644
--- a/src/compiler/nir/nir_lower_io_to_temporaries.c
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c
@@ -49,6 +49,21 @@ emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *new_vars,
nir_variable *newv = exec_node_data(nir_variable, new_node, node);
nir_variable *temp = exec_node_data(nir_variable, old_node, node);
+ /* No need to copy the contents of a non-fb_fetch_output output variable
+ * to the temporary allocated for it, since its initial value is
+ * undefined.
+ */
+ if (temp->data.mode == nir_var_shader_out &&
+ !temp->data.fb_fetch_output)
+ continue;
+
+ /* Can't copy the contents of the temporary back to a read-only
+ * interface variable. The value of the temporary won't have been
+ * modified by the shader anyway.
+ */
+ if (newv->data.read_only)
+ continue;
+
nir_intrinsic_instr *copy =
nir_intrinsic_instr_create(shader, nir_intrinsic_copy_var);
copy->variables[0] = nir_deref_var_create(copy, newv);
@@ -79,6 +94,10 @@ emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl)
}
}
} else if (impl->function == state->entrypoint) {
+ nir_cursor cursor = nir_before_block(nir_start_block(impl));
+ emit_copies(cursor, state->shader, &state->old_outputs,
+ &state->shader->outputs);
+
/* For all other shader types, we need to do the copies right before
* the jumps to the end block.
*/
@@ -121,6 +140,8 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var)
const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out";
temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name);
temp->data.mode = nir_var_global;
+ temp->data.read_only = false;
+ temp->data.fb_fetch_output = false;
temp->constant_initializer = NULL;
return nvar;