diff options
| author | Marc Sunet <marc.sunet@amd.com> | 2025-11-21 10:58:06 -0800 |
|---|---|---|
| committer | Marc Sunet <marc.sunet@amd.com> | 2025-11-21 10:58:06 -0800 |
| commit | e39e9b5bf1fb28f321b01fa427e2a7c206195b2c (patch) | |
| tree | 51d0f561e0373806466f965e41250386d3fb0828 | |
| parent | 0b5491e0a2f1a9a4023e2c4eb171287bede41388 (diff) | |
Tidy
| -rw-r--r-- | app/include/dxwindow.h | 9 | ||||
| -rw-r--r-- | hello/main.c | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/include/dxwindow.h b/app/include/dxwindow.h index 7e5a373..14caa36 100644 --- a/app/include/dxwindow.h +++ b/app/include/dxwindow.h | |||
| @@ -21,8 +21,17 @@ void window_global_quit(); | |||
| 21 | /// Return the last Window error. | 21 | /// Return the last Window error. |
| 22 | const char* window_get_error(); | 22 | const char* window_get_error(); |
| 23 | 23 | ||
| 24 | /// Initialize the window. | ||
| 24 | Window* window_init(int width, int height, const char* title); | 25 | Window* window_init(int width, int height, const char* title); |
| 26 | |||
| 27 | /// Destroy the window. | ||
| 25 | void window_destroy(Window**); | 28 | void window_destroy(Window**); |
| 29 | |||
| 30 | /// Return the Windows handle. | ||
| 26 | HWND window_handle(Window*); | 31 | HWND window_handle(Window*); |
| 32 | |||
| 33 | /// Update the window, poll for events. | ||
| 27 | void window_update(Window*); | 34 | void window_update(Window*); |
| 35 | |||
| 36 | /// Return whether the user has requested that the window should be closed. | ||
| 28 | bool window_should_close(const Window*); | 37 | bool window_should_close(const Window*); |
diff --git a/hello/main.c b/hello/main.c index 738f5c0..44f8a90 100644 --- a/hello/main.c +++ b/hello/main.c | |||
| @@ -47,6 +47,7 @@ static void d3d_create_swap_chain(D3D* d3d) { | |||
| 47 | assert(d3d); | 47 | assert(d3d); |
| 48 | assert(d3d->pDxgiFactory); | 48 | assert(d3d->pDxgiFactory); |
| 49 | assert(d3d->pCommandQueue); | 49 | assert(d3d->pCommandQueue); |
| 50 | assert(d3d->pWindow); | ||
| 50 | 51 | ||
| 51 | SafeRelease(d3d->pSwapChain); | 52 | SafeRelease(d3d->pSwapChain); |
| 52 | 53 | ||
| @@ -80,7 +81,9 @@ static void d3d_create_swap_chain_buffer_render_target_views(D3D* d3d) { | |||
| 80 | assert(d3d); | 81 | assert(d3d); |
| 81 | assert(d3d->pDevice); | 82 | assert(d3d->pDevice); |
| 82 | assert(d3d->pSwapChain); | 83 | assert(d3d->pSwapChain); |
| 84 | assert(d3d->pSwapChainBuffer); | ||
| 83 | assert(d3d->pRtvHeap); | 85 | assert(d3d->pRtvHeap); |
| 86 | assert(d3d->rtv_descriptor_size > 0); | ||
| 84 | 87 | ||
| 85 | // Create the new buffer views. | 88 | // Create the new buffer views. |
| 86 | D3D12_CPU_DESCRIPTOR_HANDLE rtv_heap_handle; | 89 | D3D12_CPU_DESCRIPTOR_HANDLE rtv_heap_handle; |
| @@ -276,6 +279,7 @@ static void d3d_init(D3D* d3d, Window* pWindow, const D3DSettings* pSettings) { | |||
| 276 | 279 | ||
| 277 | static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d3d) { | 280 | static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d3d) { |
| 278 | assert(d3d); | 281 | assert(d3d); |
| 282 | assert(d3d->pSwapChain); | ||
| 279 | assert(d3d->pRtvHeap); | 283 | assert(d3d->pRtvHeap); |
| 280 | assert(d3d->rtv_descriptor_size > 0); | 284 | assert(d3d->rtv_descriptor_size > 0); |
| 281 | D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle; | 285 | D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle; |
| @@ -288,11 +292,15 @@ static D3D12_CPU_DESCRIPTOR_HANDLE d3d_get_current_back_buffer_view(const D3D* d | |||
| 288 | 292 | ||
| 289 | static ID3D12Resource* d3d_get_current_back_buffer(const D3D* d3d) { | 293 | static ID3D12Resource* d3d_get_current_back_buffer(const D3D* d3d) { |
| 290 | assert(d3d); | 294 | assert(d3d); |
| 295 | assert(d3d->pSwapChain); | ||
| 296 | assert(d3d->pSwapChainBuffer); | ||
| 291 | return d3d->pSwapChainBuffer[d3d->pSwapChain->lpVtbl->GetCurrentBackBufferIndex(d3d->pSwapChain)]; | 297 | return d3d->pSwapChainBuffer[d3d->pSwapChain->lpVtbl->GetCurrentBackBufferIndex(d3d->pSwapChain)]; |
| 292 | } | 298 | } |
| 293 | 299 | ||
| 294 | static void d3d_populate_command_list(D3D* d3d) { | 300 | static void d3d_populate_command_list(D3D* d3d) { |
| 295 | assert(d3d); | 301 | assert(d3d); |
| 302 | assert(d3d->pCommandAllocator); | ||
| 303 | assert(d3d->pCommandList); | ||
| 296 | 304 | ||
| 297 | /// Note that we skip the following two items: | 305 | /// Note that we skip the following two items: |
| 298 | /// | 306 | /// |
| @@ -356,6 +364,8 @@ static void d3d_populate_command_list(D3D* d3d) { | |||
| 356 | 364 | ||
| 357 | static void d3d_wait_for_previous_frame(D3D* d3d) { | 365 | static void d3d_wait_for_previous_frame(D3D* d3d) { |
| 358 | assert(d3d); | 366 | assert(d3d); |
| 367 | assert(d3d->pFence); | ||
| 368 | assert(d3d->pCommandQueue); | ||
| 359 | 369 | ||
| 360 | // Advance the fence value to mark commands up to this fence point. | 370 | // Advance the fence value to mark commands up to this fence point. |
| 361 | d3d->fence_value++; | 371 | d3d->fence_value++; |
| @@ -385,6 +395,8 @@ static void d3d_wait_for_previous_frame(D3D* d3d) { | |||
| 385 | 395 | ||
| 386 | static void d3d_render(D3D* d3d) { | 396 | static void d3d_render(D3D* d3d) { |
| 387 | assert(d3d); | 397 | assert(d3d); |
| 398 | assert(d3d->pCommandQueue); | ||
| 399 | assert(d3d->pSwapChain); | ||
| 388 | 400 | ||
| 389 | d3d_populate_command_list(d3d); | 401 | d3d_populate_command_list(d3d); |
| 390 | 402 | ||
