nir: Don't set writes_memory for reading XFB
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 2 May 2022 17:59:55 +0000 (13:59 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 3 May 2022 19:02:17 +0000 (19:02 +0000)
That's a read, not a write. Fixes optimizations getting disabled for fragment
shaders when linked with a shader producing transform feedback varyings.

Fixes: 85a723975bb ("nir: add and gather shader_info::writes_memory")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16285>

src/compiler/nir/nir_gather_info.c

index 2ed70e1..6a138e7 100644 (file)
@@ -930,7 +930,8 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
       shader->info.tess.tcs_cross_invocation_outputs_read = 0;
    }
 
-   shader->info.writes_memory = shader->info.has_transform_feedback_varyings;
+   if (shader->info.stage != MESA_SHADER_FRAGMENT)
+      shader->info.writes_memory = shader->info.has_transform_feedback_varyings;
 
    void *dead_ctx = ralloc_context(NULL);
    nir_foreach_block(block, entrypoint) {