Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv-val: Add SPV_ARM_core_builtins validation #4958

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions source/val/validate_builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class BuiltInsValidator {
// Used for GlobalInvocationId, LocalInvocationId, NumWorkgroups, WorkgroupId.
spv_result_t ValidateComputeShaderI32Vec3InputAtDefinition(
const Decoration& decoration, const Instruction& inst);
spv_result_t ValidateSMBuiltinsAtDefinition(const Decoration& decoration,
spv_result_t ValidateNVSMOrARMCoreBuiltinsAtDefinition(const Decoration& decoration,
const Instruction& inst);
// Used for BaryCoord, BaryCoordNoPersp.
spv_result_t ValidateFragmentShaderF32Vec3InputAtDefinition(
Expand Down Expand Up @@ -528,7 +528,7 @@ class BuiltInsValidator {
const Instruction& referenced_inst,
const Instruction& referenced_from_inst);

spv_result_t ValidateSMBuiltinsAtReference(
spv_result_t ValidateNVSMOrARMCoreBuiltinsAtReference(
const Decoration& decoration, const Instruction& built_in_inst,
const Instruction& referenced_inst,
const Instruction& referenced_from_inst);
Expand Down Expand Up @@ -3749,7 +3749,7 @@ spv_result_t BuiltInsValidator::ValidateFullyCoveredAtReference(
return SPV_SUCCESS;
}

spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtDefinition(
spv_result_t BuiltInsValidator::ValidateNVSMOrARMCoreBuiltinsAtDefinition(
const Decoration& decoration, const Instruction& inst) {
if (spvIsVulkanEnv(_.context()->target_env)) {
if (spv_result_t error = ValidateI32(
Expand All @@ -3770,10 +3770,10 @@ spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtDefinition(
}

// 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 Instruction& referenced_inst,
const Instruction& referenced_from_inst) {
Expand All @@ -3797,7 +3797,7 @@ spv_result_t BuiltInsValidator::ValidateSMBuiltinsAtReference(
if (function_id_ == 0) {
// Propagate this rule to all dependant ids in the global scope.
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));
}

Expand Down Expand Up @@ -4225,11 +4225,16 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition(
case SpvBuiltInLocalInvocationIndex: {
return ValidateLocalInvocationIndexAtDefinition(decoration, inst);
}
case SpvBuiltInCoreIDARM:
case SpvBuiltInCoreCountARM:
case SpvBuiltInCoreMaxIDARM:
case SpvBuiltInWarpIDARM:
case SpvBuiltInWarpMaxIDARM:
case SpvBuiltInWarpsPerSMNV:
case SpvBuiltInSMCountNV:
case SpvBuiltInWarpIDNV:
case SpvBuiltInSMIDNV: {
return ValidateSMBuiltinsAtDefinition(decoration, inst);
return ValidateNVSMOrARMCoreBuiltinsAtDefinition(decoration, inst);
}
case SpvBuiltInBaseInstance:
case SpvBuiltInBaseVertex: {
Expand Down
55 changes: 55 additions & 0 deletions test/val/val_builtins_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,61 @@ INSTANTIATE_TEST_SUITE_P(
"needs to be a 32-bit int scalar",
"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 generator = CodeGenerator::GetDefaultShaderCodeGenerator();

Expand Down