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: 36ee2fd61c ("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>
This commit is contained in:
Jason Ekstrand 2022-05-13 17:06:50 -05:00 committed by Marge Bot
parent 9fe6caf4e7
commit 73b3efcd59

View file

@ -1212,20 +1212,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
@ -1869,15 +1855,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;