summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp')
-rw-r--r--3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp b/3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp
index dac95f6eb34..606abb93ddf 100644
--- a/3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp
+++ b/3rdparty/bgfx/3rdparty/spirv-tools/test/val/val_derivatives_test.cpp
@@ -62,7 +62,17 @@ OpCapability DerivativeControl
%f32vec4_ptr_input = OpTypePointer Input %f32vec4
%f32vec4_var_input = OpVariable %f32vec4_ptr_input Input
+)";
+
+ if (capabilities_and_extensions.find("OpCapability Float16") !=
+ std::string::npos) {
+ ss << "%f16 = OpTypeFloat 16\n"
+ << "%f16vec4 = OpTypeVector %f16 4\n"
+ << "%f16_0 = OpConstantNull %f16\n"
+ << "%f16vec4_0 = OpConstantNull %f16vec4\n";
+ }
+ ss << R"(
%main = OpFunction %void None %func
%main_entry = OpLabel
)";
@@ -150,6 +160,36 @@ TEST_F(ValidateDerivatives, OpDPdxWrongExecutionModel) {
"execution model: DPdx"));
}
+using ValidateHalfDerivatives = spvtest::ValidateBase<std::string>;
+
+TEST_P(ValidateHalfDerivatives, ScalarFailure) {
+ const std::string op = GetParam();
+ const std::string body = "%val = " + op + " %f16 %f16_0\n";
+
+ CompileSuccessfully(
+ GenerateShaderCode(body, "OpCapability Float16\n").c_str());
+ ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Result type component width must be 32 bits"));
+}
+
+TEST_P(ValidateHalfDerivatives, VectorFailure) {
+ const std::string op = GetParam();
+ const std::string body = "%val = " + op + " %f16vec4 %f16vec4_0\n";
+
+ CompileSuccessfully(
+ GenerateShaderCode(body, "OpCapability Float16\n").c_str());
+ ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Result type component width must be 32 bits"));
+}
+
+INSTANTIATE_TEST_SUITE_P(HalfDerivatives, ValidateHalfDerivatives,
+ ::testing::Values("OpDPdx", "OpDPdy", "OpFwidth",
+ "OpDPdxFine", "OpDPdyFine",
+ "OpFwidthFine", "OpDPdxCoarse",
+ "OpDPdyCoarse", "OpFwidthCoarse"));
+
} // namespace
} // namespace val
} // namespace spvtools