From 661b9061d47fbd8826093345fabd7246d655a85f Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Tue, 23 Jul 2024 17:03:15 +0800 Subject: [PATCH] gallium: add caps for KHR_shader_subgroup Signed-off-by: Qiang Yu Part-of: --- docs/gallium/screen.rst | 4 ++++ src/gallium/auxiliary/util/u_screen.c | 6 ++++++ src/gallium/include/pipe/p_defines.h | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 6ef8562b10d..fcfe8194c06 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -650,6 +650,10 @@ The integer capabilities: * ``PIPE_CAP_PERFORMANCE_MONITOR``: Whether GL_AMD_performance_monitor should be exposed. * ``PIPE_CAP_TEXTURE_SAMPLER_INDEPENDENT``: Whether sampler views and sampler states are independent objects, meaning both can be freely mixed and matched by the frontend. This isn't required for OpenGL where on the shader level those are the same object. However for proper gallium nine and OpenCL support this is required. * ``PIPE_CAP_ASTC_DECODE_MODE``: Whether the driver supports ASTC decode precision. The :ext:`GL_KHR_texture_compression_astc_decode_mode` extension will only get exposed if :ext:`GL_KHR_texture_compression_astc_ldr` is also supported. +* ``PIPE_CAP_SHADER_SUBGROUP_SIZE``: A fixed subgroup size shader runs on GPU when GLSL GL_KHR_shader_subgroup_* extensions are enabled. +* ``PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_STAGES``: Bitmask of Shader stages which support GL_KHR_shader_subgroup_* intrinsics. +* ``PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES``: Bitmask of shader subgroup features listed in GL_KHR_shader_subgroup. +* ``PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES``: Whether shader subgroup quad operations are supported by shader stages other than fragment shader. .. _pipe_capf: diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 929e2e798f0..70057fb1bd0 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -561,6 +561,12 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, return pscreen->get_driver_query_info && pscreen->get_driver_query_group_info && pscreen->get_driver_query_group_info(pscreen, 0, NULL) != 0; + case PIPE_CAP_SHADER_SUBGROUP_SIZE: + case PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_STAGES: + case PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES: + case PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES: + return 0; + default: unreachable("bad PIPE_CAP_*"); } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 1427faf31a8..614d598f886 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -664,6 +664,19 @@ enum pipe_conservative_raster_mode #define PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER (1 << 4) #define PIPE_IMAGE_ACCESS_DRIVER_INTERNAL (1 << 5) +/** + * Shader subgroup feature flags aligned with GL_KHR_shader_subgroup. + */ +#define PIPE_SHADER_SUBGROUP_FEATURE_BASIC (1 << 0) +#define PIPE_SHADER_SUBGROUP_FEATURE_VOTE (1 << 1) +#define PIPE_SHADER_SUBGROUP_FEATURE_ARITHMETIC (1 << 2) +#define PIPE_SHADER_SUBGROUP_FEATURE_BALLOT (1 << 3) +#define PIPE_SHADER_SUBGROUP_FEATURE_SHUFFLE (1 << 4) +#define PIPE_SHADER_SUBGROUP_FEATURE_SHUFFLE_RELATIVE (1 << 5) +#define PIPE_SHADER_SUBGROUP_FEATURE_CLUSTERED (1 << 6) +#define PIPE_SHADER_SUBGROUP_FEATURE_QUAD (1 << 7) +#define PIPE_SHADER_SUBGROUP_NUM_FEATURES 8 + /** * Implementation capabilities/limits which are queried through * pipe_screen::get_param() @@ -954,6 +967,11 @@ enum pipe_cap PIPE_CAP_PERFORMANCE_MONITOR, PIPE_CAP_TEXTURE_SAMPLER_INDEPENDENT, PIPE_CAP_ASTC_DECODE_MODE, + /** For GL_KHR_shader_subgroup */ + PIPE_CAP_SHADER_SUBGROUP_SIZE, + PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_STAGES, + PIPE_CAP_SHADER_SUBGROUP_SUPPORTED_FEATURES, + PIPE_CAP_SHADER_SUBGROUP_QUAD_ALL_STAGES, PIPE_CAP_LAST, /* XXX do not add caps after PIPE_CAP_LAST! */ };