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

Submitted by Iago Toral Quiroga on Dec. 15, 2015, 11:51 a.m.

Details

Message ID 1450180308-20143-1-git-send-email-itoral@igalia.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Iago Toral Quiroga Dec. 15, 2015, 11:51 a.m.
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(+)

Patch hide | download patch | download mbox

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

Comments

Yep, I remember when and why this was done for atomic counters.

Patches 1 and 2 are
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>

On 12/15/2015 01:51 PM, Iago Toral Quiroga wrote:
> 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