1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2020 The Khronos Group Inc.
6 * Copyright (c) 2020 Google Inc.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 *//*!
21 * \file
22 * \brief Texture multisample tests.
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktTextureMultisampleTests.hpp"
26 #include "vktAmberTestCase.hpp"
27 #include "vktTestGroupUtil.hpp"
28
29 using namespace vk;
30
31 namespace vkt
32 {
33 namespace texture
34 {
35 namespace
36 {
37
createAtomicTests(tcu::TestContext & testCtx)38 tcu::TestCaseGroup* createAtomicTests (tcu::TestContext& testCtx)
39 {
40 de::MovePtr<tcu::TestCaseGroup> atomic (new tcu::TestCaseGroup(testCtx, "atomic", "Test atomic oprerations on multisample textures"));
41 #ifndef CTS_USES_VULKANSC
42 static const char dataDir[] = "texture/multisample/atomic";
43
44 static const std::string cases[] =
45 {
46 "storage_image_r32i",
47 "storage_image_r32ui"
48 };
49
50 std::vector<std::string> requirements;
51
52 requirements.push_back("Features.shaderStorageImageMultisample");
53
54 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
55 {
56 const std::string fileName = cases[i] + ".amber";
57 cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), "", dataDir, fileName, requirements);
58
59 atomic->addChild(testCase);
60 }
61 #endif
62
63 return atomic.release();
64 }
65
createInvalidSampleIndexTests(tcu::TestContext & testCtx)66 tcu::TestCaseGroup* createInvalidSampleIndexTests(tcu::TestContext& testCtx)
67 {
68 std::pair <std::string, VkSampleCountFlagBits> cases[] =
69 {
70 { "sample_count_2", VK_SAMPLE_COUNT_2_BIT },
71 { "sample_count_4", VK_SAMPLE_COUNT_4_BIT },
72 { "sample_count_8", VK_SAMPLE_COUNT_8_BIT },
73 { "sample_count_16", VK_SAMPLE_COUNT_16_BIT },
74 { "sample_count_32", VK_SAMPLE_COUNT_32_BIT },
75 { "sample_count_64", VK_SAMPLE_COUNT_64_BIT }
76 };
77
78 de::MovePtr<tcu::TestCaseGroup> invalidWrites (new tcu::TestCaseGroup(testCtx, "invalid_sample_index", "Writes to invalid sample indices should be discarded."));
79 static const char dataDir[] = "texture/multisample/invalidsampleindex";
80 std::vector<std::string> requirements = { "Features.shaderStorageImageMultisample" };
81
82 for (const auto& testCase : cases)
83 {
84 const VkImageCreateInfo vkImageCreateInfo =
85 {
86 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
87 DE_NULL, // pNext
88 0, // flags
89 VK_IMAGE_TYPE_2D, // imageType
90 VK_FORMAT_R8G8B8A8_UNORM, // format
91 { 16, 16, 1 }, // extent
92 1, // mipLevels
93 1, // arrayLayers
94 testCase.second, // samples
95 VK_IMAGE_TILING_OPTIMAL, // tiling
96 VK_IMAGE_USAGE_SAMPLED_BIT, // usage
97 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
98 0, // queueFamilyIndexCount
99 DE_NULL, // pQueueFamilyIndices
100 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
101 };
102
103 std::vector<VkImageCreateInfo> imageRequirements = { vkImageCreateInfo };
104 const std::string fileName = testCase.first + ".amber";
105
106 invalidWrites->addChild(cts_amber::createAmberTestCase(testCtx, testCase.first.c_str(), "", dataDir, fileName, requirements, imageRequirements));
107 }
108
109 return invalidWrites.release();
110 }
111
112 } // anonymous
113
createTextureMultisampleTests(tcu::TestContext & testCtx)114 tcu::TestCaseGroup* createTextureMultisampleTests (tcu::TestContext& testCtx)
115 {
116 de::MovePtr<tcu::TestCaseGroup> multisample (new tcu::TestCaseGroup(testCtx, "multisample", "Multisample texture tests"));
117
118 multisample->addChild(createAtomicTests(testCtx));
119 multisample->addChild(createInvalidSampleIndexTests(testCtx));
120
121 return multisample.release();
122 }
123
124 } // texture
125 } // vkt
126