• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2022 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Robust Index Buffer Access Tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vktRobustnessIndexAccessTests.hpp"
25 #include "vkBufferWithMemory.hpp"
26 #include "vkImageWithMemory.hpp"
27 #include "vktRobustnessUtil.hpp"
28 #include "vktTestCaseUtil.hpp"
29 #include "vkBuilderUtil.hpp"
30 #include "vkImageUtil.hpp"
31 #include "vkMemUtil.hpp"
32 #include "vkPrograms.hpp"
33 #include "vkQueryUtil.hpp"
34 #include "vkDeviceUtil.hpp"
35 #include "vkBarrierUtil.hpp"
36 #include "vkRef.hpp"
37 #include "vkRefUtil.hpp"
38 #include "vkTypeUtil.hpp"
39 #include "vkObjUtil.hpp"
40 #include "vkCmdUtil.hpp"
41 #include "tcuTestLog.hpp"
42 #include "deMath.h"
43 #include "tcuVectorUtil.hpp"
44 #include "deUniquePtr.hpp"
45 #include <vector>
46 
47 namespace vkt
48 {
49 namespace robustness
50 {
51 
52 using namespace vk;
53 
54 #ifndef CTS_USES_VULKANSC
55 typedef de::MovePtr<vk::DeviceDriver> DeviceDriverPtr;
56 #else
57 typedef de::MovePtr<vk::DeviceDriverSC, vk::DeinitDeviceDeleter> DeviceDriverPtr;
58 #endif // CTS_USES_VULKANSC
59 
60 enum TestMode
61 {
62 	TM_DRAW_INDEXED					= 0,
63 	TM_DRAW_INDEXED_INDIRECT,
64 	TM_DRAW_INDEXED_INDIRECT_COUNT,
65 	TM_DRAW_MULTI_INDEXED,
66 };
67 
68 class DrawIndexedInstance : public vkt::TestInstance
69 {
70 public:
71 								DrawIndexedInstance		(Context&										context,
72 														 Move<VkDevice>									device,
73 														 DeviceDriverPtr								deviceDriver,
74 														 TestMode										mode,
75 														 deUint32										robustnessVersion);
76 
77 	virtual						~DrawIndexedInstance	(void) = default;
78 
79 	virtual tcu::TestStatus		iterate					(void);
80 
81 protected:
82 
83 	Move<VkDevice>								m_device;
84 	DeviceDriverPtr								m_deviceDriver;
85 	TestMode									m_mode;
86 	deUint32									m_robustnessVersion;
87 };
88 
DrawIndexedInstance(Context & context,Move<VkDevice> device,DeviceDriverPtr deviceDriver,TestMode mode,deUint32 robustnessVersion)89 DrawIndexedInstance::DrawIndexedInstance(Context&								context,
90 										 Move<VkDevice>							device,
91 										 DeviceDriverPtr						deviceDriver,
92 										 TestMode								mode,
93 										 deUint32								robustnessVersion)
94 	: vkt::TestInstance			(context)
95 	, m_device					(device)
96 	, m_deviceDriver			(deviceDriver)
97 	, m_mode					(mode)
98 	, m_robustnessVersion		(robustnessVersion)
99 {
100 }
101 
iterate(void)102 tcu::TestStatus DrawIndexedInstance::iterate(void)
103 {
104 	const DeviceInterface&	vk					= *m_deviceDriver;
105 	const deUint32			queueFamilyIndex	= m_context.getUniversalQueueFamilyIndex();
106 	const auto&				vki					= m_context.getInstanceInterface();
107 	const VkPhysicalDevice	physicalDevice		= chooseDevice(vki, m_context.getInstance(), m_context.getTestContext().getCommandLine());
108 	SimpleAllocator			memAlloc			(vk, *m_device, getPhysicalDeviceMemoryProperties(vki, physicalDevice));
109 
110 	// this is testsed - first index in index buffer is outside of bounds
111 	const deUint32					oobFirstIndex = std::numeric_limits<deUint32>::max() - 100;
112 
113 	const VkFormat					colorFormat	{ VK_FORMAT_R8G8B8A8_UNORM };
114 	const tcu::UVec2				renderSize	{ 16 };
115 	const std::vector<VkViewport>	viewports	{ makeViewport(renderSize) };
116 	const std::vector<VkRect2D>		scissors	{ makeRect2D(renderSize) };
117 
118 	// create vertex buffer
119 	const std::vector<float> vertices
120 	{
121 		 0.0f, -0.8f,    0.0f, 1.0f,
122 		 0.0f,  0.8f,    0.0f, 1.0f,
123 		 0.8f, -0.8f,    0.0f, 1.0f,
124 		 0.8f,  0.8f,    0.0f, 1.0f,
125 		-0.8f, -0.8f,    0.0f, 1.0f,
126 		-0.8f,  0.8f,    0.0f, 1.0f,
127 	};
128 	const VkBufferCreateInfo vertexBufferInfo = makeBufferCreateInfo(vertices.size() * sizeof(float), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
129 	BufferWithMemory vertexBuffer(vk, *m_device, memAlloc, vertexBufferInfo, MemoryRequirement::HostVisible);
130 	deMemcpy(vertexBuffer.getAllocation().getHostPtr(), vertices.data(), vertices.size() * sizeof(float));
131 	flushAlloc(vk, *m_device, vertexBuffer.getAllocation());
132 
133 	// create index buffer for 6 points
134 	// 4--0--2
135 	// |  |  |
136 	// 5--1--3
137 	const std::vector<deUint32> index = { 0, 1, 2, 3, 4, 5 };
138 	const VkBufferCreateInfo indexBufferInfo = makeBufferCreateInfo(index.size() * sizeof(deUint32), VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
139 	BufferWithMemory indexBuffer(vk, *m_device, memAlloc, indexBufferInfo, MemoryRequirement::HostVisible);
140 	deMemcpy(indexBuffer.getAllocation().getHostPtr(), index.data(), index.size() * sizeof(deUint32));
141 	flushAlloc(vk, *m_device, indexBuffer.getAllocation());
142 
143 	// create indirect buffer
144 	const vk::VkDrawIndexedIndirectCommand drawIndirectCommand
145 	{
146 		(deUint32)index.size(),	// indexCount
147 		1u,						// instanceCount
148 		oobFirstIndex,			// firstIndex
149 		0u,						// vertexOffset
150 		0u,						// firstInstance
151 	};
152 	const VkBufferCreateInfo indirectBufferInfo = makeBufferCreateInfo(sizeof(drawIndirectCommand), VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
153 	BufferWithMemory indirectBuffer(vk, *m_device, memAlloc, indirectBufferInfo, MemoryRequirement::HostVisible);
154 	if ((m_mode == TM_DRAW_INDEXED_INDIRECT) || (m_mode == TM_DRAW_INDEXED_INDIRECT_COUNT))
155 	{
156 		deMemcpy(indirectBuffer.getAllocation().getHostPtr(), &drawIndirectCommand, sizeof(drawIndirectCommand));
157 		flushAlloc(vk, *m_device, indirectBuffer.getAllocation());
158 	}
159 
160 	// create indirect count buffer
161 	const VkBufferCreateInfo indirectCountBufferInfo = makeBufferCreateInfo(sizeof(deUint32), VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
162 	BufferWithMemory indirectCountBuffer(vk, *m_device, memAlloc, indirectCountBufferInfo, MemoryRequirement::HostVisible);
163 	if (m_mode == TM_DRAW_INDEXED_INDIRECT_COUNT)
164 	{
165 		*(reinterpret_cast<deUint32*>(indirectCountBuffer.getAllocation().getHostPtr())) = 1;
166 		flushAlloc(vk, *m_device, indirectCountBuffer.getAllocation());
167 	}
168 
169 	// create output buffer that will be used to read rendered image
170 	const VkDeviceSize outputBufferSize = renderSize.x()* renderSize.y()* tcu::getPixelSize(mapVkFormat(colorFormat));
171 	const VkBufferCreateInfo outputBufferInfo = makeBufferCreateInfo(outputBufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
172 	BufferWithMemory outputBuffer(vk, *m_device, memAlloc, outputBufferInfo, MemoryRequirement::HostVisible);
173 
174 	// create color buffer
175 	VkExtent3D imageExtent = makeExtent3D(renderSize.x(), renderSize.y(), 1u);
176 	const VkImageCreateInfo imageCreateInfo
177 	{
178 		VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,									//	VkStructureType			sType;
179 		DE_NULL,																//	const void*				pNext;
180 		0u,																		//	VkImageCreateFlags		flags;
181 		VK_IMAGE_TYPE_2D,														//	VkImageType				imageType;
182 		colorFormat,															//	VkFormat				format;
183 		imageExtent,															//	VkExtent3D				extent;
184 		1u,																		//	deUint32				mipLevels;
185 		1u,																		//	deUint32				arrayLayers;
186 		VK_SAMPLE_COUNT_1_BIT,													//	VkSampleCountFlagBits	samples;
187 		VK_IMAGE_TILING_OPTIMAL,												//	VkImageTiling			tiling;
188 		VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,	//	VkImageUsageFlags		usage;
189 		VK_SHARING_MODE_EXCLUSIVE,												//	VkSharingMode			sharingMode;
190 		0u,																		//	deUint32				queueFamilyIndexCount;
191 		DE_NULL,																//	const deUint32*			pQueueFamilyIndices;
192 		VK_IMAGE_LAYOUT_UNDEFINED,												//	VkImageLayout			initialLayout;
193 	};
194 	const VkImageSubresourceRange colorSRR = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
195 	ImageWithMemory colorImage(vk, *m_device, memAlloc, imageCreateInfo, MemoryRequirement::Any);
196 	Move<VkImageView> colorImageView = makeImageView(vk, *m_device, colorImage.get(), VK_IMAGE_VIEW_TYPE_2D, colorFormat, colorSRR);
197 
198 	// create shader modules, renderpass, framebuffer and pipeline
199 	Move<VkShaderModule>	vertShaderModule	= createShaderModule(vk, *m_device, m_context.getBinaryCollection().get("vert"), 0);
200 	Move<VkShaderModule>	fragShaderModule	= createShaderModule(vk, *m_device, m_context.getBinaryCollection().get("frag"), 0);
201 	Move<VkRenderPass>		renderPass			= makeRenderPass(vk, *m_device, colorFormat);
202 	Move<VkPipelineLayout>	pipelineLayout		= makePipelineLayout(vk, *m_device, DE_NULL);
203 	Move<VkFramebuffer>		framebuffer			= makeFramebuffer(vk, *m_device, *renderPass, *colorImageView, renderSize.x(), renderSize.y());
204 	Move<VkPipeline>		graphicsPipeline	= makeGraphicsPipeline(vk, *m_device, *pipelineLayout,
205 																	   *vertShaderModule, DE_NULL, DE_NULL, DE_NULL, *fragShaderModule,
206 																	   *renderPass, viewports, scissors, VK_PRIMITIVE_TOPOLOGY_POINT_LIST);
207 
208 	Move<VkCommandPool>				cmdPool		= createCommandPool(vk, *m_device, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, queueFamilyIndex);
209 	vk::Move<vk::VkCommandBuffer>	cmdBuffer	= allocateCommandBuffer(vk, *m_device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY);
210 
211 	beginCommandBuffer(vk, *cmdBuffer);
212 
213 	// transition colorbuffer layout
214 	VkImageMemoryBarrier imageBarrier = makeImageMemoryBarrier(0u, VK_ACCESS_SHADER_WRITE_BIT,
215 															   VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
216 															   colorImage.get(), colorSRR);
217 	vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0u, 0u, 0u, 0u, 0u, 1u, &imageBarrier);
218 
219 	const VkRect2D renderArea = makeRect2D(0, 0, renderSize.x(), renderSize.y());
220 	beginRenderPass(vk, *cmdBuffer, *renderPass, *framebuffer, renderArea, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
221 
222 	const VkDeviceSize vBuffOffset = 0;
223 	vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *graphicsPipeline);
224 	vk.cmdBindVertexBuffers(*cmdBuffer, 0, 1, &vertexBuffer.get(), &vBuffOffset);
225 	vk.cmdBindIndexBuffer(*cmdBuffer, indexBuffer.get(), 0, VK_INDEX_TYPE_UINT32);
226 
227 	// we will draw all points at index 0
228 	if (m_mode == TM_DRAW_INDEXED)
229 		vk.cmdDrawIndexed(*cmdBuffer, (deUint32)index.size(), 1, oobFirstIndex, 0, 0);
230 	else if (m_mode == TM_DRAW_INDEXED_INDIRECT)
231 		vk.cmdDrawIndexedIndirect(*cmdBuffer, indirectBuffer.get(), 0, 1, 0);
232 	else if (m_mode == TM_DRAW_INDEXED_INDIRECT_COUNT)
233 		vk.cmdDrawIndexedIndirectCount(*cmdBuffer, indirectBuffer.get(), 0, indirectCountBuffer.get(), 0, 1, sizeof(VkDrawIndexedIndirectCommand));
234 	else if (m_mode == TM_DRAW_MULTI_INDEXED)
235 	{
236 #ifndef CTS_USES_VULKANSC
237 		VkMultiDrawIndexedInfoEXT indexInfo[]
238 		{
239 			{ oobFirstIndex, 3, 0 },
240 			{ oobFirstIndex - 3, 3, 0 },
241 		};
242 		vk.cmdDrawMultiIndexedEXT(*cmdBuffer, 2, indexInfo, 1, 0, sizeof(VkMultiDrawIndexedInfoEXT), DE_NULL);
243 #endif // CTS_USES_VULKANSC
244 	}
245 
246 	endRenderPass(vk, *cmdBuffer);
247 
248 	// wait till data is transfered to image
249 	imageBarrier = makeImageMemoryBarrier(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT,
250 										  VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
251 										  colorImage.get(), colorSRR);
252 	vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, 0u, 0u, 0u, 1u, &imageBarrier);
253 
254 	// read back color image
255 	const VkImageSubresourceLayers colorSL = makeImageSubresourceLayers(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u);
256 	const VkBufferImageCopy copyRegion = makeBufferImageCopy(imageExtent, colorSL);
257 	vk.cmdCopyImageToBuffer(*cmdBuffer, colorImage.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, outputBuffer.get(), 1u, &copyRegion);
258 
259 	endCommandBuffer(vk, *cmdBuffer);
260 
261 	VkQueue queue;
262 	vk.getDeviceQueue(*m_device, queueFamilyIndex, 0, &queue);
263 	submitCommandsAndWait(vk, *m_device, queue, *cmdBuffer);
264 
265 	// for robustBufferAccess (the original feature) OOB access will return undefined value;
266 	// we can only expect that above drawing will be executed without errors (we can't expect any specific result)
267 	if (m_robustnessVersion < 2u)
268 		return tcu::TestStatus::pass("Pass");
269 
270 	// get output buffer
271 	invalidateAlloc(vk, *m_device, outputBuffer.getAllocation());
272 	const tcu::TextureFormat resultFormat = mapVkFormat(colorFormat);
273 	tcu::ConstPixelBufferAccess outputAccess(resultFormat, renderSize.x(), renderSize.y(), 1u, outputBuffer.getAllocation().getHostPtr());
274 
275 	// for VK_EXT_robustness2 OOB access should return 0 and we can verify
276 	// that single fragment is drawn in the middle-top part of the image
277 	tcu::UVec4 expectedValue(51, 255, 127, 255);
278 	bool fragmentFound = false;
279 
280 	for (deUint32 x = 0u; x < renderSize.x(); ++x)
281 	for (deUint32 y = 0u; y < renderSize.y(); ++y)
282 	{
283 		tcu::UVec4 pixel = outputAccess.getPixelUint(x, y, 0);
284 
285 		if (tcu::boolAll(tcu::lessThan(tcu::absDiff(pixel, expectedValue), tcu::UVec4(2))))
286 		{
287 			if (fragmentFound)
288 			{
289 				m_context.getTestContext().getLog()
290 					<< tcu::TestLog::Message << "Expected single fragment with: " << expectedValue
291 					<< " color, got more, second at " << tcu::UVec2(x, y) << tcu::TestLog::EndMessage
292 					<< tcu::TestLog::Image("Result", "Result", outputAccess);
293 				return tcu::TestStatus::fail("Fail");
294 			}
295 			else if ((y < 3) && (x > 5) && (x < 10))
296 				fragmentFound = true;
297 			else
298 			{
299 				m_context.getTestContext().getLog()
300 					<< tcu::TestLog::Message << "Expected fragment in the middle-top of the image, got at: "
301 					<< tcu::UVec2(x, y) << tcu::TestLog::EndMessage
302 					<< tcu::TestLog::Image("Result", "Result", outputAccess);
303 				return tcu::TestStatus::fail("Fail");
304 			}
305 		}
306 	}
307 
308 	if (fragmentFound)
309 		return tcu::TestStatus::pass("Pass");
310 	return tcu::TestStatus::fail("Fail");
311 }
312 
313 class DrawIndexedTestCase : public vkt::TestCase
314 {
315 public:
316 
317 						DrawIndexedTestCase		(tcu::TestContext&		testContext,
318 												 const std::string&		name,
319 												 TestMode				mode,
320 												 deUint32				robustnessVersion);
321 
322 	virtual				~DrawIndexedTestCase	(void) = default;
323 
324 	void				checkSupport			(Context& context) const override;
325 	TestInstance*		createInstance			(Context& context) const override;
326 	void				initPrograms			(SourceCollections& programCollection) const override;
327 
328 protected:
329 	const TestMode		m_testMode;
330 	const deUint32		m_robustnessVersion;
331 };
332 
DrawIndexedTestCase(tcu::TestContext & testContext,const std::string & name,TestMode mode,deUint32 robustnessVersion)333 DrawIndexedTestCase::DrawIndexedTestCase(tcu::TestContext&		testContext,
334 										 const std::string&		name,
335 										 TestMode				mode,
336 										 deUint32				robustnessVersion)
337 
338 	: vkt::TestCase			(testContext, name, "")
339 	, m_testMode			(mode)
340 	, m_robustnessVersion	(robustnessVersion)
341 {}
342 
checkSupport(Context & context) const343 void DrawIndexedTestCase::checkSupport(Context& context) const
344 {
345 	if (context.isDeviceFunctionalitySupported("VK_KHR_portability_subset") && !context.getDeviceFeatures().robustBufferAccess)
346 		TCU_THROW(NotSupportedError, "VK_KHR_portability_subset: robustBufferAccess not supported by this implementation");
347 
348 	if (m_testMode == TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT)
349 		context.requireDeviceFunctionality("VK_KHR_draw_indirect_count");
350 	if (m_testMode == TestMode::TM_DRAW_MULTI_INDEXED)
351 		context.requireDeviceFunctionality("VK_EXT_multi_draw");
352 	if (m_robustnessVersion == 2)
353 	{
354 		context.requireDeviceFunctionality("VK_EXT_robustness2");
355 
356 		const auto& vki				= context.getInstanceInterface();
357 		const auto	physicalDevice	= context.getPhysicalDevice();
358 
359 		VkPhysicalDeviceRobustness2FeaturesEXT	robustness2Features	= initVulkanStructure();
360 		VkPhysicalDeviceFeatures2				features2			= initVulkanStructure(&robustness2Features);
361 
362 		vki.getPhysicalDeviceFeatures2(physicalDevice, &features2);
363 
364 		if (!robustness2Features.robustBufferAccess2)
365 			TCU_THROW(NotSupportedError, "robustBufferAccess2 not supported");
366 	}
367 }
368 
createInstance(Context & context) const369 TestInstance* DrawIndexedTestCase::createInstance(Context& context) const
370 {
371 	VkPhysicalDeviceFeatures2 features2 = initVulkanStructure();
372 	features2.features.robustBufferAccess = DE_TRUE;
373 
374 	void** nextPtr = &features2.pNext;
375 
376 #ifndef CTS_USES_VULKANSC
377 	VkPhysicalDeviceMultiDrawFeaturesEXT multiDrawFeatures = initVulkanStructure();
378 	if (m_testMode == TestMode::TM_DRAW_MULTI_INDEXED)
379 	{
380 		multiDrawFeatures.multiDraw = DE_TRUE;
381 		addToChainVulkanStructure(&nextPtr, multiDrawFeatures);
382 	}
383 #endif // CTS_USES_VULKANSC
384 
385 	VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = initVulkanStructure();
386 	if (m_robustnessVersion > 1u)
387 	{
388 		robustness2Features.robustBufferAccess2 = DE_TRUE;
389 		addToChainVulkanStructure(&nextPtr, robustness2Features);
390 	}
391 
392 	deUint32 apiVersion = context.getUsedApiVersion();
393 	VkPhysicalDeviceVulkan12Features vulkan12Features = initVulkanStructure();
394 	if ((m_testMode == TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT) && (apiVersion > VK_MAKE_API_VERSION(0, 1, 1, 0)))
395 	{
396 		vulkan12Features.drawIndirectCount = DE_TRUE;
397 		addToChainVulkanStructure(&nextPtr, vulkan12Features);
398 	}
399 
400 	Move<VkDevice>	device = createRobustBufferAccessDevice(context, &features2);
401 	DeviceDriverPtr deviceDriver =
402 #ifndef CTS_USES_VULKANSC
403 		DeviceDriverPtr(new DeviceDriver(context.getPlatformInterface(), context.getInstance(), *device));
404 #else
405 		DeviceDriverPtr(new DeviceDriverSC(context.getPlatformInterface(), context.getInstance(), *device, context.getTestContext().getCommandLine(),
406 										   context.getResourceInterface(), context.getDeviceVulkanSC10Properties(), context.getDeviceProperties()),
407 						vk::DeinitDeviceDeleter(context.getResourceInterface().get(), *device));
408 #endif // CTS_USES_VULKANSC
409 
410 	return new DrawIndexedInstance(context, device, deviceDriver, m_testMode, m_robustnessVersion);
411 }
412 
initPrograms(SourceCollections & sourceCollections) const413 void DrawIndexedTestCase::initPrograms(SourceCollections& sourceCollections) const
414 {
415 	std::string vertexSource(
416 		"#version 450\n"
417 		"layout(location = 0) in vec4 inPosition;\n"
418 		"void main(void)\n"
419 		"{\n"
420 		"\tgl_Position = inPosition;\n"
421 		"\tgl_PointSize = 1.0;\n"
422 		"}\n");
423 	sourceCollections.glslSources.add("vert") << glu::VertexSource(vertexSource);
424 
425 	std::string fragmentSource(
426 		"#version 450\n"
427 		"precision highp float;\n"
428 		"layout(location = 0) out vec4 fragColor;\n"
429 		"void main (void)\n"
430 		"{\n"
431 		"\tfragColor = vec4(0.2, 1.0, 0.5, 1.0);\n"
432 		"}\n");
433 
434 	sourceCollections.glslSources.add("frag") << glu::FragmentSource(fragmentSource);
435 }
436 
createIndexAccessTests(tcu::TestContext & testCtx)437 tcu::TestCaseGroup* createIndexAccessTests(tcu::TestContext& testCtx)
438 {
439 	de::MovePtr<tcu::TestCaseGroup> indexAccessTests(new tcu::TestCaseGroup(testCtx, "index_access", "Test access outside of the buffer for indices"));
440 
441 	struct TestConfig
442 	{
443 		std::string		name;
444 		TestMode		mode;
445 	};
446 
447 	const std::vector<TestConfig> testConfigs
448 	{
449 		{ "draw_indexed",					TestMode::TM_DRAW_INDEXED },
450 		{ "draw_indexed_indirect",			TestMode::TM_DRAW_INDEXED_INDIRECT },
451 		{ "draw_indexed_indirect_count",	TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT },
452 		{ "draw_multi_indexed",				TestMode::TM_DRAW_MULTI_INDEXED },
453 	};
454 
455 	for (deUint32 robustnessVersion = 1; robustnessVersion < 3; ++robustnessVersion)
456 	{
457 		for (const auto& c : testConfigs)
458 		{
459 			std::string name = c.name + "_" + std::to_string(robustnessVersion);
460 			indexAccessTests->addChild(new DrawIndexedTestCase(testCtx, name, c.mode, robustnessVersion));
461 		}
462 	}
463 
464 	return indexAccessTests.release();
465 }
466 
467 } // robustness
468 } // vkt
469