HLSL: phase 3c: add option to use Unknown storage format

This uses the Unknown storage format, instead of deducing the
format from the texture declaration type.
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index f0a4f93..7ffd232 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -82,6 +82,7 @@
     EOptionCascadingErrors    = (1 << 18),
     EOptionAutoMapBindings    = (1 << 19),
     EOptionFlattenUniformArrays = (1 << 20),
+    EOptionNoStorageFormat    = (1 << 21),
 };
 
 //
@@ -290,6 +291,9 @@
                                lowerword == "flatten-uniform-array"  ||
                                lowerword == "fua") {
                         Options |= EOptionFlattenUniformArrays;
+                    } else if (lowerword == "no-storage-format" || // synonyms
+                               lowerword == "nsf") {
+                        Options |= EOptionNoStorageFormat;
                     } else {
                         usage();
                     }
@@ -542,6 +546,7 @@
         shader->setShiftTextureBinding(baseTextureBinding[compUnit.stage]);
         shader->setShiftUboBinding(baseUboBinding[compUnit.stage]);
         shader->setFlattenUniformArrays((Options & EOptionFlattenUniformArrays) != 0);
+        shader->setNoStorageFormat((Options & EOptionNoStorageFormat) != 0);
 
         if (Options & EOptionAutoMapBindings)
             shader->setAutoMapBindings(true);
@@ -945,6 +950,9 @@
            "\n"
            "  --flatten-uniform-arrays                flatten uniform texture & sampler arrays to scalars\n"
            "  --fua                                   synonym for --flatten-uniform-arrays\n"
+           "\n"
+           "  --no-storage-format                     use Unknown image format\n"
+           "  --nsf                                   synonym for --no-storage-format\n"
            );
 
     exit(EFailUsage);
diff --git a/Test/baseResults/hlsl.sample.sub-vec4.dx10.frag.out b/Test/baseResults/hlsl.sample.sub-vec4.dx10.frag.out
index abe1cb5..5a97ed9 100644
--- a/Test/baseResults/hlsl.sample.sub-vec4.dx10.frag.out
+++ b/Test/baseResults/hlsl.sample.sub-vec4.dx10.frag.out
@@ -18,7 +18,7 @@
 0:18      Sequence
 0:18        move second child to first child (temp 2-component vector of float)
 0:18          'txval11' (temp 2-component vector of float)
-0:18          Construct float (temp 2-component vector of float)
+0:18          Construct vec2 (temp 2-component vector of float)
 0:?             texture (temp 4-component vector of float)
 0:18              Construct combined texture-sampler (temp sampler1D)
 0:18                'g_tTex1df2' (uniform texture1D)
@@ -28,7 +28,7 @@
 0:19      Sequence
 0:19        move second child to first child (temp 3-component vector of float)
 0:19          'txval12' (temp 3-component vector of float)
-0:19          Construct float (temp 3-component vector of float)
+0:19          Construct vec3 (temp 3-component vector of float)
 0:?             texture (temp 4-component vector of float)
 0:19              Construct combined texture-sampler (temp sampler1D)
 0:19                'g_tTex1df3' (uniform texture1D)
@@ -94,7 +94,7 @@
 0:18      Sequence
 0:18        move second child to first child (temp 2-component vector of float)
 0:18          'txval11' (temp 2-component vector of float)
-0:18          Construct float (temp 2-component vector of float)
+0:18          Construct vec2 (temp 2-component vector of float)
 0:?             texture (temp 4-component vector of float)
 0:18              Construct combined texture-sampler (temp sampler1D)
 0:18                'g_tTex1df2' (uniform texture1D)
@@ -104,7 +104,7 @@
 0:19      Sequence
 0:19        move second child to first child (temp 3-component vector of float)
 0:19          'txval12' (temp 3-component vector of float)
-0:19          Construct float (temp 3-component vector of float)
+0:19          Construct vec3 (temp 3-component vector of float)
 0:?             texture (temp 4-component vector of float)
 0:19              Construct combined texture-sampler (temp sampler1D)
 0:19                'g_tTex1df3' (uniform texture1D)
diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp
index 5333af4..6d04445 100644
--- a/glslang/MachineIndependent/ShaderLang.cpp
+++ b/glslang/MachineIndependent/ShaderLang.cpp
@@ -1497,6 +1497,7 @@
 void TShader::setShiftUboBinding(unsigned int base)     { intermediate->setShiftUboBinding(base); }
 void TShader::setAutoMapBindings(bool map)              { intermediate->setAutoMapBindings(map); }
 void TShader::setFlattenUniformArrays(bool flatten)     { intermediate->setFlattenUniformArrays(flatten); }
+void TShader::setNoStorageFormat(bool useUnknownFormat) { intermediate->setNoStorageFormat(useUnknownFormat); }
 
 //
 // Turn the shader strings into a parse tree in the TIntermediate.
diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h
index 348b78e..aae22ec 100644
--- a/glslang/MachineIndependent/localintermediate.h
+++ b/glslang/MachineIndependent/localintermediate.h
@@ -146,7 +146,8 @@
         shiftTextureBinding(0),
         shiftUboBinding(0),
         autoMapBindings(false),
-        flattenUniformArrays(false)
+        flattenUniformArrays(false),
+        useUnknownFormat(false)
     {
         localSize[0] = 1;
         localSize[1] = 1;
@@ -179,7 +180,9 @@
     bool getAutoMapBindings()             const { return autoMapBindings; }
     void setFlattenUniformArrays(bool flatten)      { flattenUniformArrays = flatten; }
     bool getFlattenUniformArrays()        const { return flattenUniformArrays; }
-
+    void setNoStorageFormat(bool b)             { useUnknownFormat = b; }
+    bool getNoStorageFormat()             const { return useUnknownFormat; }
+    
     void setVersion(int v) { version = v; }
     int getVersion() const { return version; }
     void setProfile(EProfile p) { profile = p; }
@@ -397,6 +400,7 @@
     unsigned int shiftUboBinding;
     bool autoMapBindings;
     bool flattenUniformArrays;
+    bool useUnknownFormat;
 
     EProfile profile;
     int version;
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
index 6b894c1..e5e8b4d 100644
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -309,6 +309,7 @@
     void setShiftUboBinding(unsigned int base);
     void setAutoMapBindings(bool map);
     void setFlattenUniformArrays(bool flatten);
+    void setNoStorageFormat(bool useUnknownFormat);
 
     // Interface to #include handlers.
     //
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
index 97999d0..aa41545 100755
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -154,7 +154,10 @@
 {
     const int components = txType.getVectorSize();
 
-    const auto selectFormat = [&components](TLayoutFormat v1, TLayoutFormat v2, TLayoutFormat v4) {
+    const auto selectFormat = [this,&components](TLayoutFormat v1, TLayoutFormat v2, TLayoutFormat v4) {
+        if (intermediate.getNoStorageFormat())
+            return ElfNone;
+
         return components == 1 ? v1 :
                components == 2 ? v2 : v4;
     };
@@ -288,13 +291,6 @@
 
     const TSampler& texSampler = object->getType().getSampler();
 
-    const TLayoutFormat fmt = object->getType().getQualifier().layoutFormat;
-
-    // We only handle this subset of the possible formats.
-    assert(fmt == ElfRgba32f || fmt == ElfRgba32i || fmt == ElfRgba32ui ||
-           fmt == ElfRg32f   || fmt == ElfRg32i   || fmt == ElfRg32ui   ||
-           fmt == ElfR32f    || fmt == ElfR32i    || fmt == ElfR32ui);
-
     const TType objDerefType(texSampler.type, EvqTemporary, texSampler.vectorSize);
 
     if (nodeAsBinary) {
@@ -1452,15 +1448,7 @@
             // Too many components.  Construct shorter vector from it.
             const TType clampedType(result->getType().getBasicType(), EvqTemporary, sampler.vectorSize);
 
-            TOperator op;
-
-            switch (sampler.type) {
-            case EbtInt:   op = EOpConstructInt;   break;
-            case EbtUint:  op = EOpConstructUint;  break;
-            case EbtFloat: op = EOpConstructFloat; break;
-            default:
-                error(loc, "unknown basic type in texture op", "", "");
-            }
+            const TOperator op = intermediate.mapTypeToConstructorOp(clampedType);
 
             result = constructBuiltIn(clampedType, op, result, loc, false);
         }