• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2014 The Android Open Source Project
6  * Copyright (c) 2016 The Khronos Group 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 Geometry Utilities
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktGeometryTestsUtil.hpp"
26 #include "vkTypeUtil.hpp"
27 #include "vkImageUtil.hpp"
28 #include "vkDefs.hpp"
29 #include "tcuImageCompare.hpp"
30 
31 #include "tcuImageIO.hpp"
32 
33 #include "deMath.h"
34 
35 using namespace vk;
36 
37 namespace vkt
38 {
39 namespace geometry
40 {
41 
setShader(const DeviceInterface & vk,const VkDevice device,const VkShaderStageFlagBits stage,const ProgramBinary & binary,const VkSpecializationInfo * specInfo)42 GraphicsPipelineBuilder& GraphicsPipelineBuilder::setShader (const DeviceInterface&			vk,
43 															 const VkDevice					device,
44 															 const VkShaderStageFlagBits	stage,
45 															 const ProgramBinary&			binary,
46 															 const VkSpecializationInfo*	specInfo)
47 {
48 	VkShaderModule module;
49 	switch (stage)
50 	{
51 		case (VK_SHADER_STAGE_VERTEX_BIT):
52 			DE_ASSERT(m_vertexShaderModule.get() == DE_NULL);
53 			m_vertexShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
54 			module = *m_vertexShaderModule;
55 			break;
56 
57 		case (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT):
58 			DE_ASSERT(m_tessControlShaderModule.get() == DE_NULL);
59 			m_tessControlShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
60 			module = *m_tessControlShaderModule;
61 			break;
62 
63 		case (VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT):
64 			DE_ASSERT(m_tessEvaluationShaderModule.get() == DE_NULL);
65 			m_tessEvaluationShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
66 			module = *m_tessEvaluationShaderModule;
67 			break;
68 
69 		case (VK_SHADER_STAGE_GEOMETRY_BIT):
70 			DE_ASSERT(m_geometryShaderModule.get() == DE_NULL);
71 			m_geometryShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
72 			module = *m_geometryShaderModule;
73 			break;
74 
75 		case (VK_SHADER_STAGE_FRAGMENT_BIT):
76 			DE_ASSERT(m_fragmentShaderModule.get() == DE_NULL);
77 			m_fragmentShaderModule = createShaderModule(vk, device, binary, (VkShaderModuleCreateFlags)0);
78 			module = *m_fragmentShaderModule;
79 			break;
80 
81 		default:
82 			DE_FATAL("Invalid shader stage");
83 			return *this;
84 	}
85 
86 	const VkPipelineShaderStageCreateInfo pipelineShaderStageInfo =
87 	{
88 		VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType						sType;
89 		DE_NULL,												// const void*							pNext;
90 		(VkPipelineShaderStageCreateFlags)0,					// VkPipelineShaderStageCreateFlags		flags;
91 		stage,													// VkShaderStageFlagBits				stage;
92 		module,													// VkShaderModule						module;
93 		"main",													// const char*							pName;
94 		specInfo,												// const VkSpecializationInfo*			pSpecializationInfo;
95 	};
96 
97 	m_shaderStageFlags |= stage;
98 	m_shaderStages.push_back(pipelineShaderStageInfo);
99 
100 	return *this;
101 }
102 
setVertexInputSingleAttribute(const VkFormat vertexFormat,const deUint32 stride)103 GraphicsPipelineBuilder& GraphicsPipelineBuilder::setVertexInputSingleAttribute (const VkFormat vertexFormat, const deUint32 stride)
104 {
105 	const VkVertexInputBindingDescription bindingDesc =
106 	{
107 		0u,									// uint32_t				binding;
108 		stride,								// uint32_t				stride;
109 		VK_VERTEX_INPUT_RATE_VERTEX,		// VkVertexInputRate	inputRate;
110 	};
111 	const VkVertexInputAttributeDescription attributeDesc =
112 	{
113 		0u,									// uint32_t			location;
114 		0u,									// uint32_t			binding;
115 		vertexFormat,						// VkFormat			format;
116 		0u,									// uint32_t			offset;
117 	};
118 
119 	m_vertexInputBindings.clear();
120 	m_vertexInputBindings.push_back(bindingDesc);
121 
122 	m_vertexInputAttributes.clear();
123 	m_vertexInputAttributes.push_back(attributeDesc);
124 
125 	return *this;
126 }
127 
128 template<typename T>
dataPointer(const std::vector<T> & vec)129 inline const T* dataPointer (const std::vector<T>& vec)
130 {
131 	return (vec.size() != 0 ? &vec[0] : DE_NULL);
132 }
133 
build(const DeviceInterface & vk,const VkDevice device,const VkPipelineLayout pipelineLayout,const VkRenderPass renderPass)134 Move<VkPipeline> GraphicsPipelineBuilder::build (const DeviceInterface&	vk,
135 												 const VkDevice			device,
136 												 const VkPipelineLayout	pipelineLayout,
137 												 const VkRenderPass		renderPass)
138 {
139 	const VkPipelineVertexInputStateCreateInfo vertexInputStateInfo =
140 	{
141 		VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,		// VkStructureType                             sType;
142 		DE_NULL,														// const void*                                 pNext;
143 		(VkPipelineVertexInputStateCreateFlags)0,						// VkPipelineVertexInputStateCreateFlags       flags;
144 		static_cast<deUint32>(m_vertexInputBindings.size()),			// uint32_t                                    vertexBindingDescriptionCount;
145 		dataPointer(m_vertexInputBindings),								// const VkVertexInputBindingDescription*      pVertexBindingDescriptions;
146 		static_cast<deUint32>(m_vertexInputAttributes.size()),			// uint32_t                                    vertexAttributeDescriptionCount;
147 		dataPointer(m_vertexInputAttributes),							// const VkVertexInputAttributeDescription*    pVertexAttributeDescriptions;
148 	};
149 
150 	const VkPrimitiveTopology topology = (m_shaderStageFlags & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) ? VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
151 																										 : m_primitiveTopology;
152 
153 	VkBool32	primitiveRestartEnable = VK_TRUE;
154 	switch(m_primitiveTopology)
155 	{
156 		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
157 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
158 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
159 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
160 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
161 		case VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
162 			primitiveRestartEnable = VK_FALSE;
163 			break;
164 		default:
165 			break;
166 	}
167 
168 	const VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateInfo =
169 	{
170 		VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,	// VkStructureType                             sType;
171 		DE_NULL,														// const void*                                 pNext;
172 		(VkPipelineInputAssemblyStateCreateFlags)0,						// VkPipelineInputAssemblyStateCreateFlags     flags;
173 		topology,														// VkPrimitiveTopology                         topology;
174 		primitiveRestartEnable,											// VkBool32                                    primitiveRestartEnable;
175 	};
176 
177 	const VkPipelineTessellationStateCreateInfo pipelineTessellationStateInfo =
178 	{
179 		VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,		// VkStructureType                             sType;
180 		DE_NULL,														// const void*                                 pNext;
181 		(VkPipelineTessellationStateCreateFlags)0,						// VkPipelineTessellationStateCreateFlags      flags;
182 		m_patchControlPoints,											// uint32_t                                    patchControlPoints;
183 	};
184 
185 	const VkViewport	viewport	= makeViewport(m_renderSize);
186 	const VkRect2D		scissor		= makeRect2D(m_renderSize);
187 
188 	const VkPipelineViewportStateCreateInfo pipelineViewportStateInfo =
189 	{
190 		VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,	// VkStructureType                             sType;
191 		DE_NULL,												// const void*                                 pNext;
192 		(VkPipelineViewportStateCreateFlags)0,					// VkPipelineViewportStateCreateFlags          flags;
193 		1u,														// uint32_t                                    viewportCount;
194 		&viewport,												// const VkViewport*                           pViewports;
195 		1u,														// uint32_t                                    scissorCount;
196 		&scissor,												// const VkRect2D*                             pScissors;
197 	};
198 
199 	const bool isRasterizationDisabled = ((m_shaderStageFlags & VK_SHADER_STAGE_FRAGMENT_BIT) == 0);
200 	const VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateInfo =
201 	{
202 		VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,		// VkStructureType                          sType;
203 		DE_NULL,														// const void*                              pNext;
204 		(VkPipelineRasterizationStateCreateFlags)0,						// VkPipelineRasterizationStateCreateFlags  flags;
205 		VK_FALSE,														// VkBool32                                 depthClampEnable;
206 		isRasterizationDisabled,										// VkBool32                                 rasterizerDiscardEnable;
207 		VK_POLYGON_MODE_FILL,											// VkPolygonMode							polygonMode;
208 		m_cullModeFlags,												// VkCullModeFlags							cullMode;
209 		m_frontFace,													// VkFrontFace								frontFace;
210 		VK_FALSE,														// VkBool32									depthBiasEnable;
211 		0.0f,															// float									depthBiasConstantFactor;
212 		0.0f,															// float									depthBiasClamp;
213 		0.0f,															// float									depthBiasSlopeFactor;
214 		1.0f,															// float									lineWidth;
215 	};
216 
217 	const VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateInfo =
218 	{
219 		VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,	// VkStructureType							sType;
220 		DE_NULL,													// const void*								pNext;
221 		(VkPipelineMultisampleStateCreateFlags)0,					// VkPipelineMultisampleStateCreateFlags	flags;
222 		VK_SAMPLE_COUNT_1_BIT,										// VkSampleCountFlagBits					rasterizationSamples;
223 		VK_FALSE,													// VkBool32									sampleShadingEnable;
224 		0.0f,														// float									minSampleShading;
225 		DE_NULL,													// const VkSampleMask*						pSampleMask;
226 		VK_FALSE,													// VkBool32									alphaToCoverageEnable;
227 		VK_FALSE													// VkBool32									alphaToOneEnable;
228 	};
229 
230 	const VkStencilOpState stencilOpState = makeStencilOpState(
231 		VK_STENCIL_OP_KEEP,		// stencil fail
232 		VK_STENCIL_OP_KEEP,		// depth & stencil pass
233 		VK_STENCIL_OP_KEEP,		// depth only fail
234 		VK_COMPARE_OP_NEVER,	// compare op
235 		0u,						// compare mask
236 		0u,						// write mask
237 		0u);					// reference
238 
239 	const VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateInfo =
240 	{
241 		VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,	// VkStructureType							sType;
242 		DE_NULL,													// const void*								pNext;
243 		(VkPipelineDepthStencilStateCreateFlags)0,					// VkPipelineDepthStencilStateCreateFlags	flags;
244 		VK_FALSE,													// VkBool32									depthTestEnable;
245 		VK_FALSE,													// VkBool32									depthWriteEnable;
246 		VK_COMPARE_OP_LESS,											// VkCompareOp								depthCompareOp;
247 		VK_FALSE,													// VkBool32									depthBoundsTestEnable;
248 		VK_FALSE,													// VkBool32									stencilTestEnable;
249 		stencilOpState,												// VkStencilOpState							front;
250 		stencilOpState,												// VkStencilOpState							back;
251 		0.0f,														// float									minDepthBounds;
252 		1.0f,														// float									maxDepthBounds;
253 	};
254 
255 	const VkColorComponentFlags colorComponentsAll = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
256 	const VkPipelineColorBlendAttachmentState pipelineColorBlendAttachmentState =
257 	{
258 		m_blendEnable,						// VkBool32					blendEnable;
259 		VK_BLEND_FACTOR_SRC_ALPHA,			// VkBlendFactor			srcColorBlendFactor;
260 		VK_BLEND_FACTOR_ONE,				// VkBlendFactor			dstColorBlendFactor;
261 		VK_BLEND_OP_ADD,					// VkBlendOp				colorBlendOp;
262 		VK_BLEND_FACTOR_SRC_ALPHA,			// VkBlendFactor			srcAlphaBlendFactor;
263 		VK_BLEND_FACTOR_ONE,				// VkBlendFactor			dstAlphaBlendFactor;
264 		VK_BLEND_OP_ADD,					// VkBlendOp				alphaBlendOp;
265 		colorComponentsAll,					// VkColorComponentFlags	colorWriteMask;
266 	};
267 
268 	const VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateInfo =
269 	{
270 		VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,	// VkStructureType								sType;
271 		DE_NULL,													// const void*									pNext;
272 		(VkPipelineColorBlendStateCreateFlags)0,					// VkPipelineColorBlendStateCreateFlags			flags;
273 		VK_FALSE,													// VkBool32										logicOpEnable;
274 		VK_LOGIC_OP_COPY,											// VkLogicOp									logicOp;
275 		1u,															// deUint32										attachmentCount;
276 		&pipelineColorBlendAttachmentState,							// const VkPipelineColorBlendAttachmentState*	pAttachments;
277 		{ 0.0f, 0.0f, 0.0f, 0.0f },									// float										blendConstants[4];
278 	};
279 
280 	const VkGraphicsPipelineCreateInfo graphicsPipelineInfo =
281 	{
282 		VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,						// VkStructureType									sType;
283 		DE_NULL,																// const void*										pNext;
284 		(VkPipelineCreateFlags)0,												// VkPipelineCreateFlags							flags;
285 		static_cast<deUint32>(m_shaderStages.size()),							// deUint32											stageCount;
286 		&m_shaderStages[0],														// const VkPipelineShaderStageCreateInfo*			pStages;
287 		&vertexInputStateInfo,													// const VkPipelineVertexInputStateCreateInfo*		pVertexInputState;
288 		&pipelineInputAssemblyStateInfo,										// const VkPipelineInputAssemblyStateCreateInfo*	pInputAssemblyState;
289 		(m_shaderStageFlags & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT ? &pipelineTessellationStateInfo : DE_NULL), // const VkPipelineTessellationStateCreateInfo*		pTessellationState;
290 		(isRasterizationDisabled ? DE_NULL : &pipelineViewportStateInfo),		// const VkPipelineViewportStateCreateInfo*			pViewportState;
291 		&pipelineRasterizationStateInfo,										// const VkPipelineRasterizationStateCreateInfo*	pRasterizationState;
292 		(isRasterizationDisabled ? DE_NULL : &pipelineMultisampleStateInfo),	// const VkPipelineMultisampleStateCreateInfo*		pMultisampleState;
293 		(isRasterizationDisabled ? DE_NULL : &pipelineDepthStencilStateInfo),	// const VkPipelineDepthStencilStateCreateInfo*		pDepthStencilState;
294 		(isRasterizationDisabled ? DE_NULL : &pipelineColorBlendStateInfo),		// const VkPipelineColorBlendStateCreateInfo*		pColorBlendState;
295 		DE_NULL,																// const VkPipelineDynamicStateCreateInfo*			pDynamicState;
296 		pipelineLayout,															// VkPipelineLayout									layout;
297 		renderPass,																// VkRenderPass										renderPass;
298 		0u,																		// deUint32											subpass;
299 		DE_NULL,																// VkPipeline										basePipelineHandle;
300 		0,																		// deInt32											basePipelineIndex;
301 	};
302 
303 	return createGraphicsPipeline(vk, device, DE_NULL, &graphicsPipelineInfo);
304 }
305 
inputTypeToGLString(const VkPrimitiveTopology & inputType)306 std::string inputTypeToGLString (const VkPrimitiveTopology& inputType)
307 {
308 	switch (inputType)
309 	{
310 		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
311 			return "points";
312 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
313 		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
314 			return "lines";
315 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
316 		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
317 			return "lines_adjacency";
318 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
319 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
320 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
321 			return "triangles";
322 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
323 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
324 			return "triangles_adjacency";
325 		default:
326 			DE_ASSERT(DE_FALSE);
327 			return "error";
328 	}
329 }
330 
outputTypeToGLString(const VkPrimitiveTopology & outputType)331 std::string outputTypeToGLString (const VkPrimitiveTopology& outputType)
332 {
333 	switch (outputType)
334 	{
335 		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
336 			return "points";
337 		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
338 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
339 				return "line_strip";
340 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
341 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
342 			return "triangle_strip";
343 		default:
344 			DE_ASSERT(DE_FALSE);
345 			return "error";
346 	}
347 }
348 
calcOutputVertices(const VkPrimitiveTopology & inputType)349 size_t calcOutputVertices (const VkPrimitiveTopology&  inputType)
350 {
351 	switch (inputType)
352 	{
353 		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
354 			return 1 * 3;
355 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
356 		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
357 			return 2 * 3;
358 		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
359 		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
360 			return 4 * 3;
361 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
362 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
363 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
364 			return 3 * 3;
365 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
366 		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
367 			return 6 * 3;
368 		default:
369 			DE_ASSERT(DE_FALSE);
370 			return 0;
371 	}
372 }
373 
makeImageCreateInfo(const tcu::IVec2 & size,const VkFormat format,const VkImageUsageFlags usage,const deUint32 numArrayLayers)374 VkImageCreateInfo makeImageCreateInfo (const tcu::IVec2& size, const VkFormat format, const VkImageUsageFlags usage, const deUint32 numArrayLayers)
375 {
376 	const VkImageCreateInfo imageInfo =
377 	{
378 		VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,		// VkStructureType          sType;
379 		DE_NULL,									// const void*              pNext;
380 		(VkImageCreateFlags)0,						// VkImageCreateFlags       flags;
381 		VK_IMAGE_TYPE_2D,							// VkImageType              imageType;
382 		format,										// VkFormat                 format;
383 		makeExtent3D(size.x(), size.y(), 1),		// VkExtent3D               extent;
384 		1u,											// uint32_t                 mipLevels;
385 		numArrayLayers,								// uint32_t                 arrayLayers;
386 		VK_SAMPLE_COUNT_1_BIT,						// VkSampleCountFlagBits    samples;
387 		VK_IMAGE_TILING_OPTIMAL,					// VkImageTiling            tiling;
388 		usage,										// VkImageUsageFlags        usage;
389 		VK_SHARING_MODE_EXCLUSIVE,					// VkSharingMode            sharingMode;
390 		0u,											// uint32_t                 queueFamilyIndexCount;
391 		DE_NULL,									// const uint32_t*          pQueueFamilyIndices;
392 		VK_IMAGE_LAYOUT_UNDEFINED,					// VkImageLayout            initialLayout;
393 	};
394 	return imageInfo;
395 }
396 
makeBufferImageCopy(const vk::VkDeviceSize & bufferOffset,const vk::VkImageSubresourceLayers & imageSubresource,const vk::VkOffset3D & imageOffset,const vk::VkExtent3D & imageExtent)397 VkBufferImageCopy makeBufferImageCopy (const vk::VkDeviceSize&				bufferOffset,
398 									   const vk::VkImageSubresourceLayers&	imageSubresource,
399 									   const vk::VkOffset3D&				imageOffset,
400 									   const vk::VkExtent3D&				imageExtent)
401 {
402 	const VkBufferImageCopy copyParams =
403 	{
404 		bufferOffset,								//	VkDeviceSize				bufferOffset;
405 		0u,											//	deUint32					bufferRowLength;
406 		0u,											//	deUint32					bufferImageHeight;
407 		imageSubresource,							//	VkImageSubresourceLayers	imageSubresource;
408 		imageOffset,								//	VkOffset3D					imageOffset;
409 		imageExtent,								//	VkExtent3D					imageExtent;
410 	};
411 	return copyParams;
412 }
413 
compareWithFileImage(Context & context,const tcu::ConstPixelBufferAccess & resultImage,std::string testName)414 bool compareWithFileImage (Context& context, const tcu::ConstPixelBufferAccess& resultImage, std::string testName)
415 {
416 	tcu::TextureLevel referenceImage;
417 	std::string fileName="vulkan/data/geometry/"+testName+".png";
418 	tcu::ImageIO::loadPNG(referenceImage, context.getTestContext().getArchive(), fileName.c_str());
419 
420 	if (tcu::fuzzyCompare(context.getTestContext().getLog(), "ImageComparison", "Image Comparison",
421 								referenceImage.getAccess(), resultImage, 0.0015f, tcu::COMPARE_LOG_RESULT))
422 		return tcu::intThresholdPositionDeviationCompare(context.getTestContext().getLog(), "ImageComparison", "Image Comparison",
423 														referenceImage.getAccess(), resultImage, tcu::UVec4(1u, 1u, 1u, 1u), tcu::IVec3(2,2,2), false, tcu::COMPARE_LOG_RESULT);
424 	else
425 		return false;
426 }
427 
fillBuffer(const DeviceInterface & vk,const VkDevice device,const Allocation & alloc,const VkDeviceSize offset,const VkDeviceSize size,const VkFormat format,const tcu::Vec4 & color)428 void fillBuffer (const DeviceInterface& vk, const VkDevice device, const Allocation& alloc, const VkDeviceSize offset, const VkDeviceSize size, const VkFormat format, const tcu::Vec4& color)
429 {
430 	const tcu::TextureFormat	textureFormat		= mapVkFormat(format);
431 	const deUint32				colorPixelSize		= static_cast<deUint32>(tcu::getPixelSize(textureFormat));
432 	tcu::TextureLevel			colorPixelBuffer	(textureFormat, 1, 1);
433 	tcu::PixelBufferAccess		colorPixel			(colorPixelBuffer);
434 
435 	colorPixel.setPixel(color, 0, 0);
436 
437 	const deUint8*	src		= static_cast<deUint8*>(colorPixel.getDataPtr());
438 	deUint8*		dstBase	= static_cast<deUint8*>(alloc.getHostPtr());
439 	deUint8*		dst		= &dstBase[offset];
440 
441 	for (deUint32 pixelPos = 0; pixelPos < size; pixelPos += colorPixelSize)
442 		deMemcpy(&dst[pixelPos], src, colorPixelSize);
443 
444 	flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset() + offset, size);
445 }
446 
fillBuffer(const DeviceInterface & vk,const VkDevice device,const Allocation & alloc,const VkDeviceSize offset,const VkDeviceSize size,const VkFormat format,const float depth)447 void fillBuffer (const DeviceInterface& vk, const VkDevice device, const Allocation& alloc, const VkDeviceSize offset, const VkDeviceSize size, const VkFormat format, const float depth)
448 {
449 	const tcu::TextureFormat	textureFormat		= mapVkFormat(format);
450 	const deUint32				colorPixelSize		= static_cast<deUint32>(tcu::getPixelSize(textureFormat));
451 	tcu::TextureLevel			colorPixelBuffer	(textureFormat, 1, 1);
452 	tcu::PixelBufferAccess		colorPixel			(colorPixelBuffer);
453 
454 	colorPixel.setPixDepth(depth, 0, 0);
455 
456 	const deUint8*	src		= static_cast<deUint8*>(colorPixel.getDataPtr());
457 	deUint8*		dstBase	= static_cast<deUint8*>(alloc.getHostPtr());
458 	deUint8*		dst		= &dstBase[offset];
459 
460 	for (deUint32 pixelPos = 0; pixelPos < size; pixelPos += colorPixelSize)
461 		deMemcpy(&dst[pixelPos], src, colorPixelSize);
462 
463 	flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset() + offset, size);
464 }
465 
checkPointSize(const InstanceInterface & vki,const VkPhysicalDevice physDevice)466 VkBool32 checkPointSize (const InstanceInterface& vki, const VkPhysicalDevice physDevice)
467 {
468 	const VkPhysicalDeviceFeatures	features	= getPhysicalDeviceFeatures  (vki, physDevice);
469 	return features.shaderTessellationAndGeometryPointSize;
470 }
471 
472 } //geometry
473 } //vkt
474