[Mesa-dev] [PATCH 1/3] mesa: Add helper to check if the active fragment shader has shader storage

Iago Toral Quiroga itoral at igalia.com
Tue Dec 15 03:51:46 PST 2015


Some drivers can disable the FS unit if there is nothing in the shader code
that writes to an output (i.e. color, depth, etc). For drivers that check
for these things, this helper function is useful to avoid that optimization
in the case that the shader has shader storage space assigned (since it could
be writing to it).
---
 src/mesa/main/mtypes.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 48309bf..acacae0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4544,6 +4544,13 @@ _mesa_active_fragment_shader_has_atomic_ops(const struct gl_context *ctx)
       ctx->Shader._CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->NumAtomicBuffers > 0;
 }
 
+static inline bool
+_mesa_active_fragment_shader_has_shader_storage(const struct gl_context *ctx)
+{
+   return ctx->Shader._CurrentFragmentProgram != NULL &&
+      ctx->Shader._CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->NumShaderStorageBlocks > 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.9.1



More information about the mesa-dev mailing list