forked from doitsujin/dxvk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3d11_interop.cpp
107 lines (74 loc) · 2.94 KB
/
d3d11_interop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "d3d11_context_imm.h"
#include "d3d11_interop.h"
#include "d3d11_device.h"
#include "../dxvk/dxvk_adapter.h"
#include "../dxvk/dxvk_device.h"
#include "../dxvk/dxvk_instance.h"
namespace dxvk {
D3D11VkInterop::D3D11VkInterop(
IDXGIObject* pContainer,
D3D11Device* pDevice)
: m_container (pContainer),
m_device (pDevice) { }
D3D11VkInterop::~D3D11VkInterop() {
}
ULONG STDMETHODCALLTYPE D3D11VkInterop::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11VkInterop::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE D3D11VkInterop::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
void STDMETHODCALLTYPE D3D11VkInterop::GetVulkanHandles(
VkInstance* pInstance,
VkPhysicalDevice* pPhysDev,
VkDevice* pDevice) {
auto device = m_device->GetDXVKDevice();
auto adapter = device->adapter();
auto instance = device->instance();
if (pDevice != nullptr)
*pDevice = device->handle();
if (pPhysDev != nullptr)
*pPhysDev = adapter->handle();
if (pInstance != nullptr)
*pInstance = instance->handle();
}
void STDMETHODCALLTYPE D3D11VkInterop::GetSubmissionQueue(
VkQueue* pQueue,
uint32_t* pQueueFamilyIndex) {
auto device = static_cast<D3D11Device*>(m_device)->GetDXVKDevice();
DxvkDeviceQueue queue = device->queues().graphics;
if (pQueue != nullptr)
*pQueue = queue.queueHandle;
if (pQueueFamilyIndex != nullptr)
*pQueueFamilyIndex = queue.queueFamily;
}
void STDMETHODCALLTYPE D3D11VkInterop::TransitionSurfaceLayout(
IDXGIVkInteropSurface* pSurface,
const VkImageSubresourceRange* pSubresources,
VkImageLayout OldLayout,
VkImageLayout NewLayout) {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
immediateContext->TransitionSurfaceLayout(
pSurface, pSubresources, OldLayout, NewLayout);
}
void STDMETHODCALLTYPE D3D11VkInterop::FlushRenderingCommands() {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
immediateContext->Flush();
immediateContext->SynchronizeCsThread();
}
void STDMETHODCALLTYPE D3D11VkInterop::LockSubmissionQueue() {
m_device->GetDXVKDevice()->lockSubmission();
}
void STDMETHODCALLTYPE D3D11VkInterop::ReleaseSubmissionQueue() {
m_device->GetDXVKDevice()->unlockSubmission();
}
}