summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-06-01 18:46:30 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2016-06-03 19:29:28 -0700
commit3fb289f957a8a27349a6f7df03983f92d9b6cf64 (patch)
tree79ec3a842d02baf688927291277c5d45f7249358
parent4d3b8318a714c470d12636a41b08bd60688f6c3b (diff)
i965/fs Add a wm_prog_data bit for has_side_effects
This is more accurate than calling _mesa_active_fragment_shader_has_side_effects because it looks at whether or not the SSBOs, images, or atomic buffers are actually written rather than just existing in the program. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Cc: "12.0" <mesa-stable@lists.freedesktop.org>
-rw-r--r--src/mesa/drivers/dri/i965/brw_compiler.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_nir.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h b/src/mesa/drivers/dri/i965/brw_compiler.h
index 6e6d20c7d3..f55b7f37ff 100644
--- a/src/mesa/drivers/dri/i965/brw_compiler.h
+++ b/src/mesa/drivers/dri/i965/brw_compiler.h
@@ -402,6 +402,7 @@ struct brw_wm_prog_data {
bool uses_src_depth;
bool uses_src_w;
bool uses_sample_mask;
+ bool has_side_effects;
bool pulls_bary;
/**
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 7fc43b5061..a4e5559a36 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -3331,6 +3331,10 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
case nir_intrinsic_atomic_counter_inc:
case nir_intrinsic_atomic_counter_dec:
case nir_intrinsic_atomic_counter_read: {
+ if (stage == MESA_SHADER_FRAGMENT &&
+ instr->intrinsic != nir_intrinsic_atomic_counter_read)
+ ((struct brw_wm_prog_data *)prog_data)->has_side_effects = true;
+
/* Get the arguments of the atomic intrinsic. */
const fs_reg offset = get_nir_src(instr->src[0]);
const unsigned surface = (stage_prog_data->binding_table.abo_start +
@@ -3377,6 +3381,10 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
case nir_intrinsic_image_atomic_comp_swap: {
using namespace image_access;
+ if (stage == MESA_SHADER_FRAGMENT &&
+ instr->intrinsic != nir_intrinsic_image_load)
+ ((struct brw_wm_prog_data *)prog_data)->has_side_effects = true;
+
/* Get the referenced image variable and type. */
const nir_variable *var = instr->variables[0]->var;
const glsl_type *type = var->type->without_array();
@@ -3690,6 +3698,9 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
case nir_intrinsic_store_ssbo: {
assert(devinfo->gen >= 7);
+ if (stage == MESA_SHADER_FRAGMENT)
+ ((struct brw_wm_prog_data *)prog_data)->has_side_effects = true;
+
/* Block index */
fs_reg surf_index;
nir_const_value *const_uniform_block =
@@ -3893,6 +3904,9 @@ void
fs_visitor::nir_emit_ssbo_atomic(const fs_builder &bld,
int op, nir_intrinsic_instr *instr)
{
+ if (stage == MESA_SHADER_FRAGMENT)
+ ((struct brw_wm_prog_data *)prog_data)->has_side_effects = true;
+
fs_reg dest;
if (nir_intrinsic_infos[instr->intrinsic].has_dest)
dest = get_nir_dest(instr->dest);