mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
Revert "[d3d11] Recycle command lists from deferred contexts"
This reverts commit 4e3da45fdeab9d81601ec1d4b5174cff4c6629d6. For some reason this caused crashes.
This commit is contained in:
parent
8c34f4ff8a
commit
fc0ede0657
@ -5,10 +5,9 @@ namespace dxvk {
|
||||
|
||||
D3D11CommandList::D3D11CommandList(
|
||||
D3D11Device* pDevice,
|
||||
D3D11CommandListAllocator* pAllocator)
|
||||
: m_device(pDevice), m_allocator(pAllocator) {
|
||||
|
||||
}
|
||||
UINT ContextFlags)
|
||||
: m_device (pDevice),
|
||||
m_contextFlags(ContextFlags) { }
|
||||
|
||||
|
||||
D3D11CommandList::~D3D11CommandList() {
|
||||
@ -26,14 +25,8 @@ namespace dxvk {
|
||||
|
||||
ULONG STDMETHODCALLTYPE D3D11CommandList::Release() {
|
||||
ULONG refCount = --m_refCount;
|
||||
|
||||
if (!refCount) {
|
||||
Reset();
|
||||
|
||||
m_allocator->RecycleCommandList(this);
|
||||
if (!refCount)
|
||||
m_device->Release();
|
||||
}
|
||||
|
||||
return refCount;
|
||||
}
|
||||
|
||||
@ -90,15 +83,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void D3D11CommandList::Reset() {
|
||||
m_chunks.clear();
|
||||
|
||||
m_contextFlags = 0;
|
||||
m_submitted = false;
|
||||
m_warned = false;
|
||||
}
|
||||
|
||||
|
||||
void D3D11CommandList::MarkSubmitted() {
|
||||
if (m_submitted.exchange(true) && !m_warned.exchange(true)
|
||||
&& m_device->GetOptions()->dcSingleUseMode) {
|
||||
@ -108,42 +92,4 @@ namespace dxvk {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
D3D11CommandListAllocator::D3D11CommandListAllocator(D3D11Device* pDevice)
|
||||
: m_device(pDevice) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
D3D11CommandListAllocator::~D3D11CommandListAllocator() {
|
||||
for (uint32_t i = 0; i < m_listCount; i++)
|
||||
delete m_lists[i];
|
||||
}
|
||||
|
||||
|
||||
D3D11CommandList* D3D11CommandListAllocator::AllocCommandList(
|
||||
UINT ContextFlags) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
D3D11CommandList* result = nullptr;
|
||||
|
||||
if (m_listCount)
|
||||
result = m_lists[--m_listCount];
|
||||
else
|
||||
result = new D3D11CommandList(m_device, this);
|
||||
|
||||
result->SetContextFlags(ContextFlags);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void D3D11CommandListAllocator::RecycleCommandList(
|
||||
D3D11CommandList* pCommandList) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_listCount < m_lists.size())
|
||||
m_lists[m_listCount++] = pCommandList;
|
||||
else
|
||||
delete pCommandList;
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "d3d11_context.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class D3D11CommandListAllocator;
|
||||
|
||||
class D3D11CommandList : public D3D11DeviceChild<ID3D11CommandList, NoWrapper> {
|
||||
|
||||
public:
|
||||
|
||||
D3D11CommandList(
|
||||
D3D11Device* pDevice,
|
||||
D3D11CommandListAllocator* pAllocator);
|
||||
UINT ContextFlags);
|
||||
|
||||
~D3D11CommandList();
|
||||
|
||||
@ -32,10 +27,6 @@ namespace dxvk {
|
||||
|
||||
UINT STDMETHODCALLTYPE GetContextFlags() final;
|
||||
|
||||
void SetContextFlags(UINT ContextFlags) {
|
||||
m_contextFlags = ContextFlags;
|
||||
}
|
||||
|
||||
void AddChunk(
|
||||
DxvkCsChunkRef&& Chunk);
|
||||
|
||||
@ -47,10 +38,8 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
D3D11Device* m_device;
|
||||
D3D11CommandListAllocator* m_allocator;
|
||||
|
||||
uint32_t m_contextFlags = 0;
|
||||
D3D11Device* const m_device;
|
||||
UINT const m_contextFlags;
|
||||
|
||||
std::vector<DxvkCsChunkRef> m_chunks;
|
||||
|
||||
@ -59,56 +48,8 @@ namespace dxvk {
|
||||
|
||||
std::atomic<uint32_t> m_refCount = { 0u };
|
||||
|
||||
void Reset();
|
||||
|
||||
void MarkSubmitted();
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Command list allocator
|
||||
*
|
||||
* Creates and recycles command list instances
|
||||
* in order to reduce deferred context overhead.
|
||||
*/
|
||||
class D3D11CommandListAllocator {
|
||||
|
||||
public:
|
||||
|
||||
D3D11CommandListAllocator(
|
||||
D3D11Device* pDevice);
|
||||
|
||||
~D3D11CommandListAllocator();
|
||||
|
||||
/**
|
||||
* \brief Allocates a command list
|
||||
*
|
||||
* \param [in] ContextFlags Flags of the parent context
|
||||
* \returns The command list
|
||||
*/
|
||||
D3D11CommandList* AllocCommandList(
|
||||
UINT ContextFlags);
|
||||
|
||||
/**
|
||||
* \brief Recycles a command list
|
||||
*
|
||||
* Automatically called when the command list
|
||||
* in question reaches a ref count of zero.
|
||||
* \param [in] pCommandList The command list
|
||||
*/
|
||||
void RecycleCommandList(
|
||||
D3D11CommandList* pCommandList);
|
||||
|
||||
private:
|
||||
|
||||
D3D11Device* m_device;
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::array<D3D11CommandList*, 64> m_lists;
|
||||
|
||||
uint32_t m_listCount = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -309,7 +309,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
Com<D3D11CommandList> D3D11DeferredContext::CreateCommandList() {
|
||||
return m_parent->AllocCommandList(m_contextFlags);
|
||||
return new D3D11CommandList(m_parent, m_contextFlags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,8 +39,7 @@ namespace dxvk {
|
||||
m_dxvkAdapter (m_dxvkDevice->adapter()),
|
||||
m_d3d11Formats (m_dxvkAdapter),
|
||||
m_d3d11Options (m_dxvkAdapter->instance()->config()),
|
||||
m_dxbcOptions (m_dxvkDevice, m_d3d11Options),
|
||||
m_commandListAllocator(this) {
|
||||
m_dxbcOptions (m_dxvkDevice, m_d3d11Options) {
|
||||
m_initializer = new D3D11Initializer(this);
|
||||
m_context = new D3D11ImmediateContext(this, m_dxvkDevice);
|
||||
m_d3d10Device = new D3D10Device(this, m_context);
|
||||
|
@ -412,10 +412,6 @@ namespace dxvk {
|
||||
return DxvkCsChunkRef(chunk, &m_csChunkPool);
|
||||
}
|
||||
|
||||
D3D11CommandList* AllocCommandList(UINT ContextFlags) {
|
||||
return m_commandListAllocator.AllocCommandList(ContextFlags);
|
||||
}
|
||||
|
||||
const D3D11Options* GetOptions() const {
|
||||
return &m_d3d11Options;
|
||||
}
|
||||
@ -457,7 +453,6 @@ namespace dxvk {
|
||||
D3D11StateObjectSet<D3D11RasterizerState> m_rsStateObjects;
|
||||
D3D11StateObjectSet<D3D11SamplerState> m_samplerObjects;
|
||||
D3D11ShaderModuleSet m_shaderModules;
|
||||
D3D11CommandListAllocator m_commandListAllocator;
|
||||
|
||||
HRESULT CreateShaderModule(
|
||||
D3D11CommonShader* pShaderModule,
|
||||
|
Loading…
x
Reference in New Issue
Block a user