diff --git a/Test/310.vert b/Test/310.vert index f97acae66c883c077b0ea14102828d7a7a03cb49..d4d710f29b2b5bcd700f244c9c99b9617e222a7a 100644 --- a/Test/310.vert +++ b/Test/310.vert @@ -35,4 +35,15 @@ void main() i4 = findLSB(u4); i1 = findMSB(i1); i2 = findMSB(u2); + + vec3 v3; + v3 = frexp(v3, i3); + vec2 v2; + v2 = ldexp(v2, i2); + + mediump vec4 v4; + u1 = packUnorm4x8(v4); + u1 = packSnorm4x8(v4); + v4 = unpackUnorm4x8(u1); + v4 = unpackSnorm4x8(u1); } diff --git a/Test/400.frag b/Test/400.frag index 8f83b1c4812e7c2a4be7a9bc07270a64d8420b17..f8ca8f526ed79110ae35c5ebf9641d6f07896784 100644 --- a/Test/400.frag +++ b/Test/400.frag @@ -82,4 +82,20 @@ void foodc2() vec2 v2 = dFdxFine(in2); vec3 v3 = dFdyCoarse(in3); vec4 v4 = fwidthCoarse(in4) + fwidthFine(in4); + + uint u1; + ivec3 i3; + ivec2 i2; + v2 = frexp(v2, i2); + v3 = ldexp(v3, i3); + + u1 = packUnorm4x8(v4); + u1 = packSnorm4x8(v4); + v4 = unpackUnorm4x8(u1); + v4 = unpackSnorm4x8(u1); + + double d; + uvec2 u2; + d = packDouble2x32(u2); + u2 = unpackDouble2x32(d); } diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index fc82193b63e5b79d225adb8a1e0eb29bb553cda3..77d68518a8dc8f4b7a113b547589114d97a57786 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -100,6 +100,32 @@ ERROR: node is still EOpNull! 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:40 move second child to first child (highp 3-component vector of float) +0:40 'v3' (highp 3-component vector of float) +0:40 Function Call: frexp(vf3;vi3; (highp 3-component vector of float) +0:40 'v3' (highp 3-component vector of float) +0:40 'i3' (highp 3-component vector of int) +0:42 move second child to first child (highp 2-component vector of float) +0:42 'v2' (highp 2-component vector of float) +0:42 Function Call: ldexp(vf2;vi2; (highp 2-component vector of float) +0:42 'v2' (highp 2-component vector of float) +0:42 'i2' (highp 2-component vector of int) +0:45 move second child to first child (highp uint) +0:45 'u1' (highp uint) +0:45 Function Call: packUnorm4x8(vf4; (highp uint) +0:45 'v4' (mediump 4-component vector of float) +0:46 move second child to first child (highp uint) +0:46 'u1' (highp uint) +0:46 Function Call: packSnorm4x8(vf4; (highp uint) +0:46 'v4' (mediump 4-component vector of float) +0:47 move second child to first child (mediump 4-component vector of float) +0:47 'v4' (mediump 4-component vector of float) +0:47 Function Call: unpackUnorm4x8(u1; (mediump 4-component vector of float) +0:47 'u1' (highp uint) +0:48 move second child to first child (mediump 4-component vector of float) +0:48 'v4' (mediump 4-component vector of float) +0:48 Function Call: unpackSnorm4x8(u1; (mediump 4-component vector of float) +0:48 'u1' (highp uint) 0:? Linker Objects 0:? 's' (shared highp 4-component vector of float) 0:? 'v' (buffer highp 4-component vector of float) @@ -207,6 +233,32 @@ ERROR: node is still EOpNull! 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:40 move second child to first child (highp 3-component vector of float) +0:40 'v3' (highp 3-component vector of float) +0:40 Function Call: frexp(vf3;vi3; (highp 3-component vector of float) +0:40 'v3' (highp 3-component vector of float) +0:40 'i3' (highp 3-component vector of int) +0:42 move second child to first child (highp 2-component vector of float) +0:42 'v2' (highp 2-component vector of float) +0:42 Function Call: ldexp(vf2;vi2; (highp 2-component vector of float) +0:42 'v2' (highp 2-component vector of float) +0:42 'i2' (highp 2-component vector of int) +0:45 move second child to first child (highp uint) +0:45 'u1' (highp uint) +0:45 Function Call: packUnorm4x8(vf4; (highp uint) +0:45 'v4' (mediump 4-component vector of float) +0:46 move second child to first child (highp uint) +0:46 'u1' (highp uint) +0:46 Function Call: packSnorm4x8(vf4; (highp uint) +0:46 'v4' (mediump 4-component vector of float) +0:47 move second child to first child (mediump 4-component vector of float) +0:47 'v4' (mediump 4-component vector of float) +0:47 Function Call: unpackUnorm4x8(u1; (mediump 4-component vector of float) +0:47 'u1' (highp uint) +0:48 move second child to first child (mediump 4-component vector of float) +0:48 'v4' (mediump 4-component vector of float) +0:48 Function Call: unpackSnorm4x8(u1; (mediump 4-component vector of float) +0:48 'u1' (highp 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/400.frag.out b/Test/baseResults/400.frag.out index 7a10db15e060372dee5154eae2b4fa8fb3146412..a66909ec7dc2ecb7ec4d0154ba606fcf0979bc9c 100644 --- a/Test/baseResults/400.frag.out +++ b/Test/baseResults/400.frag.out @@ -264,6 +264,40 @@ ERROR: node is still EOpNull! 0:84 'in4' (smooth in 4-component vector of float) 0:84 fwidthFine (4-component vector of float) 0:84 'in4' (smooth in 4-component vector of float) +0:89 move second child to first child (2-component vector of float) +0:89 'v2' (2-component vector of float) +0:89 Function Call: frexp(vf2;vi2; (2-component vector of float) +0:89 'v2' (2-component vector of float) +0:89 'i2' (2-component vector of int) +0:90 move second child to first child (3-component vector of float) +0:90 'v3' (3-component vector of float) +0:90 Function Call: ldexp(vf3;vi3; (3-component vector of float) +0:90 'v3' (3-component vector of float) +0:90 'i3' (3-component vector of int) +0:92 move second child to first child (uint) +0:92 'u1' (uint) +0:92 Function Call: packUnorm4x8(vf4; (uint) +0:92 'v4' (4-component vector of float) +0:93 move second child to first child (uint) +0:93 'u1' (uint) +0:93 Function Call: packSnorm4x8(vf4; (uint) +0:93 'v4' (4-component vector of float) +0:94 move second child to first child (4-component vector of float) +0:94 'v4' (4-component vector of float) +0:94 Function Call: unpackUnorm4x8(u1; (4-component vector of float) +0:94 'u1' (uint) +0:95 move second child to first child (4-component vector of float) +0:95 'v4' (4-component vector of float) +0:95 Function Call: unpackSnorm4x8(u1; (4-component vector of float) +0:95 'u1' (uint) +0:99 move second child to first child (double) +0:99 'd' (double) +0:99 Function Call: packDouble2x32(vu2; (double) +0:99 'u2' (2-component vector of uint) +0:100 move second child to first child (2-component vector of uint) +0:100 'u2' (2-component vector of uint) +0:100 Function Call: unpackDouble2x32(d1; (2-component vector of uint) +0:100 'd' (double) 0:? Linker Objects 0:? 'c2D' (smooth in 2-component vector of float) 0:? 'i' (flat in int) @@ -533,6 +567,40 @@ ERROR: node is still EOpNull! 0:84 'in4' (smooth in 4-component vector of float) 0:84 fwidthFine (4-component vector of float) 0:84 'in4' (smooth in 4-component vector of float) +0:89 move second child to first child (2-component vector of float) +0:89 'v2' (2-component vector of float) +0:89 Function Call: frexp(vf2;vi2; (2-component vector of float) +0:89 'v2' (2-component vector of float) +0:89 'i2' (2-component vector of int) +0:90 move second child to first child (3-component vector of float) +0:90 'v3' (3-component vector of float) +0:90 Function Call: ldexp(vf3;vi3; (3-component vector of float) +0:90 'v3' (3-component vector of float) +0:90 'i3' (3-component vector of int) +0:92 move second child to first child (uint) +0:92 'u1' (uint) +0:92 Function Call: packUnorm4x8(vf4; (uint) +0:92 'v4' (4-component vector of float) +0:93 move second child to first child (uint) +0:93 'u1' (uint) +0:93 Function Call: packSnorm4x8(vf4; (uint) +0:93 'v4' (4-component vector of float) +0:94 move second child to first child (4-component vector of float) +0:94 'v4' (4-component vector of float) +0:94 Function Call: unpackUnorm4x8(u1; (4-component vector of float) +0:94 'u1' (uint) +0:95 move second child to first child (4-component vector of float) +0:95 'v4' (4-component vector of float) +0:95 Function Call: unpackSnorm4x8(u1; (4-component vector of float) +0:95 'u1' (uint) +0:99 move second child to first child (double) +0:99 'd' (double) +0:99 Function Call: packDouble2x32(vu2; (double) +0:99 'u2' (2-component vector of uint) +0:100 move second child to first child (2-component vector of uint) +0:100 'u2' (2-component vector of uint) +0:100 Function Call: unpackDouble2x32(d1; (2-component vector of uint) +0:100 'd' (double) 0:? Linker Objects 0:? 'c2D' (smooth in 2-component vector of float) 0:? 'i' (flat in int) diff --git a/Todo.txt b/Todo.txt index be174afaa4d91de25394cf7ef8be044c8a2046df..9848a64ca6e942b4683bdd54da5c527d991af5e9 100644 --- a/Todo.txt +++ b/Todo.txt @@ -83,8 +83,8 @@ Shader Functionality to Implement/Finish - overlapping bindings - offset post incrementing - overlapping offsets - - frexp/ldexp - - packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8() + + frexp/ldexp + + packUnorm4x8(),packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8() - 2DMS samplers and images - inheritance of memory qualifiers in block members GLSL 1.2 @@ -148,17 +148,17 @@ Shader Functionality to Implement/Finish - Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset(). - New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision. - Add a fused multiply and add built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.) - - Added new built-in floating-point functions - - frexp() and ldexp() + + Added new built-in floating-point functions + + frexp() and ldexp() + packUnorm2x16(), unpackUnorm2x16(), - - packUnorm4x8(),packSnorm4x8(), and packDouble2x32() - - unpackUnorm4x8(),unpackSnorm4x8(), and unpackDouble2x32() - - Add new built-in integer functions - - uaddCarry() andusubBorrow() - - umulExtended() andimulExtended() - - bitfieldExtract() andbitfieldInsert() - - bitfieldReverse() - - bitCount(),findLSB(), andfindMSB() + + packUnorm4x8(), packSnorm4x8(), unpackUnorm4x8(), unpackSnorm4x8() + + packDouble2x32() and unpackDouble2x32() + + Add new built-in integer functions + + uaddCarry() and usubBorrow() + + umulExtended() and imulExtended() + + bitfieldExtract() and bitfieldInsert() + + bitfieldReverse() + + bitCount(), findLSB(), andfindMSB() - New built-in to query LOD, textureQueryLod(). - New overloaded function matching algorithm, handling selection from many valid multiple choices. + Texture gather functions that return four texels with a single call. diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index a54209093f00e595f9d856d5117faff1d570c3f7..4a53a42b7e6f7a13dc41882bfbad885c2ebdeadc 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -492,16 +492,59 @@ void TBuiltIns::initialize(int version, EProfile profile) "\n"); } + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 400)) { + commonBuiltins.append( + "highp float frexp(highp float, out highp int);" + "highp vec2 frexp(highp vec2, out highp ivec2);" + "highp vec3 frexp(highp vec3, out highp ivec3);" + "highp vec4 frexp(highp vec4, out highp ivec4);" + + "highp float ldexp(highp float, highp int);" + "highp vec2 ldexp(highp vec2, highp ivec2);" + "highp vec3 ldexp(highp vec3, highp ivec3);" + "highp vec4 ldexp(highp vec4, highp ivec4);" + + "\n"); + } + + if (profile != EEsProfile && version >= 400) { + commonBuiltins.append( + "double frexp(double, out int);" + "dvec2 frexp( dvec2, out ivec2);" + "dvec3 frexp( dvec3, out ivec3);" + "dvec4 frexp( dvec4, out ivec4);" + + "double ldexp(double, int);" + "dvec2 ldexp( dvec2, ivec2);" + "dvec3 ldexp( dvec3, ivec3);" + "dvec4 ldexp( dvec4, ivec4);" + + "double packDouble2x32(uvec2);" + "uvec2 unpackDouble2x32(double);" + + "\n"); + } + if ((profile == EEsProfile && version >= 300) || (profile != EEsProfile && version >= 400)) { commonBuiltins.append( - "highp uint packSnorm2x16 (vec2);" - "highp vec2 unpackSnorm2x16 (highp uint);" - "highp uint packUnorm2x16 (vec2);" - "highp vec2 unpackUnorm2x16 (highp uint);" + "highp uint packSnorm2x16(vec2);" + "highp vec2 unpackSnorm2x16(highp uint);" + "highp uint packUnorm2x16(vec2);" + "highp vec2 unpackUnorm2x16(highp uint);" "highp uint packHalf2x16(mediump vec2);" "mediump vec2 unpackHalf2x16(highp uint);" - + "\n"); + } + + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 400)) { + commonBuiltins.append( + "highp uint packSnorm4x8 (mediump vec4);" + "mediump vec4 unpackSnorm4x8(highp uint);" + "highp uint packUnorm4x8 (mediump vec4);" + "mediump vec4 unpackUnorm4x8(highp uint);" "\n"); }