1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Intel Corporation
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * \brief Buffer Object Util
23 *//*--------------------------------------------------------------------*/
25 #include "vktDrawBufferObjectUtil.hpp"
27 #include "vkQueryUtil.hpp"
34 Buffer::Buffer (const vk::DeviceInterface& vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object_)
35 : m_allocation (DE_NULL)
42 void Buffer::bindMemory (de::MovePtr<vk::Allocation> allocation)
44 DE_ASSERT(allocation);
45 VK_CHECK(m_vk.bindBufferMemory(m_device, *m_object, allocation->getMemory(), allocation->getOffset()));
47 DE_ASSERT(!m_allocation);
48 m_allocation = allocation;
51 de::SharedPtr<Buffer> Buffer::createAndAlloc (const vk::DeviceInterface& vk,
53 const vk::VkBufferCreateInfo &createInfo,
54 vk::Allocator &allocator,
55 vk::MemoryRequirement memoryRequirement)
57 de::SharedPtr<Buffer> ret = create(vk, device, createInfo);
59 vk::VkMemoryRequirements bufferRequirements = vk::getBufferMemoryRequirements(vk, device, ret->object());
60 ret->bindMemory(allocator.allocate(bufferRequirements, memoryRequirement));
64 de::SharedPtr<Buffer> Buffer::create (const vk::DeviceInterface& vk,
66 const vk::VkBufferCreateInfo& createInfo)
68 return de::SharedPtr<Buffer>(new Buffer(vk, device, vk::createBuffer(vk, device, &createInfo)));