| 54 | } |
| 55 | |
| 56 | void 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 | |
| 91 | void SwapChain::Shutdown() |
| 92 | { |