mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-26 01:31:06 +00:00
Add tests for matrix type data rule validation (#2082)
Add tests for matrix type data rule validation This covers the data rules for matrix types specified in the SPIR-V spec, section 2.16.1, and the WebGPU SPIR-V Execution Environment spec. Fixes #2065 Fixes #2080
This commit is contained in:
parent
f5b4a8eee3
commit
b0c143c8eb
@ -579,14 +579,56 @@ TEST_F(ValidateIdWithMessage, OpTypeMatrixGood) {
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnTypeBad) {
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnTypeNonVectorBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
%1 = OpTypeInt 32 0
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeMatrix %1 3)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Columns in a matrix must be of type vector."));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("olumns in a matrix must be of type vector.\n %mat3float = "
|
||||
"OpTypeMatrix %float 3\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpTypeMatrixVectorTypeNonFloatBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
%1 = OpTypeInt 16 0
|
||||
%2 = OpTypeVector %1 2
|
||||
%3 = OpTypeMatrix %2 2)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Matrix types can only be parameterized with floating-point "
|
||||
"types.\n %mat2v2ushort = OpTypeMatrix %v2ushort 2\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnCountLessThanTwoBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 2
|
||||
%3 = OpTypeMatrix %2 1)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Matrix types can only be parameterized as having only 2, 3, "
|
||||
"or 4 columns.\n %mat1v2float = OpTypeMatrix %v2float 1\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpTypeMatrixColumnCountGreaterThanFourBad) {
|
||||
std::string spirv = kGLSL450MemoryModel + R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%2 = OpTypeVector %1 2
|
||||
%3 = OpTypeMatrix %2 8)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Matrix types can only be parameterized as having only 2, 3, "
|
||||
"or 4 columns.\n %mat8v2float = OpTypeMatrix %v2float 8\n"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpTypeSamplerGood) {
|
||||
|
Loading…
Reference in New Issue
Block a user