1 #ifndef _VKTDRAWBUFFEROBJECTUTIL_HPP 2 #define _VKTDRAWBUFFEROBJECTUTIL_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 The Khronos Group Inc. 8 * Copyright (c) 2015 Intel Corporation 9 * 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 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 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. 21 * 22 *//*! 23 * \file 24 * \brief Buffer Object Util 25 *//*--------------------------------------------------------------------*/ 26 27 #include "vkMemUtil.hpp" 28 #include "vkRefUtil.hpp" 29 30 #include "deSharedPtr.hpp" 31 32 namespace vkt 33 { 34 namespace Draw 35 { 36 37 class Buffer 38 { 39 public: 40 static de::SharedPtr<Buffer> create(const vk::DeviceInterface &vk, vk::VkDevice device, 41 const vk::VkBufferCreateInfo &createInfo); 42 43 static de::SharedPtr<Buffer> createAndAlloc( 44 const vk::DeviceInterface &vk, vk::VkDevice device, const vk::VkBufferCreateInfo &createInfo, 45 vk::Allocator &allocator, vk::MemoryRequirement allocationMemoryProperties = vk::MemoryRequirement::Any, 46 vk::VkDeviceSize allocationOffset = 0ull); 47 48 Buffer(const vk::DeviceInterface &vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object); 49 50 void bindMemory(de::MovePtr<vk::Allocation> allocation, vk::VkDeviceSize allocOffset = 0ull); 51 object(void) const52 vk::VkBuffer object(void) const 53 { 54 return *m_object; 55 } getBoundMemory(void) const56 vk::Allocation getBoundMemory(void) const 57 { 58 return *m_allocation; 59 } 60 void *getHostPtr(void) const; 61 62 private: 63 Buffer(const Buffer &other); // Not allowed! 64 Buffer &operator=(const Buffer &other); // Not allowed! 65 66 de::MovePtr<vk::Allocation> m_allocation; 67 vk::VkDeviceSize m_allocOffset; 68 vk::Unique<vk::VkBuffer> m_object; 69 70 const vk::DeviceInterface &m_vk; 71 vk::VkDevice m_device; 72 }; 73 74 void bufferBarrier(const vk::DeviceInterface &vk, vk::VkCommandBuffer cmdBuffer, vk::VkBuffer buffer, 75 vk::VkAccessFlags srcAccessMask, vk::VkAccessFlags dstAccessMask, 76 vk::VkPipelineStageFlags srcStageMask, vk::VkPipelineStageFlags dstStageMask); 77 } // namespace Draw 78 } // namespace vkt 79 80 #endif // _VKTDRAWBUFFEROBJECTUTIL_HPP 81