Add new ShaderBuildOption to enable Workgroup scalar offsets
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 4 Feb 2021 19:28:32 +0000 (11:28 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 15 Feb 2021 13:19:47 +0000 (13:19 +0000)
This need to be explicitly set in the SPIR-V validator and it is
independent of the use of scalar offsets in other storage classes.
Equivalent to --workgroup-scalar-block-layout option in spirv-val.

Components: Vulkan

Affects: dEQP-VK.*

Change-Id: I903d4c700a08d7b03ccbd3f82274379c6bd6455e
(cherry picked from commit 147bbb57041f6e243966e18d67887eac3baf9b4f)

external/vulkancts/framework/vulkan/vkShaderProgram.hpp
external/vulkancts/framework/vulkan/vkSpirVAsm.cpp
external/vulkancts/framework/vulkan/vkValidatorOptions.hpp

index f0ec36c..92ffca1 100644 (file)
@@ -44,7 +44,8 @@ struct ShaderBuildOptions
                FLAG_USE_STORAGE_BUFFER_STORAGE_CLASS   = (1u<<0),
                FLAG_ALLOW_RELAXED_OFFSETS                              = (1u<<1),      // allow block offsets to follow VK_KHR_relaxed_block_layout
                FLAG_ALLOW_SCALAR_OFFSETS                               = (1u<<2),      // allow block offsets to follow VK_EXT_scalar_block_layout
-               FLAG_ALLOW_STD430_UBOS                                  = (1u<<3)       // allow block offsets to follow VK_EXT_uniform_buffer_standard_layout
+               FLAG_ALLOW_STD430_UBOS                                  = (1u<<3),      // allow block offsets to follow VK_EXT_uniform_buffer_standard_layout
+               FLAG_ALLOW_WORKGROUP_SCALAR_OFFSETS             = (1u<<4),      // allow scalar block offsets for Workgroup memory, part of VK_KHR_workgroup_memory_explicit_layout
        };
 
        deUint32                vulkanVersion;
@@ -69,6 +70,7 @@ struct ShaderBuildOptions
        SpirvValidatorOptions getSpirvValidatorOptions() const
        {
                SpirvValidatorOptions::BlockLayoutRules rules = SpirvValidatorOptions::kDefaultBlockLayout;
+               deUint32 validator_flags = 0u;
 
                if (flags & FLAG_ALLOW_SCALAR_OFFSETS)
                {
@@ -83,7 +85,12 @@ struct ShaderBuildOptions
                        rules = SpirvValidatorOptions::kRelaxedBlockLayout;
                }
 
-               return SpirvValidatorOptions(vulkanVersion, rules, supports_VK_KHR_spirv_1_4);
+               if (flags & FLAG_ALLOW_WORKGROUP_SCALAR_OFFSETS)
+               {
+                       validator_flags |= SpirvValidatorOptions::FLAG_SPIRV_VALIDATOR_WORKGROUP_SCALAR_BLOCK_LAYOUT;
+               }
+
+               return SpirvValidatorOptions(vulkanVersion, rules, supports_VK_KHR_spirv_1_4, validator_flags);
        }
 };
 
index bdcdc67..e408665 100644 (file)
@@ -184,6 +184,11 @@ bool validateSpirV (size_t binarySizeInWords, const deUint32* binary, std::ostre
                                break;
                }
 
+               if (val_options.flags & SpirvValidatorOptions::FLAG_SPIRV_VALIDATOR_WORKGROUP_SCALAR_BLOCK_LAYOUT)
+               {
+                       spvValidatorOptionsSetWorkgroupScalarBlockLayout(options, true);
+               }
+
                const spv_result_t              valid   = spvValidateWithOptions(context, options, &cbinary, &diagnostic);
                const bool                              passed  = (valid == SPV_SUCCESS);
 
index f593913..a8451af 100644 (file)
@@ -44,8 +44,13 @@ struct SpirvValidatorOptions
                kScalarBlockLayout
        };
 
-       SpirvValidatorOptions(deUint32 the_vulkan_version = VK_MAKE_VERSION(1, 0, 0), BlockLayoutRules the_layout = kDefaultBlockLayout, bool allowSpirv14 = false)
-       : vulkanVersion(the_vulkan_version), blockLayout(the_layout), supports_VK_KHR_spirv_1_4(allowSpirv14) {}
+       enum Flags
+       {
+               FLAG_SPIRV_VALIDATOR_WORKGROUP_SCALAR_BLOCK_LAYOUT              = (1u<<0)
+       };
+
+       SpirvValidatorOptions(deUint32 the_vulkan_version = VK_MAKE_VERSION(1, 0, 0), BlockLayoutRules the_layout = kDefaultBlockLayout, bool allowSpirv14 = false, deUint32 the_flags = 0)
+       : vulkanVersion(the_vulkan_version), blockLayout(the_layout), supports_VK_KHR_spirv_1_4(allowSpirv14), flags(the_flags) {}
 
        // The target Vulkan version.  This determines the SPIR-V environment rules to
        // be checked. The bit pattern is as produced by VK_MAKE_VERSION.
@@ -57,6 +62,8 @@ struct SpirvValidatorOptions
        // Does the device support VK_KHR_spirv_1_4?
        // (Camelcase would just be wrong here.)
        bool supports_VK_KHR_spirv_1_4;
+
+       deUint32 flags;
 };
 
 }  // namespace vk