ConstantBufferVK.h 810 B

123456789101112131415161718192021222324252627282930
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2024 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Renderer/VK/BufferVK.h>
  6. class RendererVK;
  7. /// A binary blob that can be used to pass constants to a shader
  8. class ConstantBufferVK
  9. {
  10. public:
  11. /// Constructor
  12. ConstantBufferVK(RendererVK *inRenderer, VkDeviceSize inBufferSize);
  13. ~ConstantBufferVK();
  14. /// Map / unmap buffer (get pointer to data). This will discard all data in the buffer.
  15. template <typename T> T * Map() { return reinterpret_cast<T *>(MapInternal()); }
  16. void Unmap();
  17. VkBuffer GetBuffer() const { return mBuffer.mBuffer; }
  18. private:
  19. void * MapInternal();
  20. RendererVK * mRenderer;
  21. BufferVK mBuffer;
  22. };