BsVulkanHardwareBuffer.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsVulkanPrerequisites.h"
  5. #include "BsHardwareBuffer.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Vulkan
  9. * @{
  10. */
  11. /** Class containing common functionality for all Vulkan hardware buffers. */
  12. class VulkanHardwareBuffer : public HardwareBuffer
  13. {
  14. /** Information about allocated buffer memory for a single device. */
  15. struct MemoryInfo
  16. {
  17. SPtr<VulkanDevice> device;
  18. VkDeviceMemory memory;
  19. };
  20. public:
  21. VulkanHardwareBuffer(GpuBufferUsage usage, const VkMemoryRequirements& reqs, bool useSystemMem = false,
  22. GpuDeviceFlags deviceMask = GDF_DEFAULT);
  23. ~VulkanHardwareBuffer();
  24. /** @copydoc HardwareBuffer::readData */
  25. void readData(UINT32 offset, UINT32 length, void* dest, UINT32 syncMask = 0x00000001) override;
  26. /** @copydoc HardwareBuffer::writeData */
  27. void writeData(UINT32 offset, UINT32 length, const void* source,
  28. BufferWriteType writeFlags = BWT_NORMAL, UINT32 syncMask = 0x00000001) override;
  29. /** @copydoc HardwareBuffer::copyData */
  30. void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset,
  31. UINT32 length, bool discardWholeBuffer = false, UINT32 syncMask = 0x00000001) override;
  32. protected:
  33. /** @copydoc HardwareBuffer::map */
  34. void* map(UINT32 offset, UINT32 length, GpuLockOptions options, UINT32 syncMask) override;
  35. /** @copydoc HardwareBuffer::unmap */
  36. void unmap() override;
  37. MemoryInfo mAllocations[BS_MAX_DEVICES];
  38. };
  39. /** @} */
  40. }