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 // Test atomic oprerations on multisample textures
41 de::MovePtr<tcu::TestCaseGroup> atomic(new tcu::TestCaseGroup(testCtx, "atomic"));
42 #ifndef CTS_USES_VULKANSC
43 static const char dataDir[] = "texture/multisample/atomic";
44
45 static const std::string cases[] = {"storage_image_r32i", "storage_image_r32ui"};
46
47 std::vector<std::string> requirements;
48
49 requirements.push_back("Features.shaderStorageImageMultisample");
50
51 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
52 {
53 const std::string fileName = cases[i] + ".amber";
54 cts_amber::AmberTestCase *testCase =
55 cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName, requirements);
56
57 atomic->addChild(testCase);
58 }
59 #endif
60
61 return atomic.release();
62 }
63
createInvalidSampleIndexTests(tcu::TestContext & testCtx)64 tcu::TestCaseGroup *createInvalidSampleIndexTests(tcu::TestContext &testCtx)
65 {
66 std::pair<std::string, VkSampleCountFlagBits> cases[] = {
67 {"sample_count_2", VK_SAMPLE_COUNT_2_BIT}, {"sample_count_4", VK_SAMPLE_COUNT_4_BIT},
68 {"sample_count_8", VK_SAMPLE_COUNT_8_BIT}, {"sample_count_16", VK_SAMPLE_COUNT_16_BIT},
69 {"sample_count_32", VK_SAMPLE_COUNT_32_BIT}, {"sample_count_64", VK_SAMPLE_COUNT_64_BIT}};
70
71 // Writes to invalid sample indices should be discarded.
72 de::MovePtr<tcu::TestCaseGroup> invalidWrites(new tcu::TestCaseGroup(testCtx, "invalid_sample_index"));
73 static const char dataDir[] = "texture/multisample/invalidsampleindex";
74 std::vector<std::string> requirements = {"Features.shaderStorageImageMultisample"};
75
76 for (const auto &testCase : cases)
77 {
78 const VkImageCreateInfo vkImageCreateInfo = {
79 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
80 DE_NULL, // pNext
81 0, // flags
82 VK_IMAGE_TYPE_2D, // imageType
83 VK_FORMAT_R8G8B8A8_UNORM, // format
84 {16, 16, 1}, // extent
85 1, // mipLevels
86 1, // arrayLayers
87 testCase.second, // samples
88 VK_IMAGE_TILING_OPTIMAL, // tiling
89 VK_IMAGE_USAGE_SAMPLED_BIT, // usage
90 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
91 0, // queueFamilyIndexCount
92 DE_NULL, // pQueueFamilyIndices
93 VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
94 };
95
96 std::vector<VkImageCreateInfo> imageRequirements = {vkImageCreateInfo};
97 const std::string fileName = testCase.first + ".amber";
98
99 invalidWrites->addChild(cts_amber::createAmberTestCase(testCtx, testCase.first.c_str(), dataDir, fileName,
100 requirements, imageRequirements));
101 }
102
103 return invalidWrites.release();
104 }
105
106 } // namespace
107
createTextureMultisampleTests(tcu::TestContext & testCtx)108 tcu::TestCaseGroup *createTextureMultisampleTests(tcu::TestContext &testCtx)
109 {
110 de::MovePtr<tcu::TestCaseGroup> multisample(new tcu::TestCaseGroup(testCtx, "multisample"));
111
112 multisample->addChild(createAtomicTests(testCtx));
113 multisample->addChild(createInvalidSampleIndexTests(testCtx));
114
115 return multisample.release();
116 }
117
118 } // namespace texture
119 } // namespace vkt
120