<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Feb 1, 2017 at 5:44 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In order to get good performance numbers for this, I had to hack up the<br class="gmail_msg">
driver to whack wm_prog_data::uses_kill to true to emulate a discard and<br class="gmail_msg">
used the Sascha "shadowmapping" demo. Setting uses_kill to true dropped<br class="gmail_msg">
the framerate on the demo by 25-30%. Enabling the PMA fix brought it<br class="gmail_msg">
back up to around 90% of the original framerate. This doesn't seem to<br class="gmail_msg">
really impact Dota 2; probably because it doesn't use 16-bit depth.<br class="gmail_msg"></blockquote><div><br></div><div>Nice to see this done - there's a FIXME in cmd_buffer_emit_depth_stencil() you can delete.</div><div><br></div><div>Kristian</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br class="gmail_msg">
src/intel/vulkan/TODO | 1 -<br class="gmail_msg">
src/intel/vulkan/anv_cmd_buffer.c | 1 +<br class="gmail_msg">
src/intel/vulkan/anv_genX.h | 3 +<br class="gmail_msg">
src/intel/vulkan/anv_private.h | 10 +++<br class="gmail_msg">
src/intel/vulkan/gen7_cmd_buffer.c | 7 ++<br class="gmail_msg">
src/intel/vulkan/gen8_cmd_buffer.c | 139 +++++++++++++++++++++++++++++++++++++<br class="gmail_msg">
src/intel/vulkan/genX_blorp_exec.c | 5 ++<br class="gmail_msg">
src/intel/vulkan/genX_cmd_buffer.c | 10 +++<br class="gmail_msg">
src/intel/vulkan/genX_pipeline.c | 36 ++++++++++<br class="gmail_msg">
9 files changed, 211 insertions(+), 1 deletion(-)<br class="gmail_msg">
<br class="gmail_msg">
diff --git a/src/intel/vulkan/TODO b/src/intel/vulkan/TODO<br class="gmail_msg">
index 38acc0d..f8b73a1 100644<br class="gmail_msg">
--- a/src/intel/vulkan/TODO<br class="gmail_msg">
+++ b/src/intel/vulkan/TODO<br class="gmail_msg">
@@ -12,5 +12,4 @@ Performance:<br class="gmail_msg">
- Compressed multisample support<br class="gmail_msg">
- Pushing pieces of UBOs?<br class="gmail_msg">
- Enable guardband clipping<br class="gmail_msg">
- - pma stall workaround<br class="gmail_msg">
- Use soft-pin to avoid relocations<br class="gmail_msg">
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c<br class="gmail_msg">
index 5886fa6..a762476 100644<br class="gmail_msg">
--- a/src/intel/vulkan/anv_cmd_buffer.c<br class="gmail_msg">
+++ b/src/intel/vulkan/anv_cmd_buffer.c<br class="gmail_msg">
@@ -135,6 +135,7 @@ anv_cmd_state_reset(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
state->restart_index = UINT32_MAX;<br class="gmail_msg">
state->dynamic = default_dynamic_state;<br class="gmail_msg">
state->need_query_wa = true;<br class="gmail_msg">
+ state->pma_fix_enabled = false;<br class="gmail_msg">
<br class="gmail_msg">
if (state->attachments != NULL) {<br class="gmail_msg">
vk_free(&cmd_buffer->pool->alloc, state->attachments);<br class="gmail_msg">
diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h<br class="gmail_msg">
index d04fe38..67147b0 100644<br class="gmail_msg">
--- a/src/intel/vulkan/anv_genX.h<br class="gmail_msg">
+++ b/src/intel/vulkan/anv_genX.h<br class="gmail_msg">
@@ -55,6 +55,9 @@ void genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer);<br class="gmail_msg">
<br class="gmail_msg">
void genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer);<br class="gmail_msg">
<br class="gmail_msg">
+void genX(cmd_buffer_enable_pma_fix)(struct anv_cmd_buffer *cmd_buffer,<br class="gmail_msg">
+ bool enable);<br class="gmail_msg">
+<br class="gmail_msg">
void<br class="gmail_msg">
genX(emit_urb_setup)(struct anv_device *device, struct anv_batch *batch,<br class="gmail_msg">
const struct gen_l3_config *l3_config,<br class="gmail_msg">
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h<br class="gmail_msg">
index 4fe3ebc..5fe4dd8 100644<br class="gmail_msg">
--- a/src/intel/vulkan/anv_private.h<br class="gmail_msg">
+++ b/src/intel/vulkan/anv_private.h<br class="gmail_msg">
@@ -1163,6 +1163,13 @@ struct anv_cmd_state {<br class="gmail_msg">
bool need_query_wa;<br class="gmail_msg">
<br class="gmail_msg">
/**<br class="gmail_msg">
+ * Whether or not the gen8 PMA fix is enabled. We ensure that, at the top<br class="gmail_msg">
+ * of any command buffer it disabled by disabling it in EndCommandBuffer<br class="gmail_msg">
+ * and before invoking the secondary in ExecuteCommands.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ bool pma_fix_enabled;<br class="gmail_msg">
+<br class="gmail_msg">
+ /**<br class="gmail_msg">
* Array length is anv_cmd_state::pass::attachment_count. Array content is<br class="gmail_msg">
* valid only when recording a render pass instance.<br class="gmail_msg">
*/<br class="gmail_msg">
@@ -1465,8 +1472,11 @@ struct anv_pipeline {<br class="gmail_msg">
<br class="gmail_msg">
uint32_t cs_right_mask;<br class="gmail_msg">
<br class="gmail_msg">
+ bool writes_depth;<br class="gmail_msg">
+ bool depth_test_enable;<br class="gmail_msg">
bool writes_stencil;<br class="gmail_msg">
bool depth_clamp_enable;<br class="gmail_msg">
+ bool kill_pixel;<br class="gmail_msg">
<br class="gmail_msg">
struct {<br class="gmail_msg">
uint32_t sf[7];<br class="gmail_msg">
diff --git a/src/intel/vulkan/gen7_cmd_buffer.c b/src/intel/vulkan/gen7_cmd_buffer.c<br class="gmail_msg">
index 013ed87..c1a25e8 100644<br class="gmail_msg">
--- a/src/intel/vulkan/gen7_cmd_buffer.c<br class="gmail_msg">
+++ b/src/intel/vulkan/gen7_cmd_buffer.c<br class="gmail_msg">
@@ -260,6 +260,13 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
cmd_buffer->state.dirty = 0;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+void<br class="gmail_msg">
+genX(cmd_buffer_enable_pma_fix)(struct anv_cmd_buffer *cmd_buffer,<br class="gmail_msg">
+ bool enable)<br class="gmail_msg">
+{<br class="gmail_msg">
+ /* The NP PMA fix doesn't exist on gen7 */<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
void genX(CmdSetEvent)(<br class="gmail_msg">
VkCommandBuffer commandBuffer,<br class="gmail_msg">
VkEvent event,<br class="gmail_msg">
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c<br class="gmail_msg">
index 8c8de62..b877e27 100644<br class="gmail_msg">
--- a/src/intel/vulkan/gen8_cmd_buffer.c<br class="gmail_msg">
+++ b/src/intel/vulkan/gen8_cmd_buffer.c<br class="gmail_msg">
@@ -155,6 +155,141 @@ __emit_sf_state(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
#endif<br class="gmail_msg">
<br class="gmail_msg">
void<br class="gmail_msg">
+genX(cmd_buffer_enable_pma_fix)(struct anv_cmd_buffer *cmd_buffer, bool enable)<br class="gmail_msg">
+{<br class="gmail_msg">
+#if GEN_GEN == 8<br class="gmail_msg">
+ if (cmd_buffer->state.pma_fix_enabled == enable)<br class="gmail_msg">
+ return;<br class="gmail_msg">
+<br class="gmail_msg">
+ anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {<br class="gmail_msg">
+ pc.DepthCacheFlushEnable = true;<br class="gmail_msg">
+ pc.CommandStreamerStallEnable = true;<br class="gmail_msg">
+ pc.RenderTargetCacheFlushEnable = true;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ uint32_t cache_mode;<br class="gmail_msg">
+ anv_pack_struct(&cache_mode, GENX(CACHE_MODE_1),<br class="gmail_msg">
+ .NPPMAFixEnable = enable,<br class="gmail_msg">
+ .NPEarlyZFailsDisableMask = enable,<br class="gmail_msg">
+ .NPPMAFixEnableMask = true,<br class="gmail_msg">
+ .NPEarlyZFailsDisableMask = true);<br class="gmail_msg">
+ anv_batch_emit(&cmd_buffer->batch, GENX(MI_LOAD_REGISTER_IMM), lri) {<br class="gmail_msg">
+ lri.RegisterOffset = GENX(CACHE_MODE_1_num);<br class="gmail_msg">
+ lri.DataDWord = cache_mode;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ /* After the LRI, a PIPE_CONTROL with both the Depth Stall and Depth Cache<br class="gmail_msg">
+ * Flush bits is often necessary. We do it regardless because it's easier.<br class="gmail_msg">
+ * The render cache flush is also necessary if stencil writes are enabled.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {<br class="gmail_msg">
+ pc.DepthStallEnable = true;<br class="gmail_msg">
+ pc.DepthCacheFlushEnable = true;<br class="gmail_msg">
+ pc.RenderTargetCacheFlushEnable = true;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ cmd_buffer->state.pma_fix_enabled = enable;<br class="gmail_msg">
+#endif /* GEN_GEN == 8 */<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+static inline bool<br class="gmail_msg">
+want_depth_pma_fix(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
+{<br class="gmail_msg">
+ assert(GEN_GEN == 8);<br class="gmail_msg">
+<br class="gmail_msg">
+ /* From the Broadwell PRM Vol. 2c CACHE_MODE_1::NP_PMA_FIX_ENABLE:<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * SW must set this bit in order to enable this fix when following<br class="gmail_msg">
+ * expression is TRUE.<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * 3DSTATE_WM::ForceThreadDispatch != 1 &&<br class="gmail_msg">
+ * !(3DSTATE_RASTER::ForceSampleCount != NUMRASTSAMPLES_0) &&<br class="gmail_msg">
+ * (3DSTATE_DEPTH_BUFFER::SURFACE_TYPE != NULL) &&<br class="gmail_msg">
+ * (3DSTATE_DEPTH_BUFFER::HIZ Enable) &&<br class="gmail_msg">
+ * !(3DSTATE_WM::EDSC_Mode == EDSC_PREPS) &&<br class="gmail_msg">
+ * (3DSTATE_PS_EXTRA::PixelShaderValid) &&<br class="gmail_msg">
+ * !(3DSTATE_WM_HZ_OP::DepthBufferClear ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::DepthBufferResolve ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::Hierarchical Depth Buffer Resolve Enable ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::StencilBufferClear) &&<br class="gmail_msg">
+ * (3DSTATE_WM_DEPTH_STENCIL::DepthTestEnable) &&<br class="gmail_msg">
+ * (((3DSTATE_PS_EXTRA::PixelShaderKillsPixels ||<br class="gmail_msg">
+ * 3DSTATE_PS_EXTRA::oMask Present to RenderTarget ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaToCoverageEnable ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaTestEnable ||<br class="gmail_msg">
+ * 3DSTATE_WM_CHROMAKEY::ChromaKeyKillEnable) &&<br class="gmail_msg">
+ * 3DSTATE_WM::ForceKillPix != ForceOff &&<br class="gmail_msg">
+ * ((3DSTATE_WM_DEPTH_STENCIL::DepthWriteEnable &&<br class="gmail_msg">
+ * 3DSTATE_DEPTH_BUFFER::DEPTH_WRITE_ENABLE) ||<br class="gmail_msg">
+ * (3DSTATE_WM_DEPTH_STENCIL::Stencil Buffer Write Enable &&<br class="gmail_msg">
+ * 3DSTATE_DEPTH_BUFFER::STENCIL_WRITE_ENABLE &&<br class="gmail_msg">
+ * 3DSTATE_STENCIL_BUFFER::STENCIL_BUFFER_ENABLE))) ||<br class="gmail_msg">
+ * (3DSTATE_PS_EXTRA:: Pixel Shader Computed Depth mode != PSCDEPTH_OFF))<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * This function only takes care of the pipeline parts of the equation.<br class="gmail_msg">
+ */<br class="gmail_msg">
+<br class="gmail_msg">
+ /* These are always true:<br class="gmail_msg">
+ * 3DSTATE_WM::ForceThreadDispatch != 1 &&<br class="gmail_msg">
+ * !(3DSTATE_RASTER::ForceSampleCount != NUMRASTSAMPLES_0)<br class="gmail_msg">
+ */<br class="gmail_msg">
+<br class="gmail_msg">
+ /* We only enable the PMA fix if HiZ is enabled. However, if HiZ is<br class="gmail_msg">
+ * *not* enabled and we don't set this bit there is no harm. Therefore,<br class="gmail_msg">
+ * we can just treat the NULL framebuffer case as has_hiz == false and<br class="gmail_msg">
+ * everything will work just fine.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ if (cmd_buffer->state.framebuffer == NULL)<br class="gmail_msg">
+ return false;<br class="gmail_msg">
+<br class="gmail_msg">
+ /* (3DSTATE_DEPTH_BUFFER::SURFACE_TYPE != NULL) &&<br class="gmail_msg">
+ * 3DSTATE_DEPTH_BUFFER::HIZ Enable<br class="gmail_msg">
+ */<br class="gmail_msg">
+ const struct anv_image_view *ds_iview =<br class="gmail_msg">
+ anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);<br class="gmail_msg">
+ if (!ds_iview || ds_iview->image->aux_usage != ISL_AUX_USAGE_HIZ)<br class="gmail_msg">
+ return false;<br class="gmail_msg">
+<br class="gmail_msg">
+ /* 3DSTATE_PS_EXTRA::PixelShaderValid */<br class="gmail_msg">
+ struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;<br class="gmail_msg">
+ if (!anv_pipeline_has_stage(pipeline, MESA_SHADER_FRAGMENT))<br class="gmail_msg">
+ return false;<br class="gmail_msg">
+<br class="gmail_msg">
+ /* !(3DSTATE_WM::EDSC_Mode == EDSC_PREPS) */<br class="gmail_msg">
+ const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);<br class="gmail_msg">
+ if (wm_prog_data->early_fragment_tests)<br class="gmail_msg">
+ return false;<br class="gmail_msg">
+<br class="gmail_msg">
+ /* We never use anv_pipeline for HiZ ops so this is trivially true:<br class="gmail_msg">
+ * !(3DSTATE_WM_HZ_OP::DepthBufferClear ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::DepthBufferResolve ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::Hierarchical Depth Buffer Resolve Enable ||<br class="gmail_msg">
+ * 3DSTATE_WM_HZ_OP::StencilBufferClear)<br class="gmail_msg">
+ */<br class="gmail_msg">
+<br class="gmail_msg">
+ /* 3DSTATE_WM_DEPTH_STENCIL::DepthTestEnable */<br class="gmail_msg">
+ if (!pipeline->depth_test_enable)<br class="gmail_msg">
+ return false;<br class="gmail_msg">
+<br class="gmail_msg">
+ /* (((3DSTATE_PS_EXTRA::PixelShaderKillsPixels ||<br class="gmail_msg">
+ * 3DSTATE_PS_EXTRA::oMask Present to RenderTarget ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaToCoverageEnable ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaTestEnable ||<br class="gmail_msg">
+ * 3DSTATE_WM_CHROMAKEY::ChromaKeyKillEnable) &&<br class="gmail_msg">
+ * 3DSTATE_WM::ForceKillPix != ForceOff &&<br class="gmail_msg">
+ * ((3DSTATE_WM_DEPTH_STENCIL::DepthWriteEnable &&<br class="gmail_msg">
+ * 3DSTATE_DEPTH_BUFFER::DEPTH_WRITE_ENABLE) ||<br class="gmail_msg">
+ * (3DSTATE_WM_DEPTH_STENCIL::Stencil Buffer Write Enable &&<br class="gmail_msg">
+ * 3DSTATE_DEPTH_BUFFER::STENCIL_WRITE_ENABLE &&<br class="gmail_msg">
+ * 3DSTATE_STENCIL_BUFFER::STENCIL_BUFFER_ENABLE))) ||<br class="gmail_msg">
+ * (3DSTATE_PS_EXTRA:: Pixel Shader Computed Depth mode != PSCDEPTH_OFF))<br class="gmail_msg">
+ */<br class="gmail_msg">
+ return (pipeline->kill_pixel && (pipeline->writes_depth ||<br class="gmail_msg">
+ pipeline->writes_stencil)) ||<br class="gmail_msg">
+ wm_prog_data->computed_depth_mode != PSCDEPTH_OFF;<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+void<br class="gmail_msg">
genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
{<br class="gmail_msg">
struct anv_pipeline *pipeline = cmd_buffer->state.pipeline;<br class="gmail_msg">
@@ -211,6 +346,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
if (cmd_buffer->state.dirty & (ANV_CMD_DIRTY_PIPELINE |<br class="gmail_msg">
+ ANV_CMD_DIRTY_RENDER_TARGETS |<br class="gmail_msg">
ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK |<br class="gmail_msg">
ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK)) {<br class="gmail_msg">
uint32_t wm_depth_stencil_dw[GENX(3DSTATE_WM_DEPTH_STENCIL_length)];<br class="gmail_msg">
@@ -234,6 +370,9 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)<br class="gmail_msg">
<br class="gmail_msg">
anv_batch_emit_merge(&cmd_buffer->batch, wm_depth_stencil_dw,<br class="gmail_msg">
pipeline->gen8.wm_depth_stencil);<br class="gmail_msg">
+<br class="gmail_msg">
+ genX(cmd_buffer_enable_pma_fix)(cmd_buffer,<br class="gmail_msg">
+ want_depth_pma_fix(cmd_buffer));<br class="gmail_msg">
}<br class="gmail_msg">
#else<br class="gmail_msg">
if (cmd_buffer->state.dirty & ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS) {<br class="gmail_msg">
diff --git a/src/intel/vulkan/genX_blorp_exec.c b/src/intel/vulkan/genX_blorp_exec.c<br class="gmail_msg">
index 663e6c9..6f0b063 100644<br class="gmail_msg">
--- a/src/intel/vulkan/genX_blorp_exec.c<br class="gmail_msg">
+++ b/src/intel/vulkan/genX_blorp_exec.c<br class="gmail_msg">
@@ -154,6 +154,11 @@ genX(blorp_exec)(struct blorp_batch *batch,<br class="gmail_msg">
<br class="gmail_msg">
genX(cmd_buffer_emit_gen7_depth_flush)(cmd_buffer);<br class="gmail_msg">
<br class="gmail_msg">
+ /* BLORP doesn't do anything fancy with depth such as discards, so we want<br class="gmail_msg">
+ * the PMA fix off. Also, off is always the safe option.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ genX(cmd_buffer_enable_pma_fix)(cmd_buffer, false);<br class="gmail_msg">
+<br class="gmail_msg">
blorp_exec(batch, params);<br class="gmail_msg">
<br class="gmail_msg">
cmd_buffer->state.vb_dirty = ~0;<br class="gmail_msg">
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c<br class="gmail_msg">
index b6b7f74..9b54e80 100644<br class="gmail_msg">
--- a/src/intel/vulkan/genX_cmd_buffer.c<br class="gmail_msg">
+++ b/src/intel/vulkan/genX_cmd_buffer.c<br class="gmail_msg">
@@ -627,6 +627,11 @@ genX(EndCommandBuffer)(<br class="gmail_msg">
{<br class="gmail_msg">
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);<br class="gmail_msg">
<br class="gmail_msg">
+ /* We want every command buffer to start with the PMA fix in a known state,<br class="gmail_msg">
+ * so we disable it at the end of the command buffer.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ genX(cmd_buffer_enable_pma_fix)(cmd_buffer, false);<br class="gmail_msg">
+<br class="gmail_msg">
genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer);<br class="gmail_msg">
<br class="gmail_msg">
anv_cmd_buffer_end_batch_buffer(cmd_buffer);<br class="gmail_msg">
@@ -644,6 +649,11 @@ genX(CmdExecuteCommands)(<br class="gmail_msg">
<br class="gmail_msg">
assert(primary->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);<br class="gmail_msg">
<br class="gmail_msg">
+ /* The secondary command buffers will assume that the PMA fix is disabled<br class="gmail_msg">
+ * when they begin executing. Make sure this is true.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ genX(cmd_buffer_enable_pma_fix)(primary, false);<br class="gmail_msg">
+<br class="gmail_msg">
for (uint32_t i = 0; i < commandBufferCount; i++) {<br class="gmail_msg">
ANV_FROM_HANDLE(anv_cmd_buffer, secondary, pCmdBuffers[i]);<br class="gmail_msg">
<br class="gmail_msg">
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c<br class="gmail_msg">
index 32be151..a7b294f 100644<br class="gmail_msg">
--- a/src/intel/vulkan/genX_pipeline.c<br class="gmail_msg">
+++ b/src/intel/vulkan/genX_pipeline.c<br class="gmail_msg">
@@ -710,6 +710,9 @@ emit_ds_state(struct anv_pipeline *pipeline,<br class="gmail_msg">
if (info->depthTestEnable && info->depthCompareOp == VK_COMPARE_OP_EQUAL)<br class="gmail_msg">
depth_stencil.DepthBufferWriteEnable = false;<br class="gmail_msg">
<br class="gmail_msg">
+ pipeline->writes_depth = depth_stencil.DepthBufferWriteEnable;<br class="gmail_msg">
+ pipeline->depth_test_enable = depth_stencil.DepthTestEnable;<br class="gmail_msg">
+<br class="gmail_msg">
#if GEN_GEN <= 7<br class="gmail_msg">
GENX(DEPTH_STENCIL_STATE_pack)(NULL, depth_stencil_dw, &depth_stencil);<br class="gmail_msg">
#else<br class="gmail_msg">
@@ -1428,6 +1431,38 @@ emit_3dstate_vf_topology(struct anv_pipeline *pipeline)<br class="gmail_msg">
}<br class="gmail_msg">
#endif<br class="gmail_msg">
<br class="gmail_msg">
+static void<br class="gmail_msg">
+compute_kill_pixel(struct anv_pipeline *pipeline,<br class="gmail_msg">
+ const VkPipelineMultisampleStateCreateInfo *ms_info,<br class="gmail_msg">
+ const struct anv_subpass *subpass)<br class="gmail_msg">
+{<br class="gmail_msg">
+ if (!anv_pipeline_has_stage(pipeline, MESA_SHADER_FRAGMENT)) {<br class="gmail_msg">
+ pipeline->kill_pixel = false;<br class="gmail_msg">
+ return;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);<br class="gmail_msg">
+<br class="gmail_msg">
+ /* This computes the KillPixel portion of the computation for whether or<br class="gmail_msg">
+ * not we want to enable the PMA fix on gen8. It's given by this chunk of<br class="gmail_msg">
+ * the giant formula:<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * (3DSTATE_PS_EXTRA::PixelShaderKillsPixels ||<br class="gmail_msg">
+ * 3DSTATE_PS_EXTRA::oMask Present to RenderTarget ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaToCoverageEnable ||<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaTestEnable ||<br class="gmail_msg">
+ * 3DSTATE_WM_CHROMAKEY::ChromaKeyKillEnable)<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * 3DSTATE_WM_CHROMAKEY::ChromaKeyKillEnable is always false and so is<br class="gmail_msg">
+ * 3DSTATE_PS_BLEND::AlphaTestEnable since Vulkan doesn't have a concept<br class="gmail_msg">
+ * of an alpha test.<br class="gmail_msg">
+ */<br class="gmail_msg">
+ pipeline->kill_pixel =<br class="gmail_msg">
+ subpass->has_ds_self_dep || wm_prog_data->uses_kill ||<br class="gmail_msg">
+ wm_prog_data->uses_omask ||<br class="gmail_msg">
+ (ms_info && ms_info->alphaToCoverageEnable);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
static VkResult<br class="gmail_msg">
genX(graphics_pipeline_create)(<br class="gmail_msg">
VkDevice _device,<br class="gmail_msg">
@@ -1465,6 +1500,7 @@ genX(graphics_pipeline_create)(<br class="gmail_msg">
emit_ds_state(pipeline, pCreateInfo->pDepthStencilState, pass, subpass);<br class="gmail_msg">
emit_cb_state(pipeline, pCreateInfo->pColorBlendState,<br class="gmail_msg">
pCreateInfo->pMultisampleState);<br class="gmail_msg">
+ compute_kill_pixel(pipeline, pCreateInfo->pMultisampleState, subpass);<br class="gmail_msg">
<br class="gmail_msg">
emit_urb_setup(pipeline);<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
2.5.0.400.gff86faf<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
mesa-dev mailing list<br class="gmail_msg">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="gmail_msg" target="_blank">mesa-dev@lists.freedesktop.org</a><br class="gmail_msg">
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br class="gmail_msg">
</blockquote></div></div>