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