[Mesa-dev] [PATCH v2 40/42] i965: Enable ARB_compute_shader extension on supported hardware

Iago Toral itoral at igalia.com
Wed Nov 25 04:41:44 PST 2015


Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

On Tue, 2015-11-17 at 21:55 -0800, Jordan Justen wrote:
> Enable ARB_compute_shader on gen7+, on hardware that supports the
> OpenGL 4.3 requirements of a local group size of 1024.
> 
> With SIMD16 support, this is limited to Ivy Bridge and Haswell.
> 
> Broadwell will work with a local group size up to 896 on SIMD16
> meaning programs that use this size or lower should run when setting
> MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader.
> 
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_context.c      | 11 ++++++-----
>  src/mesa/drivers/dri/i965/intel_extensions.c |  2 ++
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 2ea0a9e..fc32a2f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -330,7 +330,9 @@ brw_initialize_context_constants(struct brw_context *brw)
>        [MESA_SHADER_TESS_EVAL] = false,
>        [MESA_SHADER_GEOMETRY] = brw->gen >= 6,
>        [MESA_SHADER_FRAGMENT] = true,
> -      [MESA_SHADER_COMPUTE] = _mesa_extension_override_enables.ARB_compute_shader,
> +      [MESA_SHADER_COMPUTE] =
> +         (ctx->Const.MaxComputeWorkGroupSize[0] >= 1024) ||
> +         _mesa_extension_override_enables.ARB_compute_shader,
>     };
>  
>     unsigned num_stages = 0;
> @@ -613,7 +615,7 @@ brw_initialize_context_constants(struct brw_context *brw)
>  }
>  
>  static void
> -brw_adjust_cs_context_constants(struct brw_context *brw)
> +brw_initialize_cs_context_constants(struct brw_context *brw, unsigned max_threads)
>  {
>     struct gl_context *ctx = &brw->ctx;
>  
> @@ -627,7 +629,7 @@ brw_adjust_cs_context_constants(struct brw_context *brw)
>      */
>     const int simd_size = ctx->API == API_OPENGL_CORE ? 16 : 8;
>  
> -   const uint32_t max_invocations = simd_size * brw->max_cs_threads;
> +   const uint32_t max_invocations = simd_size * max_threads;
>     ctx->Const.MaxComputeWorkGroupSize[0] = max_invocations;
>     ctx->Const.MaxComputeWorkGroupSize[1] = max_invocations;
>     ctx->Const.MaxComputeWorkGroupSize[2] = max_invocations;
> @@ -817,6 +819,7 @@ brwCreateContext(gl_api api,
>     if (INTEL_DEBUG & DEBUG_PERF)
>        brw->perf_debug = true;
>  
> +   brw_initialize_cs_context_constants(brw, devinfo->max_cs_threads);
>     brw_initialize_context_constants(brw);
>  
>     ctx->Const.ResetStrategy = notify_reset
> @@ -871,8 +874,6 @@ brwCreateContext(gl_api api,
>     brw->urb.max_ds_entries = devinfo->urb.max_ds_entries;
>     brw->urb.max_gs_entries = devinfo->urb.max_gs_entries;
>  
> -   brw_adjust_cs_context_constants(brw);
> -
>     /* Estimate the size of the mappable aperture into the GTT.  There's an
>      * ioctl to get the whole GTT size, but not one to get the mappable subset.
>      * It turns out it's basically always 256MB, though some ancient hardware
> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c
> index 81215db..6326cfc 100644
> --- a/src/mesa/drivers/dri/i965/intel_extensions.c
> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c
> @@ -356,6 +356,8 @@ intelInitExtensions(struct gl_context *ctx)
>           ctx->Extensions.ARB_viewport_array = true;
>           ctx->Extensions.AMD_vertex_shader_viewport_index = true;
>           ctx->Extensions.ARB_shader_subroutine = true;
> +         if (ctx->Const.MaxComputeWorkGroupSize[0] >= 1024)
> +            ctx->Extensions.ARB_compute_shader = true;
>        }
>     }
>  




More information about the mesa-dev mailing list