Implement VK_KHR_uniform_buffer_standard_layout

UniformBufferStandardLayout changes the alignment rules for uniform buffers. This doesn't change SwiftShader's behavior, and is treated as always enabled for the purposes of validating inputs to SPIRV-Tools. Bug: b/169604082 Tests: dEQP-VK.ubo.* Change-Id: I0ec59ceb0bf6cc487f37e292a04e875268c37185 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49868Tested-by: 's avatarSean Risser <srisser@google.com> Commit-Queue: Sean Risser <srisser@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent f8b99b5b
......@@ -232,6 +232,12 @@ static void getPhysicalDeviceDeviceMemoryReportFeaturesEXT(T *features)
#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
template<typename T>
static void getPhysicalDeviceUniformBufferStandardLayoutFeatures(T *features)
{
features->uniformBufferStandardLayout = VK_TRUE;
}
template<typename T>
static void getPhysicalDeviceVulkan12Features(T *features)
{
features->samplerMirrorClampToEdge = VK_FALSE;
......@@ -264,7 +270,7 @@ static void getPhysicalDeviceVulkan12Features(T *features)
features->samplerFilterMinmax = VK_FALSE;
getPhysicalDeviceScalarBlockLayoutFeatures(features);
getPhysicalDeviceImagelessFramebufferFeatures(features);
features->uniformBufferStandardLayout = VK_FALSE;
getPhysicalDeviceUniformBufferStandardLayoutFeatures(features);
getPhysicalDeviceShaderSubgroupExtendedTypesFeatures(features);
getPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR(features);
features->hostQueryReset = VK_FALSE;
......@@ -342,6 +348,9 @@ void PhysicalDevice::getFeatures2(VkPhysicalDeviceFeatures2 *features) const
getPhysicalDeviceDeviceMemoryReportFeaturesEXT(reinterpret_cast<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *>(curExtension));
break;
#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES:
getPhysicalDeviceUniformBufferStandardLayoutFeatures(reinterpret_cast<VkPhysicalDeviceUniformBufferStandardLayoutFeatures *>(curExtension));
break;
default:
LOG_TRAP("curExtension->pNext->sType = %s", vk::Stringify(curExtension->sType).c_str());
break;
......
......@@ -74,18 +74,19 @@ std::vector<uint32_t> preprocessSpirv(
opt.RegisterPerformancePasses();
}
spvtools::OptimizerOptions options;
spvtools::OptimizerOptions optimizerOptions = {};
#if defined(NDEBUG)
options.set_run_validator(false);
optimizerOptions.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);
optimizerOptions.set_run_validator(true);
spvtools::ValidatorOptions validatorOptions = {};
validatorOptions.SetScalarBlockLayout(true); // VK_EXT_scalar_block_layout
validatorOptions.SetUniformBufferStandardLayout(true); // VK_KHR_uniform_buffer_standard_layout
optimizerOptions.set_validator_options(validatorOptions);
#endif
std::vector<uint32_t> optimized;
opt.Run(code.data(), code.size(), &optimized, options);
opt.Run(code.data(), code.size(), &optimized, optimizerOptions);
if(false)
{
......
......@@ -31,10 +31,11 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
spvtools::SpirvTools spirvTools(SPIRV_VERSION);
spvtools::ValidatorOptions options = {};
options.SetScalarBlockLayout(true);
spvtools::ValidatorOptions validatorOptions = {};
validatorOptions.SetScalarBlockLayout(true); // VK_EXT_scalar_block_layout
validatorOptions.SetUniformBufferStandardLayout(true); // VK_KHR_uniform_buffer_standard_layout
ASSERT(spirvTools.Validate(code, wordCount, options)); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522)
ASSERT(spirvTools.Validate(code, wordCount, validatorOptions)); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522)
#endif
}
......
......@@ -402,6 +402,7 @@ static const VkExtensionProperties deviceExtensionProperties[] = {
{ VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION },
{ VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME, VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION },
{ VK_KHR_SPIRV_1_4_EXTENSION_NAME, VK_KHR_SPIRV_1_4_SPEC_VERSION },
{ VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION },
};
static bool hasExtension(const char *extensionName, const VkExtensionProperties *extensionProperties, uint32_t extensionPropertiesCount)
......
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