diff options
| author | Marc Sunet <marc.sunet@amd.com> | 2025-11-21 09:41:06 -0800 |
|---|---|---|
| committer | Marc Sunet <marc.sunet@amd.com> | 2025-11-21 09:41:06 -0800 |
| commit | 0b5491e0a2f1a9a4023e2c4eb171287bede41388 (patch) | |
| tree | e82e93313f1fcfcc5622bae706aea9335dbc43ef /dxg/include | |
| parent | b5697421bbc73ed17ef3a8bc003571d1b6351b5c (diff) | |
Switch to plain C
Diffstat (limited to 'dxg/include')
| -rw-r--r-- | dxg/include/dxg/dxcommon.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/dxg/include/dxg/dxcommon.h b/dxg/include/dxg/dxcommon.h new file mode 100644 index 0000000..bfcdbe8 --- /dev/null +++ b/dxg/include/dxg/dxcommon.h | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <d3d12.h> | ||
| 4 | #include <dxgi1_4.h> | ||
| 5 | #include <directx/d3dx12.h> | ||
| 6 | |||
| 7 | #include <assert.h> | ||
| 8 | #include <stdio.h> | ||
| 9 | |||
| 10 | #define TRAP(ERROR) { \ | ||
| 11 | fprintf(stderr, "Error in file:[%s] line:%d: %s", __FILE__, __LINE__, ERROR);\ | ||
| 12 | assert(false);\ | ||
| 13 | __debugbreak();\ | ||
| 14 | } | ||
| 15 | |||
| 16 | #define TRAP_HRESULT(RESULT) { \ | ||
| 17 | fprintf(stderr, "HRESULT: %u", RESULT);\ | ||
| 18 | TRAP("API call failed")\ | ||
| 19 | } | ||
| 20 | |||
| 21 | #define TrapIfFailed(RESULT) {\ | ||
| 22 | if (RESULT != S_OK) {\ | ||
| 23 | TRAP_HRESULT(RESULT);\ | ||
| 24 | }\ | ||
| 25 | } | ||
| 26 | |||
| 27 | #define SafeRelease(PTR) {\ | ||
| 28 | if (PTR) {\ | ||
| 29 | PTR->lpVtbl->Release(PTR);\ | ||
| 30 | PTR = 0;\ | ||
| 31 | }\ | ||
| 32 | } | ||
| 33 | |||
| 34 | #define CD3DX12_CPU_DESCRIPTOR_HANDLE(HANDLE, INDEX, SIZE) \ | ||
| 35 | (D3D12_CPU_DESCRIPTOR_HANDLE){HANDLE.ptr + (INDEX * SIZE)} | ||
| 36 | |||
| 37 | #define OFFSET_HANDLE(HANDLE, OFFSET, SIZE) \ | ||
| 38 | (D3D12_CPU_DESCRIPTOR_HANDLE){HANDLE.ptr + (OFFSET * SIZE)} | ||
| 39 | |||
| 40 | static inline D3D12_RESOURCE_BARRIER CD3DX12_RESOURCE_BARRIER_Transition( | ||
| 41 | _In_ ID3D12Resource* pResource, | ||
| 42 | D3D12_RESOURCE_STATES stateBefore, | ||
| 43 | D3D12_RESOURCE_STATES stateAfter) { | ||
| 44 | return (D3D12_RESOURCE_BARRIER){ | ||
| 45 | .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, | ||
| 46 | .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, | ||
| 47 | .Transition.pResource = pResource, | ||
| 48 | .Transition.StateBefore = stateBefore, | ||
| 49 | .Transition.StateAfter = stateAfter, | ||
| 50 | .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES}; | ||
| 51 | } | ||
| 52 | |||
| 53 | typedef enum SampleMask { | ||
| 54 | PointSampling = 0xffffffff | ||
| 55 | } SampleMask; | ||
