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 41 static de::SharedPtr<Buffer> create (const vk::DeviceInterface& vk, vk::VkDevice device, const vk::VkBufferCreateInfo &createInfo); 42 43 static de::SharedPtr<Buffer> createAndAlloc (const vk::DeviceInterface& vk, 44 vk::VkDevice device, 45 const vk::VkBufferCreateInfo& createInfo, 46 vk::Allocator& allocator, 47 vk::MemoryRequirement allocationMemoryProperties = vk::MemoryRequirement::Any, 48 vk::VkDeviceSize allocationOffset = 0ull); 49 50 Buffer (const vk::DeviceInterface &vk, vk::VkDevice device, vk::Move<vk::VkBuffer> object); 51 52 void bindMemory (de::MovePtr<vk::Allocation> allocation, vk::VkDeviceSize allocOffset = 0ull); 53 object(void) const54 vk::VkBuffer object (void) const { return *m_object; } getBoundMemory(void) const55 vk::Allocation getBoundMemory (void) const { return *m_allocation; } 56 void* getHostPtr (void) const; 57 58 private: 59 60 Buffer (const Buffer& other); // Not allowed! 61 Buffer& operator= (const Buffer& other); // Not allowed! 62 63 de::MovePtr<vk::Allocation> m_allocation; 64 vk::VkDeviceSize m_allocOffset; 65 vk::Unique<vk::VkBuffer> m_object; 66 67 const vk::DeviceInterface& m_vk; 68 vk::VkDevice m_device; 69 }; 70 71 void bufferBarrier (const vk::DeviceInterface& vk, 72 vk::VkCommandBuffer cmdBuffer, 73 vk::VkBuffer buffer, 74 vk::VkAccessFlags srcAccessMask, 75 vk::VkAccessFlags dstAccessMask, 76 vk::VkPipelineStageFlags srcStageMask, 77 vk::VkPipelineStageFlags dstStageMask); 78 } // Draw 79 } // vkt 80 81 #endif // _VKTDRAWBUFFEROBJECTUTIL_HPP 82