Reformat GLSL std450 extended instruction table.

Also add test for Smoothstep.
This commit is contained in:
Lei Zhang 2015-08-27 10:00:16 -04:00 committed by David Neto
parent c4ba8821e7
commit dca65b3f8c
2 changed files with 65 additions and 52 deletions

View File

@ -2,57 +2,70 @@
#include <string.h>
#define GL450Inst(name) #name, GLSLstd450::GLSLstd450##name
#define GL450InstWithOneIdParam(name) \
#name, GLSLstd450::GLSLstd450##name, { SPV_OPERAND_TYPE_ID }
#define GL450InstWithTwoIdParam(name) \
#name, GLSLstd450::GLSLstd450##name, { \
SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID \
}
#define GL450InstWithThreeIdParam(name) \
#name, GLSLstd450::GLSLstd450##name, { \
SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID \
}
static const spv_ext_inst_desc_t glslStd450Entries[] = {
{ GL450Inst(Round), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(RoundEven), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Trunc), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(FAbs), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SAbs), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(FSign), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SSign), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Floor), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Ceil), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Fract), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Radians), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Degrees), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Sin), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Cos), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Tan), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Asin), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Acos), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Atan), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Sinh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Cosh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Tanh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Asinh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Acosh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Atanh), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Atan2), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Pow), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Exp), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Log), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Exp2), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Log2), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Sqrt), {SPV_OPERAND_TYPE_ID}, },
{ "Inversesqrt", GLSLstd450::GLSLstd450InverseSqrt, {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Determinant), {SPV_OPERAND_TYPE_ID}, },
{ "Inverse", GLSLstd450::GLSLstd450MatrixInverse, {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Modf), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(ModfStruct), {SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(FMin), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(UMin), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SMin), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(FMax), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(UMax), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SMax), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(FClamp), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(UClamp), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SClamp), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Mix), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(Step), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{ GL450Inst(SmoothStep), {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, },
{GL450InstWithOneIdParam(Round)},
{GL450InstWithOneIdParam(RoundEven)},
{GL450InstWithOneIdParam(Trunc)},
{GL450InstWithOneIdParam(FAbs)},
{GL450InstWithOneIdParam(SAbs)},
{GL450InstWithOneIdParam(FSign)},
{GL450InstWithOneIdParam(SSign)},
{GL450InstWithOneIdParam(Floor)},
{GL450InstWithOneIdParam(Ceil)},
{GL450InstWithOneIdParam(Fract)},
{GL450InstWithOneIdParam(Radians)},
{GL450InstWithOneIdParam(Degrees)},
{GL450InstWithOneIdParam(Sin)},
{GL450InstWithOneIdParam(Cos)},
{GL450InstWithOneIdParam(Tan)},
{GL450InstWithOneIdParam(Asin)},
{GL450InstWithOneIdParam(Acos)},
{GL450InstWithOneIdParam(Atan)},
{GL450InstWithOneIdParam(Sinh)},
{GL450InstWithOneIdParam(Cosh)},
{GL450InstWithOneIdParam(Tanh)},
{GL450InstWithOneIdParam(Asinh)},
{GL450InstWithOneIdParam(Acosh)},
{GL450InstWithOneIdParam(Atanh)},
{GL450InstWithTwoIdParam(Atan2)},
{GL450InstWithTwoIdParam(Pow)},
{GL450InstWithOneIdParam(Exp)},
{GL450InstWithOneIdParam(Log)},
{GL450InstWithOneIdParam(Exp2)},
{GL450InstWithOneIdParam(Log2)},
{GL450InstWithOneIdParam(Sqrt)},
// clang-format off
{"Inversesqrt", GLSLstd450::GLSLstd450InverseSqrt, {SPV_OPERAND_TYPE_ID}},
{GL450InstWithOneIdParam(Determinant)},
{"Inverse", GLSLstd450::GLSLstd450MatrixInverse, {SPV_OPERAND_TYPE_ID}},
// clang-format on
{GL450InstWithTwoIdParam(Modf)},
{GL450InstWithOneIdParam(ModfStruct)},
{GL450InstWithTwoIdParam(FMin)},
{GL450InstWithTwoIdParam(UMin)},
{GL450InstWithTwoIdParam(SMin)},
{GL450InstWithTwoIdParam(FMax)},
{GL450InstWithTwoIdParam(UMax)},
{GL450InstWithTwoIdParam(SMax)},
{GL450InstWithThreeIdParam(FClamp)},
{GL450InstWithThreeIdParam(UClamp)},
{GL450InstWithThreeIdParam(SClamp)},
{GL450InstWithThreeIdParam(Mix)},
{GL450InstWithTwoIdParam(Step)},
// clang-format off
{"Smoothstep", GLSLstd450::GLSLstd450SmoothStep, {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}},
// clang-format on
// TODO: Add remaining GLSL.std.450 instructions
};

View File

@ -97,8 +97,8 @@ OpFunctionEnd
// Check we do have the extended instruction's corresponding binary code in
// the generated SPIR-V binary.
std::vector<uint32_t> expected_contains(
{12 /*OpExtInst*/ | GetParam().extInstLength << 16, 4 /*%flt*/,
9 /*%result*/, 1 /*%glsl450*/, GetParam().extInstOpcode});
{12 /*OpExtInst*/ | GetParam().extInstLength << 16, 4 /*return type*/,
9 /*result id*/, 1 /*glsl450 import*/, GetParam().extInstOpcode});
for (uint32_t operand : GetParam().extInstOperandIds) {
expected_contains.push_back(operand);
}
@ -178,5 +178,5 @@ INSTANTIATE_TEST_CASE_P(
{kS32Type, kI32Const, "%4", "SClamp", "%5 %5 %5", 45, 8, {5, 5, 5}},
{kF32Type, kF32Const, "%4", "Mix", "%5 %5 %5", 46, 8, {5, 5, 5}},
{kF32Type, kF32Const, "%4", "Step", "%5 %5", 47, 7, {5, 5}},
/* SmoothStep */
{kF32Type, kF32Const, "%4", "Smoothstep", "%5 %5 %5", 48, 8, {5, 5, 5}},
})));