• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * Vulkan CTS Framework
3  * --------------------
4  *
5  * Copyright (c) 2019 Google Inc.
6  * Copyright (c) 2019 The Khronos Group Inc.
7  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief YCbCR Image backed with memory
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vkYCbCrImageWithMemory.hpp"
27 
28 #include "vkQueryUtil.hpp"
29 #include "vkImageUtil.hpp"
30 
31 namespace vk
32 {
33 
YCbCrImageWithMemory(const vk::DeviceInterface & vk,const vk::VkDevice device,vk::Allocator & allocator,const vk::VkImageCreateInfo & imageCreateInfo,const vk::MemoryRequirement requirement)34 YCbCrImageWithMemory::YCbCrImageWithMemory (const vk::DeviceInterface&		vk,
35 											const vk::VkDevice				device,
36 											vk::Allocator&					allocator,
37 											const vk::VkImageCreateInfo&	imageCreateInfo,
38 											const vk::MemoryRequirement		requirement)
39 	: m_image	(createImage(vk, device, &imageCreateInfo))
40 {
41 	if ((imageCreateInfo.flags & VK_IMAGE_CREATE_DISJOINT_BIT) != 0)
42 	{
43 		const deUint32	numPlanes	= getPlaneCount(imageCreateInfo.format);
44 
45 		bindImagePlanesMemory(vk, device, *m_image, numPlanes, m_allocations, allocator, requirement);
46 	}
47 	else
48 	{
49 		const VkMemoryRequirements reqs = getImageMemoryRequirements(vk, device, *m_image);
50 		m_allocations.push_back(AllocationSp(allocator.allocate(reqs, requirement).release()));
51 		VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocations.back()->getMemory(), m_allocations.back()->getOffset()));
52 	}
53 }
54 
55 } // vk
56