1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxgi] Refactored swap chain <-> device communication

This commit is contained in:
Philip Rebohle 2017-11-29 16:23:33 +01:00
parent 33dc4583fb
commit b35f0c64b4
13 changed files with 214 additions and 220 deletions

View File

@ -4,10 +4,12 @@
namespace dxvk { namespace dxvk {
D3D11Buffer::D3D11Buffer( D3D11Buffer::D3D11Buffer(
D3D11Device* device, D3D11Device* device,
const D3D11_BUFFER_DESC& desc) IDXGIImageResourcePrivate* resource,
: m_device(device), m_desc(desc), const D3D11_BUFFER_DESC& desc)
m_buffer(this->createBuffer()) { : m_device (device),
m_resource(resource),
m_desc (desc) {
} }
@ -23,6 +25,10 @@ namespace dxvk {
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource); COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Buffer); COM_QUERY_IFACE(riid, ppvObject, ID3D11Buffer);
if (riid == __uuidof(IDXGIResource)
|| riid == __uuidof(IDXGIBufferResourcePrivate))
return m_resource->QueryInterface(riid, ppvObject);
Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query"); Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query");
return E_NOINTERFACE; return E_NOINTERFACE;
} }
@ -42,93 +48,4 @@ namespace dxvk {
*pDesc = m_desc; *pDesc = m_desc;
} }
Rc<DxvkBuffer> D3D11Buffer::createBuffer() {
VkMemoryPropertyFlags memoryType = 0;
DxvkBufferCreateInfo info;
info.size = m_desc.ByteWidth;
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT;
info.access = VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_TRANSFER_READ_BIT;
switch (m_desc.Usage) {
case D3D11_USAGE_DEFAULT:
case D3D11_USAGE_IMMUTABLE:
memoryType |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
break;
case D3D11_USAGE_DYNAMIC:
memoryType |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
break;
case D3D11_USAGE_STAGING:
memoryType |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
break;
}
if (m_desc.BindFlags & D3D11_BIND_VERTEX_BUFFER) {
info.usage |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
info.access |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
}
if (m_desc.BindFlags & D3D11_BIND_INDEX_BUFFER) {
info.usage |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
info.access |= VK_ACCESS_INDEX_READ_BIT;
}
if (m_desc.BindFlags & (D3D11_BIND_CONSTANT_BUFFER & D3D11_BIND_SHADER_RESOURCE)) {
info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
| VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
| VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
| VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
info.access |= VK_ACCESS_SHADER_READ_BIT;
}
if (m_desc.BindFlags & D3D11_BIND_STREAM_OUTPUT) {
info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT
| VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
info.access |= VK_ACCESS_SHADER_WRITE_BIT;
}
if (m_desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) {
info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT
| VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
| VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
info.access |= VK_ACCESS_SHADER_READ_BIT
| VK_ACCESS_SHADER_WRITE_BIT;
}
if (m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) {
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
info.access |= VK_ACCESS_HOST_WRITE_BIT;
}
if (m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ) {
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
info.access |= VK_ACCESS_HOST_READ_BIT;
}
if (m_desc.MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) {
info.usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
info.access |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
}
return m_device->GetDXVKDevice()->createBuffer(info, memoryType);
}
} }

View File

@ -3,6 +3,7 @@
#include <dxvk_device.h> #include <dxvk_device.h>
#include "d3d11_device_child.h" #include "d3d11_device_child.h"
#include "d3d11_interfaces.h"
namespace dxvk { namespace dxvk {
@ -14,8 +15,9 @@ namespace dxvk {
public: public:
D3D11Buffer( D3D11Buffer(
D3D11Device* device, D3D11Device* device,
const D3D11_BUFFER_DESC& desc); IDXGIImageResourcePrivate* resource,
const D3D11_BUFFER_DESC& desc);
~D3D11Buffer(); ~D3D11Buffer();
HRESULT QueryInterface( HRESULT QueryInterface(
@ -33,12 +35,9 @@ namespace dxvk {
private: private:
Com<D3D11Device> m_device; Com<D3D11Device> m_device;
Com<IDXGIImageResourcePrivate> m_resource;
D3D11_BUFFER_DESC m_desc; D3D11_BUFFER_DESC m_desc;
Rc<DxvkBuffer> m_buffer;
Rc<DxvkBuffer> createBuffer();
}; };

View File

@ -3,6 +3,7 @@
#include "d3d11_buffer.h" #include "d3d11_buffer.h"
#include "d3d11_context.h" #include "d3d11_context.h"
#include "d3d11_device.h" #include "d3d11_device.h"
#include "d3d11_present.h"
#include "d3d11_texture.h" #include "d3d11_texture.h"
#include "d3d11_view.h" #include "d3d11_view.h"
@ -12,17 +13,21 @@ namespace dxvk {
IDXGIDevicePrivate* dxgiDevice, IDXGIDevicePrivate* dxgiDevice,
D3D_FEATURE_LEVEL featureLevel, D3D_FEATURE_LEVEL featureLevel,
UINT featureFlags) UINT featureFlags)
: m_dxgiDevice (dxgiDevice), : m_dxgiDevice (dxgiDevice),
m_featureLevel(featureLevel), m_presentDevice (ref(new D3D11PresentDevice())),
m_featureFlags(featureFlags), m_featureLevel (featureLevel),
m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()), m_featureFlags (featureFlags),
m_dxvkAdapter (m_dxvkDevice->adapter()) { m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()),
m_dxvkAdapter (m_dxvkDevice->adapter()) {
m_dxgiDevice->SetDeviceLayer(this); m_dxgiDevice->SetDeviceLayer(this);
m_presentDevice->SetDeviceLayer(this);
m_context = new D3D11DeviceContext(this, m_dxvkDevice); m_context = new D3D11DeviceContext(this, m_dxvkDevice);
} }
D3D11Device::~D3D11Device() { D3D11Device::~D3D11Device() {
m_presentDevice->SetDeviceLayer(nullptr);
m_dxgiDevice->SetDeviceLayer(nullptr); m_dxgiDevice->SetDeviceLayer(nullptr);
} }
@ -30,12 +35,14 @@ namespace dxvk {
HRESULT D3D11Device::QueryInterface(REFIID riid, void** ppvObject) { HRESULT D3D11Device::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown); COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Device); COM_QUERY_IFACE(riid, ppvObject, ID3D11Device);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DevicePrivate);
if (riid == __uuidof(IDXGIDevice) if (riid == __uuidof(IDXGIDevice)
|| riid == __uuidof(IDXGIDevicePrivate)) || riid == __uuidof(IDXGIDevicePrivate))
return m_dxgiDevice->QueryInterface(riid, ppvObject); return m_dxgiDevice->QueryInterface(riid, ppvObject);
if (riid == __uuidof(IDXGIPresentDevicePrivate))
return m_presentDevice->QueryInterface(riid, ppvObject);
Logger::warn("D3D11Device::QueryInterface: Unknown interface query"); Logger::warn("D3D11Device::QueryInterface: Unknown interface query");
return E_NOINTERFACE; return E_NOINTERFACE;
} }
@ -390,39 +397,6 @@ namespace dxvk {
} }
HRESULT D3D11Device::WrapSwapChainBackBuffer(
IDXGIImageResourcePrivate* pResource,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) {
D3D11_TEXTURE2D_DESC desc;
desc.Width = pSwapChainDesc->BufferDesc.Width;
desc.Height = pSwapChainDesc->BufferDesc.Height;
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;
*ppInterface = ref(new D3D11Texture2D(this, pResource, desc));
return S_OK;
}
HRESULT D3D11Device::FlushRenderingCommands() {
m_context->Flush();
return S_OK;
}
Rc<DxvkDevice> D3D11Device::GetDXVKDevice() {
return m_dxvkDevice;
}
bool D3D11Device::CheckFeatureLevelSupport( bool D3D11Device::CheckFeatureLevelSupport(
D3D_FEATURE_LEVEL featureLevel) { D3D_FEATURE_LEVEL featureLevel) {
return featureLevel <= D3D_FEATURE_LEVEL_11_0; return featureLevel <= D3D_FEATURE_LEVEL_11_0;

View File

@ -11,8 +11,9 @@ namespace dxvk {
class DxgiAdapter; class DxgiAdapter;
class D3D11DeviceContext; class D3D11DeviceContext;
class D3D11PresentDevice;
class D3D11Device : public ComObject<ID3D11DevicePrivate> { class D3D11Device : public ComObject<ID3D11Device> {
public: public:
@ -215,14 +216,9 @@ namespace dxvk {
UINT GetExceptionMode() final; UINT GetExceptionMode() final;
HRESULT WrapSwapChainBackBuffer( Rc<DxvkDevice> GetDXVKDevice() {
IDXGIImageResourcePrivate* pResource, return m_dxvkDevice;
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, }
IUnknown** ppInterface) final;
HRESULT FlushRenderingCommands() final;
Rc<DxvkDevice> GetDXVKDevice() final;
static bool CheckFeatureLevelSupport( static bool CheckFeatureLevelSupport(
D3D_FEATURE_LEVEL featureLevel); D3D_FEATURE_LEVEL featureLevel);
@ -230,6 +226,8 @@ namespace dxvk {
private: private:
const Com<IDXGIDevicePrivate> m_dxgiDevice; const Com<IDXGIDevicePrivate> m_dxgiDevice;
const Com<D3D11PresentDevice> m_presentDevice;
const D3D_FEATURE_LEVEL m_featureLevel; const D3D_FEATURE_LEVEL m_featureLevel;
const UINT m_featureFlags; const UINT m_featureFlags;

View File

@ -6,48 +6,3 @@
#include "../dxvk/dxvk_device.h" #include "../dxvk/dxvk_device.h"
/**
* \brief Private device interface
*
* This interface is used by \ref DxgiSwapChain
* in order to communicate with the device.
*/
MIDL_INTERFACE("ab2a2a58-d2ac-4ca0-9ad9-a260cafa00c8")
ID3D11DevicePrivate : public ID3D11Device {
static const GUID guid;
/**
* \brief Wraps swap chain image into a texture interface
*
* Creates an interface to the back buffer image of a
* swap chain. This interface will be returned by the
* swap chain's \c GetBuffer method.
* \param [in] image Image to wrap
* \param [in] pSwapChainDesc Swap chain properties
* \param [in] ppInterface Target interface
* \returns \c S_OK on success
*/
virtual HRESULT WrapSwapChainBackBuffer(
IDXGIImageResourcePrivate* pResource,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) = 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 FlushRenderingCommands() = 0;
/**
* \brief Underlying DXVK device
* \returns DXVK device handle
*/
virtual dxvk::Rc<dxvk::DxvkDevice> GetDXVKDevice() = 0;
};
DXVK_DEFINE_GUID(ID3D11DevicePrivate);

View File

@ -0,0 +1,56 @@
#include "d3d11_device.h"
#include "d3d11_present.h"
#include "d3d11_texture.h"
namespace dxvk {
D3D11PresentDevice:: D3D11PresentDevice() { }
D3D11PresentDevice::~D3D11PresentDevice() { }
HRESULT D3D11PresentDevice::QueryInterface(
REFIID riid,
void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIPresentDevicePrivate);
return m_device->QueryInterface(riid, ppvObject);
}
HRESULT D3D11PresentDevice::WrapSwapChainBackBuffer(
IDXGIImageResourcePrivate* pResource,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) {
D3D11_TEXTURE2D_DESC desc;
desc.Width = pSwapChainDesc->BufferDesc.Width;
desc.Height = pSwapChainDesc->BufferDesc.Height;
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;
*ppInterface = ref(new D3D11Texture2D(
m_device, pResource, desc));
return S_OK;
}
HRESULT D3D11PresentDevice::FlushRenderingCommands() {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
deviceContext->Flush();
return S_OK;
}
HRESULT D3D11PresentDevice::GetDevice(REFGUID riid, void** ppvDevice) {
return m_device->QueryInterface(riid, ppvDevice);
}
}

46
src/d3d11/d3d11_present.h Normal file
View File

@ -0,0 +1,46 @@
#pragma once
#include <dxgi_device.h>
#include "d3d11_include.h"
#include "../dxgi/dxgi_interfaces.h"
#include "../dxgi/dxgi_resource.h"
namespace dxvk {
class D3D11Device;
class D3D11PresentDevice : public ComObject<IDXGIPresentDevicePrivate> {
public:
D3D11PresentDevice();
~D3D11PresentDevice();
HRESULT QueryInterface(
REFIID riid,
void** ppvObject) final;
HRESULT WrapSwapChainBackBuffer(
IDXGIImageResourcePrivate* pResource,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) final;
HRESULT FlushRenderingCommands() final;
HRESULT GetDevice(
REFGUID riid,
void** ppvDevice) final;
void SetDeviceLayer(D3D11Device* pDevice) {
m_device = pDevice;
}
private:
D3D11Device* m_device = nullptr;
};
}

View File

@ -21,6 +21,7 @@ namespace dxvk {
HRESULT D3D11Texture2D::QueryInterface(REFIID riid, void** ppvObject) { HRESULT D3D11Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown); COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource); COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2D); COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2D);

View File

@ -3,6 +3,7 @@ d3d11_src = [
'd3d11_context.cpp', 'd3d11_context.cpp',
'd3d11_device.cpp', 'd3d11_device.cpp',
'd3d11_main.cpp', 'd3d11_main.cpp',
'd3d11_present.cpp',
'd3d11_texture.cpp', 'd3d11_texture.cpp',
'd3d11_view.cpp', 'd3d11_view.cpp',
] ]

View File

@ -73,7 +73,58 @@ IDXGIImageResourcePrivate : public IDXGIResource {
}; };
/**
* \brief Private presentation device interface
*
* Allows a swap chain to communicate with the device
* in order to flush pending commands or create the
* back buffer interface.
*/
MIDL_INTERFACE("79352328-16f2-4f81-9746-9c2e2ccd43cf")
IDXGIPresentDevicePrivate : public IUnknown {
static const GUID guid;
/**
* \brief Wraps swap chain image into a texture interface
*
* Creates an interface to the back buffer image of a
* swap chain. This interface will be returned by the
* swap chain's \c GetBuffer method.
* \param [in] image Image to wrap
* \param [in] pSwapChainDesc Swap chain properties
* \param [in] ppInterface Target interface
* \returns \c S_OK on success
*/
virtual HRESULT WrapSwapChainBackBuffer(
IDXGIImageResourcePrivate* pResource,
const DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IUnknown** ppInterface) = 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 FlushRenderingCommands() = 0;
/**
* \brief Underlying DXVK device
*
* \param [in] riid Device type
* \param [in] ppDevice device
* \returns DXVK device handle
*/
virtual HRESULT GetDevice(
REFGUID riid,
void** ppDevice) = 0;
};
DXVK_DEFINE_GUID(IDXGIAdapterPrivate); DXVK_DEFINE_GUID(IDXGIAdapterPrivate);
DXVK_DEFINE_GUID(IDXGIDevicePrivate); DXVK_DEFINE_GUID(IDXGIDevicePrivate);
DXVK_DEFINE_GUID(IDXGIPresentDevicePrivate);
DXVK_DEFINE_GUID(IDXGIBufferResourcePrivate); DXVK_DEFINE_GUID(IDXGIBufferResourcePrivate);
DXVK_DEFINE_GUID(IDXGIImageResourcePrivate); DXVK_DEFINE_GUID(IDXGIImageResourcePrivate);

View File

@ -13,7 +13,7 @@ namespace dxvk {
// Retrieve a device pointer that allows us to // Retrieve a device pointer that allows us to
// communicate with the underlying D3D device // communicate with the underlying D3D device
if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIDevicePrivate), if (FAILED(pDevice->QueryInterface(__uuidof(IDXGIPresentDevicePrivate),
reinterpret_cast<void**>(&m_device)))) reinterpret_cast<void**>(&m_device))))
throw DxvkError("DxgiSwapChain::DxgiSwapChain: Invalid device"); throw DxvkError("DxgiSwapChain::DxgiSwapChain: Invalid device");
@ -52,7 +52,11 @@ namespace dxvk {
throw DxvkError("DxgiSwapChain::DxgiSwapChain: Failed to set initial fullscreen state"); throw DxvkError("DxgiSwapChain::DxgiSwapChain: Failed to set initial fullscreen state");
// TODO clean up here // TODO clean up here
Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice(); Com<IDXGIDevicePrivate> dxgiDevice;
m_device->GetDevice(__uuidof(IDXGIDevicePrivate),
reinterpret_cast<void**>(&dxgiDevice));
Rc<DxvkDevice> dxvkDevice = dxgiDevice->GetDXVKDevice();
Rc<DxvkAdapter> dxvkAdapter = dxvkDevice->adapter(); Rc<DxvkAdapter> dxvkAdapter = dxvkDevice->adapter();
m_context = dxvkDevice->createContext(); m_context = dxvkDevice->createContext();
@ -189,24 +193,20 @@ namespace dxvk {
HRESULT DxgiSwapChain::Present(UINT SyncInterval, UINT Flags) { HRESULT DxgiSwapChain::Present(UINT SyncInterval, UINT Flags) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
// TODO implement generic swap chain client interface // Query DXGI device to retrieve DXVK device
Com<ID3D11DevicePrivate> d3d11device; Com<IDXGIDevicePrivate> dxgiDevice;
if (FAILED(m_device->QueryInterface(__uuidof(ID3D11DevicePrivate), m_device->GetDevice(__uuidof(IDXGIDevicePrivate),
reinterpret_cast<void**>(&d3d11device)))) { reinterpret_cast<void**>(&dxgiDevice));
Logger::err("DxgiSwapChain::Present: Invalid swap chain client interface");
return E_INVALIDARG;
}
try { try {
// Submit pending rendering commands // Submit pending rendering commands
// before recording the present code. // before recording the present code.
d3d11device->FlushRenderingCommands(); m_device->FlushRenderingCommands();
// TODO implement sync interval // TODO implement sync interval
// TODO implement flags // TODO implement flags
auto dxvkDevice = dxgiDevice->GetDXVKDevice();
auto dxvkDevice = d3d11device->GetDXVKDevice();
auto framebuffer = m_swapchain->getFramebuffer(m_acquireSync); auto framebuffer = m_swapchain->getFramebuffer(m_acquireSync);
auto framebufferSize = framebuffer->size(); auto framebufferSize = framebuffer->size();
@ -359,14 +359,11 @@ namespace dxvk {
void DxgiSwapChain::createBackBuffer() { void DxgiSwapChain::createBackBuffer() {
// TODO select format based on DXGI format // TODO select format based on DXGI format
// TODO support proper multi-sampling // TODO support proper multi-sampling
const Rc<DxvkDevice> dxvkDevice = m_device->GetDXVKDevice(); Com<IDXGIDevicePrivate> dxgiDevice;
m_device->GetDevice(__uuidof(IDXGIDevicePrivate),
reinterpret_cast<void**>(&dxgiDevice));
// TODO implement generic swap chain client interface const Rc<DxvkDevice> dxvkDevice = dxgiDevice->GetDXVKDevice();
Com<ID3D11DevicePrivate> d3d11device;
if (FAILED(m_device->QueryInterface(__uuidof(ID3D11DevicePrivate),
reinterpret_cast<void**>(&d3d11device))))
throw DxvkError("DxgiSwapChain::Present: Invalid swap chain client interface");
// Create an image that can be rendered to // Create an image that can be rendered to
// and that can be used as a sampled texture. // and that can be used as a sampled texture.
@ -399,7 +396,7 @@ namespace dxvk {
| VK_ACCESS_SHADER_READ_BIT; | VK_ACCESS_SHADER_READ_BIT;
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
if (FAILED(DXGICreateImageResourcePrivate(m_device.ptr(), &imageInfo, if (FAILED(DXGICreateImageResourcePrivate(dxgiDevice.ptr(), &imageInfo,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DXGI_USAGE_BACK_BUFFER | m_desc.BufferUsage, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DXGI_USAGE_BACK_BUFFER | m_desc.BufferUsage,
&resource))) &resource)))
throw DxvkError("DxgiSwapChain::createBackBuffer: Failed to create back buffer"); throw DxvkError("DxgiSwapChain::createBackBuffer: Failed to create back buffer");
@ -421,7 +418,7 @@ namespace dxvk {
// Wrap the back buffer image into an interface // Wrap the back buffer image into an interface
// that the device can use to access the image. // that the device can use to access the image.
if (FAILED(d3d11device->WrapSwapChainBackBuffer(resource.ptr(), &m_desc, &m_backBufferIface))) if (FAILED(m_device->WrapSwapChainBackBuffer(resource.ptr(), &m_desc, &m_backBufferIface)))
throw DxvkError("DxgiSwapChain::createBackBuffer: Failed to create back buffer interface"); throw DxvkError("DxgiSwapChain::createBackBuffer: Failed to create back buffer interface");
} }

View File

@ -80,9 +80,9 @@ namespace dxvk {
std::mutex m_mutex; std::mutex m_mutex;
Com<DxgiFactory> m_factory; Com<DxgiFactory> m_factory;
Com<IDXGIAdapter> m_adapter; Com<IDXGIAdapter> m_adapter;
Com<IDXGIDevicePrivate> m_device; Com<IDXGIPresentDevicePrivate> m_device;
DXGI_SWAP_CHAIN_DESC m_desc; DXGI_SWAP_CHAIN_DESC m_desc;
DXGI_FRAME_STATISTICS m_stats; DXGI_FRAME_STATISTICS m_stats;

View File

@ -6,11 +6,10 @@
const GUID IDXGIAdapterPrivate::guid = {0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff}}; const GUID IDXGIAdapterPrivate::guid = {0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff}};
const GUID IDXGIDevicePrivate::guid = {0x7a622cf6,0x627a,0x46b2,{0xb5,0x2f,0x36,0x0e,0xf3,0xda,0x83,0x1c}}; const GUID IDXGIDevicePrivate::guid = {0x7a622cf6,0x627a,0x46b2,{0xb5,0x2f,0x36,0x0e,0xf3,0xda,0x83,0x1c}};
const GUID IDXGIPresentDevicePrivate::guid = {0x79352328,0x16f2,0x4f81,{0x97,0x46,0x9c,0x2e,0x2c,0xcd,0x43,0xcf}};
const GUID IDXGIBufferResourcePrivate::guid = {0x5679becd,0x8547,0x4d93,{0x96,0xa1,0xe6,0x1a,0x1c,0xe7,0xef,0x37}}; const GUID IDXGIBufferResourcePrivate::guid = {0x5679becd,0x8547,0x4d93,{0x96,0xa1,0xe6,0x1a,0x1c,0xe7,0xef,0x37}};
const GUID IDXGIImageResourcePrivate::guid = {0x1cfe6592,0x7de0,0x4a07,{0x8d,0xcb,0x45,0x43,0xcb,0xbc,0x6a,0x7d}}; const GUID IDXGIImageResourcePrivate::guid = {0x1cfe6592,0x7de0,0x4a07,{0x8d,0xcb,0x45,0x43,0xcb,0xbc,0x6a,0x7d}};
const GUID ID3D11DevicePrivate::guid = {0xab2a2a58,0xd2ac,0x4ca0,{0x9a,0xd9,0xa2,0x60,0xca,0xfa,0x00,0xc8}};
std::ostream& operator << (std::ostream& os, REFIID guid) { std::ostream& operator << (std::ostream& os, REFIID guid) {
os.width(8); os.width(8);
os << std::hex << guid.Data1 << '-'; os << std::hex << guid.Data1 << '-';