mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-16 19:19:13 +01:00
9316e25652
It appears that some older drivers do not support CreateSwapChainForHwnd, resulting in DXGI_ERROR_INVALID_CALL. For these cases, fall back to the base CreateSwapChain() from DXGI 1.0. In theory this should also let us run on Win7 without the platform update, but in reality we require the newer shader compiler so this probably won't work regardless. Also any hardware of this vintage is unlikely to run Dolphin well.
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
// Copyright 2019 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#include "VideoBackends/D3D/SwapChain.h"
|
|
#include "VideoBackends/D3D/DXTexture.h"
|
|
|
|
namespace DX11
|
|
{
|
|
SwapChain::SwapChain(const WindowSystemInfo& wsi, IDXGIFactory* dxgi_factory,
|
|
ID3D11Device* d3d_device)
|
|
: D3DCommon::SwapChain(wsi, dxgi_factory, d3d_device)
|
|
{
|
|
}
|
|
|
|
SwapChain::~SwapChain() = default;
|
|
|
|
std::unique_ptr<SwapChain> SwapChain::Create(const WindowSystemInfo& wsi)
|
|
{
|
|
std::unique_ptr<SwapChain> swap_chain =
|
|
std::make_unique<SwapChain>(wsi, D3D::dxgi_factory.Get(), D3D::device.Get());
|
|
if (!swap_chain->CreateSwapChain(WantsStereo()))
|
|
return nullptr;
|
|
|
|
return swap_chain;
|
|
}
|
|
|
|
bool SwapChain::CreateSwapChainBuffers()
|
|
{
|
|
ComPtr<ID3D11Texture2D> texture;
|
|
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(&texture));
|
|
CHECK(SUCCEEDED(hr), "Get swap chain buffer");
|
|
if (FAILED(hr))
|
|
return false;
|
|
|
|
m_texture = DXTexture::CreateAdopted(texture.Get());
|
|
if (!m_texture)
|
|
return false;
|
|
|
|
m_framebuffer = DXFramebuffer::Create(m_texture.get(), nullptr);
|
|
if (!m_framebuffer)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void SwapChain::DestroySwapChainBuffers()
|
|
{
|
|
m_framebuffer.reset();
|
|
m_texture.reset();
|
|
}
|
|
} // namespace DX11
|