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

[d3d11] Some cleanup work

This commit is contained in:
Philip Rebohle 2017-12-04 13:39:37 +01:00
parent 60992143b1
commit cf33315c0c
10 changed files with 24 additions and 83 deletions

View File

@ -170,11 +170,7 @@ namespace dxvk {
void D3D11DeviceContext::ClearRenderTargetView( void D3D11DeviceContext::ClearRenderTargetView(
ID3D11RenderTargetView* pRenderTargetView, ID3D11RenderTargetView* pRenderTargetView,
const FLOAT ColorRGBA[4]) { const FLOAT ColorRGBA[4]) {
Com<ID3D11RenderTargetViewPrivate> rtv; auto rtv = static_cast<D3D11RenderTargetView*>(pRenderTargetView);
pRenderTargetView->QueryInterface(
__uuidof(ID3D11RenderTargetViewPrivate),
reinterpret_cast<void**>(&rtv));
const Rc<DxvkImageView> dxvkView = rtv->GetDXVKImageView(); const Rc<DxvkImageView> dxvkView = rtv->GetDXVKImageView();
const Rc<DxvkImage> dxvkImage = dxvkView->image(); const Rc<DxvkImage> dxvkImage = dxvkView->image();
@ -183,9 +179,9 @@ namespace dxvk {
// or not, and if it is, which attachment index it has. // or not, and if it is, which attachment index it has.
int32_t attachmentIndex = -1; int32_t attachmentIndex = -1;
for (uint32_t i = 0; i < m_state.omRenderTargetViews.size(); i++) { if (m_state.om.framebuffer != nullptr) {
if (rtv.ptr() == m_state.omRenderTargetViews.at(i).ptr()) attachmentIndex = m_state.om.framebuffer
attachmentIndex = static_cast<int32_t>(i); ->renderTargets().getAttachmentId(dxvkView);
} }
// Copy the clear color into a clear value structure. // Copy the clear color into a clear value structure.
@ -216,7 +212,6 @@ namespace dxvk {
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
clearRect.layerCount = 1; clearRect.layerCount = 1;
// Record the clear operation
m_context->clearRenderTarget(clearInfo, clearRect); m_context->clearRenderTarget(clearInfo, clearRect);
} else { } else {
// Image is not bound to the pipeline. We can still clear // Image is not bound to the pipeline. We can still clear
@ -837,13 +832,10 @@ namespace dxvk {
ID3D11DepthStencilView* pDepthStencilView) { ID3D11DepthStencilView* pDepthStencilView) {
// Update state vector for OMGetRenderTargets // Update state vector for OMGetRenderTargets
for (UINT i = 0; i < m_state.omRenderTargetViews.size(); i++) { for (UINT i = 0; i < m_state.omRenderTargetViews.size(); i++) {
Com<ID3D11RenderTargetViewPrivate> view = nullptr; D3D11RenderTargetView* view = nullptr;
if ((i < NumViews) && (ppRenderTargetViews[i] != nullptr)) { if ((i < NumViews) && (ppRenderTargetViews[i] != nullptr))
ppRenderTargetViews[i]->QueryInterface( view = static_cast<D3D11RenderTargetView*>(ppRenderTargetViews[i]);
__uuidof(ID3D11RenderTargetViewPrivate),
reinterpret_cast<void**>(&view));
}
m_state.omRenderTargetViews.at(i) = view; m_state.omRenderTargetViews.at(i) = view;
} }
@ -865,7 +857,9 @@ namespace dxvk {
Logger::err("D3D11DeviceContext::OMSetRenderTargets: Depth-stencil view not supported"); Logger::err("D3D11DeviceContext::OMSetRenderTargets: Depth-stencil view not supported");
// Create and bind the framebuffer object using the given attachments // 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);
} }

View File

@ -2,6 +2,7 @@
#include "d3d11_context_state.h" #include "d3d11_context_state.h"
#include "d3d11_device_child.h" #include "d3d11_device_child.h"
#include "d3d11_view.h"
#include <dxvk_adapter.h> #include <dxvk_adapter.h>
#include <dxvk_device.h> #include <dxvk_device.h>

View File

@ -3,16 +3,22 @@
#include <array> #include <array>
#include "d3d11_interfaces.h" #include "d3d11_interfaces.h"
#include "d3d11_view.h"
namespace dxvk { namespace dxvk {
struct D3D11ContextStateOM {
Rc<DxvkFramebuffer> framebuffer;
};
/** /**
* \brief Context state * \brief Context state
*/ */
struct D3D11ContextState { struct D3D11ContextState {
std::array< std::array<
Com<ID3D11RenderTargetViewPrivate>, Com<D3D11RenderTargetView>,
D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> omRenderTargetViews; D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> omRenderTargetViews;
D3D11ContextStateOM om;
}; };
} }

View File

@ -14,7 +14,7 @@ namespace dxvk {
D3D_FEATURE_LEVEL featureLevel, D3D_FEATURE_LEVEL featureLevel,
UINT featureFlags) UINT featureFlags)
: m_dxgiDevice (dxgiDevice), : m_dxgiDevice (dxgiDevice),
m_presentDevice (ref(new D3D11PresentDevice())), m_presentDevice (new D3D11PresentDevice()),
m_featureLevel (featureLevel), m_featureLevel (featureLevel),
m_featureFlags (featureFlags), m_featureFlags (featureFlags),
m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()), m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()),
@ -116,13 +116,7 @@ namespace dxvk {
} }
// Make sure we can retrieve the image object // Make sure we can retrieve the image object
Com<ID3D11Texture2DPrivate> texture = nullptr; auto texture = static_cast<D3D11Texture2D*>(pResource);
if (FAILED(pResource->QueryInterface(__uuidof(ID3D11Texture2DPrivate),
reinterpret_cast<void**>(&texture)))) {
Logger::err("D3D11Device::CreateRenderTargetView: Invalid texture");
return E_INVALIDARG;
}
// Image that we are going to create the view for // Image that we are going to create the view for
const Rc<DxvkImage> image = texture->GetDXVKImage(); const Rc<DxvkImage> image = texture->GetDXVKImage();

View File

@ -5,49 +5,3 @@
#include "../dxgi/dxgi_interfaces.h" #include "../dxgi/dxgi_interfaces.h"
#include "../dxvk/dxvk_device.h" #include "../dxvk/dxvk_device.h"
MIDL_INTERFACE("776fc4de-9cd9-4a4d-936a-7837d20ec5d9")
ID3D11BufferPrivate : public ID3D11Buffer {
static const GUID guid;
virtual dxvk::Rc<dxvk::DxvkBuffer> GetDXVKBuffer() = 0;
};
MIDL_INTERFACE("cc62022f-eb7c-473c-b58c-c621bc27b405")
ID3D11Texture1DPrivate : public ID3D11Texture1D {
static const GUID guid;
virtual dxvk::Rc<dxvk::DxvkImage> GetDXVKImage() = 0;
};
MIDL_INTERFACE("0ca9d5af-96e6-41f2-a2c0-6b43d4dc837d")
ID3D11Texture2DPrivate : public ID3D11Texture2D {
static const GUID guid;
virtual dxvk::Rc<dxvk::DxvkImage> GetDXVKImage() = 0;
};
MIDL_INTERFACE("b0f7d56e-761e-46c0-8fca-d465b742b2f8")
ID3D11Texture3DPrivate : public ID3D11Texture3D {
static const GUID guid;
virtual dxvk::Rc<dxvk::DxvkImage> GetDXVKImage() = 0;
};
MIDL_INTERFACE("175a9e94-115c-416a-967d-afabadfa0ea8")
ID3D11RenderTargetViewPrivate : public ID3D11RenderTargetView {
static const GUID guid;
virtual dxvk::Rc<dxvk::DxvkImageView> GetDXVKImageView() = 0;
};
DXVK_DEFINE_GUID(ID3D11BufferPrivate);
DXVK_DEFINE_GUID(ID3D11Texture1DPrivate);
DXVK_DEFINE_GUID(ID3D11Texture2DPrivate);
DXVK_DEFINE_GUID(ID3D11Texture3DPrivate);
DXVK_DEFINE_GUID(ID3D11RenderTargetViewPrivate);

View File

@ -24,7 +24,6 @@ namespace dxvk {
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); 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);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2DPrivate);
if (riid == __uuidof(IDXGIResource) if (riid == __uuidof(IDXGIResource)
|| riid == __uuidof(IDXGIImageResourcePrivate)) || riid == __uuidof(IDXGIImageResourcePrivate))

View File

@ -10,7 +10,7 @@ namespace dxvk {
class D3D11Device; class D3D11Device;
class D3D11Texture2D : public D3D11DeviceChild<ID3D11Texture2DPrivate> { class D3D11Texture2D : public D3D11DeviceChild<ID3D11Texture2D> {
public: public:
@ -37,7 +37,7 @@ namespace dxvk {
void GetDesc( void GetDesc(
D3D11_TEXTURE2D_DESC *pDesc) final; D3D11_TEXTURE2D_DESC *pDesc) final;
Rc<DxvkImage> GetDXVKImage() final; Rc<DxvkImage> GetDXVKImage();
private: private:

View File

@ -26,7 +26,6 @@ namespace dxvk {
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11View); COM_QUERY_IFACE(riid, ppvObject, ID3D11View);
COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetView); COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetView);
COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetViewPrivate);
Logger::warn("D3D11RenderTargetView::QueryInterface: Unknown interface query"); Logger::warn("D3D11RenderTargetView::QueryInterface: Unknown interface query");
return E_NOINTERFACE; return E_NOINTERFACE;

View File

@ -8,7 +8,7 @@ namespace dxvk {
class D3D11Device; class D3D11Device;
class D3D11RenderTargetView : public D3D11DeviceChild<ID3D11RenderTargetViewPrivate> { class D3D11RenderTargetView : public D3D11DeviceChild<ID3D11RenderTargetView> {
public: public:
@ -32,7 +32,7 @@ namespace dxvk {
void GetDesc( void GetDesc(
D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final; D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final;
Rc<DxvkImageView> GetDXVKImageView() final; Rc<DxvkImageView> GetDXVKImageView();
private: private:

View File

@ -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 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 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) { std::ostream& operator << (std::ostream& os, REFIID guid) {
os.width(8); os.width(8);
os << std::hex << guid.Data1 << '-'; os << std::hex << guid.Data1 << '-';