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, ©Region);
258
259 auto bufferBarrier = makeBufferMemoryBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_HOST_READ_BIT, outputBuffer.get(), 0u, VK_WHOLE_SIZE);
260
261 vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0u, 0u, 0u, 1u, &bufferBarrier, 0u, 0u);
262
263 endCommandBuffer(vk, *cmdBuffer);
264
265 VkQueue queue;
266 vk.getDeviceQueue(*m_device, queueFamilyIndex, 0, &queue);
267 submitCommandsAndWait(vk, *m_device, queue, *cmdBuffer);
268
269 // for robustBufferAccess (the original feature) OOB access will return undefined value;
270 // we can only expect that above drawing will be executed without errors (we can't expect any specific result)
271 if (m_robustnessVersion < 2u)
272 return tcu::TestStatus::pass("Pass");
273
274 // get output buffer
275 invalidateAlloc(vk, *m_device, outputBuffer.getAllocation());
276 const tcu::TextureFormat resultFormat = mapVkFormat(colorFormat);
277 tcu::ConstPixelBufferAccess outputAccess(resultFormat, renderSize.x(), renderSize.y(), 1u, outputBuffer.getAllocation().getHostPtr());
278
279 // for VK_EXT_robustness2 OOB access should return 0 and we can verify
280 // that single fragment is drawn in the middle-top part of the image
281 tcu::UVec4 expectedValue(51, 255, 127, 255);
282 bool fragmentFound = false;
283
284 for (deUint32 x = 0u; x < renderSize.x(); ++x)
285 for (deUint32 y = 0u; y < renderSize.y(); ++y)
286 {
287 tcu::UVec4 pixel = outputAccess.getPixelUint(x, y, 0);
288
289 if (tcu::boolAll(tcu::lessThan(tcu::absDiff(pixel, expectedValue), tcu::UVec4(2))))
290 {
291 if (fragmentFound)
292 {
293 m_context.getTestContext().getLog()
294 << tcu::TestLog::Message << "Expected single fragment with: " << expectedValue
295 << " color, got more, second at " << tcu::UVec2(x, y) << tcu::TestLog::EndMessage
296 << tcu::TestLog::Image("Result", "Result", outputAccess);
297 return tcu::TestStatus::fail("Fail");
298 }
299 else if ((y < 3) && (x > 5) && (x < 10))
300 fragmentFound = true;
301 else
302 {
303 m_context.getTestContext().getLog()
304 << tcu::TestLog::Message << "Expected fragment in the middle-top of the image, got at: "
305 << tcu::UVec2(x, y) << tcu::TestLog::EndMessage
306 << tcu::TestLog::Image("Result", "Result", outputAccess);
307 return tcu::TestStatus::fail("Fail");
308 }
309 }
310 }
311
312 if (fragmentFound)
313 return tcu::TestStatus::pass("Pass");
314 return tcu::TestStatus::fail("Fail");
315 }
316
317 class DrawIndexedTestCase : public vkt::TestCase
318 {
319 public:
320
321 DrawIndexedTestCase (tcu::TestContext& testContext,
322 const std::string& name,
323 TestMode mode,
324 deUint32 robustnessVersion);
325
326 virtual ~DrawIndexedTestCase (void) = default;
327
328 void checkSupport (Context& context) const override;
329 TestInstance* createInstance (Context& context) const override;
330 void initPrograms (SourceCollections& programCollection) const override;
331
332 protected:
333 const TestMode m_testMode;
334 const deUint32 m_robustnessVersion;
335 };
336
DrawIndexedTestCase(tcu::TestContext & testContext,const std::string & name,TestMode mode,deUint32 robustnessVersion)337 DrawIndexedTestCase::DrawIndexedTestCase(tcu::TestContext& testContext,
338 const std::string& name,
339 TestMode mode,
340 deUint32 robustnessVersion)
341
342 : vkt::TestCase (testContext, name, "")
343 , m_testMode (mode)
344 , m_robustnessVersion (robustnessVersion)
345 {}
346
checkSupport(Context & context) const347 void DrawIndexedTestCase::checkSupport(Context& context) const
348 {
349 if (context.isDeviceFunctionalitySupported("VK_KHR_portability_subset") && !context.getDeviceFeatures().robustBufferAccess)
350 TCU_THROW(NotSupportedError, "VK_KHR_portability_subset: robustBufferAccess not supported by this implementation");
351
352 if (m_testMode == TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT)
353 context.requireDeviceFunctionality("VK_KHR_draw_indirect_count");
354 if (m_testMode == TestMode::TM_DRAW_MULTI_INDEXED)
355 context.requireDeviceFunctionality("VK_EXT_multi_draw");
356 if (m_robustnessVersion == 2)
357 {
358 context.requireDeviceFunctionality("VK_EXT_robustness2");
359
360 const auto& vki = context.getInstanceInterface();
361 const auto physicalDevice = context.getPhysicalDevice();
362
363 VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = initVulkanStructure();
364 VkPhysicalDeviceFeatures2 features2 = initVulkanStructure(&robustness2Features);
365
366 vki.getPhysicalDeviceFeatures2(physicalDevice, &features2);
367
368 if (!robustness2Features.robustBufferAccess2)
369 TCU_THROW(NotSupportedError, "robustBufferAccess2 not supported");
370 }
371 }
372
createInstance(Context & context) const373 TestInstance* DrawIndexedTestCase::createInstance(Context& context) const
374 {
375 VkPhysicalDeviceFeatures2 features2 = initVulkanStructure();
376 features2.features.robustBufferAccess = DE_TRUE;
377
378 void** nextPtr = &features2.pNext;
379
380 #ifndef CTS_USES_VULKANSC
381 VkPhysicalDeviceMultiDrawFeaturesEXT multiDrawFeatures = initVulkanStructure();
382 if (m_testMode == TestMode::TM_DRAW_MULTI_INDEXED)
383 {
384 multiDrawFeatures.multiDraw = DE_TRUE;
385 addToChainVulkanStructure(&nextPtr, multiDrawFeatures);
386 }
387 #endif // CTS_USES_VULKANSC
388
389 VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = initVulkanStructure();
390 if (m_robustnessVersion > 1u)
391 {
392 robustness2Features.robustBufferAccess2 = DE_TRUE;
393 addToChainVulkanStructure(&nextPtr, robustness2Features);
394 }
395
396 deUint32 apiVersion = context.getUsedApiVersion();
397 VkPhysicalDeviceVulkan12Features vulkan12Features = initVulkanStructure();
398 if ((m_testMode == TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT) && (apiVersion > VK_MAKE_API_VERSION(0, 1, 1, 0)))
399 {
400 vulkan12Features.drawIndirectCount = DE_TRUE;
401 addToChainVulkanStructure(&nextPtr, vulkan12Features);
402 }
403
404 Move<VkDevice> device = createRobustBufferAccessDevice(context, &features2);
405 DeviceDriverPtr deviceDriver =
406 #ifndef CTS_USES_VULKANSC
407 DeviceDriverPtr(new DeviceDriver(context.getPlatformInterface(), context.getInstance(), *device));
408 #else
409 DeviceDriverPtr(new DeviceDriverSC(context.getPlatformInterface(), context.getInstance(), *device, context.getTestContext().getCommandLine(),
410 context.getResourceInterface(), context.getDeviceVulkanSC10Properties(), context.getDeviceProperties()),
411 vk::DeinitDeviceDeleter(context.getResourceInterface().get(), *device));
412 #endif // CTS_USES_VULKANSC
413
414 return new DrawIndexedInstance(context, device, deviceDriver, m_testMode, m_robustnessVersion);
415 }
416
initPrograms(SourceCollections & sourceCollections) const417 void DrawIndexedTestCase::initPrograms(SourceCollections& sourceCollections) const
418 {
419 std::string vertexSource(
420 "#version 450\n"
421 "layout(location = 0) in vec4 inPosition;\n"
422 "void main(void)\n"
423 "{\n"
424 "\tgl_Position = inPosition;\n"
425 "\tgl_PointSize = 1.0;\n"
426 "}\n");
427 sourceCollections.glslSources.add("vert") << glu::VertexSource(vertexSource);
428
429 std::string fragmentSource(
430 "#version 450\n"
431 "precision highp float;\n"
432 "layout(location = 0) out vec4 fragColor;\n"
433 "void main (void)\n"
434 "{\n"
435 "\tfragColor = vec4(0.2, 1.0, 0.5, 1.0);\n"
436 "}\n");
437
438 sourceCollections.glslSources.add("frag") << glu::FragmentSource(fragmentSource);
439 }
440
createIndexAccessTests(tcu::TestContext & testCtx)441 tcu::TestCaseGroup* createIndexAccessTests(tcu::TestContext& testCtx)
442 {
443 de::MovePtr<tcu::TestCaseGroup> indexAccessTests(new tcu::TestCaseGroup(testCtx, "index_access", "Test access outside of the buffer for indices"));
444
445 struct TestConfig
446 {
447 std::string name;
448 TestMode mode;
449 };
450
451 const std::vector<TestConfig> testConfigs
452 {
453 { "draw_indexed", TestMode::TM_DRAW_INDEXED },
454 { "draw_indexed_indirect", TestMode::TM_DRAW_INDEXED_INDIRECT },
455 { "draw_indexed_indirect_count", TestMode::TM_DRAW_INDEXED_INDIRECT_COUNT },
456 { "draw_multi_indexed", TestMode::TM_DRAW_MULTI_INDEXED },
457 };
458
459 const deUint32 robustnessVersion = 2;
460 for (const auto& c : testConfigs)
461 {
462 std::string name = c.name + "_" + std::to_string(robustnessVersion);
463 indexAccessTests->addChild(new DrawIndexedTestCase(testCtx, name, c.mode, robustnessVersion));
464 }
465
466 return indexAccessTests.release();
467 }
468
469 } // robustness
470 } // vkt
471