From 5c5c2dd48fe0910dc79d3187bed99a52b5ed2848 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 6 Apr 2020 11:22:55 +0100 Subject: [PATCH] radv/aco: enable 8/16-bit storage and int8/int16 on GFX8+ With this, Doom Eternal should now run with ACO on GFX8+. The generated 8/16-bit storage code is okay but the generated int8/int16 code is currently pretty bad but it works and apparently Doom Eternal doesn't actually use it (even though it requires it). Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Part-of: --- docs/relnotes/new_features.txt | 4 ++++ src/amd/vulkan/radv_device.c | 34 +++++++++++++++++-------------- src/amd/vulkan/radv_extensions.py | 7 ++++--- src/amd/vulkan/radv_shader.c | 10 +++++---- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 49541cf4763..701c1e5e912 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -8,3 +8,7 @@ GL_NV_viewport_array2 on nvc0 (GM200+). GL_NV_viewport_swizzle on nvc0 (GM200+). VK_KHR_shader_non_semantic_info on Intel, RADV. GL_EXT_draw_instanced on gles2 +VK_KHR_8bit_storage for ACO on GFX8+ +VK_KHR_16bit_storage for ACO on GFX8+ (storageInputOutput16 is still unsupported) +shaderInt16 for ACO on GFX9+ +VK_KHR_shader_float16_int8 for ACO on GFX8+ (shaderFloat16 is still unsupported) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index bed7062ec1d..75c72f5eb15 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -957,7 +957,7 @@ void radv_GetPhysicalDeviceFeatures( .shaderCullDistance = true, .shaderFloat64 = true, .shaderInt64 = true, - .shaderInt16 = pdevice->rad_info.chip_class >= GFX9 && !pdevice->use_aco, + .shaderInt16 = pdevice->rad_info.chip_class >= GFX9, .sparseBinding = true, .variableMultisampleRate = true, .inheritedQueries = true, @@ -999,9 +999,10 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES: { VkPhysicalDevice16BitStorageFeatures *features = (VkPhysicalDevice16BitStorageFeatures*)ext; - features->storageBuffer16BitAccess = !pdevice->use_aco; - features->uniformAndStorageBuffer16BitAccess = !pdevice->use_aco; - features->storagePushConstant16 = !pdevice->use_aco; + 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 && !pdevice->use_aco && LLVM_VERSION_MAJOR >= 9; break; } @@ -1100,16 +1101,17 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES: { VkPhysicalDevice8BitStorageFeatures *features = (VkPhysicalDevice8BitStorageFeatures *)ext; - features->storageBuffer8BitAccess = !pdevice->use_aco; - features->uniformAndStorageBuffer8BitAccess = !pdevice->use_aco; - features->storagePushConstant8 = !pdevice->use_aco; + bool enable = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; + features->storageBuffer8BitAccess = enable; + features->uniformAndStorageBuffer8BitAccess = enable; + features->storagePushConstant8 = enable; 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; + features->shaderInt8 = !pdevice->use_aco || pdevice->rad_info.chip_class >= GFX8; break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES: { @@ -1217,9 +1219,10 @@ void radv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES: { VkPhysicalDeviceVulkan11Features *features = (VkPhysicalDeviceVulkan11Features *)ext; - features->storageBuffer16BitAccess = !pdevice->use_aco; - features->uniformAndStorageBuffer16BitAccess = !pdevice->use_aco; - features->storagePushConstant16 = !pdevice->use_aco; + 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 && !pdevice->use_aco && LLVM_VERSION_MAJOR >= 9; features->multiview = true; features->multiviewGeometryShader = true; @@ -1234,15 +1237,16 @@ void radv_GetPhysicalDeviceFeatures2( 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 = !pdevice->use_aco; - features->uniformAndStorageBuffer8BitAccess = !pdevice->use_aco; - features->storagePushConstant8 = !pdevice->use_aco; + 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 = !pdevice->use_aco; + features->shaderInt8 = int8_enable; features->descriptorIndexing = true; features->shaderInputAttachmentArrayDynamicIndexing = true; features->shaderUniformTexelBufferArrayDynamicIndexing = true; diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py index 23a6bb6702f..ea789bbded7 100644 --- a/src/amd/vulkan/radv_extensions.py +++ b/src/amd/vulkan/radv_extensions.py @@ -52,7 +52,7 @@ class Extension: EXTENSIONS = [ Extension('VK_ANDROID_external_memory_android_hardware_buffer', 3, 'RADV_SUPPORT_ANDROID_HARDWARE_BUFFER && device->rad_info.has_syncobj_wait_for_submit'), Extension('VK_ANDROID_native_buffer', 5, 'ANDROID && device->rad_info.has_syncobj_wait_for_submit'), - Extension('VK_KHR_16bit_storage', 1, '!device->use_aco'), + Extension('VK_KHR_16bit_storage', 1, '!device->use_aco || device->rad_info.chip_class >= GFX8'), Extension('VK_KHR_bind_memory2', 1, True), Extension('VK_KHR_buffer_device_address', 1, True), Extension('VK_KHR_create_renderpass2', 1, True), @@ -92,7 +92,7 @@ EXTENSIONS = [ Extension('VK_KHR_shader_clock', 1, True), Extension('VK_KHR_shader_draw_parameters', 1, True), Extension('VK_KHR_shader_float_controls', 1, True), - Extension('VK_KHR_shader_float16_int8', 1, '!device->use_aco'), + Extension('VK_KHR_shader_float16_int8', 1, '!device->use_aco || device->rad_info.chip_class >= GFX8'), Extension('VK_KHR_shader_non_semantic_info', 1, True), Extension('VK_KHR_shader_subgroup_extended_types', 1, '!device->use_aco'), Extension('VK_KHR_spirv_1_4', 1, True), @@ -109,7 +109,7 @@ EXTENSIONS = [ Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_multiview', 1, True), Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), - Extension('VK_KHR_8bit_storage', 1, '!device->use_aco'), + Extension('VK_KHR_8bit_storage', 1, '!device->use_aco || device->rad_info.chip_class >= GFX8'), Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), Extension('VK_EXT_buffer_device_address', 1, True), @@ -258,6 +258,7 @@ def _init_exts_from_xml(xml): for ext in EXTENSIONS: if ext.type == 'device': + ext.enable = '(' + ext.enable + ')' for dep in extra_deps(ext): ext.enable += ' && ' + dep diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 42a664f7f36..36a7b5f5511 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -346,6 +346,8 @@ radv_shader_compile_to_nir(struct radv_device *device, } } } + bool int8_int16_enable = !device->physical_device->use_aco || + device->physical_device->rad_info.chip_class >= GFX8; const struct spirv_to_nir_options spirv_options = { .lower_ubo_ssbo_access_to_offsets = true, .caps = { @@ -369,8 +371,8 @@ radv_shader_compile_to_nir(struct radv_device *device, .image_ms_array = true, .image_read_without_format = true, .image_write_without_format = true, - .int8 = !device->physical_device->use_aco, - .int16 = !device->physical_device->use_aco, + .int8 = int8_int16_enable, + .int16 = int8_int16_enable, .int64 = true, .int64_atomics = true, .multiview = true, @@ -380,8 +382,8 @@ radv_shader_compile_to_nir(struct radv_device *device, .shader_clock = true, .shader_viewport_index_layer = true, .stencil_export = true, - .storage_8bit = !device->physical_device->use_aco, - .storage_16bit = !device->physical_device->use_aco, + .storage_8bit = int8_int16_enable, + .storage_16bit = int8_int16_enable, .storage_image_ms = true, .subgroup_arithmetic = true, .subgroup_ballot = true, -- 2.30.2