From ef2a6456b0a498b5d1e723c32b6c3c5a5dc3a86b Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Wed, 19 Nov 2025 11:47:18 -0800 Subject: Tidy --- hello/main.cc | 62 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'hello/main.cc') diff --git a/hello/main.cc b/hello/main.cc index 47a2aba..bd76cc3 100644 --- a/hello/main.cc +++ b/hello/main.cc @@ -11,7 +11,7 @@ using Microsoft::WRL::ComPtr; struct D3DSettings { - int width = 0; + int width = 0; int height = 0; }; @@ -52,7 +52,7 @@ public: m_cbv_descriptor_size = m_device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - const D3D12_COMMAND_QUEUE_DESC queue_desc = + const D3D12_COMMAND_QUEUE_DESC queue_desc { .Type = D3D12_COMMAND_LIST_TYPE_DIRECT, .Flags = D3D12_COMMAND_QUEUE_FLAG_NONE, @@ -61,12 +61,12 @@ public: &queue_desc, IID_PPV_ARGS(&m_command_queue))); + // The command allocator is the memory backing for the command list. + // It is in the allocator's memory where the commands are stored. ThrowIfFailed(m_device->CreateCommandAllocator( queue_desc.Type, IID_PPV_ARGS(&m_command_allocator))); - // The command allocator is the memory backing for the command list. - // It is in the allocator's memory where the commands are stored. ThrowIfFailed(m_device->CreateCommandList( /*nodeMask=*/0, queue_desc.Type, @@ -105,7 +105,7 @@ public: { PopulateCommandList(); - ID3D12CommandList* command_lists[] = { m_command_list.Get() }; + ID3D12CommandList* command_lists[] { m_command_list.Get() }; m_command_queue->ExecuteCommandLists( _countof(command_lists), command_lists); @@ -150,20 +150,20 @@ private: m_command_list->ResourceBarrier(1, &render_barrier); // Record commands. - const float clear_colour[] = { 0.0f, 0.502f, 0.494f, 0.0f }; + const float clear_colour[] { 0.0f, 0.502f, 0.494f, 0.0f }; m_command_list->ClearRenderTargetView( GetCurrentBackBufferView(), clear_colour, - 0, // Number of rectangles in the following array. - nullptr); // No rectangles; clear the entire resource. + 0, // Number of rectangles in the following array. + nullptr); // No rectangles; clear the entire resource. m_command_list->ClearDepthStencilView( GetDepthStencilView(), D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, - 1.0f, // Depth. - 0, // Stencil. - 0, // Number of rectangles in the following array. - nullptr); // No rectangles; clear the entire resource view. + 1.0f, // Depth. + 0, // Stencil. + 0, // Number of rectangles in the following array. + nullptr); // No rectangles; clear the entire resource view. // Indicate that we now intend to use the back buffer to present. const auto present_barrier = CD3DX12_RESOURCE_BARRIER::Transition( @@ -211,7 +211,7 @@ private: // The RTV heap must hold as many descriptors as we have buffers in the // swap chain. - const D3D12_DESCRIPTOR_HEAP_DESC rtv_heap_desc = + const D3D12_DESCRIPTOR_HEAP_DESC rtv_heap_desc { .Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV, .NumDescriptors = SWAP_CHAIN_BUFFER_COUNT, @@ -222,7 +222,7 @@ private: &rtv_heap_desc, IID_PPV_ARGS(&m_rtv_heap))); // For the depth/stencil buffer, we just need one view. - const D3D12_DESCRIPTOR_HEAP_DESC dsv_heap_desc = + const D3D12_DESCRIPTOR_HEAP_DESC dsv_heap_desc { .Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV, .NumDescriptors = 1, @@ -243,19 +243,19 @@ private: SafeRelease(m_swap_chain); - DXGI_SWAP_CHAIN_DESC1 desc = + DXGI_SWAP_CHAIN_DESC1 desc { .Width = static_cast(m_settings.width), .Height = static_cast(m_settings.height), .Format = DXGI_FORMAT_R8G8B8A8_UNORM, .SampleDesc = DXGI_SAMPLE_DESC { - .Count = 1, + .Count = 1, .Quality = 0, }, .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, .BufferCount = SWAP_CHAIN_BUFFER_COUNT, - .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, }; ComPtr swap_chain; ThrowIfFailed(m_dxgi_factory->CreateSwapChainForHwnd( @@ -295,29 +295,29 @@ private: { assert(m_device); - const D3D12_RESOURCE_DESC depth_stencil_desc = + const D3D12_RESOURCE_DESC depth_stencil_desc { - .Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D, - .Alignment = 0, - .Width = static_cast(m_settings.width), - .Height = static_cast(m_settings.height), + .Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D, + .Alignment = 0, + .Width = static_cast(m_settings.width), + .Height = static_cast(m_settings.height), .DepthOrArraySize = 1, - .MipLevels = 1, - .Format = DXGI_FORMAT_D24_UNORM_S8_UINT, - .SampleDesc = DXGI_SAMPLE_DESC + .MipLevels = 1, + .Format = DXGI_FORMAT_D24_UNORM_S8_UINT, + .SampleDesc = DXGI_SAMPLE_DESC { - .Count = 1, + .Count = 1, .Quality = 0, }, .Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - .Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, + .Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, }; - const D3D12_CLEAR_VALUE opt_clear_value = + const D3D12_CLEAR_VALUE opt_clear_value { - .Format = depth_stencil_desc.Format, + .Format = depth_stencil_desc.Format, .DepthStencil = D3D12_DEPTH_STENCIL_VALUE { - .Depth = 1.0f, + .Depth = 1.0f, .Stencil = 0, }, }; @@ -395,7 +395,7 @@ int main() const D3DSettings settings = { // TODO: use 960x600 or 1920x1200 depending on native resolution. - .width = 1920, + .width = 1920, .height = 1200, }; -- cgit v1.2.3