mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +01:00
[dxvk] Introduce GetContext method to retrieve immediate context.
Bypasses vtable hooks when retrieving the immediate context internally. Remaining uses of GetImmediateContext are fine since those only interact with public methods.
This commit is contained in:
parent
990a720525
commit
e074d83d0b
@ -421,7 +421,11 @@ namespace dxvk {
|
||||
D3D10Device* GetD3D10Interface() const {
|
||||
return m_d3d10Device;
|
||||
}
|
||||
|
||||
|
||||
D3D11ImmediateContext* GetContext() const {
|
||||
return m_context.ptr();
|
||||
}
|
||||
|
||||
bool Is11on12Device() const;
|
||||
|
||||
static D3D_FEATURE_LEVEL GetMaxFeatureLevel(
|
||||
|
@ -150,11 +150,8 @@ namespace dxvk {
|
||||
HRESULT D3D11GDISurface::CreateReadbackResource() {
|
||||
auto tex = GetCommonTexture(m_resource);
|
||||
|
||||
Com<ID3D11Device> device;
|
||||
Com<ID3D11DeviceContext> context;
|
||||
|
||||
Com<ID3D11Device> device;
|
||||
m_resource->GetDevice(&device);
|
||||
device->GetImmediateContext(&context);
|
||||
|
||||
D3D11_RESOURCE_DIMENSION dim = { };
|
||||
m_resource->GetType(&dim);
|
||||
|
@ -75,21 +75,15 @@ namespace dxvk {
|
||||
const VkImageSubresourceRange* pSubresources,
|
||||
VkImageLayout OldLayout,
|
||||
VkImageLayout NewLayout) {
|
||||
Com<ID3D11DeviceContext> deviceContext = nullptr;
|
||||
m_device->GetImmediateContext(&deviceContext);
|
||||
|
||||
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
||||
|
||||
auto immediateContext = m_device->GetContext();
|
||||
|
||||
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());
|
||||
auto immediateContext = m_device->GetContext();
|
||||
immediateContext->Flush();
|
||||
immediateContext->SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
|
||||
}
|
||||
|
@ -112,9 +112,6 @@ namespace dxvk {
|
||||
Com<ID3D12DXVKInteropDevice> interopDevice;
|
||||
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
|
||||
|
||||
Com<ID3D11DeviceContext> context;
|
||||
m_device->GetImmediateContext(&context);
|
||||
|
||||
for (uint32_t i = 0; i < ResourceCount; i++) {
|
||||
D3D11_ON_12_RESOURCE_INFO info;
|
||||
|
||||
@ -125,7 +122,7 @@ namespace dxvk {
|
||||
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.OutputState, &layout);
|
||||
static_cast<D3D11ImmediateContext*>(context.ptr())->Release11on12Resource(ppResources[i], layout);
|
||||
m_device->GetContext()->Release11on12Resource(ppResources[i], layout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,9 +133,6 @@ namespace dxvk {
|
||||
Com<ID3D12DXVKInteropDevice> interopDevice;
|
||||
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
|
||||
|
||||
Com<ID3D11DeviceContext> context;
|
||||
m_device->GetImmediateContext(&context);
|
||||
|
||||
for (uint32_t i = 0; i < ResourceCount; i++) {
|
||||
D3D11_ON_12_RESOURCE_INFO info;
|
||||
|
||||
@ -149,7 +143,7 @@ namespace dxvk {
|
||||
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.InputState, &layout);
|
||||
static_cast<D3D11ImmediateContext*>(context.ptr())->Acquire11on12Resource(ppResources[i], layout);
|
||||
m_device->GetContext()->Acquire11on12Resource(ppResources[i], layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,11 +335,8 @@ namespace dxvk {
|
||||
|
||||
|
||||
HRESULT D3D11SwapChain::PresentImage(UINT SyncInterval) {
|
||||
Com<ID3D11DeviceContext> deviceContext = nullptr;
|
||||
m_parent->GetImmediateContext(&deviceContext);
|
||||
|
||||
// Flush pending rendering commands before
|
||||
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
||||
auto immediateContext = m_parent->GetContext();
|
||||
immediateContext->EndFrame();
|
||||
immediateContext->Flush();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user