Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d9] Stub out D3D9On12 interfaces #3448

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/d3d9/d3d9.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ EXPORTS
DXVK_UnRegisterAnnotation @28258 NONAME

Direct3D9ForceHybridEnumeration @16 NONAME PRIVATE

Direct3DCreate9On12 @20
Direct3DCreate9On12Ex @21
2 changes: 2 additions & 0 deletions src/d3d9/d3d9.sym
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
DXVK_RegisterAnnotation;
DXVK_UnRegisterAnnotation;
Direct3D9ForceHybridEnumeration;
Direct3DCreate9On12;
Direct3DCreate9On12Ex;

local:
*;
Expand Down
8 changes: 7 additions & 1 deletion src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace dxvk {
, m_isSWVP ( (BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) ? true : false )
, m_csThread ( dxvkDevice, dxvkDevice->createContext(DxvkContextType::Primary) )
, m_csChunk ( AllocCsChunk() )
, m_d3d9Interop ( this ) {
, m_d3d9Interop ( this )
, m_d3d9On12 ( this ) {
// If we can SWVP, then we use an extended constant set
// as SWVP has many more slots available than HWVP.
bool canSWVP = CanSWVP();
Expand Down Expand Up @@ -197,6 +198,11 @@ namespace dxvk {
return S_OK;
}

if (riid == __uuidof(IDirect3DDevice9On12)) {
*ppvObject = ref(&m_d3d9On12);
return S_OK;
}

// We want to ignore this if the extended device is queried and we weren't made extended.
if (riid == __uuidof(IDirect3DDevice9Ex))
return E_NOINTERFACE;
Expand Down
2 changes: 2 additions & 0 deletions src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "d3d9_spec_constants.h"
#include "d3d9_interop.h"
#include "d3d9_on_12.h"

#include <unordered_set>
#include <vector>
Expand Down Expand Up @@ -1370,6 +1371,7 @@ namespace dxvk {
Direct3DState9 m_state;

D3D9VkInteropDevice m_d3d9Interop;
D3D9On12 m_d3d9On12;
};

}
47 changes: 47 additions & 0 deletions src/d3d9/d3d9_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,50 @@ typedef struct _D3DDEVINFO_RESOURCEMANAGER
#define D3DPOOL_MANAGED_EX D3DPOOL(6)

using D3D9VertexElements = std::vector<D3DVERTEXELEMENT9>;

/////////////////////
// D3D9On12 content
/////////////////////

#include <d3d12.h>

#define MAX_D3D9ON12_QUEUES 2

struct D3D9ON12_ARGS {
BOOL Enable9On12;
IUnknown* pD3D12Device;
IUnknown* ppD3D12Queues[MAX_D3D9ON12_QUEUES];
UINT NumQueues;
UINT NodeMask;
};

extern "C" {

// Ordinal 20
typedef IDirect3D9* (WINAPI* PFN_Direct3DCreate9On12)(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count);
IDirect3D9* WINAPI Direct3DCreate9On12(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count);

// Ordinal 21
typedef HRESULT(WINAPI* PFN_Direct3DCreate9On12Ex)(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count, IDirect3D9Ex** output);
HRESULT WINAPI Direct3DCreate9On12Ex(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count, IDirect3D9Ex** output);

}

MIDL_INTERFACE("e7fda234-b589-4049-940d-8878977531c8")
IDirect3DDevice9On12 : public IUnknown {

virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** object) = 0;
virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
virtual ULONG STDMETHODCALLTYPE Release() = 0;

virtual HRESULT STDMETHODCALLTYPE GetD3D12Device(REFIID riid, void** object) = 0;
virtual HRESULT STDMETHODCALLTYPE UnwrapUnderlyingResource(IDirect3DResource9* resource, ID3D12CommandQueue* command_queue, REFIID riid, void** object) = 0;
virtual HRESULT STDMETHODCALLTYPE ReturnUnderlyingResource(IDirect3DResource9* resource, UINT num_sync, UINT64* signal_values, ID3D12Fence** fences) = 0;
};

#ifdef _MSC_VER
struct __declspec(uuid("e7fda234-b589-4049-940d-8878977531c8")) IDirect3DDevice9On12;
#else
__CRT_UUID_DECL(IDirect3DDevice9On12, 0xe7fda234,0xb589,0x4049,0x94,0x0d,0x88,0x78,0x97,0x75,0x31,0xc8);
#endif

10 changes: 10 additions & 0 deletions src/d3d9/d3d9_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,14 @@ extern "C" {
DLLEXPORT void __stdcall Direct3D9ForceHybridEnumeration(UINT uHybrid) {
}

DLLEXPORT IDirect3D9* __stdcall Direct3DCreate9On12(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count) {
dxvk::Logger::warn("Direct3DCreate9On12: 9On12 functionality is unimplemented.");
return Direct3DCreate9(sdk_version);
}

DLLEXPORT HRESULT __stdcall Direct3DCreate9On12Ex(UINT sdk_version, D3D9ON12_ARGS* override_list, UINT override_entry_count, IDirect3D9Ex** output) {
dxvk::Logger::warn("Direct3DCreate9On12Ex: 9On12 functionality is unimplemented.");
return Direct3DCreate9Ex(sdk_version, output);
}

}
37 changes: 37 additions & 0 deletions src/d3d9/d3d9_on_12.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "d3d9_on_12.h"

#include "d3d9_device.h"

namespace dxvk {

D3D9On12::D3D9On12(D3D9DeviceEx* device)
: m_device(device) {

}

HRESULT STDMETHODCALLTYPE D3D9On12::QueryInterface(REFIID riid, void** object) {
return m_device->QueryInterface(riid, object);
}
ULONG STDMETHODCALLTYPE D3D9On12::AddRef() {
return m_device->AddRef();
}
ULONG STDMETHODCALLTYPE D3D9On12::Release() {
return m_device->Release();
}

HRESULT STDMETHODCALLTYPE D3D9On12::GetD3D12Device(REFIID riid, void** object) {
InitReturnPtr(object);

Logger::err("D3D9On12::GetD3D12Device: Stub");
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE D3D9On12::UnwrapUnderlyingResource(IDirect3DResource9* resource, ID3D12CommandQueue* command_queue, REFIID riid, void** object) {
Logger::err("D3D9On12::GetD3D12Device: UnwrapUnderlyingResource: Stub");
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE D3D9On12::ReturnUnderlyingResource(IDirect3DResource9* resource, UINT num_sync, UINT64* signal_values, ID3D12Fence** fences) {
Logger::err("D3D9On12::GetD3D12Device: ReturnUnderlyingResource: Stub");
return E_NOINTERFACE;
}

}
29 changes: 29 additions & 0 deletions src/d3d9/d3d9_on_12.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "d3d9_include.h"

namespace dxvk {

class D3D9DeviceEx;

class D3D9On12 final : public IDirect3DDevice9On12 {

public:

D3D9On12(D3D9DeviceEx* device);

HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** object);
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();

HRESULT STDMETHODCALLTYPE GetD3D12Device(REFIID riid, void** object);
HRESULT STDMETHODCALLTYPE UnwrapUnderlyingResource(IDirect3DResource9* resource, ID3D12CommandQueue* command_queue, REFIID riid, void** object);
HRESULT STDMETHODCALLTYPE ReturnUnderlyingResource(IDirect3DResource9* resource, UINT num_sync, UINT64* signal_values, ID3D12Fence** fences);

private:

D3D9DeviceEx* m_device;

};

}
3 changes: 2 additions & 1 deletion src/d3d9/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ d3d9_src = [
'd3d9_annotation.cpp',
'd3d9_mem.cpp',
'd3d9_window.cpp',
'd3d9_interop.cpp'
'd3d9_interop.cpp',
'd3d9_on_12.cpp'
]

d3d9_ld_args = []
Expand Down