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

[d3d10] Implement D3D10ShaderResourceView

This commit is contained in:
Philip Rebohle 2018-08-11 23:19:28 +02:00
parent 04fa062eba
commit 0052ff236b
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 192 additions and 6 deletions

View File

@ -218,8 +218,21 @@ namespace dxvk {
ID3D10Resource* pResource,
const D3D10_SHADER_RESOURCE_VIEW_DESC* pDesc,
ID3D10ShaderResourceView** ppSRView) {
Logger::err("D3D10Device::CreateShaderResourceView: Not implemented");
return E_NOTIMPL;
Com<ID3D11Resource> d3d11Resource;
GetD3D11Resource(pResource, &d3d11Resource);
ID3D11ShaderResourceView* d3d11Srv = nullptr;
HRESULT hr = m_device->CreateShaderResourceView(d3d11Resource.ptr(),
reinterpret_cast<const D3D11_SHADER_RESOURCE_VIEW_DESC*>(pDesc),
ppSRView ? &d3d11Srv : nullptr);
if (FAILED(hr))
return hr;
if (ppSRView != nullptr) {
*ppSRView = static_cast<D3D11ShaderResourceView*>(d3d11Srv)->GetD3D10Iface();
return S_OK;
} return S_FALSE;
}
@ -227,8 +240,21 @@ namespace dxvk {
ID3D10Resource* pResource,
const D3D10_SHADER_RESOURCE_VIEW_DESC1* pDesc,
ID3D10ShaderResourceView1** ppSRView) {
Logger::err("D3D10Device::CreateShaderResourceView1: Not implemented");
return E_NOTIMPL;
Com<ID3D11Resource> d3d11Resource;
GetD3D11Resource(pResource, &d3d11Resource);
ID3D11ShaderResourceView* d3d11Srv = nullptr;
HRESULT hr = m_device->CreateShaderResourceView(d3d11Resource.ptr(),
reinterpret_cast<const D3D11_SHADER_RESOURCE_VIEW_DESC*>(pDesc),
ppSRView ? &d3d11Srv : nullptr);
if (FAILED(hr))
return hr;
if (ppSRView != nullptr) {
*ppSRView = static_cast<D3D11ShaderResourceView*>(d3d11Srv)->GetD3D10Iface();
return S_OK;
} return S_FALSE;
}

View File

@ -0,0 +1,83 @@
#include "d3d10_view_srv.h"
#include "../d3d11/d3d11_device.h"
#include "../d3d11/d3d11_view_srv.h"
namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D10ShaderResourceView::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_d3d11->QueryInterface(riid, ppvObject);
}
ULONG STDMETHODCALLTYPE D3D10ShaderResourceView::AddRef() {
return m_d3d11->AddRef();
}
ULONG STDMETHODCALLTYPE D3D10ShaderResourceView::Release() {
return m_d3d11->Release();
}
void STDMETHODCALLTYPE D3D10ShaderResourceView::GetDevice(
ID3D10Device** ppDevice) {
GetD3D10Device(m_d3d11, ppDevice);
}
HRESULT STDMETHODCALLTYPE D3D10ShaderResourceView::GetPrivateData(
REFGUID guid,
UINT* pDataSize,
void* pData) {
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10ShaderResourceView::SetPrivateData(
REFGUID guid,
UINT DataSize,
const void* pData) {
return m_d3d11->SetPrivateData(guid, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10ShaderResourceView::SetPrivateDataInterface(
REFGUID guid,
const IUnknown* pData) {
return m_d3d11->SetPrivateDataInterface(guid, pData);
}
void STDMETHODCALLTYPE D3D10ShaderResourceView::GetResource(
ID3D10Resource** ppResource) {
GetD3D10ResourceFromView(m_d3d11, ppResource);
}
void STDMETHODCALLTYPE D3D10ShaderResourceView::GetDesc(
D3D10_SHADER_RESOURCE_VIEW_DESC* pDesc) {
static_assert(sizeof(D3D10_SHADER_RESOURCE_VIEW_DESC) ==
sizeof(D3D11_SHADER_RESOURCE_VIEW_DESC));
m_d3d11->GetDesc(reinterpret_cast<D3D11_SHADER_RESOURCE_VIEW_DESC*>(pDesc));
if (pDesc->ViewDimension > D3D10_SRV_DIMENSION_TEXTURECUBE)
pDesc->ViewDimension = D3D10_SRV_DIMENSION_UNKNOWN;
}
void STDMETHODCALLTYPE D3D10ShaderResourceView::GetDesc1(
D3D10_SHADER_RESOURCE_VIEW_DESC1* pDesc) {
static_assert(sizeof(D3D10_SHADER_RESOURCE_VIEW_DESC1) ==
sizeof(D3D11_SHADER_RESOURCE_VIEW_DESC));
m_d3d11->GetDesc(reinterpret_cast<D3D11_SHADER_RESOURCE_VIEW_DESC*>(pDesc));
if (pDesc->ViewDimension > D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY)
pDesc->ViewDimension = D3D10_1_SRV_DIMENSION_UNKNOWN;
}
}

View File

@ -0,0 +1,61 @@
#pragma once
#include "d3d10_util.h"
namespace dxvk {
class D3D11Device;
class D3D11ShaderResourceView;
class D3D10ShaderResourceView : public ID3D10ShaderResourceView1 {
public:
D3D10ShaderResourceView(D3D11ShaderResourceView* 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_SHADER_RESOURCE_VIEW_DESC* pDesc);
void STDMETHODCALLTYPE GetDesc1(
D3D10_SHADER_RESOURCE_VIEW_DESC1* pDesc);
D3D11ShaderResourceView* GetD3D11Iface() {
return m_d3d11;
}
private:
D3D11ShaderResourceView* m_d3d11;
};
}

View File

@ -10,7 +10,7 @@ namespace dxvk {
D3D11Device* pDevice,
ID3D11Resource* pResource,
const D3D11_SHADER_RESOURCE_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);
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
@ -177,6 +177,14 @@ namespace dxvk {
return S_OK;
}
if (riid == __uuidof(ID3D10DeviceChild)
|| riid == __uuidof(ID3D10View)
|| riid == __uuidof(ID3D10ShaderResourceView)
|| riid == __uuidof(ID3D10ShaderResourceView1)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11ShaderResourceView::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
return E_NOINTERFACE;

View File

@ -2,6 +2,8 @@
#include "../dxvk/dxvk_device.h"
#include "../d3d10/d3d10_view_srv.h"
#include "d3d11_device_child.h"
namespace dxvk {
@ -43,6 +45,10 @@ namespace dxvk {
Rc<DxvkImageView> GetImageView() const {
return m_imageView;
}
D3D10ShaderResourceView* GetD3D10Iface() {
return &m_d3d10;
}
static HRESULT GetDescFromResource(
ID3D11Resource* pResource,
@ -59,7 +65,8 @@ namespace dxvk {
D3D11_SHADER_RESOURCE_VIEW_DESC m_desc;
Rc<DxvkBufferView> m_bufferView;
Rc<DxvkImageView> m_imageView;
D3D10ShaderResourceView m_d3d10;
};
}

View File

@ -8,6 +8,7 @@ d3d10_src = [
'../d3d10/d3d10_sampler.cpp',
'../d3d10/d3d10_texture.cpp',
'../d3d10/d3d10_util.cpp',
'../d3d10/d3d10_view_srv.cpp',
]
d3d11_src = [