mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-26 05:10:05 +00:00
spirv-val: Add SPV_ARM_core_builtins validation (#4958)
Signed-off-by: Kevin Petit <kevin.petit@arm.com> Change-Id: If1680a823aea9662d44def1ec6fe6ac334c00574 Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
parent
4dbc66380d
commit
a6e6454ef2
@ -333,7 +333,7 @@ class BuiltInsValidator {
|
|||||||
// Used for GlobalInvocationId, LocalInvocationId, NumWorkgroups, WorkgroupId.
|
// Used for GlobalInvocationId, LocalInvocationId, NumWorkgroups, WorkgroupId.
|
||||||
spv_result_t ValidateComputeShaderI32Vec3InputAtDefinition(
|
spv_result_t ValidateComputeShaderI32Vec3InputAtDefinition(
|
||||||
const Decoration& decoration, const Instruction& inst);
|
const Decoration& decoration, const Instruction& inst);
|
||||||
spv_result_t ValidateSMBuiltinsAtDefinition(const Decoration& decoration,
|
spv_result_t ValidateNVSMOrARMCoreBuiltinsAtDefinition(const Decoration& decoration,
|
||||||
const Instruction& inst);
|
const Instruction& inst);
|
||||||
// Used for BaryCoord, BaryCoordNoPersp.
|
// Used for BaryCoord, BaryCoordNoPersp.
|
||||||
spv_result_t ValidateFragmentShaderF32Vec3InputAtDefinition(
|
spv_result_t ValidateFragmentShaderF32Vec3InputAtDefinition(
|
||||||
@ -528,7 +528,7 @@ class BuiltInsValidator {
|
|||||||
const Instruction& referenced_inst,
|
const Instruction& referenced_inst,
|
||||||
const Instruction& referenced_from_inst);
|
const Instruction& referenced_from_inst);
|
||||||
|
|
||||||
spv_result_t ValidateSMBuiltinsAtReference(
|
spv_result_t ValidateNVSMOrARMCoreBuiltinsAtReference(
|
||||||
const Decoration& decoration, const Instruction& built_in_inst,
|
const Decoration& decoration, const Instruction& built_in_inst,
|
||||||
const Instruction& referenced_inst,
|
const Instruction& referenced_inst,
|
||||||
const Instruction& referenced_from_inst);
|
const Instruction& referenced_from_inst);
|
||||||
@ -3749,7 +3749,7 @@ spv_result_t BuiltInsValidator::ValidateFullyCoveredAtReference(
|
|||||||
return SPV_SUCCESS;
|
return SPV_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtDefinition(
|
spv_result_t BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtDefinition(
|
||||||
const Decoration& decoration, const Instruction& inst) {
|
const Decoration& decoration, const Instruction& inst) {
|
||||||
if (spvIsVulkanEnv(_.context()->target_env)) {
|
if (spvIsVulkanEnv(_.context()->target_env)) {
|
||||||
if (spv_result_t error = ValidateI32(
|
if (spv_result_t error = ValidateI32(
|
||||||
@ -3770,10 +3770,10 @@ spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtDefinition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Seed at reference checks with this built-in.
|
// Seed at reference checks with this built-in.
|
||||||
return ValidateSMBuiltinsAtReference(decoration, inst, inst, inst);
|
return ValidateNVSMOrARMCoreBuiltinsAtReference(decoration, inst, inst, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtReference(
|
spv_result_t BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtReference(
|
||||||
const Decoration& decoration, const Instruction& built_in_inst,
|
const Decoration& decoration, const Instruction& built_in_inst,
|
||||||
const Instruction& referenced_inst,
|
const Instruction& referenced_inst,
|
||||||
const Instruction& referenced_from_inst) {
|
const Instruction& referenced_from_inst) {
|
||||||
@ -3797,7 +3797,7 @@ spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtReference(
|
|||||||
if (function_id_ == 0) {
|
if (function_id_ == 0) {
|
||||||
// Propagate this rule to all dependant ids in the global scope.
|
// Propagate this rule to all dependant ids in the global scope.
|
||||||
id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind(
|
id_to_at_reference_checks_[referenced_from_inst.id()].push_back(std::bind(
|
||||||
&BuiltInsValidator::ValidateSMBuiltinsAtReference, this, decoration,
|
&BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtReference, this, decoration,
|
||||||
built_in_inst, referenced_from_inst, std::placeholders::_1));
|
built_in_inst, referenced_from_inst, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4225,11 +4225,16 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition(
|
|||||||
case SpvBuiltInLocalInvocationIndex: {
|
case SpvBuiltInLocalInvocationIndex: {
|
||||||
return ValidateLocalInvocationIndexAtDefinition(decoration, inst);
|
return ValidateLocalInvocationIndexAtDefinition(decoration, inst);
|
||||||
}
|
}
|
||||||
|
case SpvBuiltInCoreIDARM:
|
||||||
|
case SpvBuiltInCoreCountARM:
|
||||||
|
case SpvBuiltInCoreMaxIDARM:
|
||||||
|
case SpvBuiltInWarpIDARM:
|
||||||
|
case SpvBuiltInWarpMaxIDARM:
|
||||||
case SpvBuiltInWarpsPerSMNV:
|
case SpvBuiltInWarpsPerSMNV:
|
||||||
case SpvBuiltInSMCountNV:
|
case SpvBuiltInSMCountNV:
|
||||||
case SpvBuiltInWarpIDNV:
|
case SpvBuiltInWarpIDNV:
|
||||||
case SpvBuiltInSMIDNV: {
|
case SpvBuiltInSMIDNV: {
|
||||||
return ValidateSMBuiltinsAtDefinition(decoration, inst);
|
return ValidateNVSMOrARMCoreBuiltinsAtDefinition(decoration, inst);
|
||||||
}
|
}
|
||||||
case SpvBuiltInBaseInstance:
|
case SpvBuiltInBaseInstance:
|
||||||
case SpvBuiltInBaseVertex: {
|
case SpvBuiltInBaseVertex: {
|
||||||
|
@ -2851,6 +2851,61 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
"needs to be a 32-bit int scalar",
|
"needs to be a 32-bit int scalar",
|
||||||
"has bit width 64"))));
|
"has bit width 64"))));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ArmCoreBuiltinsInputSuccess,
|
||||||
|
ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
|
||||||
|
Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
|
||||||
|
"WarpMaxIDARM"),
|
||||||
|
Values("Vertex", "Fragment", "TessellationControl",
|
||||||
|
"TessellationEvaluation", "Geometry", "GLCompute"),
|
||||||
|
Values("Input"), Values("%u32"),
|
||||||
|
Values("OpCapability CoreBuiltinsARM\n"),
|
||||||
|
Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
|
||||||
|
Values(TestResult())));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ArmCoreBuiltinsNotInput,
|
||||||
|
ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
|
||||||
|
Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
|
||||||
|
"WarpMaxIDARM"),
|
||||||
|
Values("Vertex", "Fragment", "TessellationControl",
|
||||||
|
"TessellationEvaluation", "Geometry", "GLCompute"),
|
||||||
|
Values("Output"), Values("%u32"),
|
||||||
|
Values("OpCapability CoreBuiltinsARM\n"),
|
||||||
|
Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
|
||||||
|
Values(TestResult(
|
||||||
|
SPV_ERROR_INVALID_DATA,
|
||||||
|
"to be only used for variables with Input storage class",
|
||||||
|
"uses storage class Output"))));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ArmCoreBuiltinsNotIntScalar,
|
||||||
|
ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
|
||||||
|
Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
|
||||||
|
"WarpMaxIDARM"),
|
||||||
|
Values("Vertex", "Fragment", "TessellationControl",
|
||||||
|
"TessellationEvaluation", "Geometry", "GLCompute"),
|
||||||
|
Values("Input"), Values("%f32", "%u32vec3"),
|
||||||
|
Values("OpCapability CoreBuiltinsARM\n"),
|
||||||
|
Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
|
||||||
|
Values(TestResult(SPV_ERROR_INVALID_DATA,
|
||||||
|
"needs to be a 32-bit int scalar",
|
||||||
|
"is not an int scalar"))));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ArmCoreBuiltinsNotInt32,
|
||||||
|
ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
|
||||||
|
Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
|
||||||
|
"WarpMaxIDARM"),
|
||||||
|
Values("Vertex", "Fragment", "TessellationControl",
|
||||||
|
"TessellationEvaluation", "Geometry", "GLCompute"),
|
||||||
|
Values("Input"), Values("%u64"),
|
||||||
|
Values("OpCapability CoreBuiltinsARM\n"),
|
||||||
|
Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
|
||||||
|
Values(TestResult(SPV_ERROR_INVALID_DATA,
|
||||||
|
"needs to be a 32-bit int scalar",
|
||||||
|
"has bit width 64"))));
|
||||||
|
|
||||||
CodeGenerator GetWorkgroupSizeSuccessGenerator() {
|
CodeGenerator GetWorkgroupSizeSuccessGenerator() {
|
||||||
CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
|
CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user