From e9ac86c283feb19a3520ddc57a4fb6314b0b343e Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 6 Mar 2023 00:19:12 +0100 Subject: [PATCH 57/97] vulkan: enable forcing of full subgroups --- libavutil/vulkan.c | 15 +++++++++++++-- libavutil/vulkan.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 9d607ee1ce..70d162772c 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -91,9 +91,13 @@ int ff_vk_load_props(FFVulkanContext *s) s->hprops = (VkPhysicalDeviceExternalMemoryHostPropertiesEXT) { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT, }; + s->subgroup_props = (VkPhysicalDeviceSubgroupSizeControlProperties) { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES, + .pNext = &s->hprops, + }; s->desc_buf_props = (VkPhysicalDeviceDescriptorBufferPropertiesEXT) { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT, - .pNext = &s->hprops, + .pNext = &s->subgroup_props, }; s->driver_props = (VkPhysicalDeviceDriverProperties) { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES, @@ -1281,13 +1285,20 @@ void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, } int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, - VkShaderStageFlags stage) + VkShaderStageFlags stage, uint32_t required_subgroup_size) { av_bprint_init(&shd->src, 0, AV_BPRINT_SIZE_UNLIMITED); shd->shader.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shd->shader.stage = stage; + if (required_subgroup_size) { + shd->shader.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT; + shd->shader.pNext = &shd->subgroup_info; + shd->subgroup_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO; + shd->subgroup_info.requiredSubgroupSize = required_subgroup_size; + } + shd->name = name; GLSLF(0, #version %i ,460); diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index 449ffbd334..1d5ece3f09 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -61,6 +61,7 @@ typedef struct FFVkSPIRVShader { AVBPrint src; int local_size[3]; /* Compute shader workgroup sizes */ VkPipelineShaderStageCreateInfo shader; + VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info; } FFVkSPIRVShader; typedef struct FFVulkanDescriptorSetBinding { @@ -217,6 +218,7 @@ typedef struct FFVulkanContext { VkPhysicalDeviceMemoryProperties mprops; VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops; VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props; + VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props; VkQueueFamilyQueryResultStatusPropertiesKHR *query_props; VkQueueFamilyVideoPropertiesKHR *video_props; VkQueueFamilyProperties2 *qf_props; @@ -399,7 +401,7 @@ int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, * Shader management. */ int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, - VkShaderStageFlags stage); + VkShaderStageFlags stage, uint32_t required_subgroup_size); void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z); void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio); int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, -- 2.40.0