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)
features->shaderSubgroupExtendedTypes = VK_TRUE;
}
template<typename T>
static void getPhysicalDeviceScalarBlockLayoutFeatures(T *features)
{
features->scalarBlockLayout = VK_TRUE;
}
#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
template<typename T>
static void getPhysicalDeviceDeviceMemoryReportFeaturesEXT(T *features)
......@@ -256,7 +262,7 @@ static void getPhysicalDeviceVulkan12Features(T *features)
features->descriptorBindingVariableDescriptorCount = VK_FALSE;
features->runtimeDescriptorArray = VK_FALSE;
features->samplerFilterMinmax = VK_FALSE;
features->scalarBlockLayout = VK_FALSE;
getPhysicalDeviceScalarBlockLayoutFeatures(features);
getPhysicalDeviceImagelessFramebufferFeatures(features);
features->uniformBufferStandardLayout = VK_FALSE;
getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(features);
......@@ -328,6 +334,9 @@ void PhysicalDevice::getFeatures2(VkPhysicalDeviceFeatures2 *features) const
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR:
getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(reinterpret_cast<VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures *>(curExtension));
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES:
getPhysicalDeviceScalarBlockLayoutFeatures(reinterpret_cast<VkPhysicalDeviceScalarBlockLayoutFeatures *>(curExtension));
break;
#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT:
getPhysicalDeviceDeviceMemoryReportFeaturesEXT(reinterpret_cast<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *>(curExtension));
......
......@@ -74,12 +74,17 @@ std::vector<uint32_t> preprocessSpirv(
opt.RegisterPerformancePasses();
}
std::vector<uint32_t> optimized;
spvtools::OptimizerOptions options;
#if defined(NDEBUG)
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
std::vector<uint32_t> optimized;
opt.Run(code.data(), code.size(), &optimized, options);
if(false)
......
......@@ -31,7 +31,10 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
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
}
......
......@@ -396,6 +396,7 @@ static const VkExtensionProperties deviceExtensionProperties[] = {
{ VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME, VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION },
#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
// 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_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME, VK_KHR_IMAGELESS_FRAMEBUFFER_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
(void)imagelessFramebufferFeatures->imagelessFramebuffer;
}
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
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