1 #ifndef _VKIMAGEWITHMEMORY_HPP
2 #define _VKIMAGEWITHMEMORY_HPP
3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
8 * Copyright (c) 2016 Google Inc.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Image backed with memory
25 *//*--------------------------------------------------------------------*/
28 #include "vkMemUtil.hpp"
29 #include "vkQueryUtil.hpp"
31 #include "vkRefUtil.hpp"
38 ImageWithMemory (const vk::DeviceInterface& vk,
39 const vk::VkDevice device,
40 vk::Allocator& allocator,
41 const vk::VkImageCreateInfo& imageCreateInfo,
42 const vk::MemoryRequirement memoryRequirement)
44 : m_image (createImage(vk, device, &imageCreateInfo))
45 , m_allocation (allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement))
47 VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
50 const vk::VkImage& get (void) const { return *m_image; }
51 const vk::VkImage& operator* (void) const { return get(); }
52 vk::Allocation& getAllocation (void) const { return *m_allocation; }
55 const vk::Unique<vk::VkImage> m_image;
56 const de::UniquePtr<vk::Allocation> m_allocation;
59 ImageWithMemory (const ImageWithMemory&);
60 ImageWithMemory& operator= (const ImageWithMemory&);
64 #endif // _VKIMAGEWITHMEMORY_HPP