1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d11] D3D11Presenter -> D3D11PresentDevice

This commit is contained in:
Philip Rebohle 2018-10-23 15:10:01 +02:00
parent 83b51a66ac
commit 7b9726fd93
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
9 changed files with 25 additions and 158 deletions

View File

@ -67,7 +67,7 @@ namespace dxvk {
return S_OK;
}
if (riid == __uuidof(IDXGIVkPresenter)) {
if (riid == __uuidof(IDXGIVkPresentDevice)) {
*ppvObject = ref(m_d3d11Presenter);
return S_OK;
}

View File

@ -31,7 +31,7 @@ namespace dxvk {
class D3D11DeviceContext;
class D3D11ImmediateContext;
class D3D11Predicate;
class D3D11Presenter;
class D3D11PresentDevice;
class D3D11Query;
class D3D11Texture1D;
class D3D11Texture2D;
@ -59,10 +59,10 @@ namespace dxvk {
REFIID riid,
void** ppParent);
IDXGIVkDevice* m_dxgiDevice = nullptr;
D3D11Device* m_d3d11Device = nullptr;
D3D11Presenter* m_d3d11Presenter = nullptr;
D3D11VkInterop* m_d3d11VkInterop = nullptr;
IDXGIVkDevice* m_dxgiDevice = nullptr;
D3D11Device* m_d3d11Device = nullptr;
D3D11PresentDevice* m_d3d11Presenter = nullptr;
D3D11VkInterop* m_d3d11VkInterop = nullptr;
};

View File

@ -79,7 +79,7 @@ extern "C" {
container->m_d3d11Device = new D3D11Device(
container.ptr(), container->m_dxgiDevice, fl, Flags);
container->m_d3d11Presenter = new D3D11Presenter(
container->m_d3d11Presenter = new D3D11PresentDevice(
container.ptr(), container->m_d3d11Device);
container->m_d3d11VkInterop = new D3D11VkInterop(
container.ptr(), container->m_d3d11Device);

View File

@ -1,31 +1,9 @@
#include "d3d11_device.h"
#include "d3d11_context_imm.h"
#include "d3d11_present.h"
namespace dxvk {
D3D11VkBackBuffer::D3D11VkBackBuffer(D3D11Texture2D* pTexture)
: m_texture(pTexture) {
m_texture->AddRefPrivate();
}
D3D11VkBackBuffer::~D3D11VkBackBuffer() {
m_texture->ReleasePrivate();
}
HRESULT STDMETHODCALLTYPE D3D11VkBackBuffer::QueryInterface(REFIID riid, void** ppvObject) {
return m_texture->QueryInterface(riid, ppvObject);
}
Rc<DxvkImage> D3D11VkBackBuffer::GetDXVKImage() {
return m_texture->GetCommonTexture()->GetImage();
}
D3D11Presenter:: D3D11Presenter(
D3D11PresentDevice::D3D11PresentDevice(
IDXGIObject* pContainer,
ID3D11Device* pDevice)
: m_container(pContainer), m_device(pDevice) {
@ -33,76 +11,27 @@ namespace dxvk {
}
D3D11Presenter::~D3D11Presenter() {
D3D11PresentDevice::~D3D11PresentDevice() {
}
ULONG STDMETHODCALLTYPE D3D11Presenter::AddRef() {
ULONG STDMETHODCALLTYPE D3D11PresentDevice::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11Presenter::Release() {
ULONG STDMETHODCALLTYPE D3D11PresentDevice::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::QueryInterface(REFIID riid, void** ppvObject) {
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::QueryInterface(REFIID riid, void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::CreateSwapChainBackBuffer(
const DXGI_SWAP_CHAIN_DESC1* pSwapChainDesc,
IDXGIVkBackBuffer** ppInterface) {
D3D11_COMMON_TEXTURE_DESC desc;
desc.Width = std::max(pSwapChainDesc->Width, 1u);
desc.Height = std::max(pSwapChainDesc->Height, 1u);
desc.Depth = 1;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = pSwapChainDesc->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;
try {
*ppInterface = ref(new D3D11VkBackBuffer(
new D3D11Texture2D(static_cast<D3D11Device*>(m_device), &desc)));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
return E_FAIL;
}
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::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;
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::GetDevice(REFGUID riid, void** ppvDevice) {
return m_device->QueryInterface(riid, ppvDevice);
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::CreateSwapChainForHwnd(
HRESULT STDMETHODCALLTYPE D3D11PresentDevice::CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
IDXGIVkSwapChain** ppSwapChain) {

View File

@ -5,46 +5,25 @@
#include "d3d11_include.h"
#include "d3d11_swapchain.h"
#include "d3d11_texture.h"
namespace dxvk {
class D3D11Device;
class D3D11VkBackBuffer : public ComObject<IDXGIVkBackBuffer> {
public:
D3D11VkBackBuffer(D3D11Texture2D* pTexture);
~D3D11VkBackBuffer();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
Rc<DxvkImage> GetDXVKImage() final;
public:
D3D11Texture2D* m_texture;
};
/**
* \brief Present device
*
* Wires up some swap chain related
* functions to the D3D11 device.
*/
class D3D11Presenter final : public IDXGIVkPresenter {
class D3D11PresentDevice final : public IDXGIVkPresentDevice {
public:
D3D11Presenter(
D3D11PresentDevice(
IDXGIObject* pContainer,
ID3D11Device* pDevice);
~D3D11Presenter();
~D3D11PresentDevice();
ULONG STDMETHODCALLTYPE AddRef();
@ -54,16 +33,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE CreateSwapChainBackBuffer(
const DXGI_SWAP_CHAIN_DESC1* pSwapChainDesc,
IDXGIVkBackBuffer** ppInterface);
HRESULT STDMETHODCALLTYPE FlushRenderingCommands();
HRESULT STDMETHODCALLTYPE GetDevice(
REFGUID riid,
void** ppvDevice);
HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,

View File

@ -150,41 +150,9 @@ IDXGIVkBackBuffer : public IUnknown {
* back buffer interface.
*/
MIDL_INTERFACE("79352328-16f2-4f81-9746-9c2e2ccd43cf")
IDXGIVkPresenter : public IUnknown {
IDXGIVkPresentDevice : public IUnknown {
static const GUID guid;
/**
* \brief Creates a swap chain back buffer
*
* \param [in] pSwapChainDesc Swap chain description
* \param [out] ppBackBuffer The swap chain back buffer
* \returns \c S_OK on success
*/
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainBackBuffer(
const DXGI_SWAP_CHAIN_DESC1* pSwapChainDesc,
IDXGIVkBackBuffer** ppBackBuffer) = 0;
/**
* \brief Flushes the immediate context
*
* Used by the swap chain's \c Present method to
* ensure that all rendering commands get dispatched
* before presenting the swap chain's back buffer.
* \returns \c S_OK on success
*/
virtual HRESULT STDMETHODCALLTYPE FlushRenderingCommands() = 0;
/**
* \brief Underlying DXVK device
*
* \param [in] riid Device type
* \param [in] ppDevice device
* \returns DXVK device handle
*/
virtual HRESULT STDMETHODCALLTYPE GetDevice(
REFGUID riid,
void** ppDevice) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
@ -337,7 +305,7 @@ IDXGIVkInteropDevice : public IUnknown {
struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIVkAdapter;
struct __declspec(uuid("7a622cf6-627a-46b2-b52f-360ef3da831c")) IDXGIVkDevice;
struct __declspec(uuid("5679becd-8547-4d93-96a1-e61a1ce7ef37")) IDXGIVkBackBuffer;
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresenter;
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresentDevice;
struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice;
struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface;
struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain;
@ -345,7 +313,7 @@ struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain
DXVK_DEFINE_GUID(IDXGIVkAdapter);
DXVK_DEFINE_GUID(IDXGIVkDevice);
DXVK_DEFINE_GUID(IDXGIVkBackBuffer);
DXVK_DEFINE_GUID(IDXGIVkPresenter);
DXVK_DEFINE_GUID(IDXGIVkPresentDevice);
DXVK_DEFINE_GUID(IDXGIVkInteropDevice);
DXVK_DEFINE_GUID(IDXGIVkInteropSurface);
DXVK_DEFINE_GUID(IDXGIVkSwapChain);

View File

@ -16,10 +16,12 @@ namespace dxvk {
m_desc (*pDesc),
m_descFs (*pFullscreenDesc),
m_monitor (nullptr) {
Com<IDXGIVkPresentDevice> presentDevice;
// Retrieve a device pointer that allows us to
// communicate with the underlying D3D device
if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIVkPresenter),
reinterpret_cast<void**>(&m_presentDevice))))
if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIVkPresentDevice),
reinterpret_cast<void**>(&presentDevice))))
throw DxvkError("DXGI: DxgiSwapChain: Invalid device");
// Retrieve the adapter, which is going
@ -54,7 +56,7 @@ namespace dxvk {
if (!m_descFs.Windowed && FAILED(EnterFullscreenMode(nullptr)))
throw DxvkError("DXGI: DxgiSwapChain: Failed to set initial fullscreen state");
if (FAILED(m_presentDevice->CreateSwapChainForHwnd(m_window, &m_desc, &m_presenter)))
if (FAILED(presentDevice->CreateSwapChainForHwnd(m_window, &m_desc, &m_presenter)))
throw DxvkError("DXGI: DxgiSwapChain: Failed to create presenter");
}

View File

@ -137,7 +137,6 @@ namespace dxvk {
Com<DxgiFactory> m_factory;
Com<DxgiAdapter> m_adapter;
Com<DxgiDevice> m_device;
Com<IDXGIVkPresenter> m_presentDevice;
HWND m_window;
DXGI_SWAP_CHAIN_DESC1 m_desc;

View File

@ -7,7 +7,7 @@
const GUID IDXGIVkAdapter::guid = {0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff}};
const GUID IDXGIVkDevice::guid = {0x7a622cf6,0x627a,0x46b2,{0xb5,0x2f,0x36,0x0e,0xf3,0xda,0x83,0x1c}};
const GUID IDXGIVkBackBuffer::guid = {0x5679becd,0x8547,0x4d93,{0x96,0xa1,0xe6,0x1a,0x1c,0xe7,0xef,0x37}};
const GUID IDXGIVkPresenter::guid = {0x79352328,0x16f2,0x4f81,{0x97,0x46,0x9c,0x2e,0x2c,0xcd,0x43,0xcf}};
const GUID IDXGIVkPresentDevice::guid = {0x79352328,0x16f2,0x4f81,{0x97,0x46,0x9c,0x2e,0x2c,0xcd,0x43,0xcf}};
const GUID IDXGIVkInteropDevice::guid = {0xe2ef5fa5,0xdc21,0x4af7,{0x90,0xc4,0xf6,0x7e,0xf6,0xa0,0x93,0x23}};
const GUID IDXGIVkInteropSurface::guid = {0x5546cf8c,0x77e7,0x4341,{0xb0,0x5d,0x8d,0x4d,0x50,0x00,0xe7,0x7d}};
const GUID IDXGIVkSwapChain::guid = {0x104001a6,0x7f36,0x4957,{0xb9,0x32,0x86,0xad,0xe9,0x56,0x7d,0x91}};