From 03655dfda12c16f13b0e132282a5ef779b925b93 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 28 Aug 2024 10:17:48 -0700 Subject: [PATCH] compiler, vk: Support subgroup size of 4 Relax the assert and assign it an enum value Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/shader_enums.h | 1 + src/intel/compiler/brw_nir.c | 3 +++ src/intel/compiler/elk/elk_nir.c | 3 +++ src/vulkan/runtime/vk_pipeline.c | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 45dda151689..a1e20bb7e8d 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -1586,6 +1586,7 @@ enum ENUM_PACKED gl_subgroup_size * also the subgroup size. If any new values are added, they must respect * this invariant. */ + SUBGROUP_SIZE_REQUIRE_4 = 4, /**< VK_EXT_subgroup_size_control */ SUBGROUP_SIZE_REQUIRE_8 = 8, /**< VK_EXT_subgroup_size_control */ SUBGROUP_SIZE_REQUIRE_16 = 16, /**< VK_EXT_subgroup_size_control */ SUBGROUP_SIZE_REQUIRE_32 = 32, /**< VK_EXT_subgroup_size_control */ diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index efc0e76f880..3f2516a65fa 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -1911,6 +1911,9 @@ get_subgroup_size(const struct shader_info *info, unsigned max_subgroup_size) */ return info->stage == MESA_SHADER_FRAGMENT ? 0 : max_subgroup_size; + case SUBGROUP_SIZE_REQUIRE_4: + unreachable("Unsupported subgroup size type"); + case SUBGROUP_SIZE_REQUIRE_8: case SUBGROUP_SIZE_REQUIRE_16: case SUBGROUP_SIZE_REQUIRE_32: diff --git a/src/intel/compiler/elk/elk_nir.c b/src/intel/compiler/elk/elk_nir.c index 48f8ec6297b..d0ab5888900 100644 --- a/src/intel/compiler/elk/elk_nir.c +++ b/src/intel/compiler/elk/elk_nir.c @@ -1616,6 +1616,9 @@ get_subgroup_size(const struct shader_info *info, unsigned max_subgroup_size) */ return info->stage == MESA_SHADER_FRAGMENT ? 0 : max_subgroup_size; + case SUBGROUP_SIZE_REQUIRE_4: + unreachable("Unsupported subgroup size type"); + case SUBGROUP_SIZE_REQUIRE_8: case SUBGROUP_SIZE_REQUIRE_16: case SUBGROUP_SIZE_REQUIRE_32: diff --git a/src/vulkan/runtime/vk_pipeline.c b/src/vulkan/runtime/vk_pipeline.c index ac08df2be87..6c68b23d6ca 100644 --- a/src/vulkan/runtime/vk_pipeline.c +++ b/src/vulkan/runtime/vk_pipeline.c @@ -110,7 +110,7 @@ vk_get_subgroup_size(uint32_t spirv_version, uint32_t req_subgroup_size = get_required_subgroup_size(info_pNext); if (req_subgroup_size > 0) { assert(util_is_power_of_two_nonzero(req_subgroup_size)); - assert(req_subgroup_size >= 8 && req_subgroup_size <= 128); + assert(req_subgroup_size >= 4 && req_subgroup_size <= 128); return req_subgroup_size; } else if (allow_varying || spirv_version >= 0x10600) { /* Starting with SPIR-V 1.6, varying subgroup size the default */