diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 67fd9d23..a2ca649e 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -6,7 +6,6 @@ #include "d3d11_context_state.h" #include "d3d11_device_child.h" -#include "d3d11_view.h" namespace dxvk { diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index 9a8032a8..2d1327cc 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -7,8 +7,10 @@ #include "d3d11_sampler.h" #include "d3d11_shader.h" #include "d3d11_state.h" -#include "d3d11_uav.h" -#include "d3d11_view.h" +#include "d3d11_view_dsv.h" +#include "d3d11_view_rtv.h" +#include "d3d11_view_srv.h" +#include "d3d11_view_uav.h" namespace dxvk { diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 831cd2bc..e39f7c1f 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -12,7 +12,6 @@ #include "d3d11_sampler.h" #include "d3d11_shader.h" #include "d3d11_texture.h" -#include "d3d11_view.h" namespace dxvk { diff --git a/src/d3d11/d3d11_view.h b/src/d3d11/d3d11_view.h deleted file mode 100644 index ad502055..00000000 --- a/src/d3d11/d3d11_view.h +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once - -#include "../dxvk/dxvk_device.h" - -#include "d3d11_device_child.h" - -namespace dxvk { - - class D3D11Device; - - /** - * \brief Generic resource view template - * - * Stores an image view or a buffer view, depending - * on the referenced resource type, and implements - * the interface for a given view type. - * \tparam Iface Base interface - * \tparam DescType View description type - */ - template - class D3D11ResourceView : public D3D11DeviceChild { - - public: - - D3D11ResourceView( - D3D11Device* device, - ID3D11Resource* resource, - const DescType& desc, - const Rc& bufferView) - : m_device(device), m_resource(resource), - m_desc(desc), m_bufferView(bufferView) { } - - D3D11ResourceView( - D3D11Device* device, - ID3D11Resource* resource, - const DescType& desc, - const Rc& imageView) - : m_device(device), m_resource(resource), - m_desc(desc), m_imageView(imageView) { } - - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final { - COM_QUERY_IFACE(riid, ppvObject, IUnknown); - COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); - COM_QUERY_IFACE(riid, ppvObject, ID3D11View); - COM_QUERY_IFACE(riid, ppvObject, Iface); - - Logger::warn("D3D11ResourceView::QueryInterface: Unknown interface query"); - return E_NOINTERFACE; - } - - void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final { - *ppDevice = m_device.ref(); - } - - void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final { - *ppResource = m_resource.ref(); - } - - void STDMETHODCALLTYPE GetDesc(DescType* pDesc) final { - *pDesc = m_desc; - } - - D3D11_RESOURCE_DIMENSION GetResourceType() const { - D3D11_RESOURCE_DIMENSION type; - m_resource->GetType(&type); - return type; - } - - Rc GetBufferView() const { - return m_bufferView; - } - - Rc GetImageView() const { - return m_imageView; - } - - private: - - Com m_device; - Com m_resource; - DescType m_desc; - Rc m_bufferView; - Rc m_imageView; - - }; - - - using D3D11ShaderResourceView = D3D11ResourceView< - ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>; - - using D3D11RenderTargetView = D3D11ResourceView< - ID3D11RenderTargetView, D3D11_RENDER_TARGET_VIEW_DESC>; - - using D3D11DepthStencilView = D3D11ResourceView< - ID3D11DepthStencilView, D3D11_DEPTH_STENCIL_VIEW_DESC>; - -} diff --git a/src/d3d11/d3d11_view_dsv.cpp b/src/d3d11/d3d11_view_dsv.cpp new file mode 100644 index 00000000..27879c6f --- /dev/null +++ b/src/d3d11/d3d11_view_dsv.cpp @@ -0,0 +1,45 @@ +#include "d3d11_device.h" +#include "d3d11_view_dsv.h" + +namespace dxvk { + + D3D11DepthStencilView::D3D11DepthStencilView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_DEPTH_STENCIL_VIEW_DESC& desc, + const Rc& view) + : m_device(device), m_resource(resource), + m_desc(desc), m_view(view) { } + + + D3D11DepthStencilView::~D3D11DepthStencilView() { + + } + + + HRESULT STDMETHODCALLTYPE D3D11DepthStencilView::QueryInterface(REFIID riid, void** ppvObject) { + COM_QUERY_IFACE(riid, ppvObject, IUnknown); + COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); + COM_QUERY_IFACE(riid, ppvObject, ID3D11View); + COM_QUERY_IFACE(riid, ppvObject, ID3D11DepthStencilView); + + Logger::warn("D3D11DepthStencilView::QueryInterface: Unknown interface query"); + return E_NOINTERFACE; + } + + + void STDMETHODCALLTYPE D3D11DepthStencilView::GetDevice(ID3D11Device** ppDevice) { + *ppDevice = m_device.ref(); + } + + + void STDMETHODCALLTYPE D3D11DepthStencilView::GetResource(ID3D11Resource** ppResource) { + *ppResource = m_resource.ref(); + } + + + void STDMETHODCALLTYPE D3D11DepthStencilView::GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) { + *pDesc = m_desc; + } + +} diff --git a/src/d3d11/d3d11_view_dsv.h b/src/d3d11/d3d11_view_dsv.h new file mode 100644 index 00000000..2592f8cf --- /dev/null +++ b/src/d3d11/d3d11_view_dsv.h @@ -0,0 +1,57 @@ +#pragma once + +#include "../dxvk/dxvk_device.h" + +#include "d3d11_device_child.h" + +namespace dxvk { + + class D3D11Device; + + /** + * \brief Depth-stencil view + * + * Unordered access views are special in that they can + * have counters, which can be used inside shaders to + * atomically append or consume structures. + */ + class D3D11DepthStencilView : public D3D11DeviceChild { + + public: + + D3D11DepthStencilView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_DEPTH_STENCIL_VIEW_DESC& desc, + const Rc& view); + + ~D3D11DepthStencilView(); + + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final; + + void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final; + + void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final; + + void STDMETHODCALLTYPE GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc) final; + + D3D11_RESOURCE_DIMENSION GetResourceType() const { + D3D11_RESOURCE_DIMENSION type; + m_resource->GetType(&type); + return type; + } + + Rc GetImageView() const { + return m_view; + } + + private: + + Com m_device; + Com m_resource; + D3D11_DEPTH_STENCIL_VIEW_DESC m_desc; + Rc m_view; + + }; + +} diff --git a/src/d3d11/d3d11_view_rtv.cpp b/src/d3d11/d3d11_view_rtv.cpp new file mode 100644 index 00000000..aa1e5d1d --- /dev/null +++ b/src/d3d11/d3d11_view_rtv.cpp @@ -0,0 +1,45 @@ +#include "d3d11_device.h" +#include "d3d11_view_rtv.h" + +namespace dxvk { + + D3D11RenderTargetView::D3D11RenderTargetView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_RENDER_TARGET_VIEW_DESC& desc, + const Rc& view) + : m_device(device), m_resource(resource), + m_desc(desc), m_view(view) { } + + + D3D11RenderTargetView::~D3D11RenderTargetView() { + + } + + + HRESULT STDMETHODCALLTYPE D3D11RenderTargetView::QueryInterface(REFIID riid, void** ppvObject) { + COM_QUERY_IFACE(riid, ppvObject, IUnknown); + COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); + COM_QUERY_IFACE(riid, ppvObject, ID3D11View); + COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetView); + + Logger::warn("D3D11RenderTargetView::QueryInterface: Unknown interface query"); + return E_NOINTERFACE; + } + + + void STDMETHODCALLTYPE D3D11RenderTargetView::GetDevice(ID3D11Device** ppDevice) { + *ppDevice = m_device.ref(); + } + + + void STDMETHODCALLTYPE D3D11RenderTargetView::GetResource(ID3D11Resource** ppResource) { + *ppResource = m_resource.ref(); + } + + + void STDMETHODCALLTYPE D3D11RenderTargetView::GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) { + *pDesc = m_desc; + } + +} diff --git a/src/d3d11/d3d11_view_rtv.h b/src/d3d11/d3d11_view_rtv.h new file mode 100644 index 00000000..14d558b7 --- /dev/null +++ b/src/d3d11/d3d11_view_rtv.h @@ -0,0 +1,53 @@ +#pragma once + +#include "../dxvk/dxvk_device.h" + +#include "d3d11_device_child.h" + +namespace dxvk { + + class D3D11Device; + + /** + * \brief Render target view + */ + class D3D11RenderTargetView : public D3D11DeviceChild { + + public: + + D3D11RenderTargetView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_RENDER_TARGET_VIEW_DESC& desc, + const Rc& view); + + ~D3D11RenderTargetView(); + + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final; + + void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final; + + void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final; + + void STDMETHODCALLTYPE GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final; + + D3D11_RESOURCE_DIMENSION GetResourceType() const { + D3D11_RESOURCE_DIMENSION type; + m_resource->GetType(&type); + return type; + } + + Rc GetImageView() const { + return m_view; + } + + private: + + Com m_device; + Com m_resource; + D3D11_RENDER_TARGET_VIEW_DESC m_desc; + Rc m_view; + + }; + +} diff --git a/src/d3d11/d3d11_view_srv.cpp b/src/d3d11/d3d11_view_srv.cpp new file mode 100644 index 00000000..2774f518 --- /dev/null +++ b/src/d3d11/d3d11_view_srv.cpp @@ -0,0 +1,54 @@ +#include "d3d11_device.h" +#include "d3d11_view_srv.h" + +namespace dxvk { + + D3D11ShaderResourceView::D3D11ShaderResourceView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_SHADER_RESOURCE_VIEW_DESC& desc, + const Rc& bufferView) + : m_device(device), m_resource(resource), + m_desc(desc), m_bufferView(bufferView) { } + + + D3D11ShaderResourceView::D3D11ShaderResourceView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_SHADER_RESOURCE_VIEW_DESC& desc, + const Rc& imageView) + : m_device(device), m_resource(resource), + m_desc(desc), m_imageView(imageView) { } + + + D3D11ShaderResourceView::~D3D11ShaderResourceView() { + + } + + + HRESULT STDMETHODCALLTYPE D3D11ShaderResourceView::QueryInterface(REFIID riid, void** ppvObject) { + COM_QUERY_IFACE(riid, ppvObject, IUnknown); + COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild); + COM_QUERY_IFACE(riid, ppvObject, ID3D11View); + COM_QUERY_IFACE(riid, ppvObject, ID3D11ShaderResourceView); + + Logger::warn("D3D11ShaderResourceView::QueryInterface: Unknown interface query"); + return E_NOINTERFACE; + } + + + void STDMETHODCALLTYPE D3D11ShaderResourceView::GetDevice(ID3D11Device** ppDevice) { + *ppDevice = m_device.ref(); + } + + + void STDMETHODCALLTYPE D3D11ShaderResourceView::GetResource(ID3D11Resource** ppResource) { + *ppResource = m_resource.ref(); + } + + + void STDMETHODCALLTYPE D3D11ShaderResourceView::GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) { + *pDesc = m_desc; + } + +} diff --git a/src/d3d11/d3d11_view_srv.h b/src/d3d11/d3d11_view_srv.h new file mode 100644 index 00000000..c6fc68de --- /dev/null +++ b/src/d3d11/d3d11_view_srv.h @@ -0,0 +1,64 @@ +#pragma once + +#include "../dxvk/dxvk_device.h" + +#include "d3d11_device_child.h" + +namespace dxvk { + + class D3D11Device; + + /** + * \brief Shader resource view + */ + class D3D11ShaderResourceView : public D3D11DeviceChild { + + public: + + D3D11ShaderResourceView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_SHADER_RESOURCE_VIEW_DESC& desc, + const Rc& bufferView); + + D3D11ShaderResourceView( + D3D11Device* device, + ID3D11Resource* resource, + const D3D11_SHADER_RESOURCE_VIEW_DESC& desc, + const Rc& imageView); + + ~D3D11ShaderResourceView(); + + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final; + + void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) final; + + void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final; + + void STDMETHODCALLTYPE GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc) final; + + D3D11_RESOURCE_DIMENSION GetResourceType() const { + D3D11_RESOURCE_DIMENSION type; + m_resource->GetType(&type); + return type; + } + + Rc GetBufferView() const { + return m_bufferView; + } + + Rc GetImageView() const { + return m_imageView; + } + + private: + + Com m_device; + Com m_resource; + D3D11_SHADER_RESOURCE_VIEW_DESC m_desc; + Rc m_bufferView; + Rc m_imageView; + + }; + +} diff --git a/src/d3d11/d3d11_uav.cpp b/src/d3d11/d3d11_view_uav.cpp similarity index 94% rename from src/d3d11/d3d11_uav.cpp rename to src/d3d11/d3d11_view_uav.cpp index f1f4544c..ca6e7d0a 100644 --- a/src/d3d11/d3d11_uav.cpp +++ b/src/d3d11/d3d11_view_uav.cpp @@ -1,5 +1,5 @@ #include "d3d11_device.h" -#include "d3d11_uav.h" +#include "d3d11_view_uav.h" namespace dxvk { @@ -37,7 +37,7 @@ namespace dxvk { COM_QUERY_IFACE(riid, ppvObject, ID3D11View); COM_QUERY_IFACE(riid, ppvObject, ID3D11UnorderedAccessView); - Logger::warn("ID3D11UnorderedAccessView::QueryInterface: Unknown interface query"); + Logger::warn("D3D11UnorderedAccessView::QueryInterface: Unknown interface query"); return E_NOINTERFACE; } diff --git a/src/d3d11/d3d11_uav.h b/src/d3d11/d3d11_view_uav.h similarity index 100% rename from src/d3d11/d3d11_uav.h rename to src/d3d11/d3d11_view_uav.h diff --git a/src/d3d11/meson.build b/src/d3d11/meson.build index e96ff923..6a9100e7 100644 --- a/src/d3d11/meson.build +++ b/src/d3d11/meson.build @@ -18,8 +18,11 @@ d3d11_src = [ 'd3d11_shader.cpp', 'd3d11_state.cpp', 'd3d11_texture.cpp', - 'd3d11_uav.cpp', 'd3d11_util.cpp', + 'd3d11_view_dsv.cpp', + 'd3d11_view_rtv.cpp', + 'd3d11_view_srv.cpp', + 'd3d11_view_uav.cpp', ] d3d11_dll = shared_library('d3d11', d3d11_src,