Commit 4f907507 by Nicolas Capens Committed by Nicolas Capens

Implement VK_EXT_scalar_block_layout support

This extension is relied on by dEQP-VK.robustness.image_robustness.* but it is only checked for since dEQP 1.2.5. Tests: dEQP-VK.* Bug: b/159329067 Bug: b/167692239 Change-Id: I52cc47302534537b4c95ea01b19308d9d39d9632 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51128Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 31cc1f14
...@@ -217,6 +217,12 @@ static void getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(T *features) ...@@ -217,6 +217,12 @@ static void getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(T *features)
features->shaderSubgroupExtendedTypes = VK_TRUE; features->shaderSubgroupExtendedTypes = VK_TRUE;
} }
template<typename T>
static void getPhysicalDeviceScalarBlockLayoutFeatures(T *features)
{
features->scalarBlockLayout = VK_TRUE;
}
#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT #ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
template<typename T> template<typename T>
static void getPhysicalDeviceDeviceMemoryReportFeaturesEXT(T *features) static void getPhysicalDeviceDeviceMemoryReportFeaturesEXT(T *features)
...@@ -256,7 +262,7 @@ static void getPhysicalDeviceVulkan12Features(T *features) ...@@ -256,7 +262,7 @@ static void getPhysicalDeviceVulkan12Features(T *features)
features->descriptorBindingVariableDescriptorCount = VK_FALSE; features->descriptorBindingVariableDescriptorCount = VK_FALSE;
features->runtimeDescriptorArray = VK_FALSE; features->runtimeDescriptorArray = VK_FALSE;
features->samplerFilterMinmax = VK_FALSE; features->samplerFilterMinmax = VK_FALSE;
features->scalarBlockLayout = VK_FALSE; getPhysicalDeviceScalarBlockLayoutFeatures(features);
getPhysicalDeviceImagelessFramebufferFeatures(features); getPhysicalDeviceImagelessFramebufferFeatures(features);
features->uniformBufferStandardLayout = VK_FALSE; features->uniformBufferStandardLayout = VK_FALSE;
getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(features); getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(features);
...@@ -328,6 +334,9 @@ void PhysicalDevice::getFeatures2(VkPhysicalDeviceFeatures2 *features) const ...@@ -328,6 +334,9 @@ void PhysicalDevice::getFeatures2(VkPhysicalDeviceFeatures2 *features) const
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR:
getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(reinterpret_cast<VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures *>(curExtension)); getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(reinterpret_cast<VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures *>(curExtension));
break; break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES:
getPhysicalDeviceScalarBlockLayoutFeatures(reinterpret_cast<VkPhysicalDeviceScalarBlockLayoutFeatures *>(curExtension));
break;
#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT #ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT:
getPhysicalDeviceDeviceMemoryReportFeaturesEXT(reinterpret_cast<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *>(curExtension)); getPhysicalDeviceDeviceMemoryReportFeaturesEXT(reinterpret_cast<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *>(curExtension));
......
...@@ -74,12 +74,17 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -74,12 +74,17 @@ std::vector<uint32_t> preprocessSpirv(
opt.RegisterPerformancePasses(); opt.RegisterPerformancePasses();
} }
std::vector<uint32_t> optimized;
spvtools::OptimizerOptions options; spvtools::OptimizerOptions options;
#if defined(NDEBUG) #if defined(NDEBUG)
options.set_run_validator(false); options.set_run_validator(false);
#else
options.set_run_validator(true);
spvtools::ValidatorOptions validatorOptions;
validatorOptions.SetScalarBlockLayout(true); // VK_EXT_scalar_block_layout
options.set_validator_options(validatorOptions);
#endif #endif
std::vector<uint32_t> optimized;
opt.Run(code.data(), code.size(), &optimized, options); opt.Run(code.data(), code.size(), &optimized, options);
if(false) if(false)
......
...@@ -31,7 +31,10 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me ...@@ -31,7 +31,10 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
spvtools::SpirvTools spirvTools(SPIRV_VERSION); spvtools::SpirvTools spirvTools(SPIRV_VERSION);
ASSERT(spirvTools.Validate(getCode())); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522) spvtools::ValidatorOptions options = {};
options.SetScalarBlockLayout(true);
ASSERT(spirvTools.Validate(code, wordCount, options)); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522)
#endif #endif
} }
......
...@@ -396,6 +396,7 @@ static const VkExtensionProperties deviceExtensionProperties[] = { ...@@ -396,6 +396,7 @@ static const VkExtensionProperties deviceExtensionProperties[] = {
{ VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME, VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION }, { VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME, VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION },
#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT #endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
// Vulkan 1.2 promoted extensions // Vulkan 1.2 promoted extensions
{ VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME, VK_EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION },
{ VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION }, { VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION },
{ VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME, VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION }, { VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME, VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION },
{ VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION }, { VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION },
...@@ -772,6 +773,14 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -772,6 +773,14 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
(void)imagelessFramebufferFeatures->imagelessFramebuffer; (void)imagelessFramebufferFeatures->imagelessFramebuffer;
} }
break; break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES:
{
const VkPhysicalDeviceScalarBlockLayoutFeatures *scalarBlockLayoutFeatures = reinterpret_cast<const VkPhysicalDeviceScalarBlockLayoutFeatures *>(extensionCreateInfo);
// VK_EXT_scalar_block_layout is supported, allowing C-like structure layout for SPIR-V blocks.
(void)scalarBlockLayoutFeatures->scalarBlockLayout;
}
break;
#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT #ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT:
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment