BRE12
VertexAndIndexBufferCreator.h
1 #pragma once
2 
3 #include <cstddef>
4 #include <cstdint>
5 #include <d3d12.h>
6 #include <wrl.h>
7 
8 namespace BRE {
10 public:
11  VertexAndIndexBufferCreator() = delete;
12  ~VertexAndIndexBufferCreator() = delete;
14  const VertexAndIndexBufferCreator& operator=(const VertexAndIndexBufferCreator&) = delete;
17 
19  BufferCreationData() = default;
20  explicit BufferCreationData(const void* data,
21  const std::uint32_t elementCount,
22  const std::size_t elementSize);
23  ~BufferCreationData() = default;
24  BufferCreationData(const BufferCreationData&) = delete;
25  const BufferCreationData& operator=(const BufferCreationData&) = delete;
27  BufferCreationData& operator=(BufferCreationData&&) = delete;
28 
29  bool IsDataValid() const noexcept;
30 
31  const void* mData{ nullptr };
32  std::uint32_t mElementCount{ 0U };
33  std::size_t mElementSize{ 0UL };
34  };
35 
37  VertexBufferData() = default;
38  ~VertexBufferData() = default;
39  VertexBufferData(const VertexBufferData&) = default;
40 
41  const VertexBufferData& operator=(const VertexBufferData& instance);
42 
44  VertexBufferData& operator=(VertexBufferData&&) = default;
45 
46  bool IsDataValid() const noexcept;
47 
48  ID3D12Resource* mBuffer{ nullptr };
49  D3D12_VERTEX_BUFFER_VIEW mBufferView{};
50  std::uint32_t mElementCount{ 0U };
51  };
52 
53  struct IndexBufferData {
54  IndexBufferData() = default;
55  ~IndexBufferData() = default;
56  IndexBufferData(const IndexBufferData&) = default;
57 
58  const IndexBufferData& operator=(const IndexBufferData& instance);
59 
60  IndexBufferData(IndexBufferData&&) = default;
61  IndexBufferData& operator=(IndexBufferData&&) = default;
62 
63  bool IsDataValid() const noexcept;
64 
65  ID3D12Resource* mBuffer{ nullptr };
66  D3D12_INDEX_BUFFER_VIEW mBufferView{};
67  std::uint32_t mElementCount{ 0U };
68  };
69 
70  static void CreateVertexBuffer(ID3D12GraphicsCommandList& commandList,
71  const BufferCreationData& bufferCreationData,
72  VertexBufferData& vertexBufferData,
73  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadBuffer) noexcept;
74 
75  static void CreateIndexBuffer(ID3D12GraphicsCommandList& commandList,
76  const BufferCreationData& bufferCreationData,
77  IndexBufferData& indexBufferData,
78  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadBuffer) noexcept;
79 };
80 }
81 
Definition: Camera.cpp:8
Definition: VertexAndIndexBufferCreator.h:53
Definition: VertexAndIndexBufferCreator.h:18
Definition: VertexAndIndexBufferCreator.h:9
Definition: VertexAndIndexBufferCreator.h:36