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

[d3d10] Implement D3D10DepthStencilState

This commit is contained in:
Philip Rebohle 2018-08-11 22:31:12 +02:00
parent 2b5272134c
commit 68bfacfcaa
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 145 additions and 6 deletions

View File

@ -0,0 +1,60 @@
#include "d3d10_depth_stencil.h"
#include "../d3d11/d3d11_depth_stencil.h"
#include "../d3d11/d3d11_device.h"
namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D10DepthStencilState::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_d3d11->QueryInterface(riid, ppvObject);
}
ULONG STDMETHODCALLTYPE D3D10DepthStencilState::AddRef() {
return m_d3d11->AddRef();
}
ULONG STDMETHODCALLTYPE D3D10DepthStencilState::Release() {
return m_d3d11->Release();
}
void STDMETHODCALLTYPE D3D10DepthStencilState::GetDevice(
ID3D10Device** ppDevice) {
GetD3D10Device(m_d3d11, ppDevice);
}
HRESULT STDMETHODCALLTYPE D3D10DepthStencilState::GetPrivateData(
REFGUID guid,
UINT* pDataSize,
void* pData) {
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10DepthStencilState::SetPrivateData(
REFGUID guid,
UINT DataSize,
const void* pData) {
return m_d3d11->SetPrivateData(guid, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10DepthStencilState::SetPrivateDataInterface(
REFGUID guid,
const IUnknown* pData) {
return m_d3d11->SetPrivateDataInterface(guid, pData);
}
void STDMETHODCALLTYPE D3D10DepthStencilState::GetDesc(
D3D10_DEPTH_STENCIL_DESC* pDesc) {
static_assert(sizeof(D3D10_DEPTH_STENCIL_DESC) == sizeof(D3D11_DEPTH_STENCIL_DESC));
m_d3d11->GetDesc(reinterpret_cast<D3D11_DEPTH_STENCIL_DESC*>(pDesc));
}
}

View File

@ -0,0 +1,55 @@
#pragma once
#include "d3d10_util.h"
namespace dxvk {
class D3D11DepthStencilState;
class D3D11Device;
class D3D10DepthStencilState : public ID3D10DepthStencilState {
public:
D3D10DepthStencilState(D3D11DepthStencilState* 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 GetDesc(
D3D10_DEPTH_STENCIL_DESC* pDesc);
D3D11DepthStencilState* GetD3D11Iface() {
return m_d3d11;
}
private:
D3D11DepthStencilState* m_d3d11;
};
}

View File

@ -373,8 +373,20 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D10Device::CreateDepthStencilState(
const D3D10_DEPTH_STENCIL_DESC* pDepthStencilDesc,
ID3D10DepthStencilState** ppDepthStencilState) {
Logger::err("D3D10Device::CreateDepthStencilState: Not implemented");
return E_NOTIMPL;
InitReturnPtr(ppDepthStencilState);
ID3D11DepthStencilState* d3d11DepthStencilState = nullptr;
HRESULT hr = m_device->CreateDepthStencilState(
reinterpret_cast<const D3D11_DEPTH_STENCIL_DESC*>(pDepthStencilDesc),
ppDepthStencilState ? &d3d11DepthStencilState : nullptr);
if (FAILED(hr))
return hr;
if (ppDepthStencilState != nullptr) {
*ppDepthStencilState = static_cast<D3D11DepthStencilState*>(d3d11DepthStencilState)->GetD3D10Iface();
return S_OK;
} return S_FALSE;
}

View File

@ -6,7 +6,7 @@ namespace dxvk {
D3D11DepthStencilState::D3D11DepthStencilState(
D3D11Device* device,
const D3D11_DEPTH_STENCIL_DESC& desc)
: m_device(device), m_desc(desc) {
: m_device(device), m_desc(desc), m_d3d10(this) {
m_state.enableDepthTest = desc.DepthEnable;
m_state.enableDepthWrite = desc.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ALL;
m_state.enableStencilTest = desc.StencilEnable;
@ -30,6 +30,12 @@ namespace dxvk {
*ppvObject = ref(this);
return S_OK;
}
if (riid == __uuidof(ID3D10DeviceChild)
|| riid == __uuidof(ID3D10DepthStencilState)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11DepthStencilState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -1,6 +1,8 @@
#pragma once
#include <dxvk_device.h>
#include "../dxvk/dxvk_device.h"
#include "../d3d10/d3d10_depth_stencil.h"
#include "d3d11_device_child.h"
#include "d3d11_util.h"
@ -33,18 +35,21 @@ namespace dxvk {
void BindToContext(
const Rc<DxvkContext>& ctx);
D3D10DepthStencilState* GetD3D10Iface() {
return &m_d3d10;
}
static D3D11_DEPTH_STENCIL_DESC DefaultDesc();
static HRESULT NormalizeDesc(
D3D11_DEPTH_STENCIL_DESC* pDesc);
private:
D3D11Device* const m_device;
D3D11_DEPTH_STENCIL_DESC m_desc;
DxvkDepthStencilState m_state;
D3D10DepthStencilState m_d3d10;
VkStencilOpState DecodeStencilOpState(
const D3D11_DEPTH_STENCILOP_DESC& StencilDesc,

View File

@ -1,6 +1,7 @@
d3d10_src = [
'../d3d10/d3d10_blend.cpp',
'../d3d10/d3d10_buffer.cpp',
'../d3d10/d3d10_depth_stencil.cpp',
'../d3d10/d3d10_device.cpp',
'../d3d10/d3d10_input_layout.cpp',
'../d3d10/d3d10_sampler.cpp',