BRE12
ResourceManager.h
1 #pragma once
2 
3 #include <d3d12.h>
4 #include <mutex>
5 #include <tbb/concurrent_unordered_set.h>
6 
7 #include <ResourceManager/UploadBuffer.h>
8 
9 namespace BRE {
10 // This class is responsible to create/get:
11 // - Textures
12 // - Buffers
13 // - Resources
15 public:
16  ResourceManager() = delete;
17  ~ResourceManager() = delete;
18  ResourceManager(const ResourceManager&) = delete;
19  const ResourceManager& operator=(const ResourceManager&) = delete;
20  ResourceManager(ResourceManager&&) = delete;
21  ResourceManager& operator=(ResourceManager&&) = delete;
22 
23  static void EraseAll() noexcept;
24 
25  // If resourceName is nullptr, then it will have
26  // the default name.
27  static ID3D12Resource& LoadTextureFromFile(const char* textureFilename,
28  ID3D12GraphicsCommandList& commandList,
29  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadBuffer,
30  const wchar_t* resourceName) noexcept;
31 
32  // Note: uploadBuffer has to be kept alive after the above function calls because
33  // the command list has not been executed yet that performs the actual copy.
34  // The caller can Release the uploadBuffer after it knows the copy has been executed.
35 
36  // If resourceName is nullptr, then it will have
37  // the default name.
38  // Preconditions:
39  // - "sourceData" must not be nullptr
40  // - "sourceDataSize" must be greater than zero
41  static ID3D12Resource& CreateDefaultBuffer(ID3D12GraphicsCommandList& commandList,
42  const void* sourceData,
43  const std::size_t sourceDataSize,
44  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadBuffer,
45  const wchar_t* resourceName) noexcept;
46 
47  // If resourceName is nullptr, then it will have
48  // the default name.
49  static ID3D12Resource& CreateCommittedResource(const D3D12_HEAP_PROPERTIES& heapProperties,
50  const D3D12_HEAP_FLAGS& heapFlags,
51  const D3D12_RESOURCE_DESC& resourceDescriptor,
52  const D3D12_RESOURCE_STATES& resourceStates,
53  const D3D12_CLEAR_VALUE* clearValue,
54  const wchar_t* resourceName) noexcept;
55 
56 private:
58  static Resources mResources;
59 
60  static std::mutex mMutex;
61 };
62 
63 }
64 
Definition: Camera.cpp:8
Definition: concurrent_unordered_set.h:58
Definition: ResourceManager.h:14