Skip to content

Commit

Permalink
Validate Vulkan 1.2 capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-baker authored and dneto0 committed Jan 15, 2020
1 parent d46a1b0 commit 323a81f
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 2 deletions.
33 changes: 31 additions & 2 deletions source/val/validate_capability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ bool IsSupportGuaranteedVulkan_1_1(uint32_t capability) {

bool IsSupportGuaranteedVulkan_1_2(uint32_t capability) {
if (IsSupportGuaranteedVulkan_1_1(capability)) return true;
// TODO(dneto): Check if any additional capability is required.
switch (capability) {
case SpvCapabilityShaderNonUniform:
return true;
}
return false;
}

Expand Down Expand Up @@ -129,7 +132,33 @@ bool IsSupportOptionalVulkan_1_1(uint32_t capability) {

bool IsSupportOptionalVulkan_1_2(uint32_t capability) {
if (IsSupportOptionalVulkan_1_1(capability)) return true;
// TODO(dneto): Check which additional capability is optional.

switch (capability) {
case SpvCapabilityDenormPreserve:
case SpvCapabilityDenormFlushToZero:
case SpvCapabilitySignedZeroInfNanPreserve:
case SpvCapabilityRoundingModeRTE:
case SpvCapabilityRoundingModeRTZ:
case SpvCapabilityVulkanMemoryModel:
case SpvCapabilityVulkanMemoryModelDeviceScope:
case SpvCapabilityStorageBuffer8BitAccess:
case SpvCapabilityUniformAndStorageBuffer8BitAccess:
case SpvCapabilityStoragePushConstant8:
case SpvCapabilityShaderViewportIndex:
case SpvCapabilityShaderLayer:
case SpvCapabilityPhysicalStorageBufferAddresses:
case SpvCapabilityRuntimeDescriptorArray:
case SpvCapabilityUniformTexelBufferArrayDynamicIndexing:
case SpvCapabilityStorageTexelBufferArrayDynamicIndexing:
case SpvCapabilityUniformBufferArrayNonUniformIndexing:
case SpvCapabilitySampledImageArrayNonUniformIndexing:
case SpvCapabilityStorageBufferArrayNonUniformIndexing:
case SpvCapabilityStorageImageArrayNonUniformIndexing:
case SpvCapabilityInputAttachmentArrayNonUniformIndexing:
case SpvCapabilityUniformTexelBufferArrayNonUniformIndexing:
case SpvCapabilityStorageTexelBufferArrayNonUniformIndexing:
return true;
}
return false;
}

Expand Down
228 changes: 228 additions & 0 deletions test/val/val_capability_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ using ValidateCapabilityVulkan10 = spvtest::ValidateBase<CapTestParameter>;
using ValidateCapabilityOpenGL40 = spvtest::ValidateBase<CapTestParameter>;
// Always assembles using Vulkan 1.1.
using ValidateCapabilityVulkan11 = spvtest::ValidateBase<CapTestParameter>;
// Always assembles using Vulkan 1.2.
using ValidateCapabilityVulkan12 = spvtest::ValidateBase<CapTestParameter>;
// Always assembles using WebGPU.
using ValidateCapabilityWebGPU = spvtest::ValidateBase<CapTestParameter>;

Expand Down Expand Up @@ -217,6 +219,114 @@ const std::vector<std::string>& AllCapabilities() {
return *r;
}

const std::vector<std::string>& AllSpirV15Capabilities() {
static const auto r = new std::vector<std::string>{
"",
"Matrix",
"Shader",
"Geometry",
"Tessellation",
"Addresses",
"Linkage",
"Kernel",
"Vector16",
"Float16Buffer",
"Float16",
"Float64",
"Int64",
"Int64Atomics",
"ImageBasic",
"ImageReadWrite",
"ImageMipmap",
"Pipes",
"Groups",
"DeviceEnqueue",
"LiteralSampler",
"AtomicStorage",
"Int16",
"TessellationPointSize",
"GeometryPointSize",
"ImageGatherExtended",
"StorageImageMultisample",
"UniformBufferArrayDynamicIndexing",
"SampledImageArrayDynamicIndexing",
"StorageBufferArrayDynamicIndexing",
"StorageImageArrayDynamicIndexing",
"ClipDistance",
"CullDistance",
"ImageCubeArray",
"SampleRateShading",
"ImageRect",
"SampledRect",
"GenericPointer",
"Int8",
"InputAttachment",
"SparseResidency",
"MinLod",
"Sampled1D",
"Image1D",
"SampledCubeArray",
"SampledBuffer",
"ImageBuffer",
"ImageMSArray",
"StorageImageExtendedFormats",
"ImageQuery",
"DerivativeControl",
"InterpolationFunction",
"TransformFeedback",
"GeometryStreams",
"StorageImageReadWithoutFormat",
"StorageImageWriteWithoutFormat",
"MultiViewport",
"SubgroupDispatch",
"NamedBarrier",
"PipeStorage",
"GroupNonUniform",
"GroupNonUniformVote",
"GroupNonUniformArithmetic",
"GroupNonUniformBallot",
"GroupNonUniformShuffle",
"GroupNonUniformShuffleRelative",
"GroupNonUniformClustered",
"GroupNonUniformQuad",
"DrawParameters",
"StorageBuffer16BitAccess",
"StorageUniformBufferBlock16",
"UniformAndStorageBuffer16BitAccess",
"StorageUniform16",
"StoragePushConstant16",
"StorageInputOutput16",
"DeviceGroup",
"MultiView",
"VariablePointersStorageBuffer",
"VariablePointers",
"DenormPreserve",
"DenormFlushToZero",
"SignedZeroInfNanPreserve",
"RoundingModeRTE",
"RoundingModeRTZ",
// Omitted due to extra validation requirements on memory model.
//"VulkanMemoryModel",
//"VulkanMemoryModelDeviceScope",
"StorageBuffer8BitAccess",
"UniformAndStorageBuffer8BitAccess",
"StoragePushConstant8",
"ShaderViewportIndex",
"ShaderLayer",
"PhysicalStorageBufferAddresses",
"RuntimeDescriptorArray",
"UniformTexelBufferArrayDynamicIndexing",
"StorageTexelBufferArrayDynamicIndexing",
"UniformBufferArrayNonUniformIndexing",
"SampledImageArrayNonUniformIndexing",
"StorageBufferArrayNonUniformIndexing",
"StorageImageArrayNonUniformIndexing",
"InputAttachmentArrayNonUniformIndexing",
"UniformTexelBufferArrayNonUniformIndexing",
"StorageTexelBufferArrayNonUniformIndexing"};
return *r;
}

const std::vector<std::string>& AllSpirV10Capabilities() {
static const auto r = new std::vector<std::string>{
"",
Expand Down Expand Up @@ -390,6 +500,94 @@ const std::vector<std::string>& AllVulkan11Capabilities() {
return *r;
}

const std::vector<std::string>& AllVulkan12Capabilities() {
static const auto r = new std::vector<std::string>{
"",
"Matrix",
"Shader",
"InputAttachment",
"Sampled1D",
"Image1D",
"SampledBuffer",
"ImageBuffer",
"ImageQuery",
"DerivativeControl",
"Geometry",
"Tessellation",
"Float16",
"Float64",
"Int64",
"Int64Atomics",
"Int16",
"TessellationPointSize",
"GeometryPointSize",
"ImageGatherExtended",
"StorageImageMultisample",
"UniformBufferArrayDynamicIndexing",
"SampledImageArrayDynamicIndexing",
"StorageBufferArrayDynamicIndexing",
"StorageImageArrayDynamicIndexing",
"ClipDistance",
"CullDistance",
"ImageCubeArray",
"SampleRateShading",
"Int8",
"SparseResidency",
"MinLod",
"SampledCubeArray",
"ImageMSArray",
"StorageImageExtendedFormats",
"InterpolationFunction",
"StorageImageReadWithoutFormat",
"StorageImageWriteWithoutFormat",
"MultiViewport",
"GroupNonUniform",
"GroupNonUniformVote",
"GroupNonUniformArithmetic",
"GroupNonUniformBallot",
"GroupNonUniformShuffle",
"GroupNonUniformShuffleRelative",
"GroupNonUniformClustered",
"GroupNonUniformQuad",
"DrawParameters",
"StorageBuffer16BitAccess",
"StorageUniformBufferBlock16",
"UniformAndStorageBuffer16BitAccess",
"StorageUniform16",
"StoragePushConstant16",
"StorageInputOutput16",
"DeviceGroup",
"MultiView",
"VariablePointersStorageBuffer",
"VariablePointers",
"TransformFeedback",
"GeometryStreams",
"DenormPreserve",
"DenormFlushToZero",
"SignedZeroInfNanPreserve",
"RoundingModeRTE",
"RoundingModeRTZ",
"VulkanMemoryModel",
"VulkanMemoryModelDeviceScope",
"StorageBuffer8BitAccess",
"UniformAndStorageBuffer8BitAccess",
"StoragePushConstant8",
"ShaderViewportIndex",
"ShaderLayer",
"PhysicalStorageBufferAddresses",
"RuntimeDescriptorArray",
"UniformTexelBufferArrayDynamicIndexing",
"StorageTexelBufferArrayDynamicIndexing",
"UniformBufferArrayNonUniformIndexing",
"SampledImageArrayNonUniformIndexing",
"StorageBufferArrayNonUniformIndexing",
"StorageImageArrayNonUniformIndexing",
"InputAttachmentArrayNonUniformIndexing",
"UniformTexelBufferArrayNonUniformIndexing",
"StorageTexelBufferArrayNonUniformIndexing"};
return *r;
}

const std::vector<std::string>& AllWebGPUCapabilities() {
static const auto r = new std::vector<std::string>{
"",
Expand Down Expand Up @@ -1640,6 +1838,25 @@ std::make_pair(std::string(kGLSL450MemoryModel) +
AllVulkan11Capabilities())
)));

INSTANTIATE_TEST_SUITE_P(Capabilities, ValidateCapabilityVulkan12,
Combine(
// All capabilities to try.
ValuesIn(AllSpirV15Capabilities()),
Values(
std::make_pair(std::string(kGLSL450MemoryModel) +
"OpEntryPoint Vertex %func \"shader\" \n" +
"OpDecorate %int0 BuiltIn PointSize\n"
"%intt = OpTypeInt 32 0\n"
"%int0 = OpConstant %intt 0\n" + std::string(kVoidFVoid),
AllVulkan12Capabilities()),
std::make_pair(std::string(kGLSL450MemoryModel) +
"OpEntryPoint Vertex %func \"shader\" \n" +
"OpDecorate %int0 BuiltIn CullDistance\n"
"%intt = OpTypeInt 32 0\n"
"%int0 = OpConstant %intt 0\n" + std::string(kVoidFVoid),
AllVulkan12Capabilities())
)));

// TODO(umar): Selection Control
// TODO(umar): Loop Control
// TODO(umar): Function Control
Expand Down Expand Up @@ -1803,6 +2020,17 @@ TEST_P(ValidateCapabilityVulkan11, Capability) {
}
}

TEST_P(ValidateCapabilityVulkan12, Capability) {
const std::string capability = Capability(GetParam());
if (Exists(capability, SPV_ENV_VULKAN_1_2)) {
const std::string test_code = MakeAssembly(GetParam());
CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_2);
ASSERT_EQ(ExpectedResult(GetParam()),
ValidateInstructions(SPV_ENV_VULKAN_1_2))
<< test_code;
}
}

TEST_P(ValidateCapabilityOpenGL40, Capability) {
const std::string capability = Capability(GetParam());
if (Exists(capability, SPV_ENV_OPENGL_4_0)) {
Expand Down

0 comments on commit 323a81f

Please sign in to comment.