Bladeren bron

web: Fix accidental additon of refract() prototypes and update README.

John Kessenich 6 jaren geleden
bovenliggende
commit
369ffa9543
3 gewijzigde bestanden met toevoegingen van 23 en 11 verwijderingen
  1. 9 2
      README.md
  2. 3 3
      Test/baseResults/spv.specConstant.vert.out
  3. 11 6
      glslang/MachineIndependent/Initialize.cpp

+ 9 - 2
README.md

@@ -155,17 +155,24 @@ changes are quite infrequent. For windows you can get binaries from
 The command to rebuild is:
 
 ```bash
+m4 -P MachineIndependent/glslang.m4 > MachineIndependent/glslang.y
 bison --defines=MachineIndependent/glslang_tab.cpp.h
       -t MachineIndependent/glslang.y
       -o MachineIndependent/glslang_tab.cpp
 ```
 
-The above command is also available in the bash script at
-`glslang/updateGrammar`.
+The above commands are also available in the bash script in `updateGrammar`,
+when executed from the glslang subdirectory of the glslang repository.
+With no arguments it builds the full grammar, and with a "web" argument,
+the web grammar subset (see more about the web subset in the next section).
 
 ### WASM for the the Web
 
 Use the steps in [Build Steps](#build-steps), which following notes/exceptions:
+* For building the web subset of core glslang:
+  + `m4` also needs a `-DGLSLANG_WEB` argument, or simply execute `updateGrammar web` from the glslang subdirectory
+  + turn off the CMAKE options for `BUILD_TESTING`, `ENABLE_OPT`, and `INSTALL_GTEST`,
+    while turning on `ENABLE_GLSLANG_WEB`
 * `emsdk` needs to be present in your executable search path, *PATH* for
   Bash-like enivironments
   + Instructions located

+ 3 - 3
Test/baseResults/spv.specConstant.vert.out

@@ -11,7 +11,7 @@ spv.specConstant.vert
                               Source GLSL 400
                               Name 4  "main"
                               Name 9  "arraySize"
-                              Name 14  "foo(vf4[s2772];"
+                              Name 14  "foo(vf4[s2769];"
                               Name 13  "p"
                               Name 17  "builtin_spec_constant("
                               Name 20  "color"
@@ -102,10 +102,10 @@ spv.specConstant.vert
                               Store 20(color) 46
               48:          10 Load 22(ucol)
                               Store 47(param) 48
-              49:           2 FunctionCall 14(foo(vf4[s2772];) 47(param)
+              49:           2 FunctionCall 14(foo(vf4[s2769];) 47(param)
                               Return
                               FunctionEnd
-14(foo(vf4[s2772];):           2 Function None 12
+14(foo(vf4[s2769];):           2 Function None 12
            13(p):     11(ptr) FunctionParameter
               15:             Label
               54:     24(ptr) AccessChain 53(dupUcol) 23

+ 11 - 6
glslang/MachineIndependent/Initialize.cpp

@@ -107,7 +107,8 @@ const ArgType TypeIU  = static_cast<ArgType>(TypeI | TypeU);
 // output, or other unusual situations.
 enum ArgClass {
     ClassRegular = 0,    // nothing special, just all vector widths with matching return type; traditional arithmetic
-    ClassLS   = 1 << 1,  // the last argument is also held fixed as a (type-matched) scalar while the others cycle
+    ClassLS   = 1 << 0,  // the last argument is also held fixed as a (type-matched) scalar while the others cycle
+    ClassXLS  = 1 << 1,  // the last argument is exclusively a (type-matched) scalar while the others cycle
     ClassLS2  = 1 << 2,  // the last two arguments are held fixed as a (type-matched) scalar while the others cycle
     ClassFS   = 1 << 3,  // the first argument is held fixed as a (type-matched) scalar while the others cycle
     ClassFS2  = 1 << 4,  // the first two arguments are held fixed as a (type-matched) scalar while the others cycle
@@ -217,7 +218,7 @@ const BuiltInFunction BaseFunctions[] = {
     { EOpNormalize,        "normalize",        1,   TypeF,     ClassRegular, nullptr },
     { EOpFaceForward,      "faceforward",      3,   TypeF,     ClassRegular, nullptr },
     { EOpReflect,          "reflect",          2,   TypeF,     ClassRegular, nullptr },
-    { EOpRefract,          "refract",          3,   TypeF,     ClassLS,      nullptr },
+    { EOpRefract,          "refract",          3,   TypeF,     ClassXLS,     nullptr },
     { EOpLength,           "length",           1,   TypeF,     ClassRS,      nullptr },
     { EOpDistance,         "distance",         2,   TypeF,     ClassRS,      nullptr },
     { EOpDot,              "dot",              2,   TypeF,     ClassRS,      nullptr },
@@ -286,9 +287,12 @@ void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
     // loop across these two:
     //  0: the varying arg set, and
     //  1: the fixed scalar args
-    const ArgClass ClassFixed = (ArgClass)(ClassLS | ClassLS2 | ClassFS | ClassFS2);
+    const ArgClass ClassFixed = (ArgClass)(ClassLS | ClassXLS | ClassLS2 | ClassFS | ClassFS2);
     for (int fixed = 0; fixed < ((function.classes & ClassFixed) > 0 ? 2 : 1); ++fixed) {
 
+        if (fixed == 0 && (function.classes & ClassXLS))
+            continue;
+
         // walk the type strings in TypeString[]
         for (int type = 0; type < TypeStringCount; ++type) {
             // skip types not selected: go from type to row number to type bit
@@ -303,8 +307,8 @@ void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
             if ((function.classes & ClassV3) && (type & TypeStringColumnMask) != 2)
                 continue;
 
-            // skip replication of all scalars between the varying arg set and the fixed args
-            if (fixed == 1 && type == (type & TypeStringScalarMask))
+            // skip replication of all arg scalars between the varying arg set and the fixed args
+            if (fixed == 1 && type == (type & TypeStringScalarMask) && (function.classes & ClassXLS) == 0)
                 continue;
 
             // skip scalars when we are told to
@@ -336,7 +340,8 @@ void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
                 }
                 if ((function.classes & ClassLB) && arg == function.numArguments - 1)
                     decls.append(TypeString[type & TypeStringColumnMask]);
-                else if (fixed && ((arg == function.numArguments - 1 && (function.classes & (ClassLS | ClassLS2))) ||
+                else if (fixed && ((arg == function.numArguments - 1 && (function.classes & (ClassLS | ClassXLS |
+                                                                                                       ClassLS2))) ||
                                    (arg == function.numArguments - 2 && (function.classes & ClassLS2))             ||
                                    (arg == 0                         && (function.classes & (ClassFS | ClassFS2))) ||
                                    (arg == 1                         && (function.classes & ClassFS2))))