Add atomic operation tests for multisample storage images
authorAri Suonpaa <ari.suonpaa@siru.fi>
Mon, 22 Jun 2020 04:20:45 +0000 (07:20 +0300)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 3 Jul 2020 08:12:16 +0000 (04:12 -0400)
VK-GL-CTS Issue: 2310

New tests:

dEQP-VK.texture.multisample.atomic.*

Components: Vulkan
Change-Id: Ie2bcd1fd2e5cd458abfd846deda19f22f82af778

AndroidGen.mk
android/cts/master/vk-master-2020-03-01.txt
android/cts/master/vk-master.txt
external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32i.amber [new file with mode: 0644]
external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32ui.amber [new file with mode: 0644]
external/vulkancts/modules/vulkan/amber/vktAmberTestCase.cpp
external/vulkancts/modules/vulkan/texture/CMakeLists.txt
external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/texture/vktTextureTests.cpp
external/vulkancts/mustpass/master/vk-default.txt

index 76291b2..f0130f3 100644 (file)
@@ -413,6 +413,7 @@ LOCAL_SRC_FILES := \
        external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp \
        external/vulkancts/modules/vulkan/texture/vktTextureFilteringTests.cpp \
        external/vulkancts/modules/vulkan/texture/vktTextureMipmapTests.cpp \
+       external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.cpp \
        external/vulkancts/modules/vulkan/texture/vktTextureShadowTests.cpp \
        external/vulkancts/modules/vulkan/texture/vktTextureSubgroupLodTests.cpp \
        external/vulkancts/modules/vulkan/texture/vktTextureSwizzleTests.cpp \
index 0f5dbfd..5cbcfbf 100644 (file)
@@ -197481,6 +197481,8 @@ dEQP-VK.texture.conversion.snorm_clamp.r8g8b8a8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8b8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8_snorm
+dEQP-VK.texture.multisample.atomic.storage_image_r32i
+dEQP-VK.texture.multisample.atomic.storage_image_r32ui
 dEQP-VK.geometry.layered.1d_array.64_1_4.render_to_default_layer
 dEQP-VK.geometry.layered.1d_array.64_1_4.render_to_one
 dEQP-VK.geometry.layered.1d_array.64_1_4.render_to_all
index 3d69eaf..75a3600 100644 (file)
@@ -569754,6 +569754,8 @@ dEQP-VK.texture.conversion.snorm_clamp.r8g8b8a8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8b8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8_snorm
+dEQP-VK.texture.multisample.atomic.storage_image_r32i
+dEQP-VK.texture.multisample.atomic.storage_image_r32ui
 dEQP-VK.geometry.input.basic_primitive.points
 dEQP-VK.geometry.input.basic_primitive.lines
 dEQP-VK.geometry.input.basic_primitive.line_strip
diff --git a/external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32i.amber b/external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32i.amber
new file mode 100644 (file)
index 0000000..aa38b2b
--- /dev/null
@@ -0,0 +1,98 @@
+#!amber
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_FEATURE shaderStorageImageMultisample
+
+SHADER compute compute_shader GLSL
+#version 430
+
+layout(local_size_x = 16, local_size_y = 16) in;
+uniform layout(set=0, binding=0, r32i) iimage2DMS texture;
+uniform layout(set=0, binding=1, rgba8) image2D result;
+
+void main()
+{
+    ivec2 loc = ivec2(gl_LocalInvocationID.xy);
+    // Partner location is a mirror in local workgroup space.
+    ivec2 partnerLoc = ivec2(15) - loc;
+    int id = loc.y * 16 + loc.x;
+    int partnerId = partnerLoc.y * 16 + partnerLoc.x;
+    ivec2 workGroupOffset = ivec2(gl_WorkGroupID.xy) * ivec2(16);
+
+    // Initialize texture with id + sample id
+    for (int s = 0; s < 4; s++)
+        imageStore(texture, loc + workGroupOffset, s, ivec4(s + id));
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // Add id to both location and partner location.
+        imageAtomicAdd(texture, loc + workGroupOffset, s, id);
+        imageAtomicAdd(texture, partnerLoc + workGroupOffset, s, id);
+
+        // Set MSB for location and the second MSB for partner.
+        imageAtomicOr(texture, loc + workGroupOffset, s, 1 << 31);
+        imageAtomicOr(texture, partnerLoc + workGroupOffset, s, 1 << 30);
+    }
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // XOR with two patterns in the second highest byte. Should set this
+        // byte to 0xc. The order of XOR operations don't matter.
+        imageAtomicXor(texture, loc + workGroupOffset, s, 0x0a000000);
+        imageAtomicXor(texture, partnerLoc + workGroupOffset, s, 0x06000000);
+    }
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // Finally mask out one of LSBs based on sample
+        imageAtomicAnd(texture, loc + workGroupOffset, s, ~(1 << s));
+    }
+
+    // Verification
+    bool ok = true;
+
+    for (int s = 0; s < 4; s++)
+    {
+        if (imageLoad(texture, loc + workGroupOffset, s).r != (((s + id * 2 + partnerId) | 0xcc000000) & ~(1 << s)))
+            ok = false;
+    }
+
+    vec4 color = ok ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
+    imageStore(result, loc + workGroupOffset, color);
+}
+END
+
+IMAGE texture FORMAT R32_SINT DIM_2D WIDTH 64 HEIGHT 64 SAMPLES 4
+IMAGE result FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 FILL 0
+
+PIPELINE compute pipeline
+  ATTACH compute_shader
+
+  BIND BUFFER texture AS storage_image DESCRIPTOR_SET 0 BINDING 0
+  BIND BUFFER result AS storage_image DESCRIPTOR_SET 0 BINDING 1
+END
+
+RUN pipeline 4 4 1
+
+EXPECT result IDX 0 0 SIZE 64 64 EQ_RGBA 0 255 0 255
diff --git a/external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32ui.amber b/external/vulkancts/data/vulkan/amber/texture/multisample/atomic/storage_image_r32ui.amber
new file mode 100644 (file)
index 0000000..8d2c584
--- /dev/null
@@ -0,0 +1,98 @@
+#!amber
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_FEATURE shaderStorageImageMultisample
+
+SHADER compute compute_shader GLSL
+#version 430
+
+layout(local_size_x = 16, local_size_y = 16) in;
+uniform layout(set=0, binding=0, r32ui) uimage2DMS texture;
+uniform layout(set=0, binding=1, rgba8) image2D result;
+
+void main()
+{
+    ivec2 loc = ivec2(gl_LocalInvocationID.xy);
+    // Partner location is a mirror in local workgroup space.
+    ivec2 partnerLoc = ivec2(15) - loc;
+    uint id = loc.y * 16 + loc.x;
+    uint partnerId = partnerLoc.y * 16 + partnerLoc.x;
+    ivec2 workGroupOffset = ivec2(gl_WorkGroupID.xy) * ivec2(16);
+
+    // Initialize texture with id + sample id
+    for (int s = 0; s < 4; s++)
+        imageStore(texture, loc + workGroupOffset, s, uvec4(s + id));
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // Add id to both location and partner location.
+        imageAtomicAdd(texture, loc + workGroupOffset, s, id);
+        imageAtomicAdd(texture, partnerLoc + workGroupOffset, s, id);
+
+        // Set MSB for location and the second MSB for partner.
+        imageAtomicOr(texture, loc + workGroupOffset, s, 1u << 31);
+        imageAtomicOr(texture, partnerLoc + workGroupOffset, s, 1u << 30);
+    }
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // XOR with two patterns in the second highest byte. Should set this
+        // byte to 0xc. The order of XOR operations don't matter.
+        imageAtomicXor(texture, loc + workGroupOffset, s, 0x0a000000);
+        imageAtomicXor(texture, partnerLoc + workGroupOffset, s, 0x06000000);
+    }
+
+    memoryBarrierImage();
+    barrier();
+
+    for (int s = 0; s < 4; s++)
+    {
+        // Finally mask out one of LSBs based on sample
+        imageAtomicAnd(texture, loc + workGroupOffset, s, ~(1u << s));
+    }
+
+    // Verification
+    bool ok = true;
+
+    for (int s = 0; s < 4; s++)
+    {
+        if (imageLoad(texture, loc + workGroupOffset, s).r != (((s + id * 2 + partnerId) | 0xcc000000) & ~(1u << s)))
+            ok = false;
+    }
+
+    vec4 color = ok ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
+    imageStore(result, loc + workGroupOffset, color);
+}
+END
+
+IMAGE texture FORMAT R32_UINT DIM_2D WIDTH 64 HEIGHT 64 SAMPLES 4
+IMAGE result FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 FILL 0
+
+PIPELINE compute pipeline
+  ATTACH compute_shader
+
+  BIND BUFFER texture AS storage_image DESCRIPTOR_SET 0 BINDING 0
+  BIND BUFFER result AS storage_image DESCRIPTOR_SET 0 BINDING 1
+END
+
+RUN pipeline 4 4 1
+
+EXPECT result IDX 0 0 SIZE 64 64 EQ_RGBA 0 255 0 255
index a0b08e3..c33103b 100644 (file)
@@ -91,6 +91,8 @@ static bool isFeatureSupported(const vkt::Context& ctx, const std::string& featu
                return ctx.getDeviceFeatures().vertexPipelineStoresAndAtomics;
        if (feature == "Features.fillModeNonSolid")
                return ctx.getDeviceFeatures().fillModeNonSolid;
+       if (feature == "Features.shaderStorageImageMultisample")
+               return ctx.getDeviceFeatures().shaderStorageImageMultisample;
        if (feature == "VariablePointerFeatures.variablePointersStorageBuffer")
                return ctx.getVariablePointersFeatures().variablePointersStorageBuffer;
        if (feature == "VariablePointerFeatures.variablePointers")
index e2a5f44..6478aa6 100644 (file)
@@ -23,6 +23,8 @@ set(DEQP_VK_TEXTURE_SRCS
        vktTextureFilteringTests.hpp
        vktTextureMipmapTests.cpp
        vktTextureMipmapTests.hpp
+       vktTextureMultisampleTests.cpp
+       vktTextureMultisampleTests.hpp
        vktTextureShadowTests.cpp
        vktTextureShadowTests.hpp
        vktTextureSubgroupLodTests.cpp
diff --git a/external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.cpp b/external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.cpp
new file mode 100644 (file)
index 0000000..eeb919c
--- /dev/null
@@ -0,0 +1,76 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2020 The Khronos Group Inc.
+ * Copyright (c) 2020 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Texture multisample tests.
+ *//*--------------------------------------------------------------------*/
+
+#include "vktTextureMultisampleTests.hpp"
+#include "vktAmberTestCase.hpp"
+#include "vktTestGroupUtil.hpp"
+
+using namespace vk;
+
+namespace vkt
+{
+namespace texture
+{
+namespace
+{
+
+tcu::TestCaseGroup* createAtomicTests (tcu::TestContext& testCtx)
+{
+       de::MovePtr<tcu::TestCaseGroup> atomic          (new tcu::TestCaseGroup(testCtx, "atomic", "Test atomic oprerations on multisample textures"));
+       static const char                               dataDir[]       = "texture/multisample/atomic";
+
+       static const std::string                cases[]         =
+       {
+               "storage_image_r32i",
+               "storage_image_r32ui"
+       };
+
+       std::vector<std::string>                requirements;
+
+       requirements.push_back("Features.shaderStorageImageMultisample");
+
+       for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
+       {
+               const std::string                       fileName        = cases[i] + ".amber";
+               cts_amber::AmberTestCase*       testCase        = cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), "", dataDir, fileName, requirements);
+
+               atomic->addChild(testCase);
+       }
+
+       return atomic.release();
+}
+
+} // anonymous
+
+tcu::TestCaseGroup* createTextureMultisampleTests (tcu::TestContext& testCtx)
+{
+       de::MovePtr<tcu::TestCaseGroup> multisample (new tcu::TestCaseGroup(testCtx, "multisample", "Multisample texture tests"));
+
+       multisample->addChild(createAtomicTests(testCtx));
+
+       return multisample.release();
+}
+
+} // texture
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.hpp b/external/vulkancts/modules/vulkan/texture/vktTextureMultisampleTests.hpp
new file mode 100644 (file)
index 0000000..f30d98b
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef _VKTTEXTUREMULTISAMPLETESTS_HPP
+#define _VKTTEXTUREMULTISAMPLETESTS_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2020 The Khronos Group Inc.
+ * Copyright (c) 2020 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Texture multisample tests.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tcuTestCase.hpp"
+#include "vktTestCase.hpp"
+
+namespace vkt
+{
+namespace texture
+{
+
+tcu::TestCaseGroup*    createTextureMultisampleTests   (tcu::TestContext& testCtx);
+
+} // texture
+} // vkt
+
+#endif // _VKTTEXTUREMULTISAMPLETESTS_HPP
index ed0d5f5..5300e36 100644 (file)
@@ -34,6 +34,7 @@
 #include "vktTextureSwizzleTests.hpp"
 #include "vktTextureSubgroupLodTests.hpp"
 #include "vktTextureConversionTests.hpp"
+#include "vktTextureMultisampleTests.hpp"
 
 namespace vkt
 {
@@ -55,6 +56,7 @@ void createTextureTests (tcu::TestCaseGroup* textureTests)
        textureTests->addChild(createTextureSwizzleTests                        (testCtx));
        textureTests->addChild(createTextureSubgroupLodTests            (testCtx));
        textureTests->addChild(createTextureConversionTests                     (testCtx));
+       textureTests->addChild(createTextureMultisampleTests            (testCtx));
 }
 
 } // anonymous
index 86cb514..03692a6 100644 (file)
@@ -571814,6 +571814,8 @@ dEQP-VK.texture.conversion.snorm_clamp.r8g8b8a8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8b8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8g8_snorm
 dEQP-VK.texture.conversion.snorm_clamp.r8_snorm
+dEQP-VK.texture.multisample.atomic.storage_image_r32i
+dEQP-VK.texture.multisample.atomic.storage_image_r32ui
 dEQP-VK.geometry.input.basic_primitive.points
 dEQP-VK.geometry.input.basic_primitive.lines
 dEQP-VK.geometry.input.basic_primitive.line_strip