BRE12
ResourceStateManager.h
1 #pragma once
2 
3 #include <d3d12.h>
4 #include <tbb/concurrent_hash_map.h>
5 
6 #include <DXUtils\d3dx12.h>
7 
8 struct ID3D12Resource;
9 
10 namespace BRE {
11 // To track resource states.
12 // Its functionality includes:
13 // - GetResource state registration
14 // - GetResource state change
15 // - GetResource unregistration
17 public:
18  ResourceStateManager() = delete;
19  ~ResourceStateManager() = delete;
21  const ResourceStateManager& operator=(const ResourceStateManager&) = delete;
23  ResourceStateManager& operator=(ResourceStateManager&&) = delete;
24 
25  // Preconditions:
26  // - Resource must not have been registered
27  static void AddResource(ID3D12Resource& resource,
28  const D3D12_RESOURCE_STATES initialState) noexcept;
29 
30  // Preconditions:
31  // - Resource must have been registered
32  // - New state must be different than current state
33  static CD3DX12_RESOURCE_BARRIER ChangeResourceStateAndGetBarrier(ID3D12Resource& resource,
34  const D3D12_RESOURCE_STATES newState) noexcept;
35 
36  // Preconditions:
37  // - Resource must have been registered
38  static D3D12_RESOURCE_STATES GetResourceState(ID3D12Resource& resource) noexcept;
39 
40 private:
42  static StateByResource mStateByResource;
43 };
44 }
45 
Definition: ResourceStateManager.h:16
Definition: Camera.cpp:8
Unordered map from Key to T.
Definition: concurrent_hash_map.h:63