Cogs.Core
CommonD3D12.h
1#pragma once
2
3#pragma warning(push)
4//NOTE: Disabled warning C4005 to avoid cascading warnings when compiling with the Windows 8.1 SDK/Kit and
5// the DirectX SDK installed separately.
6#pragma warning(disable:4005)
7#pragma warning(disable:4100)
8#pragma warning(disable:4458)
9#pragma warning(disable:4238)
10#pragma warning(disable:4458)
11#include <D3D12.h>
12#include <dxgi.h>
13#include "d3dx12.h"
14
15#include <vector>
16#include <cassert>
17
18#include "../Common.h"
19#include "../Base/EffectsCommon.h"
20#include "../Base/ResourceMap.h"
21#include "../Base/ResourcePointer.h"
22
23#include "Foundation/Logging/Logger.h"
24
25namespace Cogs
26{
28 {
29 D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
30
32 struct PoolBuffer * pooledResource = nullptr;
33
34 D3D12_RESOURCE_STATES usage = D3D12_RESOURCE_STATE_COMMON;
35 };
36
37 inline void setResourceBarrier(ID3D12GraphicsCommandList * commandList, ID3D12Resource * resource, D3D12_RESOURCE_STATES stateBefore, D3D12_RESOURCE_STATES stateAfter)
38 {
39 D3D12_RESOURCE_BARRIER barrier = {};
40
41 barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
42 barrier.Transition.pResource = resource;
43 barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
44 barrier.Transition.StateBefore = stateBefore;
45 barrier.Transition.StateAfter = stateAfter;
46
47 commandList->ResourceBarrier(1, &barrier);
48 }
49
50 inline void setResourceState(ID3D12GraphicsCommandList * commandList, ResourceD3D12 & resource, D3D12_RESOURCE_STATES stateAfter)
51 {
52 if (resource.usage == stateAfter) return;
53
54 setResourceBarrier(commandList, resource.resource, resource.usage, stateAfter);
55
56 resource.usage = stateAfter;
57 }
58
59 extern const CD3DX12_HEAP_PROPERTIES defaultHeapProperties;
60 extern const CD3DX12_HEAP_PROPERTIES uploadHeapProperties;
61 extern const CD3DX12_HEAP_PROPERTIES readbackHeapProperties;
62}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23