From cea6d7ada5463d462043f61963eb83fc7f456cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Mon, 29 Sep 2025 14:17:26 +0200 Subject: [PATCH] v3d: expose GL_KHR_shader_subgroup for v71+ All the compiler support was implemented as part of the v3dv implementation (see commit 31e8740808c and MR#27211). We are using the same size/supported_stages and mostly the same supported features, so probably at some point it would be good to have a common place for that info. Zink reuses their definitions, but as far as I see it does that because the PIPE and equivalent VK definitions has the same values, that seems somewhat fragile. We don't support all features, and in order to support arithmetic we need to enable a lowering. Using CTS, right now we are passing 1023 tests out of 6053 (the rest are skipped). Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/compiler/vir.c | 1 + src/gallium/drivers/v3d/v3d_screen.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 8b58f0136ff..a4dcabef5a1 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1876,6 +1876,7 @@ v3d_attempt_compile(struct v3d_compile *c) .lower_subgroup_masks = true, .lower_relative_shuffle = true, .lower_quad = true, + .lower_reduce = true, }; NIR_PASS(_, c->s, nir_lower_subgroups, &subgroup_opts); diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 0226003eb71..0beb8481cd6 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -391,6 +391,19 @@ v3d_init_screen_caps(struct v3d_screen *screen) caps->device_reset_status_query = screen->devinfo.has_reset_counter; caps->robust_buffer_access_behavior = true; + + /* FIXME: same settings as v3dv, maybe put them in a common place. */ + if (screen->devinfo.ver >= 71) { + caps->shader_subgroup_size = V3D_CHANNELS; + caps->shader_subgroup_supported_stages = + BITFIELD_BIT(MESA_SHADER_FRAGMENT) | BITFIELD_BIT(MESA_SHADER_COMPUTE); + caps->shader_subgroup_supported_features = PIPE_SHADER_SUBGROUP_FEATURE_BASIC | + PIPE_SHADER_SUBGROUP_FEATURE_BALLOT | PIPE_SHADER_SUBGROUP_FEATURE_SHUFFLE | + PIPE_SHADER_SUBGROUP_FEATURE_SHUFFLE_RELATIVE | + PIPE_SHADER_SUBGROUP_FEATURE_VOTE | PIPE_SHADER_SUBGROUP_FEATURE_ARITHMETIC | + PIPE_SHADER_SUBGROUP_FEATURE_QUAD; + caps->shader_subgroup_quad_all_stages = false; + } } static bool