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

[d3d11] Add stub IDXGIKeyedMutex interface. (#3601)

Partially based on a patch by Derek Lesho.

Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
This commit is contained in:
gofman 2023-08-07 09:23:32 -06:00 committed by GitHub
parent 549bd86f03
commit cbda22a040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 170 additions and 4 deletions

View File

@ -6,13 +6,101 @@
namespace dxvk { namespace dxvk {
D3D11DXGIResource::D3D11DXGIResource( D3D11DXGIKeyedMutex::D3D11DXGIKeyedMutex(
ID3D11Resource* pResource) ID3D11Resource* pResource)
: m_resource(pResource) { : m_resource(pResource) {
} }
D3D11DXGIKeyedMutex::~D3D11DXGIKeyedMutex() {
}
ULONG STDMETHODCALLTYPE D3D11DXGIKeyedMutex::AddRef() {
return m_resource->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11DXGIKeyedMutex::Release() {
return m_resource->Release();
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_resource->QueryInterface(riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::GetPrivateData(
REFGUID Name,
UINT* pDataSize,
void* pData) {
return m_resource->GetPrivateData(Name, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::SetPrivateData(
REFGUID Name,
UINT DataSize,
const void* pData) {
return m_resource->SetPrivateData(Name, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::SetPrivateDataInterface(
REFGUID Name,
const IUnknown* pUnknown) {
return m_resource->SetPrivateDataInterface(Name, pUnknown);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::GetParent(
REFIID riid,
void** ppParent) {
return GetDevice(riid, ppParent);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::GetDevice(
REFIID riid,
void** ppDevice) {
Com<ID3D11Device> device;
m_resource->GetDevice(&device);
return device->QueryInterface(riid, ppDevice);
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::AcquireSync(
UINT64 Key,
DWORD dwMilliseconds) {
if (!m_warned) {
m_warned = true;
Logger::err("D3D11DXGIKeyedMutex::AcquireSync: Stub");
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D11DXGIKeyedMutex::ReleaseSync(
UINT64 Key) {
if (!m_warned) {
m_warned = true;
Logger::err("D3D11DXGIKeyedMutex::AcquireSync: Stub");
}
return S_OK;
}
D3D11DXGIResource::D3D11DXGIResource(
ID3D11Resource* pResource)
: m_resource(pResource),
m_keyedMutex(pResource) {
}
D3D11DXGIResource::~D3D11DXGIResource() { D3D11DXGIResource::~D3D11DXGIResource() {
} }
@ -176,6 +264,16 @@ namespace dxvk {
} }
HRESULT D3D11DXGIResource::GetKeyedMutex(
void **ppvObject) {
auto texture = GetCommonTexture(m_resource);
if (texture == nullptr || !(texture->Desc()->MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX))
return E_NOINTERFACE;
*ppvObject = ref(&m_keyedMutex);
return S_OK;
}
HRESULT GetResource11on12Info( HRESULT GetResource11on12Info(
ID3D11Resource* pResource, ID3D11Resource* pResource,
D3D11_ON_12_RESOURCE_INFO* p11on12Info) { D3D11_ON_12_RESOURCE_INFO* p11on12Info) {

View File

@ -22,6 +22,62 @@ namespace dxvk {
}; };
/**
* \brief IDXGIKeyedMutex implementation
*/
class D3D11DXGIKeyedMutex : public IDXGIKeyedMutex {
public:
D3D11DXGIKeyedMutex(
ID3D11Resource* pResource);
~D3D11DXGIKeyedMutex();
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE GetPrivateData(
REFGUID Name,
UINT* pDataSize,
void* pData);
HRESULT STDMETHODCALLTYPE SetPrivateData(
REFGUID Name,
UINT DataSize,
const void* pData);
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
REFGUID Name,
const IUnknown* pUnknown);
HRESULT STDMETHODCALLTYPE GetParent(
REFIID riid,
void** ppParent);
HRESULT STDMETHODCALLTYPE GetDevice(
REFIID riid,
void** ppDevice);
HRESULT STDMETHODCALLTYPE AcquireSync(
UINT64 Key,
DWORD dwMilliseconds);
HRESULT STDMETHODCALLTYPE ReleaseSync(
UINT64 Key);
private:
ID3D11Resource* m_resource;
bool m_warned = false;
};
/** /**
* \brief IDXGIResource implementation for D3D11 resources * \brief IDXGIResource implementation for D3D11 resources
*/ */
@ -86,9 +142,12 @@ namespace dxvk {
UINT index, UINT index,
IDXGISurface2** ppSurface); IDXGISurface2** ppSurface);
HRESULT GetKeyedMutex(void **ppvObject);
private: private:
ID3D11Resource* m_resource; ID3D11Resource* m_resource;
D3D11DXGIKeyedMutex m_keyedMutex;
}; };

View File

@ -1147,6 +1147,9 @@ namespace dxvk {
return S_OK; return S_OK;
} }
if (riid == __uuidof(IDXGIKeyedMutex))
return m_resource.GetKeyedMutex(ppvObject);
if (riid == __uuidof(IDXGIVkInteropSurface)) { if (riid == __uuidof(IDXGIVkInteropSurface)) {
*ppvObject = ref(&m_interop); *ppvObject = ref(&m_interop);
return S_OK; return S_OK;
@ -1308,6 +1311,9 @@ namespace dxvk {
return S_OK; return S_OK;
} }
if (riid == __uuidof(IDXGIKeyedMutex))
return m_resource.GetKeyedMutex(ppvObject);
if (riid == __uuidof(IDXGIVkInteropSurface)) { if (riid == __uuidof(IDXGIVkInteropSurface)) {
*ppvObject = ref(&m_interop); *ppvObject = ref(&m_interop);
return S_OK; return S_OK;
@ -1419,6 +1425,9 @@ namespace dxvk {
return S_OK; return S_OK;
} }
if (riid == __uuidof(IDXGIKeyedMutex))
return m_resource.GetKeyedMutex(ppvObject);
if (riid == __uuidof(IDXGIVkInteropSurface)) { if (riid == __uuidof(IDXGIVkInteropSurface)) {
*ppvObject = ref(&m_interop); *ppvObject = ref(&m_interop);
return S_OK; return S_OK;