diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 0ff64e25e..536aef856 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -13,7 +13,7 @@ namespace dxvk { D3D11Device* pParent, const Rc& Device) : D3D11DeviceContext(pParent, Device, DxvkCsChunkFlag::SingleUse), - m_csThread(Device, Device->createContext()), + m_csThread(Device, Device->createContext(DxvkContextType::Primary)), m_maxImplicitDiscardSize(pParent->GetOptions()->maxImplicitDiscardSize), m_videoContext(this, Device) { EmitCs([ diff --git a/src/d3d11/d3d11_initializer.cpp b/src/d3d11/d3d11_initializer.cpp index 863c453e7..cfe0e9bcc 100644 --- a/src/d3d11/d3d11_initializer.cpp +++ b/src/d3d11/d3d11_initializer.cpp @@ -9,7 +9,7 @@ namespace dxvk { D3D11Device* pParent) : m_parent(pParent), m_device(pParent->GetDXVKDevice()), - m_context(m_device->createContext()) { + m_context(m_device->createContext(DxvkContextType::Supplementary)) { m_context->beginRecording( m_device->createCommandList()); } diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index 56c51a7b8..b6ba21e17 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -21,7 +21,7 @@ namespace dxvk { m_window (hWnd), m_desc (*pDesc), m_device (pDevice->GetDXVKDevice()), - m_context (m_device->createContext()), + m_context (m_device->createContext(DxvkContextType::Supplementary)), m_frameLatencyCap(pDevice->GetOptions()->maxFrameLatency) { CreateFrameLatencyEvent(); diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 4b9a74224..f2411de8d 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -49,7 +49,7 @@ namespace dxvk { , m_d3d9Options ( dxvkDevice, pParent->GetInstance()->config() ) , m_multithread ( BehaviorFlags & D3DCREATE_MULTITHREADED ) , m_isSWVP ( (BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) ? true : false ) - , m_csThread ( dxvkDevice, dxvkDevice->createContext() ) + , m_csThread ( dxvkDevice, dxvkDevice->createContext(DxvkContextType::Primary) ) , m_csChunk ( AllocCsChunk() ) { // If we can SWVP, then we use an extended constant set // as SWVP has many more slots available than HWVP. diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index 2615aa49a..0ccfba350 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -10,7 +10,7 @@ namespace dxvk { D3D9FormatHelper::D3D9FormatHelper(const Rc& device) - : m_device(device), m_context(m_device->createContext()) { + : m_device(device), m_context(m_device->createContext(DxvkContextType::Supplementary)) { m_context->beginRecording( m_device->createCommandList()); diff --git a/src/d3d9/d3d9_initializer.cpp b/src/d3d9/d3d9_initializer.cpp index 22088c9b2..daf60cb0a 100644 --- a/src/d3d9/d3d9_initializer.cpp +++ b/src/d3d9/d3d9_initializer.cpp @@ -6,7 +6,7 @@ namespace dxvk { D3D9Initializer::D3D9Initializer( const Rc& Device) - : m_device(Device), m_context(m_device->createContext()) { + : m_device(Device), m_context(m_device->createContext(DxvkContextType::Supplementary)) { m_context->beginRecording( m_device->createCommandList()); } diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index a17991174..4422913cb 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -190,7 +190,7 @@ namespace dxvk { const D3DDISPLAYMODEEX* pFullscreenDisplayMode) : D3D9SwapChainExBase(pDevice) , m_device (pDevice->GetDXVKDevice()) - , m_context (m_device->createContext()) + , m_context (m_device->createContext(DxvkContextType::Supplementary)) , m_frameLatencyCap (pDevice->GetOptions()->maxFrameLatency) , m_frameLatencySignal(new sync::Fence(m_frameId)) , m_dialog (pDevice->GetOptions()->enableDialogMode) { diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 8752ff6f7..abd2318fc 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -7,8 +7,9 @@ namespace dxvk { - DxvkContext::DxvkContext(const Rc& device) + DxvkContext::DxvkContext(const Rc& device, DxvkContextType type) : m_device (device), + m_type (type), m_common (&device->m_objects), m_sdmaAcquires(DxvkCmdBuffer::SdmaBuffer), m_sdmaBarriers(DxvkCmdBuffer::SdmaBuffer), diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 874da38a7..56ced3d4e 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -22,7 +22,7 @@ namespace dxvk { constexpr static VkDeviceSize StagingBufferSize = 4ull << 20; public: - DxvkContext(const Rc& device); + DxvkContext(const Rc& device, DxvkContextType type); ~DxvkContext(); /** @@ -1038,6 +1038,7 @@ namespace dxvk { private: Rc m_device; + DxvkContextType m_type; DxvkObjects* m_common; Rc m_cmd; diff --git a/src/dxvk/dxvk_descriptor.h b/src/dxvk/dxvk_descriptor.h index 243e6b0a2..6c8c8d4c5 100644 --- a/src/dxvk/dxvk_descriptor.h +++ b/src/dxvk/dxvk_descriptor.h @@ -8,6 +8,16 @@ namespace dxvk { class DxvkDevice; + /** + * \brief DXVK context type + * + * Used as a hint to optimize certain usage patterns. + */ + enum class DxvkContextType : uint32_t { + Primary = 0, + Supplementary = 1, + }; + /** * \brief Descriptor info * diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index a31be08da..5795455d6 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -94,8 +94,8 @@ namespace dxvk { } - Rc DxvkDevice::createContext() { - return new DxvkContext(this); + Rc DxvkDevice::createContext(DxvkContextType type) { + return new DxvkContext(this, type); } diff --git a/src/dxvk/dxvk_device.h b/src/dxvk/dxvk_device.h index 227e66c69..0d1ac5cc7 100644 --- a/src/dxvk/dxvk_device.h +++ b/src/dxvk/dxvk_device.h @@ -244,9 +244,10 @@ namespace dxvk { * * Creates a context object that can * be used to record command buffers. + * \param [in] type Context type * \returns The context object */ - Rc createContext(); + Rc createContext(DxvkContextType type); /** * \brief Creates a GPU event diff --git a/src/dxvk/dxvk_unbound.cpp b/src/dxvk/dxvk_unbound.cpp index 852672418..7ea2f1db5 100644 --- a/src/dxvk/dxvk_unbound.cpp +++ b/src/dxvk/dxvk_unbound.cpp @@ -21,7 +21,7 @@ namespace dxvk { void DxvkUnboundResources::clearResources(DxvkDevice* dev) { - const Rc ctx = dev->createContext(); + const Rc ctx = dev->createContext(DxvkContextType::Supplementary); ctx->beginRecording(dev->createCommandList()); this->clearBuffer(ctx, m_buffer);