anv: Don't disable the fragment shader if XFB is enabled

It turns out that we need a fragment shader for streamout.  Whh?  From
Lionel's reading of simulator sources, it seems the streamout unit is
looking at enabled next stages.  It'll generate output to the clipper in
the following cases :

 - 3DSTATE_STREAMOUT::ForceRendering = ON
 - PS enabled
 - Stencil test enabled
 - depth test enabled
 - depth write enabled
 - some other depth/hiz clear condition

Forcing rendering without a PS seems like a recipe for hangs so it's
probably better to just enable the PS in this case.

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>
(cherry picked from commit 0d28de212a)
This commit is contained in:
Jason Ekstrand 2022-05-13 17:09:52 -05:00 committed by Dylan Baker
parent c6f6b47b5d
commit bac2d7f383
2 changed files with 8 additions and 5 deletions

View file

@ -1404,7 +1404,7 @@
"description": "anv: Don't disable the fragment shader if XFB is enabled",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"because_sha": "36ee2fd61c8f943be1d1e2b0354f7a121ffef28f"
},
{

View file

@ -2001,18 +2001,21 @@ anv_pipeline_compile_graphics(struct anv_graphics_pipeline *pipeline,
done:
if (pipeline->shaders[MESA_SHADER_FRAGMENT] != NULL) {
const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
struct anv_shader_bin *fs = pipeline->shaders[MESA_SHADER_FRAGMENT];
const struct brw_wm_prog_data *wm_prog_data =
brw_wm_prog_data_const(fs->prog_data);
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) {
!wm_prog_data->computed_stencil &&
fs->xfb_info == NULL) {
/* 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]);
anv_shader_bin_unref(pipeline->base.device, fs);
pipeline->shaders[MESA_SHADER_FRAGMENT] = NULL;
pipeline->active_stages &= ~VK_SHADER_STAGE_FRAGMENT_BIT;
}