diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index f8ad108e..7a44b5ad 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -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( diff --git a/src/d3d11/d3d11_gdi.cpp b/src/d3d11/d3d11_gdi.cpp index bd1fa90b..e9f7bf73 100644 --- a/src/d3d11/d3d11_gdi.cpp +++ b/src/d3d11/d3d11_gdi.cpp @@ -150,11 +150,8 @@ namespace dxvk { HRESULT D3D11GDISurface::CreateReadbackResource() { auto tex = GetCommonTexture(m_resource); - Com device; - Com context; - + Com device; m_resource->GetDevice(&device); - device->GetImmediateContext(&context); D3D11_RESOURCE_DIMENSION dim = { }; m_resource->GetType(&dim); diff --git a/src/d3d11/d3d11_interop.cpp b/src/d3d11/d3d11_interop.cpp index 8fa50288..04fef383 100644 --- a/src/d3d11/d3d11_interop.cpp +++ b/src/d3d11/d3d11_interop.cpp @@ -75,21 +75,15 @@ namespace dxvk { const VkImageSubresourceRange* pSubresources, VkImageLayout OldLayout, VkImageLayout NewLayout) { - Com deviceContext = nullptr; - m_device->GetImmediateContext(&deviceContext); - - auto immediateContext = static_cast(deviceContext.ptr()); - + auto immediateContext = m_device->GetContext(); + immediateContext->TransitionSurfaceLayout( pSurface, pSubresources, OldLayout, NewLayout); } void STDMETHODCALLTYPE D3D11VkInterop::FlushRenderingCommands() { - Com deviceContext = nullptr; - m_device->GetImmediateContext(&deviceContext); - - auto immediateContext = static_cast(deviceContext.ptr()); + auto immediateContext = m_device->GetContext(); immediateContext->Flush(); immediateContext->SynchronizeCsThread(DxvkCsThread::SynchronizeAll); } diff --git a/src/d3d11/d3d11_on_12.cpp b/src/d3d11/d3d11_on_12.cpp index 2c5841a9..7393021c 100644 --- a/src/d3d11/d3d11_on_12.cpp +++ b/src/d3d11/d3d11_on_12.cpp @@ -112,9 +112,6 @@ namespace dxvk { Com interopDevice; m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast(&interopDevice)); - Com 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(context.ptr())->Release11on12Resource(ppResources[i], layout); + m_device->GetContext()->Release11on12Resource(ppResources[i], layout); } } @@ -136,9 +133,6 @@ namespace dxvk { Com interopDevice; m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast(&interopDevice)); - Com 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(context.ptr())->Acquire11on12Resource(ppResources[i], layout); + m_device->GetContext()->Acquire11on12Resource(ppResources[i], layout); } } diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index eeb84706..da0bc20c 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -335,11 +335,8 @@ namespace dxvk { HRESULT D3D11SwapChain::PresentImage(UINT SyncInterval) { - Com deviceContext = nullptr; - m_parent->GetImmediateContext(&deviceContext); - // Flush pending rendering commands before - auto immediateContext = static_cast(deviceContext.ptr()); + auto immediateContext = m_parent->GetContext(); immediateContext->EndFrame(); immediateContext->Flush();