1 #ifndef _VKBUFFERWITHMEMORY_HPP
2 #define _VKBUFFERWITHMEMORY_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 Buffer backed with memory
25 *//*--------------------------------------------------------------------*/
29 #include "vkMemUtil.hpp"
30 #include "vkQueryUtil.hpp"
32 #include "vkRefUtil.hpp"
36 class BufferWithMemory
39 BufferWithMemory (const vk::DeviceInterface& vk,
40 const vk::VkDevice device,
41 vk::Allocator& allocator,
42 const vk::VkBufferCreateInfo& bufferCreateInfo,
43 const vk::MemoryRequirement memoryRequirement)
45 : m_buffer (createBuffer(vk, device, &bufferCreateInfo))
46 , m_allocation (allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement))
48 VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
51 const vk::VkBuffer& get (void) const { return *m_buffer; }
52 const vk::VkBuffer& operator* (void) const { return get(); }
53 vk::Allocation& getAllocation (void) const { return *m_allocation; }
56 const vk::Unique<vk::VkBuffer> m_buffer;
57 const de::UniquePtr<vk::Allocation> m_allocation;
60 BufferWithMemory (const BufferWithMemory&);
61 BufferWithMemory operator= (const BufferWithMemory&);
65 #endif // _VKBUFFERWITHMEMORY_HPP