diff options
| -rw-r--r-- | dxg/include/dxg/dxcommon.h | 2 | ||||
| -rw-r--r-- | dxg/include/dxg/imm.h | 2 | ||||
| -rw-r--r-- | dxg/src/imm.c | 8 | ||||
| -rw-r--r-- | triangle/main.c | 4 |
4 files changed, 7 insertions, 9 deletions
diff --git a/dxg/include/dxg/dxcommon.h b/dxg/include/dxg/dxcommon.h index 96cf3a5..6cc3466 100644 --- a/dxg/include/dxg/dxcommon.h +++ b/dxg/include/dxg/dxcommon.h | |||
| @@ -43,6 +43,8 @@ static inline free_aligned(alloc_t* alloc) { | |||
| 43 | #define FREE(ALLOC) free_aligned(&(ALLOC)) | 43 | #define FREE(ALLOC) free_aligned(&(ALLOC)) |
| 44 | 44 | ||
| 45 | #ifndef NDEBUG | 45 | #ifndef NDEBUG |
| 46 | #define WIN32_LEAN_AND_MEAN | ||
| 47 | #include <Windows.h> // OutputDebugStringA | ||
| 46 | #define DEBUG_PRINT OutputDebugStringA | 48 | #define DEBUG_PRINT OutputDebugStringA |
| 47 | #else | 49 | #else |
| 48 | #define DEBUG_PRINT | 50 | #define DEBUG_PRINT |
diff --git a/dxg/include/dxg/imm.h b/dxg/include/dxg/imm.h index fdee725..831c1b8 100644 --- a/dxg/include/dxg/imm.h +++ b/dxg/include/dxg/imm.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | typedef struct DxgImm DxgImm; | 7 | typedef struct DxgImm DxgImm; |
| 8 | 8 | ||
| 9 | DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue*, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSizeVerts); | 9 | DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue*, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSize); |
| 10 | void dxg_imm_destroy(DxgImm**); | 10 | void dxg_imm_destroy(DxgImm**); |
| 11 | void dxg_imm_set_graphics_state(DxgImm*, const D3D12_VIEWPORT*, D3D12_CPU_DESCRIPTOR_HANDLE hBackBufferView, D3D12_CPU_DESCRIPTOR_HANDLE hDepthStencilView); | 11 | void dxg_imm_set_graphics_state(DxgImm*, const D3D12_VIEWPORT*, D3D12_CPU_DESCRIPTOR_HANDLE hBackBufferView, D3D12_CPU_DESCRIPTOR_HANDLE hDepthStencilView); |
| 12 | void dxg_imm_flush(DxgImm*); | 12 | void dxg_imm_flush(DxgImm*); |
diff --git a/dxg/src/imm.c b/dxg/src/imm.c index 28baa99..4a4be93 100644 --- a/dxg/src/imm.c +++ b/dxg/src/imm.c | |||
| @@ -18,9 +18,6 @@ ping-ponging between the two buffers.*/ | |||
| 18 | #include <imm_vs.h> // generated | 18 | #include <imm_vs.h> // generated |
| 19 | #include <imm_ps.h> // generated | 19 | #include <imm_ps.h> // generated |
| 20 | 20 | ||
| 21 | #define WIN32_LEAN_AND_MEAN | ||
| 22 | #include <Windows.h> // OutputDebugStringA | ||
| 23 | |||
| 24 | #include <stdint.h> | 21 | #include <stdint.h> |
| 25 | #include <stdlib.h> | 22 | #include <stdlib.h> |
| 26 | 23 | ||
| @@ -181,7 +178,7 @@ static void dxg_imm_draw(DxgImm* imm) { | |||
| 181 | pCmdQueue->lpVtbl->ExecuteCommandLists(pCmdQueue, 1, cmdLists); | 178 | pCmdQueue->lpVtbl->ExecuteCommandLists(pCmdQueue, 1, cmdLists); |
| 182 | } | 179 | } |
| 183 | 180 | ||
| 184 | DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSizeVerts) { | 181 | DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSize) { |
| 185 | assert(pDevice); | 182 | assert(pDevice); |
| 186 | assert(pCmdQueue); | 183 | assert(pCmdQueue); |
| 187 | 184 | ||
| @@ -192,7 +189,7 @@ DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_ | |||
| 192 | 189 | ||
| 193 | imm->pDevice = pDevice; | 190 | imm->pDevice = pDevice; |
| 194 | imm->pCmdQueue = pCmdQueue; | 191 | imm->pCmdQueue = pCmdQueue; |
| 195 | imm->bufferSizeVerts = bufferSizeVerts; | 192 | imm->bufferSizeVerts = bufferSize / 3 / sizeof(float); |
| 196 | imm->fenceValue = 0; | 193 | imm->fenceValue = 0; |
| 197 | 194 | ||
| 198 | // TODO: Move this to the application side. | 195 | // TODO: Move this to the application side. |
| @@ -271,7 +268,6 @@ DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_ | |||
| 271 | TrapIfFailed(imm->pDevice->lpVtbl->CreateGraphicsPipelineState( | 268 | TrapIfFailed(imm->pDevice->lpVtbl->CreateGraphicsPipelineState( |
| 272 | imm->pDevice, &gpso, &IID_ID3D12PipelineState, &imm->pPipelineState)); | 269 | imm->pDevice, &gpso, &IID_ID3D12PipelineState, &imm->pPipelineState)); |
| 273 | 270 | ||
| 274 | const size_t bufferSize = verts_byte_count(bufferSizeVerts); | ||
| 275 | for (int i = 0; i < 2; ++i) { | 271 | for (int i = 0; i < 2; ++i) { |
| 276 | imm->resources[i].pVertexBuffer = create_buffer(pDevice, bufferSize); | 272 | imm->resources[i].pVertexBuffer = create_buffer(pDevice, bufferSize); |
| 277 | if (!imm->resources[i].pVertexBuffer) { | 273 | if (!imm->resources[i].pVertexBuffer) { |
diff --git a/triangle/main.c b/triangle/main.c index 3413fdf..1ed4c4a 100644 --- a/triangle/main.c +++ b/triangle/main.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #define HEIGHT 1200 | 9 | #define HEIGHT 1200 |
| 10 | 10 | ||
| 11 | #define SWAP_CHAIN_BUFFER_COUNT 2 // Double-buffering. | 11 | #define SWAP_CHAIN_BUFFER_COUNT 2 // Double-buffering. |
| 12 | #define IMM_NUM_VERTS 1024 | 12 | #define IMM_BUFFER_SIZE (16 * 1024) |
| 13 | 13 | ||
| 14 | typedef struct D3DSettings | 14 | typedef struct D3DSettings |
| 15 | { | 15 | { |
| @@ -287,7 +287,7 @@ static void d3d_init(D3D* d3d, Window* pWindow, const D3DSettings* pSettings) { | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | d3d->pImm = dxg_imm_init( | 289 | d3d->pImm = dxg_imm_init( |
| 290 | d3d->pDevice, d3d->pCommandQueue, swapChainRtvFormat, swapChainSampleDesc, IMM_NUM_VERTS); | 290 | d3d->pDevice, d3d->pCommandQueue, swapChainRtvFormat, swapChainSampleDesc, IMM_BUFFER_SIZE); |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | void d3d_destroy(D3D* d3d) { | 293 | void d3d_destroy(D3D* d3d) { |
