summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@collabora.com>2022-05-13 17:06:50 -0500
committerDylan Baker <dylan.c.baker@intel.com>2022-06-01 13:00:33 -0700
commitc6f6b47b5da53318aa1a7b98814672c329ecd2fb (patch)
tree5fd70be6e2731164ca4c53ea205f309b39340e06
parentc11fe3647f165d71853cc5f7a8798a8b0670b021 (diff)
anv: Handle the null FS optimization after compiling shaders
Actually compile and cache the no-op fragment shader but remove it from the pipeline if we determine it's a no-op. This way we always have it even if it's not strictly needed. Fixes: 36ee2fd61c8f ("anv: Implement the basic form of VK_EXT_transform_feedback") Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16506> (cherry picked from commit 73b3efcd59ade6b9dc8c4cce994d7fbe5c1f0cac)
-rw-r--r--.pick_status.json2
-rw-r--r--src/intel/vulkan/anv_pipeline.c39
2 files changed, 17 insertions, 24 deletions
diff --git a/.pick_status.json b/.pick_status.json
index c59919d7edd..8b331b9bd43 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1412,7 +1412,7 @@
"description": "anv: Handle the null FS optimization after compiling shaders",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"because_sha": "36ee2fd61c8f943be1d1e2b0354f7a121ffef28f"
},
{
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 7c4bb052a43..c3fa0b1ecab 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1352,20 +1352,6 @@ anv_pipeline_compile_fs(const struct brw_compiler *compiler,
fs_stage->num_stats = (uint32_t)fs_stage->prog_data.wm.dispatch_8 +
(uint32_t)fs_stage->prog_data.wm.dispatch_16 +
(uint32_t)fs_stage->prog_data.wm.dispatch_32;
-
- if (fs_stage->key.wm.color_outputs_valid == 0 &&
- !fs_stage->prog_data.wm.has_side_effects &&
- !fs_stage->prog_data.wm.uses_omask &&
- !fs_stage->prog_data.wm.uses_kill &&
- fs_stage->prog_data.wm.computed_depth_mode == BRW_PSCDEPTH_OFF &&
- !fs_stage->prog_data.wm.computed_stencil) {
- /* This fragment shader has no outputs and no side effects. Go ahead
- * and return the code pointer so we don't accidentally think the
- * compile failed but zero out prog_data which will set program_size to
- * zero and disable the stage.
- */
- memset(&fs_stage->prog_data, 0, sizeof(fs_stage->prog_data));
- }
}
static void
@@ -2014,15 +2000,22 @@ anv_pipeline_compile_graphics(struct anv_graphics_pipeline *pipeline,
done:
- if (pipeline->shaders[MESA_SHADER_FRAGMENT] &&
- pipeline->shaders[MESA_SHADER_FRAGMENT]->prog_data->program_size == 0) {
- /* This can happen if we decided to implicitly disable the fragment
- * shader. See anv_pipeline_compile_fs().
- */
- anv_shader_bin_unref(pipeline->base.device,
- pipeline->shaders[MESA_SHADER_FRAGMENT]);
- pipeline->shaders[MESA_SHADER_FRAGMENT] = NULL;
- pipeline->active_stages &= ~VK_SHADER_STAGE_FRAGMENT_BIT;
+ if (pipeline->shaders[MESA_SHADER_FRAGMENT] != NULL) {
+ const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
+ if (wm_prog_data->color_outputs_written == 0 &&
+ !wm_prog_data->has_side_effects &&
+ !wm_prog_data->uses_omask &&
+ !wm_prog_data->uses_kill &&
+ wm_prog_data->computed_depth_mode == BRW_PSCDEPTH_OFF &&
+ !wm_prog_data->computed_stencil) {
+ /* This can happen if we decided to implicitly disable the fragment
+ * shader. See anv_pipeline_compile_fs().
+ */
+ anv_shader_bin_unref(pipeline->base.device,
+ pipeline->shaders[MESA_SHADER_FRAGMENT]);
+ pipeline->shaders[MESA_SHADER_FRAGMENT] = NULL;
+ pipeline->active_stages &= ~VK_SHADER_STAGE_FRAGMENT_BIT;
+ }
}
pipeline_feedback.duration = os_time_get_nano() - pipeline_start;