Add uint type (big change). For both int/uint, add the operators >>, <<, &, |, and ^. Also added unsigned literals and uint precision support. Also fixed how int/uint literal underflow/overflow is handled.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21054 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
@@ -10,7 +10,11 @@ lowp vec2 foo(mediump vec3 mv3)
|
||||
|
||||
int global_medium;
|
||||
|
||||
precision highp int;
|
||||
precision highp int;
|
||||
precision highp ivec2; // ERROR
|
||||
precision mediump int[2]; // ERROR
|
||||
precision lowp uint; // ERROR
|
||||
precision mediump vec4; // ERROR
|
||||
|
||||
int global_high;
|
||||
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
#extension GL_3DL_array_objects : enable
|
||||
|
||||
int a = 0xffffffff; // 32 bits, a gets the value -1
|
||||
//int b = 0xffffffffU; // ERROR: can't convert uint to int
|
||||
int b = 0xffffffffU; // ERROR: can't convert uint to int
|
||||
uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF
|
||||
//uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF
|
||||
uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF
|
||||
int e = -1; // the literal is "1", then negation is performed,
|
||||
// and the resulting non-literal 32-bit signed
|
||||
// bit pattern of 0xFFFFFFFF is assigned, giving e
|
||||
// the value of -1.
|
||||
//uint f = -1u; // the literal is "1u", then negation is performed,
|
||||
uint f = -1u; // the literal is "1u", then negation is performed,
|
||||
// and the resulting non-literal 32-bit unsigned
|
||||
// bit pattern of 0xFFFFFFFF is assigned, giving f
|
||||
// the value of 0xFFFFFFFF.
|
||||
int g = 3000000000; // a signed decimal literal taking 32 bits,
|
||||
// setting the sign bit, g gets -1294967296
|
||||
int h = 0xA0000000; // okay, 32-bit signed hexadecimal
|
||||
//int i = 5000000000; // ERROR: needs more than 32 bits
|
||||
//int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits
|
||||
int i = 5000000000; // ERROR: needs more than 32 bits
|
||||
int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits
|
||||
int k = 0x80000000; // k gets -2147483648 == 0x80000000
|
||||
int l = 2147483648; // l gets -2147483648 (the literal set the sign bit)
|
||||
|
||||
|
||||
@@ -29,3 +29,4 @@ constErrors.frag
|
||||
constFold.frag
|
||||
errors.frag
|
||||
forwardRef.frag
|
||||
uint.frag
|
||||
|
||||
105
Test/uint.frag
Normal file
105
Test/uint.frag
Normal file
@@ -0,0 +1,105 @@
|
||||
#version 300 es
|
||||
|
||||
in uvec2 t;
|
||||
in float f;
|
||||
in vec2 tc;
|
||||
|
||||
uniform uvec4 v;
|
||||
uniform int i;
|
||||
uniform bool b;
|
||||
|
||||
out uvec4 c;
|
||||
|
||||
uniform usampler2D usampler;
|
||||
|
||||
void main()
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
uint u = t.y + 3u;
|
||||
const uint cu1error = 0xFFFFFFFF; // ERROR
|
||||
const uint cu1 = 0xFFFFFFFFU;
|
||||
const uint cu2 = -1u; // 0xFFFFFFFF
|
||||
const uint cu3 = 1U;
|
||||
const uint cu4error = 1; // ERROR
|
||||
const uint cu4 = 1u;
|
||||
|
||||
if (cu1 == cu2)
|
||||
count *= 2; // done
|
||||
if (cu3 == cu4)
|
||||
count *= 3; // done
|
||||
if (cu2 == cu3)
|
||||
count *= 5; // not done
|
||||
|
||||
const uint cushiftediierror = 0xFFFFFFFF >> 10; // ERROR
|
||||
const int cshiftedii = 0xFFFFFFFF >> 10;
|
||||
const uint cushiftedui = 0xFFFFFFFFu >> 10;
|
||||
const uint cushiftediuerror = 0xFFFFFFFF >> 10u; // ERROR
|
||||
const int cshiftediu = 0xFFFFFFFF >> 10u;
|
||||
const uint cushifteduu = 0xFFFFFFFFu >> 10u;
|
||||
|
||||
if (cshiftedii == cshiftediu)
|
||||
count *= 7; // done
|
||||
if (cushiftedui == cushifteduu)
|
||||
count *= 11; // done
|
||||
if (cshiftedii == int(cushiftedui))
|
||||
count *= 13; // not done
|
||||
|
||||
uint shiftediierror = 0xFFFFFFFF >> 10; // ERROR
|
||||
int shiftedii = 0xFFFFFFFF >> 10;
|
||||
uint shiftedui = 0xFFFFFFFFu >> 10;
|
||||
uint shiftediuerror = 0xFFFFFFFF >> 10u; // ERROR
|
||||
int shiftediu = 0xFFFFFFFF >> 10u;
|
||||
uint shifteduu = 0xFFFFFFFFu >> 10u;
|
||||
|
||||
if (shiftedii == shiftediu)
|
||||
c = texture(usampler, tc);
|
||||
if (shiftedui == shifteduu)
|
||||
c = texture(usampler, tc + float(1u));
|
||||
if (shiftedii == int(shiftedui))
|
||||
c = texture(usampler, tc - vec2(2u));
|
||||
|
||||
if (t.x > 4u) {
|
||||
float af = float(u);
|
||||
bool ab = bool(u);
|
||||
int ai = int(u);
|
||||
|
||||
c += uvec4(uint(af), uint(ab), uint(ai), count);
|
||||
}
|
||||
|
||||
const uint cmask1 = 0x0A1u;
|
||||
const uint cmask2 = 0xA10u;
|
||||
const uint cmask3 = cmask1 << 4;
|
||||
const uint cmask4 = 0xAB1u;
|
||||
|
||||
if (cmask3 == cmask2)
|
||||
count *= 17; // done
|
||||
|
||||
if ((cmask3 & cmask1) != 0u)
|
||||
count *= 19; // not done
|
||||
|
||||
if ((cmask1 | cmask3) == cmask4)
|
||||
count *= 23; // done
|
||||
|
||||
if ((cmask1 ^ cmask4) == 0xA10u)
|
||||
count *= 27; // done
|
||||
|
||||
uint mask1 = 0x0A1u;
|
||||
uint mask2 = 0xA10u;
|
||||
uint mask3 = mask1 << 4;
|
||||
uint mask4 = 0xAB1u;
|
||||
|
||||
if (mask3 == mask2)
|
||||
count *= 100;
|
||||
|
||||
if ((mask3 & mask1) != 0u)
|
||||
count *= 101;
|
||||
|
||||
if ((mask1 | mask3) == mask4)
|
||||
count *= 102;
|
||||
|
||||
if ((mask1 ^ mask4) == 0xA10u)
|
||||
count *= 103;
|
||||
|
||||
c += uvec4(count);
|
||||
}
|
||||
Reference in New Issue
Block a user