• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"));
41 
42 	// .srgb
43 	{
44 		tcu::TestCaseGroup* const	srgb		= new tcu::TestCaseGroup(testCtx, "srgb");
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 		// Test uniform texel buffer with packed formats
107 		tcu::TestCaseGroup* const	packed		= new tcu::TestCaseGroup(testCtx, "packed");
108 		static const char			dataDir[]	= "texture/texel_buffer/uniform/packed";
109 
110 		static const std::string	cases[]		=
111 		{
112 			"a2b10g10r10-uint-pack32",
113 			"a2b10g10r10-unorm-pack32",
114 			"a8b8g8r8-sint-pack32",
115 			"a8b8g8r8-snorm-pack32",
116 			"a8b8g8r8-uint-pack32",
117 			"a8b8g8r8-unorm-pack32",
118 			"b10g11r11-ufloat-pack32"
119 		};
120 
121 		uniform->addChild(packed);
122 
123 		for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
124 		{
125 			const std::string			fileName	= cases[i] + ".amber";
126 			cts_amber::AmberTestCase*	testCase	= cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName);
127 
128 			packed->addChild(testCase);
129 		}
130 	}
131 #endif
132 
133 	// .snorm
134 #ifndef CTS_USES_VULKANSC
135 	{
136 		tcu::TestCaseGroup* const	snorm		= new tcu::TestCaseGroup(testCtx, "snorm", "Test uniform texel buffer with SNORM formats");
137 		static const char			dataDir[]	= "texture/texel_buffer/uniform/snorm";
138 
139 		static const struct {
140 			std::string	testName;
141 			bool		mandatoryFormat;
142 			VkFormat	format;
143 		} cases[]                               =
144 		{
145 			{	"b8g8r8-snorm",			false,	VK_FORMAT_B8G8R8_SNORM			},
146 			{	"b8g8r8a8-snorm",		false,	VK_FORMAT_B8G8R8A8_SINT			},
147 			{	"r16-snorm",			false,	VK_FORMAT_R16_SNORM				},
148 			{	"r16g16-snorm",			false,	VK_FORMAT_R16G16_SNORM			},
149 			{	"r16g16b16-snorm",		false,	VK_FORMAT_R16G16B16_SNORM		},
150 			{	"r16g16b16a16-snorm",	false,	VK_FORMAT_R16G16B16A16_SNORM	},
151 			{	"r8-snorm",				true,	VK_FORMAT_R8_SNORM				},
152 			{	"r8g8-snorm",			true,	VK_FORMAT_R8G8_SNORM			},
153 			{	"r8g8b8-snorm",			false,	VK_FORMAT_R8G8B8_SNORM			},
154 			{	"r8g8b8a8-snorm",		false,	VK_FORMAT_R8G8B8A8_SNORM		}
155 		};
156 
157 		uniform->addChild(snorm);
158 
159 		for (const auto& c : cases)
160 		{
161 			const std::string							fileName			= c.testName + ".amber";
162 			std::vector<cts_amber::BufferRequirement>	bufferRequirements;
163 
164 			if (!c.mandatoryFormat)
165 				bufferRequirements.push_back({c.format, VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT});
166 
167 			cts_amber::AmberTestCase*					testCase			= cts_amber::createAmberTestCase(testCtx, c.testName.c_str(),
168 																											 dataDir, fileName,
169 																											 std::vector<std::string>(),
170 																											 std::vector<vk::VkImageCreateInfo>(),
171 																											 bufferRequirements);
172 
173 			snorm->addChild(testCase);
174 		}
175 	}
176 #endif
177 
178 	return uniform.release();
179 }
180 
181 } // anonymous
182 
createTextureTexelBufferTests(tcu::TestContext & testCtx)183 tcu::TestCaseGroup* createTextureTexelBufferTests (tcu::TestContext& testCtx)
184 {
185 	de::MovePtr<tcu::TestCaseGroup> texelBuffer (new tcu::TestCaseGroup(testCtx, "texel_buffer", "Test texel buffer"));
186 
187 	texelBuffer->addChild(createUniformTexelBufferTests(testCtx));
188 
189 	return texelBuffer.release();
190 }
191 
192 } // texture
193 } // vkt
194