mirror of
https://github.com/RPCSX/SPIRV-Tools.git
synced 2025-01-09 04:40:37 +00:00
Avoid capability checks on ID values. They are not literals
Works around issue 248 by weakening the test: https://github.com/KhronosGroup/SPIRV-Tools/issues/248 The validator should try to track (32-bit) constant values, and then for capability checks on IDs, check the referenced value, not the raw ID number.
This commit is contained in:
parent
f760d115b9
commit
e461cbe268
@ -35,6 +35,7 @@
|
||||
|
||||
#include "diagnostic.h"
|
||||
#include "opcode.h"
|
||||
#include "operand.h"
|
||||
#include "spirv_definition.h"
|
||||
#include "val/Function.h"
|
||||
#include "val/ValidationState.h"
|
||||
@ -109,6 +110,10 @@ spv_result_t CapCheck(ValidationState_t& _,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (spvIsIdType(operand.type)) {
|
||||
// TODO(dneto): Check the value referenced by this Id, if we can compute
|
||||
// it. For now, just punt, to fix issue 248:
|
||||
// https://github.com/KhronosGroup/SPIRV-Tools/issues/248
|
||||
} else {
|
||||
// Check the operand word as a whole.
|
||||
const auto caps = RequiredCapabilities(_.grammar(), operand.type, word);
|
||||
|
@ -1153,4 +1153,39 @@ TEST_P(ValidateCapabilityV11, Capability) {
|
||||
<< test_code;
|
||||
}
|
||||
|
||||
TEST_F(ValidateCapability, SemanticsIdIsAnIdNotALiteral) {
|
||||
// From https://github.com/KhronosGroup/SPIRV-Tools/issues/248
|
||||
// The validator was interpreting the memory semantics ID number
|
||||
// as the value to be checked rather than an ID that references
|
||||
// another value to be checked.
|
||||
// In this case a raw ID of 64 was mistaken to mean a literal
|
||||
// semantic value of UniformMemory, which would require the Shader
|
||||
// capability.
|
||||
const char str[] = R"(
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Logical OpenCL
|
||||
|
||||
; %i32 has ID 1
|
||||
%i32 = OpTypeInt 32 1
|
||||
%tf = OpTypeFunction %i32
|
||||
%pi32 = OpTypePointer CrossWorkgroup %i32
|
||||
%var = OpVariable %pi32 CrossWorkgroup
|
||||
%c = OpConstant %i32 100
|
||||
%scope = OpConstant %i32 1 ; Device scope
|
||||
|
||||
; Fake an instruction with 64 as the result id.
|
||||
; !64 = OpConstantNull %i32
|
||||
!0x3002e !1 !64
|
||||
|
||||
%f = OpFunction %i32 None %tf
|
||||
%l = OpLabel
|
||||
%result = OpAtomicIAdd %i32 %var %scope !64 %c
|
||||
OpReturnValue %result
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
Loading…
Reference in New Issue
Block a user