[Mesa-dev] [PATCH v2 19/20] st/mesa: expose ARB_compute_shader when compute is supported

Ilia Mirkin imirkin at alum.mit.edu
Sun Feb 7 00:02:27 UTC 2016


On Sat, Feb 6, 2016 at 5:04 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> ARB_compute_shader is only enabled if the underlying driver exposes
> TGSI through the PIPE_CAP_SHADER_SUPPORTED_IRS cap.
>
> Changes from v2:
>  - make use of the new PIPE_CAP_SHADER_SUPPORTED_IRS cap instead of
>    enabling the extension when PIPE_CAP_COMPUTE is enabled.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/mesa/state_tracker/st_extensions.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 660c05e..072e9fd 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -479,6 +479,7 @@ void st_init_extensions(struct pipe_screen *screen,
>  {
>     unsigned i;
>     int glsl_feature_level;
> +   int shader_supported_irs;
>     GLboolean *extension_table = (GLboolean *) extensions;
>
>     static const struct st_extension_cap_mapping cap_mapping[] = {
> @@ -1020,7 +1021,10 @@ void st_init_extensions(struct pipe_screen *screen,
>         screen->get_param(screen, PIPE_CAP_STRING_MARKER))
>        extensions->GREMEDY_string_marker = GL_TRUE;
>
> -   if (extensions->ARB_compute_shader) {
> +   shader_supported_irs =
> +      screen->get_shader_param(screen, PIPE_SHADER_COMPUTE,
> +                               PIPE_SHADER_CAP_SUPPORTED_IRS);

You should query for PIPE_CAP_COMPUTE first. If that returns false,
the get_shader_param function could reasonably be expected to not
properly handle the unexpected PIPE_SHADER_COMPUTE shader.

Also the shader_supported_irs thing seems a bit misnamed, since it
only refers to the compute shader supported irs...

> +   if (shader_supported_irs & (1 << PIPE_SHADER_IR_TGSI)) {
>        uint64_t grid_size[3], block_size[3];
>
>        screen->get_compute_param(screen, PIPE_COMPUTE_CAP_MAX_GRID_SIZE,
> @@ -1036,5 +1040,6 @@ void st_init_extensions(struct pipe_screen *screen,
>           consts->MaxComputeWorkGroupCount[i] = grid_size[i];
>           consts->MaxComputeWorkGroupSize[i] = block_size[i];
>        }
> +      extensions->ARB_compute_shader = true;
>     }
>  }
> --
> 2.6.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list