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, const vk::VkDevice device,
35 vk::Allocator &allocator, const vk::VkImageCreateInfo &imageCreateInfo,
36 const vk::MemoryRequirement requirement)
37 : m_image(createImage(vk, device, &imageCreateInfo))
38 {
39 if ((imageCreateInfo.flags & VK_IMAGE_CREATE_DISJOINT_BIT) != 0)
40 {
41 const uint32_t numPlanes = getPlaneCount(imageCreateInfo.format);
42
43 bindImagePlanesMemory(vk, device, *m_image, numPlanes, m_allocations, allocator, requirement);
44 }
45 else
46 {
47 const VkMemoryRequirements reqs = getImageMemoryRequirements(vk, device, *m_image);
48 m_allocations.push_back(AllocationSp(allocator.allocate(reqs, requirement).release()));
49 VK_CHECK(
50 vk.bindImageMemory(device, *m_image, m_allocations.back()->getMemory(), m_allocations.back()->getOffset()));
51 }
52 }
53
54 } // namespace vk
55