1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[d3d11] Implement ID3D11RenderTargetView1

This commit is contained in:
Philip Rebohle 2019-09-16 14:12:14 +02:00
parent 0758f14a35
commit 345f8694e8
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 125 additions and 13 deletions

View File

@ -340,13 +340,13 @@ namespace dxvk {
// The view description is optional. If not defined, it // The view description is optional. If not defined, it
// will use the resource's format and all array layers. // will use the resource's format and all array layers.
D3D11_RENDER_TARGET_VIEW_DESC desc; D3D11_RENDER_TARGET_VIEW_DESC1 desc;
if (pDesc == nullptr) { if (pDesc == nullptr) {
if (FAILED(D3D11RenderTargetView::GetDescFromResource(pResource, &desc))) if (FAILED(D3D11RenderTargetView::GetDescFromResource(pResource, &desc)))
return E_INVALIDARG; return E_INVALIDARG;
} else { } else {
desc = *pDesc; desc = D3D11RenderTargetView::PromoteDesc(pDesc);
if (FAILED(D3D11RenderTargetView::NormalizeDesc(pResource, &desc))) if (FAILED(D3D11RenderTargetView::NormalizeDesc(pResource, &desc)))
return E_INVALIDARG; return E_INVALIDARG;

View File

@ -9,7 +9,7 @@ namespace dxvk {
D3D11RenderTargetView::D3D11RenderTargetView( D3D11RenderTargetView::D3D11RenderTargetView(
D3D11Device* pDevice, D3D11Device* pDevice,
ID3D11Resource* pResource, ID3D11Resource* pResource,
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc) const D3D11_RENDER_TARGET_VIEW_DESC1* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) { : m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
ResourceAddRefPrivate(m_resource); ResourceAddRefPrivate(m_resource);
@ -123,7 +123,8 @@ namespace dxvk {
if (riid == __uuidof(IUnknown) if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild) || riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11View) || riid == __uuidof(ID3D11View)
|| riid == __uuidof(ID3D11RenderTargetView)) { || riid == __uuidof(ID3D11RenderTargetView)
|| riid == __uuidof(ID3D11RenderTargetView1)) {
*ppvObject = ref(this); *ppvObject = ref(this);
return S_OK; return S_OK;
} }
@ -152,13 +153,58 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11RenderTargetView::GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) { void STDMETHODCALLTYPE D3D11RenderTargetView::GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) {
pDesc->Format = m_desc.Format;
pDesc->ViewDimension = m_desc.ViewDimension;
switch (m_desc.ViewDimension) {
case D3D11_RTV_DIMENSION_UNKNOWN:
break;
case D3D11_RTV_DIMENSION_BUFFER:
pDesc->Buffer = m_desc.Buffer;
break;
case D3D11_RTV_DIMENSION_TEXTURE1D:
pDesc->Texture1D = m_desc.Texture1D;
break;
case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
pDesc->Texture1DArray = m_desc.Texture1DArray;
break;
case D3D11_RTV_DIMENSION_TEXTURE2D:
pDesc->Texture2D.MipSlice = m_desc.Texture2D.MipSlice;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
pDesc->Texture2DArray.MipSlice = m_desc.Texture2DArray.MipSlice;
pDesc->Texture2DArray.FirstArraySlice = m_desc.Texture2DArray.FirstArraySlice;
pDesc->Texture2DArray.ArraySize = m_desc.Texture2DArray.ArraySize;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DMS:
pDesc->Texture2DMS = m_desc.Texture2DMS;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
pDesc->Texture2DMSArray = m_desc.Texture2DMSArray;
break;
case D3D11_RTV_DIMENSION_TEXTURE3D:
pDesc->Texture3D = m_desc.Texture3D;
break;
}
}
void STDMETHODCALLTYPE D3D11RenderTargetView::GetDesc1(D3D11_RENDER_TARGET_VIEW_DESC1* pDesc) {
*pDesc = m_desc; *pDesc = m_desc;
} }
HRESULT D3D11RenderTargetView::GetDescFromResource( HRESULT D3D11RenderTargetView::GetDescFromResource(
ID3D11Resource* pResource, ID3D11Resource* pResource,
D3D11_RENDER_TARGET_VIEW_DESC* pDesc) { D3D11_RENDER_TARGET_VIEW_DESC1* pDesc) {
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
pResource->GetType(&resourceDim); pResource->GetType(&resourceDim);
@ -189,12 +235,14 @@ namespace dxvk {
if (resourceDesc.SampleDesc.Count == 1) { if (resourceDesc.SampleDesc.Count == 1) {
if (resourceDesc.ArraySize == 1) { if (resourceDesc.ArraySize == 1) {
pDesc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; pDesc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
pDesc->Texture2D.MipSlice = 0; pDesc->Texture2D.MipSlice = 0;
pDesc->Texture2D.PlaneSlice = 0;
} else { } else {
pDesc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; pDesc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
pDesc->Texture2DArray.MipSlice = 0; pDesc->Texture2DArray.MipSlice = 0;
pDesc->Texture2DArray.FirstArraySlice = 0; pDesc->Texture2DArray.FirstArraySlice = 0;
pDesc->Texture2DArray.ArraySize = resourceDesc.ArraySize; pDesc->Texture2DArray.ArraySize = resourceDesc.ArraySize;
pDesc->Texture2DArray.PlaneSlice = 0;
} }
} else { } else {
if (resourceDesc.ArraySize == 1) { if (resourceDesc.ArraySize == 1) {
@ -227,9 +275,60 @@ namespace dxvk {
} }
D3D11_RENDER_TARGET_VIEW_DESC1 D3D11RenderTargetView::PromoteDesc(
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc) {
D3D11_RENDER_TARGET_VIEW_DESC1 dstDesc;
dstDesc.Format = pDesc->Format;
dstDesc.ViewDimension = pDesc->ViewDimension;
switch (pDesc->ViewDimension) {
case D3D11_RTV_DIMENSION_UNKNOWN:
break;
case D3D11_RTV_DIMENSION_BUFFER:
dstDesc.Buffer = pDesc->Buffer;
break;
case D3D11_RTV_DIMENSION_TEXTURE1D:
dstDesc.Texture1D = pDesc->Texture1D;
break;
case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
dstDesc.Texture1DArray = pDesc->Texture1DArray;
break;
case D3D11_RTV_DIMENSION_TEXTURE2D:
dstDesc.Texture2D.MipSlice = pDesc->Texture2D.MipSlice;
dstDesc.Texture2D.PlaneSlice = 0;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
dstDesc.Texture2DArray.MipSlice = pDesc->Texture2DArray.MipSlice;
dstDesc.Texture2DArray.FirstArraySlice = pDesc->Texture2DArray.FirstArraySlice;
dstDesc.Texture2DArray.ArraySize = pDesc->Texture2DArray.ArraySize;
dstDesc.Texture2DArray.PlaneSlice = 0;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DMS:
dstDesc.Texture2DMS = pDesc->Texture2DMS;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
dstDesc.Texture2DMSArray = pDesc->Texture2DMSArray;
break;
case D3D11_RTV_DIMENSION_TEXTURE3D:
dstDesc.Texture3D = pDesc->Texture3D;
break;
}
return dstDesc;
}
HRESULT D3D11RenderTargetView::NormalizeDesc( HRESULT D3D11RenderTargetView::NormalizeDesc(
ID3D11Resource* pResource, ID3D11Resource* pResource,
D3D11_RENDER_TARGET_VIEW_DESC* pDesc) { D3D11_RENDER_TARGET_VIEW_DESC1* pDesc) {
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
pResource->GetType(&resourceDim); pResource->GetType(&resourceDim);
@ -300,9 +399,17 @@ namespace dxvk {
pDesc->Texture1DArray.ArraySize = numLayers - pDesc->Texture1DArray.FirstArraySlice; pDesc->Texture1DArray.ArraySize = numLayers - pDesc->Texture1DArray.FirstArraySlice;
break; break;
case D3D11_RTV_DIMENSION_TEXTURE2D:
if (pDesc->Texture2D.PlaneSlice != 0)
return E_INVALIDARG;
break;
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY: case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
if (pDesc->Texture2DArray.ArraySize > numLayers - pDesc->Texture2DArray.FirstArraySlice) if (pDesc->Texture2DArray.ArraySize > numLayers - pDesc->Texture2DArray.FirstArraySlice)
pDesc->Texture2DArray.ArraySize = numLayers - pDesc->Texture2DArray.FirstArraySlice; pDesc->Texture2DArray.ArraySize = numLayers - pDesc->Texture2DArray.FirstArraySlice;
if (pDesc->Texture2DArray.PlaneSlice != 0)
return E_INVALIDARG;
break; break;
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY: case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:

View File

@ -14,14 +14,14 @@ namespace dxvk {
/** /**
* \brief Render target view * \brief Render target view
*/ */
class D3D11RenderTargetView : public D3D11DeviceChild<ID3D11RenderTargetView> { class D3D11RenderTargetView : public D3D11DeviceChild<ID3D11RenderTargetView1> {
public: public:
D3D11RenderTargetView( D3D11RenderTargetView(
D3D11Device* pDevice, D3D11Device* pDevice,
ID3D11Resource* pResource, ID3D11Resource* pResource,
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc); const D3D11_RENDER_TARGET_VIEW_DESC1* pDesc);
~D3D11RenderTargetView(); ~D3D11RenderTargetView();
@ -32,7 +32,9 @@ namespace dxvk {
void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final; void STDMETHODCALLTYPE GetResource(ID3D11Resource** ppResource) final;
void STDMETHODCALLTYPE GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final; void STDMETHODCALLTYPE GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* pDesc) final;
void STDMETHODCALLTYPE GetDesc1(D3D11_RENDER_TARGET_VIEW_DESC1* pDesc) final;
const D3D11_VK_VIEW_INFO& GetViewInfo() const { const D3D11_VK_VIEW_INFO& GetViewInfo() const {
return m_info; return m_info;
} }
@ -63,17 +65,20 @@ namespace dxvk {
static HRESULT GetDescFromResource( static HRESULT GetDescFromResource(
ID3D11Resource* pResource, ID3D11Resource* pResource,
D3D11_RENDER_TARGET_VIEW_DESC* pDesc); D3D11_RENDER_TARGET_VIEW_DESC1* pDesc);
static D3D11_RENDER_TARGET_VIEW_DESC1 PromoteDesc(
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc);
static HRESULT NormalizeDesc( static HRESULT NormalizeDesc(
ID3D11Resource* pResource, ID3D11Resource* pResource,
D3D11_RENDER_TARGET_VIEW_DESC* pDesc); D3D11_RENDER_TARGET_VIEW_DESC1* pDesc);
private: private:
Com<D3D11Device> m_device; Com<D3D11Device> m_device;
ID3D11Resource* m_resource; ID3D11Resource* m_resource;
D3D11_RENDER_TARGET_VIEW_DESC m_desc; D3D11_RENDER_TARGET_VIEW_DESC1 m_desc;
D3D11_VK_VIEW_INFO m_info; D3D11_VK_VIEW_INFO m_info;
Rc<DxvkImageView> m_view; Rc<DxvkImageView> m_view;
D3D10RenderTargetView m_d3d10; D3D10RenderTargetView m_d3d10;