diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 34083dc36..bd178d9aa 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -170,11 +170,7 @@ namespace dxvk { void D3D11DeviceContext::ClearRenderTargetView( ID3D11RenderTargetView* pRenderTargetView, const FLOAT ColorRGBA[4]) { - Com rtv; - - pRenderTargetView->QueryInterface( - __uuidof(ID3D11RenderTargetViewPrivate), - reinterpret_cast(&rtv)); + auto rtv = static_cast(pRenderTargetView); const Rc dxvkView = rtv->GetDXVKImageView(); const Rc dxvkImage = dxvkView->image(); @@ -183,9 +179,9 @@ namespace dxvk { // or not, and if it is, which attachment index it has. int32_t attachmentIndex = -1; - for (uint32_t i = 0; i < m_state.omRenderTargetViews.size(); i++) { - if (rtv.ptr() == m_state.omRenderTargetViews.at(i).ptr()) - attachmentIndex = static_cast(i); + if (m_state.om.framebuffer != nullptr) { + attachmentIndex = m_state.om.framebuffer + ->renderTargets().getAttachmentId(dxvkView); } // Copy the clear color into a clear value structure. @@ -216,7 +212,6 @@ namespace dxvk { if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) clearRect.layerCount = 1; - // Record the clear operation m_context->clearRenderTarget(clearInfo, clearRect); } else { // Image is not bound to the pipeline. We can still clear @@ -837,13 +832,10 @@ namespace dxvk { ID3D11DepthStencilView* pDepthStencilView) { // Update state vector for OMGetRenderTargets for (UINT i = 0; i < m_state.omRenderTargetViews.size(); i++) { - Com view = nullptr; + D3D11RenderTargetView* view = nullptr; - if ((i < NumViews) && (ppRenderTargetViews[i] != nullptr)) { - ppRenderTargetViews[i]->QueryInterface( - __uuidof(ID3D11RenderTargetViewPrivate), - reinterpret_cast(&view)); - } + if ((i < NumViews) && (ppRenderTargetViews[i] != nullptr)) + view = static_cast(ppRenderTargetViews[i]); m_state.omRenderTargetViews.at(i) = view; } @@ -865,7 +857,9 @@ namespace dxvk { Logger::err("D3D11DeviceContext::OMSetRenderTargets: Depth-stencil view not supported"); // Create and bind the framebuffer object using the given attachments - m_context->bindFramebuffer(m_device->createFramebuffer(attachments)); + auto fbo = m_device->createFramebuffer(attachments); + m_state.om.framebuffer = fbo; + m_context->bindFramebuffer(fbo); } diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 43ff63d6d..3b5f864b1 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -2,6 +2,7 @@ #include "d3d11_context_state.h" #include "d3d11_device_child.h" +#include "d3d11_view.h" #include #include diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index e81546c51..f45fb9931 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -3,16 +3,22 @@ #include #include "d3d11_interfaces.h" +#include "d3d11_view.h" namespace dxvk { + struct D3D11ContextStateOM { + Rc framebuffer; + }; + /** * \brief Context state */ struct D3D11ContextState { std::array< - Com, + Com, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> omRenderTargetViews; + D3D11ContextStateOM om; }; } \ No newline at end of file diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 9a3fd063e..bc8928e3a 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -14,7 +14,7 @@ namespace dxvk { D3D_FEATURE_LEVEL featureLevel, UINT featureFlags) : m_dxgiDevice (dxgiDevice), - m_presentDevice (ref(new D3D11PresentDevice())), + m_presentDevice (new D3D11PresentDevice()), m_featureLevel (featureLevel), m_featureFlags (featureFlags), m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()), @@ -116,13 +116,7 @@ namespace dxvk { } // Make sure we can retrieve the image object - Com texture = nullptr; - - if (FAILED(pResource->QueryInterface(__uuidof(ID3D11Texture2DPrivate), - reinterpret_cast(&texture)))) { - Logger::err("D3D11Device::CreateRenderTargetView: Invalid texture"); - return E_INVALIDARG; - } + auto texture = static_cast(pResource); // Image that we are going to create the view for const Rc image = texture->GetDXVKImage(); diff --git a/src/d3d11/d3d11_interfaces.h b/src/d3d11/d3d11_interfaces.h index 445bfefca..aa9e692bf 100644 --- a/src/d3d11/d3d11_interfaces.h +++ b/src/d3d11/d3d11_interfaces.h @@ -5,49 +5,3 @@ #include "../dxgi/dxgi_interfaces.h" #include "../dxvk/dxvk_device.h" - -MIDL_INTERFACE("776fc4de-9cd9-4a4d-936a-7837d20ec5d9") -ID3D11BufferPrivate : public ID3D11Buffer { - static const GUID guid; - - virtual dxvk::Rc GetDXVKBuffer() = 0; -}; - - -MIDL_INTERFACE("cc62022f-eb7c-473c-b58c-c621bc27b405") -ID3D11Texture1DPrivate : public ID3D11Texture1D { - static const GUID guid; - - virtual dxvk::Rc GetDXVKImage() = 0; -}; - - -MIDL_INTERFACE("0ca9d5af-96e6-41f2-a2c0-6b43d4dc837d") -ID3D11Texture2DPrivate : public ID3D11Texture2D { - static const GUID guid; - - virtual dxvk::Rc GetDXVKImage() = 0; -}; - - -MIDL_INTERFACE("b0f7d56e-761e-46c0-8fca-d465b742b2f8") -ID3D11Texture3DPrivate : public ID3D11Texture3D { - static const GUID guid; - - virtual dxvk::Rc GetDXVKImage() = 0; -}; - - -MIDL_INTERFACE("175a9e94-115c-416a-967d-afabadfa0ea8") -ID3D11RenderTargetViewPrivate : public ID3D11RenderTargetView { - static const GUID guid; - - virtual dxvk::Rc GetDXVKImageView() = 0; -}; - - -DXVK_DEFINE_GUID(ID3D11BufferPrivate); -DXVK_DEFINE_GUID(ID3D11Texture1DPrivate); -DXVK_DEFINE_GUID(ID3D11Texture2DPrivate); -DXVK_DEFINE_GUID(ID3D11Texture3DPrivate); -DXVK_DEFINE_GUID(ID3D11RenderTargetViewPrivate); \ No newline at end of file diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index d4f38d992..a33250ff3 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -24,7 +24,6 @@ namespace dxvk { COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource); COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2D); - COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2DPrivate); if (riid == __uuidof(IDXGIResource) || riid == __uuidof(IDXGIImageResourcePrivate)) diff --git a/src/d3d11/d3d11_texture.h b/src/d3d11/d3d11_texture.h index e253f6cdc..623542a86 100644 --- a/src/d3d11/d3d11_texture.h +++ b/src/d3d11/d3d11_texture.h @@ -10,7 +10,7 @@ namespace dxvk { class D3D11Device; - class D3D11Texture2D : public D3D11DeviceChild { + class D3D11Texture2D : public D3D11DeviceChild { public: @@ -37,7 +37,7 @@ namespace dxvk { void GetDesc( D3D11_TEXTURE2D_DESC *pDesc) final; - Rc GetDXVKImage() final; + Rc GetDXVKImage(); private: diff --git a/src/d3d11/d3d11_view.cpp b/src/d3d11/d3d11_view.cpp index 7c5778d16..534089cfd 100644 --- a/src/d3d11/d3d11_view.cpp +++ b/src/d3d11/d3d11_view.cpp @@ -26,7 +26,6 @@ namespace dxvk { COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); COM_QUERY_IFACE(riid, ppvObject, ID3D11View); COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetView); - COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetViewPrivate); Logger::warn("D3D11RenderTargetView::QueryInterface: Unknown interface query"); return E_NOINTERFACE; diff --git a/src/d3d11/d3d11_view.h b/src/d3d11/d3d11_view.h index 30dcc46e7..0b6bbf7b9 100644 --- a/src/d3d11/d3d11_view.h +++ b/src/d3d11/d3d11_view.h @@ -8,7 +8,7 @@ namespace dxvk { class D3D11Device; - class D3D11RenderTargetView : public D3D11DeviceChild { + class D3D11RenderTargetView : public D3D11DeviceChild { public: @@ -32,7 +32,7 @@ namespace dxvk { void GetDesc( D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final; - Rc GetDXVKImageView() final; + Rc GetDXVKImageView(); private: diff --git a/src/util/com/com_guid.cpp b/src/util/com/com_guid.cpp index 476b308f9..6db1265f6 100644 --- a/src/util/com/com_guid.cpp +++ b/src/util/com/com_guid.cpp @@ -10,12 +10,6 @@ const GUID IDXGIPresentDevicePrivate::guid = {0x79352328,0x16f2,0x4f81,{0x97 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 ID3D11BufferPrivate::guid = {0x776fc4de,0x9cd9,0x4a4d,{0x93,0x6a,0x78,0x37,0xd2,0x0e,0xc5,0xd9}}; -const GUID ID3D11Texture1DPrivate::guid = {0xcc62022f,0xeb7c,0x473c,{0xb5,0x8c,0xc6,0x21,0xbc,0x27,0xb4,0x05}}; -const GUID ID3D11Texture2DPrivate::guid = {0x0ca9d5af,0x96e6,0x41f2,{0xa2,0xc0,0x6b,0x43,0xd4,0xdc,0x83,0x7d}}; -const GUID ID3D11Texture3DPrivate::guid = {0xb0f7d56e,0x761e,0x46c0,{0x8f,0xca,0xd4,0x65,0xb7,0x42,0xb2,0xf8}}; -const GUID ID3D11RenderTargetViewPrivate::guid = {0x175a9e94,0x115c,0x416a,{0x96,0x7d,0xaf,0xab,0xad,0xfa,0x0e,0xa8}}; - std::ostream& operator << (std::ostream& os, REFIID guid) { os.width(8); os << std::hex << guid.Data1 << '-';