Implement frexp, ldexp, packUnorm2x16, unpackUnorm2x16, packUnorm4x8, packSnorm4x8...
authorJohn Kessenich <cepheus@frii.com>
Thu, 14 Aug 2014 19:45:52 +0000 (19:45 +0000)
committerJohn Kessenich <cepheus@frii.com>
Thu, 14 Aug 2014 19:45:52 +0000 (19:45 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27738 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/310.vert
Test/400.frag
Test/baseResults/310.vert.out
Test/baseResults/400.frag.out
Todo.txt
glslang/MachineIndependent/Initialize.cpp

index f97acae..d4d710f 100644 (file)
@@ -35,4 +35,15 @@ void main()
     i4 = findLSB(u4);\r
     i1 = findMSB(i1);\r
     i2 = findMSB(u2);\r
+\r
+    vec3 v3;\r
+    v3 = frexp(v3, i3);\r
+    vec2 v2;\r
+    v2 = ldexp(v2, i2);\r
+\r
+    mediump vec4 v4;\r
+    u1 = packUnorm4x8(v4);\r
+    u1 = packSnorm4x8(v4);\r
+    v4 = unpackUnorm4x8(u1);\r
+    v4 = unpackSnorm4x8(u1);\r
 }\r
index 8f83b1c..f8ca8f5 100644 (file)
@@ -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);
 }
index fc82193..77d6851 100644 (file)
@@ -100,6 +100,32 @@ ERROR: node is still EOpNull!
 0:37        'i2' (highp 2-component vector of int)\r
 0:37        Function Call: findMSB(vu2; (highp 2-component vector of int)\r
 0:37          'u2' (highp 2-component vector of uint)\r
+0:40      move second child to first child (highp 3-component vector of float)\r
+0:40        'v3' (highp 3-component vector of float)\r
+0:40        Function Call: frexp(vf3;vi3; (highp 3-component vector of float)\r
+0:40          'v3' (highp 3-component vector of float)\r
+0:40          'i3' (highp 3-component vector of int)\r
+0:42      move second child to first child (highp 2-component vector of float)\r
+0:42        'v2' (highp 2-component vector of float)\r
+0:42        Function Call: ldexp(vf2;vi2; (highp 2-component vector of float)\r
+0:42          'v2' (highp 2-component vector of float)\r
+0:42          'i2' (highp 2-component vector of int)\r
+0:45      move second child to first child (highp uint)\r
+0:45        'u1' (highp uint)\r
+0:45        Function Call: packUnorm4x8(vf4; (highp uint)\r
+0:45          'v4' (mediump 4-component vector of float)\r
+0:46      move second child to first child (highp uint)\r
+0:46        'u1' (highp uint)\r
+0:46        Function Call: packSnorm4x8(vf4; (highp uint)\r
+0:46          'v4' (mediump 4-component vector of float)\r
+0:47      move second child to first child (mediump 4-component vector of float)\r
+0:47        'v4' (mediump 4-component vector of float)\r
+0:47        Function Call: unpackUnorm4x8(u1; (mediump 4-component vector of float)\r
+0:47          'u1' (highp uint)\r
+0:48      move second child to first child (mediump 4-component vector of float)\r
+0:48        'v4' (mediump 4-component vector of float)\r
+0:48        Function Call: unpackSnorm4x8(u1; (mediump 4-component vector of float)\r
+0:48          'u1' (highp uint)\r
 0:?   Linker Objects\r
 0:?     's' (shared highp 4-component vector of float)\r
 0:?     'v' (buffer highp 4-component vector of float)\r
@@ -207,6 +233,32 @@ ERROR: node is still EOpNull!
 0:37        'i2' (highp 2-component vector of int)\r
 0:37        Function Call: findMSB(vu2; (highp 2-component vector of int)\r
 0:37          'u2' (highp 2-component vector of uint)\r
+0:40      move second child to first child (highp 3-component vector of float)\r
+0:40        'v3' (highp 3-component vector of float)\r
+0:40        Function Call: frexp(vf3;vi3; (highp 3-component vector of float)\r
+0:40          'v3' (highp 3-component vector of float)\r
+0:40          'i3' (highp 3-component vector of int)\r
+0:42      move second child to first child (highp 2-component vector of float)\r
+0:42        'v2' (highp 2-component vector of float)\r
+0:42        Function Call: ldexp(vf2;vi2; (highp 2-component vector of float)\r
+0:42          'v2' (highp 2-component vector of float)\r
+0:42          'i2' (highp 2-component vector of int)\r
+0:45      move second child to first child (highp uint)\r
+0:45        'u1' (highp uint)\r
+0:45        Function Call: packUnorm4x8(vf4; (highp uint)\r
+0:45          'v4' (mediump 4-component vector of float)\r
+0:46      move second child to first child (highp uint)\r
+0:46        'u1' (highp uint)\r
+0:46        Function Call: packSnorm4x8(vf4; (highp uint)\r
+0:46          'v4' (mediump 4-component vector of float)\r
+0:47      move second child to first child (mediump 4-component vector of float)\r
+0:47        'v4' (mediump 4-component vector of float)\r
+0:47        Function Call: unpackUnorm4x8(u1; (mediump 4-component vector of float)\r
+0:47          'u1' (highp uint)\r
+0:48      move second child to first child (mediump 4-component vector of float)\r
+0:48        'v4' (mediump 4-component vector of float)\r
+0:48        Function Call: unpackSnorm4x8(u1; (mediump 4-component vector of float)\r
+0:48          'u1' (highp uint)\r
 0:?   Linker Objects\r
 0:?     's' (shared highp 4-component vector of float)\r
 0:?     'v' (buffer highp 4-component vector of float)\r
index 7a10db1..a66909e 100644 (file)
@@ -264,6 +264,40 @@ ERROR: node is still EOpNull!
 0:84              'in4' (smooth in 4-component vector of float)\r
 0:84            fwidthFine (4-component vector of float)\r
 0:84              'in4' (smooth in 4-component vector of float)\r
+0:89      move second child to first child (2-component vector of float)\r
+0:89        'v2' (2-component vector of float)\r
+0:89        Function Call: frexp(vf2;vi2; (2-component vector of float)\r
+0:89          'v2' (2-component vector of float)\r
+0:89          'i2' (2-component vector of int)\r
+0:90      move second child to first child (3-component vector of float)\r
+0:90        'v3' (3-component vector of float)\r
+0:90        Function Call: ldexp(vf3;vi3; (3-component vector of float)\r
+0:90          'v3' (3-component vector of float)\r
+0:90          'i3' (3-component vector of int)\r
+0:92      move second child to first child (uint)\r
+0:92        'u1' (uint)\r
+0:92        Function Call: packUnorm4x8(vf4; (uint)\r
+0:92          'v4' (4-component vector of float)\r
+0:93      move second child to first child (uint)\r
+0:93        'u1' (uint)\r
+0:93        Function Call: packSnorm4x8(vf4; (uint)\r
+0:93          'v4' (4-component vector of float)\r
+0:94      move second child to first child (4-component vector of float)\r
+0:94        'v4' (4-component vector of float)\r
+0:94        Function Call: unpackUnorm4x8(u1; (4-component vector of float)\r
+0:94          'u1' (uint)\r
+0:95      move second child to first child (4-component vector of float)\r
+0:95        'v4' (4-component vector of float)\r
+0:95        Function Call: unpackSnorm4x8(u1; (4-component vector of float)\r
+0:95          'u1' (uint)\r
+0:99      move second child to first child (double)\r
+0:99        'd' (double)\r
+0:99        Function Call: packDouble2x32(vu2; (double)\r
+0:99          'u2' (2-component vector of uint)\r
+0:100      move second child to first child (2-component vector of uint)\r
+0:100        'u2' (2-component vector of uint)\r
+0:100        Function Call: unpackDouble2x32(d1; (2-component vector of uint)\r
+0:100          'd' (double)\r
 0:?   Linker Objects\r
 0:?     'c2D' (smooth in 2-component vector of float)\r
 0:?     'i' (flat in int)\r
@@ -533,6 +567,40 @@ ERROR: node is still EOpNull!
 0:84              'in4' (smooth in 4-component vector of float)\r
 0:84            fwidthFine (4-component vector of float)\r
 0:84              'in4' (smooth in 4-component vector of float)\r
+0:89      move second child to first child (2-component vector of float)\r
+0:89        'v2' (2-component vector of float)\r
+0:89        Function Call: frexp(vf2;vi2; (2-component vector of float)\r
+0:89          'v2' (2-component vector of float)\r
+0:89          'i2' (2-component vector of int)\r
+0:90      move second child to first child (3-component vector of float)\r
+0:90        'v3' (3-component vector of float)\r
+0:90        Function Call: ldexp(vf3;vi3; (3-component vector of float)\r
+0:90          'v3' (3-component vector of float)\r
+0:90          'i3' (3-component vector of int)\r
+0:92      move second child to first child (uint)\r
+0:92        'u1' (uint)\r
+0:92        Function Call: packUnorm4x8(vf4; (uint)\r
+0:92          'v4' (4-component vector of float)\r
+0:93      move second child to first child (uint)\r
+0:93        'u1' (uint)\r
+0:93        Function Call: packSnorm4x8(vf4; (uint)\r
+0:93          'v4' (4-component vector of float)\r
+0:94      move second child to first child (4-component vector of float)\r
+0:94        'v4' (4-component vector of float)\r
+0:94        Function Call: unpackUnorm4x8(u1; (4-component vector of float)\r
+0:94          'u1' (uint)\r
+0:95      move second child to first child (4-component vector of float)\r
+0:95        'v4' (4-component vector of float)\r
+0:95        Function Call: unpackSnorm4x8(u1; (4-component vector of float)\r
+0:95          'u1' (uint)\r
+0:99      move second child to first child (double)\r
+0:99        'd' (double)\r
+0:99        Function Call: packDouble2x32(vu2; (double)\r
+0:99          'u2' (2-component vector of uint)\r
+0:100      move second child to first child (2-component vector of uint)\r
+0:100        'u2' (2-component vector of uint)\r
+0:100        Function Call: unpackDouble2x32(d1; (2-component vector of uint)\r
+0:100          'd' (double)\r
 0:?   Linker Objects\r
 0:?     'c2D' (smooth in 2-component vector of float)\r
 0:?     'i' (flat in int)\r
index be174af..9848a64 100644 (file)
--- 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 \93a * b + c\94 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.
index a542090..4a53a42 100644 (file)
@@ -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");
     }