From be70339296ab95faa974f0334ef8b3edd894b0b8 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 13 Aug 2014 20:04:19 +0000 Subject: [PATCH] Add the bitField built-in functions. Mark 330 as being complete. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27728 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/310.frag | 9 + Test/310.vert | 28 +++ Test/400.geom | 28 +++ Test/baseResults/310.frag.out | 11 +- Test/baseResults/310.vert.out | 183 +++++++++++++++++- Test/baseResults/330.frag.out | 1 - Test/baseResults/330comp.frag.out | 1 - Test/baseResults/400.geom.out | 182 +++++++++++++++++ Test/baseResults/constErrors.frag.out | 1 - Test/baseResults/recurse1.vert.out | 3 - Todo.txt | 38 +++- glslang/MachineIndependent/Initialize.cpp | 88 ++++++++- glslang/MachineIndependent/IntermTraverse.cpp | 4 +- glslang/MachineIndependent/ShaderLang.cpp | 2 +- 14 files changed, 560 insertions(+), 19 deletions(-) diff --git a/Test/310.frag b/Test/310.frag index 183d9113..1309fa70 100644 --- a/Test/310.frag +++ b/Test/310.frag @@ -59,3 +59,12 @@ void foo23() uvec3 um3 = mix(uvec3(i), uvec3(i), bvec3(b)); ivec4 im4 = mix(ivec4(i), ivec4(i), bvec4(b)); } + +layout(binding=3) uniform sampler2D s1; +layout(binding=3) uniform sampler2D s2; // ERROR: overlapping bindings? Don't see that in the 310 spec. +layout(binding=2) uniform writeonly image2D i2D; + +layout(binding = 1) uniform bb { + int foo; + layout(binding = 2) float f; // ERROR +} bbi; diff --git a/Test/310.vert b/Test/310.vert index 8f0dee49..f97acae6 100644 --- a/Test/310.vert +++ b/Test/310.vert @@ -8,3 +8,31 @@ layout(location = 2) uniform mat4 x; layout(location = 3) uniform mat4 y; layout(location = 2) out mat4 xi; layout(location = 3) out mat4 yi; // ERROR, locations conflict with xi + +void main() +{ + uvec2 u2; + u2 = uaddCarry(u2, u2, u2); + uint u1; + u1 = usubBorrow(u1, u1, u1); + uvec4 u4; + umulExtended(u4, u4, u4, u4); + ivec4 i4; + imulExtended(i4, i4, i4, i4); + int i1; + i1 = bitfieldExtract(i1, 4, 5); + uvec3 u3; + u3 = bitfieldExtract(u3, 4, 5); + ivec3 i3; + i3 = bitfieldInsert(i3, i3, 4, 5); + u1 = bitfieldInsert(u1, u1, 4, 5); + ivec2 i2; + i2 = bitfieldReverse(i2); + u4 = bitfieldReverse(u4); + i1 = bitCount(i1); + i3 = bitCount(u3); + i2 = findLSB(i2); + i4 = findLSB(u4); + i1 = findMSB(i1); + i2 = findMSB(u2); +} diff --git a/Test/400.geom b/Test/400.geom index adb29f63..34a3fb96 100644 --- a/Test/400.geom +++ b/Test/400.geom @@ -71,3 +71,31 @@ in inblockscalar { in inblocka { int a; } inbla[17]; // ERROR, wrong array size + +void bits() +{ + uvec2 u2; + u2 = uaddCarry(u2, u2, u2); + uint u1; + u1 = usubBorrow(u1, u1, u1); + uvec4 u4; + umulExtended(u4, u4, u4, u4); + ivec4 i4; + imulExtended(i4, i4, i4, i4); + int i1; + i1 = bitfieldExtract(i1, 4, 5); + uvec3 u3; + u3 = bitfieldExtract(u3, 4, 5); + ivec3 i3; + i3 = bitfieldInsert(i3, i3, 4, 5); + u1 = bitfieldInsert(u1, u1, 4, 5); + ivec2 i2; + i2 = bitfieldReverse(i2); + u4 = bitfieldReverse(u4); + i1 = bitCount(i1); + i3 = bitCount(u3); + i2 = findLSB(i2); + i4 = findLSB(u4); + i1 = findMSB(i1); + i2 = findMSB(u2); +} diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out index eb7b53c3..e1e30fcd 100644 --- a/Test/baseResults/310.frag.out +++ b/Test/baseResults/310.frag.out @@ -16,7 +16,8 @@ ERROR: 0:44: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, ERROR: 0:44: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:45: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] ERROR: 0:45: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset] -ERROR: 16 compilation errors. No code generated. +ERROR: 0:69: 'binding' : requires block, or sampler/image, or atomic-counter type +ERROR: 17 compilation errors. No code generated. Shader version: 310 @@ -203,6 +204,10 @@ ERROR: node is still EOpNull! 0:? 'c2D' (smooth in mediump 2-component vector of float) 0:? 'i' (uniform mediump int) 0:? 'outp' (out mediump 4-component vector of float) +0:? 's1' (layout(binding=3 ) uniform highp sampler2D) +0:? 's2' (layout(binding=3 ) uniform highp sampler2D) +0:? 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) +0:? 'bbi' (layout(binding=1 column_major shared ) uniform block{layout(column_major shared ) uniform mediump int foo, layout(binding=2 column_major shared ) uniform mediump float f}) Linked fragment stage: @@ -392,4 +397,8 @@ ERROR: node is still EOpNull! 0:? 'c2D' (smooth in mediump 2-component vector of float) 0:? 'i' (uniform mediump int) 0:? 'outp' (out mediump 4-component vector of float) +0:? 's1' (layout(binding=3 ) uniform highp sampler2D) +0:? 's2' (layout(binding=3 ) uniform highp sampler2D) +0:? 'i2D' (layout(binding=2 ) writeonly uniform highp image2D) +0:? 'bbi' (layout(binding=1 column_major shared ) uniform block{layout(column_major shared ) uniform mediump int foo, layout(binding=2 column_major shared ) uniform mediump float f}) diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index 4c42e968..fc82193b 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -9,6 +9,97 @@ ERROR: 4 compilation errors. No code generated. Shader version: 310 ERROR: node is still EOpNull! +0:12 Function Definition: main( (void) +0:12 Function Parameters: +0:? Sequence +0:15 move second child to first child (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 Function Call: uaddCarry(vu2;vu2;vu2; (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:17 move second child to first child (highp uint) +0:17 'u1' (highp uint) +0:17 Function Call: usubBorrow(u1;u1;u1; (highp uint) +0:17 'u1' (highp uint) +0:17 'u1' (highp uint) +0:17 'u1' (highp uint) +0:19 Function Call: umulExtended(vu4;vu4;vu4;vu4; (void) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:21 Function Call: imulExtended(vi4;vi4;vi4;vi4; (void) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:23 move second child to first child (highp int) +0:23 'i1' (highp int) +0:23 Function Call: bitfieldExtract(i1;i1;i1; (highp int) +0:23 'i1' (highp int) +0:23 Constant: +0:23 4 (const int) +0:23 Constant: +0:23 5 (const int) +0:25 move second child to first child (highp 3-component vector of uint) +0:25 'u3' (highp 3-component vector of uint) +0:25 Function Call: bitfieldExtract(vu3;i1;i1; (highp 3-component vector of uint) +0:25 'u3' (highp 3-component vector of uint) +0:25 Constant: +0:25 4 (const int) +0:25 Constant: +0:25 5 (const int) +0:27 move second child to first child (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 Function Call: bitfieldInsert(vi3;vi3;i1;i1; (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 Constant: +0:27 4 (const int) +0:27 Constant: +0:27 5 (const int) +0:28 move second child to first child (highp uint) +0:28 'u1' (highp uint) +0:28 Function Call: bitfieldInsert(u1;u1;i1;i1; (highp uint) +0:28 'u1' (highp uint) +0:28 'u1' (highp uint) +0:28 Constant: +0:28 4 (const int) +0:28 Constant: +0:28 5 (const int) +0:30 move second child to first child (highp 2-component vector of int) +0:30 'i2' (highp 2-component vector of int) +0:30 Function Call: bitfieldReverse(vi2; (highp 2-component vector of int) +0:30 'i2' (highp 2-component vector of int) +0:31 move second child to first child (highp 4-component vector of uint) +0:31 'u4' (highp 4-component vector of uint) +0:31 Function Call: bitfieldReverse(vu4; (highp 4-component vector of uint) +0:31 'u4' (highp 4-component vector of uint) +0:32 move second child to first child (highp int) +0:32 'i1' (highp int) +0:32 Function Call: bitCount(i1; (highp int) +0:32 'i1' (highp int) +0:33 move second child to first child (highp 3-component vector of int) +0:33 'i3' (highp 3-component vector of int) +0:33 Function Call: bitCount(vu3; (highp 3-component vector of int) +0:33 'u3' (highp 3-component vector of uint) +0:34 move second child to first child (highp 2-component vector of int) +0:34 'i2' (highp 2-component vector of int) +0:34 Function Call: findLSB(vi2; (highp 2-component vector of int) +0:34 'i2' (highp 2-component vector of int) +0:35 move second child to first child (highp 4-component vector of int) +0:35 'i4' (highp 4-component vector of int) +0:35 Function Call: findLSB(vu4; (highp 4-component vector of int) +0:35 'u4' (highp 4-component vector of uint) +0:36 move second child to first child (highp int) +0:36 'i1' (highp int) +0:36 Function Call: findMSB(i1; (highp int) +0:36 'i1' (highp int) +0:37 move second child to first child (highp 2-component vector of int) +0:37 'i2' (highp 2-component vector of int) +0:37 Function Call: findMSB(vu2; (highp 2-component vector of int) +0:37 'u2' (highp 2-component vector of uint) 0:? Linker Objects 0:? 's' (shared highp 4-component vector of float) 0:? 'v' (buffer highp 4-component vector of float) @@ -22,10 +113,100 @@ ERROR: node is still EOpNull! Linked vertex stage: -ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point Shader version: 310 ERROR: node is still EOpNull! +0:12 Function Definition: main( (void) +0:12 Function Parameters: +0:? Sequence +0:15 move second child to first child (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 Function Call: uaddCarry(vu2;vu2;vu2; (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:15 'u2' (highp 2-component vector of uint) +0:17 move second child to first child (highp uint) +0:17 'u1' (highp uint) +0:17 Function Call: usubBorrow(u1;u1;u1; (highp uint) +0:17 'u1' (highp uint) +0:17 'u1' (highp uint) +0:17 'u1' (highp uint) +0:19 Function Call: umulExtended(vu4;vu4;vu4;vu4; (void) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:19 'u4' (highp 4-component vector of uint) +0:21 Function Call: imulExtended(vi4;vi4;vi4;vi4; (void) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:21 'i4' (highp 4-component vector of int) +0:23 move second child to first child (highp int) +0:23 'i1' (highp int) +0:23 Function Call: bitfieldExtract(i1;i1;i1; (highp int) +0:23 'i1' (highp int) +0:23 Constant: +0:23 4 (const int) +0:23 Constant: +0:23 5 (const int) +0:25 move second child to first child (highp 3-component vector of uint) +0:25 'u3' (highp 3-component vector of uint) +0:25 Function Call: bitfieldExtract(vu3;i1;i1; (highp 3-component vector of uint) +0:25 'u3' (highp 3-component vector of uint) +0:25 Constant: +0:25 4 (const int) +0:25 Constant: +0:25 5 (const int) +0:27 move second child to first child (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 Function Call: bitfieldInsert(vi3;vi3;i1;i1; (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 'i3' (highp 3-component vector of int) +0:27 Constant: +0:27 4 (const int) +0:27 Constant: +0:27 5 (const int) +0:28 move second child to first child (highp uint) +0:28 'u1' (highp uint) +0:28 Function Call: bitfieldInsert(u1;u1;i1;i1; (highp uint) +0:28 'u1' (highp uint) +0:28 'u1' (highp uint) +0:28 Constant: +0:28 4 (const int) +0:28 Constant: +0:28 5 (const int) +0:30 move second child to first child (highp 2-component vector of int) +0:30 'i2' (highp 2-component vector of int) +0:30 Function Call: bitfieldReverse(vi2; (highp 2-component vector of int) +0:30 'i2' (highp 2-component vector of int) +0:31 move second child to first child (highp 4-component vector of uint) +0:31 'u4' (highp 4-component vector of uint) +0:31 Function Call: bitfieldReverse(vu4; (highp 4-component vector of uint) +0:31 'u4' (highp 4-component vector of uint) +0:32 move second child to first child (highp int) +0:32 'i1' (highp int) +0:32 Function Call: bitCount(i1; (highp int) +0:32 'i1' (highp int) +0:33 move second child to first child (highp 3-component vector of int) +0:33 'i3' (highp 3-component vector of int) +0:33 Function Call: bitCount(vu3; (highp 3-component vector of int) +0:33 'u3' (highp 3-component vector of uint) +0:34 move second child to first child (highp 2-component vector of int) +0:34 'i2' (highp 2-component vector of int) +0:34 Function Call: findLSB(vi2; (highp 2-component vector of int) +0:34 'i2' (highp 2-component vector of int) +0:35 move second child to first child (highp 4-component vector of int) +0:35 'i4' (highp 4-component vector of int) +0:35 Function Call: findLSB(vu4; (highp 4-component vector of int) +0:35 'u4' (highp 4-component vector of uint) +0:36 move second child to first child (highp int) +0:36 'i1' (highp int) +0:36 Function Call: findMSB(i1; (highp int) +0:36 'i1' (highp int) +0:37 move second child to first child (highp 2-component vector of int) +0:37 'i2' (highp 2-component vector of int) +0:37 Function Call: findMSB(vu2; (highp 2-component vector of int) +0:37 'u2' (highp 2-component vector of uint) 0:? Linker Objects 0:? 's' (shared highp 4-component vector of float) 0:? 'v' (buffer highp 4-component vector of float) diff --git a/Test/baseResults/330.frag.out b/Test/baseResults/330.frag.out index 9995e540..e56026b4 100644 --- a/Test/baseResults/330.frag.out +++ b/Test/baseResults/330.frag.out @@ -1,5 +1,4 @@ 330.frag -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. ERROR: 0:27: 'block declaration' : cannot redeclare block: gl_block ERROR: 0:31: 'gl_name' : identifiers starting with "gl_" are reserved ERROR: 0:32: 'gl_i' : identifiers starting with "gl_" are reserved diff --git a/Test/baseResults/330comp.frag.out b/Test/baseResults/330comp.frag.out index 280b5777..e131ee5a 100644 --- a/Test/baseResults/330comp.frag.out +++ b/Test/baseResults/330comp.frag.out @@ -1,5 +1,4 @@ 330comp.frag -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. Shader version: 330 0:? Sequence diff --git a/Test/baseResults/400.geom.out b/Test/baseResults/400.geom.out index a11504f8..b05fd2fb 100644 --- a/Test/baseResults/400.geom.out +++ b/Test/baseResults/400.geom.out @@ -73,6 +73,97 @@ ERROR: node is still EOpNull! 0:50 3 (const int) 0:51 Constant: 0:51 3 (const int) +0:75 Function Definition: bits( (void) +0:75 Function Parameters: +0:? Sequence +0:78 move second child to first child (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 Function Call: uaddCarry(vu2;vu2;vu2; (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:80 move second child to first child (uint) +0:80 'u1' (uint) +0:80 Function Call: usubBorrow(u1;u1;u1; (uint) +0:80 'u1' (uint) +0:80 'u1' (uint) +0:80 'u1' (uint) +0:82 Function Call: umulExtended(vu4;vu4;vu4;vu4; (void) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:84 Function Call: imulExtended(vi4;vi4;vi4;vi4; (void) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:86 move second child to first child (int) +0:86 'i1' (int) +0:86 Function Call: bitfieldExtract(i1;i1;i1; (int) +0:86 'i1' (int) +0:86 Constant: +0:86 4 (const int) +0:86 Constant: +0:86 5 (const int) +0:88 move second child to first child (3-component vector of uint) +0:88 'u3' (3-component vector of uint) +0:88 Function Call: bitfieldExtract(vu3;i1;i1; (3-component vector of uint) +0:88 'u3' (3-component vector of uint) +0:88 Constant: +0:88 4 (const int) +0:88 Constant: +0:88 5 (const int) +0:90 move second child to first child (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 Function Call: bitfieldInsert(vi3;vi3;i1;i1; (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 Constant: +0:90 4 (const int) +0:90 Constant: +0:90 5 (const int) +0:91 move second child to first child (uint) +0:91 'u1' (uint) +0:91 Function Call: bitfieldInsert(u1;u1;i1;i1; (uint) +0:91 'u1' (uint) +0:91 'u1' (uint) +0:91 Constant: +0:91 4 (const int) +0:91 Constant: +0:91 5 (const int) +0:93 move second child to first child (2-component vector of int) +0:93 'i2' (2-component vector of int) +0:93 Function Call: bitfieldReverse(vi2; (2-component vector of int) +0:93 'i2' (2-component vector of int) +0:94 move second child to first child (4-component vector of uint) +0:94 'u4' (4-component vector of uint) +0:94 Function Call: bitfieldReverse(vu4; (4-component vector of uint) +0:94 'u4' (4-component vector of uint) +0:95 move second child to first child (int) +0:95 'i1' (int) +0:95 Function Call: bitCount(i1; (int) +0:95 'i1' (int) +0:96 move second child to first child (3-component vector of int) +0:96 'i3' (3-component vector of int) +0:96 Function Call: bitCount(vu3; (3-component vector of int) +0:96 'u3' (3-component vector of uint) +0:97 move second child to first child (2-component vector of int) +0:97 'i2' (2-component vector of int) +0:97 Function Call: findLSB(vi2; (2-component vector of int) +0:97 'i2' (2-component vector of int) +0:98 move second child to first child (4-component vector of int) +0:98 'i4' (4-component vector of int) +0:98 Function Call: findLSB(vu4; (4-component vector of int) +0:98 'u4' (4-component vector of uint) +0:99 move second child to first child (int) +0:99 'i1' (int) +0:99 Function Call: findMSB(i1; (int) +0:99 'i1' (int) +0:100 move second child to first child (2-component vector of int) +0:100 'i2' (2-component vector of int) +0:100 Function Call: findMSB(vu2; (2-component vector of int) +0:100 'u2' (2-component vector of uint) 0:? Linker Objects 0:? 'bn' (in 3-element array of block{in int a}) 0:? 'gl_in' (in 3-element array of block{in 4-component vector of float gl_Position, in float gl_PointSize}) @@ -147,6 +238,97 @@ ERROR: node is still EOpNull! 0:50 3 (const int) 0:51 Constant: 0:51 3 (const int) +0:75 Function Definition: bits( (void) +0:75 Function Parameters: +0:? Sequence +0:78 move second child to first child (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 Function Call: uaddCarry(vu2;vu2;vu2; (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:78 'u2' (2-component vector of uint) +0:80 move second child to first child (uint) +0:80 'u1' (uint) +0:80 Function Call: usubBorrow(u1;u1;u1; (uint) +0:80 'u1' (uint) +0:80 'u1' (uint) +0:80 'u1' (uint) +0:82 Function Call: umulExtended(vu4;vu4;vu4;vu4; (void) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:82 'u4' (4-component vector of uint) +0:84 Function Call: imulExtended(vi4;vi4;vi4;vi4; (void) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:84 'i4' (4-component vector of int) +0:86 move second child to first child (int) +0:86 'i1' (int) +0:86 Function Call: bitfieldExtract(i1;i1;i1; (int) +0:86 'i1' (int) +0:86 Constant: +0:86 4 (const int) +0:86 Constant: +0:86 5 (const int) +0:88 move second child to first child (3-component vector of uint) +0:88 'u3' (3-component vector of uint) +0:88 Function Call: bitfieldExtract(vu3;i1;i1; (3-component vector of uint) +0:88 'u3' (3-component vector of uint) +0:88 Constant: +0:88 4 (const int) +0:88 Constant: +0:88 5 (const int) +0:90 move second child to first child (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 Function Call: bitfieldInsert(vi3;vi3;i1;i1; (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 'i3' (3-component vector of int) +0:90 Constant: +0:90 4 (const int) +0:90 Constant: +0:90 5 (const int) +0:91 move second child to first child (uint) +0:91 'u1' (uint) +0:91 Function Call: bitfieldInsert(u1;u1;i1;i1; (uint) +0:91 'u1' (uint) +0:91 'u1' (uint) +0:91 Constant: +0:91 4 (const int) +0:91 Constant: +0:91 5 (const int) +0:93 move second child to first child (2-component vector of int) +0:93 'i2' (2-component vector of int) +0:93 Function Call: bitfieldReverse(vi2; (2-component vector of int) +0:93 'i2' (2-component vector of int) +0:94 move second child to first child (4-component vector of uint) +0:94 'u4' (4-component vector of uint) +0:94 Function Call: bitfieldReverse(vu4; (4-component vector of uint) +0:94 'u4' (4-component vector of uint) +0:95 move second child to first child (int) +0:95 'i1' (int) +0:95 Function Call: bitCount(i1; (int) +0:95 'i1' (int) +0:96 move second child to first child (3-component vector of int) +0:96 'i3' (3-component vector of int) +0:96 Function Call: bitCount(vu3; (3-component vector of int) +0:96 'u3' (3-component vector of uint) +0:97 move second child to first child (2-component vector of int) +0:97 'i2' (2-component vector of int) +0:97 Function Call: findLSB(vi2; (2-component vector of int) +0:97 'i2' (2-component vector of int) +0:98 move second child to first child (4-component vector of int) +0:98 'i4' (4-component vector of int) +0:98 Function Call: findLSB(vu4; (4-component vector of int) +0:98 'u4' (4-component vector of uint) +0:99 move second child to first child (int) +0:99 'i1' (int) +0:99 Function Call: findMSB(i1; (int) +0:99 'i1' (int) +0:100 move second child to first child (2-component vector of int) +0:100 'i2' (2-component vector of int) +0:100 Function Call: findMSB(vu2; (2-component vector of int) +0:100 'u2' (2-component vector of uint) 0:? Linker Objects 0:? 'bn' (in 3-element array of block{in int a}) 0:? 'gl_in' (in 3-element array of block{in 4-component vector of float gl_Position, in float gl_PointSize}) diff --git a/Test/baseResults/constErrors.frag.out b/Test/baseResults/constErrors.frag.out index 461bedef..2381b356 100644 --- a/Test/baseResults/constErrors.frag.out +++ b/Test/baseResults/constErrors.frag.out @@ -1,5 +1,4 @@ constErrors.frag -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. ERROR: 0:14: 'non-constant initializer' : not supported for this version or the enabled extensions ERROR: 0:17: '' : constant expression required ERROR: 0:17: '' : array size must be a constant integer expression diff --git a/Test/baseResults/recurse1.vert.out b/Test/baseResults/recurse1.vert.out index 53e651af..292a2511 100644 --- a/Test/baseResults/recurse1.vert.out +++ b/Test/baseResults/recurse1.vert.out @@ -1,5 +1,4 @@ recurse1.vert -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. Shader version: 330 0:? Sequence @@ -70,7 +69,6 @@ Shader version: 330 0:? 'gl_InstanceID' (gl_InstanceId int) recurse1.frag -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. Shader version: 330 0:? Sequence @@ -159,7 +157,6 @@ Shader version: 330 0:? Linker Objects recurse2.frag -Warning, version 330 is not yet complete; most version-specific features are present, but some are missing. Shader version: 330 0:? Sequence diff --git a/Todo.txt b/Todo.txt index ade92f59..5fcdc376 100644 --- a/Todo.txt +++ b/Todo.txt @@ -69,6 +69,17 @@ Shader Functionality to Implement/Finish + implement non-inductive array accesses limitation detection ESSL 3.0 - "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions + ESSL 3.1 + + Compute shaders + + Shader storage buffer objects + - Arrays of arrays + + Atomic counters + + Images + + Separate program objects (also known as separate shader objects) + + Explicit uniform locations + + Texture gather + + Bitfield operations + + Integer mix function GLSL 1.2 + Handle multiple compilation units per stage + Allow initializers on uniform declarations @@ -108,6 +119,9 @@ Shader Functionality to Implement/Finish + Broaden structure usage to include geometry inputs and geometry outputs. + texel offset limit checking + 1.50: geometry shaders: max_vertices must be checked against gl_MaxGeometryOutputVertices (maybe at compile time) + GLSL 3.3 + + Add ARB_explicit_attrib_location extension + + Add ARB_shader_bit_encoding extension GLSL 4.0 + tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization. + patch in, patch out @@ -179,8 +193,8 @@ Shader Functionality to Implement/Finish + The const keyword can be used to declare variables within a function body with initializer expressions that are not constant expressions. + Qualifiers on variable declarations no longer have to follow a strict order. The layout qualifier can be used multiple times, and multiple parameter qualifiers can be used. + Parameter qualifiers can include precision and memory qualifiers. - - Add a new atomic_uint type to support atomic counters. Also, add built-in functions for manipulating atomic counters. - - atomicCounterIncrement, atomicCounterDecrement, and atomicCounter + + Add a new atomic_uint type to support atomic counters. Also, add built-in functions for manipulating atomic counters. + + atomicCounterIncrement, atomicCounterDecrement, and atomicCounter - Add layout qualifier identifiers binding and offset to bind units to sampler and image variable declarations, atomic counters, and uniform blocks. - Add built-in functions to pack/unpack 16 bit floating-point numbers (ARB_shading_language_pack2f). - packHalf2x16 and unpackHalf2x16 @@ -196,11 +210,12 @@ Shader Functionality to Implement/Finish + Use vec2 instead of vec3 for coordinate in textureGather*(sampler2DRect,...). + Clarify that textureGatherOffset() can take non-constants for the offsets. GLSL 4.3 - - Add shader storage buffer objects, as per the ARB_shader_storage_buffer_object extension. This includes + + Add shader storage buffer objects, as per the ARB_shader_storage_buffer_object extension. This includes + allowing the last member of a storage buffer block to be an array that does not know its size until render time - - read/write memory shared with the application and other shader invocations + + read/write memory shared with the application and other shader invocations + adding the std430 layout qualifier for shader storage blocks - - add atomic built-ins + + add atomic built-ins + + layout(binding=) - Allow .length() on all arrays; returning a compile-time constant or not, depending on how the array is sized, as per the ARB_shader_storage_buffer_object extension. - Be clear that implicit array sizing is only within a stage, not cross stage. @@ -250,4 +265,15 @@ Shader Functionality to Implement/Finish transform feedback buffering. + Bug 10530: To be consistent with ES, include sample types as valid in a precision statement. Note the defaults are irrelevant, as precision qualifiers are not required or have any meaning. - + GLSL 4.5 + + Incorporate the ARB_ES3_1_compatibility extension + + Supports OpenGL ES 310 shaders. + + Adds imageAtomicExchange() built-in function for floating-point images. + + Adds coherent to atomic and image-atomic built-in function parameters. + + Adds gl_HelperInvocation built-in variable to say whether a fragment shader invocation is + only as a helper, so the shader can skip code not needed or harmful when in a helper invocation. + + Adds gl_MaxSamplesbuilt-in constant, and several other built-in constants. + + Adds mix() built-in functions for selection of int, uint, andbool components. + + Incorporate the GL_ARB_shader_texture_image_samples extension to query how many samples are in a multi-sample texture or image. + + Incorporate the GL_ARB_cull_distance extensions to add the built-in variable gl_CullDistance[] , which will cull whole primitives. + + Incorporate the GL_ARB_derivative_control extension diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 1a354de1..a5420909 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -804,6 +804,93 @@ void TBuiltIns::initialize(int version, EProfile profile) "\n"); } + // Bitfield + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 400)) { + commonBuiltins.append( + " uint uaddCarry( uint, uint, out uint carry);" + "uvec2 uaddCarry(uvec2, uvec2, out uvec2 carry);" + "uvec3 uaddCarry(uvec3, uvec3, out uvec3 carry);" + "uvec4 uaddCarry(uvec4, uvec4, out uvec4 carry);" + + " uint usubBorrow( uint, uint, out uint borrow);" + "uvec2 usubBorrow(uvec2, uvec2, out uvec2 borrow);" + "uvec3 usubBorrow(uvec3, uvec3, out uvec3 borrow);" + "uvec4 usubBorrow(uvec4, uvec4, out uvec4 borrow);" + + "void umulExtended( uint, uint, out uint, out uint lsb);" + "void umulExtended(uvec2, uvec2, out uvec2, out uvec2 lsb);" + "void umulExtended(uvec3, uvec3, out uvec3, out uvec3 lsb);" + "void umulExtended(uvec4, uvec4, out uvec4, out uvec4 lsb);" + + "void imulExtended( int, int, out int, out int lsb);" + "void imulExtended(ivec2, ivec2, out ivec2, out ivec2 lsb);" + "void imulExtended(ivec3, ivec3, out ivec3, out ivec3 lsb);" + "void imulExtended(ivec4, ivec4, out ivec4, out ivec4 lsb);" + + " int bitfieldExtract( int, int, int);" + "ivec2 bitfieldExtract(ivec2, int, int);" + "ivec3 bitfieldExtract(ivec3, int, int);" + "ivec4 bitfieldExtract(ivec4, int, int);" + + " uint bitfieldExtract( uint, int, int);" + "uvec2 bitfieldExtract(uvec2, int, int);" + "uvec3 bitfieldExtract(uvec3, int, int);" + "uvec4 bitfieldExtract(uvec4, int, int);" + + " int bitfieldInsert( int base, int, int, int);" + "ivec2 bitfieldInsert(ivec2 base, ivec2, int, int);" + "ivec3 bitfieldInsert(ivec3 base, ivec3, int, int);" + "ivec4 bitfieldInsert(ivec4 base, ivec4, int, int);" + + " uint bitfieldInsert( uint base, uint, int, int);" + "uvec2 bitfieldInsert(uvec2 base, uvec2, int, int);" + "uvec3 bitfieldInsert(uvec3 base, uvec3, int, int);" + "uvec4 bitfieldInsert(uvec4 base, uvec4, int, int);" + + " int bitfieldReverse( int);" + "ivec2 bitfieldReverse(ivec2);" + "ivec3 bitfieldReverse(ivec3);" + "ivec4 bitfieldReverse(ivec4);" + + " uint bitfieldReverse( uint);" + "uvec2 bitfieldReverse(uvec2);" + "uvec3 bitfieldReverse(uvec3);" + "uvec4 bitfieldReverse(uvec4);" + + " int bitCount( int);" + "ivec2 bitCount(ivec2);" + "ivec3 bitCount(ivec3);" + "ivec4 bitCount(ivec4);" + + " int bitCount( uint);" + "ivec2 bitCount(uvec2);" + "ivec3 bitCount(uvec3);" + "ivec4 bitCount(uvec4);" + + " int findLSB( int);" + "ivec2 findLSB(ivec2);" + "ivec3 findLSB(ivec3);" + "ivec4 findLSB(ivec4);" + + " int findLSB( uint);" + "ivec2 findLSB(uvec2);" + "ivec3 findLSB(uvec3);" + "ivec4 findLSB(uvec4);" + + " int findMSB( int);" + "ivec2 findMSB(ivec2);" + "ivec3 findMSB(ivec3);" + "ivec4 findMSB(ivec4);" + + " int findMSB( uint);" + "ivec2 findMSB(uvec2);" + "ivec3 findMSB(uvec3);" + "ivec4 findMSB(uvec4);" + + "\n"); + } + //============================================================================ // // Prototypes for built-in functions seen by vertex shaders only. @@ -2556,7 +2643,6 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb break; case EShLangCompute: - // TODO: 4.3 desktop functionality: compute special variables break; default: diff --git a/glslang/MachineIndependent/IntermTraverse.cpp b/glslang/MachineIndependent/IntermTraverse.cpp index 28f8da8c..3bca44d2 100644 --- a/glslang/MachineIndependent/IntermTraverse.cpp +++ b/glslang/MachineIndependent/IntermTraverse.cpp @@ -58,9 +58,7 @@ namespace glslang { // void TIntermMethod::traverse(TIntermTraverser* it) { - // Tree should always resolve all methods as constants - - // TODO: 4.3 functionality: some .length() will stay as methods + // Tree should always resolve all methods as a non-method. } void TIntermSymbol::traverse(TIntermTraverser *it) diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index 4d3f2247..cdde0993 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -396,11 +396,11 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo case 130: case 140: case 150: + case 330: // versions are complete break; case 310: - case 330: case 400: case 410: case 420: