• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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 Vulkan Buffer View Memory Tests
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktApiBufferViewAccessTests.hpp"
26 
27 #include "deStringUtil.hpp"
28 #include "deUniquePtr.hpp"
29 #include "vktTestCase.hpp"
30 #include "vktTestCaseUtil.hpp"
31 #include "vkImageUtil.hpp"
32 #include "vkMemUtil.hpp"
33 #include "vkPrograms.hpp"
34 #include "vkQueryUtil.hpp"
35 #include "vkRef.hpp"
36 #include "vkRefUtil.hpp"
37 #include "vkTypeUtil.hpp"
38 #include "tcuImageCompare.hpp"
39 #include "tcuTexture.hpp"
40 #include "tcuTextureUtil.hpp"
41 
42 namespace vkt
43 {
44 
45 namespace api
46 {
47 
48 using namespace vk;
49 
50 namespace
51 {
52 
53 struct BufferViewCaseParams
54 {
55 	deUint32	bufferSize;
56 	deUint32	bufferViewSize;
57 	deUint32	elementOffset;
58 };
59 
60 class BufferViewTestInstance : public vkt::TestInstance
61 {
62 public:
63 										BufferViewTestInstance		(Context&				context,
64 																	 BufferViewCaseParams	testCase);
65 	virtual								~BufferViewTestInstance		(void);
66 	virtual tcu::TestStatus				iterate						(void);
67 
68 private:
69 	void								createQuad					(void);
70 	tcu::TestStatus						checkResult					(deInt8	factor = 1);
71 
72 private:
73 	BufferViewCaseParams				m_testCase;
74 
75 	const tcu::IVec2					m_renderSize;
76 	const VkFormat						m_colorFormat;
77 
78 	const VkDeviceSize					m_pixelDataSize;
79 
80 	Move<VkImage>						m_colorImage;
81 	de::MovePtr<Allocation>				m_colorImageAlloc;
82 	Move<VkImageView>					m_colorAttachmentView;
83 	Move<VkRenderPass>					m_renderPass;
84 	Move<VkFramebuffer>					m_framebuffer;
85 
86 	Move<VkDescriptorSetLayout>			m_descriptorSetLayout;
87 	Move<VkDescriptorPool>				m_descriptorPool;
88 	Move<VkDescriptorSet>				m_descriptorSet;
89 
90 	Move<VkBuffer>						m_uniformBuffer;
91 	de::MovePtr<vk::Allocation>			m_uniformBufferAlloc;
92 	Move<VkBufferView>					m_uniformBufferView;
93 
94 	Move<VkShaderModule>				m_vertexShaderModule;
95 	Move<VkShaderModule>				m_fragmentShaderModule;
96 
97 	Move<VkBuffer>						m_vertexBuffer;
98 	std::vector<tcu::Vec4>				m_vertices;
99 	de::MovePtr<Allocation>				m_vertexBufferAlloc;
100 
101 	Move<VkPipelineLayout>				m_pipelineLayout;
102 	Move<VkPipeline>					m_graphicsPipelines;
103 
104 	Move<VkCommandPool>					m_cmdPool;
105 	Move<VkCommandBuffer>				m_cmdBuffer;
106 
107 	Move<VkBuffer>						m_resultBuffer;
108 	de::MovePtr<Allocation>				m_resultBufferAlloc;
109 
110 	Move<VkFence>						m_fence;
111 };
112 
generateBuffer(std::vector<deUint32> & uniformData,deUint32 bufferSize,deInt8 factor=1)113 static void generateBuffer (std::vector<deUint32>& uniformData, deUint32 bufferSize, deInt8 factor = 1)
114 {
115 	for (deUint32 i = 0; i < bufferSize; ++i)
116 		uniformData.push_back(factor * i);
117 }
118 
createQuad(void)119 void BufferViewTestInstance::createQuad (void)
120 {
121 	tcu::Vec4 a(-1.0, -1.0, 0.0, 1.0);
122 	tcu::Vec4 b(1.0, -1.0, 0.0, 1.0);
123 	tcu::Vec4 c(1.0, 1.0, 0.0, 1.0);
124 	tcu::Vec4 d(-1.0, 1.0, 0.0, 1.0);
125 
126 	// Triangle 1
127 	m_vertices.push_back(a);
128 	m_vertices.push_back(c);
129 	m_vertices.push_back(b);
130 
131 	// Triangle 2
132 	m_vertices.push_back(c);
133 	m_vertices.push_back(a);
134 	m_vertices.push_back(d);
135 }
136 
~BufferViewTestInstance(void)137 BufferViewTestInstance::~BufferViewTestInstance	(void)
138 {
139 }
140 
BufferViewTestInstance(Context & context,BufferViewCaseParams testCase)141 BufferViewTestInstance::BufferViewTestInstance (Context& context, BufferViewCaseParams testCase)
142 	: vkt::TestInstance		(context)
143 	, m_testCase			(testCase)
144 	, m_renderSize			(testCase.bufferViewSize, testCase.bufferViewSize)
145 	, m_colorFormat			(VK_FORMAT_R32_UINT)
146 	, m_pixelDataSize		(m_renderSize.x() * m_renderSize.y() * mapVkFormat(m_colorFormat).getPixelSize())
147 {
148 	const DeviceInterface&		vk					= context.getDeviceInterface();
149 	const VkDevice				vkDevice			= context.getDevice();
150 	const deUint32				queueFamilyIndex	= context.getUniversalQueueFamilyIndex();
151 	SimpleAllocator				memAlloc			(vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
152 	const VkComponentMapping	channelMappingRGBA	= { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
153 
154 	// Create color image
155 	{
156 		const VkImageCreateInfo colorImageParams =
157 		{
158 			VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,										// VkStructureType		sType;
159 			DE_NULL,																	// const void*			pNext;
160 			0u,																			// VkImageCreateFlags	flags;
161 			VK_IMAGE_TYPE_2D,															// VkImageType			imageType;
162 			m_colorFormat,																// VkFormat				format;
163 			{ (deUint32)m_renderSize.x(), (deUint32)m_renderSize.y(), 1u },				// VkExtent3D			extent;
164 			1u,																			// deUint32				mipLevels;
165 			1u,																			// deUint32				arraySize;
166 			VK_SAMPLE_COUNT_1_BIT,														// deUint32				samples;
167 			VK_IMAGE_TILING_OPTIMAL,													// VkImageTiling		tiling;
168 			VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,		// VkImageUsageFlags	usage;
169 			VK_SHARING_MODE_EXCLUSIVE,													// VkSharingMode		sharingMode;
170 			1u,																			// deUint32				queueFamilyCount;
171 			&queueFamilyIndex,															// const deUint32*		pQueueFamilyIndices;
172 			VK_IMAGE_LAYOUT_UNDEFINED,													// VkImageLayout		initialLayout;
173 		};
174 
175 		m_colorImage			= createImage(vk, vkDevice, &colorImageParams);
176 
177 		// Allocate and bind color image memory
178 		m_colorImageAlloc		= memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_colorImage), MemoryRequirement::Any);
179 		VK_CHECK(vk.bindImageMemory(vkDevice, *m_colorImage, m_colorImageAlloc->getMemory(), m_colorImageAlloc->getOffset()));
180 	}
181 
182 	// Create destination buffer
183 	{
184 		const VkBufferCreateInfo bufferParams =
185 		{
186 			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,		// VkStructureType		sType;
187 			DE_NULL,									// const void*			pNext;
188 			0u,											// VkBufferCreateFlags	flags;
189 			m_pixelDataSize,							// VkDeviceSize			size;
190 			VK_BUFFER_USAGE_TRANSFER_DST_BIT,		   // VkBufferUsageFlags	usage;
191 			VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode		sharingMode;
192 			0u,											// deUint32				queueFamilyCount;
193 			DE_NULL,									// const deUint32*		pQueueFamilyIndices;
194 		};
195 
196 		m_resultBuffer		= createBuffer(vk, vkDevice, &bufferParams);
197 		m_resultBufferAlloc = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_resultBuffer), MemoryRequirement::HostVisible);
198 
199 		VK_CHECK(vk.bindBufferMemory(vkDevice, *m_resultBuffer, m_resultBufferAlloc->getMemory(), m_resultBufferAlloc->getOffset()));
200 	}
201 
202 	// Create color attachment view
203 	{
204 		const VkImageViewCreateInfo colorAttachmentViewParams =
205 		{
206 			VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,			// VkStructureType			sType;
207 			DE_NULL,											// const void*				pNext;
208 			0u,													// VkImageViewCreateFlags	flags;
209 			*m_colorImage,										// VkImage					image;
210 			VK_IMAGE_VIEW_TYPE_2D,								// VkImageViewType			viewType;
211 			m_colorFormat,										// VkFormat					format;
212 			channelMappingRGBA,									// VkChannelMapping			channels;
213 			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u },		// VkImageSubresourceRange	subresourceRange;
214 		};
215 
216 		m_colorAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
217 	}
218 
219 	// Create render pass
220 	{
221 		const VkAttachmentDescription colorAttachmentDescription =
222 		{
223 			0u,													// VkAttachmentDescriptionFlags	flags;
224 			m_colorFormat,										// VkFormat						format;
225 			VK_SAMPLE_COUNT_1_BIT,								// deUint32						samples;
226 			VK_ATTACHMENT_LOAD_OP_CLEAR,						// VkAttachmentLoadOp			loadOp;
227 			VK_ATTACHMENT_STORE_OP_STORE,						// VkAttachmentStoreOp			storeOp;
228 			VK_ATTACHMENT_LOAD_OP_DONT_CARE,					// VkAttachmentLoadOp			stencilLoadOp;
229 			VK_ATTACHMENT_STORE_OP_DONT_CARE,					// VkAttachmentStoreOp			stencilStoreOp;
230 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,			// VkImageLayout				initialLayout;
231 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,			// VkImageLayout				finalLayout;
232 		};
233 
234 		const VkAttachmentReference colorAttachmentReference =
235 		{
236 			0u,													// deUint32			attachment;
237 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL			// VkImageLayout	layout;
238 		};
239 
240 		const VkSubpassDescription subpassDescription =
241 		{
242 			0u,													// VkSubpassDescriptionFlags		flags;
243 			VK_PIPELINE_BIND_POINT_GRAPHICS,					// VkPipelineBindPoint				pipelineBindPoint;
244 			0u,													// deUint32							inputCount;
245 			DE_NULL,											// const VkAttachmentReference*		pInputAttachments;
246 			1u,													// deUint32							colorCount;
247 			&colorAttachmentReference,							// const VkAttachmentReference*		pColorAttachments;
248 			DE_NULL,											// const VkAttachmentReference*		pResolveAttachments;
249 			DE_NULL,											// VkAttachmentReference			depthStencilAttachment;
250 			0u,													// deUint32							preserveCount;
251 			DE_NULL												// const VkAttachmentReference*		pPreserveAttachments;
252 		};
253 
254 		const VkRenderPassCreateInfo renderPassParams =
255 		{
256 			VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,			// VkStructureType					sType;
257 			DE_NULL,											// const void*						pNext;
258 			(VkRenderPassCreateFlags)0,
259 			1u,													// deUint32							attachmentCount;
260 			&colorAttachmentDescription,						// const VkAttachmentDescription*	pAttachments;
261 			1u,													// deUint32							subpassCount;
262 			&subpassDescription,								// const VkSubpassDescription*		pSubpasses;
263 			0u,													// deUint32							dependencyCount;
264 			DE_NULL												// const VkSubpassDependency*		pDependencies;
265 		};
266 
267 		m_renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
268 	}
269 
270 	// Create framebuffer
271 	{
272 		const VkImageView attachmentBindInfos[1] =
273 		{
274 			*m_colorAttachmentView,
275 		};
276 
277 		const VkFramebufferCreateInfo framebufferParams =
278 		{
279 			VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,			// VkStructureType				sType;
280 			DE_NULL,											// const void*					pNext;
281 			(VkFramebufferCreateFlags)0,
282 			*m_renderPass,										// VkRenderPass					renderPass;
283 			1u,													// deUint32						attachmentCount;
284 			attachmentBindInfos,								// const VkImageView*			pAttachments;
285 			(deUint32)m_renderSize.x(),							// deUint32						width;
286 			(deUint32)m_renderSize.y(),							// deUint32						height;
287 			1u													// deUint32						layers;
288 		};
289 
290 		m_framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
291 	}
292 
293 	// Create descriptors
294 	{
295 		const VkDescriptorSetLayoutBinding layoutBindings[1] =
296 		{
297 			{
298 				0u,											// deUint32				binding;
299 				VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,	// VkDescriptorType		descriptorType;
300 				1u,											// deUint32				arraySize;
301 				VK_SHADER_STAGE_ALL,						// VkShaderStageFlags	stageFlags;
302 				DE_NULL										// const VkSampler*		pImmutableSamplers;
303 			},
304 		};
305 
306 		const VkDescriptorSetLayoutCreateInfo descriptorLayoutParams =
307 		{
308 			VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,	// VkStructureType						sType;
309 			DE_NULL,												// cost void*							pNexŧ;
310 			(VkDescriptorSetLayoutCreateFlags)0,
311 			DE_LENGTH_OF_ARRAY(layoutBindings),						// deUint32								count;
312 			layoutBindings											// const VkDescriptorSetLayoutBinding	pBinding;
313 		};
314 
315 		m_descriptorSetLayout = createDescriptorSetLayout(vk, vkDevice, &descriptorLayoutParams);
316 
317 		// Generate buffer
318 		std::vector<deUint32> uniformData;
319 		generateBuffer(uniformData, testCase.bufferSize);
320 
321 		const VkDeviceSize uniformSize = testCase.bufferSize * sizeof(deUint32);
322 		const VkBufferCreateInfo uniformBufferParams =
323 		{
324 			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,		// VkStructureType		sType;
325 			DE_NULL,									// const void*			pNext;
326 			0u,											// VkBufferCreateFlags	flags; <-- TODO: 0u?
327 			uniformSize,								// VkDeviceSize			size;
328 			VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT,	// VkBufferUsageFlags	usage;
329 			VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode		sharingMode;
330 			1u,											// deUint32				queueFamilyIndexCount;
331 			&queueFamilyIndex							// const deUint32*		pQueueFamilyIndices;
332 		};
333 
334 		m_uniformBuffer			= createBuffer(vk, vkDevice, &uniformBufferParams);
335 		m_uniformBufferAlloc	= memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_uniformBuffer), MemoryRequirement::HostVisible);
336 
337 		VK_CHECK(vk.bindBufferMemory(vkDevice, *m_uniformBuffer, m_uniformBufferAlloc->getMemory(), 0));
338 		deMemcpy(m_uniformBufferAlloc->getHostPtr(), uniformData.data(), (size_t)uniformSize);
339 
340 		const VkBufferViewCreateInfo viewInfo =
341 		{
342 			VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,							// VkStructureType	sType;
343 			DE_NULL,															// void*			pNext;
344 			(VkBufferViewCreateFlags)0,
345 			*m_uniformBuffer,													// VkBuffer			buffer;
346 			m_colorFormat,														// VkFormat			format;
347 			m_testCase.elementOffset * sizeof(deUint32),						// VkDeviceSize		offset;
348 			m_testCase.bufferViewSize * sizeof(deUint32)						// VkDeviceSize		range;
349 		};
350 
351 		m_uniformBufferView = createBufferView(vk, vkDevice, &viewInfo);
352 
353 		const VkDescriptorPoolSize descriptorTypes[1] =
354 		{
355 			{
356 				VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,		// VkDescriptorType		type;
357 				1												// deUint32				count;
358 			}
359 		};
360 
361 		const VkDescriptorPoolCreateInfo descriptorPoolParams =
362 		{
363 			VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,		// VkStructureType					sType;
364 			DE_NULL,											// void*							pNext;
365 			VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,	// VkDescriptorPoolCreateFlags		flags;
366 			1u,													// uint32_t							maxSets;
367 			DE_LENGTH_OF_ARRAY(descriptorTypes),				// deUint32							count;
368 			descriptorTypes										// const VkDescriptorTypeCount*		pTypeCount
369 		};
370 
371 		m_descriptorPool = createDescriptorPool(vk, vkDevice, &descriptorPoolParams);
372 
373 		const VkDescriptorSetAllocateInfo descriptorSetParams =
374 		{
375 			VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
376 			DE_NULL,
377 			*m_descriptorPool,
378 			1u,
379 			&m_descriptorSetLayout.get(),
380 		};
381 		m_descriptorSet = allocateDescriptorSet(vk, vkDevice, &descriptorSetParams);
382 
383 		const VkWriteDescriptorSet writeDescritporSets[] =
384 		{
385 			{
386 				VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,		// VkStructureType			sType;
387 				DE_NULL,									// const void*				pNext;
388 				*m_descriptorSet,							// VkDescriptorSet			destSet;
389 				0,											// deUint32					destBinding;
390 				0,											// deUint32					destArrayElement;
391 				1u,											// deUint32					count;
392 				VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,	// VkDescriptorType			descriptorType;
393 				(const VkDescriptorImageInfo*)DE_NULL,
394 				(const VkDescriptorBufferInfo*)DE_NULL,
395 				&m_uniformBufferView.get(),
396 			}
397 		};
398 
399 		vk.updateDescriptorSets(vkDevice, DE_LENGTH_OF_ARRAY(writeDescritporSets), writeDescritporSets, 0u, DE_NULL);
400 	}
401 
402 	// Create pipeline layout
403 	{
404 		const VkPipelineLayoutCreateInfo pipelineLayoutParams =
405 		{
406 			VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,		// VkStructureType				sType;
407 			DE_NULL,											// const void*					pNext;
408 			(VkPipelineLayoutCreateFlags)0,
409 			1u,													// deUint32						descriptorSetCount;
410 			&*m_descriptorSetLayout,							// const VkDescriptorSetLayout*	pSetLayouts;
411 			0u,													// deUint32						pushConstantRangeCount;
412 			DE_NULL												// const VkPushConstantRange*	pPushConstantRanges;
413 		};
414 
415 		m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
416 	}
417 
418 	// Create shaders
419 	{
420 		m_vertexShaderModule	= createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("vert"), 0);
421 		m_fragmentShaderModule	= createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("frag"), 0);
422 	}
423 
424 	// Create pipeline
425 	{
426 
427 		const VkPipelineShaderStageCreateInfo shaderStageParams[2] =
428 		{
429 			{
430 				VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,		// VkStructureType				sType;
431 				DE_NULL,													// const void*					pNext;
432 				(VkPipelineShaderStageCreateFlags)0,
433 				VK_SHADER_STAGE_VERTEX_BIT,									// VkShaderStage				stage;
434 				*m_vertexShaderModule,										// VkShader						shader;
435 				"main",
436 				DE_NULL														// const VkSpecializationInfo*	pSpecializationInfo;
437 			},
438 			{
439 				VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,		// VkStructureType				sType;
440 				DE_NULL,													// const void*					pNext;
441 				(VkPipelineShaderStageCreateFlags)0,
442 				VK_SHADER_STAGE_FRAGMENT_BIT,								// VkShaderStage				stage;
443 				*m_fragmentShaderModule,									// VkShader						shader;
444 				"main",
445 				DE_NULL														// const VkSpecializationInfo*	pSpecializationInfo;
446 			}
447 		};
448 
449 		const VkVertexInputBindingDescription vertexInputBindingDescription =
450 		{
451 			0u,								// deUint32					binding;
452 			sizeof(tcu::Vec4),				// deUint32					strideInBytes;
453 			VK_VERTEX_INPUT_RATE_VERTEX		// VkVertexInputStepRate	stepRate;
454 		};
455 
456 		const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[1] =
457 		{
458 			{
459 				0u,									// deUint32	location;
460 				0u,									// deUint32	binding;
461 				VK_FORMAT_R32G32B32A32_SFLOAT,		// VkFormat	format;
462 				0u									// deUint32	offsetInBytes;
463 			}
464 		};
465 
466 		const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
467 		{
468 			VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,		// VkStructureType							sType;
469 			DE_NULL,														// const void*								pNext;
470 			(VkPipelineVertexInputStateCreateFlags)0,
471 			1u,																// deUint32									bindingCount;
472 			&vertexInputBindingDescription,									// const VkVertexInputBindingDescription*	pVertexBindingDescriptions;
473 			1u,																// deUint32									attributeCount;
474 			vertexInputAttributeDescriptions								// const VkVertexInputAttributeDescription*	pVertexAttributeDescriptions;
475 		};
476 
477 		const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
478 		{
479 			VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType		sType;
480 			DE_NULL,														// const void*			pNext;
481 			(VkPipelineInputAssemblyStateCreateFlags)0,
482 			VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,							// VkPrimitiveTopology	topology;
483 			false															// VkBool32				primitiveRestartEnable;
484 		};
485 
486 		const VkViewport viewport =
487 		{
488 			0.0f,						// float	originX;
489 			0.0f,						// float	originY;
490 			(float)m_renderSize.x(),	// float	width;
491 			(float)m_renderSize.y(),	// float	height;
492 			0.0f,						// float	minDepth;
493 			1.0f						// float	maxDepth;
494 		};
495 		const VkRect2D scissor =
496 		{
497 			{ 0, 0 },													// VkOffset2D  offset;
498 			{ (deUint32)m_renderSize.x(), (deUint32)m_renderSize.y() }	// VkExtent2D  extent;
499 		};
500 		const VkPipelineViewportStateCreateInfo viewportStateParams =
501 		{
502 			VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,			// VkStructureType		sType;
503 			DE_NULL,														// const void*			pNext;
504 			(VkPipelineViewportStateCreateFlags)0,
505 			1u,																// deUint32				viewportCount;
506 			&viewport,														// const VkViewport*	pViewports;
507 			1u,																// deUint32				scissorCount;
508 			&scissor														// const VkRect2D*		pScissors;
509 		};
510 
511 		const VkPipelineRasterizationStateCreateInfo rasterStateParams =
512 		{
513 			VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,		// VkStructureType	sType;
514 			DE_NULL,														// const void*		pNext;
515 			(VkPipelineRasterizationStateCreateFlags)0,
516 			false,															// VkBool32			depthClipEnable;
517 			false,															// VkBool32			rasterizerDiscardEnable;
518 			VK_POLYGON_MODE_FILL,											// VkFillMode		fillMode;
519 			VK_CULL_MODE_NONE,												// VkCullMode		cullMode;
520 			VK_FRONT_FACE_COUNTER_CLOCKWISE,								// VkFrontFace		frontFace;
521 			VK_FALSE,														// VkBool32			depthBiasEnable;
522 			0.0f,															// float			depthBias;
523 			0.0f,															// float			depthBiasClamp;
524 			0.0f,															// float			slopeScaledDepthBias;
525 			1.0f,															// float			lineWidth;
526 		};
527 
528 		const VkPipelineMultisampleStateCreateInfo		multisampleStateParams =
529 		{
530 			VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,		// VkStructureType							sType;
531 			DE_NULL,														// const void*								pNext;
532 			0u,																// VkPipelineMultisampleStateCreateFlags	flags;
533 			VK_SAMPLE_COUNT_1_BIT,											// VkSampleCountFlagBits					rasterizationSamples;
534 			VK_FALSE,														// VkBool32									sampleShadingEnable;
535 			0.0f,															// float									minSampleShading;
536 			DE_NULL,														// const VkSampleMask*						pSampleMask;
537 			VK_FALSE,														// VkBool32									alphaToCoverageEnable;
538 			VK_FALSE														// VkBool32									alphaToOneEnable;
539 		};
540 
541 		const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
542 		{
543 			false,														// VkBool32			blendEnable;
544 			VK_BLEND_FACTOR_ONE,										// VkBlend			srcBlendColor;
545 			VK_BLEND_FACTOR_ZERO,										// VkBlend			destBlendColor;
546 			VK_BLEND_OP_ADD,											// VkBlendOp		blendOpColor;
547 			VK_BLEND_FACTOR_ONE,										// VkBlend			srcBlendAlpha;
548 			VK_BLEND_FACTOR_ZERO,										// VkBlend			destBlendAlpha;
549 			VK_BLEND_OP_ADD,											// VkBlendOp		blendOpAlpha;
550 			(VK_COLOR_COMPONENT_R_BIT |
551 			 VK_COLOR_COMPONENT_G_BIT |
552 			 VK_COLOR_COMPONENT_B_BIT |
553 			 VK_COLOR_COMPONENT_A_BIT)									// VkChannelFlags	channelWriteMask;
554 		};
555 
556 		const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
557 		{
558 			VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	// VkStructureType								sType;
559 			DE_NULL,													// const void*									pNext;
560 			(VkPipelineColorBlendStateCreateFlags)0,
561 			false,														// VkBool32										logicOpEnable;
562 			VK_LOGIC_OP_COPY,											// VkLogicOp									logicOp;
563 			1u,															// deUint32										attachmentCount;
564 			&colorBlendAttachmentState,									// const VkPipelineColorBlendAttachmentState*	pAttachments;
565 			{ 0.0f, 0.0f, 0.0f, 0.0f },									// float										blendConst[4];
566 		};
567 
568 		const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
569 		{
570 			VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,	// VkStructureType									sType;
571 			DE_NULL,											// const void*										pNext;
572 			0u,													// VkPipelineCreateFlags							flags;
573 			2u,													// deUint32											stageCount;
574 			shaderStageParams,									// const VkPipelineShaderStageCreateInfo*			pStages;
575 			&vertexInputStateParams,							// const VkPipelineVertexInputStateCreateInfo*		pVertexInputState;
576 			&inputAssemblyStateParams,							// const VkPipelineInputAssemblyStateCreateInfo*	pInputAssemblyState;
577 			DE_NULL,											// const VkPipelineTessellationStateCreateInfo*		pTessellationState;
578 			&viewportStateParams,								// const VkPipelineViewportStateCreateInfo*			pViewportState;
579 			&rasterStateParams,									// const VkPipelineRasterStateCreateInfo*			pRasterState;
580 			&multisampleStateParams,							// const VkPipelineMultisampleStateCreateInfo*		pMultisampleState;
581 			DE_NULL,											// const VkPipelineDepthStencilStateCreateInfo*		pDepthStencilState;
582 			&colorBlendStateParams,								// const VkPipelineColorBlendStateCreateInfo*		pColorBlendState;
583 			DE_NULL,											// const VkPipelineDynamicStateCreateInfo*			pDynamicState;
584 			*m_pipelineLayout,									// VkPipelineLayout									layout;
585 			*m_renderPass,										// VkRenderPass										renderPass;
586 			0u,													// deUint32											subpass;
587 			0u,													// VkPipeline										basePipelineHandle;
588 			0u													// deInt32											basePipelineIndex;
589 		};
590 
591 		m_graphicsPipelines		= createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
592 	}
593 
594 	// Create vertex buffer
595 	{
596 		createQuad();
597 		const VkDeviceSize vertexDataSize = m_vertices.size() * sizeof(tcu::Vec4);
598 		const VkBufferCreateInfo vertexBufferParams =
599 		{
600 			VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,		// VkStructureType		sType;
601 			DE_NULL,									// const void*			pNext;
602 			0u,											// VkBufferCreateFlags	flags;
603 			vertexDataSize,								// VkDeviceSize			size;
604 			VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,			// VkBufferUsageFlags	usage;
605 			VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode		sharingMode;
606 			1u,											// deUint32				queueFamilyCount;
607 			&queueFamilyIndex							// const deUint32*		pQueueFamilyIndices;
608 		};
609 
610 		m_vertexBuffer		= createBuffer(vk, vkDevice, &vertexBufferParams);
611 		m_vertexBufferAlloc	= memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_vertexBuffer), MemoryRequirement::HostVisible);
612 
613 		VK_CHECK(vk.bindBufferMemory(vkDevice, *m_vertexBuffer, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset()));
614 
615 		// Load vertices into vertex buffer
616 		deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), (size_t)vertexDataSize);
617 		flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexDataSize);
618 	}
619 
620 	// Create command pool
621 	{
622 		const VkCommandPoolCreateInfo cmdPoolParams =
623 		{
624 			VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,		// VkStructureType		sType;
625 			DE_NULL,										// const void*			pNext;
626 			VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,			// VkCmdPoolCreateFlags	flags;
627 			queueFamilyIndex,								// deUint32				queueFamilyIndex;
628 		};
629 
630 		m_cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
631 	}
632 
633 	// Create command buffer
634 	{
635 		const VkCommandBufferAllocateInfo cmdBufferParams =
636 		{
637 			VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,	// VkStructureType			sType;
638 			DE_NULL,										// const void*				pNext;
639 			*m_cmdPool,										// VkCmdPool				cmdPool;
640 			VK_COMMAND_BUFFER_LEVEL_PRIMARY,				// VkCmdBufferLevel			level;
641 			1u												// deUint32					count;
642 		};
643 
644 		const VkCommandBufferBeginInfo cmdBufferBeginInfo =
645 		{
646 			VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,	// VkStructureType			sType;
647 			DE_NULL,										// const void*				pNext;
648 			0u,												// VkCmdBufferOptimizeFlags	flags;
649 			(const VkCommandBufferInheritanceInfo*)DE_NULL,
650 		};
651 
652 		const VkClearValue clearValue = makeClearValueColorF32(0.0, 0.0, 0.0, 0.0);
653 
654 		const VkClearValue attachmentClearValues[1] =
655 		{
656 			clearValue,
657 		};
658 
659 		const VkRenderPassBeginInfo renderPassBeginInfo =
660 		{
661 			VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,				// VkStructureType		sType;
662 			DE_NULL,												// const void*			pNext;
663 			*m_renderPass,											// VkRenderPass			renderPass;
664 			*m_framebuffer,											// VkFramebuffer		framebuffer;
665 			{
666 				{ 0, 0 },
667 				{ (deUint32)m_renderSize.x(), (deUint32)m_renderSize.y() }
668 			},														// VkRect2D				renderArea;
669 			1u,														// deUint32				clearValueCount;
670 			attachmentClearValues									// const VkClearValue*	pClearValues;
671 		};
672 
673 		m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, &cmdBufferParams);
674 
675 		VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
676 
677 		const VkImageMemoryBarrier initialImageBarrier =
678 		{
679 			VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,		// VkStructureType			sType;
680 			DE_NULL,									// const void*				pNext;
681 			0,											// VkMemoryOutputFlags		outputMask;
682 			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,		// VkMemoryInputFlags		inputMask;
683 			VK_IMAGE_LAYOUT_UNDEFINED,					// VkImageLayout			oldLayout;
684 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,	// VkImageLayout			newLayout;
685 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					srcQueueFamilyIndex;
686 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					destQueueFamilyIndex;
687 			*m_colorImage,								// VkImage					image;
688 			{											// VkImageSubresourceRange	subresourceRange;
689 				VK_IMAGE_ASPECT_COLOR_BIT,				// VkImageAspectFlags	aspectMask;
690 				0u,										// deUint32				baseMipLevel;
691 				1u,										// deUint32				mipLevels;
692 				0u,										// deUint32				baseArraySlice;
693 				1u										// deUint32				arraySize;
694 			}
695 		};
696 
697 		vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &initialImageBarrier);
698 
699 		vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
700 
701 		const VkDeviceSize	vertexBufferOffset[1] = { 0 };
702 
703 		vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipelines);
704 		vk.cmdBindDescriptorSets(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0u, 1, &*m_descriptorSet, 0u, DE_NULL);
705 		vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &m_vertexBuffer.get(), vertexBufferOffset);
706 		vk.cmdDraw(*m_cmdBuffer, (deUint32)m_vertices.size(), 1, 0, 0);
707 		vk.cmdEndRenderPass(*m_cmdBuffer);
708 
709 		const VkImageMemoryBarrier imageBarrier =
710 		{
711 			VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,		// VkStructureType			sType;
712 			DE_NULL,									// const void*				pNext;
713 			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,		// VkMemoryOutputFlags		outputMask;
714 			VK_ACCESS_TRANSFER_READ_BIT,				// VkMemoryInputFlags		inputMask;
715 			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,	// VkImageLayout			oldLayout;
716 			VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,		// VkImageLayout			newLayout;
717 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					srcQueueFamilyIndex;
718 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					destQueueFamilyIndex;
719 			*m_colorImage,								// VkImage					image;
720 			{											// VkImageSubresourceRange	subresourceRange;
721 				VK_IMAGE_ASPECT_COLOR_BIT,				// VkImageAspectFlags	aspectMask;
722 				0u,										// deUint32				baseMipLevel;
723 				1u,										// deUint32				mipLevels;
724 				0u,										// deUint32				baseArraySlice;
725 				1u										// deUint32				arraySize;
726 			}
727 		};
728 
729 		const VkBufferMemoryBarrier bufferBarrier =
730 		{
731 			VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,	// VkStructureType		sType;
732 			DE_NULL,									// const void*			pNext;
733 			VK_ACCESS_TRANSFER_WRITE_BIT,				// VkMemoryOutputFlags	outputMask;
734 			VK_ACCESS_HOST_READ_BIT,					// VkMemoryInputFlags	inputMask;
735 			VK_QUEUE_FAMILY_IGNORED,					// deUint32				srcQueueFamilyIndex;
736 			VK_QUEUE_FAMILY_IGNORED,					// deUint32				destQueueFamilyIndex;
737 			*m_resultBuffer,							// VkBuffer				buffer;
738 			0u,											// VkDeviceSize			offset;
739 			m_pixelDataSize								// VkDeviceSize			size;
740 		};
741 
742 		const VkBufferImageCopy copyRegion =
743 		{
744 			0u,											// VkDeviceSize				bufferOffset;
745 			(deUint32)m_renderSize.x(),					// deUint32					bufferRowLength;
746 			(deUint32)m_renderSize.y(),					// deUint32					bufferImageHeight;
747 			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u },	// VkImageSubresourceCopy	imageSubresource;
748 			{ 0, 0, 0 },								// VkOffset3D				imageOffset;
749 			{
750 				(deUint32)m_renderSize.x(),
751 				(deUint32)m_renderSize.y(),
752 				1u
753 			}											// VkExtent3D				imageExtent;
754 		};
755 
756 		vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &imageBarrier);
757 		vk.cmdCopyImageToBuffer(*m_cmdBuffer, *m_colorImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *m_resultBuffer, 1, &copyRegion);
758 		vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
759 
760 		VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
761 	}
762 
763 	// Create fence
764 	{
765 		const VkFenceCreateInfo fenceParams =
766 		{
767 			VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,	// VkStructureType		sType;
768 			DE_NULL,								// const void*			pNext;
769 			0u										// VkFenceCreateFlags	flags;
770 		};
771 
772 		m_fence = createFence(vk, vkDevice, &fenceParams);
773 	}
774 }
775 
checkResult(deInt8 factor)776 tcu::TestStatus BufferViewTestInstance::checkResult (deInt8 factor)
777 {
778 	const DeviceInterface&			vk					= m_context.getDeviceInterface();
779 	const VkDevice					vkDevice			= m_context.getDevice();
780 	const tcu::TextureFormat		tcuFormat			= mapVkFormat(m_colorFormat);
781 	de::MovePtr<tcu::TextureLevel>	resultLevel			(new tcu::TextureLevel(tcuFormat, m_renderSize.x(), m_renderSize.y()));
782 
783 	invalidateMappedMemoryRange(vk, vkDevice, m_resultBufferAlloc->getMemory(), m_resultBufferAlloc->getOffset(), m_pixelDataSize);
784 	tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_resultBufferAlloc->getHostPtr()));
785 
786 	tcu::ConstPixelBufferAccess pixelBuffer = resultLevel->getAccess();
787 	for (deInt32 i = 0; i < (deInt32) m_renderSize.x(); ++i)
788 	{
789 		tcu::IVec4 pixel	= pixelBuffer.getPixelInt(i, i);
790 		deInt32 expected	= factor * (m_testCase.elementOffset + i);
791 		deInt32 actual		= pixel[0];
792 		if (expected != actual)
793 		{
794 			std::ostringstream errorMessage;
795 			errorMessage << "BufferView test failed. expected: " << expected << " actual: " << actual;
796 			return tcu::TestStatus::fail(errorMessage.str());
797 		}
798 	}
799 
800 	return tcu::TestStatus::pass("BufferView test");
801 }
802 
iterate(void)803 tcu::TestStatus BufferViewTestInstance::iterate (void)
804 {
805 	const DeviceInterface&		vk			= m_context.getDeviceInterface();
806 	const VkDevice				vkDevice	= m_context.getDevice();
807 	const VkQueue				queue		= m_context.getUniversalQueue();
808 	const VkSubmitInfo			submitInfo	=
809 	{
810 		VK_STRUCTURE_TYPE_SUBMIT_INFO,
811 		DE_NULL,
812 		0u,
813 		(const VkSemaphore*)DE_NULL,
814 		(const VkPipelineStageFlags*)DE_NULL,
815 		1u,
816 		&m_cmdBuffer.get(),
817 		0u,
818 		(const VkSemaphore*)DE_NULL,
819 	};
820 
821 	VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
822 	VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
823 	VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
824 
825 	tcu::TestStatus				testStatus	= checkResult();
826 	if (testStatus.getCode() != QP_TEST_RESULT_PASS)
827 	{
828 		return testStatus;
829 	}
830 
831 	// Generate and bind another buffer
832 	std::vector<deUint32>		uniformData;
833 	const VkDeviceSize			uniformSize = m_testCase.bufferSize * sizeof(deUint32);
834 	const deInt8				factor		= 2;
835 
836 	generateBuffer(uniformData, m_testCase.bufferSize, factor);
837 	deMemcpy(m_uniformBufferAlloc->getHostPtr(), uniformData.data(), (size_t)uniformSize);
838 
839 	VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
840 	VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
841 	VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity */));
842 
843 	return checkResult(factor);
844 }
845 
846 class BufferViewTestCase : public vkt::TestCase
847 {
848 public:
BufferViewTestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description,BufferViewCaseParams bufferViewTestInfo)849 							BufferViewTestCase			(tcu::TestContext&			testCtx,
850 														 const std::string&			name,
851 														 const std::string&			description,
852 														 BufferViewCaseParams	bufferViewTestInfo)
853 								: vkt::TestCase			(testCtx, name, description)
854 								, m_bufferViewTestInfo	(bufferViewTestInfo)
855 							{}
856 
~BufferViewTestCase(void)857 	virtual					~BufferViewTestCase			(void) {}
858 	virtual	void			initPrograms				(SourceCollections&			programCollection) const;
859 
createInstance(Context & context) const860 	virtual TestInstance*	createInstance				(Context&					context) const
861 							{
862 								return new BufferViewTestInstance(context, m_bufferViewTestInfo);
863 							}
864 private:
865 	BufferViewCaseParams	m_bufferViewTestInfo;
866 };
867 
initPrograms(SourceCollections & programCollection) const868 void BufferViewTestCase::initPrograms (SourceCollections& programCollection) const
869 {
870 	programCollection.glslSources.add("vert") << glu::VertexSource(
871 		"#version 310 es\n"
872 		"layout (location = 0) in highp vec4 a_position;\n"
873 		"void main()\n"
874 		"{\n"
875 		"	gl_Position = a_position;\n"
876 		"}\n");
877 
878 
879 	programCollection.glslSources.add("frag") << glu::FragmentSource(
880 		"#version 310 es\n"
881 		"#extension GL_EXT_texture_buffer : enable\n"
882 		"layout (set=0, binding=0) uniform highp usamplerBuffer u_buffer;\n"
883 		"layout (location = 0) out highp uint o_color;\n"
884 		"void main()\n"
885 		"{\n"
886 		"	o_color = texelFetch(u_buffer, int(gl_FragCoord.x)).x;\n"
887 		"}\n");
888 }
889 
890 } // anonymous
891 
createBufferViewAccessTests(tcu::TestContext & testCtx)892 tcu::TestCaseGroup* createBufferViewAccessTests (tcu::TestContext& testCtx)
893 {
894 	de::MovePtr<tcu::TestCaseGroup>	bufferViewTests	(new tcu::TestCaseGroup(testCtx, "access", "BufferView Access Tests"));
895 
896 	{
897 		BufferViewCaseParams info =
898 		{
899 			512,	// deUint32	bufferSize
900 			512,	// deUint32	bufferViewSize
901 			0,		// deUint32	elementOffset
902 		};
903 		std::ostringstream description;
904 		description << "bufferSize: " << info.bufferSize << " bufferViewSize: " << info.bufferViewSize << " bufferView element offset: " << info.elementOffset;
905 		bufferViewTests->addChild(new BufferViewTestCase(testCtx, "buffer_view_memory_test_complete", description.str(), info));
906 	}
907 
908 	{
909 		BufferViewCaseParams info =
910 		{
911 			4096,	// deUint32	bufferSize
912 			512,	// deUint32	bufferViewSize
913 			0,		// deUint32	elementOffset
914 		};
915 		std::ostringstream description;
916 		description << "bufferSize: " << info.bufferSize << " bufferViewSize: " << info.bufferViewSize << " bufferView element offset: " << info.elementOffset;
917 		bufferViewTests->addChild(new BufferViewTestCase(testCtx, "buffer_view_memory_test_partial_offset0", description.str(), info));
918 	}
919 
920 	{
921 		BufferViewCaseParams info =
922 		{
923 			4096,	// deUint32	bufferSize
924 			512,	// deUint32	bufferViewSize
925 			128,	// deUint32	elementOffset
926 		};
927 		std::ostringstream description;
928 		description << "bufferSize: " << info.bufferSize << " bufferViewSize: " << info.bufferViewSize << " bufferView element offset: " << info.elementOffset;
929 		bufferViewTests->addChild(new BufferViewTestCase(testCtx, "buffer_view_memory_test_partial_offset1", description.str(), info));
930 	}
931 
932 	return bufferViewTests.release();
933 }
934 
935 } // api
936 } // vkt
937