mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 01:24:11 +01:00
[d3d10] Implement D3D10CreateDepthStencilView
This commit is contained in:
parent
ea46a0340e
commit
ae12fbd23c
@ -284,8 +284,59 @@ namespace dxvk {
|
||||
ID3D10Resource* pResource,
|
||||
const D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc,
|
||||
ID3D10DepthStencilView** ppDepthStencilView) {
|
||||
Logger::err("D3D10Device::CreateDepthStencilView: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
Com<ID3D11Resource> d3d11Resource;
|
||||
GetD3D11Resource(pResource, &d3d11Resource);
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC d3d11Desc;
|
||||
d3d11Desc.ViewDimension = D3D11_DSV_DIMENSION(pDesc->ViewDimension);
|
||||
d3d11Desc.Format = pDesc->Format;
|
||||
d3d11Desc.Flags = 0;
|
||||
|
||||
switch (pDesc->ViewDimension) {
|
||||
case D3D10_DSV_DIMENSION_UNKNOWN:
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE1D:
|
||||
d3d11Desc.Texture1D.MipSlice = pDesc->Texture1D.MipSlice;
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE1DARRAY:
|
||||
d3d11Desc.Texture1DArray.MipSlice = pDesc->Texture1DArray.MipSlice;
|
||||
d3d11Desc.Texture1DArray.FirstArraySlice = pDesc->Texture1DArray.FirstArraySlice;
|
||||
d3d11Desc.Texture1DArray.ArraySize = pDesc->Texture1DArray.ArraySize;
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE2D:
|
||||
d3d11Desc.Texture2D.MipSlice = pDesc->Texture2D.MipSlice;
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE2DARRAY:
|
||||
d3d11Desc.Texture2DArray.MipSlice = pDesc->Texture2DArray.MipSlice;
|
||||
d3d11Desc.Texture2DArray.FirstArraySlice = pDesc->Texture2DArray.FirstArraySlice;
|
||||
d3d11Desc.Texture2DArray.ArraySize = pDesc->Texture2DArray.ArraySize;
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE2DMS:
|
||||
break;
|
||||
|
||||
case D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY:
|
||||
d3d11Desc.Texture2DMSArray.FirstArraySlice = pDesc->Texture2DMSArray.FirstArraySlice;
|
||||
d3d11Desc.Texture2DMSArray.ArraySize = pDesc->Texture2DMSArray.ArraySize;
|
||||
break;
|
||||
}
|
||||
|
||||
ID3D11DepthStencilView* d3d11View = nullptr;
|
||||
HRESULT hr = m_device->CreateDepthStencilView(
|
||||
d3d11Resource.ptr(), &d3d11Desc,
|
||||
ppDepthStencilView ? &d3d11View : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppDepthStencilView != nullptr) {
|
||||
*ppDepthStencilView = static_cast<D3D11DepthStencilView*>(d3d11View)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
102
src/d3d10/d3d10_view_dsv.cpp
Normal file
102
src/d3d10/d3d10_view_dsv.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
#include "d3d10_view_dsv.h"
|
||||
|
||||
#include "../d3d11/d3d11_device.h"
|
||||
#include "../d3d11/d3d11_view_dsv.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10DepthStencilView::QueryInterface(
|
||||
REFIID riid,
|
||||
void** ppvObject) {
|
||||
return m_d3d11->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE D3D10DepthStencilView::AddRef() {
|
||||
return m_d3d11->AddRef();
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE D3D10DepthStencilView::Release() {
|
||||
return m_d3d11->Release();
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10DepthStencilView::GetDevice(
|
||||
ID3D10Device** ppDevice) {
|
||||
GetD3D10Device(m_d3d11, ppDevice);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10DepthStencilView::GetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT* pDataSize,
|
||||
void* pData) {
|
||||
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10DepthStencilView::SetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT DataSize,
|
||||
const void* pData) {
|
||||
return m_d3d11->SetPrivateData(guid, DataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D10DepthStencilView::SetPrivateDataInterface(
|
||||
REFGUID guid,
|
||||
const IUnknown* pData) {
|
||||
return m_d3d11->SetPrivateDataInterface(guid, pData);
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10DepthStencilView::GetResource(
|
||||
ID3D10Resource** ppResource) {
|
||||
GetD3D10ResourceFromView(m_d3d11, ppResource);
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D10DepthStencilView::GetDesc(
|
||||
D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc) {
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC d3d11Desc;
|
||||
m_d3d11->GetDesc(&d3d11Desc);
|
||||
|
||||
pDesc->ViewDimension = D3D10_DSV_DIMENSION(d3d11Desc.ViewDimension);
|
||||
pDesc->Format = d3d11Desc.Format;
|
||||
|
||||
switch (d3d11Desc.ViewDimension) {
|
||||
case D3D11_DSV_DIMENSION_UNKNOWN:
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE1D:
|
||||
pDesc->Texture1D.MipSlice = d3d11Desc.Texture1D.MipSlice;
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE1DARRAY:
|
||||
pDesc->Texture1DArray.MipSlice = d3d11Desc.Texture1DArray.MipSlice;
|
||||
pDesc->Texture1DArray.FirstArraySlice = d3d11Desc.Texture1DArray.FirstArraySlice;
|
||||
pDesc->Texture1DArray.ArraySize = d3d11Desc.Texture1DArray.ArraySize;
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE2D:
|
||||
pDesc->Texture2D.MipSlice = d3d11Desc.Texture2D.MipSlice;
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE2DARRAY:
|
||||
pDesc->Texture2DArray.MipSlice = d3d11Desc.Texture2DArray.MipSlice;
|
||||
pDesc->Texture2DArray.FirstArraySlice = d3d11Desc.Texture2DArray.FirstArraySlice;
|
||||
pDesc->Texture2DArray.ArraySize = d3d11Desc.Texture2DArray.ArraySize;
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE2DMS:
|
||||
break;
|
||||
|
||||
case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY:
|
||||
pDesc->Texture2DMSArray.FirstArraySlice = d3d11Desc.Texture2DMSArray.FirstArraySlice;
|
||||
pDesc->Texture2DMSArray.ArraySize = d3d11Desc.Texture2DMSArray.ArraySize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
58
src/d3d10/d3d10_view_dsv.h
Normal file
58
src/d3d10/d3d10_view_dsv.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d10_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11Device;
|
||||
class D3D11DepthStencilView;
|
||||
|
||||
class D3D10DepthStencilView : public ID3D10DepthStencilView {
|
||||
|
||||
public:
|
||||
|
||||
D3D10DepthStencilView(D3D11DepthStencilView* pParent)
|
||||
: m_d3d11(pParent) { }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
REFIID riid,
|
||||
void** ppvObject);
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice(
|
||||
ID3D10Device** ppDevice);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT* pDataSize,
|
||||
void* pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT DataSize,
|
||||
const void* pData);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
|
||||
REFGUID guid,
|
||||
const IUnknown* pData);
|
||||
|
||||
void STDMETHODCALLTYPE GetResource(
|
||||
ID3D10Resource** ppResource);
|
||||
|
||||
void STDMETHODCALLTYPE GetDesc(
|
||||
D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc);
|
||||
|
||||
D3D11DepthStencilView* GetD3D11Iface() {
|
||||
return m_d3d11;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
D3D11DepthStencilView* m_d3d11;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
ID3D11Resource* pResource,
|
||||
const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc)
|
||||
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
|
||||
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc), m_d3d10(this) {
|
||||
ResourceAddRefPrivate(m_resource);
|
||||
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
@ -100,6 +100,13 @@ namespace dxvk {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ID3D10DeviceChild)
|
||||
|| riid == __uuidof(ID3D10View)
|
||||
|| riid == __uuidof(ID3D10DepthStencilView)) {
|
||||
*ppvObject = ref(this);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Logger::warn("D3D11DepthStencilView::QueryInterface: Unknown interface query");
|
||||
Logger::warn(str::format(riid));
|
||||
return E_NOINTERFACE;
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "../dxvk/dxvk_device.h"
|
||||
|
||||
#include "../d3d10/d3d10_view_dsv.h"
|
||||
|
||||
#include "d3d11_device_child.h"
|
||||
|
||||
namespace dxvk {
|
||||
@ -60,6 +62,10 @@ namespace dxvk {
|
||||
return VK_IMAGE_LAYOUT_GENERAL;
|
||||
}
|
||||
}
|
||||
|
||||
D3D10DepthStencilView* GetD3D10Iface() {
|
||||
return &m_d3d10;
|
||||
}
|
||||
|
||||
static HRESULT GetDescFromResource(
|
||||
ID3D11Resource* pResource,
|
||||
@ -75,6 +81,7 @@ namespace dxvk {
|
||||
ID3D11Resource* m_resource;
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC m_desc;
|
||||
Rc<DxvkImageView> m_view;
|
||||
D3D10DepthStencilView m_d3d10;
|
||||
|
||||
};
|
||||
|
||||
|
@ -8,6 +8,7 @@ d3d10_src = [
|
||||
'../d3d10/d3d10_sampler.cpp',
|
||||
'../d3d10/d3d10_texture.cpp',
|
||||
'../d3d10/d3d10_util.cpp',
|
||||
'../d3d10/d3d10_view_dsv.cpp',
|
||||
'../d3d10/d3d10_view_rtv.cpp',
|
||||
'../d3d10/d3d10_view_srv.cpp',
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user