<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 11, 2018 at 12:15 PM, Caio Marcelo de Oliveira Filho <span dir="ltr"><<a href="mailto:caio.oliveira@intel.com" target="_blank">caio.oliveira@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Gustavo Lima Chaves <<a href="mailto:gustavo.lima.chaves@intel.com">gustavo.lima.chaves@intel.com</a><wbr>><br>
<br>
v2:<br>
An attempt to support SpvExecutionModeStencilRefRepl<wbr>acingEXT's behavior<br>
also follows, with the interpretation to said mode being we prevent<br>
writes to the built-in FragStencilRefEXT variable when the execution<br>
mode isn't set.<br>
<br>
v3:<br>
A more cautious reading of 1db44252d01bf7539452ccc2b5210c<wbr>74b8dcd573 led<br>
me to a missing change that would stop (what I later discovered were)<br>
GPU hangs on the CTS test written to exercize this.<br>
<br>
v4:<br>
Turn FragStencilRefEXT decoration usage without StencilRefReplacingEXT<br>
mode into a warning, instead of trying to make the variable read-only.<br>
If we are to follow the originating extension on GL, the built-in<br>
variable in question should never be readable anyway.<br>
---<br>
<br>
This is the original patch from Gustavo Lima Chaves (v5 was another<br>
rebase), with some trivial changes to rebase.<br>
<br>
I'm updating the test on Vulkan CTS to make sure we have some coverage<br>
of this feature; so this should only land once that gets accepted, but<br>
is ready for review.<br>
<br>
src/compiler/shader_info.h | 2 ++<br>
src/compiler/spirv/spirv_to_<wbr>nir.c | 4 ++++<br>
src/compiler/spirv/vtn_<wbr>variables.c | 5 +++++<br>
src/intel/vulkan/anv_<wbr>extensions.py | 1 +<br>
src/intel/vulkan/anv_pipeline.<wbr>c | 1 +<br>
src/intel/vulkan/genX_<wbr>pipeline.c | 1 +<br>
6 files changed, 14 insertions(+)<br>
<br>
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h<br>
index 81f844d36ae..e9141261e8b 100644<br>
--- a/src/compiler/shader_info.h<br>
+++ b/src/compiler/shader_info.h<br>
@@ -180,6 +180,8 @@ typedef struct shader_info {<br>
<br>
bool pixel_center_integer;<br>
<br>
+ bool outputs_stencil;<br></blockquote><div><br></div><div>This isn't used by anything outside of spirv_to_nir so I don't think it makes sense in shader_info. If user wants to know if the output is written, they can look at outputs_written. If you want to have the warning below (which seems good to me), maybe a boolean in vtn_builder instead?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
/** gl_FragDepth layout for ARB_conservative_depth. */<br>
enum gl_frag_depth_layout depth_layout;<br>
} fs;<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 6c0551603ea..81c5e890071 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -3577,6 +3577,10 @@ vtn_handle_execution_mode(<wbr>struct vtn_builder *b, struct vtn_value *entry_point,<br>
case SpvExecutionModeContractionOff<wbr>:<br>
break; /* OpenCL */<br>
<br>
+ case SpvExecutionModeStencilRefRepl<wbr>acingEXT:<br>
+ b->shader->info.fs.outputs_<wbr>stencil = true;<br>
+ break;<br>
+<br>
default:<br>
vtn_fail("Unhandled execution mode");<br>
}<br>
diff --git a/src/compiler/spirv/vtn_<wbr>variables.c b/src/compiler/spirv/vtn_<wbr>variables.c<br>
index 53bee1b9288..0a3108bdc43 100644<br>
--- a/src/compiler/spirv/vtn_<wbr>variables.c<br>
+++ b/src/compiler/spirv/vtn_<wbr>variables.c<br>
@@ -1429,6 +1429,11 @@ apply_var_decoration(struct vtn_builder *b, nir_variable *nir_var,<br>
case SpvBuiltInSamplePosition:<br>
nir_var->data.origin_upper_<wbr>left = b->origin_upper_left;<br>
break;<br>
+ case SpvBuiltInFragStencilRefEXT:<br>
+ if (!b->shader->info.fs.outputs_<wbr>stencil)<br>
+ vtn_warn("The StencilRefReplacingEXT mode should be declared when"<br>
+ " the decoration FragStencilRefEXT is used on a variable");<br>
+ break;<br></blockquote><div><br></div><div>This stuff should go in the previous patch.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
default:<br>
break;<br>
}<br>
diff --git a/src/intel/vulkan/anv_<wbr>extensions.py b/src/intel/vulkan/anv_<wbr>extensions.py<br>
index b5bee0881ce..8160864685f 100644<br>
--- a/src/intel/vulkan/anv_<wbr>extensions.py<br>
+++ b/src/intel/vulkan/anv_<wbr>extensions.py<br>
@@ -112,6 +112,7 @@ EXTENSIONS = [<br>
Extension('VK_EXT_global_<wbr>priority', 1,<br>
'device->has_context_priority'<wbr>),<br>
Extension('VK_EXT_shader_<wbr>viewport_index_layer', 1, True),<br>
+ Extension('VK_EXT_shader_<wbr>stencil_export', 1, 'device->info.gen >= 9'),<br>
]<br>
<br>
class VkVersion:<br>
diff --git a/src/intel/vulkan/anv_<wbr>pipeline.c b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
index 8f30136b100..c37b9b96e11 100644<br>
--- a/src/intel/vulkan/anv_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
@@ -152,6 +152,7 @@ anv_shader_compile_to_nir(<wbr>struct anv_pipeline *pipeline,<br>
.subgroup_quad = true,<br>
.subgroup_shuffle = true,<br>
.subgroup_vote = true,<br>
+ .stencil_export = true,<br>
},<br>
};<br>
<br>
diff --git a/src/intel/vulkan/genX_<wbr>pipeline.c b/src/intel/vulkan/genX_<wbr>pipeline.c<br>
index 6016d257584..462c59451cc 100644<br>
--- a/src/intel/vulkan/genX_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/genX_<wbr>pipeline.c<br>
@@ -1600,6 +1600,7 @@ emit_3dstate_ps_extra(struct anv_pipeline *pipeline,<br>
ps.PixelShaderHasUAV = true;<br>
<br>
#if GEN_GEN >= 9<br>
+ ps.PixelShaderComputesStencil = wm_prog_data->computed_<wbr>stencil;<br>
ps.PixelShaderPullsBary = wm_prog_data->pulls_bary;<br>
ps.InputCoverageMaskState = wm_prog_data->uses_sample_mask ?<br>
ICMS_INNER_CONSERVATIVE : ICMS_NONE;<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>