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 Texel buffer tests.
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktTextureTexelBufferTests.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
createUniformTexelBufferTests(tcu::TestContext & testCtx)38 tcu::TestCaseGroup* createUniformTexelBufferTests (tcu::TestContext& testCtx)
39 {
40 de::MovePtr<tcu::TestCaseGroup> uniform (new tcu::TestCaseGroup(testCtx, "uniform", "Test uniform texel buffer"));
41
42 // .srgb
43 {
44 tcu::TestCaseGroup* const srgb = new tcu::TestCaseGroup(testCtx, "srgb", "Test uniform texel buffer with srgb formats");
45 static const char dataDir[] = "texture/texel_buffer/uniform/srgb";
46
47 static const struct {
48 std::string testName;
49 VkFormat format;
50 } cases[] =
51 {
52 {"r8g8b8a8_srgb", VK_FORMAT_R8G8B8A8_SRGB},
53 {"b8g8r8a8_srgb", VK_FORMAT_B8G8R8A8_SRGB},
54 {"b8g8r8_srgb", VK_FORMAT_B8G8R8_SRGB},
55 {"r8g8b8_srgb", VK_FORMAT_R8G8B8_SRGB},
56 {"r8g8_srgb", VK_FORMAT_R8G8_SRGB},
57 {"r8_srgb", VK_FORMAT_R8_SRGB}
58 };
59
60 uniform->addChild(srgb);
61
62 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
63 {
64 const std::string fileName = cases[i].testName + ".amber";
65 const VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
66
67 const deUint32 width = 8;
68 const deUint32 height = 8;
69
70 VkImageCreateInfo imageParams =
71 {
72 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
73 DE_NULL, // const void* pNext;
74 DE_NULL, // VkImageCreateFlags flags;
75 VK_IMAGE_TYPE_2D, // VkImageType imageType;
76 cases[i].format, // VkFormat format;
77 VkExtent3D({width, height, 1u}), // VkExtent3D extent;
78 1u, // deUint32 mipLevels;
79 1u, // deUint32 arrayLayers;
80 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
81 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
82 usageFlags, // VkImageUsageFlags usage;
83 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
84 0u, // deUint32 queueFamilyIndexCount;
85 DE_NULL, // const deUint32* pQueueFamilyIndices;
86 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
87 };
88
89 std::vector<VkImageCreateInfo> imageRequirements;
90 imageRequirements.push_back(imageParams);
91
92 std::vector<cts_amber::BufferRequirement> bufferRequirements;
93 bufferRequirements.push_back({cases[i].format, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT});
94
95 cts_amber::AmberTestCase* testCase =
96 cts_amber::createAmberTestCase(testCtx, cases[i].testName.c_str(), "",
97 dataDir, fileName, std::vector<std::string>(),
98 imageRequirements, bufferRequirements);
99 srgb->addChild(testCase);
100 }
101 }
102
103 // .packed
104 #ifndef CTS_USES_VULKANSC
105 {
106 tcu::TestCaseGroup* const packed = new tcu::TestCaseGroup(testCtx, "packed", "Test uniform texel buffer with packed formats");
107 static const char dataDir[] = "texture/texel_buffer/uniform/packed";
108
109 static const std::string cases[] =
110 {
111 "a2b10g10r10-uint-pack32",
112 "a2b10g10r10-unorm-pack32",
113 "a8b8g8r8-sint-pack32",
114 "a8b8g8r8-snorm-pack32",
115 "a8b8g8r8-uint-pack32",
116 "a8b8g8r8-unorm-pack32",
117 "b10g11r11-ufloat-pack32"
118 };
119
120 uniform->addChild(packed);
121
122 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
123 {
124 const std::string fileName = cases[i] + ".amber";
125 cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), "", dataDir, fileName);
126
127 packed->addChild(testCase);
128 }
129 }
130 #endif
131
132 // .snorm
133 #ifndef CTS_USES_VULKANSC
134 {
135 tcu::TestCaseGroup* const snorm = new tcu::TestCaseGroup(testCtx, "snorm", "Test uniform texel buffer with SNORM formats");
136 static const char dataDir[] = "texture/texel_buffer/uniform/snorm";
137
138 static const struct {
139 std::string testName;
140 bool mandatoryFormat;
141 VkFormat format;
142 } cases[] =
143 {
144 { "b8g8r8-snorm", false, VK_FORMAT_B8G8R8_SNORM },
145 { "b8g8r8a8-snorm", false, VK_FORMAT_B8G8R8A8_SINT },
146 { "r16-snorm", false, VK_FORMAT_R16_SNORM },
147 { "r16g16-snorm", false, VK_FORMAT_R16G16_SNORM },
148 { "r16g16b16-snorm", false, VK_FORMAT_R16G16B16_SNORM },
149 { "r16g16b16a16-snorm", false, VK_FORMAT_R16G16B16A16_SNORM },
150 { "r8-snorm", true, VK_FORMAT_R8_SNORM },
151 { "r8g8-snorm", true, VK_FORMAT_R8G8_SNORM },
152 { "r8g8b8-snorm", false, VK_FORMAT_R8G8B8_SNORM },
153 { "r8g8b8a8-snorm", false, VK_FORMAT_R8G8B8A8_SNORM }
154 };
155
156 uniform->addChild(snorm);
157
158 for (const auto& c : cases)
159 {
160 const std::string fileName = c.testName + ".amber";
161 std::vector<cts_amber::BufferRequirement> bufferRequirements;
162
163 if (!c.mandatoryFormat)
164 bufferRequirements.push_back({c.format, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT});
165
166 cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, c.testName.c_str(), "",
167 dataDir, fileName,
168 std::vector<std::string>(),
169 std::vector<vk::VkImageCreateInfo>(),
170 bufferRequirements);
171
172 snorm->addChild(testCase);
173 }
174 }
175 #endif
176
177 return uniform.release();
178 }
179
180 } // anonymous
181
createTextureTexelBufferTests(tcu::TestContext & testCtx)182 tcu::TestCaseGroup* createTextureTexelBufferTests (tcu::TestContext& testCtx)
183 {
184 de::MovePtr<tcu::TestCaseGroup> texelBuffer (new tcu::TestCaseGroup(testCtx, "texel_buffer", "Test texel buffer"));
185
186 texelBuffer->addChild(createUniformTexelBufferTests(testCtx));
187
188 return texelBuffer.release();
189 }
190
191 } // texture
192 } // vkt
193