SPV: Correct selection of storage-image capabilities. Fixes #986.
authorJohn Kessenich <cepheus@frii.com>
Tue, 15 Aug 2017 04:10:00 +0000 (22:10 -0600)
committerJohn Kessenich <cepheus@frii.com>
Tue, 15 Aug 2017 04:10:00 +0000 (22:10 -0600)
Code was reflecting an old historical use of sampled as a SPIR-V
2-valued operand, instead of its current 3 values.

22 files changed:
SPIRV/SpvBuilder.cpp
Test/baseResults/hlsl.getdimensions.dx10.frag.out
Test/baseResults/hlsl.getdimensions.rw.dx10.frag.out
Test/baseResults/hlsl.getsampleposition.dx10.frag.out
Test/baseResults/hlsl.load.2dms.dx10.frag.out
Test/baseResults/hlsl.load.rwbuffer.dx10.frag.out
Test/baseResults/hlsl.load.rwtexture.array.dx10.frag.out
Test/baseResults/hlsl.load.rwtexture.dx10.frag.out
Test/baseResults/hlsl.promote.atomic.frag.out
Test/baseResults/hlsl.rw.atomics.frag.out
Test/baseResults/hlsl.rw.bracket.frag.out
Test/baseResults/hlsl.rw.register.frag.out
Test/baseResults/hlsl.rw.scalar.bracket.frag.out
Test/baseResults/hlsl.rw.swizzle.frag.out
Test/baseResults/hlsl.rw.vec2.bracket.frag.out
Test/baseResults/hlsl.structbuffer.fn2.comp.out
Test/baseResults/spv.image.frag.out
Test/baseResults/spv.memoryQualifier.frag.out
Test/baseResults/spv.rw.autoassign.frag.out
Test/baseResults/spv.separate.frag.out
Test/baseResults/spv.sparseTexture.frag.out
Test/baseResults/spv.subpass.frag.out

index d472eb5333a6e5e50910f99d6da2ede1eba83f90..9246a8195cf9b1f41d85f7ff6274115bcfbea2ed 100644 (file)
@@ -402,6 +402,8 @@ Id Builder::makeFunctionType(Id returnType, const std::vector<Id>& paramTypes)
 
 Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, bool ms, unsigned sampled, ImageFormat format)
 {
+    assert(sampled == 1 || sampled == 2);
+
     // try to find it
     Instruction* type;
     for (int t = 0; t < (int)groupedTypes[OpTypeImage].size(); ++t) {
@@ -433,27 +435,27 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
     // deal with capabilities
     switch (dim) {
     case DimBuffer:
-        if (sampled)
+        if (sampled == 1)
             addCapability(CapabilitySampledBuffer);
         else
             addCapability(CapabilityImageBuffer);
         break;
     case Dim1D:
-        if (sampled)
+        if (sampled == 1)
             addCapability(CapabilitySampled1D);
         else
             addCapability(CapabilityImage1D);
         break;
     case DimCube:
         if (arrayed) {
-            if (sampled)
+            if (sampled == 1)
                 addCapability(CapabilitySampledCubeArray);
             else
                 addCapability(CapabilityImageCubeArray);
         }
         break;
     case DimRect:
-        if (sampled)
+        if (sampled == 1)
             addCapability(CapabilitySampledRect);
         else
             addCapability(CapabilityImageRect);
@@ -466,10 +468,11 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
     }
 
     if (ms) {
-        if (arrayed)
-            addCapability(CapabilityImageMSArray);
-        if (! sampled)
+        if (sampled == 2) {
             addCapability(CapabilityStorageImageMultisample);
+            if (arrayed)
+                addCapability(CapabilityImageMSArray);
+        }
     }
 
     return type->getResultId();
index ea6c200da8b2a7fb38bba5d8a700b51b016912f0..3780bd34dc1150b19e7e71409bbc5646fed89484 100644 (file)
@@ -2322,7 +2322,6 @@ gl_FragCoord origin is upper left
                               Capability Shader
                               Capability Sampled1D
                               Capability SampledCubeArray
-                              Capability ImageMSArray
                               Capability ImageQuery
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
index beb19092a8a1cbe650b4005495789a260711ba58..b301a61ad21ccbac661ba25317641932f1a7a46e 100644 (file)
@@ -720,8 +720,8 @@ gl_FragCoord origin is upper left
 // Id's are bound by 232
 
                               Capability Shader
-                              Capability Sampled1D
-                              Capability SampledBuffer
+                              Capability Image1D
+                              Capability ImageBuffer
                               Capability ImageQuery
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
index d45d7316baa41cafc68d2e36be12277f68685068..12fe30c89d39e74ec39c65270931d313d7899590 100644 (file)
@@ -582,7 +582,6 @@ gl_FragCoord origin is upper left
 // Id's are bound by 221
 
                               Capability Shader
-                              Capability ImageMSArray
                               Capability ImageQuery
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
index 462bb81efd0d32edfdfde8e77dc602f4ddf6a399..b5d046604feee551717dfee35357f2f2210b4b9b 100644 (file)
@@ -361,7 +361,6 @@ gl_FragCoord origin is upper left
 
                               Capability Shader
                               Capability ImageGatherExtended
-                              Capability ImageMSArray
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 120 124
index fa66acca908146a67b48430a41f95d2895d777e7..851f82462d226a776fe61f9f3f8c460559114721 100644 (file)
@@ -114,7 +114,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 57
 
                               Capability Shader
-                              Capability SampledBuffer
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 54
index 99070b7054967e610e1a8b453022c8f388c477cc..10931001a462943229ef7dd1c2471efb496ded7d 100644 (file)
@@ -210,7 +210,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 119
 
                               Capability Shader
-                              Capability Sampled1D
+                              Capability Image1D
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 82 86
index 6c9e2c0104da8ae48372415f72e5fb49ec354b3d..1347a519197455dcb49f63c13dce0052bfb6de71 100644 (file)
@@ -246,7 +246,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 132
 
                               Capability Shader
-                              Capability Sampled1D
+                              Capability Image1D
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 104 108
index b31ac6126a961c27bd2e0d050ebc305788ef78da..ead4fe311bb5fa4ecb0cdaf2c3d4172d5b20bcb4 100644 (file)
@@ -68,7 +68,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 36
 
                               Capability Shader
-                              Capability SampledBuffer
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 34
index 5e7fdb1dba9e897d0e836a1c468f3ba70dd6d1e6..99c417404a5abdabe1927e0e58e88f5b504a0cec 100644 (file)
@@ -3950,8 +3950,8 @@ gl_FragCoord origin is upper left
 // Id's are bound by 1147
 
                               Capability Shader
-                              Capability Sampled1D
-                              Capability SampledBuffer
+                              Capability Image1D
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 1117
index 91172653057c203f12418af39507243f3c4cc63c..7804e33a82da49be4f308604403528068f546fc2 100644 (file)
@@ -1748,7 +1748,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 607
 
                               Capability Shader
-                              Capability Sampled1D
+                              Capability Image1D
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 583
index 237303c452e556955a80310a0a282fa9fcd51e1a..5464ac2eb9ac0c66a42b3d0b0c99529b4689e392 100644 (file)
@@ -102,8 +102,8 @@ gl_FragCoord origin is upper left
 // Id's are bound by 42
 
                               Capability Shader
-                              Capability Sampled1D
-                              Capability SampledBuffer
+                              Capability Image1D
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 39
index da7a5a11aafdeba34c0a95889d0e7e86dc76d433..7ff34fa01f93d7d42d8c904d676739b2efad7ba7 100644 (file)
@@ -1694,7 +1694,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 571
 
                               Capability Shader
-                              Capability Sampled1D
+                              Capability Image1D
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 547
index 60a6b997e8e5d5389de3d3d9eb2a4ce5a6afddd8..4d804e98b4d174fa363356953287d29d95f5dfd0 100644 (file)
@@ -206,7 +206,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 63
 
                               Capability Shader
-                              Capability SampledBuffer
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 58
index d920bf3eb211d8e02143c177f6ee465296f33933..980c82b63fa99f44260d1521e8f09372ecf84a7d 100644 (file)
@@ -1712,7 +1712,7 @@ gl_FragCoord origin is upper left
 // Id's are bound by 605
 
                               Capability Shader
-                              Capability Sampled1D
+                              Capability Image1D
                               Capability StorageImageExtendedFormats
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
index cb12ba5d3f142d5e8a748af24b9e9f226c1dabbf..efe5fe3c1c15f2c89cdefe2f183d4cc42956060a 100644 (file)
@@ -138,7 +138,7 @@ local_size = (256, 1, 1)
 // Id's are bound by 61
 
                               Capability Shader
-                              Capability SampledBuffer
+                              Capability ImageBuffer
                               Capability StorageImageExtendedFormats
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
index c21f9bf15b110f329c65e8741e248c3663367420..d645f2a32ab8caf8c6b15b642c5f1eb08fc4ded0 100644 (file)
@@ -4,10 +4,11 @@ spv.image.frag
 // Id's are bound by 376
 
                               Capability Shader
-                              Capability SampledRect
-                              Capability Sampled1D
-                              Capability SampledCubeArray
-                              Capability SampledBuffer
+                              Capability StorageImageMultisample
+                              Capability ImageCubeArray
+                              Capability ImageRect
+                              Capability Image1D
+                              Capability ImageBuffer
                               Capability ImageMSArray
                               Capability StorageImageExtendedFormats
                               Capability ImageQuery
index 00608680d884956816bfc5f76144fe7e663d2108..c041a5229759a3a26381b83b51e9977df8ef6d0b 100644 (file)
@@ -4,8 +4,8 @@ spv.memoryQualifier.frag
 // Id's are bound by 97
 
                               Capability Shader
-                              Capability SampledRect
-                              Capability Sampled1D
+                              Capability ImageRect
+                              Capability Image1D
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main"
index 0f2a51d213be9f9b0a8167f4c64a7a7ea0f9325b..6121b9b9a0c4846c6aaf669b589820f0b6b57865 100644 (file)
@@ -4,8 +4,8 @@ spv.rw.autoassign.frag
 // Id's are bound by 42
 
                               Capability Shader
-                              Capability Sampled1D
-                              Capability SampledBuffer
+                              Capability Image1D
+                              Capability ImageBuffer
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 39
index 5b078afc7ad4b7221422630983778b41ce2ca2d2..38072426d4c1ec494705ee16b034cdee268043de 100644 (file)
@@ -8,7 +8,6 @@ spv.separate.frag
                               Capability Sampled1D
                               Capability SampledCubeArray
                               Capability SampledBuffer
-                              Capability ImageMSArray
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 11 34
index af3b63eccba251092054a066ce58514234904379..b57b87ca792efac58c4836b6ede5800e6a22ecc5 100644 (file)
@@ -4,6 +4,7 @@ spv.sparseTexture.frag
 // Id's are bound by 438
 
                               Capability Shader
+                              Capability StorageImageMultisample
                               Capability SampledRect
                               Capability SparseResidency
                               Capability SampledCubeArray
index 661ebbafbfa8378dbfb9cd85d6f0e09416cb549c..7db9e39d44d67ded3cf32e9a68208651a4cadd96 100644 (file)
@@ -4,6 +4,7 @@ spv.subpass.frag
 // Id's are bound by 67
 
                               Capability Shader
+                              Capability StorageImageMultisample
                               Capability InputAttachment
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450