2018-01-23 09:23:31 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-25 22:08:21 +02:00
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-01-23 12:03:26 +01:00
|
|
|
#include "d3d11_context.h"
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
namespace dxvk {
|
2019-10-25 22:08:21 +02:00
|
|
|
|
|
|
|
class D3D11CommandListAllocator;
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2019-10-25 21:37:18 +02:00
|
|
|
class D3D11CommandList : public D3D11DeviceChild<ID3D11CommandList, NoWrapper> {
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11CommandList(
|
2019-10-25 22:08:21 +02:00
|
|
|
D3D11Device* pDevice,
|
|
|
|
D3D11CommandListAllocator* pAllocator);
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
~D3D11CommandList();
|
|
|
|
|
2019-10-25 21:37:18 +02:00
|
|
|
ULONG STDMETHODCALLTYPE AddRef();
|
|
|
|
|
|
|
|
ULONG STDMETHODCALLTYPE Release();
|
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject) final;
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE GetDevice(
|
|
|
|
ID3D11Device **ppDevice) final;
|
|
|
|
|
2018-01-23 12:16:28 +01:00
|
|
|
UINT STDMETHODCALLTYPE GetContextFlags() final;
|
2019-10-25 22:08:21 +02:00
|
|
|
|
|
|
|
void SetContextFlags(UINT ContextFlags) {
|
|
|
|
m_contextFlags = ContextFlags;
|
|
|
|
}
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2018-04-03 19:52:14 +02:00
|
|
|
void AddChunk(
|
2018-08-27 16:07:38 +02:00
|
|
|
DxvkCsChunkRef&& Chunk);
|
2018-01-23 12:03:26 +01:00
|
|
|
|
|
|
|
void EmitToCommandList(
|
|
|
|
ID3D11CommandList* pCommandList);
|
|
|
|
|
|
|
|
void EmitToCsThread(
|
2018-03-03 20:59:17 +01:00
|
|
|
DxvkCsThread* CsThread);
|
2018-01-23 12:03:26 +01:00
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
private:
|
|
|
|
|
2019-10-25 22:08:21 +02:00
|
|
|
D3D11Device* m_device;
|
|
|
|
D3D11CommandListAllocator* m_allocator;
|
|
|
|
|
|
|
|
uint32_t m_contextFlags = 0;
|
|
|
|
|
2018-08-27 16:07:38 +02:00
|
|
|
std::vector<DxvkCsChunkRef> m_chunks;
|
2018-06-29 12:44:52 +02:00
|
|
|
|
|
|
|
std::atomic<bool> m_submitted = { false };
|
|
|
|
std::atomic<bool> m_warned = { false };
|
|
|
|
|
2019-10-25 21:37:18 +02:00
|
|
|
std::atomic<uint32_t> m_refCount = { 0u };
|
|
|
|
|
2019-10-25 22:08:21 +02:00
|
|
|
void Reset();
|
|
|
|
|
2018-06-29 12:44:52 +02:00
|
|
|
void MarkSubmitted();
|
2018-01-23 12:03:26 +01:00
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
};
|
|
|
|
|
2019-10-25 22:08:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
}
|