| 382 | } |
| 383 | |
| 384 | HRESULT |
| 385 | DeviceManager::ChangeBackBufferFormat(DXGI_FORMAT format, UINT sampleCount) |
| 386 | { |
| 387 | HRESULT hr = E_FAIL; |
| 388 | |
| 389 | if((format == DXGI_FORMAT_UNKNOWN || format == m_SwapChainDesc.BufferDesc.Format) && |
| 390 | (sampleCount == 0 || sampleCount == m_SwapChainDesc.SampleDesc.Count)) |
| 391 | return S_FALSE; |
| 392 | |
| 393 | if(m_Device) |
| 394 | { |
| 395 | bool fullscreen = (GetWindowState() == kWindowFullscreen); |
| 396 | if(fullscreen) |
| 397 | m_SwapChain->SetFullscreenState(false, NULL); |
| 398 | |
| 399 | IDXGISwapChain* newSwapChain = NULL; |
| 400 | DXGI_SWAP_CHAIN_DESC newSwapChainDesc = m_SwapChainDesc; |
| 401 | |
| 402 | if(format != DXGI_FORMAT_UNKNOWN) |
| 403 | newSwapChainDesc.BufferDesc.Format = format; |
| 404 | if(sampleCount != 0) |
| 405 | newSwapChainDesc.SampleDesc.Count = sampleCount; |
| 406 | |
| 407 | IDXGIAdapter* pDXGIAdapter = GetDXGIAdapter(); |
| 408 | |
| 409 | IDXGIFactory* pDXGIFactory = NULL; |
| 410 | pDXGIAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pDXGIFactory)); |
| 411 | |
| 412 | hr = pDXGIFactory->CreateSwapChain(m_Device, &newSwapChainDesc, &newSwapChain); |
| 413 | |
| 414 | pDXGIFactory->Release(); |
| 415 | pDXGIAdapter->Release(); |
| 416 | |
| 417 | if (FAILED(hr)) |
| 418 | { |
| 419 | if(fullscreen) |
| 420 | m_SwapChain->SetFullscreenState(true, NULL); |
| 421 | |
| 422 | return hr; |
| 423 | } |
| 424 | |
| 425 | SAFE_RELEASE(m_BackBufferRTV); |
| 426 | SAFE_RELEASE(m_SwapChain); |
| 427 | SAFE_RELEASE(m_DepthStencilBuffer); |
| 428 | SAFE_RELEASE(m_DepthStencilDSV); |
| 429 | |
| 430 | m_SwapChain = newSwapChain; |
| 431 | m_SwapChainDesc = newSwapChainDesc; |
| 432 | |
| 433 | m_DepthStencilDesc.SampleDesc.Count = sampleCount; |
| 434 | |
| 435 | if(fullscreen) |
| 436 | m_SwapChain->SetFullscreenState(true, NULL); |
| 437 | |
| 438 | CreateRenderTargetAndDepthStencil(); |
| 439 | BackBufferResized(); |
| 440 | } |
| 441 |
nothing calls this directly
no test coverage detected