spirv-reader: Support NClamp, NMin, NMax
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max". The behaviour of FClamp, FMin, and FMax doesn't specify much when operands are NaN. Map to WGSL functions which are more prescriptive about results when operands are NaN. Also add TODOs for the GLSL.std.450 instructions that I had missed earlier: the interpolate-at instructions Change-Id: I48503be68128d2a0659bef7057e890cb9c0617ad Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35080 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org> Auto-Submit: David Neto <dneto@google.com>
This commit is contained in:
parent
8b0ffe9185
commit
eb7865cd0d
src/reader/spirv
|
@ -337,10 +337,18 @@ std::string GetGlslStd450FuncName(uint32_t ext_opcode) {
|
|||
return "normalize";
|
||||
case GLSLstd450UClamp:
|
||||
case GLSLstd450SClamp:
|
||||
case GLSLstd450FClamp:
|
||||
case GLSLstd450NClamp:
|
||||
case GLSLstd450FClamp: // FClamp is less prescriptive about NaN operands
|
||||
return "clamp";
|
||||
case GLSLstd450Length:
|
||||
return "length";
|
||||
case GLSLstd450NMin:
|
||||
case GLSLstd450FMin: // FMin is less prescriptive about NaN operands
|
||||
return "min";
|
||||
case GLSLstd450NMax:
|
||||
case GLSLstd450FMax: // FMax is less prescriptive about NaN operands
|
||||
return "max";
|
||||
|
||||
default:
|
||||
// TODO(dneto). The following are not implemented.
|
||||
// They are grouped semantically, as in GLSL.std.450.h.
|
||||
|
@ -381,10 +389,8 @@ std::string GetGlslStd450FuncName(uint32_t ext_opcode) {
|
|||
|
||||
case GLSLstd450Modf:
|
||||
case GLSLstd450ModfStruct:
|
||||
case GLSLstd450FMin:
|
||||
case GLSLstd450UMin:
|
||||
case GLSLstd450SMin:
|
||||
case GLSLstd450FMax:
|
||||
case GLSLstd450UMax:
|
||||
case GLSLstd450SMax:
|
||||
case GLSLstd450FMix:
|
||||
|
@ -418,6 +424,10 @@ std::string GetGlslStd450FuncName(uint32_t ext_opcode) {
|
|||
case GLSLstd450FindILsb:
|
||||
case GLSLstd450FindSMsb:
|
||||
case GLSLstd450FindUMsb:
|
||||
|
||||
case GLSLstd450InterpolateAtCentroid:
|
||||
case GLSLstd450InterpolateAtSample:
|
||||
case GLSLstd450InterpolateAtOffset:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -467,12 +467,21 @@ INSTANTIATE_TEST_SUITE_P(Samples,
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(Samples,
|
||||
SpvParserTest_GlslStd450_Floating_FloatingFloating,
|
||||
::testing::Values(GlslStd450Case{"Atan2", "atan2"}));
|
||||
::testing::ValuesIn(std::vector<GlslStd450Case>{
|
||||
{"Atan2", "atan2"},
|
||||
{"NMax", "max"},
|
||||
{"NMin", "min"},
|
||||
{"FMax", "max"}, // WGSL max promises more for NaN
|
||||
{"FMin", "min"} // WGSL min promises more for NaN
|
||||
}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Samples,
|
||||
SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating,
|
||||
::testing::Values(GlslStd450Case{"FClamp", "clamp"}));
|
||||
::testing::ValuesIn(std::vector<GlslStd450Case>{
|
||||
{"NClamp", "clamp"},
|
||||
{"FClamp", "clamp"} // WGSL FClamp promises more for NaN
|
||||
}));
|
||||
|
||||
TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) {
|
||||
const auto assembly = Preamble() + R"(
|
||||
|
|
Loading…
Reference in New Issue