| 156 | } |
| 157 | |
| 158 | void SwapChain::Reset() |
| 159 | { |
| 160 | Assert_(swapChain); |
| 161 | |
| 162 | // Release all references |
| 163 | for(uint64 i = 0; i < NumBackBuffers; ++i) |
| 164 | { |
| 165 | DX12::Release(backBuffers[i].Texture.Resource); |
| 166 | DX12::RTVDescriptorHeap.Free(backBuffers[i].RTV); |
| 167 | } |
| 168 | |
| 169 | if(format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) |
| 170 | noSRGBFormat = DXGI_FORMAT_R8G8B8A8_UNORM; |
| 171 | else if(format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB) |
| 172 | noSRGBFormat = DXGI_FORMAT_B8G8R8A8_UNORM; |
| 173 | else |
| 174 | noSRGBFormat = format; |
| 175 | |
| 176 | if(fullScreen) |
| 177 | PrepareFullScreenSettings(); |
| 178 | else |
| 179 | { |
| 180 | refreshRate.Numerator = 60; |
| 181 | refreshRate.Denominator = 1; |
| 182 | } |
| 183 | |
| 184 | DXCall(swapChain->SetFullscreenState(fullScreen, NULL)); |
| 185 | |
| 186 | DXCall(swapChain->ResizeBuffers(NumBackBuffers, width, height, |
| 187 | noSRGBFormat, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)); |
| 188 | |
| 189 | if(fullScreen) |
| 190 | { |
| 191 | DXGI_MODE_DESC mode; |
| 192 | mode.Format = noSRGBFormat; |
| 193 | mode.Width = width; |
| 194 | mode.Height = height; |
| 195 | mode.RefreshRate.Numerator = 0; |
| 196 | mode.RefreshRate.Denominator = 0; |
| 197 | mode.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; |
| 198 | mode.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; |
| 199 | DXCall(swapChain->ResizeTarget(&mode)); |
| 200 | } |
| 201 | |
| 202 | AfterReset(); |
| 203 | } |
| 204 | |
| 205 | void SwapChain::BeginFrame() |
| 206 | { |
no test coverage detected