Fix a parse issue of imageAtomicCompSwap()
authorRex Xu <rex.xu@amd.com>
Wed, 17 Oct 2018 05:55:11 +0000 (13:55 +0800)
committerRex Xu <rex.xu@amd.com>
Wed, 17 Oct 2018 05:55:11 +0000 (13:55 +0800)
The max count of arguments is 5 when image2DMS/image2DMSArray is
specified.

Test/baseResults/spv.image.frag.out
Test/spv.image.frag
glslang/MachineIndependent/ParseHelper.cpp

index 2f925b3..a544180 100644 (file)
@@ -5,7 +5,7 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
 
 // Module Version 10000
 // Generated by (magic number): 80007
-// Id's are bound by 376
+// Id's are bound by 395
 
                               Capability Shader
                               Capability StorageImageMultisample
@@ -19,7 +19,7 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
                               Capability StorageImageWriteWithoutFormat
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 132 142 152 248 362 375
+                              EntryPoint Fragment 4  "main" 132 142 152 248 381 394
                               ExecutionMode 4 OriginUpperLeft
                               Source GLSL 450
                               Name 4  "main"
@@ -43,9 +43,11 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
                               Name 232  "ii1D"
                               Name 245  "ui2D"
                               Name 248  "value"
-                              Name 357  "wo2D"
-                              Name 362  "fragData"
-                              Name 375  "ic4D"
+                              Name 357  "ii2DMS"
+                              Name 367  "ui2DMSArray"
+                              Name 376  "wo2D"
+                              Name 381  "fragData"
+                              Name 394  "ic4D"
                               Decorate 15(i1D) DescriptorSet 0
                               Decorate 15(i1D) Binding 0
                               Decorate 27(i2D) DescriptorSet 0
@@ -76,10 +78,14 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
                               Decorate 245(ui2D) DescriptorSet 0
                               Decorate 245(ui2D) Binding 12
                               Decorate 248(value) Flat
-                              Decorate 357(wo2D) DescriptorSet 0
-                              Decorate 357(wo2D) Binding 1
-                              Decorate 357(wo2D) NonReadable
-                              Decorate 375(ic4D) Flat
+                              Decorate 357(ii2DMS) DescriptorSet 0
+                              Decorate 357(ii2DMS) Binding 13
+                              Decorate 367(ui2DMSArray) DescriptorSet 0
+                              Decorate 367(ui2DMSArray) Binding 14
+                              Decorate 376(wo2D) DescriptorSet 0
+                              Decorate 376(wo2D) Binding 1
+                              Decorate 376(wo2D) NonReadable
+                              Decorate 394(ic4D) Flat
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeInt 32 1
@@ -161,16 +167,22 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
              340:      6(int) Constant 18
              341:      6(int) Constant 17
              349:     18(int) Constant 19
-             355:             TypeImage 12(float) 2D nonsampled format:Unknown
+             355:             TypeImage 6(int) 2D multi-sampled nonsampled format:R32i
              356:             TypePointer UniformConstant 355
-       357(wo2D):    356(ptr) Variable UniformConstant
-             361:             TypePointer Output 125(fvec4)
-   362(fragData):    361(ptr) Variable Output
-             367:             TypeBool
-             370:             TypeVector 367(bool) 4
-             373:             TypeVector 6(int) 4
-             374:             TypePointer Input 373(ivec4)
-       375(ic4D):    374(ptr) Variable Input
+     357(ii2DMS):    356(ptr) Variable UniformConstant
+             365:             TypeImage 18(int) 2D array multi-sampled nonsampled format:R32ui
+             366:             TypePointer UniformConstant 365
+367(ui2DMSArray):    366(ptr) Variable UniformConstant
+             374:             TypeImage 12(float) 2D nonsampled format:Unknown
+             375:             TypePointer UniformConstant 374
+       376(wo2D):    375(ptr) Variable UniformConstant
+             380:             TypePointer Output 125(fvec4)
+   381(fragData):    380(ptr) Variable Output
+             386:             TypeBool
+             389:             TypeVector 386(bool) 4
+             392:             TypeVector 6(int) 4
+             393:             TypePointer Input 392(ivec4)
+       394(ic4D):    393(ptr) Variable Input
          4(main):           2 Function None 3
                5:             Label
            9(iv):      8(ptr) Variable Function
@@ -497,18 +509,33 @@ error: Capability ImageRect is not allowed by Vulkan 1.0 specification (or requi
              353:     18(int) Load 229(ui)
              354:     18(int) IAdd 353 352
                               Store 229(ui) 354
-             358:         355 Load 357(wo2D)
-             359:   29(ivec2) Load 142(ic2D)
-             360:  125(fvec4) Load 127(v)
-                              ImageWrite 358 359 360
-             363:     18(int) Load 229(ui)
-             364:     20(ptr) AccessChain 9(iv) 237
-             365:      6(int) Load 364
-             366:     18(int) Bitcast 365
-             368:   367(bool) INotEqual 363 366
-             369:  125(fvec4) Load 127(v)
-             371:  370(bvec4) CompositeConstruct 368 368 368 368
-             372:  125(fvec4) Select 371 369 129
-                              Store 362(fragData) 372
+             358:   29(ivec2) Load 142(ic2D)
+             359:    235(ptr) ImageTexelPointer 357(ii2DMS) 358 216
+             360:      6(int) AtomicCompareExchange 359 237 19 19 341 340
+             361:     20(ptr) AccessChain 9(iv) 19
+             362:      6(int) Load 361
+             363:      6(int) IAdd 362 360
+             364:     20(ptr) AccessChain 9(iv) 19
+                              Store 364 363
+             368:    7(ivec3) Load 152(ic3D)
+             369:     18(int) Load 248(value)
+             370:    250(ptr) ImageTexelPointer 367(ui2DMSArray) 368 220
+             371:     18(int) AtomicCompareExchange 370 237 19 19 369 349
+             372:     18(int) Load 229(ui)
+             373:     18(int) IAdd 372 371
+                              Store 229(ui) 373
+             377:         374 Load 376(wo2D)
+             378:   29(ivec2) Load 142(ic2D)
+             379:  125(fvec4) Load 127(v)
+                              ImageWrite 377 378 379
+             382:     18(int) Load 229(ui)
+             383:     20(ptr) AccessChain 9(iv) 237
+             384:      6(int) Load 383
+             385:     18(int) Bitcast 384
+             387:   386(bool) INotEqual 382 385
+             388:  125(fvec4) Load 127(v)
+             390:  389(bvec4) CompositeConstruct 387 387 387 387
+             391:  125(fvec4) Select 390 388 129
+                              Store 381(fragData) 391
                               Return
                               FunctionEnd
index 30b339c..d9305ef 100644 (file)
@@ -14,6 +14,8 @@ layout(rgba32f, binding = 10)   uniform image2DMSArray  i2DMSArray;
 \r
 layout(r32i,    binding = 11)   uniform iimage1D        ii1D;\r
 layout(r32ui,   binding = 12)   uniform uimage2D        ui2D;\r
+layout(r32i,    binding = 13)   uniform iimage2DMS      ii2DMS;\r
+layout(r32ui,   binding = 14)   uniform uimage2DMSArray ui2DMSArray;\r
 \r
 flat in int     ic1D;\r
 flat in ivec2   ic2D;\r
@@ -85,6 +87,8 @@ void main()
     ui      += imageAtomicExchange(ui2D, ic2D, value);\r
     iv.x    += imageAtomicCompSwap(ii1D, ic1D, 18, 17);\r
     ui      += imageAtomicCompSwap(ui2D, ic2D, 19u, value);\r
+    iv.x    += imageAtomicCompSwap(ii2DMS, ic2D, 2, 18, 17);\r
+    ui      += imageAtomicCompSwap(ui2DMSArray, ic3D, 3, 19u, value);\r
 \r
     imageStore(wo2D, ic2D, v);\r
 \r
index a6821de..82ccc9e 100644 (file)
@@ -1897,7 +1897,8 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
                 error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
         }
 
-        if (argp->size() > 4) {
+        const size_t maxArgs = imageType.getSampler().isMultiSample() ? 5 : 4;
+        if (argp->size() > maxArgs) {
             requireExtensions(loc, 1, &E_GL_KHR_memory_scope_semantics, fnCandidate.getName().c_str());
             memorySemanticsCheck(loc, fnCandidate, callNode);
         }