1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-22 23:52:10 +01:00
dxvk/src/d3d11/d3d11_present.cpp

79 lines
2.6 KiB
C++
Raw Normal View History

#include "d3d11_device.h"
#include "d3d11_context_imm.h"
#include "d3d11_present.h"
namespace dxvk {
2018-03-28 19:06:00 +02:00
HRESULT STDMETHODCALLTYPE D3D11VkBackBuffer::QueryInterface(REFIID riid, void** ppvObject) {
2017-12-19 16:01:50 +01:00
return m_texture->QueryInterface(riid, ppvObject);
}
2018-03-28 19:06:00 +02:00
Rc<DxvkImage> D3D11VkBackBuffer::GetDXVKImage() {
return m_texture->GetCommonTexture()->GetImage();
2017-12-19 16:01:50 +01:00
}
D3D11PresentDevice:: D3D11PresentDevice() { }
D3D11PresentDevice::~D3D11PresentDevice() { }
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::QueryInterface(
REFIID riid,
void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
2018-03-28 19:06:00 +02:00
COM_QUERY_IFACE(riid, ppvObject, IDXGIVkPresenter);
return m_device->QueryInterface(riid, ppvObject);
}
2017-12-19 16:01:50 +01:00
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::CreateSwapChainBackBuffer(
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
2018-03-28 19:06:00 +02:00
IDXGIVkBackBuffer** ppInterface) {
D3D11_COMMON_TEXTURE_DESC desc;
desc.Width = pSwapChainDesc->BufferDesc.Width;
desc.Height = pSwapChainDesc->BufferDesc.Height;
desc.Depth = 1;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = pSwapChainDesc->BufferDesc.Format;
desc.SampleDesc = pSwapChainDesc->SampleDesc;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_RENDER_TARGET
| D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
if (pSwapChainDesc->BufferUsage & DXGI_USAGE_UNORDERED_ACCESS)
desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
2017-12-19 16:01:50 +01:00
try {
2018-03-28 19:06:00 +02:00
*ppInterface = ref(new D3D11VkBackBuffer(
2017-12-19 16:01:50 +01:00
new D3D11Texture2D(m_device, &desc)));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
return E_FAIL;
}
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::FlushRenderingCommands() {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
// The presentation code is run from the main rendering thread
// rather than the command stream thread, so we synchronize.
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
immediateContext->Flush();
immediateContext->SynchronizeCsThread();
return S_OK;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::GetDevice(REFGUID riid, void** ppvDevice) {
return m_device->QueryInterface(riid, ppvDevice);
}
}