Implement extension GL_AMD_gpu_shader_int16

- Add int16 types (int16_t, uint16_t, i16vec, u16vec).
- Add int16 support to GLSL operators.
- Add int16 type conversions (to int16, from int16).
- Add int16 built-in functions.
This commit is contained in:
Rex Xu 2017-03-24 13:41:14 +08:00
parent 4d5bcd3162
commit cabbb788b4
28 changed files with 8560 additions and 5521 deletions

View file

@ -85,8 +85,6 @@ TBuiltIns::TBuiltIns()
prefixes[EbtFloat] = "";
prefixes[EbtInt] = "i";
prefixes[EbtUint] = "u";
prefixes[EbtInt64] = "i64";
prefixes[EbtUint64] = "u64";
postfixes[2] = "2";
postfixes[3] = "3";
postfixes[4] = "4";
@ -2612,6 +2610,157 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
// GL_AMD_gpu_shader_int16
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append(
"int16_t abs(int16_t);"
"i16vec2 abs(i16vec2);"
"i16vec3 abs(i16vec3);"
"i16vec4 abs(i16vec4);"
"int16_t sign(int16_t);"
"i16vec2 sign(i16vec2);"
"i16vec3 sign(i16vec3);"
"i16vec4 sign(i16vec4);"
"int16_t min(int16_t, int16_t);"
"i16vec2 min(i16vec2, int16_t);"
"i16vec3 min(i16vec3, int16_t);"
"i16vec4 min(i16vec4, int16_t);"
"i16vec2 min(i16vec2, i16vec2);"
"i16vec3 min(i16vec3, i16vec3);"
"i16vec4 min(i16vec4, i16vec4);"
"uint16_t min(uint16_t, uint16_t);"
"u16vec2 min(u16vec2, uint16_t);"
"u16vec3 min(u16vec3, uint16_t);"
"u16vec4 min(u16vec4, uint16_t);"
"u16vec2 min(u16vec2, u16vec2);"
"u16vec3 min(u16vec3, u16vec3);"
"u16vec4 min(u16vec4, u16vec4);"
"int16_t max(int16_t, int16_t);"
"i16vec2 max(i16vec2, int16_t);"
"i16vec3 max(i16vec3, int16_t);"
"i16vec4 max(i16vec4, int16_t);"
"i16vec2 max(i16vec2, i16vec2);"
"i16vec3 max(i16vec3, i16vec3);"
"i16vec4 max(i16vec4, i16vec4);"
"uint16_t max(uint16_t, uint16_t);"
"u16vec2 max(u16vec2, uint16_t);"
"u16vec3 max(u16vec3, uint16_t);"
"u16vec4 max(u16vec4, uint16_t);"
"u16vec2 max(u16vec2, u16vec2);"
"u16vec3 max(u16vec3, u16vec3);"
"u16vec4 max(u16vec4, u16vec4);"
"int16_t clamp(int16_t, int16_t, int16_t);"
"i16vec2 clamp(i16vec2, int16_t, int16_t);"
"i16vec3 clamp(i16vec3, int16_t, int16_t);"
"i16vec4 clamp(i16vec4, int16_t, int16_t);"
"i16vec2 clamp(i16vec2, i16vec2, i16vec2);"
"i16vec3 clamp(i16vec3, i16vec3, i16vec3);"
"i16vec4 clamp(i16vec4, i16vec4, i16vec4);"
"uint16_t clamp(uint16_t, uint16_t, uint16_t);"
"u16vec2 clamp(u16vec2, uint16_t, uint16_t);"
"u16vec3 clamp(u16vec3, uint16_t, uint16_t);"
"u16vec4 clamp(u16vec4, uint16_t, uint16_t);"
"u16vec2 clamp(u16vec2, u16vec2, u16vec2);"
"u16vec3 clamp(u16vec3, u16vec3, u16vec3);"
"u16vec4 clamp(u16vec4, u16vec4, u16vec4);"
"int16_t mix(int16_t, int16_t, bool);"
"i16vec2 mix(i16vec2, i16vec2, bvec2);"
"i16vec3 mix(i16vec3, i16vec3, bvec3);"
"i16vec4 mix(i16vec4, i16vec4, bvec4);"
"uint16_t mix(uint16_t, uint16_t, bool);"
"u16vec2 mix(u16vec2, u16vec2, bvec2);"
"u16vec3 mix(u16vec3, u16vec3, bvec3);"
"u16vec4 mix(u16vec4, u16vec4, bvec4);"
"float16_t frexp(float16_t, out int16_t);"
"f16vec2 frexp(f16vec2, out i16vec2);"
"f16vec3 frexp(f16vec3, out i16vec3);"
"f16vec4 frexp(f16vec4, out i16vec4);"
"float16_t ldexp(float16_t, int16_t);"
"f16vec2 ldexp(f16vec2, i16vec2);"
"f16vec3 ldexp(f16vec3, i16vec3);"
"f16vec4 ldexp(f16vec4, i16vec4);"
"int16_t float16BitsToInt16(float16_t);"
"i16vec2 float16BitsToInt16(f16vec2);"
"i16vec3 float16BitsToInt16(f16vec3);"
"i16vec4 float16BitsToInt16(f16vec4);"
"uint16_t float16BitsToUint16(float16_t);"
"u16vec2 float16BitsToUint16(f16vec2);"
"u16vec3 float16BitsToUint16(f16vec3);"
"u16vec4 float16BitsToUint16(f16vec4);"
"float16_t int16BitsToFloat16(int16_t);"
"f16vec2 int16BitsToFloat16(i16vec2);"
"f16vec3 int16BitsToFloat16(i16vec3);"
"f16vec4 int16BitsToFloat16(i16vec4);"
"float16_t uint16BitsToFloat16(uint16_t);"
"f16vec2 uint16BitsToFloat16(u16vec2);"
"f16vec3 uint16BitsToFloat16(u16vec3);"
"f16vec4 uint16BitsToFloat16(u16vec4);"
"int packInt2x16(i16vec2);"
"uint packUint2x16(u16vec2);"
"int64_t packInt4x16(i16vec4);"
"uint64_t packUint4x16(u16vec4);"
"i16vec2 unpackInt2x16(int);"
"u16vec2 unpackUint2x16(uint);"
"i16vec4 unpackInt4x16(int64_t);"
"u16vec4 unpackUint4x16(uint64_t);"
"bvec2 lessThan(i16vec2, i16vec2);"
"bvec3 lessThan(i16vec3, i16vec3);"
"bvec4 lessThan(i16vec4, i16vec4);"
"bvec2 lessThan(u16vec2, u16vec2);"
"bvec3 lessThan(u16vec3, u16vec3);"
"bvec4 lessThan(u16vec4, u16vec4);"
"bvec2 lessThanEqual(i16vec2, i16vec2);"
"bvec3 lessThanEqual(i16vec3, i16vec3);"
"bvec4 lessThanEqual(i16vec4, i16vec4);"
"bvec2 lessThanEqual(u16vec2, u16vec2);"
"bvec3 lessThanEqual(u16vec3, u16vec3);"
"bvec4 lessThanEqual(u16vec4, u16vec4);"
"bvec2 greaterThan(i16vec2, i16vec2);"
"bvec3 greaterThan(i16vec3, i16vec3);"
"bvec4 greaterThan(i16vec4, i16vec4);"
"bvec2 greaterThan(u16vec2, u16vec2);"
"bvec3 greaterThan(u16vec3, u16vec3);"
"bvec4 greaterThan(u16vec4, u16vec4);"
"bvec2 greaterThanEqual(i16vec2, i16vec2);"
"bvec3 greaterThanEqual(i16vec3, i16vec3);"
"bvec4 greaterThanEqual(i16vec4, i16vec4);"
"bvec2 greaterThanEqual(u16vec2, u16vec2);"
"bvec3 greaterThanEqual(u16vec3, u16vec3);"
"bvec4 greaterThanEqual(u16vec4, u16vec4);"
"bvec2 equal(i16vec2, i16vec2);"
"bvec3 equal(i16vec3, i16vec3);"
"bvec4 equal(i16vec4, i16vec4);"
"bvec2 equal(u16vec2, u16vec2);"
"bvec3 equal(u16vec3, u16vec3);"
"bvec4 equal(u16vec4, u16vec4);"
"bvec2 notEqual(i16vec2, i16vec2);"
"bvec3 notEqual(i16vec3, i16vec3);"
"bvec4 notEqual(i16vec4, i16vec4);"
"bvec2 notEqual(u16vec2, u16vec2);"
"bvec3 notEqual(u16vec3, u16vec3);"
"bvec4 notEqual(u16vec4, u16vec4);"
"\n");
}
#endif
//============================================================================
@ -5639,6 +5788,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("doubleBitsToUint64", EOpDoubleBitsToUint64);
symbolTable.relateToOperator("int64BitsToDouble", EOpInt64BitsToDouble);
symbolTable.relateToOperator("uint64BitsToDouble", EOpUint64BitsToDouble);
#ifdef AMD_EXTENSIONS
symbolTable.relateToOperator("float16BitsToInt16", EOpFloat16BitsToInt16);
symbolTable.relateToOperator("float16BitsToUint16", EOpFloat16BitsToUint16);
symbolTable.relateToOperator("int16BitsToFloat16", EOpInt16BitsToFloat16);
symbolTable.relateToOperator("uint16BitsToFloat16", EOpUint16BitsToFloat16);
#endif
symbolTable.relateToOperator("packSnorm2x16", EOpPackSnorm2x16);
symbolTable.relateToOperator("unpackSnorm2x16", EOpUnpackSnorm2x16);
@ -5662,6 +5817,16 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("unpackUint2x32", EOpUnpackUint2x32);
#ifdef AMD_EXTENSIONS
symbolTable.relateToOperator("packInt2x16", EOpPackInt2x16);
symbolTable.relateToOperator("unpackInt2x16", EOpUnpackInt2x16);
symbolTable.relateToOperator("packUint2x16", EOpPackUint2x16);
symbolTable.relateToOperator("unpackUint2x16", EOpUnpackUint2x16);
symbolTable.relateToOperator("packInt4x16", EOpPackInt4x16);
symbolTable.relateToOperator("unpackInt4x16", EOpUnpackInt4x16);
symbolTable.relateToOperator("packUint4x16", EOpPackUint4x16);
symbolTable.relateToOperator("unpackUint4x16", EOpUnpackUint4x16);
symbolTable.relateToOperator("packFloat2x16", EOpPackFloat2x16);
symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16);
#endif