From d89331f1636f8d53a3c8e9d0f7bfcf7a6041b88a Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 4 Dec 2025 18:50:48 -0800 Subject: Tidy --- dxg/include/dxg/dxcommon.h | 2 ++ dxg/include/dxg/imm.h | 2 +- dxg/src/imm.c | 8 ++------ 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) { #define FREE(ALLOC) free_aligned(&(ALLOC)) #ifndef NDEBUG +#define WIN32_LEAN_AND_MEAN +#include // OutputDebugStringA #define DEBUG_PRINT OutputDebugStringA #else #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 @@ typedef struct DxgImm DxgImm; -DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue*, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSizeVerts); +DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue*, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSize); void dxg_imm_destroy(DxgImm**); void dxg_imm_set_graphics_state(DxgImm*, const D3D12_VIEWPORT*, D3D12_CPU_DESCRIPTOR_HANDLE hBackBufferView, D3D12_CPU_DESCRIPTOR_HANDLE hDepthStencilView); 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.*/ #include // generated #include // generated -#define WIN32_LEAN_AND_MEAN -#include // OutputDebugStringA - #include #include @@ -181,7 +178,7 @@ static void dxg_imm_draw(DxgImm* imm) { pCmdQueue->lpVtbl->ExecuteCommandLists(pCmdQueue, 1, cmdLists); } -DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSizeVerts) { +DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_FORMAT swapChainRtvFormat, DXGI_SAMPLE_DESC swapChainSampleDesc, size_t bufferSize) { assert(pDevice); assert(pCmdQueue); @@ -192,7 +189,7 @@ DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_ imm->pDevice = pDevice; imm->pCmdQueue = pCmdQueue; - imm->bufferSizeVerts = bufferSizeVerts; + imm->bufferSizeVerts = bufferSize / 3 / sizeof(float); imm->fenceValue = 0; // TODO: Move this to the application side. @@ -271,7 +268,6 @@ DxgImm* dxg_imm_init(ID3D12Device* pDevice, ID3D12CommandQueue* pCmdQueue, DXGI_ TrapIfFailed(imm->pDevice->lpVtbl->CreateGraphicsPipelineState( imm->pDevice, &gpso, &IID_ID3D12PipelineState, &imm->pPipelineState)); - const size_t bufferSize = verts_byte_count(bufferSizeVerts); for (int i = 0; i < 2; ++i) { imm->resources[i].pVertexBuffer = create_buffer(pDevice, bufferSize); 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 @@ #define HEIGHT 1200 #define SWAP_CHAIN_BUFFER_COUNT 2 // Double-buffering. -#define IMM_NUM_VERTS 1024 +#define IMM_BUFFER_SIZE (16 * 1024) typedef struct D3DSettings { @@ -287,7 +287,7 @@ static void d3d_init(D3D* d3d, Window* pWindow, const D3DSettings* pSettings) { } d3d->pImm = dxg_imm_init( - d3d->pDevice, d3d->pCommandQueue, swapChainRtvFormat, swapChainSampleDesc, IMM_NUM_VERTS); + d3d->pDevice, d3d->pCommandQueue, swapChainRtvFormat, swapChainSampleDesc, IMM_BUFFER_SIZE); } void d3d_destroy(D3D* d3d) { -- cgit v1.2.3