Commit 7462e81f by John Kessenich

Merge branch 'explicit_types'

parents d2495bcc d7d7c442
...@@ -46,9 +46,7 @@ ...@@ -46,9 +46,7 @@
#include "SpvBuilder.h" #include "SpvBuilder.h"
#ifdef AMD_EXTENSIONS #include "hex_float.h"
#include "hex_float.h"
#endif
#ifndef _WIN32 #ifndef _WIN32
#include <cstdio> #include <cstdio>
...@@ -194,6 +192,9 @@ Id Builder::makeIntegerType(int width, bool hasSign) ...@@ -194,6 +192,9 @@ Id Builder::makeIntegerType(int width, bool hasSign)
// deal with capabilities // deal with capabilities
switch (width) { switch (width) {
case 8:
addCapability(CapabilityInt8);
break;
case 16: case 16:
addCapability(CapabilityInt16); addCapability(CapabilityInt16);
break; break;
...@@ -816,7 +817,6 @@ Id Builder::makeDoubleConstant(double d, bool specConstant) ...@@ -816,7 +817,6 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
return c->getResultId(); return c->getResultId();
} }
#ifdef AMD_EXTENSIONS
Id Builder::makeFloat16Constant(float f16, bool specConstant) Id Builder::makeFloat16Constant(float f16, bool specConstant)
{ {
Op opcode = specConstant ? OpSpecConstant : OpConstant; Op opcode = specConstant ? OpSpecConstant : OpConstant;
...@@ -844,7 +844,6 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant) ...@@ -844,7 +844,6 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
return c->getResultId(); return c->getResultId();
} }
#endif
Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const
{ {
......
// //
// Copyright (C) 2014-2015 LunarG, Inc. // Copyright (C) 2014-2015 LunarG, Inc.
// Copyright (C) 2015-2016 Google, Inc. // Copyright (C) 2015-2016 Google, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -212,19 +213,17 @@ public: ...@@ -212,19 +213,17 @@ public:
// For making new constants (will return old constant if the requested one was already made). // For making new constants (will return old constant if the requested one was already made).
Id makeBoolConstant(bool b, bool specConstant = false); Id makeBoolConstant(bool b, bool specConstant = false);
Id makeInt8Constant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(8), (unsigned)i, specConstant); }
Id makeUint8Constant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(8), u, specConstant); }
Id makeInt16Constant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(16), (unsigned)i, specConstant); }
Id makeUint16Constant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(16), u, specConstant); }
Id makeIntConstant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(32), (unsigned)i, specConstant); } Id makeIntConstant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(32), (unsigned)i, specConstant); }
Id makeUintConstant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(32), u, specConstant); } Id makeUintConstant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(32), u, specConstant); }
Id makeInt64Constant(long long i, bool specConstant = false) { return makeInt64Constant(makeIntType(64), (unsigned long long)i, specConstant); } Id makeInt64Constant(long long i, bool specConstant = false) { return makeInt64Constant(makeIntType(64), (unsigned long long)i, specConstant); }
Id makeUint64Constant(unsigned long long u, bool specConstant = false) { return makeInt64Constant(makeUintType(64), u, specConstant); } Id makeUint64Constant(unsigned long long u, bool specConstant = false) { return makeInt64Constant(makeUintType(64), u, specConstant); }
#ifdef AMD_EXTENSIONS
Id makeInt16Constant(short i, bool specConstant = false) { return makeIntConstant(makeIntType(16), (unsigned)((unsigned short)i), specConstant); }
Id makeUint16Constant(unsigned short u, bool specConstant = false) { return makeIntConstant(makeUintType(16), (unsigned)u, specConstant); }
#endif
Id makeFloatConstant(float f, bool specConstant = false); Id makeFloatConstant(float f, bool specConstant = false);
Id makeDoubleConstant(double d, bool specConstant = false); Id makeDoubleConstant(double d, bool specConstant = false);
#ifdef AMD_EXTENSIONS
Id makeFloat16Constant(float f16, bool specConstant = false); Id makeFloat16Constant(float f16, bool specConstant = false);
#endif
// Turn the array of constants into a proper spv constant of the requested type. // Turn the array of constants into a proper spv constant of the requested type.
Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false); Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false);
...@@ -331,7 +330,7 @@ public: ...@@ -331,7 +330,7 @@ public:
// Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'. // Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'.
// The type of the created vector is a vector of components of the same type as the scalar. // The type of the created vector is a vector of components of the same type as the scalar.
// //
// Note: One of the arguments will change, with the result coming back that way rather than // Note: One of the arguments will change, with the result coming back that way rather than
// through the return value. // through the return value.
void promoteScalar(Decoration precision, Id& left, Id& right); void promoteScalar(Decoration precision, Id& left, Id& right);
......
findFunction.frag
ERROR: 0:39: 'func' : ambiguous best function under implicit type conversion
ERROR: 0:40: 'func' : no matching overloaded function found
ERROR: 0:40: '=' : cannot convert from ' const float' to ' temp int64_t'
ERROR: 0:41: 'func' : no matching overloaded function found
ERROR: 0:41: '=' : cannot convert from ' const float' to ' temp int64_t'
ERROR: 0:44: 'func' : no matching overloaded function found
ERROR: 0:44: '=' : cannot convert from ' const float' to ' temp int64_t'
ERROR: 0:45: 'func' : ambiguous best function under implicit type conversion
ERROR: 8 compilation errors. No code generated.
Shader version: 450
Requested GL_KHX_shader_explicit_arithmetic_types
ERROR: node is still EOpNull!
0:5 Function Definition: func(i81;i161;i161; ( global int64_t)
0:5 Function Parameters:
0:5 'a' ( in int8_t)
0:5 'b' ( in int16_t)
0:5 'c' ( in int16_t)
0:7 Sequence
0:7 Branch: Return with expression
0:7 Convert int16_t to int64 ( temp int64_t)
0:7 inclusive-or ( temp int16_t)
0:7 Convert int8_t to int16_t ( temp int16_t)
0:7 'a' ( in int8_t)
0:7 add ( temp int16_t)
0:7 'b' ( in int16_t)
0:7 'c' ( in int16_t)
0:10 Function Definition: func(i81;i161;i1; ( global int64_t)
0:10 Function Parameters:
0:10 'a' ( in int8_t)
0:10 'b' ( in int16_t)
0:10 'c' ( in int)
0:12 Sequence
0:12 Branch: Return with expression
0:12 Convert int to int64 ( temp int64_t)
0:12 inclusive-or ( temp int)
0:12 Convert int8_t to int ( temp int)
0:12 'a' ( in int8_t)
0:12 subtract ( temp int)
0:12 Convert int16_t to int ( temp int)
0:12 'b' ( in int16_t)
0:12 'c' ( in int)
0:15 Function Definition: func(i1;i1;i1; ( global int64_t)
0:15 Function Parameters:
0:15 'a' ( in int)
0:15 'b' ( in int)
0:15 'c' ( in int)
0:17 Sequence
0:17 Branch: Return with expression
0:17 Convert int to int64 ( temp int64_t)
0:17 add ( temp int)
0:17 divide ( temp int)
0:17 'a' ( in int)
0:17 'b' ( in int)
0:17 'c' ( in int)
0:20 Function Definition: func(f161;f161;f1; ( global int64_t)
0:20 Function Parameters:
0:20 'a' ( in float16_t)
0:20 'b' ( in float16_t)
0:20 'c' ( in float)
0:22 Sequence
0:22 Branch: Return with expression
0:22 Convert float to int64 ( temp int64_t)
0:22 subtract ( temp float)
0:22 Convert float16_t to float ( temp float)
0:22 'a' ( in float16_t)
0:22 component-wise multiply ( temp float)
0:22 Convert float16_t to float ( temp float)
0:22 'b' ( in float16_t)
0:22 'c' ( in float)
0:25 Function Definition: func(f161;i161;f1; ( global int64_t)
0:25 Function Parameters:
0:25 'a' ( in float16_t)
0:25 'b' ( in int16_t)
0:25 'c' ( in float)
0:27 Sequence
0:27 Branch: Return with expression
0:27 Convert float to int64 ( temp int64_t)
0:27 subtract ( temp float)
0:27 Convert float16_t to float ( temp float)
0:27 'a' ( in float16_t)
0:27 component-wise multiply ( temp float)
0:27 Convert int16_t to float ( temp float)
0:27 'b' ( in int16_t)
0:27 'c' ( in float)
0:30 Function Definition: main( ( global void)
0:30 Function Parameters:
0:? Sequence
0:38 Sequence
0:38 move second child to first child ( temp int64_t)
0:38 'b1' ( temp int64_t)
0:38 Function Call: func(i81;i161;i1; ( global int64_t)
0:38 'x' ( temp int8_t)
0:38 'y' ( temp int16_t)
0:38 'z' ( temp int)
0:39 Sequence
0:39 move second child to first child ( temp int64_t)
0:39 'b2' ( temp int64_t)
0:39 Function Call: func(f161;i161;f1; ( global int64_t)
0:39 Convert int16_t to float16_t ( temp float16_t)
0:39 'y' ( temp int16_t)
0:39 'y' ( temp int16_t)
0:39 Convert int to float ( temp float)
0:39 'z' ( temp int)
0:42 Sequence
0:42 move second child to first child ( temp int64_t)
0:42 'b5' ( temp int64_t)
0:42 Function Call: func(f161;i161;f1; ( global int64_t)
0:42 Convert int16_t to float16_t ( temp float16_t)
0:42 'y' ( temp int16_t)
0:42 'y' ( temp int16_t)
0:42 Convert float16_t to float ( temp float)
0:42 'f16' ( temp float16_t)
0:43 Sequence
0:43 move second child to first child ( temp int64_t)
0:43 'b7' ( temp int64_t)
0:43 Function Call: func(f161;f161;f1; ( global int64_t)
0:43 'f16' ( temp float16_t)
0:43 'f16' ( temp float16_t)
0:43 Convert int16_t to float ( temp float)
0:43 'y' ( temp int16_t)
0:45 Sequence
0:45 move second child to first child ( temp int64_t)
0:45 'b9' ( temp int64_t)
0:45 Function Call: func(f161;f161;f1; ( global int64_t)
0:45 'f16' ( temp float16_t)
0:45 Convert int8_t to float16_t ( temp float16_t)
0:45 'x' ( temp int8_t)
0:45 Convert float16_t to float ( temp float)
0:45 'f16' ( temp float16_t)
0:? Linker Objects
Linked fragment stage:
Shader version: 450
Requested GL_KHX_shader_explicit_arithmetic_types
ERROR: node is still EOpNull!
0:10 Function Definition: func(i81;i161;i1; ( global int64_t)
0:10 Function Parameters:
0:10 'a' ( in int8_t)
0:10 'b' ( in int16_t)
0:10 'c' ( in int)
0:12 Sequence
0:12 Branch: Return with expression
0:12 Convert int to int64 ( temp int64_t)
0:12 inclusive-or ( temp int)
0:12 Convert int8_t to int ( temp int)
0:12 'a' ( in int8_t)
0:12 subtract ( temp int)
0:12 Convert int16_t to int ( temp int)
0:12 'b' ( in int16_t)
0:12 'c' ( in int)
0:20 Function Definition: func(f161;f161;f1; ( global int64_t)
0:20 Function Parameters:
0:20 'a' ( in float16_t)
0:20 'b' ( in float16_t)
0:20 'c' ( in float)
0:22 Sequence
0:22 Branch: Return with expression
0:22 Convert float to int64 ( temp int64_t)
0:22 subtract ( temp float)
0:22 Convert float16_t to float ( temp float)
0:22 'a' ( in float16_t)
0:22 component-wise multiply ( temp float)
0:22 Convert float16_t to float ( temp float)
0:22 'b' ( in float16_t)
0:22 'c' ( in float)
0:25 Function Definition: func(f161;i161;f1; ( global int64_t)
0:25 Function Parameters:
0:25 'a' ( in float16_t)
0:25 'b' ( in int16_t)
0:25 'c' ( in float)
0:27 Sequence
0:27 Branch: Return with expression
0:27 Convert float to int64 ( temp int64_t)
0:27 subtract ( temp float)
0:27 Convert float16_t to float ( temp float)
0:27 'a' ( in float16_t)
0:27 component-wise multiply ( temp float)
0:27 Convert int16_t to float ( temp float)
0:27 'b' ( in int16_t)
0:27 'c' ( in float)
0:30 Function Definition: main( ( global void)
0:30 Function Parameters:
0:? Sequence
0:38 Sequence
0:38 move second child to first child ( temp int64_t)
0:38 'b1' ( temp int64_t)
0:38 Function Call: func(i81;i161;i1; ( global int64_t)
0:38 'x' ( temp int8_t)
0:38 'y' ( temp int16_t)
0:38 'z' ( temp int)
0:39 Sequence
0:39 move second child to first child ( temp int64_t)
0:39 'b2' ( temp int64_t)
0:39 Function Call: func(f161;i161;f1; ( global int64_t)
0:39 Convert int16_t to float16_t ( temp float16_t)
0:39 'y' ( temp int16_t)
0:39 'y' ( temp int16_t)
0:39 Convert int to float ( temp float)
0:39 'z' ( temp int)
0:42 Sequence
0:42 move second child to first child ( temp int64_t)
0:42 'b5' ( temp int64_t)
0:42 Function Call: func(f161;i161;f1; ( global int64_t)
0:42 Convert int16_t to float16_t ( temp float16_t)
0:42 'y' ( temp int16_t)
0:42 'y' ( temp int16_t)
0:42 Convert float16_t to float ( temp float)
0:42 'f16' ( temp float16_t)
0:43 Sequence
0:43 move second child to first child ( temp int64_t)
0:43 'b7' ( temp int64_t)
0:43 Function Call: func(f161;f161;f1; ( global int64_t)
0:43 'f16' ( temp float16_t)
0:43 'f16' ( temp float16_t)
0:43 Convert int16_t to float ( temp float)
0:43 'y' ( temp int16_t)
0:45 Sequence
0:45 move second child to first child ( temp int64_t)
0:45 'b9' ( temp int64_t)
0:45 Function Call: func(f161;f161;f1; ( global int64_t)
0:45 'f16' ( temp float16_t)
0:45 Convert int8_t to float16_t ( temp float16_t)
0:45 'x' ( temp int8_t)
0:45 Convert float16_t to float ( temp float)
0:45 'f16' ( temp float16_t)
0:? Linker Objects
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
int64_t func(int8_t a, int16_t b, int16_t c)
{
return int64_t(a | b + c);
}
int64_t func(int8_t a, int16_t b, int32_t c)
{
return int64_t(a | b - c);
}
int64_t func(int32_t a, int32_t b, int32_t c)
{
return int64_t(a / b + c);
}
int64_t func(float16_t a, float16_t b, float32_t c)
{
return int64_t(a - b * c);
}
int64_t func(float16_t a, int16_t b, float32_t c)
{
return int64_t(a - b * c);
}
void main()
{
int8_t x;
int16_t y;
int32_t z;
int64_t w;
float16_t f16;
float64_t f64;
int64_t b1 = func(x, y, z);
int64_t b2 = func(y, y, z); // tie
int64_t b3 = func(y, y, w); // No match
int64_t b4 = func(y, z, f16); // No match
int64_t b5 = func(y, y, f16);
int64_t b7 = func(f16, f16, y);
int64_t b8 = func(f16, f16, f64); // No match
int64_t b9 = func(f16, x, f16); // tie
}
static bool a, b = true; static bool a, b = true;
float4 main() : SV_Position float4 main() : SV_Position
{ {
int r = 0; int r = 0;
r += a + b; r += a + b;
r += a - b; r += a - b;
r += a * b; r += a * b;
r += a / b; r += a / b;
r += a % b; r += a % b;
r += a & b; r += a & b;
r += a | b; r += a | b;
r += a ^ b; r += a ^ b;
r += a << b; r += a << b;
r += a >> b; r += a >> b;
return r; return r;
} }
\ No newline at end of file
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int8: require
#extension GL_KHX_shader_explicit_arithmetic_types_int16: require
#extension GL_KHX_shader_explicit_arithmetic_types_int32: require
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
#extension GL_KHX_shader_explicit_arithmetic_types_float16: require
#extension GL_KHX_shader_explicit_arithmetic_types_float32: require
#extension GL_KHX_shader_explicit_arithmetic_types_float64: require
void main()
{
}
// Single float literals
void literal()
{
const float32_t f32c = 0.000001f;
const f32vec2 f32cv = f32vec2(-0.25F, 0.03f);
f32vec2 f32v;
f32v.x = f32c;
f32v += f32cv;
}
// Block memory layout
struct S
{
float32_t x;
f32vec2 y;
f32vec3 z;
};
layout(column_major, std140) uniform B1
{
float32_t a;
f32vec2 b;
f32vec3 c;
float32_t d[2];
f32mat2x3 e;
f32mat2x3 f[2];
S g;
S h[2];
};
// Specialization constant
layout(constant_id = 100) const float16_t sf16 = 0.125hf;
layout(constant_id = 101) const float32_t sf = 0.25;
layout(constant_id = 102) const float64_t sd = 0.5lf;
const float f16_to_f = float(sf16);
const double f16_to_d = float(sf16);
const float16_t f_to_f16 = float16_t(sf);
const float16_t d_to_f16 = float16_t(sd);
void operators()
{
float32_t f32;
f32vec2 f32v;
f32mat2x2 f32m;
bool b;
// Arithmetic
f32v += f32v;
f32v -= f32v;
f32v *= f32v;
f32v /= f32v;
f32v++;
f32v--;
++f32m;
--f32m;
f32v = -f32v;
f32m = -f32m;
f32 = f32v.x + f32v.y;
f32 = f32v.x - f32v.y;
f32 = f32v.x * f32v.y;
f32 = f32v.x / f32v.y;
// Relational
b = (f32v.x != f32);
b = (f32v.y == f32);
b = (f32v.x > f32);
b = (f32v.y < f32);
b = (f32v.x >= f32);
b = (f32v.y <= f32);
// Vector/matrix operations
f32v = f32v * f32;
f32m = f32m * f32;
f32v = f32m * f32v;
f32v = f32v * f32m;
f32m = f32m * f32m;
}
void typeCast()
{
bvec3 bv;
f32vec3 f32v;
f64vec3 f64v;
i8vec3 i8v;
u8vec3 u8v;
i16vec3 i16v;
u16vec3 u16v;
i32vec3 i32v;
u32vec3 u32v;
i64vec3 i64v;
u64vec3 u64v;
f16vec3 f16v;
f64v = f32v; // float32_t -> float64_t
f32v = f32vec3(bv); // bool -> float32
bv = bvec3(f32v); // float32 -> bool
f32v = f32vec3(f64v); // double -> float32
f64v = f64vec3(f32v); // float32 -> double
f32v = f32vec3(f16v); // float16 -> float32
f16v = f16vec3(f32v); // float32 -> float16
i8v = i8vec3(f32v); // float32 -> int8
i16v = i16vec3(f32v); // float32 -> int16
i32v = i32vec3(f32v); // float32 -> int32
i64v = i64vec3(f32v); // float32 -> int64
u8v = u8vec3(f32v); // float32 -> uint8
u16v = u16vec3(f32v); // float32 -> uint16
u32v = u32vec3(f32v); // float32 -> uint32
u64v = u64vec3(f32v); // float32 -> uint64
}
void builtinAngleTrigFuncs()
{
f32vec4 f32v1, f32v2;
f32v2 = radians(f32v1);
f32v2 = degrees(f32v1);
f32v2 = sin(f32v1);
f32v2 = cos(f32v1);
f32v2 = tan(f32v1);
f32v2 = asin(f32v1);
f32v2 = acos(f32v1);
f32v2 = atan(f32v1, f32v2);
f32v2 = atan(f32v1);
f32v2 = sinh(f32v1);
f32v2 = cosh(f32v1);
f32v2 = tanh(f32v1);
f32v2 = asinh(f32v1);
f32v2 = acosh(f32v1);
f32v2 = atanh(f32v1);
}
void builtinExpFuncs()
{
f32vec2 f32v1, f32v2;
f32v2 = pow(f32v1, f32v2);
f32v2 = exp(f32v1);
f32v2 = log(f32v1);
f32v2 = exp2(f32v1);
f32v2 = log2(f32v1);
f32v2 = sqrt(f32v1);
f32v2 = inversesqrt(f32v1);
}
void builtinCommonFuncs()
{
f32vec3 f32v1, f32v2, f32v3;
float32_t f32;
bool b;
bvec3 bv;
ivec3 iv;
f32v2 = abs(f32v1);
f32v2 = sign(f32v1);
f32v2 = floor(f32v1);
f32v2 = trunc(f32v1);
f32v2 = round(f32v1);
f32v2 = roundEven(f32v1);
f32v2 = ceil(f32v1);
f32v2 = fract(f32v1);
f32v2 = mod(f32v1, f32v2);
f32v2 = mod(f32v1, f32);
f32v3 = modf(f32v1, f32v2);
f32v3 = min(f32v1, f32v2);
f32v3 = min(f32v1, f32);
f32v3 = max(f32v1, f32v2);
f32v3 = max(f32v1, f32);
f32v3 = clamp(f32v1, f32, f32v2.x);
f32v3 = clamp(f32v1, f32v2, f32vec3(f32));
f32v3 = mix(f32v1, f32v2, f32);
f32v3 = mix(f32v1, f32v2, f32v3);
f32v3 = mix(f32v1, f32v2, bv);
f32v3 = step(f32v1, f32v2);
f32v3 = step(f32, f32v3);
f32v3 = smoothstep(f32v1, f32v2, f32v3);
f32v3 = smoothstep(f32, f32v1.x, f32v2);
b = isnan(f32);
bv = isinf(f32v1);
f32v3 = fma(f32v1, f32v2, f32v3);
f32v2 = frexp(f32v1, iv);
f32v2 = ldexp(f32v1, iv);
}
void builtinGeometryFuncs()
{
float32_t f32;
f32vec3 f32v1, f32v2, f32v3;
f32 = length(f32v1);
f32 = distance(f32v1, f32v2);
f32 = dot(f32v1, f32v2);
f32v3 = cross(f32v1, f32v2);
f32v2 = normalize(f32v1);
f32v3 = faceforward(f32v1, f32v2, f32v3);
f32v3 = reflect(f32v1, f32v2);
f32v3 = refract(f32v1, f32v2, f32);
}
void builtinMatrixFuncs()
{
f32mat2x3 f32m1, f32m2, f32m3;
f32mat3x2 f32m4;
f32mat3 f32m5;
f32mat4 f32m6, f32m7;
f32vec3 f32v1;
f32vec2 f32v2;
float32_t f32;
f32m3 = matrixCompMult(f32m1, f32m2);
f32m1 = outerProduct(f32v1, f32v2);
f32m4 = transpose(f32m1);
f32 = determinant(f32m5);
f32m6 = inverse(f32m7);
}
void builtinVecRelFuncs()
{
f32vec3 f32v1, f32v2;
bvec3 bv;
bv = lessThan(f32v1, f32v2);
bv = lessThanEqual(f32v1, f32v2);
bv = greaterThan(f32v1, f32v2);
bv = greaterThanEqual(f32v1, f32v2);
bv = equal(f32v1, f32v2);
bv = notEqual(f32v1, f32v2);
}
in f32vec3 if32v;
void builtinFragProcFuncs()
{
f32vec3 f32v;
// Derivative
f32v.x = dFdx(if32v.x);
f32v.y = dFdy(if32v.y);
f32v.xy = dFdxFine(if32v.xy);
f32v.xy = dFdyFine(if32v.xy);
f32v = dFdxCoarse(if32v);
f32v = dFdxCoarse(if32v);
f32v.x = fwidth(if32v.x);
f32v.xy = fwidthFine(if32v.xy);
f32v = fwidthCoarse(if32v);
// Interpolation
f32v.x = interpolateAtCentroid(if32v.x);
f32v.xy = interpolateAtSample(if32v.xy, 1);
f32v = interpolateAtOffset(if32v, f32vec2(0.5f));
}
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int8: require
#extension GL_KHX_shader_explicit_arithmetic_types_int16: require
#extension GL_KHX_shader_explicit_arithmetic_types_int32: require
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
#extension GL_KHX_shader_explicit_arithmetic_types_float16: require
#extension GL_KHX_shader_explicit_arithmetic_types_float32: require
#extension GL_KHX_shader_explicit_arithmetic_types_float64: require
void main()
{
}
// Single float literals
void literal()
{
const float64_t f64c = 0.000001LF;
const f64vec2 f64cv = f64vec2(-0.25lF, 0.03Lf);
f64vec2 f64v;
f64v.x = f64c;
f64v += f64cv;
}
// Block memory layout
struct S
{
float64_t x;
f64vec2 y;
f64vec3 z;
};
layout(column_major, std140) uniform B1
{
float64_t a;
f64vec2 b;
f64vec3 c;
float64_t d[2];
f64mat2x3 e;
f64mat2x3 f[2];
S g;
S h[2];
};
// Specialization constant
layout(constant_id = 100) const float16_t sf16 = 0.125hf;
layout(constant_id = 101) const float32_t sf = 0.25;
layout(constant_id = 102) const float64_t sd = 0.5lf;
const float f16_to_f = float(sf16);
const double f16_to_d = float(sf16);
const float16_t f_to_f16 = float16_t(sf);
const float16_t d_to_f16 = float16_t(sd);
void operators()
{
float64_t f64;
f64vec2 f64v;
f64mat2x2 f64m;
bool b;
// Arithmetic
f64v += f64v;
f64v -= f64v;
f64v *= f64v;
f64v /= f64v;
f64v++;
f64v--;
++f64m;
--f64m;
f64v = -f64v;
f64m = -f64m;
f64 = f64v.x + f64v.y;
f64 = f64v.x - f64v.y;
f64 = f64v.x * f64v.y;
f64 = f64v.x / f64v.y;
// Relational
b = (f64v.x != f64);
b = (f64v.y == f64);
b = (f64v.x > f64);
b = (f64v.y < f64);
b = (f64v.x >= f64);
b = (f64v.y <= f64);
// Vector/matrix operations
f64v = f64v * f64;
f64m = f64m * f64;
f64v = f64m * f64v;
f64v = f64v * f64m;
f64m = f64m * f64m;
}
void typeCast()
{
bvec3 bv;
f32vec3 f32v;
f64vec3 f64v;
i8vec3 i8v;
u8vec3 u8v;
i16vec3 i16v;
u16vec3 u16v;
i32vec3 i32v;
u32vec3 u32v;
i64vec3 i64v;
u64vec3 u64v;
f16vec3 f16v;
f64v = f64vec3(bv); // bool -> float64
bv = bvec3(f64v); // float64 -> bool
f64v = f64vec3(f16v); // float16 -> float64
f16v = f16vec3(f64v); // float64 -> float16
i8v = i8vec3(f64v); // float64 -> int8
i16v = i16vec3(f64v); // float64 -> int16
i32v = i32vec3(f64v); // float64 -> int32
i64v = i64vec3(f64v); // float64 -> int64
u8v = u8vec3(f64v); // float64 -> uint8
u16v = u16vec3(f64v); // float64 -> uint16
u32v = u32vec3(f64v); // float64 -> uint32
u64v = u64vec3(f64v); // float64 -> uint64
}
void builtinAngleTrigFuncs()
{
f64vec4 f64v1, f64v2;
f64v2 = radians(f64v1);
f64v2 = degrees(f64v1);
f64v2 = sin(f64v1);
f64v2 = cos(f64v1);
f64v2 = tan(f64v1);
f64v2 = asin(f64v1);
f64v2 = acos(f64v1);
f64v2 = atan(f64v1, f64v2);
f64v2 = atan(f64v1);
f64v2 = sinh(f64v1);
f64v2 = cosh(f64v1);
f64v2 = tanh(f64v1);
f64v2 = asinh(f64v1);
f64v2 = acosh(f64v1);
f64v2 = atanh(f64v1);
}
void builtinExpFuncs()
{
f64vec2 f64v1, f64v2;
f64v2 = pow(f64v1, f64v2);
f64v2 = exp(f64v1);
f64v2 = log(f64v1);
f64v2 = exp2(f64v1);
f64v2 = log2(f64v1);
f64v2 = sqrt(f64v1);
f64v2 = inversesqrt(f64v1);
}
void builtinCommonFuncs()
{
f64vec3 f64v1, f64v2, f64v3;
float64_t f64;
bool b;
bvec3 bv;
ivec3 iv;
f64v2 = abs(f64v1);
f64v2 = sign(f64v1);
f64v2 = floor(f64v1);
f64v2 = trunc(f64v1);
f64v2 = round(f64v1);
f64v2 = roundEven(f64v1);
f64v2 = ceil(f64v1);
f64v2 = fract(f64v1);
f64v2 = mod(f64v1, f64v2);
f64v2 = mod(f64v1, f64);
f64v3 = modf(f64v1, f64v2);
f64v3 = min(f64v1, f64v2);
f64v3 = min(f64v1, f64);
f64v3 = max(f64v1, f64v2);
f64v3 = max(f64v1, f64);
f64v3 = clamp(f64v1, f64, f64v2.x);
f64v3 = clamp(f64v1, f64v2, f64vec3(f64));
f64v3 = mix(f64v1, f64v2, f64);
f64v3 = mix(f64v1, f64v2, f64v3);
f64v3 = mix(f64v1, f64v2, bv);
f64v3 = step(f64v1, f64v2);
f64v3 = step(f64, f64v3);
f64v3 = smoothstep(f64v1, f64v2, f64v3);
f64v3 = smoothstep(f64, f64v1.x, f64v2);
b = isnan(f64);
bv = isinf(f64v1);
f64v3 = fma(f64v1, f64v2, f64v3);
f64v2 = frexp(f64v1, iv);
f64v2 = ldexp(f64v1, iv);
}
void builtinGeometryFuncs()
{
float64_t f64;
f64vec3 f64v1, f64v2, f64v3;
f64 = length(f64v1);
f64 = distance(f64v1, f64v2);
f64 = dot(f64v1, f64v2);
f64v3 = cross(f64v1, f64v2);
f64v2 = normalize(f64v1);
f64v3 = faceforward(f64v1, f64v2, f64v3);
f64v3 = reflect(f64v1, f64v2);
f64v3 = refract(f64v1, f64v2, f64);
}
void builtinMatrixFuncs()
{
f64mat2x3 f64m1, f64m2, f64m3;
f64mat3x2 f64m4;
f64mat3 f64m5;
f64mat4 f64m6, f64m7;
f64vec3 f64v1;
f64vec2 f64v2;
float64_t f64;
f64m3 = matrixCompMult(f64m1, f64m2);
f64m1 = outerProduct(f64v1, f64v2);
f64m4 = transpose(f64m1);
f64 = determinant(f64m5);
f64m6 = inverse(f64m7);
}
void builtinVecRelFuncs()
{
f64vec3 f64v1, f64v2;
bvec3 bv;
bv = lessThan(f64v1, f64v2);
bv = lessThanEqual(f64v1, f64v2);
bv = greaterThan(f64v1, f64v2);
bv = greaterThanEqual(f64v1, f64v2);
bv = equal(f64v1, f64v2);
bv = notEqual(f64v1, f64v2);
}
in flat f64vec3 if64v;
void builtinFragProcFuncs()
{
f64vec3 f64v;
// Derivative
f64v.x = dFdx(if64v.x);
f64v.y = dFdy(if64v.y);
f64v.xy = dFdxFine(if64v.xy);
f64v.xy = dFdyFine(if64v.xy);
f64v = dFdxCoarse(if64v);
f64v = dFdxCoarse(if64v);
f64v.x = fwidth(if64v.x);
f64v.xy = fwidthFine(if64v.xy);
f64v = fwidthCoarse(if64v);
// Interpolation
f64v.x = interpolateAtCentroid(if64v.x);
f64v.xy = interpolateAtSample(if64v.xy, 1);
f64v = interpolateAtOffset(if64v, f64vec2(0.5f));
}
#version 450 core
#extension GL_ARB_gpu_shader_int64: enable
#extension GL_AMD_gpu_shader_half_float: enable
#extension GL_AMD_gpu_shader_int16: enable
layout(binding = 0) uniform Uniforms
{
uint i;
};
// int16/uint16 in block
layout(std140, binding = 1) uniform Block
{
i16vec3 i16v;
uint16_t u16;
} block;
// int16/uint16 for input
layout(location = 0) in flat u16vec3 iu16v;
layout(location = 1) in flat int16_t ii16;
void literal()
{
const int16_t i16c[3] =
{
0x111S, // Hex
-2s, // Dec
0400s, // Oct
};
const uint16_t u16c[] =
{
0xFFFFus, // Hex
65535US, // Dec
0177777us, // Oct
};
uint16_t u16 = i16c[i] + u16c[i];
}
void operators()
{
u16vec3 u16v;
int16_t i16;
uint16_t u16;
int i;
uint u;
bool b;
// Unary
u16v++;
i16--;
++i16;
--u16v;
u16v = ~u16v;
i16 = +i16;
u16v = -u16v;
// Arithmetic
u16 += i16;
u16v -= u16v;
i16 *= i16;
u16v /= u16v;
u16v %= i16;
u16v = u16v + u16v;
u16 = i16 - u16;
u16v = u16v * i16;
i16 = i16 * i16;
i16 = i16 % i16;
// Shift
u16v <<= i16;
i16 >>= u16v.y;
i16 = i16 << u16v.z;
u16v = u16v << i16;
// Relational
b = (u16v.x != i16);
b = (i16 == u16v.x);
b = (u16v.x > u16v.y);
b = (i16 < u);
b = (u16v.y >= u16v.x);
b = (i16 <= i);
// Bitwise
u16v |= i16;
u16 = i16 | u16;
i16 &= i16;
u16v = u16v & u16v;
u16v ^= i16;
u16v = u16v ^ i16;
}
void typeCast()
{
bvec2 bv;
ivec2 iv;
uvec2 uv;
vec2 fv;
dvec2 dv;
f16vec2 f16v;
i64vec2 i64v;
u64vec2 u64v;
i16vec2 i16v;
u16vec2 u16v;
i16v = i16vec2(bv); // bool -> int16
u16v = u16vec2(bv); // bool -> uint16
bv = bvec2(i16v); // int16 -> bool
bv = bvec2(u16v); // uint16 -> bool
i16v = i16vec2(iv); // int -> int16
u16v = u16vec2(iv); // int -> uint16
iv = i16v; // int16 -> int
iv = ivec2(u16v); // uint16 -> int
i16v = i16vec2(uv); // uint -> int16
u16v = u16vec2(uv); // uint -> uint16
uv = i16v; // int16 -> uint
uv = u16v; // uint16 -> uint
i16v = i16vec2(fv); // float -> int16
u16v = u16vec2(fv); // float -> uint16
fv = i16v; // int16 -> float
fv = u16v; // uint16 -> float
i16v = i16vec2(dv); // double -> int16
u16v = u16vec2(dv); // double -> uint16
dv = i16v; // int16 -> double
dv = u16v; // uint16 -> double
i16v = i16vec2(f16v); // float16 -> int16
u16v = u16vec2(f16v); // float16 -> uint16
f16v = i16v; // int16 -> float16
f16v = u16v; // uint16 -> float16
i16v = i16vec2(i64v); // int64 -> int16
u16v = u16vec2(i64v); // int64 -> uint16
i64v = i16v; // int16 -> int64
i64v = i64vec2(u16v); // uint16 -> int64
i16v = i16vec2(u64v); // uint64 -> int16
u16v = u16vec2(u64v); // uint64 -> uint16
u64v = i16v; // int16 -> uint64
u64v = u16v; // uint16 -> uint64
i16v = i16vec2(u16v); // uint16 -> int16
u16v = i16v; // int16 -> uint16
}
void builtinFuncs()
{
i16vec2 i16v;
u16vec3 u16v;
f16vec3 f16v;
bvec3 bv;
int16_t i16;
uint16_t u16;
// abs()
i16v = abs(i16v);
// sign()
i16v = sign(i16v);
// min()
i16v = min(i16v, i16);
i16v = min(i16v, i16vec2(-1s));
u16v = min(u16v, u16);
u16v = min(u16v, u16vec3(0us));
// max()
i16v = max(i16v, i16);
i16v = max(i16v, i16vec2(-1s));
u16v = max(u16v, u16);
u16v = max(u16v, u16vec3(0us));
// clamp()
i16v = clamp(i16v, -i16, i16);
i16v = clamp(i16v, -i16v, i16v);
u16v = clamp(u16v, -u16, u16);
u16v = clamp(u16v, -u16v, u16v);
// mix()
i16 = mix(i16v.x, i16v.y, true);
i16v = mix(i16vec2(i16), i16vec2(-i16), bvec2(false));
u16 = mix(u16v.x, u16v.y, true);
u16v = mix(u16vec3(u16), u16vec3(-u16), bvec3(false));
// frexp()
i16vec3 exp;
f16v = frexp(f16v, exp);
// ldexp()
f16v = ldexp(f16v, exp);
// float16BitsToInt16()
i16v = float16BitsToInt16(f16v.xy);
// float16BitsToUint16()
u16v.x = float16BitsToUint16(f16v.z);
// int16BitsToFloat16()
f16v.xy = int16BitsToFloat16(i16v);
// uint16BitsToFloat16()
f16v = uint16BitsToFloat16(u16v);
// packInt2x16()
int packi = packInt2x16(i16v);
// unpackInt2x16()
i16v = unpackInt2x16(packi);
// packUint2x16()
uint packu = packUint2x16(u16v.xy);
// unpackUint2x16()
u16v.xy = unpackUint2x16(packu);
// packInt4x16()
int64_t packi64 = packInt4x16(i16vec4(i16));
// unpackInt4x16()
i16v = unpackInt4x16(packi64).xy;
// packUint4x16()
uint64_t packu64 = packUint4x16(u16vec4(u16));
// unpackUint4x16()
u16v = unpackUint4x16(packu64).xyz;
// lessThan()
bv = lessThan(u16v, u16vec3(u16));
bv.xy = lessThan(i16v, i16vec2(i16));
// lessThanEqual()
bv = lessThanEqual(u16v, u16vec3(u16));
bv.xy = lessThanEqual(i16v, i16vec2(i16));
// greaterThan()
bv = greaterThan(u16v, u16vec3(u16));
bv.xy = greaterThan(i16v, i16vec2(i16));
// greaterThanEqual()
bv = greaterThanEqual(u16v, u16vec3(u16));
bv.xy = greaterThanEqual(i16v, i16vec2(i16));
// equal()
bv = equal(u16v, u16vec3(u16));
bv.xy = equal(i16v, i16vec2(i16));
// notEqual()
bv = notEqual(u16v, u16vec3(u16));
bv.xy = notEqual(i16v, i16vec2(i16));
}
// Type conversion for specialization constant
layout(constant_id = 100) const int64_t si64 = -10L;
layout(constant_id = 101) const uint64_t su64 = 20UL;
layout(constant_id = 102) const int si = -5;
layout(constant_id = 103) const uint su = 4;
layout(constant_id = 104) const bool sb = true;
layout(constant_id = 105) const int16_t si16 = -5S;
layout(constant_id = 106) const uint16_t su16 = 4US;
// bool <-> int16/uint16
const bool i16_to_b = bool(si16);
const bool u16_to_b = bool(su16);
const int16_t b_to_i16 = int16_t(sb);
const uint16_t b_to_u16 = uint16_t(sb);
// int <-> int16/uint16
const int i16_to_i = int(si16);
const int u16_to_i = int(su16);
const int16_t i_to_i16 = int16_t(si);
const uint16_t i_to_u16 = uint16_t(si);
// uint <-> int16/uint16
const uint i16_to_u = uint(si16);
const uint u16_to_u = uint(su16);
const int16_t u_to_i16 = int16_t(su);
const uint16_t u_to_u16 = uint16_t(su);
// int64 <-> int16/uint16
const int64_t i16_to_i64 = int64_t(si16);
const int64_t u16_to_i64 = int64_t(su16);
const int16_t i64_to_i16 = int16_t(si64);
const uint16_t i64_to_u16 = uint16_t(si64);
// uint64 <-> int16/uint16
const uint64_t i16_to_u64 = uint64_t(si16);
const uint64_t u16_to_u64 = uint64_t(su16);
const int16_t u64_to_i16 = int16_t(su64);
const uint16_t u64_to_u16 = uint16_t(su64);
// int16 <-> uint16
const uint16_t i16_to_u16 = uint16_t(si16);
const int16_t u16_to_i16 = int16_t(su16);
void main()
{
literal();
operators();
typeCast();
builtinFuncs();
}
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int8: require
#extension GL_KHX_shader_explicit_arithmetic_types_int16: require
#extension GL_KHX_shader_explicit_arithmetic_types_int32: require
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
#extension GL_KHX_shader_explicit_arithmetic_types_float16: require
#extension GL_KHX_shader_explicit_arithmetic_types_float32: require
#extension GL_KHX_shader_explicit_arithmetic_types_float64: require
layout(binding = 0) uniform Uniforms
{
uint index;
};
layout(std140, binding = 1) uniform Block
{
int32_t i32;
i32vec2 i32v2;
i32vec3 i32v3;
i32vec4 i32v4;
uint32_t u32;
u32vec2 u32v2;
u32vec3 u32v3;
u32vec4 u32v4;
} block;
void main()
{
}
void literal()
{
const int32_t i32Const[3] =
{
-0x11111111, // Hex
-1, // Dec
04000000000, // Oct
};
int32_t i32 = i32Const[index];
const uint32_t u32Const[] =
{
0xFFFFFFFF, // Hex
4294967295, // Dec
017777777777, // Oct
};
uint32_t u32 = u32Const[index];
}
void typeCast32()
{
i8vec2 i8v;
u8vec2 u8v;
i16vec2 i16v;
u16vec2 u16v;
i32vec2 i32v;
u32vec2 u32v;
i64vec2 i64v;
u64vec2 u64v;
f16vec2 f16v;
f32vec2 f32v;
f64vec2 f64v;
bvec2 bv;
u32v = i32v; // int32_t -> uint32_t
i64v = i32v; // int32_t -> int64_t
u64v = i32v; // int32_t -> uint64_t
i64v = u32v; // uint32_t -> int64_t
u64v = u32v; // uint32_t -> uint64_t
f32v = i32v; // int32_t -> float32_t
f64v = i32v; // int32_t -> float64_t
f32v = u32v; // uint32_t -> float32_t
f64v = u32v; // uint32_t -> float64_t
i8v = i8vec2(i32v); // int32_t -> int8_t
i8v = i8vec2(u32v); // uint32_t -> int8_t
i16v = i16vec2(i32v); // int32_t -> int16_t
i16v = i16vec2(u32v); // uint32_t -> int16_t
i32v = i32vec2(i32v); // int32_t -> int32_t
i32v = i32vec2(u32v); // uint32_t -> int32_t
i64v = i64vec2(i32v); // int32_t -> int64_t
i64v = i64vec2(u32v); // uint32_t -> int64_t
u8v = u8vec2(i32v); // int32_t -> uint8_t
u8v = u8vec2(u32v); // uint32_t -> uint8_t
u16v = u16vec2(i32v); // int32_t -> uint16_t
u16v = u16vec2(u32v); // uint32_t -> uint16_t
u32v = u32vec2(i32v); // int32_t -> uint32_t
u32v = u32vec2(u32v); // uint32_t -> uint32_t
u64v = u64vec2(i32v); // int32_t -> uint64_t
u64v = u64vec2(u32v); // uint32_t -> uint64_t
f16v = f16vec2(i32v); // int32_t -> float16_t
f32v = f32vec2(i32v); // int32_t -> float32_t
f64v = f64vec2(i32v); // int32_t -> float64_t
f16v = f16vec2(u32v); // uint32_t -> float16_t
f32v = f32vec2(u32v); // uint32_t -> float32_t
f64v = f64vec2(u32v); // uint32_t -> float64_t
i32v = i32vec2(bv); // bool -> int32
u32v = u32vec2(bv); // bool -> uint32
bv = bvec2(i32v); // int32 -> bool
bv = bvec2(u32v); // uint32 -> bool
}
void operators()
{
u32vec3 u32v;
int32_t i32;
uvec3 uv;
int32_t i;
int64_t i64;
bool b;
// Unary
u32v++;
i32--;
++i32;
--u32v;
u32v = ~u32v;
i32 = +i32;
u32v = -u32v;
// Arithmetic
i32 += i32;
u32v -= u32v;
i *= i32;
uv /= u32v;
uv %= i32;
uv = u32v + uv;
i64 = i32 - i64;
uv = u32v * uv;
i64 = i32 * i64;
i = i32 % i;
// Shift
u32v <<= i32;
i32 >>= u32v.y;
i64 = i64 << u32v.z;
uv = u32v << i;
// Relational
b = (u32v.x != i32);
b = (i32 == u32v.x);
b = (u32v.x > uv.y);
b = (i32 < i);
b = (u32v.y >= uv.x);
b = (i32 <= i);
// Bitwise
uv |= i32;
i = i32 | i;
i64 &= i32;
uv = u32v & uv;
uv ^= i32;
u32v = u32v ^ i32;
}
void builtinFuncs()
{
i32vec2 i32v;
i32vec4 i32v4;
u32vec3 u32v;
u32vec2 u32v2;
u32vec4 u32v4;
bvec3 bv;
int32_t i32;
uint32_t u32;
int64_t i64;
uint64_t u64;
i8vec4 i8v4;
u8vec4 u8v4;
i16vec2 i16v2;
u16vec2 u16v2;
// abs()
i32v = abs(i32v);
// sign()
i32 = sign(i32);
// min()
i32v = min(i32v, i32);
i32v = min(i32v, i32vec2(-1));
u32v = min(u32v, u32);
u32v = min(u32v, u32vec3(0));
// max()
i32v = max(i32v, i32);
i32v = max(i32v, i32vec2(-1));
u32v = max(u32v, u32);
u32v = max(u32v, u32vec3(0));
// clamp()
i32v = clamp(i32v, -i32, i32);
i32v = clamp(i32v, -i32v, i32v);
u32v = clamp(u32v, -u32, u32);
u32v = clamp(u32v, -u32v, u32v);
// mix()
i32 = mix(i32v.x, i32v.y, true);
i32v = mix(i32vec2(i32), i32vec2(-i32), bvec2(false));
u32 = mix(u32v.x, u32v.y, true);
u32v = mix(u32vec3(u32), u32vec3(-u32), bvec3(false));
//pack
i32 = pack32(i8v4);
i32 = pack32(i16v2);
u32 = pack32(u8v4);
u32 = pack32(u16v2);
i32v = unpack32(i64);
u32v2 = unpack32(u64);
// lessThan()
bv = lessThan(u32v, u32vec3(u32));
bv.xy = lessThan(i32v, i32vec2(i32));
// lessThanEqual()
bv = lessThanEqual(u32v, u32vec3(u32));
bv.xy = lessThanEqual(i32v, i32vec2(i32));
// greaterThan()
bv = greaterThan(u32v, u32vec3(u32));
bv.xy = greaterThan(i32v, i32vec2(i32));
// greaterThanEqual()
bv = greaterThanEqual(u32v, u32vec3(u32));
bv.xy = greaterThanEqual(i32v, i32vec2(i32));
// equal()
bv = equal(u32v, u32vec3(u32));
bv.xy = equal(i32v, i32vec2(i32));
// notEqual()
bv = notEqual(u32v, u32vec3(u32));
bv.xy = notEqual(i32v, i32vec2(i32));
}
// Type conversion for specialization constant
layout(constant_id = 100) const int32_t si32 = -10;
layout(constant_id = 101) const uint32_t su32 = 20U;
layout(constant_id = 102) const int si = -5;
layout(constant_id = 103) const uint su = 4;
layout(constant_id = 104) const bool sb = true;
#define UINT32_MAX 4294967295u
uint32_t u32Max = UINT32_MAX;
#version 450
#extension GL_KHX_shader_explicit_arithmetic_types: enable
#extension GL_KHX_shader_explicit_arithmetic_types_int8: require
#extension GL_KHX_shader_explicit_arithmetic_types_int16: require
#extension GL_KHX_shader_explicit_arithmetic_types_int32: require
#extension GL_KHX_shader_explicit_arithmetic_types_int64: require
#extension GL_KHX_shader_explicit_arithmetic_types_float16: require
#extension GL_KHX_shader_explicit_arithmetic_types_float32: require
#extension GL_KHX_shader_explicit_arithmetic_types_float64: require
layout(binding = 0) uniform Uniforms
{
uint index;
};
layout(std140, binding = 1) uniform Block
{
int8_t i8;
i8vec2 i8v2;
i8vec3 i8v3;
i8vec4 i8v4;
uint8_t u8;
u8vec2 u8v2;
u8vec3 u8v3;
u8vec4 u8v4;
} block;
void main()
{
}
void literal()
{
const int8_t i8Const[3] =
{
int8_t(-0x11), // Hex
int8_t(-1), // Dec
int8_t(0400), // Oct
};
int8_t i8 = i8Const[index];
const uint8_t u8Const[] =
{
uint8_t(0xFF), // Hex
uint8_t(255), // Dec
uint8_t(0177), // Oct
};
uint8_t u8 = u8Const[index];
}
void typeCast8()
{
i8vec2 i8v;
u8vec2 u8v;
i16vec2 i16v;
u16vec2 u16v;
i32vec2 i32v;
u32vec2 u32v;
i64vec2 i64v;
u64vec2 u64v;
f16vec2 f16v;
f32vec2 f32v;
f64vec2 f64v;
bvec2 bv;
u8v = i8v; // int8_t -> uint8_t
i16v = i8v; // int8_t -> int16_t
i16v = u8v; // uint8_t -> int16_t
i32v = i8v; // int8_t -> int32_t
i32v = u8v; // uint8_t -> int32_t
u32v = i8v; // int8_t -> uint32_t
i64v = i8v; // int8_t -> int64_t
u64v = i8v; // int8_t -> uint64_t
u32v = u8v; // uint8_t -> uint32_t
i64v = u8v; // uint8_t -> int64_t
u64v = u8v; // uint8_t -> uint64_t
f16v = i8v; // int8_t -> float16_t
f32v = i8v; // int8_t -> float32_t
f64v = i8v; // int8_t -> float64_t
f16v = u8v; // uint8_t -> float16_t
f32v = u8v; // uint8_t -> float32_t
f64v = u8v; // uint8_t -> float64_t
i8v = i8vec2(u8v); // uint8_t -> int8_t
i16v = i16vec2(i8v); // int8_t -> int16_t
i16v = i16vec2(u8v); // uint8_t -> int16_t
i32v = i32vec2(i8v); // int8_t -> int32_t
i32v = i32vec2(u8v); // uint8_t -> int32_t
i64v = i64vec2(i8v); // int8_t -> int64_t
u64v = i64vec2(i8v); // int8_t -> uint64_t
u16v = u16vec2(i8v); // int8_t -> uint16_t
u16v = u16vec2(u8v); // uint8_t -> uint16_t
u32v = u32vec2(u8v); // uint8_t -> uint32_t
i64v = i64vec2(u8v); // uint8_t -> int64_t
u64v = i64vec2(u8v); // uint8_t -> uint64_t
f16v = f16vec2(i8v); // int8_t -> float16_t
f32v = f32vec2(i8v); // int8_t -> float32_t
f64v = f64vec2(i8v); // int8_t -> float64_t
f16v = f16vec2(u8v); // uint8_t -> float16_t
f32v = f32vec2(u8v); // uint8_t -> float32_t
f64v = f64vec2(u8v); // uint8_t -> float64_t
i8v = i8vec2(bv); // bool -> int8
u8v = u8vec2(bv); // bool -> uint8
bv = bvec2(i8v); // int8 -> bool
bv = bvec2(u8v); // uint8 -> bool
}
void operators()
{
u8vec3 u8v;
int8_t i8;
uvec3 uv;
int32_t i;
int16_t i16;
bool b;
// Unary
u8v++;
i8--;
++i8;
--u8v;
u8v = ~u8v;
i8 = +i8;
u8v = -u8v;
// Arithmetic
i8 += i8;
u8v -= u8v;
i *= i8;
uv /= u8v;
uv %= i8;
uv = u8v + uv;
i16 = i8 - i16;
uv = u8v * uv;
i16 = i8 * i16;
i = i8 % i;
// Shift
u8v <<= i8;
i8 >>= u8v.y;
i8 = i8 << u8v.z;
u8v = u8v << i8;
// Relational
b = (u8v.x != i8);
b = (i8 == u8v.x);
b = (u8v.x > uv.y);
b = (i8 < i);
b = (u8v.y >= uv.x);
b = (i8 <= i);
// Bitwise
uv |= i8;
i = i8 | i;
i16 &= i8;
uv = u8v & uv;
uv ^= i8;
u8v = u8v ^ i8;
}
void builtinFuncs()
{
i8vec2 i8v;
i8vec4 i8v4;
u8vec3 u8v;
u8vec2 u8v2;
u8vec4 u8v4;
bvec3 bv;
int16_t i16;
int32_t i32;
uint16_t u16;
uint32_t u32;
int8_t i8;
uint8_t u8;
// abs()
i8v = abs(i8v);
// sign()
i8 = sign(i8);
// min()
i8v = min(i8v, i8);
i8v = min(i8v, i8vec2(-1));
u8v = min(u8v, u8);
u8v = min(u8v, u8vec3(0));
// max()
i8v = max(i8v, i8);
i8v = max(i8v, i8vec2(-1));
u8v = max(u8v, u8);
u8v = max(u8v, u8vec3(0));
// clamp()
i8v = clamp(i8v, -i8, i8);
i8v = clamp(i8v, -i8v, i8v);
u8v = clamp(u8v, -u8, u8);
u8v = clamp(u8v, -u8v, u8v);
// mix()
i8 = mix(i8v.x, i8v.y, true);
i8v = mix(i8vec2(i8), i8vec2(-i8), bvec2(false));
u8 = mix(u8v.x, u8v.y, true);
u8v = mix(u8vec3(u8), u8vec3(-u8), bvec3(false));
//pack
i16 = pack16(i8v);
i32 = pack32(i8v4);
u16 = pack16(u8v2);
u32 = pack32(u8v4);
i8v = unpack8(i16);
i8v4 = unpack8(i32);
u8v2 = unpack8(u16);
u8v4 = unpack8(u32);
// lessThan()
bv = lessThan(u8v, u8vec3(u8));
bv.xy = lessThan(i8v, i8vec2(i8));
// lessThanEqual()
bv = lessThanEqual(u8v, u8vec3(u8));
bv.xy = lessThanEqual(i8v, i8vec2(i8));
// greaterThan()
bv = greaterThan(u8v, u8vec3(u8));
bv.xy = greaterThan(i8v, i8vec2(i8));
// greaterThanEqual()
bv = greaterThanEqual(u8v, u8vec3(u8));
bv.xy = greaterThanEqual(i8v, i8vec2(i8));
// equal()
bv = equal(u8v, u8vec3(u8));
bv.xy = equal(i8v, i8vec2(i8));
// notEqual()
bv = notEqual(u8v, u8vec3(u8));
bv.xy = notEqual(i8v, i8vec2(i8));
}
// Type conversion for specialization constant
layout(constant_id = 100) const int8_t si8 = int8_t(-10);
layout(constant_id = 101) const uint8_t su8 = uint8_t(20);
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc. // Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -46,17 +47,15 @@ enum TBasicType { ...@@ -46,17 +47,15 @@ enum TBasicType {
EbtVoid, EbtVoid,
EbtFloat, EbtFloat,
EbtDouble, EbtDouble,
#ifdef AMD_EXTENSIONS
EbtFloat16, EbtFloat16,
#endif EbtInt8,
EbtUint8,
EbtInt16,
EbtUint16,
EbtInt, EbtInt,
EbtUint, EbtUint,
EbtInt64, EbtInt64,
EbtUint64, EbtUint64,
#ifdef AMD_EXTENSIONS
EbtInt16,
EbtUint16,
#endif
EbtBool, EbtBool,
EbtAtomicUint, EbtAtomicUint,
EbtSampler, EbtSampler,
...@@ -227,7 +226,7 @@ enum TBuiltInVariable { ...@@ -227,7 +226,7 @@ enum TBuiltInVariable {
EbvSecondaryViewportMaskNV, EbvSecondaryViewportMaskNV,
EbvPositionPerViewNV, EbvPositionPerViewNV,
EbvViewportMaskPerViewNV, EbvViewportMaskPerViewNV,
#endif #endif
// HLSL built-ins that live only temporarily, until they get remapped // HLSL built-ins that live only temporarily, until they get remapped
// to one of the above. // to one of the above.
...@@ -364,7 +363,7 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v) ...@@ -364,7 +363,7 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
case EbvPositionPerViewNV: return "PositionPerViewNV"; case EbvPositionPerViewNV: return "PositionPerViewNV";
case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
#endif #endif
default: return "unknown built-in variable"; default: return "unknown built-in variable";
} }
} }
...@@ -380,7 +379,7 @@ enum TPrecisionQualifier { ...@@ -380,7 +379,7 @@ enum TPrecisionQualifier {
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p) __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
{ {
switch(p) { switch (p) {
case EpqNone: return ""; break; case EpqNone: return ""; break;
case EpqLow: return "lowp"; break; case EpqLow: return "lowp"; break;
case EpqMedium: return "mediump"; break; case EpqMedium: return "mediump"; break;
...@@ -389,6 +388,75 @@ __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p) ...@@ -389,6 +388,75 @@ __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
} }
} }
__inline bool isTypeSignedInt(TBasicType type)
{
switch (type) {
case EbtInt8:
case EbtInt16:
case EbtInt:
case EbtInt64:
return true;
default:
return false;
}
}
__inline bool isTypeUnsignedInt(TBasicType type)
{
switch (type) {
case EbtUint8:
case EbtUint16:
case EbtUint:
case EbtUint64:
return true;
default:
return false;
}
}
__inline bool isTypeInt(TBasicType type)
{
return isTypeSignedInt(type) || isTypeUnsignedInt(type);
}
__inline bool isTypeFloat(TBasicType type)
{
switch (type) {
case EbtFloat:
case EbtDouble:
case EbtFloat16:
return true;
default:
return false;
}
}
__inline int getTypeRank(TBasicType type) {
int res = -1;
switch(type) {
case EbtInt8:
case EbtUint8:
res = 0;
break;
case EbtInt16:
case EbtUint16:
res = 1;
break;
case EbtInt:
case EbtUint:
res = 2;
break;
case EbtInt64:
case EbtUint64:
res = 3;
break;
default:
assert(false);
break;
}
return res;
}
} // end namespace glslang } // end namespace glslang
#endif // _BASICTYPES_INCLUDED_ #endif // _BASICTYPES_INCLUDED_
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2016 LunarG, Inc. // Copyright (C) 2012-2016 LunarG, Inc.
// Copyright (C) 2015-2016 Google, Inc. // Copyright (C) 2015-2016 Google, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -204,9 +205,15 @@ struct TSampler { // misnomer now; includes images, textures without sampler, ...@@ -204,9 +205,15 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
} }
switch (type) { switch (type) {
case EbtFloat: break; case EbtFloat: break;
case EbtInt: s.append("i"); break; case EbtInt8: s.append("i8"); break;
case EbtUint: s.append("u"); break; case EbtUint16: s.append("u8"); break;
case EbtInt16: s.append("i16"); break;
case EbtUint8: s.append("u16"); 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 default: break; // some compilers want this
} }
if (image) { if (image) {
...@@ -1358,11 +1365,7 @@ public: ...@@ -1358,11 +1365,7 @@ public:
virtual bool isImplicitlySizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; } virtual bool isImplicitlySizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; }
virtual bool isRuntimeSizedArray() 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; } virtual bool isStruct() const { return structure != nullptr; }
#ifdef AMD_EXTENSIONS
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; } virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; }
#else
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble; }
#endif
virtual bool isIntegerDomain() const virtual bool isIntegerDomain() const
{ {
switch (basicType) { switch (basicType) {
...@@ -1370,10 +1373,8 @@ public: ...@@ -1370,10 +1373,8 @@ public:
case EbtUint: case EbtUint:
case EbtInt64: case EbtInt64:
case EbtUint64: case EbtUint64:
#ifdef AMD_EXTENSIONS
case EbtInt16: case EbtInt16:
case EbtUint16: case EbtUint16:
#endif
case EbtAtomicUint: case EbtAtomicUint:
return true; return true;
default: default:
...@@ -1389,7 +1390,7 @@ public: ...@@ -1389,7 +1390,7 @@ public:
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); } virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
// return true if this type contains any subtype which satisfies the given predicate. // return true if this type contains any subtype which satisfies the given predicate.
template <typename P> template <typename P>
bool contains(P predicate) const bool contains(P predicate) const
{ {
if (predicate(this)) if (predicate(this))
...@@ -1442,17 +1443,15 @@ public: ...@@ -1442,17 +1443,15 @@ public:
case EbtVoid: case EbtVoid:
case EbtFloat: case EbtFloat:
case EbtDouble: case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16: case EbtFloat16:
#endif case EbtInt8:
case EbtUint8:
case EbtInt16:
case EbtUint16:
case EbtInt: case EbtInt:
case EbtUint: case EbtUint:
case EbtInt64: case EbtInt64:
case EbtUint64: case EbtUint64:
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
#endif
case EbtBool: case EbtBool:
return true; return true;
default: default:
...@@ -1529,17 +1528,15 @@ public: ...@@ -1529,17 +1528,15 @@ public:
case EbtVoid: return "void"; case EbtVoid: return "void";
case EbtFloat: return "float"; case EbtFloat: return "float";
case EbtDouble: return "double"; case EbtDouble: return "double";
#ifdef AMD_EXTENSIONS
case EbtFloat16: return "float16_t"; case EbtFloat16: return "float16_t";
#endif case EbtInt8: return "int8_t";
case EbtUint8: return "uint8_t";
case EbtInt16: return "int16_t";
case EbtUint16: return "uint16_t";
case EbtInt: return "int"; case EbtInt: return "int";
case EbtUint: return "uint"; case EbtUint: return "uint";
case EbtInt64: return "int64_t"; case EbtInt64: return "int64_t";
case EbtUint64: return "uint64_t"; case EbtUint64: return "uint64_t";
#ifdef AMD_EXTENSIONS
case EbtInt16: return "int16_t";
case EbtUint16: return "uint16_t";
#endif
case EbtBool: return "bool"; case EbtBool: return "bool";
case EbtAtomicUint: return "atomic_uint"; case EbtAtomicUint: return "atomic_uint";
case EbtSampler: return "sampler/image"; case EbtSampler: return "sampler/image";
......
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2016 LunarG, Inc. // Copyright (C) 2012-2016 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -84,100 +85,189 @@ enum TOperator { ...@@ -84,100 +85,189 @@ enum TOperator {
EOpPreIncrement, EOpPreIncrement,
EOpPreDecrement, EOpPreDecrement,
// (u)int* -> bool
EOpConvInt8ToBool,
EOpConvUint8ToBool,
EOpConvInt16ToBool,
EOpConvUint16ToBool,
EOpConvIntToBool, EOpConvIntToBool,
EOpConvUintToBool, EOpConvUintToBool,
EOpConvFloatToBool,
EOpConvDoubleToBool,
EOpConvInt64ToBool, EOpConvInt64ToBool,
EOpConvUint64ToBool, EOpConvUint64ToBool,
EOpConvBoolToFloat,
EOpConvIntToFloat, // float* -> bool
EOpConvUintToFloat, EOpConvFloat16ToBool,
EOpConvDoubleToFloat, EOpConvFloatToBool,
EOpConvInt64ToFloat, EOpConvDoubleToBool,
EOpConvUint64ToFloat,
EOpConvUintToInt, // bool -> (u)int*
EOpConvFloatToInt, EOpConvBoolToInt8,
EOpConvBoolToUint8,
EOpConvBoolToInt16,
EOpConvBoolToUint16,
EOpConvBoolToInt, EOpConvBoolToInt,
EOpConvDoubleToInt,
EOpConvInt64ToInt,
EOpConvUint64ToInt,
EOpConvIntToUint,
EOpConvFloatToUint,
EOpConvBoolToUint, EOpConvBoolToUint,
EOpConvDoubleToUint,
EOpConvInt64ToUint,
EOpConvUint64ToUint,
EOpConvIntToDouble,
EOpConvUintToDouble,
EOpConvFloatToDouble,
EOpConvBoolToDouble,
EOpConvInt64ToDouble,
EOpConvUint64ToDouble,
EOpConvBoolToInt64, EOpConvBoolToInt64,
EOpConvIntToInt64,
EOpConvUintToInt64,
EOpConvFloatToInt64,
EOpConvDoubleToInt64,
EOpConvUint64ToInt64,
EOpConvBoolToUint64, EOpConvBoolToUint64,
// bool -> float*
EOpConvBoolToFloat16,
EOpConvBoolToFloat,
EOpConvBoolToDouble,
// int8_t -> (u)int*
EOpConvInt8ToInt16,
EOpConvInt8ToInt,
EOpConvInt8ToInt64,
EOpConvInt8ToUint8,
EOpConvInt8ToUint16,
EOpConvInt8ToUint,
EOpConvInt8ToUint64,
// uint8_t -> (u)int*
EOpConvUint8ToInt8,
EOpConvUint8ToInt16,
EOpConvUint8ToInt,
EOpConvUint8ToInt64,
EOpConvUint8ToUint16,
EOpConvUint8ToUint,
EOpConvUint8ToUint64,
// int8_t -> float*
EOpConvInt8ToFloat16,
EOpConvInt8ToFloat,
EOpConvInt8ToDouble,
// uint8_t -> float*
EOpConvUint8ToFloat16,
EOpConvUint8ToFloat,
EOpConvUint8ToDouble,
// int16_t -> (u)int*
EOpConvInt16ToInt8,
EOpConvInt16ToInt,
EOpConvInt16ToInt64,
EOpConvInt16ToUint8,
EOpConvInt16ToUint16,
EOpConvInt16ToUint,
EOpConvInt16ToUint64,
// uint16_t -> (u)int*
EOpConvUint16ToInt8,
EOpConvUint16ToInt16,
EOpConvUint16ToInt,
EOpConvUint16ToInt64,
EOpConvUint16ToUint8,
EOpConvUint16ToUint,
EOpConvUint16ToUint64,
// int16_t -> float*
EOpConvInt16ToFloat16,
EOpConvInt16ToFloat,
EOpConvInt16ToDouble,
// uint16_t -> float*
EOpConvUint16ToFloat16,
EOpConvUint16ToFloat,
EOpConvUint16ToDouble,
// int32_t -> (u)int*
EOpConvIntToInt8,
EOpConvIntToInt16,
EOpConvIntToInt64,
EOpConvIntToUint8,
EOpConvIntToUint16,
EOpConvIntToUint,
EOpConvIntToUint64, EOpConvIntToUint64,
// uint32_t -> (u)int*
EOpConvUintToInt8,
EOpConvUintToInt16,
EOpConvUintToInt,
EOpConvUintToInt64,
EOpConvUintToUint8,
EOpConvUintToUint16,
EOpConvUintToUint64, EOpConvUintToUint64,
EOpConvFloatToUint64,
EOpConvDoubleToUint64, // int32_t -> float*
EOpConvInt64ToUint64,
#ifdef AMD_EXTENSIONS
EOpConvBoolToFloat16,
EOpConvIntToFloat16, EOpConvIntToFloat16,
EOpConvIntToFloat,
EOpConvIntToDouble,
// uint32_t -> float*
EOpConvUintToFloat16, EOpConvUintToFloat16,
EOpConvFloatToFloat16, EOpConvUintToFloat,
EOpConvDoubleToFloat16, EOpConvUintToDouble,
// int64_t -> (u)int*
EOpConvInt64ToInt8,
EOpConvInt64ToInt16,
EOpConvInt64ToInt,
EOpConvInt64ToUint8,
EOpConvInt64ToUint16,
EOpConvInt64ToUint,
EOpConvInt64ToUint64,
// uint64_t -> (u)int*
EOpConvUint64ToInt8,
EOpConvUint64ToInt16,
EOpConvUint64ToInt,
EOpConvUint64ToInt64,
EOpConvUint64ToUint8,
EOpConvUint64ToUint16,
EOpConvUint64ToUint,
// int64_t -> float*
EOpConvInt64ToFloat16, EOpConvInt64ToFloat16,
EOpConvInt64ToFloat,
EOpConvInt64ToDouble,
// uint64_t -> float*
EOpConvUint64ToFloat16, EOpConvUint64ToFloat16,
EOpConvFloat16ToBool, EOpConvUint64ToFloat,
EOpConvUint64ToDouble,
// float16_t -> (u)int*
EOpConvFloat16ToInt8,
EOpConvFloat16ToInt16,
EOpConvFloat16ToInt, EOpConvFloat16ToInt,
EOpConvFloat16ToInt64,
EOpConvFloat16ToUint8,
EOpConvFloat16ToUint16,
EOpConvFloat16ToUint, EOpConvFloat16ToUint,
EOpConvFloat16ToUint64,
// float16_t -> float*
EOpConvFloat16ToFloat, EOpConvFloat16ToFloat,
EOpConvFloat16ToDouble, EOpConvFloat16ToDouble,
EOpConvFloat16ToInt64,
EOpConvFloat16ToUint64,
EOpConvBoolToInt16, // float -> (u)int*
EOpConvIntToInt16, EOpConvFloatToInt8,
EOpConvUintToInt16,
EOpConvFloatToInt16, EOpConvFloatToInt16,
EOpConvDoubleToInt16, EOpConvFloatToInt,
EOpConvFloat16ToInt16, EOpConvFloatToInt64,
EOpConvInt64ToInt16, EOpConvFloatToUint8,
EOpConvUint64ToInt16,
EOpConvUint16ToInt16,
EOpConvInt16ToBool,
EOpConvInt16ToInt,
EOpConvInt16ToUint,
EOpConvInt16ToFloat,
EOpConvInt16ToDouble,
EOpConvInt16ToFloat16,
EOpConvInt16ToInt64,
EOpConvInt16ToUint64,
EOpConvBoolToUint16,
EOpConvIntToUint16,
EOpConvUintToUint16,
EOpConvFloatToUint16, EOpConvFloatToUint16,
EOpConvFloatToUint,
EOpConvFloatToUint64,
// float -> float*
EOpConvFloatToFloat16,
EOpConvFloatToDouble,
// float64 _t-> (u)int*
EOpConvDoubleToInt8,
EOpConvDoubleToInt16,
EOpConvDoubleToInt,
EOpConvDoubleToInt64,
EOpConvDoubleToUint8,
EOpConvDoubleToUint16, EOpConvDoubleToUint16,
EOpConvFloat16ToUint16, EOpConvDoubleToUint,
EOpConvInt64ToUint16, EOpConvDoubleToUint64,
EOpConvUint64ToUint16,
EOpConvInt16ToUint16, // float64_t -> float*
EOpConvUint16ToBool, EOpConvDoubleToFloat16,
EOpConvUint16ToInt, EOpConvDoubleToFloat,
EOpConvUint16ToUint,
EOpConvUint16ToFloat,
EOpConvUint16ToDouble,
EOpConvUint16ToFloat16,
EOpConvUint16ToInt64,
EOpConvUint16ToUint64,
#endif
// //
// binary operations // binary operations
...@@ -280,12 +370,10 @@ enum TOperator { ...@@ -280,12 +370,10 @@ enum TOperator {
EOpDoubleBitsToUint64, EOpDoubleBitsToUint64,
EOpInt64BitsToDouble, EOpInt64BitsToDouble,
EOpUint64BitsToDouble, EOpUint64BitsToDouble,
#ifdef AMD_EXTENSIONS
EOpFloat16BitsToInt16, EOpFloat16BitsToInt16,
EOpFloat16BitsToUint16, EOpFloat16BitsToUint16,
EOpInt16BitsToFloat16, EOpInt16BitsToFloat16,
EOpUint16BitsToFloat16, EOpUint16BitsToFloat16,
#endif
EOpPackSnorm2x16, EOpPackSnorm2x16,
EOpUnpackSnorm2x16, EOpUnpackSnorm2x16,
EOpPackUnorm2x16, EOpPackUnorm2x16,
...@@ -302,7 +390,6 @@ enum TOperator { ...@@ -302,7 +390,6 @@ enum TOperator {
EOpUnpackInt2x32, EOpUnpackInt2x32,
EOpPackUint2x32, EOpPackUint2x32,
EOpUnpackUint2x32, EOpUnpackUint2x32,
#ifdef AMD_EXTENSIONS
EOpPackFloat2x16, EOpPackFloat2x16,
EOpUnpackFloat2x16, EOpUnpackFloat2x16,
EOpPackInt2x16, EOpPackInt2x16,
...@@ -313,7 +400,12 @@ enum TOperator { ...@@ -313,7 +400,12 @@ enum TOperator {
EOpUnpackInt4x16, EOpUnpackInt4x16,
EOpPackUint4x16, EOpPackUint4x16,
EOpUnpackUint4x16, EOpUnpackUint4x16,
#endif EOpPack16,
EOpPack32,
EOpPack64,
EOpUnpack32,
EOpUnpack16,
EOpUnpack8,
EOpLength, EOpLength,
EOpDistance, EOpDistance,
...@@ -507,32 +599,36 @@ enum TOperator { ...@@ -507,32 +599,36 @@ enum TOperator {
EOpConstructGuardStart, EOpConstructGuardStart,
EOpConstructInt, // these first scalar forms also identify what implicit conversion is needed EOpConstructInt, // these first scalar forms also identify what implicit conversion is needed
EOpConstructUint, EOpConstructUint,
EOpConstructInt64, EOpConstructInt8,
EOpConstructUint64, EOpConstructUint8,
#ifdef AMD_EXTENSIONS
EOpConstructInt16, EOpConstructInt16,
EOpConstructUint16, EOpConstructUint16,
#endif EOpConstructInt64,
EOpConstructUint64,
EOpConstructBool, EOpConstructBool,
EOpConstructFloat, EOpConstructFloat,
EOpConstructDouble, EOpConstructDouble,
#ifdef AMD_EXTENSIONS
EOpConstructFloat16,
#endif
EOpConstructVec2, EOpConstructVec2,
EOpConstructVec3, EOpConstructVec3,
EOpConstructVec4, EOpConstructVec4,
EOpConstructDVec2, EOpConstructDVec2,
EOpConstructDVec3, EOpConstructDVec3,
EOpConstructDVec4, EOpConstructDVec4,
#ifdef AMD_EXTENSIONS
EOpConstructF16Vec2,
EOpConstructF16Vec3,
EOpConstructF16Vec4,
#endif
EOpConstructBVec2, EOpConstructBVec2,
EOpConstructBVec3, EOpConstructBVec3,
EOpConstructBVec4, EOpConstructBVec4,
EOpConstructI8Vec2,
EOpConstructI8Vec3,
EOpConstructI8Vec4,
EOpConstructU8Vec2,
EOpConstructU8Vec3,
EOpConstructU8Vec4,
EOpConstructI16Vec2,
EOpConstructI16Vec3,
EOpConstructI16Vec4,
EOpConstructU16Vec2,
EOpConstructU16Vec3,
EOpConstructU16Vec4,
EOpConstructIVec2, EOpConstructIVec2,
EOpConstructIVec3, EOpConstructIVec3,
EOpConstructIVec4, EOpConstructIVec4,
...@@ -545,14 +641,6 @@ enum TOperator { ...@@ -545,14 +641,6 @@ enum TOperator {
EOpConstructU64Vec2, EOpConstructU64Vec2,
EOpConstructU64Vec3, EOpConstructU64Vec3,
EOpConstructU64Vec4, EOpConstructU64Vec4,
#ifdef AMD_EXTENSIONS
EOpConstructI16Vec2,
EOpConstructI16Vec3,
EOpConstructI16Vec4,
EOpConstructU16Vec2,
EOpConstructU16Vec3,
EOpConstructU16Vec4,
#endif
EOpConstructMat2x2, EOpConstructMat2x2,
EOpConstructMat2x3, EOpConstructMat2x3,
EOpConstructMat2x4, EOpConstructMat2x4,
...@@ -598,7 +686,10 @@ enum TOperator { ...@@ -598,7 +686,10 @@ enum TOperator {
EOpConstructBMat4x2, EOpConstructBMat4x2,
EOpConstructBMat4x3, EOpConstructBMat4x3,
EOpConstructBMat4x4, EOpConstructBMat4x4,
#ifdef AMD_EXTENSIONS EOpConstructFloat16,
EOpConstructF16Vec2,
EOpConstructF16Vec3,
EOpConstructF16Vec4,
EOpConstructF16Mat2x2, EOpConstructF16Mat2x2,
EOpConstructF16Mat2x3, EOpConstructF16Mat2x3,
EOpConstructF16Mat2x4, EOpConstructF16Mat2x4,
...@@ -608,7 +699,6 @@ enum TOperator { ...@@ -608,7 +699,6 @@ enum TOperator {
EOpConstructF16Mat4x2, EOpConstructF16Mat4x2,
EOpConstructF16Mat4x3, EOpConstructF16Mat4x3,
EOpConstructF16Mat4x4, EOpConstructF16Mat4x4,
#endif
EOpConstructStruct, EOpConstructStruct,
EOpConstructTextureSampler, EOpConstructTextureSampler,
EOpConstructGuardEnd, EOpConstructGuardEnd,
......
...@@ -385,6 +385,7 @@ public: ...@@ -385,6 +385,7 @@ public:
const TFunction* findFunctionExact(const TSourceLoc& loc, const TFunction& call, bool& builtIn); const TFunction* findFunctionExact(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunction120(const TSourceLoc& loc, const TFunction& call, bool& builtIn); const TFunction* findFunction120(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunction400(const TSourceLoc& loc, const TFunction& call, bool& builtIn); const TFunction* findFunction400(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
const TFunction* findFunctionExplicitTypes(const TSourceLoc& loc, const TFunction& call, bool& builtIn);
void declareTypeDefaults(const TSourceLoc&, const TPublicType&); void declareTypeDefaults(const TSourceLoc&, const TPublicType&);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TPublicType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0); TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, const TPublicType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0);
TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&); TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&);
......
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc. // Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -60,17 +61,15 @@ void TType::buildMangledName(TString& mangledName) const ...@@ -60,17 +61,15 @@ void TType::buildMangledName(TString& mangledName) const
switch (basicType) { switch (basicType) {
case EbtFloat: mangledName += 'f'; break; case EbtFloat: mangledName += 'f'; break;
case EbtDouble: mangledName += 'd'; break; case EbtDouble: mangledName += 'd'; break;
#ifdef AMD_EXTENSIONS
case EbtFloat16: mangledName += "f16"; break; case EbtFloat16: mangledName += "f16"; break;
#endif
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
case EbtUint: mangledName += 'u'; break; case EbtUint: mangledName += 'u'; break;
case EbtInt64: mangledName += "i64"; break; case EbtInt8: mangledName += "i8"; break;
case EbtUint64: mangledName += "u64"; break; case EbtUint8: mangledName += "u8"; break;
#ifdef AMD_EXTENSIONS
case EbtInt16: mangledName += "i16"; break; case EbtInt16: mangledName += "i16"; break;
case EbtUint16: mangledName += "u16"; break; case EbtUint16: mangledName += "u16"; break;
#endif case EbtInt64: mangledName += "i64"; break;
case EbtUint64: mangledName += "u64"; break;
case EbtBool: mangledName += 'b'; break; case EbtBool: mangledName += 'b'; break;
case EbtAtomicUint: mangledName += "au"; break; case EbtAtomicUint: mangledName += "au"; break;
case EbtSampler: case EbtSampler:
......
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc. // Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -256,6 +257,16 @@ void TParseVersions::initializeExtensionBehavior() ...@@ -256,6 +257,16 @@ void TParseVersions::initializeExtensionBehavior()
// OVR extensions // OVR extensions
extensionBehavior[E_GL_OVR_multiview] = EBhDisable; extensionBehavior[E_GL_OVR_multiview] = EBhDisable;
extensionBehavior[E_GL_OVR_multiview2] = EBhDisable; extensionBehavior[E_GL_OVR_multiview2] = EBhDisable;
// explicit types
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_int8] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_int16] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_int32] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_int64] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_float16] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_float32] = EBhDisable;
extensionBehavior[E_GL_KHX_shader_explicit_arithmetic_types_float64] = EBhDisable;
} }
// Get code that is not part of a shared symbol table, is specific to this shader, // Get code that is not part of a shared symbol table, is specific to this shader,
...@@ -361,6 +372,14 @@ void TParseVersions::getPreamble(std::string& preamble) ...@@ -361,6 +372,14 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_geometry_shader_passthrough 1\n" "#define GL_NV_geometry_shader_passthrough 1\n"
"#define GL_NV_viewport_array2 1\n" "#define GL_NV_viewport_array2 1\n"
#endif #endif
"#define GL_KHX_shader_explicit_arithmetic_types 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int16 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int32 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int64 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_float16 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_float32 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_float64 1\n"
; ;
if (version >= 150) { if (version >= 150) {
...@@ -767,35 +786,105 @@ void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op) ...@@ -767,35 +786,105 @@ void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op)
profileRequires(loc, ECompatibilityProfile, 400, nullptr, op); profileRequires(loc, ECompatibilityProfile, 400, nullptr, op);
} }
#ifdef AMD_EXTENSIONS // Call for any operation needing GLSL float16 data-type support.
// Call for any operation needing GLSL 16-bit integer data-type support. void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool builtIn)
void TParseVersions::int16Check(const TSourceLoc& loc, const char* op, bool builtIn)
{ {
if (! builtIn) { if (!builtIn) {
requireExtensions(loc, 1, &E_GL_AMD_gpu_shader_int16, "shader int16"); #if AMD_EXTENSIONS
const char* const extensions[3] = {E_GL_AMD_gpu_shader_half_float,
E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_float16};
#else
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_float16};
#endif
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op); profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op); profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
} }
} }
// Call for any operation needing GLSL float16 data-type support. // Call for any operation needing GLSL float32 data-type support.
void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool builtIn) void TParseVersions::explicitFloat32Check(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_float32};
requireExtensions(loc, 2, extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
}
}
// Call for any operation needing GLSL float64 data-type support.
void TParseVersions::explicitFloat64Check(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (!builtIn) {
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_float64};
requireExtensions(loc, 2, extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
}
}
// Call for any operation needing GLSL explicit int8 data-type support.
void TParseVersions::explicitInt8Check(const TSourceLoc& loc, const char* op, bool builtIn)
{ {
if (! builtIn) { if (! builtIn) {
requireExtensions(loc, 1, &E_GL_AMD_gpu_shader_half_float, "shader half float"); const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_int8};
requireExtensions(loc, 2, extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op); profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op); profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
} }
} }
// Call for any operation needing GLSL explicit int16 data-type support.
void TParseVersions::explicitInt16Check(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (! builtIn) {
#if AMD_EXTENSIONS
const char* const extensions[3] = {E_GL_AMD_gpu_shader_int16,
E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_int16};
#else
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_int16};
#endif #endif
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
}
}
// Call for any operation needing GLSL explicit int32 data-type support.
void TParseVersions::explicitInt32Check(const TSourceLoc& loc, const char* op, bool builtIn)
{
if (! builtIn) {
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_int32};
requireExtensions(loc, 2, extensions, "explicit types");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
}
}
// Call for any operation needing GLSL 64-bit integer data-type support. // Call for any operation needing GLSL 64-bit integer data-type support.
void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool builtIn) void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool builtIn)
{ {
if (! builtIn) { if (! builtIn) {
requireExtensions(loc, 1, &E_GL_ARB_gpu_shader_int64, "shader int64"); const char* const extensions[3] = {E_GL_ARB_gpu_shader_int64,
E_GL_KHX_shader_explicit_arithmetic_types,
E_GL_KHX_shader_explicit_arithmetic_types_int64};
requireExtensions(loc, 3, extensions, "shader int64");
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile, 450, nullptr, op); profileRequires(loc, ECoreProfile, 450, nullptr, op);
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op); profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
......
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2012-2013 LunarG, Inc. // Copyright (C) 2012-2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -225,6 +226,16 @@ const char* const E_GL_OES_tessellation_point_size = "GL_OES_tessel ...@@ -225,6 +226,16 @@ const char* const E_GL_OES_tessellation_point_size = "GL_OES_tessel
const char* const E_GL_OES_texture_buffer = "GL_OES_texture_buffer"; const char* const E_GL_OES_texture_buffer = "GL_OES_texture_buffer";
const char* const E_GL_OES_texture_cube_map_array = "GL_OES_texture_cube_map_array"; const char* const E_GL_OES_texture_cube_map_array = "GL_OES_texture_cube_map_array";
// KHX
const char* const E_GL_KHX_shader_explicit_arithmetic_types = "GL_KHX_shader_explicit_arithmetic_types";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_int8 = "GL_KHX_shader_explicit_arithmetic_types_int8";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_int16 = "GL_KHX_shader_explicit_arithmetic_types_int16";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_int32 = "GL_KHX_shader_explicit_arithmetic_types_int32";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_int64 = "GL_KHX_shader_explicit_arithmetic_types_int64";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_float16 = "GL_KHX_shader_explicit_arithmetic_types_float16";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_float32 = "GL_KHX_shader_explicit_arithmetic_types_float32";
const char* const E_GL_KHX_shader_explicit_arithmetic_types_float64 = "GL_KHX_shader_explicit_arithmetic_types_float64";
// Arrays of extensions for the above AEP duplications // Arrays of extensions for the above AEP duplications
const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader }; const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// //
// Copyright (C) 2013 LunarG, Inc. // Copyright (C) 2013 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -1064,11 +1065,11 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size) ...@@ -1064,11 +1065,11 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
case EbtInt64: case EbtInt64:
case EbtUint64: case EbtUint64:
case EbtDouble: size = 8; return 8; case EbtDouble: size = 8; return 8;
#ifdef AMD_EXTENSIONS
case EbtInt16:
case EbtUint16:
case EbtFloat16: size = 2; return 2; case EbtFloat16: size = 2; return 2;
#endif case EbtInt8:
case EbtUint8: size = 1; return 1;
case EbtInt16:
case EbtUint16: size = 2; return 2;
default: size = 4; return 4; default: size = 4; return 4;
} }
} }
......
// //
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2016 LunarG, Inc. // Copyright (C) 2016 LunarG, Inc.
// Copyright (C) 2017 ARM Limited.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
...@@ -77,7 +78,7 @@ public: ...@@ -77,7 +78,7 @@ public:
assert(i < MaxSwizzleSelectors); assert(i < MaxSwizzleSelectors);
return components[i]; return components[i];
} }
private: private:
int size_; int size_;
selectorType components[MaxSwizzleSelectors]; selectorType components[MaxSwizzleSelectors];
...@@ -399,6 +400,7 @@ public: ...@@ -399,6 +400,7 @@ public:
TIntermSymbol* addSymbol(const TType&, const TSourceLoc&); TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
TIntermSymbol* addSymbol(const TIntermSymbol&); TIntermSymbol* addSymbol(const TIntermSymbol&);
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const; TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const;
std::tuple<TIntermTyped*, TIntermTyped*> addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1) const;
TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*); TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*);
void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode); void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
TIntermTyped* addShapeConversion(const TType&, TIntermTyped*); TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
...@@ -408,6 +410,11 @@ public: ...@@ -408,6 +410,11 @@ public:
TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, TSourceLoc); TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, TSourceLoc);
TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType); TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType);
bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const; bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const;
bool isIntegralPromotion(TBasicType from, TBasicType to) const;
bool isFPPromotion(TBasicType from, TBasicType to) const;
bool isIntegralConversion(TBasicType from, TBasicType to) const;
bool isFPConversion(TBasicType from, TBasicType to) const;
bool isFPIntegralConversion(TBasicType from, TBasicType to) const;
TOperator mapTypeToConstructorOp(const TType&) const; TOperator mapTypeToConstructorOp(const TType&) const;
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right); TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&); TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&);
...@@ -421,15 +428,14 @@ public: ...@@ -421,15 +428,14 @@ public:
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, const TSourceLoc&); TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, const TSourceLoc&);
TIntermConstantUnion* addConstantUnion(const TConstUnionArray&, const TType&, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(const TConstUnionArray&, const TType&, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(signed char, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(unsigned char, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(signed short, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(unsigned short, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(int, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(int, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(unsigned int, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(unsigned int, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(long long, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(long long, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(unsigned long long, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(unsigned long long, const TSourceLoc&, bool literal = false) const;
#ifdef AMD_EXTENSIONS
TIntermConstantUnion* addConstantUnion(short, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(unsigned short, const TSourceLoc&, bool literal = false) const;
#endif
TIntermConstantUnion* addConstantUnion(bool, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(bool, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(double, TBasicType, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(double, TBasicType, const TSourceLoc&, bool literal = false) const;
TIntermConstantUnion* addConstantUnion(const TString*, const TSourceLoc&, bool literal = false) const; TIntermConstantUnion* addConstantUnion(const TString*, const TSourceLoc&, bool literal = false) const;
...@@ -634,6 +640,9 @@ protected: ...@@ -634,6 +640,9 @@ protected:
void pushSelector(TIntermSequence&, const TMatrixSelector&, const TSourceLoc&); void pushSelector(TIntermSequence&, const TMatrixSelector&, const TSourceLoc&);
bool specConstantPropagates(const TIntermTyped&, const TIntermTyped&); bool specConstantPropagates(const TIntermTyped&, const TIntermTyped&);
void performTextureUpgradeAndSamplerRemovalTransformation(TIntermNode* root); void performTextureUpgradeAndSamplerRemovalTransformation(TIntermNode* root);
bool isConversionAllowed(TOperator op, TIntermTyped* node) const;
TIntermUnary* createConversion(TBasicType convertTo, TIntermTyped* node) const;
std::tuple<TBasicType, TBasicType> getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const;
const EShLanguage language; // stage, known at construction time const EShLanguage language; // stage, known at construction time
EShSource source; // source language, known a bit later EShSource source; // source language, known a bit later
......
// //
// Copyright (C) 2016 Google, Inc. // Copyright (C) 2016 Google, Inc.
// Copyright (C) 2017 ARM Limited.
// //
// All rights reserved. // All rights reserved.
// //
...@@ -77,11 +78,13 @@ public: ...@@ -77,11 +78,13 @@ public:
virtual void updateExtensionBehavior(int line, const char* const extension, const char* behavior); virtual void updateExtensionBehavior(int line, const char* const extension, const char* behavior);
virtual void fullIntegerCheck(const TSourceLoc&, const char* op); virtual void fullIntegerCheck(const TSourceLoc&, const char* op);
virtual void doubleCheck(const TSourceLoc&, const char* op); virtual void doubleCheck(const TSourceLoc&, const char* op);
#ifdef AMD_EXTENSIONS
virtual void int16Check(const TSourceLoc& loc, const char* op, bool builtIn = false);
virtual void float16Check(const TSourceLoc&, const char* op, bool builtIn = false); 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 int64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt8Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt16Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitInt32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat32Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void explicitFloat64Check(const TSourceLoc&, const char* op, bool builtIn = false);
virtual void spvRemoved(const TSourceLoc&, const char* op); virtual void spvRemoved(const TSourceLoc&, const char* op);
virtual void vulkanRemoved(const TSourceLoc&, const char* op); virtual void vulkanRemoved(const TSourceLoc&, const char* op);
virtual void requireVulkan(const TSourceLoc&, const char* op); virtual void requireVulkan(const TSourceLoc&, const char* op);
......
...@@ -721,12 +721,10 @@ int TPpContext::CPPerror(TPpToken* ppToken) ...@@ -721,12 +721,10 @@ int TPpContext::CPPerror(TPpToken* ppToken)
TSourceLoc loc = ppToken->loc; TSourceLoc loc = ppToken->loc;
while (token != '\n' && token != EndOfInput) { while (token != '\n' && token != EndOfInput) {
if (token == PpAtomConstInt || token == PpAtomConstUint || if (token == PpAtomConstInt16 || token == PpAtomConstUint16 ||
token == PpAtomConstInt || token == PpAtomConstUint ||
token == PpAtomConstInt64 || token == PpAtomConstUint64 || token == PpAtomConstInt64 || token == PpAtomConstUint64 ||
#ifdef AMD_EXTENSIONS
token == PpAtomConstInt16 || token == PpAtomConstUint16 ||
token == PpAtomConstFloat16 || token == PpAtomConstFloat16 ||
#endif
token == PpAtomConstFloat || token == PpAtomConstDouble) { token == PpAtomConstFloat || token == PpAtomConstDouble) {
message.append(ppToken->name); message.append(ppToken->name);
} else if (token == PpAtomIdentifier || token == PpAtomConstString) { } else if (token == PpAtomIdentifier || token == PpAtomConstString) {
...@@ -765,9 +763,7 @@ int TPpContext::CPPpragma(TPpToken* ppToken) ...@@ -765,9 +763,7 @@ int TPpContext::CPPpragma(TPpToken* ppToken)
#endif #endif
case PpAtomConstFloat: case PpAtomConstFloat:
case PpAtomConstDouble: case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16: case PpAtomConstFloat16:
#endif
tokens.push_back(ppToken->name); tokens.push_back(ppToken->name);
break; break;
default: default:
......
...@@ -147,9 +147,7 @@ void TPpContext::TokenStream::putToken(int token, TPpToken* ppToken) ...@@ -147,9 +147,7 @@ void TPpContext::TokenStream::putToken(int token, TPpToken* ppToken)
#endif #endif
case PpAtomConstFloat: case PpAtomConstFloat:
case PpAtomConstDouble: case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16: case PpAtomConstFloat16:
#endif
str = ppToken->name; str = ppToken->name;
while (*str) { while (*str) {
putSubtoken(*str); putSubtoken(*str);
...@@ -187,9 +185,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken ...@@ -187,9 +185,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken
case PpAtomIdentifier: case PpAtomIdentifier:
case PpAtomConstFloat: case PpAtomConstFloat:
case PpAtomConstDouble: case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16: case PpAtomConstFloat16:
#endif
case PpAtomConstInt: case PpAtomConstInt:
case PpAtomConstUint: case PpAtomConstUint:
case PpAtomConstInt64: case PpAtomConstInt64:
...@@ -219,9 +215,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken ...@@ -219,9 +215,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken
break; break;
case PpAtomConstFloat: case PpAtomConstFloat:
case PpAtomConstDouble: case PpAtomConstDouble:
#ifdef AMD_EXTENSIONS
case PpAtomConstFloat16: case PpAtomConstFloat16:
#endif
ppToken->dval = atof(ppToken->name); ppToken->dval = atof(ppToken->name);
break; break;
case PpAtomConstInt: case PpAtomConstInt:
......
...@@ -127,10 +127,8 @@ enum EFixedAtoms { ...@@ -127,10 +127,8 @@ enum EFixedAtoms {
PpAtomConstUint, PpAtomConstUint,
PpAtomConstInt64, PpAtomConstInt64,
PpAtomConstUint64, PpAtomConstUint64,
#ifdef AMD_EXTENSIONS
PpAtomConstInt16, PpAtomConstInt16,
PpAtomConstUint16, PpAtomConstUint16,
#endif
PpAtomConstFloat, PpAtomConstFloat,
PpAtomConstDouble, PpAtomConstDouble,
PpAtomConstFloat16, PpAtomConstFloat16,
......
...@@ -201,6 +201,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -201,6 +201,7 @@ INSTANTIATE_TEST_CASE_P(
"precise.tesc", "precise.tesc",
"precise_struct_block.vert", "precise_struct_block.vert",
"maxClipDistances.vert", "maxClipDistances.vert",
"findFunction.frag",
})), })),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
......
...@@ -336,6 +336,11 @@ INSTANTIATE_TEST_CASE_P( ...@@ -336,6 +336,11 @@ INSTANTIATE_TEST_CASE_P(
"spv.subgroupArithmetic.comp", "spv.subgroupArithmetic.comp",
"spv.subgroupClustered.comp", "spv.subgroupClustered.comp",
"spv.subgroupQuad.comp", "spv.subgroupQuad.comp",
"spv.int8.frag",
"spv.int16.frag",
"spv.int32.frag",
"spv.float32.frag",
"spv.float64.frag",
})), })),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
...@@ -421,6 +426,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -421,6 +426,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.float16.frag", "spv.float16.frag",
"spv.imageLoadStoreLod.frag", "spv.imageLoadStoreLod.frag",
"spv.int16.frag", "spv.int16.frag",
"spv.int16.amd.frag",
"spv.shaderBallotAMD.comp", "spv.shaderBallotAMD.comp",
"spv.shaderFragMaskAMD.frag", "spv.shaderFragMaskAMD.frag",
"spv.textureGatherBiasLod.frag" "spv.textureGatherBiasLod.frag"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment