Parser: Implement extension GL_AMD_gpu_shader_half_float.

- Add built-in types: float16_t, f16vec, f16mat.
- Add support of half float constant: hf, HF.
- Extend built-in floating-point operators: +, -, *, /, ++, --, +=, -=,
  *=, /=, ==, !=, >=, <=, >, <.
- Add support of type conversions: float16_t -> XXX, XXX -> float16_t.
- Add new built-in functions.
This commit is contained in:
Rex Xu
2016-07-29 16:00:05 +08:00
parent b1672fa0de
commit c9e3c3c941
35 changed files with 9765 additions and 4370 deletions

View File

@@ -46,6 +46,9 @@ enum TBasicType {
EbtVoid,
EbtFloat,
EbtDouble,
#ifdef AMD_EXTENSIONS
EbtFloat16,
#endif
EbtInt,
EbtUint,
EbtInt64,

View File

@@ -185,8 +185,6 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
case EbtFloat: break;
case EbtInt: s.append("i"); break;
case EbtUint: s.append("u"); break;
case EbtInt64: s.append("i64"); break;
case EbtUint64: s.append("u64"); break;
default: break; // some compilers want this
}
if (image) {
@@ -1277,7 +1275,11 @@ public:
virtual bool isImplicitlySizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; }
virtual bool isRuntimeSizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage == EvqBuffer; }
virtual bool isStruct() const { return structure != nullptr; }
#ifdef AMD_EXTENSIONS
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; }
#else
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble; }
#endif
virtual bool isOpaque() const { return basicType == EbtSampler || basicType == EbtAtomicUint; }
@@ -1359,6 +1361,9 @@ public:
case EbtVoid:
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
case EbtInt:
case EbtUint:
case EbtInt64:
@@ -1451,6 +1456,9 @@ public:
case EbtVoid: return "void";
case EbtFloat: return "float";
case EbtDouble: return "double";
#ifdef AMD_EXTENSIONS
case EbtFloat16: return "float16_t";
#endif
case EbtInt: return "int";
case EbtUint: return "uint";
case EbtInt64: return "int64_t";

View File

@@ -119,6 +119,22 @@ enum TOperator {
EOpConvFloatToUint64,
EOpConvDoubleToUint64,
EOpConvInt64ToUint64,
#ifdef AMD_EXTENSIONS
EOpConvBoolToFloat16,
EOpConvIntToFloat16,
EOpConvUintToFloat16,
EOpConvFloatToFloat16,
EOpConvDoubleToFloat16,
EOpConvInt64ToFloat16,
EOpConvUint64ToFloat16,
EOpConvFloat16ToBool,
EOpConvFloat16ToInt,
EOpConvFloat16ToUint,
EOpConvFloat16ToFloat,
EOpConvFloat16ToDouble,
EOpConvFloat16ToInt64,
EOpConvFloat16ToUint64,
#endif
//
// binary operations
@@ -236,6 +252,10 @@ enum TOperator {
EOpUnpackInt2x32,
EOpPackUint2x32,
EOpUnpackUint2x32,
#ifdef AMD_EXTENSIONS
EOpPackFloat2x16,
EOpUnpackFloat2x16,
#endif
EOpLength,
EOpDistance,
@@ -396,6 +416,21 @@ enum TOperator {
EOpConstructDMat4x2,
EOpConstructDMat4x3,
EOpConstructDMat4x4,
#ifdef AMD_EXTENSIONS
EOpConstructFloat16,
EOpConstructF16Vec2,
EOpConstructF16Vec3,
EOpConstructF16Vec4,
EOpConstructF16Mat2x2,
EOpConstructF16Mat2x3,
EOpConstructF16Mat2x4,
EOpConstructF16Mat3x2,
EOpConstructF16Mat3x3,
EOpConstructF16Mat3x4,
EOpConstructF16Mat4x2,
EOpConstructF16Mat4x3,
EOpConstructF16Mat4x4,
#endif
EOpConstructStruct,
EOpConstructTextureSampler,
EOpConstructGuardEnd,

View File

@@ -176,6 +176,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
switch (getType().getBasicType()) {
case EbtDouble:
case EbtFloat:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
newConstArray[i].setDConst(leftUnionArray[i].getDConst() / rightUnionArray[i].getDConst());
break;
@@ -450,6 +453,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpNegative:
switch (getType().getBasicType()) {
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
@@ -688,6 +694,9 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
// Second, do the actual folding
bool isFloatingPoint = children[0]->getAsTyped()->getBasicType() == EbtFloat ||
#ifdef AMD_EXTENSIONS
children[0]->getAsTyped()->getBasicType() == EbtFloat16 ||
#endif
children[0]->getAsTyped()->getBasicType() == EbtDouble;
bool isSigned = children[0]->getAsTyped()->getBasicType() == EbtInt ||
children[0]->getAsTyped()->getBasicType() == EbtInt64;

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";
@@ -875,6 +873,21 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 mid3(uvec3, uvec3, uvec3);"
"uvec4 mid3(uvec4, uvec4, uvec4);"
"float16_t min3(float16_t, float16_t, float16_t);"
"f16vec2 min3(f16vec2, f16vec2, f16vec2);"
"f16vec3 min3(f16vec3, f16vec3, f16vec3);"
"f16vec4 min3(f16vec4, f16vec4, f16vec4);"
"float16_t max3(float16_t, float16_t, float16_t);"
"f16vec2 max3(f16vec2, f16vec2, f16vec2);"
"f16vec3 max3(f16vec3, f16vec3, f16vec3);"
"f16vec4 max3(f16vec4, f16vec4, f16vec4);"
"float16_t mid3(float16_t, float16_t, float16_t);"
"f16vec2 mid3(f16vec2, f16vec2, f16vec2);"
"f16vec3 mid3(f16vec3, f16vec3, f16vec3);"
"f16vec4 mid3(f16vec4, f16vec4, f16vec4);"
"\n"
);
}
@@ -1709,6 +1722,354 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
// GL_AMD_gpu_shader_half_float
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append(
"float16_t radians(float16_t);"
"f16vec2 radians(f16vec2);"
"f16vec3 radians(f16vec3);"
"f16vec4 radians(f16vec4);"
"float16_t degrees(float16_t);"
"f16vec2 degrees(f16vec2);"
"f16vec3 degrees(f16vec3);"
"f16vec4 degrees(f16vec4);"
"float16_t sin(float16_t);"
"f16vec2 sin(f16vec2);"
"f16vec3 sin(f16vec3);"
"f16vec4 sin(f16vec4);"
"float16_t cos(float16_t);"
"f16vec2 cos(f16vec2);"
"f16vec3 cos(f16vec3);"
"f16vec4 cos(f16vec4);"
"float16_t tan(float16_t);"
"f16vec2 tan(f16vec2);"
"f16vec3 tan(f16vec3);"
"f16vec4 tan(f16vec4);"
"float16_t asin(float16_t);"
"f16vec2 asin(f16vec2);"
"f16vec3 asin(f16vec3);"
"f16vec4 asin(f16vec4);"
"float16_t acos(float16_t);"
"f16vec2 acos(f16vec2);"
"f16vec3 acos(f16vec3);"
"f16vec4 acos(f16vec4);"
"float16_t atan(float16_t, float16_t);"
"f16vec2 atan(f16vec2, f16vec2);"
"f16vec3 atan(f16vec3, f16vec3);"
"f16vec4 atan(f16vec4, f16vec4);"
"float16_t atan(float16_t);"
"f16vec2 atan(f16vec2);"
"f16vec3 atan(f16vec3);"
"f16vec4 atan(f16vec4);"
"float16_t sinh(float16_t);"
"f16vec2 sinh(f16vec2);"
"f16vec3 sinh(f16vec3);"
"f16vec4 sinh(f16vec4);"
"float16_t cosh(float16_t);"
"f16vec2 cosh(f16vec2);"
"f16vec3 cosh(f16vec3);"
"f16vec4 cosh(f16vec4);"
"float16_t tanh(float16_t);"
"f16vec2 tanh(f16vec2);"
"f16vec3 tanh(f16vec3);"
"f16vec4 tanh(f16vec4);"
"float16_t asinh(float16_t);"
"f16vec2 asinh(f16vec2);"
"f16vec3 asinh(f16vec3);"
"f16vec4 asinh(f16vec4);"
"float16_t acosh(float16_t);"
"f16vec2 acosh(f16vec2);"
"f16vec3 acosh(f16vec3);"
"f16vec4 acosh(f16vec4);"
"float16_t atanh(float16_t);"
"f16vec2 atanh(f16vec2);"
"f16vec3 atanh(f16vec3);"
"f16vec4 atanh(f16vec4);"
"float16_t pow(float16_t, float16_t);"
"f16vec2 pow(f16vec2, f16vec2);"
"f16vec3 pow(f16vec3, f16vec3);"
"f16vec4 pow(f16vec4, f16vec4);"
"float16_t exp(float16_t);"
"f16vec2 exp(f16vec2);"
"f16vec3 exp(f16vec3);"
"f16vec4 exp(f16vec4);"
"float16_t log(float16_t);"
"f16vec2 log(f16vec2);"
"f16vec3 log(f16vec3);"
"f16vec4 log(f16vec4);"
"float16_t exp2(float16_t);"
"f16vec2 exp2(f16vec2);"
"f16vec3 exp2(f16vec3);"
"f16vec4 exp2(f16vec4);"
"float16_t log2(float16_t);"
"f16vec2 log2(f16vec2);"
"f16vec3 log2(f16vec3);"
"f16vec4 log2(f16vec4);"
"float16_t sqrt(float16_t);"
"f16vec2 sqrt(f16vec2);"
"f16vec3 sqrt(f16vec3);"
"f16vec4 sqrt(f16vec4);"
"float16_t inversesqrt(float16_t);"
"f16vec2 inversesqrt(f16vec2);"
"f16vec3 inversesqrt(f16vec3);"
"f16vec4 inversesqrt(f16vec4);"
"float16_t abs(float16_t);"
"f16vec2 abs(f16vec2);"
"f16vec3 abs(f16vec3);"
"f16vec4 abs(f16vec4);"
"float16_t sign(float16_t);"
"f16vec2 sign(f16vec2);"
"f16vec3 sign(f16vec3);"
"f16vec4 sign(f16vec4);"
"float16_t floor(float16_t);"
"f16vec2 floor(f16vec2);"
"f16vec3 floor(f16vec3);"
"f16vec4 floor(f16vec4);"
"float16_t trunc(float16_t);"
"f16vec2 trunc(f16vec2);"
"f16vec3 trunc(f16vec3);"
"f16vec4 trunc(f16vec4);"
"float16_t round(float16_t);"
"f16vec2 round(f16vec2);"
"f16vec3 round(f16vec3);"
"f16vec4 round(f16vec4);"
"float16_t roundEven(float16_t);"
"f16vec2 roundEven(f16vec2);"
"f16vec3 roundEven(f16vec3);"
"f16vec4 roundEven(f16vec4);"
"float16_t ceil(float16_t);"
"f16vec2 ceil(f16vec2);"
"f16vec3 ceil(f16vec3);"
"f16vec4 ceil(f16vec4);"
"float16_t fract(float16_t);"
"f16vec2 fract(f16vec2);"
"f16vec3 fract(f16vec3);"
"f16vec4 fract(f16vec4);"
"float16_t mod(float16_t, float16_t);"
"f16vec2 mod(f16vec2, float16_t);"
"f16vec3 mod(f16vec3, float16_t);"
"f16vec4 mod(f16vec4, float16_t);"
"f16vec2 mod(f16vec2, f16vec2);"
"f16vec3 mod(f16vec3, f16vec3);"
"f16vec4 mod(f16vec4, f16vec4);"
"float16_t modf(float16_t, out float16_t);"
"f16vec2 modf(f16vec2, out f16vec2);"
"f16vec3 modf(f16vec3, out f16vec3);"
"f16vec4 modf(f16vec4, out f16vec4);"
"float16_t min(float16_t, float16_t);"
"f16vec2 min(f16vec2, float16_t);"
"f16vec3 min(f16vec3, float16_t);"
"f16vec4 min(f16vec4, float16_t);"
"f16vec2 min(f16vec2, f16vec2);"
"f16vec3 min(f16vec3, f16vec3);"
"f16vec4 min(f16vec4, f16vec4);"
"float16_t max(float16_t, float16_t);"
"f16vec2 max(f16vec2, float16_t);"
"f16vec3 max(f16vec3, float16_t);"
"f16vec4 max(f16vec4, float16_t);"
"f16vec2 max(f16vec2, f16vec2);"
"f16vec3 max(f16vec3, f16vec3);"
"f16vec4 max(f16vec4, f16vec4);"
"float16_t clamp(float16_t, float16_t, float16_t);"
"f16vec2 clamp(f16vec2, float16_t, float16_t);"
"f16vec3 clamp(f16vec3, float16_t, float16_t);"
"f16vec4 clamp(f16vec4, float16_t, float16_t);"
"f16vec2 clamp(f16vec2, f16vec2, f16vec2);"
"f16vec3 clamp(f16vec3, f16vec3, f16vec3);"
"f16vec4 clamp(f16vec4, f16vec4, f16vec4);"
"float16_t mix(float16_t, float16_t, float16_t);"
"f16vec2 mix(f16vec2, f16vec2, float16_t);"
"f16vec3 mix(f16vec3, f16vec3, float16_t);"
"f16vec4 mix(f16vec4, f16vec4, float16_t);"
"f16vec2 mix(f16vec2, f16vec2, f16vec2);"
"f16vec3 mix(f16vec3, f16vec3, f16vec3);"
"f16vec4 mix(f16vec4, f16vec4, f16vec4);"
"float16_t mix(float16_t, float16_t, bool);"
"f16vec2 mix(f16vec2, f16vec2, bvec2);"
"f16vec3 mix(f16vec3, f16vec3, bvec3);"
"f16vec4 mix(f16vec4, f16vec4, bvec4);"
"float16_t step(float16_t, float16_t);"
"f16vec2 step(f16vec2, f16vec2);"
"f16vec3 step(f16vec3, f16vec3);"
"f16vec4 step(f16vec4, f16vec4);"
"f16vec2 step(float16_t, f16vec2);"
"f16vec3 step(float16_t, f16vec3);"
"f16vec4 step(float16_t, f16vec4);"
"float16_t smoothstep(float16_t, float16_t, float16_t);"
"f16vec2 smoothstep(f16vec2, f16vec2, f16vec2);"
"f16vec3 smoothstep(f16vec3, f16vec3, f16vec3);"
"f16vec4 smoothstep(f16vec4, f16vec4, f16vec4);"
"f16vec2 smoothstep(float16_t, float16_t, f16vec2);"
"f16vec3 smoothstep(float16_t, float16_t, f16vec3);"
"f16vec4 smoothstep(float16_t, float16_t, f16vec4);"
"bool isnan(float16_t);"
"bvec2 isnan(f16vec2);"
"bvec3 isnan(f16vec3);"
"bvec4 isnan(f16vec4);"
"bool isinf(float16_t);"
"bvec2 isinf(f16vec2);"
"bvec3 isinf(f16vec3);"
"bvec4 isinf(f16vec4);"
"float16_t fma(float16_t, float16_t, float16_t);"
"f16vec2 fma(f16vec2, f16vec2, f16vec2);"
"f16vec3 fma(f16vec3, f16vec3, f16vec3);"
"f16vec4 fma(f16vec4, f16vec4, f16vec4);"
"float16_t frexp(float16_t, out int);"
"f16vec2 frexp(f16vec2, out ivec2);"
"f16vec3 frexp(f16vec3, out ivec3);"
"f16vec4 frexp(f16vec4, out ivec4);"
"float16_t ldexp(float16_t, in int);"
"f16vec2 ldexp(f16vec2, in ivec2);"
"f16vec3 ldexp(f16vec3, in ivec3);"
"f16vec4 ldexp(f16vec4, in ivec4);"
"uint packFloat2x16(f16vec2);"
"f16vec2 unpackFloat2x16(uint);"
"float16_t length(float16_t);"
"float16_t length(f16vec2);"
"float16_t length(f16vec3);"
"float16_t length(f16vec4);"
"float16_t distance(float16_t, float16_t);"
"float16_t distance(f16vec2, f16vec2);"
"float16_t distance(f16vec3, f16vec3);"
"float16_t distance(f16vec4, f16vec4);"
"float16_t dot(float16_t, float16_t);"
"float16_t dot(f16vec2, f16vec2);"
"float16_t dot(f16vec3, f16vec3);"
"float16_t dot(f16vec4, f16vec4);"
"f16vec3 cross(f16vec3, f16vec3);"
"float16_t normalize(float16_t);"
"f16vec2 normalize(f16vec2);"
"f16vec3 normalize(f16vec3);"
"f16vec4 normalize(f16vec4);"
"float16_t faceforward(float16_t, float16_t, float16_t);"
"f16vec2 faceforward(f16vec2, f16vec2, f16vec2);"
"f16vec3 faceforward(f16vec3, f16vec3, f16vec3);"
"f16vec4 faceforward(f16vec4, f16vec4, f16vec4);"
"float16_t reflect(float16_t, float16_t);"
"f16vec2 reflect(f16vec2, f16vec2);"
"f16vec3 reflect(f16vec3, f16vec3);"
"f16vec4 reflect(f16vec4, f16vec4);"
"float16_t refract(float16_t, float16_t, float16_t);"
"f16vec2 refract(f16vec2, f16vec2, float16_t);"
"f16vec3 refract(f16vec3, f16vec3, float16_t);"
"f16vec4 refract(f16vec4, f16vec4, float16_t);"
"f16mat2 matrixCompMult(f16mat2, f16mat2);"
"f16mat3 matrixCompMult(f16mat3, f16mat3);"
"f16mat4 matrixCompMult(f16mat4, f16mat4);"
"f16mat2x3 matrixCompMult(f16mat2x3, f16mat2x3);"
"f16mat2x4 matrixCompMult(f16mat2x4, f16mat2x4);"
"f16mat3x2 matrixCompMult(f16mat3x2, f16mat3x2);"
"f16mat3x4 matrixCompMult(f16mat3x4, f16mat3x4);"
"f16mat4x2 matrixCompMult(f16mat4x2, f16mat4x2);"
"f16mat4x3 matrixCompMult(f16mat4x3, f16mat4x3);"
"f16mat2 outerProduct(f16vec2, f16vec2);"
"f16mat3 outerProduct(f16vec3, f16vec3);"
"f16mat4 outerProduct(f16vec4, f16vec4);"
"f16mat2x3 outerProduct(f16vec3, f16vec2);"
"f16mat3x2 outerProduct(f16vec2, f16vec3);"
"f16mat2x4 outerProduct(f16vec4, f16vec2);"
"f16mat4x2 outerProduct(f16vec2, f16vec4);"
"f16mat3x4 outerProduct(f16vec4, f16vec3);"
"f16mat4x3 outerProduct(f16vec3, f16vec4);"
"f16mat2 transpose(f16mat2);"
"f16mat3 transpose(f16mat3);"
"f16mat4 transpose(f16mat4);"
"f16mat2x3 transpose(f16mat3x2);"
"f16mat3x2 transpose(f16mat2x3);"
"f16mat2x4 transpose(f16mat4x2);"
"f16mat4x2 transpose(f16mat2x4);"
"f16mat3x4 transpose(f16mat4x3);"
"f16mat4x3 transpose(f16mat3x4);"
"float16_t determinant(f16mat2);"
"float16_t determinant(f16mat3);"
"float16_t determinant(f16mat4);"
"f16mat2 inverse(f16mat2);"
"f16mat3 inverse(f16mat3);"
"f16mat4 inverse(f16mat4);"
"bvec2 lessThan(f16vec2, f16vec2);"
"bvec3 lessThan(f16vec3, f16vec3);"
"bvec4 lessThan(f16vec4, f16vec4);"
"bvec2 lessThanEqual(f16vec2, f16vec2);"
"bvec3 lessThanEqual(f16vec3, f16vec3);"
"bvec4 lessThanEqual(f16vec4, f16vec4);"
"bvec2 greaterThan(f16vec2, f16vec2);"
"bvec3 greaterThan(f16vec3, f16vec3);"
"bvec4 greaterThan(f16vec4, f16vec4);"
"bvec2 greaterThanEqual(f16vec2, f16vec2);"
"bvec3 greaterThanEqual(f16vec3, f16vec3);"
"bvec4 greaterThanEqual(f16vec4, f16vec4);"
"bvec2 equal(f16vec2, f16vec2);"
"bvec3 equal(f16vec3, f16vec3);"
"bvec4 equal(f16vec4, f16vec4);"
"bvec2 notEqual(f16vec2, f16vec2);"
"bvec3 notEqual(f16vec3, f16vec3);"
"bvec4 notEqual(f16vec4, f16vec4);"
"\n");
}
#endif
//============================================================================
@@ -1975,6 +2336,77 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 interpolateAtVertexAMD(uvec3, uint);"
"uvec4 interpolateAtVertexAMD(uvec4, uint);"
"uint interpolateAtVertexAMD(float16_t, uint);"
"uvec2 interpolateAtVertexAMD(f16vec2, uint);"
"uvec3 interpolateAtVertexAMD(f16vec3, uint);"
"uvec4 interpolateAtVertexAMD(f16vec4, uint);"
"\n");
}
// GL_AMD_gpu_shader_half_float
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangFragment].append(
"float16_t dFdx(float16_t);"
"f16vec2 dFdx(f16vec2);"
"f16vec3 dFdx(f16vec3);"
"f16vec4 dFdx(f16vec4);"
"float16_t dFdy(float16_t);"
"f16vec2 dFdy(f16vec2);"
"f16vec3 dFdy(f16vec3);"
"f16vec4 dFdy(f16vec4);"
"float16_t dFdxFine(float16_t);"
"f16vec2 dFdxFine(f16vec2);"
"f16vec3 dFdxFine(f16vec3);"
"f16vec4 dFdxFine(f16vec4);"
"float16_t dFdyFine(float16_t);"
"f16vec2 dFdyFine(f16vec2);"
"f16vec3 dFdyFine(f16vec3);"
"f16vec4 dFdyFine(f16vec4);"
"float16_t dFdxCoarse(float16_t);"
"f16vec2 dFdxCoarse(f16vec2);"
"f16vec3 dFdxCoarse(f16vec3);"
"f16vec4 dFdxCoarse(f16vec4);"
"float16_t dFdyCoarse(float16_t);"
"f16vec2 dFdyCoarse(f16vec2);"
"f16vec3 dFdyCoarse(f16vec3);"
"f16vec4 dFdyCoarse(f16vec4);"
"float16_t fwidth(float16_t);"
"f16vec2 fwidth(f16vec2);"
"f16vec3 fwidth(f16vec3);"
"f16vec4 fwidth(f16vec4);"
"float16_t fwidthFine(float16_t);"
"f16vec2 fwidthFine(f16vec2);"
"f16vec3 fwidthFine(f16vec3);"
"f16vec4 fwidthFine(f16vec4);"
"float16_t fwidthCoarse(float16_t);"
"f16vec2 fwidthCoarse(f16vec2);"
"f16vec3 fwidthCoarse(f16vec3);"
"f16vec4 fwidthCoarse(f16vec4);"
"float16_t interpolateAtCentroid(float16_t);"
"f16vec2 interpolateAtCentroid(f16vec2);"
"f16vec3 interpolateAtCentroid(f16vec3);"
"f16vec4 interpolateAtCentroid(f16vec4);"
"float16_t interpolateAtSample(float16_t, int);"
"f16vec2 interpolateAtSample(f16vec2, int);"
"f16vec3 interpolateAtSample(f16vec3, int);"
"f16vec4 interpolateAtSample(f16vec4, int);"
"float16_t interpolateAtOffset(float16_t, vec2);"
"f16vec2 interpolateAtOffset(f16vec2, vec2);"
"f16vec3 interpolateAtOffset(f16vec3, vec2);"
"f16vec4 interpolateAtOffset(f16vec4, vec2);"
"\n");
}
#endif
@@ -4369,6 +4801,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("packUint2x32", EOpPackUint2x32);
symbolTable.relateToOperator("unpackUint2x32", EOpUnpackUint2x32);
#ifdef AMD_EXTENSIONS
symbolTable.relateToOperator("packFloat2x16", EOpPackFloat2x16);
symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16);
#endif
symbolTable.relateToOperator("length", EOpLength);
symbolTable.relateToOperator("distance", EOpDistance);
symbolTable.relateToOperator("dot", EOpDot);

View File

@@ -268,6 +268,9 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break;
case EOpConstructDouble: newType = EbtDouble; break;
#ifdef AMD_EXTENSIONS
case EOpConstructFloat16: newType = EbtFloat16; break;
#endif
default: break; // some compilers want this
}
@@ -293,6 +296,9 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
case EOpConstructBool:
case EOpConstructFloat:
case EOpConstructDouble:
#ifdef AMD_EXTENSIONS
case EOpConstructFloat16:
#endif
return child;
default: break; // some compilers want this
}
@@ -471,6 +477,11 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpConstructDouble:
promoteTo = EbtDouble;
break;
#ifdef AMD_EXTENSIONS
case EOpConstructFloat16:
promoteTo = EbtFloat16;
break;
#endif
case EOpConstructInt:
promoteTo = EbtInt;
break;
@@ -585,6 +596,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtUint: newOp = EOpConvUintToDouble; break;
case EbtBool: newOp = EOpConvBoolToDouble; break;
case EbtFloat: newOp = EOpConvFloatToDouble; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToDouble; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToDouble; break;
case EbtUint64: newOp = EOpConvUint64ToDouble; break;
default:
@@ -597,18 +611,39 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtUint: newOp = EOpConvUintToFloat; break;
case EbtBool: newOp = EOpConvBoolToFloat; break;
case EbtDouble: newOp = EOpConvDoubleToFloat; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToFloat; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToFloat; break;
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
default:
return 0;
}
break;
#ifdef AMD_EXTENSIONS
case EbtFloat16:
switch (node->getBasicType()) {
case EbtInt: newOp = EOpConvIntToFloat16; break;
case EbtUint: newOp = EOpConvUintToFloat16; break;
case EbtBool: newOp = EOpConvBoolToFloat16; break;
case EbtFloat: newOp = EOpConvFloatToFloat16; break;
case EbtDouble: newOp = EOpConvDoubleToFloat16; break;
case EbtInt64: newOp = EOpConvInt64ToFloat16; break;
case EbtUint64: newOp = EOpConvUint64ToFloat16; break;
default:
return 0;
}
break;
#endif
case EbtBool:
switch (node->getBasicType()) {
case EbtInt: newOp = EOpConvIntToBool; break;
case EbtUint: newOp = EOpConvUintToBool; break;
case EbtFloat: newOp = EOpConvFloatToBool; break;
case EbtDouble: newOp = EOpConvDoubleToBool; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToBool; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToBool; break;
case EbtUint64: newOp = EOpConvUint64ToBool; break;
default:
@@ -621,6 +656,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtBool: newOp = EOpConvBoolToInt; break;
case EbtFloat: newOp = EOpConvFloatToInt; break;
case EbtDouble: newOp = EOpConvDoubleToInt; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToInt; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToInt; break;
case EbtUint64: newOp = EOpConvUint64ToInt; break;
default:
@@ -633,6 +671,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtBool: newOp = EOpConvBoolToUint; break;
case EbtFloat: newOp = EOpConvFloatToUint; break;
case EbtDouble: newOp = EOpConvDoubleToUint; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToUint; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToUint; break;
case EbtUint64: newOp = EOpConvUint64ToUint; break;
default:
@@ -646,6 +687,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtBool: newOp = EOpConvBoolToInt64; break;
case EbtFloat: newOp = EOpConvFloatToInt64; break;
case EbtDouble: newOp = EOpConvDoubleToInt64; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToInt64; break;
#endif
case EbtUint64: newOp = EOpConvUint64ToInt64; break;
default:
return 0;
@@ -658,6 +702,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EbtBool: newOp = EOpConvBoolToUint64; break;
case EbtFloat: newOp = EOpConvFloatToUint64; break;
case EbtDouble: newOp = EOpConvDoubleToUint64; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: newOp = EOpConvFloat16ToUint64; break;
#endif
case EbtInt64: newOp = EOpConvInt64ToUint64; break;
default:
return 0;
@@ -779,6 +826,9 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
case EbtUint64:
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
return true;
default:
return false;
@@ -788,6 +838,9 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
case EbtInt:
case EbtUint:
case EbtFloat:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
return true;
default:
return false;
@@ -923,6 +976,47 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
}
}
break;
#ifdef AMD_EXTENSIONS
case EbtFloat16:
if (type.getMatrixCols()) {
switch (type.getMatrixCols()) {
case 2:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructF16Mat2x2; break;
case 3: op = EOpConstructF16Mat2x3; break;
case 4: op = EOpConstructF16Mat2x4; break;
default: break; // some compilers want this
}
break;
case 3:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructF16Mat3x2; break;
case 3: op = EOpConstructF16Mat3x3; break;
case 4: op = EOpConstructF16Mat3x4; break;
default: break; // some compilers want this
}
break;
case 4:
switch (type.getMatrixRows()) {
case 2: op = EOpConstructF16Mat4x2; break;
case 3: op = EOpConstructF16Mat4x3; break;
case 4: op = EOpConstructF16Mat4x4; break;
default: break; // some compilers want this
}
break;
}
}
else {
switch (type.getVectorSize()) {
case 1: op = EOpConstructFloat16; break;
case 2: op = EOpConstructF16Vec2; break;
case 3: op = EOpConstructF16Vec3; break;
case 4: op = EOpConstructF16Vec4; break;
default: break; // some compilers want this
}
}
break;
#endif
case EbtInt:
switch(type.getVectorSize()) {
case 1: op = EOpConstructInt; break;
@@ -1196,7 +1290,11 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(bool b, const TSourceLoc&
TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseType, const TSourceLoc& loc, bool literal) const
{
#ifdef AMD_EXTENSIONS
assert(baseType == EbtFloat || baseType == EbtDouble || baseType == EbtFloat16);
#else
assert(baseType == EbtFloat || baseType == EbtDouble);
#endif
TConstUnionArray unionArray(1);
unionArray[0].setDConst(d);
@@ -1451,6 +1549,12 @@ bool TIntermediate::isSpecializationOperation(const TIntermOperator& node) const
case EOpVectorSwizzle:
case EOpConvFloatToDouble:
case EOpConvDoubleToFloat:
#ifdef AMD_EXTENSIONS
case EOpConvFloat16ToFloat:
case EOpConvFloatToFloat16:
case EOpConvFloat16ToDouble:
case EOpConvDoubleToFloat16:
#endif
return true;
default:
return false;
@@ -1607,6 +1711,9 @@ bool TIntermUnary::promote()
operand->getBasicType() != EbtInt64 &&
operand->getBasicType() != EbtUint64 &&
operand->getBasicType() != EbtFloat &&
#ifdef AMD_EXTENSIONS
operand->getBasicType() != EbtFloat16 &&
#endif
operand->getBasicType() != EbtDouble)
return false;
@@ -1626,7 +1733,11 @@ bool TIntermUnary::promote()
void TIntermUnary::updatePrecision()
{
#ifdef AMD_EXTENSIONS
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
#else
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat) {
#endif
if (operand->getQualifier().precision > getQualifier().precision)
getQualifier().precision = operand->getQualifier().precision;
}
@@ -1955,7 +2066,11 @@ bool TIntermBinary::promote()
void TIntermBinary::updatePrecision()
{
#ifdef AMD_EXTENSIONS
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
#else
if (getBasicType() == EbtInt || getBasicType() == EbtUint || getBasicType() == EbtFloat) {
#endif
getQualifier().precision = std::max(right->getQualifier().precision, left->getQualifier().precision);
if (getQualifier().precision != EpqNone) {
left->propagatePrecision(getQualifier().precision);
@@ -1966,7 +2081,11 @@ void TIntermBinary::updatePrecision()
void TIntermTyped::propagatePrecision(TPrecisionQualifier newPrecision)
{
#ifdef AMD_EXTENSIONS
if (getQualifier().precision != EpqNone || (getBasicType() != EbtInt && getBasicType() != EbtUint && getBasicType() != EbtFloat && getBasicType() != EbtFloat16))
#else
if (getQualifier().precision != EpqNone || (getBasicType() != EbtInt && getBasicType() != EbtUint && getBasicType() != EbtFloat))
#endif
return;
getQualifier().precision = newPrecision;
@@ -2040,10 +2159,11 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
break;
case EbtFloat:
leftUnionArray[i] = rightUnionArray[i];
break;
case EbtDouble:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getDConst()));
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i] = rightUnionArray[i];
break;
default:
return node;
@@ -2068,12 +2188,43 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i] = rightUnionArray[i];
break;
default:
return node;
}
break;
#ifdef AMD_EXTENSIONS
case EbtFloat16:
switch (node->getType().getBasicType()) {
case EbtInt:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getIConst()));
break;
case EbtUint:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getUConst()));
break;
case EbtInt64:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getI64Const()));
break;
case EbtUint64:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getU64Const()));
break;
case EbtBool:
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
break;
case EbtFloat:
case EbtDouble:
case EbtFloat16:
leftUnionArray[i] = rightUnionArray[i];
break;
default:
return node;
}
break;
#endif
case EbtInt:
switch (node->getType().getBasicType()) {
case EbtInt:
@@ -2093,6 +2244,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getDConst()));
break;
default:
@@ -2118,6 +2272,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getDConst()));
break;
default:
@@ -2143,6 +2300,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i].setBConst(rightUnionArray[i].getDConst() != 0.0);
break;
default:
@@ -2168,6 +2328,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getDConst()));
break;
default:
@@ -2193,6 +2356,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getDConst()));
break;
default:

View File

@@ -4559,6 +4559,11 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
// containing a double, the offset must also be a multiple of 8..."
if (type.containsBasicType(EbtDouble) && ! IsMultipleOfPow2(qualifier.layoutXfbOffset, 8))
error(loc, "type contains double; xfb_offset must be a multiple of 8", "xfb_offset", "");
#ifdef AMD_EXTENSIONS
// ..., if applied to an aggregate containing a float16_t, the offset must also be a multiple of 2..."
else if (type.containsBasicType(EbtFloat16) && !IsMultipleOfPow2(qualifier.layoutXfbOffset, 2))
error(loc, "type contains half float; xfb_offset must be a multiple of 2", "xfb_offset", "");
#endif
else if (! IsMultipleOfPow2(qualifier.layoutXfbOffset, 4))
error(loc, "must be a multiple of size of first component", "xfb_offset", "");
}
@@ -4662,6 +4667,9 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
case EbtBool:
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
break;
default:
error(loc, "cannot be applied to this type", "constant_id", "");
@@ -5561,6 +5569,24 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
basicOp = EOpConstructDouble;
break;
#ifdef AMD_EXTENSIONS
case EOpConstructF16Vec2:
case EOpConstructF16Vec3:
case EOpConstructF16Vec4:
case EOpConstructF16Mat2x2:
case EOpConstructF16Mat2x3:
case EOpConstructF16Mat2x4:
case EOpConstructF16Mat3x2:
case EOpConstructF16Mat3x3:
case EOpConstructF16Mat3x4:
case EOpConstructF16Mat4x2:
case EOpConstructF16Mat4x3:
case EOpConstructF16Mat4x4:
case EOpConstructFloat16:
basicOp = EOpConstructFloat16;
break;
#endif
case EOpConstructIVec2:
case EOpConstructIVec3:
case EOpConstructIVec4:

View File

@@ -463,6 +463,25 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["u64vec3"] = U64VEC3;
(*KeywordMap)["u64vec4"] = U64VEC4;
#ifdef AMD_EXTENSIONS
(*KeywordMap)["float16_t"] = FLOAT16_T;
(*KeywordMap)["f16vec2"] = F16VEC2;
(*KeywordMap)["f16vec3"] = F16VEC3;
(*KeywordMap)["f16vec4"] = F16VEC4;
(*KeywordMap)["f16mat2"] = F16MAT2;
(*KeywordMap)["f16mat3"] = F16MAT3;
(*KeywordMap)["f16mat4"] = F16MAT4;
(*KeywordMap)["f16mat2x2"] = F16MAT2X2;
(*KeywordMap)["f16mat2x3"] = F16MAT2X3;
(*KeywordMap)["f16mat2x4"] = F16MAT2X4;
(*KeywordMap)["f16mat3x2"] = F16MAT3X2;
(*KeywordMap)["f16mat3x3"] = F16MAT3X3;
(*KeywordMap)["f16mat3x4"] = F16MAT3X4;
(*KeywordMap)["f16mat4x2"] = F16MAT4X2;
(*KeywordMap)["f16mat4x3"] = F16MAT4X3;
(*KeywordMap)["f16mat4x4"] = F16MAT4X4;
#endif
(*KeywordMap)["sampler2D"] = SAMPLER2D;
(*KeywordMap)["samplerCube"] = SAMPLERCUBE;
(*KeywordMap)["samplerCubeArray"] = SAMPLERCUBEARRAY;
@@ -687,6 +706,9 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
case PpAtomConstUint64: parserToken->sType.lex.i64 = ppToken.i64val; return UINT64CONSTANT;
case PpAtomConstFloat: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
case PpAtomConstDouble: parserToken->sType.lex.d = ppToken.dval; return DOUBLECONSTANT;
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16: parserToken->sType.lex.d = ppToken.dval; return FLOAT16CONSTANT;
#endif
case PpAtomIdentifier:
{
int token = tokenizeIdentifier();
@@ -938,10 +960,38 @@ int TScanContext::tokenizeIdentifier()
case U64VEC2:
case U64VEC3:
case U64VEC4:
if (parseContext.profile != EEsProfile && parseContext.version >= 450)
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
return keyword;
return identifierOrType();
#ifdef AMD_EXTENSIONS
case FLOAT16_T:
case F16VEC2:
case F16VEC3:
case F16VEC4:
case F16MAT2:
case F16MAT3:
case F16MAT4:
case F16MAT2X2:
case F16MAT2X3:
case F16MAT2X4:
case F16MAT3X2:
case F16MAT3X3:
case F16MAT3X4:
case F16MAT4X2:
case F16MAT4X3:
case F16MAT4X4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
return keyword;
return identifierOrType();
#endif
case SAMPLERCUBEARRAY:
case SAMPLERCUBEARRAYSHADOW:
case ISAMPLERCUBEARRAY:

View File

@@ -60,6 +60,9 @@ void TType::buildMangledName(TString& mangledName)
switch (basicType) {
case EbtFloat: mangledName += 'f'; break;
case EbtDouble: mangledName += 'd'; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: mangledName += "f16"; break;
#endif
case EbtInt: mangledName += 'i'; break;
case EbtUint: mangledName += 'u'; break;
case EbtInt64: mangledName += "i64"; break;

View File

@@ -192,6 +192,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_AMD_shader_trinary_minmax] = EBhDisable;
extensionBehavior[E_GL_AMD_shader_explicit_vertex_parameter] = EBhDisable;
extensionBehavior[E_GL_AMD_gcn_shader] = EBhDisable;
extensionBehavior[E_GL_AMD_gpu_shader_half_float] = EBhDisable;
#endif
// AEP
@@ -299,6 +300,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_AMD_shader_trinary_minmax 1\n"
"#define GL_AMD_shader_explicit_vertex_parameter 1\n"
"#define GL_AMD_gcn_shader 1\n"
"#define GL_AMD_gpu_shader_half_float 1\n"
#endif
;
}
@@ -663,6 +665,19 @@ void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op)
profileRequires(loc, ECompatibilityProfile, 400, nullptr, op);
}
#ifdef AMD_EXTENSIONS
// Call for any operation needing GLSL float16 data-type support.
void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
requireExtensions(loc, 1, &E_GL_AMD_gpu_shader_half_float, "shader half float");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
}
}
#endif
// Call for any operation needing GLSL 64-bit integer data-type support.
void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool builtIn)
{

View File

@@ -136,10 +136,11 @@ const char* const E_GL_GOOGLE_cpp_style_line_directive = "GL_GOOGLE_cpp
const char* const E_GL_GOOGLE_include_directive = "GL_GOOGLE_include_directive";
#ifdef AMD_EXTENSIONS
const char* const E_GL_AMD_shader_ballot = "GL_AMD_shader_ballot";
const char* const E_GL_AMD_shader_trinary_minmax = "GL_AMD_shader_trinary_minmax";
const char* const E_GL_AMD_shader_explicit_vertex_parameter = "GL_AMD_shader_explicit_vertex_parameter";
const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_shader";
const char* const E_GL_AMD_shader_ballot = "GL_AMD_shader_ballot";
const char* const E_GL_AMD_shader_trinary_minmax = "GL_AMD_shader_trinary_minmax";
const char* const E_GL_AMD_shader_explicit_vertex_parameter = "GL_AMD_shader_explicit_vertex_parameter";
const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_shader";
const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_shader_half_float";
#endif
// AEP

View File

@@ -76,6 +76,24 @@
#define GL_DOUBLE_MAT4x2 0x8F4D
#define GL_DOUBLE_MAT4x3 0x8F4E
#ifdef AMD_EXTENSIONS
// Those constants are borrowed from extension NV_gpu_shader5
#define GL_FLOAT16_NV 0x8FF8
#define GL_FLOAT16_VEC2_NV 0x8FF9
#define GL_FLOAT16_VEC3_NV 0x8FFA
#define GL_FLOAT16_VEC4_NV 0x8FFB
#define GL_FLOAT16_MAT2_AMD 0x91C5
#define GL_FLOAT16_MAT3_AMD 0x91C6
#define GL_FLOAT16_MAT4_AMD 0x91C7
#define GL_FLOAT16_MAT2x3_AMD 0x91C8
#define GL_FLOAT16_MAT2x4_AMD 0x91C9
#define GL_FLOAT16_MAT3x2_AMD 0x91CA
#define GL_FLOAT16_MAT3x4_AMD 0x91CB
#define GL_FLOAT16_MAT4x2_AMD 0x91CC
#define GL_FLOAT16_MAT4x3_AMD 0x91CD
#endif
#define GL_SAMPLER_1D 0x8B5D
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_3D 0x8B5F

View File

@@ -119,13 +119,14 @@ extern int yylex(YYSTYPE*, TParseContext&);
%expect 1 // One shift reduce conflict because of if | else
%token <lex> ATTRIBUTE VARYING
%token <lex> CONST BOOL FLOAT DOUBLE INT UINT INT64_T UINT64_T
%token <lex> CONST BOOL FLOAT DOUBLE INT UINT INT64_T UINT64_T FLOAT16_T
%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT SUBROUTINE
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 I64VEC2 I64VEC3 I64VEC4 UVEC2 UVEC3 UVEC4 U64VEC2 U64VEC3 U64VEC4 VEC2 VEC3 VEC4
%token <lex> MAT2 MAT3 MAT4 CENTROID IN OUT INOUT
%token <lex> UNIFORM PATCH SAMPLE BUFFER SHARED
%token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY
%token <lex> DVEC2 DVEC3 DVEC4 DMAT2 DMAT3 DMAT4
%token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4
%token <lex> NOPERSPECTIVE FLAT SMOOTH LAYOUT __EXPLICITINTERPAMD
%token <lex> MAT2X2 MAT2X3 MAT2X4
@@ -134,6 +135,9 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> DMAT2X2 DMAT2X3 DMAT2X4
%token <lex> DMAT3X2 DMAT3X3 DMAT3X4
%token <lex> DMAT4X2 DMAT4X3 DMAT4X4
%token <lex> F16MAT2X2 F16MAT2X3 F16MAT2X4
%token <lex> F16MAT3X2 F16MAT3X3 F16MAT3X4
%token <lex> F16MAT4X2 F16MAT4X3 F16MAT4X4
%token <lex> ATOMIC_UINT
// combined image/sampler
@@ -182,7 +186,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> STRUCT VOID WHILE
%token <lex> IDENTIFIER TYPE_NAME
%token <lex> FLOATCONSTANT DOUBLECONSTANT INTCONSTANT UINTCONSTANT INT64CONSTANT UINT64CONSTANT BOOLCONSTANT
%token <lex> FLOATCONSTANT DOUBLECONSTANT INTCONSTANT UINTCONSTANT INT64CONSTANT UINT64CONSTANT BOOLCONSTANT FLOAT16CONSTANT
%token <lex> LEFT_OP RIGHT_OP
%token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
%token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
@@ -274,6 +278,12 @@ primary_expression
parseContext.doubleCheck($1.loc, "double literal");
$$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true);
}
| FLOAT16CONSTANT {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float literal");
$$ = parseContext.intermediate.addConstantUnion($1.d, EbtFloat16, $1.loc, true);
#endif
}
| BOOLCONSTANT {
$$ = parseContext.intermediate.addConstantUnion($1.b, $1.loc, true);
}
@@ -1324,6 +1334,13 @@ type_specifier_nonarray
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtDouble;
}
| FLOAT16_T {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
#endif
}
| INT {
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtInt;
@@ -1380,6 +1397,30 @@ type_specifier_nonarray
$$.basicType = EbtDouble;
$$.setVector(4);
}
| F16VEC2 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setVector(2);
#endif
}
| F16VEC3 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setVector(3);
#endif
}
| F16VEC4 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float vector", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setVector(4);
#endif
}
| BVEC2 {
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtBool;
@@ -1596,6 +1637,102 @@ type_specifier_nonarray
$$.basicType = EbtDouble;
$$.setMatrix(4, 4);
}
| F16MAT2 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(2, 2);
#endif
}
| F16MAT3 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(3, 3);
#endif
}
| F16MAT4 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(4, 4);
#endif
}
| F16MAT2X2 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(2, 2);
#endif
}
| F16MAT2X3 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(2, 3);
#endif
}
| F16MAT2X4 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(2, 4);
#endif
}
| F16MAT3X2 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(3, 2);
#endif
}
| F16MAT3X3 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(3, 3);
#endif
}
| F16MAT3X4 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(3, 4);
#endif
}
| F16MAT4X2 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(4, 2);
#endif
}
| F16MAT4X3 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(4, 3);
#endif
}
| F16MAT4X4 {
#ifdef AMD_EXTENSIONS
parseContext.float16Check($1.loc, "half float matrix", parseContext.symbolTable.atBuiltInLevel());
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtFloat16;
$$.setMatrix(4, 4);
#endif
}
| ATOMIC_UINT {
parseContext.vulkanRemoved($1.loc, "atomic counter types");
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* A Bison parser, made by GNU Bison 2.7. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
# define YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
/* Debug traces. */
#ifndef YY_YY_GLSLANG_TAB_CPP_H_INCLUDED
# define YY_YY_GLSLANG_TAB_CPP_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
@@ -40,288 +40,306 @@
extern int yydebug;
#endif
/* Token type. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
ATTRIBUTE = 258,
VARYING = 259,
CONST = 260,
BOOL = 261,
FLOAT = 262,
DOUBLE = 263,
INT = 264,
UINT = 265,
INT64_T = 266,
UINT64_T = 267,
BREAK = 268,
CONTINUE = 269,
DO = 270,
ELSE = 271,
FOR = 272,
IF = 273,
DISCARD = 274,
RETURN = 275,
SWITCH = 276,
CASE = 277,
DEFAULT = 278,
SUBROUTINE = 279,
BVEC2 = 280,
BVEC3 = 281,
BVEC4 = 282,
IVEC2 = 283,
IVEC3 = 284,
IVEC4 = 285,
I64VEC2 = 286,
I64VEC3 = 287,
I64VEC4 = 288,
UVEC2 = 289,
UVEC3 = 290,
UVEC4 = 291,
U64VEC2 = 292,
U64VEC3 = 293,
U64VEC4 = 294,
VEC2 = 295,
VEC3 = 296,
VEC4 = 297,
MAT2 = 298,
MAT3 = 299,
MAT4 = 300,
CENTROID = 301,
IN = 302,
OUT = 303,
INOUT = 304,
UNIFORM = 305,
PATCH = 306,
SAMPLE = 307,
BUFFER = 308,
SHARED = 309,
COHERENT = 310,
VOLATILE = 311,
RESTRICT = 312,
READONLY = 313,
WRITEONLY = 314,
DVEC2 = 315,
DVEC3 = 316,
DVEC4 = 317,
DMAT2 = 318,
DMAT3 = 319,
DMAT4 = 320,
NOPERSPECTIVE = 321,
FLAT = 322,
SMOOTH = 323,
LAYOUT = 324,
__EXPLICITINTERPAMD = 325,
MAT2X2 = 326,
MAT2X3 = 327,
MAT2X4 = 328,
MAT3X2 = 329,
MAT3X3 = 330,
MAT3X4 = 331,
MAT4X2 = 332,
MAT4X3 = 333,
MAT4X4 = 334,
DMAT2X2 = 335,
DMAT2X3 = 336,
DMAT2X4 = 337,
DMAT3X2 = 338,
DMAT3X3 = 339,
DMAT3X4 = 340,
DMAT4X2 = 341,
DMAT4X3 = 342,
DMAT4X4 = 343,
ATOMIC_UINT = 344,
SAMPLER1D = 345,
SAMPLER2D = 346,
SAMPLER3D = 347,
SAMPLERCUBE = 348,
SAMPLER1DSHADOW = 349,
SAMPLER2DSHADOW = 350,
SAMPLERCUBESHADOW = 351,
SAMPLER1DARRAY = 352,
SAMPLER2DARRAY = 353,
SAMPLER1DARRAYSHADOW = 354,
SAMPLER2DARRAYSHADOW = 355,
ISAMPLER1D = 356,
ISAMPLER2D = 357,
ISAMPLER3D = 358,
ISAMPLERCUBE = 359,
ISAMPLER1DARRAY = 360,
ISAMPLER2DARRAY = 361,
USAMPLER1D = 362,
USAMPLER2D = 363,
USAMPLER3D = 364,
USAMPLERCUBE = 365,
USAMPLER1DARRAY = 366,
USAMPLER2DARRAY = 367,
SAMPLER2DRECT = 368,
SAMPLER2DRECTSHADOW = 369,
ISAMPLER2DRECT = 370,
USAMPLER2DRECT = 371,
SAMPLERBUFFER = 372,
ISAMPLERBUFFER = 373,
USAMPLERBUFFER = 374,
SAMPLERCUBEARRAY = 375,
SAMPLERCUBEARRAYSHADOW = 376,
ISAMPLERCUBEARRAY = 377,
USAMPLERCUBEARRAY = 378,
SAMPLER2DMS = 379,
ISAMPLER2DMS = 380,
USAMPLER2DMS = 381,
SAMPLER2DMSARRAY = 382,
ISAMPLER2DMSARRAY = 383,
USAMPLER2DMSARRAY = 384,
SAMPLEREXTERNALOES = 385,
SAMPLER = 386,
SAMPLERSHADOW = 387,
TEXTURE1D = 388,
TEXTURE2D = 389,
TEXTURE3D = 390,
TEXTURECUBE = 391,
TEXTURE1DARRAY = 392,
TEXTURE2DARRAY = 393,
ITEXTURE1D = 394,
ITEXTURE2D = 395,
ITEXTURE3D = 396,
ITEXTURECUBE = 397,
ITEXTURE1DARRAY = 398,
ITEXTURE2DARRAY = 399,
UTEXTURE1D = 400,
UTEXTURE2D = 401,
UTEXTURE3D = 402,
UTEXTURECUBE = 403,
UTEXTURE1DARRAY = 404,
UTEXTURE2DARRAY = 405,
TEXTURE2DRECT = 406,
ITEXTURE2DRECT = 407,
UTEXTURE2DRECT = 408,
TEXTUREBUFFER = 409,
ITEXTUREBUFFER = 410,
UTEXTUREBUFFER = 411,
TEXTURECUBEARRAY = 412,
ITEXTURECUBEARRAY = 413,
UTEXTURECUBEARRAY = 414,
TEXTURE2DMS = 415,
ITEXTURE2DMS = 416,
UTEXTURE2DMS = 417,
TEXTURE2DMSARRAY = 418,
ITEXTURE2DMSARRAY = 419,
UTEXTURE2DMSARRAY = 420,
SUBPASSINPUT = 421,
SUBPASSINPUTMS = 422,
ISUBPASSINPUT = 423,
ISUBPASSINPUTMS = 424,
USUBPASSINPUT = 425,
USUBPASSINPUTMS = 426,
IMAGE1D = 427,
IIMAGE1D = 428,
UIMAGE1D = 429,
IMAGE2D = 430,
IIMAGE2D = 431,
UIMAGE2D = 432,
IMAGE3D = 433,
IIMAGE3D = 434,
UIMAGE3D = 435,
IMAGE2DRECT = 436,
IIMAGE2DRECT = 437,
UIMAGE2DRECT = 438,
IMAGECUBE = 439,
IIMAGECUBE = 440,
UIMAGECUBE = 441,
IMAGEBUFFER = 442,
IIMAGEBUFFER = 443,
UIMAGEBUFFER = 444,
IMAGE1DARRAY = 445,
IIMAGE1DARRAY = 446,
UIMAGE1DARRAY = 447,
IMAGE2DARRAY = 448,
IIMAGE2DARRAY = 449,
UIMAGE2DARRAY = 450,
IMAGECUBEARRAY = 451,
IIMAGECUBEARRAY = 452,
UIMAGECUBEARRAY = 453,
IMAGE2DMS = 454,
IIMAGE2DMS = 455,
UIMAGE2DMS = 456,
IMAGE2DMSARRAY = 457,
IIMAGE2DMSARRAY = 458,
UIMAGE2DMSARRAY = 459,
STRUCT = 460,
VOID = 461,
WHILE = 462,
IDENTIFIER = 463,
TYPE_NAME = 464,
FLOATCONSTANT = 465,
DOUBLECONSTANT = 466,
INTCONSTANT = 467,
UINTCONSTANT = 468,
INT64CONSTANT = 469,
UINT64CONSTANT = 470,
BOOLCONSTANT = 471,
LEFT_OP = 472,
RIGHT_OP = 473,
INC_OP = 474,
DEC_OP = 475,
LE_OP = 476,
GE_OP = 477,
EQ_OP = 478,
NE_OP = 479,
AND_OP = 480,
OR_OP = 481,
XOR_OP = 482,
MUL_ASSIGN = 483,
DIV_ASSIGN = 484,
ADD_ASSIGN = 485,
MOD_ASSIGN = 486,
LEFT_ASSIGN = 487,
RIGHT_ASSIGN = 488,
AND_ASSIGN = 489,
XOR_ASSIGN = 490,
OR_ASSIGN = 491,
SUB_ASSIGN = 492,
LEFT_PAREN = 493,
RIGHT_PAREN = 494,
LEFT_BRACKET = 495,
RIGHT_BRACKET = 496,
LEFT_BRACE = 497,
RIGHT_BRACE = 498,
DOT = 499,
COMMA = 500,
COLON = 501,
EQUAL = 502,
SEMICOLON = 503,
BANG = 504,
DASH = 505,
TILDE = 506,
PLUS = 507,
STAR = 508,
SLASH = 509,
PERCENT = 510,
LEFT_ANGLE = 511,
RIGHT_ANGLE = 512,
VERTICAL_BAR = 513,
CARET = 514,
AMPERSAND = 515,
QUESTION = 516,
INVARIANT = 517,
PRECISE = 518,
HIGH_PRECISION = 519,
MEDIUM_PRECISION = 520,
LOW_PRECISION = 521,
PRECISION = 522,
PACKED = 523,
RESOURCE = 524,
SUPERP = 525
};
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
ATTRIBUTE = 258,
VARYING = 259,
CONST = 260,
BOOL = 261,
FLOAT = 262,
DOUBLE = 263,
INT = 264,
UINT = 265,
INT64_T = 266,
UINT64_T = 267,
FLOAT16_T = 268,
BREAK = 269,
CONTINUE = 270,
DO = 271,
ELSE = 272,
FOR = 273,
IF = 274,
DISCARD = 275,
RETURN = 276,
SWITCH = 277,
CASE = 278,
DEFAULT = 279,
SUBROUTINE = 280,
BVEC2 = 281,
BVEC3 = 282,
BVEC4 = 283,
IVEC2 = 284,
IVEC3 = 285,
IVEC4 = 286,
I64VEC2 = 287,
I64VEC3 = 288,
I64VEC4 = 289,
UVEC2 = 290,
UVEC3 = 291,
UVEC4 = 292,
U64VEC2 = 293,
U64VEC3 = 294,
U64VEC4 = 295,
VEC2 = 296,
VEC3 = 297,
VEC4 = 298,
MAT2 = 299,
MAT3 = 300,
MAT4 = 301,
CENTROID = 302,
IN = 303,
OUT = 304,
INOUT = 305,
UNIFORM = 306,
PATCH = 307,
SAMPLE = 308,
BUFFER = 309,
SHARED = 310,
COHERENT = 311,
VOLATILE = 312,
RESTRICT = 313,
READONLY = 314,
WRITEONLY = 315,
DVEC2 = 316,
DVEC3 = 317,
DVEC4 = 318,
DMAT2 = 319,
DMAT3 = 320,
DMAT4 = 321,
F16VEC2 = 322,
F16VEC3 = 323,
F16VEC4 = 324,
F16MAT2 = 325,
F16MAT3 = 326,
F16MAT4 = 327,
NOPERSPECTIVE = 328,
FLAT = 329,
SMOOTH = 330,
LAYOUT = 331,
__EXPLICITINTERPAMD = 332,
MAT2X2 = 333,
MAT2X3 = 334,
MAT2X4 = 335,
MAT3X2 = 336,
MAT3X3 = 337,
MAT3X4 = 338,
MAT4X2 = 339,
MAT4X3 = 340,
MAT4X4 = 341,
DMAT2X2 = 342,
DMAT2X3 = 343,
DMAT2X4 = 344,
DMAT3X2 = 345,
DMAT3X3 = 346,
DMAT3X4 = 347,
DMAT4X2 = 348,
DMAT4X3 = 349,
DMAT4X4 = 350,
F16MAT2X2 = 351,
F16MAT2X3 = 352,
F16MAT2X4 = 353,
F16MAT3X2 = 354,
F16MAT3X3 = 355,
F16MAT3X4 = 356,
F16MAT4X2 = 357,
F16MAT4X3 = 358,
F16MAT4X4 = 359,
ATOMIC_UINT = 360,
SAMPLER1D = 361,
SAMPLER2D = 362,
SAMPLER3D = 363,
SAMPLERCUBE = 364,
SAMPLER1DSHADOW = 365,
SAMPLER2DSHADOW = 366,
SAMPLERCUBESHADOW = 367,
SAMPLER1DARRAY = 368,
SAMPLER2DARRAY = 369,
SAMPLER1DARRAYSHADOW = 370,
SAMPLER2DARRAYSHADOW = 371,
ISAMPLER1D = 372,
ISAMPLER2D = 373,
ISAMPLER3D = 374,
ISAMPLERCUBE = 375,
ISAMPLER1DARRAY = 376,
ISAMPLER2DARRAY = 377,
USAMPLER1D = 378,
USAMPLER2D = 379,
USAMPLER3D = 380,
USAMPLERCUBE = 381,
USAMPLER1DARRAY = 382,
USAMPLER2DARRAY = 383,
SAMPLER2DRECT = 384,
SAMPLER2DRECTSHADOW = 385,
ISAMPLER2DRECT = 386,
USAMPLER2DRECT = 387,
SAMPLERBUFFER = 388,
ISAMPLERBUFFER = 389,
USAMPLERBUFFER = 390,
SAMPLERCUBEARRAY = 391,
SAMPLERCUBEARRAYSHADOW = 392,
ISAMPLERCUBEARRAY = 393,
USAMPLERCUBEARRAY = 394,
SAMPLER2DMS = 395,
ISAMPLER2DMS = 396,
USAMPLER2DMS = 397,
SAMPLER2DMSARRAY = 398,
ISAMPLER2DMSARRAY = 399,
USAMPLER2DMSARRAY = 400,
SAMPLEREXTERNALOES = 401,
SAMPLER = 402,
SAMPLERSHADOW = 403,
TEXTURE1D = 404,
TEXTURE2D = 405,
TEXTURE3D = 406,
TEXTURECUBE = 407,
TEXTURE1DARRAY = 408,
TEXTURE2DARRAY = 409,
ITEXTURE1D = 410,
ITEXTURE2D = 411,
ITEXTURE3D = 412,
ITEXTURECUBE = 413,
ITEXTURE1DARRAY = 414,
ITEXTURE2DARRAY = 415,
UTEXTURE1D = 416,
UTEXTURE2D = 417,
UTEXTURE3D = 418,
UTEXTURECUBE = 419,
UTEXTURE1DARRAY = 420,
UTEXTURE2DARRAY = 421,
TEXTURE2DRECT = 422,
ITEXTURE2DRECT = 423,
UTEXTURE2DRECT = 424,
TEXTUREBUFFER = 425,
ITEXTUREBUFFER = 426,
UTEXTUREBUFFER = 427,
TEXTURECUBEARRAY = 428,
ITEXTURECUBEARRAY = 429,
UTEXTURECUBEARRAY = 430,
TEXTURE2DMS = 431,
ITEXTURE2DMS = 432,
UTEXTURE2DMS = 433,
TEXTURE2DMSARRAY = 434,
ITEXTURE2DMSARRAY = 435,
UTEXTURE2DMSARRAY = 436,
SUBPASSINPUT = 437,
SUBPASSINPUTMS = 438,
ISUBPASSINPUT = 439,
ISUBPASSINPUTMS = 440,
USUBPASSINPUT = 441,
USUBPASSINPUTMS = 442,
IMAGE1D = 443,
IIMAGE1D = 444,
UIMAGE1D = 445,
IMAGE2D = 446,
IIMAGE2D = 447,
UIMAGE2D = 448,
IMAGE3D = 449,
IIMAGE3D = 450,
UIMAGE3D = 451,
IMAGE2DRECT = 452,
IIMAGE2DRECT = 453,
UIMAGE2DRECT = 454,
IMAGECUBE = 455,
IIMAGECUBE = 456,
UIMAGECUBE = 457,
IMAGEBUFFER = 458,
IIMAGEBUFFER = 459,
UIMAGEBUFFER = 460,
IMAGE1DARRAY = 461,
IIMAGE1DARRAY = 462,
UIMAGE1DARRAY = 463,
IMAGE2DARRAY = 464,
IIMAGE2DARRAY = 465,
UIMAGE2DARRAY = 466,
IMAGECUBEARRAY = 467,
IIMAGECUBEARRAY = 468,
UIMAGECUBEARRAY = 469,
IMAGE2DMS = 470,
IIMAGE2DMS = 471,
UIMAGE2DMS = 472,
IMAGE2DMSARRAY = 473,
IIMAGE2DMSARRAY = 474,
UIMAGE2DMSARRAY = 475,
STRUCT = 476,
VOID = 477,
WHILE = 478,
IDENTIFIER = 479,
TYPE_NAME = 480,
FLOATCONSTANT = 481,
DOUBLECONSTANT = 482,
INTCONSTANT = 483,
UINTCONSTANT = 484,
INT64CONSTANT = 485,
UINT64CONSTANT = 486,
BOOLCONSTANT = 487,
FLOAT16CONSTANT = 488,
LEFT_OP = 489,
RIGHT_OP = 490,
INC_OP = 491,
DEC_OP = 492,
LE_OP = 493,
GE_OP = 494,
EQ_OP = 495,
NE_OP = 496,
AND_OP = 497,
OR_OP = 498,
XOR_OP = 499,
MUL_ASSIGN = 500,
DIV_ASSIGN = 501,
ADD_ASSIGN = 502,
MOD_ASSIGN = 503,
LEFT_ASSIGN = 504,
RIGHT_ASSIGN = 505,
AND_ASSIGN = 506,
XOR_ASSIGN = 507,
OR_ASSIGN = 508,
SUB_ASSIGN = 509,
LEFT_PAREN = 510,
RIGHT_PAREN = 511,
LEFT_BRACKET = 512,
RIGHT_BRACKET = 513,
LEFT_BRACE = 514,
RIGHT_BRACE = 515,
DOT = 516,
COMMA = 517,
COLON = 518,
EQUAL = 519,
SEMICOLON = 520,
BANG = 521,
DASH = 522,
TILDE = 523,
PLUS = 524,
STAR = 525,
SLASH = 526,
PERCENT = 527,
LEFT_ANGLE = 528,
RIGHT_ANGLE = 529,
VERTICAL_BAR = 530,
CARET = 531,
AMPERSAND = 532,
QUESTION = 533,
INVARIANT = 534,
PRECISE = 535,
HIGH_PRECISION = 536,
MEDIUM_PRECISION = 537,
LOW_PRECISION = 538,
PRECISION = 539,
PACKED = 540,
RESOURCE = 541,
SUPERP = 542
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
#line 66 "MachineIndependent/glslang.y" /* yacc.c:1909 */
/* Line 2058 of yacc.c */
#line 66 "glslang.y"
struct {
glslang::TSourceLoc loc;
@@ -355,16 +373,28 @@ union YYSTYPE
};
} interm;
#line 359 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
/* Line 2058 of yacc.c */
#line 379 "glslang_tab.cpp.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (glslang::TParseContext* pParseContext);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED */
#endif /* !YY_YY_GLSLANG_TAB_CPP_H_INCLUDED */

View File

@@ -304,6 +304,11 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpPackUint2x32: out.debug << "packUint2x32"; break;
case EOpUnpackUint2x32: out.debug << "unpackUint2x32"; break;
#ifdef AMD_EXTENSIONS
case EOpPackFloat2x16: out.debug << "packFloat2x16"; break;
case EOpUnpackFloat2x16: out.debug << "unpackFloat2x16"; break;
#endif
case EOpLength: out.debug << "length"; break;
case EOpNormalize: out.debug << "normalize"; break;
case EOpDPdx: out.debug << "dPdx"; break;
@@ -373,6 +378,21 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpCubeFaceIndex: out.debug << "cubeFaceIndex"; break;
case EOpCubeFaceCoord: out.debug << "cubeFaceCoord"; break;
case EOpConvBoolToFloat16: out.debug << "Convert bool to float16"; break;
case EOpConvIntToFloat16: out.debug << "Convert int to float16"; break;
case EOpConvUintToFloat16: out.debug << "Convert uint to float16"; break;
case EOpConvFloatToFloat16: out.debug << "Convert float to float16"; break;
case EOpConvDoubleToFloat16: out.debug << "Convert double to float16"; break;
case EOpConvInt64ToFloat16: out.debug << "Convert int64 to float16"; break;
case EOpConvUint64ToFloat16: out.debug << "Convert uint64 to float16"; break;
case EOpConvFloat16ToBool: out.debug << "Convert float16 to bool"; break;
case EOpConvFloat16ToInt: out.debug << "Convert float16 to int"; break;
case EOpConvFloat16ToUint: out.debug << "Convert float16 to uint"; break;
case EOpConvFloat16ToFloat: out.debug << "Convert float16 to float"; break;
case EOpConvFloat16ToDouble: out.debug << "Convert float16 to double"; break;
case EOpConvFloat16ToInt64: out.debug << "Convert float16 to int64"; break;
case EOpConvFloat16ToUint64: out.debug << "Convert float16 to uint64"; break;
#endif
default: out.debug.message(EPrefixError, "Bad unary op");
@@ -447,6 +467,21 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpConstructDMat4x2: out.debug << "Construct dmat4x2"; break;
case EOpConstructDMat4x3: out.debug << "Construct dmat4x3"; break;
case EOpConstructDMat4x4: out.debug << "Construct dmat4"; break;
#ifdef AMD_EXTENSIONS
case EOpConstructFloat16: out.debug << "Construct float16_t"; break;
case EOpConstructF16Vec2: out.debug << "Construct f16vec2"; break;
case EOpConstructF16Vec3: out.debug << "Construct f16vec3"; break;
case EOpConstructF16Vec4: out.debug << "Construct f16vec4"; break;
case EOpConstructF16Mat2x2: out.debug << "Construct f16mat2"; break;
case EOpConstructF16Mat2x3: out.debug << "Construct f16mat2x3"; break;
case EOpConstructF16Mat2x4: out.debug << "Construct f16mat2x4"; break;
case EOpConstructF16Mat3x2: out.debug << "Construct f16mat3x2"; break;
case EOpConstructF16Mat3x3: out.debug << "Construct f16mat3"; break;
case EOpConstructF16Mat3x4: out.debug << "Construct f16mat3x4"; break;
case EOpConstructF16Mat4x2: out.debug << "Construct f16mat4x2"; break;
case EOpConstructF16Mat4x3: out.debug << "Construct f16mat4x3"; break;
case EOpConstructF16Mat4x4: out.debug << "Construct f16mat4"; break;
#endif
case EOpConstructStruct: out.debug << "Construct structure"; break;
case EOpConstructTextureSampler: out.debug << "Construct combined texture-sampler"; break;
@@ -636,6 +671,9 @@ static void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const
break;
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
{
const double value = constUnion[i].getDConst();
// Print infinity in a portable way, for test stability.

View File

@@ -950,6 +950,9 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
case EbtInt64:
case EbtUint64:
case EbtDouble: size = 8; return 8;
#ifdef AMD_EXTENSIONS
case EbtFloat16: size = 2; return 2;
#endif
default: size = 4; return 4;
}
}

View File

@@ -76,6 +76,9 @@ public:
virtual void updateExtensionBehavior(int line, const char* const extension, const char* behavior);
virtual void fullIntegerCheck(const TSourceLoc&, const char* op);
virtual void doubleCheck(const TSourceLoc&, const char* op);
#ifdef AMD_EXTENSIONS
virtual void float16Check(const TSourceLoc&, const char* op, bool builtIn = false);
#endif
virtual void int64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void spvRemoved(const TSourceLoc&, const char* op);
virtual void vulkanRemoved(const TSourceLoc&, const char* op);

View File

@@ -705,6 +705,9 @@ int TPpContext::CPPerror(TPpToken* ppToken)
while (token != '\n' && token != EndOfInput) {
if (token == PpAtomConstInt || token == PpAtomConstUint ||
token == PpAtomConstInt64 || token == PpAtomConstUint64 ||
#ifdef AMD_EXTENSIONS
token == PpAtomConstFloat16 ||
#endif
token == PpAtomConstFloat || token == PpAtomConstDouble) {
message.append(ppToken->name);
} else if (token == PpAtomIdentifier || token == PpAtomConstString) {
@@ -739,6 +742,9 @@ int TPpContext::CPPpragma(TPpToken* ppToken)
case PpAtomConstUint64:
case PpAtomConstFloat:
case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16:
#endif
tokens.push_back(ppToken->name);
break;
default:

View File

@@ -117,6 +117,10 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
int declen;
int str_len;
int isDouble = 0;
#ifdef AMD_EXTENSIONS
int isFloat16 = 0;
bool enableFloat16 = parseContext.version >= 450 && parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float);
#endif
declen = 0;
@@ -200,6 +204,28 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
len = 1,str_len=1;
}
}
#ifdef AMD_EXTENSIONS
} else if (enableFloat16 && (ch == 'h' || ch == 'H')) {
parseContext.float16Check(ppToken->loc, "half floating-point suffix");
if (!HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
int ch2 = getChar();
if (ch2 != 'f' && ch2 != 'F') {
ungetChar();
ungetChar();
}
else {
if (len < MaxTokenLength) {
str[len++] = (char)ch;
str[len++] = (char)ch2;
isFloat16 = 1;
}
else {
parseContext.ppError(ppToken->loc, "float literal too long", "", "");
len = 1, str_len = 1;
}
}
#endif
} else if (ch == 'f' || ch == 'F') {
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
if (! parseContext.relaxedErrors())
@@ -222,6 +248,10 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
if (isDouble)
return PpAtomConstDouble;
#ifdef AMD_EXTENSIONS
else if (isFloat16)
return PpAtomConstFloat16;
#endif
else
return PpAtomConstFloat;
}
@@ -744,6 +774,9 @@ const char* TPpContext::tokenize(TPpToken* ppToken)
case PpAtomConstInt64:
case PpAtomConstUint64:
case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16:
#endif
tokenString = ppToken->name;
break;
case PpAtomConstString:

View File

@@ -144,6 +144,9 @@ void TPpContext::RecordToken(TokenStream *pTok, int token, TPpToken* ppToken)
case PpAtomConstUint64:
case PpAtomConstFloat:
case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16:
#endif
str = ppToken->name;
while (*str) {
lAddByte(pTok, (unsigned char) *str);
@@ -195,6 +198,9 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
case PpAtomIdentifier:
case PpAtomConstFloat:
case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16:
#endif
case PpAtomConstInt:
case PpAtomConstUint:
case PpAtomConstInt64:
@@ -221,6 +227,9 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
break;
case PpAtomConstFloat:
case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16:
#endif
ppToken->dval = atof(ppToken->name);
break;
case PpAtomConstInt:

View File

@@ -123,6 +123,9 @@ enum EFixedAtoms {
PpAtomConstUint64,
PpAtomConstFloat,
PpAtomConstDouble,
#ifdef AMD_EXTENSIONS
PpAtomConstFloat16,
#endif
PpAtomConstString,
// Identifiers

View File

@@ -529,6 +529,9 @@ public:
switch (type.getBasicType()) {
case EbtFloat: return GL_FLOAT_VEC2 + offset;
case EbtDouble: return GL_DOUBLE_VEC2 + offset;
#ifdef AMD_EXTENSIONS
case EbtFloat16: return GL_FLOAT16_VEC2_NV + offset;
#endif
case EbtInt: return GL_INT_VEC2 + offset;
case EbtUint: return GL_UNSIGNED_INT_VEC2 + offset;
case EbtInt64: return GL_INT64_ARB + offset;
@@ -588,6 +591,32 @@ public:
default: return 0;
}
}
#ifdef AMD_EXTENSIONS
case EbtFloat16:
switch (type.getMatrixCols()) {
case 2:
switch (type.getMatrixRows()) {
case 2: return GL_FLOAT16_MAT2_AMD;
case 3: return GL_FLOAT16_MAT2x3_AMD;
case 4: return GL_FLOAT16_MAT2x4_AMD;
default: return 0;
}
case 3:
switch (type.getMatrixRows()) {
case 2: return GL_FLOAT16_MAT3x2_AMD;
case 3: return GL_FLOAT16_MAT3_AMD;
case 4: return GL_FLOAT16_MAT3x4_AMD;
default: return 0;
}
case 4:
switch (type.getMatrixRows()) {
case 2: return GL_FLOAT16_MAT4x2_AMD;
case 3: return GL_FLOAT16_MAT4x3_AMD;
case 4: return GL_FLOAT16_MAT4_AMD;
default: return 0;
}
}
#endif
default:
return 0;
}
@@ -596,6 +625,9 @@ public:
switch (type.getBasicType()) {
case EbtFloat: return GL_FLOAT;
case EbtDouble: return GL_DOUBLE;
#ifdef AMD_EXTENSIONS
case EbtFloat16: return GL_FLOAT16_NV;
#endif
case EbtInt: return GL_INT;
case EbtUint: return GL_UNSIGNED_INT;
case EbtInt64: return GL_INT64_ARB;