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

Tapani Pälli tapani.palli at intel.com
Tue Dec 15 04:04:41 PST 2015


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

Patches 1 and 2 are
Reviewed-by: Tapani Pälli <tapani.palli at 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



More information about the mesa-dev mailing list