BRE12
UploadBuffer.h
1 #pragma once
2 
3 #include <cstddef>
4 #include <cstdint>
5 #include <d3d12.h>
6 #include <wrl.h>
7 
8 namespace BRE {
9 class UploadBuffer {
10 public:
11  explicit UploadBuffer(ID3D12Device& device,
12  const std::size_t elementSize,
13  const std::uint32_t elementCount);
14 
15  ~UploadBuffer();
16  UploadBuffer(const UploadBuffer&) = delete;
17  const UploadBuffer& operator=(const UploadBuffer&) = delete;
18  UploadBuffer(UploadBuffer&&) = delete;
19  UploadBuffer& operator=(UploadBuffer&&) = delete;
20 
21  __forceinline ID3D12Resource* GetResource() const noexcept
22  {
23  return mBuffer.Get();
24  }
25 
26  void CopyData(const std::uint32_t elementIndex,
27  const void* sourceData,
28  const std::size_t sourceDataSize) const noexcept;
29 
30  // Constant buffers must be a multiple of the minimum hardware
31  // allocation size (usually 256 bytes). So round up to nearest
32  // multiple of 256.
33  static std::size_t GetRoundedConstantBufferSizeInBytes(const std::size_t sizeInBytes);
34 
35 private:
36  Microsoft::WRL::ComPtr<ID3D12Resource> mBuffer;
37  std::uint8_t* mMappedData{ nullptr };
38  std::size_t mElementSize{ 0U };
39 };
40 }
41 
Definition: Camera.cpp:8
Definition: UploadBuffer.h:9