summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2015-12-18 10:17:59 +0100
committerSamuel Iglesias Gonsálvez <[email protected]>2015-12-22 12:38:48 +0100
commit1a95b87dad341e73e355b244a275d9b4d60537af (patch)
treea11d3240d3a963fa4aa1f68dfd8f0e419bb15a18 /src/mesa/main
parent57f7c85dcf8ca8b47b71076fb70d9242aec00588 (diff)
mesa: Add a _mesa_active_fragment_shader_has_side_effects helper
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). Right now, mesa has a function to check for atomic buffers and the i965 driver also checks for images. Refactor this logic into a generic function that we can use for any source of side effects in a fragment shader. Suggested by Jason. v2: - Use '_Shader', as suggested by Tapani, to fix the following CTS test: ES31-CTS.shader_atomic_counters.advanced-usage-many-draw-calls2 Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 707ebb9872a..c57ec0cd0d0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4535,11 +4535,20 @@ enum _debug
DEBUG_INCOMPLETE_FBO = (1 << 3)
};
+/**
+ * Checks if the active fragment shader program can have side effects due
+ * to use of things like atomic buffers or images
+ */
static inline bool
-_mesa_active_fragment_shader_has_atomic_ops(const struct gl_context *ctx)
+_mesa_active_fragment_shader_has_side_effects(const struct gl_context *ctx)
{
- return ctx->Shader._CurrentFragmentProgram != NULL &&
- ctx->Shader._CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->NumAtomicBuffers > 0;
+ const struct gl_shader *sh;
+
+ if (!ctx->_Shader->_CurrentFragmentProgram)
+ return false;
+
+ sh = ctx->_Shader->_CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT];
+ return sh->NumAtomicBuffers > 0 || sh->NumImages > 0;
}
#ifdef __cplusplus