Implement frexp, ldexp, packUnorm2x16, unpackUnorm2x16, packUnorm4x8, packSnorm4x8, unpackUnorm4x8, unpackSnorm4x8, and unpackDouble2x32().

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27738 e7fa87d3-cd2b-0410-9028-fcbf551c1848
diff --git a/Test/310.vert b/Test/310.vert
index f97acae..d4d710f 100644
--- a/Test/310.vert
+++ b/Test/310.vert
@@ -35,4 +35,15 @@
     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 8f83b1c..f8ca8f5 100644
--- a/Test/400.frag
+++ b/Test/400.frag
@@ -82,4 +82,20 @@
     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 fc82193..77d6851 100644
--- a/Test/baseResults/310.vert.out
+++ b/Test/baseResults/310.vert.out
@@ -100,6 +100,32 @@
 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 @@
 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 7a10db1..a66909e 100644
--- a/Test/baseResults/400.frag.out
+++ b/Test/baseResults/400.frag.out
@@ -264,6 +264,40 @@
 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 @@
 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 be174af..9848a64 100644
--- a/Todo.txt
+++ b/Todo.txt
@@ -83,8 +83,8 @@
       - 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 @@
       - 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 a542090..4a53a42 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -492,16 +492,59 @@
             "\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");
     }