1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[dxvk] Remove context type concept

We only have a single context per device now.
This commit is contained in:
Philip Rebohle 2024-10-22 15:18:38 +02:00 committed by Philip Rebohle
parent b4ed108105
commit 4af31a9d64
8 changed files with 30 additions and 59 deletions

View File

@ -16,7 +16,7 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device)
: D3D11CommonContext<D3D11ImmediateContext>(pParent, Device, 0, DxvkCsChunkFlag::SingleUse),
m_csThread(Device, Device->createContext(DxvkContextType::Primary)),
m_csThread(Device, Device->createContext()),
m_maxImplicitDiscardSize(pParent->GetOptions()->maxImplicitDiscardSize),
m_submissionFence(new sync::CallbackFence()),
m_flushTracker(pParent->GetOptions()->reproducibleCommandStream),

View File

@ -54,7 +54,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(DxvkContextType::Primary) )
, m_csThread ( dxvkDevice, dxvkDevice->createContext() )
, m_csChunk ( AllocCsChunk() )
, m_submissionFence (new sync::Fence())
, m_flushTracker (m_d3d9Options.reproducibleCommandStream)

View File

@ -7,9 +7,8 @@
namespace dxvk {
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device, DxvkContextType type)
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device)
: m_device (device),
m_type (type),
m_common (&device->m_objects),
m_sdmaBarriers(DxvkCmdBuffer::SdmaBuffer),
m_initBarriers(DxvkCmdBuffer::InitBuffer),
@ -18,7 +17,7 @@ namespace dxvk {
// Init framebuffer info with default render pass in case
// the app does not explicitly bind any render targets
m_state.om.framebufferInfo = makeFramebufferInfo(m_state.om.renderTargets);
m_descriptorManager = new DxvkDescriptorManager(device.ptr(), type);
m_descriptorManager = new DxvkDescriptorManager(device.ptr());
// Default destination barriers for graphics pipelines
m_globalRoGraphicsBarrier.stages = m_device->getShaderPipelineStages()

View File

@ -32,7 +32,7 @@ namespace dxvk {
public:
DxvkContext(const Rc<DxvkDevice>& device, DxvkContextType type);
DxvkContext(const Rc<DxvkDevice>& device);
~DxvkContext();
/**
@ -1389,7 +1389,6 @@ namespace dxvk {
private:
Rc<DxvkDevice> m_device;
DxvkContextType m_type;
DxvkObjects* m_common;
Rc<DxvkCommandList> m_cmd;

View File

@ -35,9 +35,8 @@ namespace dxvk {
DxvkDescriptorPool::DxvkDescriptorPool(
DxvkDevice* device,
DxvkDescriptorManager* manager,
DxvkContextType contextType)
: m_device(device), m_manager(manager), m_contextType(contextType),
DxvkDescriptorManager* manager)
: m_device(device), m_manager(manager),
m_cachedEntry(nullptr, nullptr) {
}
@ -49,12 +48,10 @@ namespace dxvk {
for (auto pool : m_descriptorPools)
vk->vkDestroyDescriptorPool(vk->device(), pool, nullptr);
if (m_contextType == DxvkContextType::Primary) {
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount,
uint64_t(-int64_t(m_descriptorPools.size())));
m_device->addStatCtr(DxvkStatCounter::DescriptorSetCount,
uint64_t(-int64_t(m_setsAllocated)));
}
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount,
uint64_t(-int64_t(m_descriptorPools.size())));
m_device->addStatCtr(DxvkStatCounter::DescriptorSetCount,
uint64_t(-int64_t(m_setsAllocated)));
}
@ -63,9 +60,10 @@ namespace dxvk {
if (!m_setsAllocated)
return false;
// No frame tracking for supplementary contexts, so
// always submit those at the end of a command list
if (endFrame || m_contextType != DxvkContextType::Primary)
// Submit at the end of each frame to make it more likely
// to get similar descriptor set layouts the next time the
// pool gets used.
if (endFrame)
return true;
// Submit very large descriptor pools to prevent extreme
@ -136,10 +134,8 @@ namespace dxvk {
void DxvkDescriptorPool::updateStats(DxvkStatCounters& counters) {
if (m_contextType == DxvkContextType::Primary) {
counters.addCtr(DxvkStatCounter::DescriptorSetCount,
uint64_t(int64_t(m_setsAllocated) - int64_t(m_prevSetsAllocated)));
}
counters.addCtr(DxvkStatCounter::DescriptorSetCount,
uint64_t(int64_t(m_setsAllocated) - int64_t(m_prevSetsAllocated)));
m_prevSetsAllocated = m_setsAllocated;
}
@ -238,15 +234,12 @@ namespace dxvk {
DxvkDescriptorManager::DxvkDescriptorManager(
DxvkDevice* device,
DxvkContextType contextType)
: m_device(device), m_contextType(contextType) {
DxvkDevice* device)
: m_device(device) {
// Deliberately pick a very high number of descriptor sets so that
// we will typically end up using all available pool memory before
// the descriptor set limit becomes the limiting factor.
m_maxSets = m_contextType == DxvkContextType::Primary
? (env::is32BitHostPlatform() ? 24576u : 49152u)
: (512u);
m_maxSets = env::is32BitHostPlatform() ? 24576u : 49152u;
}
@ -256,10 +249,8 @@ namespace dxvk {
for (size_t i = 0; i < m_vkPoolCount; i++)
vk->vkDestroyDescriptorPool(vk->device(), m_vkPools[i], nullptr);
if (m_contextType == DxvkContextType::Primary) {
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount,
uint64_t(-int64_t(m_vkPoolCount)));
}
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount,
uint64_t(-int64_t(m_vkPoolCount)));
}
@ -267,7 +258,7 @@ namespace dxvk {
Rc<DxvkDescriptorPool> pool = m_pools.retrieveObject();
if (pool == nullptr)
pool = new DxvkDescriptorPool(m_device, this, m_contextType);
pool = new DxvkDescriptorPool(m_device, this);
return pool;
}
@ -319,8 +310,7 @@ namespace dxvk {
if (vk->vkCreateDescriptorPool(vk->device(), &info, nullptr, &pool) != VK_SUCCESS)
throw DxvkError("DxvkDescriptorPool: Failed to create descriptor pool");
if (m_contextType == DxvkContextType::Primary)
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount, 1);
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount, 1);
return pool;
}
@ -337,9 +327,7 @@ namespace dxvk {
}
}
if (m_contextType == DxvkContextType::Primary)
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount, uint64_t(-1ll));
m_device->addStatCtr(DxvkStatCounter::DescriptorPoolCount, uint64_t(-1ll));
vk->vkDestroyDescriptorPool(vk->device(), pool, nullptr);
}

View File

@ -12,16 +12,6 @@ namespace dxvk {
class DxvkDevice;
class DxvkDescriptorManager;
/**
* \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
*
@ -85,8 +75,7 @@ namespace dxvk {
DxvkDescriptorPool(
DxvkDevice* device,
DxvkDescriptorManager* manager,
DxvkContextType contextType);
DxvkDescriptorManager* manager);
~DxvkDescriptorPool();
@ -134,7 +123,6 @@ namespace dxvk {
DxvkDevice* m_device;
DxvkDescriptorManager* m_manager;
DxvkContextType m_contextType;
std::vector<VkDescriptorPool> m_descriptorPools;
@ -184,8 +172,7 @@ namespace dxvk {
public:
DxvkDescriptorManager(
DxvkDevice* device,
DxvkContextType contextType);
DxvkDevice* device);
~DxvkDescriptorManager();
@ -234,7 +221,6 @@ namespace dxvk {
private:
DxvkDevice* m_device;
DxvkContextType m_contextType;
uint32_t m_maxSets = 0;
DxvkRecycler<DxvkDescriptorPool, 8> m_pools;

View File

@ -133,8 +133,8 @@ namespace dxvk {
}
Rc<DxvkContext> DxvkDevice::createContext(DxvkContextType type) {
return new DxvkContext(this, type);
Rc<DxvkContext> DxvkDevice::createContext() {
return new DxvkContext(this);
}

View File

@ -278,10 +278,9 @@ namespace dxvk {
*
* Creates a context object that can
* be used to record command buffers.
* \param [in] type Context type
* \returns The context object
*/
Rc<DxvkContext> createContext(DxvkContextType type);
Rc<DxvkContext> createContext();
/**
* \brief Creates a GPU event