• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * Vulkan CTS Framework
3  * --------------------
4  *
5  * Copyright (c) 2018 The Khronos Group Inc.
6  * Copyright (c) 2018 Google Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief Utility for generating barriers
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vkBarrierUtil.hpp"
26 
27 namespace vk
28 {
29 
makeBufferMemoryBarrier(const VkAccessFlags srcAccessMask,const VkAccessFlags dstAccessMask,const VkBuffer buffer,const VkDeviceSize offset,const VkDeviceSize bufferSizeBytes)30 VkBufferMemoryBarrier makeBufferMemoryBarrier (const VkAccessFlags	srcAccessMask,
31 											   const VkAccessFlags	dstAccessMask,
32 											   const VkBuffer		buffer,
33 											   const VkDeviceSize	offset,
34 											   const VkDeviceSize	bufferSizeBytes)
35 {
36 	const VkBufferMemoryBarrier barrier =
37 	{
38 		VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,	// VkStructureType	sType;
39 		DE_NULL,									// const void*		pNext;
40 		srcAccessMask,								// VkAccessFlags	srcAccessMask;
41 		dstAccessMask,								// VkAccessFlags	dstAccessMask;
42 		VK_QUEUE_FAMILY_IGNORED,					// deUint32			srcQueueFamilyIndex;
43 		VK_QUEUE_FAMILY_IGNORED,					// deUint32			destQueueFamilyIndex;
44 		buffer,										// VkBuffer			buffer;
45 		offset,										// VkDeviceSize		offset;
46 		bufferSizeBytes,							// VkDeviceSize		size;
47 	};
48 	return barrier;
49 }
50 
makeImageMemoryBarrier(const VkAccessFlags srcAccessMask,const VkAccessFlags dstAccessMask,const VkImageLayout oldLayout,const VkImageLayout newLayout,const VkImage image,const VkImageSubresourceRange subresourceRange,const deUint32 srcQueueFamilyIndex,const deUint32 destQueueFamilyIndex)51 VkImageMemoryBarrier makeImageMemoryBarrier (const VkAccessFlags			srcAccessMask,
52 											 const VkAccessFlags			dstAccessMask,
53 											 const VkImageLayout			oldLayout,
54 											 const VkImageLayout			newLayout,
55 											 const VkImage					image,
56 											 const VkImageSubresourceRange	subresourceRange,
57 											 const deUint32					srcQueueFamilyIndex,
58 											 const deUint32					destQueueFamilyIndex)
59 {
60 	const VkImageMemoryBarrier barrier =
61 	{
62 		VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,	// VkStructureType			sType;
63 		DE_NULL,								// const void*				pNext;
64 		srcAccessMask,							// VkAccessFlags			outputMask;
65 		dstAccessMask,							// VkAccessFlags			inputMask;
66 		oldLayout,								// VkImageLayout			oldLayout;
67 		newLayout,								// VkImageLayout			newLayout;
68 		srcQueueFamilyIndex,					// deUint32					srcQueueFamilyIndex;
69 		destQueueFamilyIndex,					// deUint32					destQueueFamilyIndex;
70 		image,									// VkImage					image;
71 		subresourceRange,						// VkImageSubresourceRange	subresourceRange;
72 	};
73 	return barrier;
74 }
75 
makeMemoryBarrier(const VkAccessFlags srcAccessMask,const VkAccessFlags dstAccessMask)76 VkMemoryBarrier makeMemoryBarrier (const VkAccessFlags	srcAccessMask,
77 								   const VkAccessFlags	dstAccessMask)
78 {
79 	const VkMemoryBarrier barrier =
80 	{
81 		VK_STRUCTURE_TYPE_MEMORY_BARRIER,	// VkStructureType    sType;
82 		DE_NULL,							// const void*        pNext;
83 		srcAccessMask,						// VkAccessFlags      srcAccessMask;
84 		dstAccessMask,						// VkAccessFlags      dstAccessMask;
85 	};
86 	return barrier;
87 }
88 
89 } // vkt
90