2017-11-29 15:16:07 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <dxvk_device.h>
|
|
|
|
|
|
|
|
#include "d3d11_device_child.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
class D3D11Device;
|
|
|
|
|
2017-12-09 02:09:13 +01:00
|
|
|
/**
|
|
|
|
* \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> {
|
2017-11-29 15:16:07 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-12-09 02:09:13 +01:00
|
|
|
D3D11ResourceView(
|
|
|
|
D3D11Device* device,
|
|
|
|
ID3D11Resource* resource,
|
|
|
|
const DescType& desc,
|
|
|
|
const Rc<DxvkBufferView>& bufferView,
|
|
|
|
const Rc<DxvkImageView>& imageView)
|
|
|
|
: m_device(device), m_resource(resource), m_desc(desc),
|
|
|
|
m_bufferView(bufferView), m_imageView(imageView) { }
|
|
|
|
|
|
|
|
HRESULT 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 GetDevice(ID3D11Device** ppDevice) final {
|
2017-12-09 15:57:05 +01:00
|
|
|
*ppDevice = m_device.ref();
|
2017-12-09 02:09:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetResource(ID3D11Resource** ppResource) final {
|
|
|
|
*ppResource = m_resource.ref();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetDesc(DescType* pDesc) final {
|
|
|
|
*pDesc = m_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rc<DxvkBufferView> GetDXVKBufferView() {
|
|
|
|
return m_bufferView;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rc<DxvkImageView> GetDXVKImageView() {
|
|
|
|
return m_imageView;
|
|
|
|
}
|
2017-11-29 20:19:40 +01:00
|
|
|
|
2017-11-29 15:16:07 +01:00
|
|
|
private:
|
|
|
|
|
2017-12-09 15:57:05 +01:00
|
|
|
Com<D3D11Device> m_device;
|
2017-12-09 02:09:13 +01:00
|
|
|
Com<ID3D11Resource> m_resource;
|
|
|
|
DescType m_desc;
|
|
|
|
Rc<DxvkBufferView> m_bufferView;
|
|
|
|
Rc<DxvkImageView> m_imageView;
|
2017-11-29 15:16:07 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-12-08 23:25:38 +01:00
|
|
|
|
2017-12-09 02:09:13 +01:00
|
|
|
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>;
|
2017-12-08 23:25:38 +01:00
|
|
|
|
2017-12-09 02:09:13 +01:00
|
|
|
using D3D11UnorderedAccessView = D3D11ResourceView<
|
|
|
|
ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>;
|
2017-12-08 23:25:38 +01:00
|
|
|
|
2017-11-29 15:16:07 +01:00
|
|
|
}
|