MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / Initialize

Method Initialize

SampleFramework12/v1.00/Graphics/SwapChain.cpp:56–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void SwapChain::Initialize(HWND outputWindow)
57{
58 Shutdown();
59
60 // We'll just use the first output for fullscreen
61 DXCall(DX12::Adapter->EnumOutputs(0, &output));
62
63 if(format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
64 noSRGBFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
65 else if(format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB)
66 noSRGBFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
67 else
68 noSRGBFormat = format;
69
70 DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
71 swapChainDesc.BufferCount = uint32(NumBackBuffers);
72 swapChainDesc.BufferDesc.Width = width;
73 swapChainDesc.BufferDesc.Height = height;
74 swapChainDesc.BufferDesc.Format = noSRGBFormat;
75 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
76 swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
77 swapChainDesc.OutputWindow = outputWindow;
78 swapChainDesc.SampleDesc.Count = 1;
79 swapChainDesc.Windowed = TRUE;
80
81 IDXGISwapChain* tempSwapChain = nullptr;
82 DXCall(DX12::Factory->CreateSwapChain(DX12::GfxQueue, &swapChainDesc, &tempSwapChain));
83 DXCall(tempSwapChain->QueryInterface(IID_PPV_ARGS(&swapChain)));
84 DX12::Release(tempSwapChain);
85
86 backBufferIdx = swapChain->GetCurrentBackBufferIndex();
87
88 AfterReset();
89}
90
91void SwapChain::Shutdown()
92{

Callers

nothing calls this directly

Calls 3

DXCallFunction · 0.85
ReleaseFunction · 0.85
ShutdownFunction · 0.70

Tested by

no test coverage detected