1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 22:24:15 +01:00

[dxvk] Separated resource view classes

Since we are doing this for UAVs already, we should be
doing this for all view classes in order to account for
the minor differences between all of them.
This commit is contained in:
Philip Rebohle 2018-02-05 22:35:23 +01:00
parent 0437e5652b
commit 83458c4467
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
13 changed files with 328 additions and 104 deletions

View File

@ -6,7 +6,6 @@
#include "d3d11_context_state.h"
#include "d3d11_device_child.h"
#include "d3d11_view.h"
namespace dxvk {

View File

@ -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 {

View File

@ -12,7 +12,6 @@
#include "d3d11_sampler.h"
#include "d3d11_shader.h"
#include "d3d11_texture.h"
#include "d3d11_view.h"
namespace dxvk {

View File

@ -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<typename Iface, typename DescType>
class D3D11ResourceView : public D3D11DeviceChild<Iface> {
public:
D3D11ResourceView(
D3D11Device* device,
ID3D11Resource* resource,
const DescType& desc,
const Rc<DxvkBufferView>& bufferView)
: m_device(device), m_resource(resource),
m_desc(desc), m_bufferView(bufferView) { }
D3D11ResourceView(
D3D11Device* device,
ID3D11Resource* resource,
const DescType& desc,
const Rc<DxvkImageView>& 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<DxvkBufferView> GetBufferView() const {
return m_bufferView;
}
Rc<DxvkImageView> GetImageView() const {
return m_imageView;
}
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
DescType m_desc;
Rc<DxvkBufferView> m_bufferView;
Rc<DxvkImageView> 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>;
}

View File

@ -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<DxvkImageView>& 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;
}
}

View File

@ -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<ID3D11DepthStencilView> {
public:
D3D11DepthStencilView(
D3D11Device* device,
ID3D11Resource* resource,
const D3D11_DEPTH_STENCIL_VIEW_DESC& desc,
const Rc<DxvkImageView>& 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<DxvkImageView> GetImageView() const {
return m_view;
}
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
D3D11_DEPTH_STENCIL_VIEW_DESC m_desc;
Rc<DxvkImageView> m_view;
};
}

View File

@ -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<DxvkImageView>& 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;
}
}

View File

@ -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<ID3D11RenderTargetView> {
public:
D3D11RenderTargetView(
D3D11Device* device,
ID3D11Resource* resource,
const D3D11_RENDER_TARGET_VIEW_DESC& desc,
const Rc<DxvkImageView>& 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<DxvkImageView> GetImageView() const {
return m_view;
}
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
D3D11_RENDER_TARGET_VIEW_DESC m_desc;
Rc<DxvkImageView> m_view;
};
}

View File

@ -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<DxvkBufferView>& 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<DxvkImageView>& 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;
}
}

View File

@ -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<ID3D11ShaderResourceView> {
public:
D3D11ShaderResourceView(
D3D11Device* device,
ID3D11Resource* resource,
const D3D11_SHADER_RESOURCE_VIEW_DESC& desc,
const Rc<DxvkBufferView>& bufferView);
D3D11ShaderResourceView(
D3D11Device* device,
ID3D11Resource* resource,
const D3D11_SHADER_RESOURCE_VIEW_DESC& desc,
const Rc<DxvkImageView>& 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<DxvkBufferView> GetBufferView() const {
return m_bufferView;
}
Rc<DxvkImageView> GetImageView() const {
return m_imageView;
}
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
D3D11_SHADER_RESOURCE_VIEW_DESC m_desc;
Rc<DxvkBufferView> m_bufferView;
Rc<DxvkImageView> m_imageView;
};
}

View File

@ -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;
}

View File

@ -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,