From e1fa60838edf4c6b1c01311c5fbeb28db4d29f67 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 20 May 2020 09:07:49 +0200 Subject: [PATCH] radv: cleanup physical device features Similar to the physical device properties. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_device.c | 261 +++++++++++++++++++---------------- 1 file changed, 144 insertions(+), 117 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index b8f1ff4b7ff..482c104f2db 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -948,77 +948,168 @@ void radv_GetPhysicalDeviceFeatures( }; } +static void +radv_get_physical_device_features_1_1(struct radv_physical_device *pdevice, + VkPhysicalDeviceVulkan11Features *f) +{ + assert(f->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES); + + f->storageBuffer16BitAccess = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->uniformAndStorageBuffer16BitAccess = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->storagePushConstant16 = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->storageInputOutput16 = pdevice->rad_info.has_double_rate_fp16 && (LLVM_VERSION_MAJOR >= 9 || pdevice->use_aco); + f->multiview = true; + f->multiviewGeometryShader = true; + f->multiviewTessellationShader = true; + f->variablePointersStorageBuffer = true; + f->variablePointers = true; + f->protectedMemory = false; + f->samplerYcbcrConversion = true; + f->shaderDrawParameters = true; +} + +static void +radv_get_physical_device_features_1_2(struct radv_physical_device *pdevice, + VkPhysicalDeviceVulkan12Features *f) +{ + assert(f->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES); + + f->samplerMirrorClampToEdge = true; + f->drawIndirectCount = true; + f->storageBuffer8BitAccess = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->uniformAndStorageBuffer8BitAccess = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->storagePushConstant8 = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + f->shaderBufferInt64Atomics = LLVM_VERSION_MAJOR >= 9; + f->shaderSharedInt64Atomics = LLVM_VERSION_MAJOR >= 9; + f->shaderFloat16 = pdevice->rad_info.has_double_rate_fp16 && !pdevice->use_aco; + f->shaderInt8 = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + + f->descriptorIndexing = true; + f->shaderInputAttachmentArrayDynamicIndexing = true; + f->shaderUniformTexelBufferArrayDynamicIndexing = true; + f->shaderStorageTexelBufferArrayDynamicIndexing = true; + f->shaderUniformBufferArrayNonUniformIndexing = true; + f->shaderSampledImageArrayNonUniformIndexing = true; + f->shaderStorageBufferArrayNonUniformIndexing = true; + f->shaderStorageImageArrayNonUniformIndexing = true; + f->shaderInputAttachmentArrayNonUniformIndexing = true; + f->shaderUniformTexelBufferArrayNonUniformIndexing = true; + f->shaderStorageTexelBufferArrayNonUniformIndexing = true; + f->descriptorBindingUniformBufferUpdateAfterBind = true; + f->descriptorBindingSampledImageUpdateAfterBind = true; + f->descriptorBindingStorageImageUpdateAfterBind = true; + f->descriptorBindingStorageBufferUpdateAfterBind = true; + f->descriptorBindingUniformTexelBufferUpdateAfterBind = true; + f->descriptorBindingStorageTexelBufferUpdateAfterBind = true; + f->descriptorBindingUpdateUnusedWhilePending = true; + f->descriptorBindingPartiallyBound = true; + f->descriptorBindingVariableDescriptorCount = true; + f->runtimeDescriptorArray = true; + + f->samplerFilterMinmax = true; + f->scalarBlockLayout = pdevice->rad_info.chip_class >= GFX7; + f->imagelessFramebuffer = true; + f->uniformBufferStandardLayout = true; + f->shaderSubgroupExtendedTypes = !pdevice->use_aco; + f->separateDepthStencilLayouts = true; + f->hostQueryReset = true; + f->timelineSemaphore = pdevice->rad_info.has_syncobj_wait_for_submit; + f->bufferDeviceAddress = true; + f->bufferDeviceAddressCaptureReplay = false; + f->bufferDeviceAddressMultiDevice = false; + f->vulkanMemoryModel = false; + f->vulkanMemoryModelDeviceScope = false; + f->vulkanMemoryModelAvailabilityVisibilityChains = false; + f->shaderOutputViewportIndex = true; + f->shaderOutputLayer = true; + f->subgroupBroadcastDynamicId = true; +} + void radv_GetPhysicalDeviceFeatures2( VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures) { RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice); + radv_GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features); + + VkPhysicalDeviceVulkan11Features core_1_1 = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, + }; + radv_get_physical_device_features_1_1(pdevice, &core_1_1); + + VkPhysicalDeviceVulkan12Features core_1_2 = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, + }; + radv_get_physical_device_features_1_2(pdevice, &core_1_2); + +#define CORE_FEATURE(major, minor, feature) \ + features->feature = core_##major##_##minor.feature + vk_foreach_struct(ext, pFeatures->pNext) { switch (ext->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES: { VkPhysicalDeviceVariablePointersFeatures *features = (void *)ext; - features->variablePointersStorageBuffer = true; - features->variablePointers = true; + CORE_FEATURE(1, 1, variablePointersStorageBuffer); + CORE_FEATURE(1, 1, variablePointers); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES: { VkPhysicalDeviceMultiviewFeatures *features = (VkPhysicalDeviceMultiviewFeatures*)ext; - features->multiview = true; - features->multiviewGeometryShader = true; - features->multiviewTessellationShader = true; + CORE_FEATURE(1, 1, multiview); + CORE_FEATURE(1, 1, multiviewGeometryShader); + CORE_FEATURE(1, 1, multiviewTessellationShader); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES: { VkPhysicalDeviceShaderDrawParametersFeatures *features = (VkPhysicalDeviceShaderDrawParametersFeatures*)ext; - features->shaderDrawParameters = true; + CORE_FEATURE(1, 1, shaderDrawParameters); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES: { VkPhysicalDeviceProtectedMemoryFeatures *features = (VkPhysicalDeviceProtectedMemoryFeatures*)ext; - features->protectedMemory = false; + CORE_FEATURE(1, 1, protectedMemory); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES: { VkPhysicalDevice16BitStorageFeatures *features = (VkPhysicalDevice16BitStorageFeatures*)ext; - bool enable = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; - features->storageBuffer16BitAccess = enable; - features->uniformAndStorageBuffer16BitAccess = enable; - features->storagePushConstant16 = enable; - features->storageInputOutput16 = pdevice->rad_info.has_double_rate_fp16 && (LLVM_VERSION_MAJOR >= 9 || pdevice->use_aco); + CORE_FEATURE(1, 1, storageBuffer16BitAccess); + CORE_FEATURE(1, 1, uniformAndStorageBuffer16BitAccess); + CORE_FEATURE(1, 1, storagePushConstant16); + CORE_FEATURE(1, 1, storageInputOutput16); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES: { VkPhysicalDeviceSamplerYcbcrConversionFeatures *features = (VkPhysicalDeviceSamplerYcbcrConversionFeatures*)ext; - features->samplerYcbcrConversion = true; + CORE_FEATURE(1, 1, samplerYcbcrConversion); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES: { VkPhysicalDeviceDescriptorIndexingFeatures *features = (VkPhysicalDeviceDescriptorIndexingFeatures*)ext; - features->shaderInputAttachmentArrayDynamicIndexing = true; - features->shaderUniformTexelBufferArrayDynamicIndexing = true; - features->shaderStorageTexelBufferArrayDynamicIndexing = true; - features->shaderUniformBufferArrayNonUniformIndexing = true; - features->shaderSampledImageArrayNonUniformIndexing = true; - features->shaderStorageBufferArrayNonUniformIndexing = true; - features->shaderStorageImageArrayNonUniformIndexing = true; - features->shaderInputAttachmentArrayNonUniformIndexing = true; - features->shaderUniformTexelBufferArrayNonUniformIndexing = true; - features->shaderStorageTexelBufferArrayNonUniformIndexing = true; - features->descriptorBindingUniformBufferUpdateAfterBind = true; - features->descriptorBindingSampledImageUpdateAfterBind = true; - features->descriptorBindingStorageImageUpdateAfterBind = true; - features->descriptorBindingStorageBufferUpdateAfterBind = true; - features->descriptorBindingUniformTexelBufferUpdateAfterBind = true; - features->descriptorBindingStorageTexelBufferUpdateAfterBind = true; - features->descriptorBindingUpdateUnusedWhilePending = true; - features->descriptorBindingPartiallyBound = true; - features->descriptorBindingVariableDescriptorCount = true; - features->runtimeDescriptorArray = true; + CORE_FEATURE(1, 2, shaderInputAttachmentArrayDynamicIndexing); + CORE_FEATURE(1, 2, shaderUniformTexelBufferArrayDynamicIndexing); + CORE_FEATURE(1, 2, shaderStorageTexelBufferArrayDynamicIndexing); + CORE_FEATURE(1, 2, shaderUniformBufferArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderSampledImageArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderStorageBufferArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderStorageImageArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderInputAttachmentArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderUniformTexelBufferArrayNonUniformIndexing); + CORE_FEATURE(1, 2, shaderStorageTexelBufferArrayNonUniformIndexing); + CORE_FEATURE(1, 2, descriptorBindingUniformBufferUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingSampledImageUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingStorageImageUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingStorageBufferUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingUniformTexelBufferUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingStorageTexelBufferUpdateAfterBind); + CORE_FEATURE(1, 2, descriptorBindingUpdateUnusedWhilePending); + CORE_FEATURE(1, 2, descriptorBindingPartiallyBound); + CORE_FEATURE(1, 2, descriptorBindingVariableDescriptorCount); + CORE_FEATURE(1, 2, runtimeDescriptorArray); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT: { @@ -1045,7 +1136,7 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES: { VkPhysicalDeviceScalarBlockLayoutFeatures *features = (VkPhysicalDeviceScalarBlockLayoutFeatures *)ext; - features->scalarBlockLayout = pdevice->rad_info.chip_class >= GFX7; + CORE_FEATURE(1, 2, scalarBlockLayout); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT: { @@ -1065,9 +1156,9 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES: { VkPhysicalDeviceBufferDeviceAddressFeatures *features = (VkPhysicalDeviceBufferDeviceAddressFeatures *)ext; - features->bufferDeviceAddress = true; - features->bufferDeviceAddressCaptureReplay = false; - features->bufferDeviceAddressMultiDevice = false; + CORE_FEATURE(1, 2, bufferDeviceAddress); + CORE_FEATURE(1, 2, bufferDeviceAddressCaptureReplay); + CORE_FEATURE(1, 2, bufferDeviceAddressMultiDevice); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT: { @@ -1079,30 +1170,29 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES: { VkPhysicalDeviceHostQueryResetFeatures *features = (VkPhysicalDeviceHostQueryResetFeatures *)ext; - features->hostQueryReset = true; + CORE_FEATURE(1, 2, hostQueryReset); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES: { VkPhysicalDevice8BitStorageFeatures *features = (VkPhysicalDevice8BitStorageFeatures *)ext; - bool enable = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; - features->storageBuffer8BitAccess = enable; - features->uniformAndStorageBuffer8BitAccess = enable; - features->storagePushConstant8 = enable; + CORE_FEATURE(1, 2, storageBuffer8BitAccess); + CORE_FEATURE(1, 2, uniformAndStorageBuffer8BitAccess); + CORE_FEATURE(1, 2, storagePushConstant8); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES: { VkPhysicalDeviceShaderFloat16Int8Features *features = (VkPhysicalDeviceShaderFloat16Int8Features*)ext; - features->shaderFloat16 = pdevice->rad_info.has_double_rate_fp16 && !pdevice->use_aco; - features->shaderInt8 = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + CORE_FEATURE(1, 2, shaderFloat16); + CORE_FEATURE(1, 2, shaderInt8); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES: { VkPhysicalDeviceShaderAtomicInt64Features *features = (VkPhysicalDeviceShaderAtomicInt64Features *)ext; - features->shaderBufferInt64Atomics = LLVM_VERSION_MAJOR >= 9; - features->shaderSharedInt64Atomics = LLVM_VERSION_MAJOR >= 9; + CORE_FEATURE(1, 2, shaderBufferInt64Atomics); + CORE_FEATURE(1, 2, shaderSharedInt64Atomics); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT: { @@ -1135,7 +1225,7 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES: { VkPhysicalDeviceUniformBufferStandardLayoutFeatures *features = (VkPhysicalDeviceUniformBufferStandardLayoutFeatures *)ext; - features->uniformBufferStandardLayout = true; + CORE_FEATURE(1, 2, uniformBufferStandardLayout); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT: { @@ -1147,7 +1237,7 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES: { VkPhysicalDeviceImagelessFramebufferFeatures *features = (VkPhysicalDeviceImagelessFramebufferFeatures *)ext; - features->imagelessFramebuffer = true; + CORE_FEATURE(1, 2, imagelessFramebuffer); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR: { @@ -1172,7 +1262,7 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES: { VkPhysicalDeviceTimelineSemaphoreFeatures *features = (VkPhysicalDeviceTimelineSemaphoreFeatures *) ext; - features->timelineSemaphore = true; + CORE_FEATURE(1, 2, timelineSemaphore); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT: { @@ -1191,84 +1281,21 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES: { VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures *features = (VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures *)ext; - features->shaderSubgroupExtendedTypes = !pdevice->use_aco; + CORE_FEATURE(1, 2, shaderSubgroupExtendedTypes); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR: { VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *features = (VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *)ext; - features->separateDepthStencilLayouts = true; + CORE_FEATURE(1, 2, separateDepthStencilLayouts); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES: { - VkPhysicalDeviceVulkan11Features *features = - (VkPhysicalDeviceVulkan11Features *)ext; - bool storage16_enable = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; - features->storageBuffer16BitAccess = storage16_enable; - features->uniformAndStorageBuffer16BitAccess = storage16_enable; - features->storagePushConstant16 = storage16_enable; - features->storageInputOutput16 = pdevice->rad_info.has_double_rate_fp16 && (LLVM_VERSION_MAJOR >= 9 || pdevice->use_aco); - features->multiview = true; - features->multiviewGeometryShader = true; - features->multiviewTessellationShader = true; - features->variablePointersStorageBuffer = true; - features->variablePointers = true; - features->protectedMemory = false; - features->samplerYcbcrConversion = true; - features->shaderDrawParameters = true; + radv_get_physical_device_features_1_1(pdevice, (void *)ext); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES: { - VkPhysicalDeviceVulkan12Features *features = - (VkPhysicalDeviceVulkan12Features *)ext; - bool int8_enable = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; - features->samplerMirrorClampToEdge = true; - features->drawIndirectCount = true; - features->storageBuffer8BitAccess = int8_enable; - features->uniformAndStorageBuffer8BitAccess = int8_enable; - features->storagePushConstant8 = int8_enable; - features->shaderBufferInt64Atomics = LLVM_VERSION_MAJOR >= 9; - features->shaderSharedInt64Atomics = LLVM_VERSION_MAJOR >= 9; - features->shaderFloat16 = pdevice->rad_info.has_double_rate_fp16 && !pdevice->use_aco; - features->shaderInt8 = int8_enable; - features->descriptorIndexing = true; - features->shaderInputAttachmentArrayDynamicIndexing = true; - features->shaderUniformTexelBufferArrayDynamicIndexing = true; - features->shaderStorageTexelBufferArrayDynamicIndexing = true; - features->shaderUniformBufferArrayNonUniformIndexing = true; - features->shaderSampledImageArrayNonUniformIndexing = true; - features->shaderStorageBufferArrayNonUniformIndexing = true; - features->shaderStorageImageArrayNonUniformIndexing = true; - features->shaderInputAttachmentArrayNonUniformIndexing = true; - features->shaderUniformTexelBufferArrayNonUniformIndexing = true; - features->shaderStorageTexelBufferArrayNonUniformIndexing = true; - features->descriptorBindingUniformBufferUpdateAfterBind = true; - features->descriptorBindingSampledImageUpdateAfterBind = true; - features->descriptorBindingStorageImageUpdateAfterBind = true; - features->descriptorBindingStorageBufferUpdateAfterBind = true; - features->descriptorBindingUniformTexelBufferUpdateAfterBind = true; - features->descriptorBindingStorageTexelBufferUpdateAfterBind = true; - features->descriptorBindingUpdateUnusedWhilePending = true; - features->descriptorBindingPartiallyBound = true; - features->descriptorBindingVariableDescriptorCount = true; - features->runtimeDescriptorArray = true; - features->samplerFilterMinmax = true; - features->scalarBlockLayout = pdevice->rad_info.chip_class >= GFX7; - features->imagelessFramebuffer = true; - features->uniformBufferStandardLayout = true; - features->shaderSubgroupExtendedTypes = !pdevice->use_aco; - features->separateDepthStencilLayouts = true; - features->hostQueryReset = true; - features->timelineSemaphore = pdevice->rad_info.has_syncobj_wait_for_submit; - features->bufferDeviceAddress = true; - features->bufferDeviceAddressCaptureReplay = false; - features->bufferDeviceAddressMultiDevice = false; - features->vulkanMemoryModel = false; - features->vulkanMemoryModelDeviceScope = false; - features->vulkanMemoryModelAvailabilityVisibilityChains = false; - features->shaderOutputViewportIndex = true; - features->shaderOutputLayer = true; - features->subgroupBroadcastDynamicId = true; + radv_get_physical_device_features_1_2(pdevice, (void *)ext); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT: { @@ -1319,7 +1346,7 @@ void radv_GetPhysicalDeviceFeatures2( break; } } - radv_GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features); +#undef CORE_FEATURE } static size_t -- 2.30.2