From db083070f03fc033ea5ff43200a9a1fcb2b73df0 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Thu, 19 Jan 2023 13:30:49 -0800 Subject: [PATCH] dzn: Implement subgroup size control extension Part-of: --- src/microsoft/vulkan/dzn_device.c | 9 +++++---- src/microsoft/vulkan/dzn_pipeline.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c index d5fcb94..e083bb2 100644 --- a/src/microsoft/vulkan/dzn_device.c +++ b/src/microsoft/vulkan/dzn_device.c @@ -109,6 +109,7 @@ dzn_physical_device_get_extensions(struct dzn_physical_device *pdev) #endif .EXT_shader_subgroup_ballot = true, .EXT_shader_subgroup_vote = true, + .EXT_subgroup_size_control = true, .EXT_vertex_attribute_divisor = true, }; } @@ -1411,8 +1412,8 @@ dzn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, .privateData = true, .shaderDemoteToHelperInvocation = false, .shaderTerminateInvocation = false, - .subgroupSizeControl = false, - .computeFullSubgroups = false, + .subgroupSizeControl = pdev->options1.WaveOps && pdev->shader_model >= D3D_SHADER_MODEL_6_6, + .computeFullSubgroups = true, .synchronization2 = true, .textureCompressionASTC_HDR = false, .shaderZeroInitializeWorkgroupMemory = false, @@ -1817,10 +1818,10 @@ dzn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVulkan13Properties core_1_3 = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES, .minSubgroupSize = pdevice->options1.WaveOps ? pdevice->options1.WaveLaneCountMin : 1, - .minSubgroupSize = pdevice->options1.WaveOps ? pdevice->options1.WaveLaneCountMax : 1, + .maxSubgroupSize = pdevice->options1.WaveOps ? pdevice->options1.WaveLaneCountMax : 1, .maxComputeWorkgroupSubgroups = D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP / (pdevice->options1.WaveOps ? pdevice->options1.WaveLaneCountMin : 1), - .requiredSubgroupSizeStages = 0, + .requiredSubgroupSizeStages = VK_SHADER_STAGE_COMPUTE_BIT, }; vk_foreach_struct(ext, pProperties->pNext) { diff --git a/src/microsoft/vulkan/dzn_pipeline.c b/src/microsoft/vulkan/dzn_pipeline.c index dd3e7d2..19928fa 100644 --- a/src/microsoft/vulkan/dzn_pipeline.c +++ b/src/microsoft/vulkan/dzn_pipeline.c @@ -195,6 +195,7 @@ struct dzn_nir_options { bool lower_view_index_to_rt_layer; enum pipe_format *vi_conversions; const nir_shader_compiler_options *nir_opts; + enum gl_subgroup_size subgroup_size; }; static VkResult @@ -259,6 +260,7 @@ dzn_pipeline_get_nir_shader(struct dzn_device *device, if (needs_conv) NIR_PASS_V(*nir, dxil_nir_lower_vs_vertex_conversion, options->vi_conversions); } + (*nir)->info.subgroup_size = options->subgroup_size; if (cache) vk_pipeline_cache_add_nir(cache, hash, SHA1_DIGEST_LENGTH, *nir); @@ -791,6 +793,12 @@ dzn_graphics_pipeline_compile_shaders(struct dzn_device *device, struct mesa_sha1 nir_hash_ctx; uint8_t nir_hash[SHA1_DIGEST_LENGTH]; + const VkPipelineShaderStageRequiredSubgroupSizeCreateInfo *subgroup_size = + (const VkPipelineShaderStageRequiredSubgroupSizeCreateInfo *) + vk_find_struct_const(stages[stage].info->pNext, PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO); + enum gl_subgroup_size subgroup_enum = subgroup_size && subgroup_size->requiredSubgroupSize >= 8 ? + subgroup_size->requiredSubgroupSize : SUBGROUP_SIZE_FULL_SUBGROUPS; + if (cache) { _mesa_sha1_init(&nir_hash_ctx); if (stage != MESA_SHADER_FRAGMENT) @@ -803,6 +811,7 @@ dzn_graphics_pipeline_compile_shaders(struct dzn_device *device, _mesa_sha1_update(&nir_hash_ctx, &z_flip_mask, sizeof(z_flip_mask)); _mesa_sha1_update(&nir_hash_ctx, &lower_view_index, sizeof(lower_view_index)); } + _mesa_sha1_update(&nir_hash_ctx, &subgroup_enum, sizeof(subgroup_enum)); _mesa_sha1_update(&nir_hash_ctx, stages[stage].spirv_hash, sizeof(stages[stage].spirv_hash)); _mesa_sha1_final(&nir_hash_ctx, nir_hash); } @@ -815,7 +824,8 @@ dzn_graphics_pipeline_compile_shaders(struct dzn_device *device, .lower_view_index = lower_view_index, .lower_view_index_to_rt_layer = stage == last_raster_stage ? lower_view_index : false, .vi_conversions = vi_conversions, - .nir_opts = &nir_opts + .nir_opts = &nir_opts, + .subgroup_size = subgroup_enum, }; ret = dzn_pipeline_get_nir_shader(device, layout, -- 2.7.4