1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d11] Move EmitCs and related methods to D3D11CommonContext

This commit is contained in:
Philip Rebohle 2022-08-03 21:19:11 +02:00
parent e0ea272c0d
commit 532b3a6add
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 57 additions and 60 deletions

View File

@ -12,15 +12,11 @@ namespace dxvk {
D3D11DeviceContext::D3D11DeviceContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags)
const Rc<DxvkDevice>& Device)
: D3D11DeviceChild<ID3D11DeviceContext4>(pParent),
m_multithread(this, false),
m_device (Device),
m_staging (Device, StagingBufferSize),
m_csFlags (CsFlags),
m_csChunk (AllocCsChunk()),
m_cmdData (nullptr) {
m_staging (Device, StagingBufferSize) {
}
@ -86,11 +82,6 @@ namespace dxvk {
}
DxvkCsChunkRef D3D11DeviceContext::AllocCsChunk() {
return m_parent->AllocCsChunk(m_csFlags);
}
void D3D11DeviceContext::InitDefaultPrimitiveTopology(
DxvkInputAssemblyState* pIaState) {
pIaState->primitiveTopology = VK_PRIMITIVE_TOPOLOGY_MAX_ENUM;

View File

@ -30,8 +30,7 @@ namespace dxvk {
D3D11DeviceContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags);
const Rc<DxvkDevice>& Device);
~D3D11DeviceContext();
D3D10DeviceLock LockContext() {
@ -47,11 +46,7 @@ namespace dxvk {
DxvkStagingBuffer m_staging;
DxvkCsChunkFlags m_csFlags;
DxvkCsChunkRef m_csChunk;
D3D11ContextState m_state;
D3D11CmdData* m_cmdData;
VkClearValue ConvertColorValue(
const FLOAT Color[4],
@ -64,8 +59,6 @@ namespace dxvk {
void ResetStagingBuffer();
DxvkCsChunkRef AllocCsChunk();
static void InitDefaultPrimitiveTopology(
DxvkInputAssemblyState* pIaState);
@ -103,48 +96,9 @@ namespace dxvk {
return bufferSize >= Offset + Size;
}
template<typename Cmd>
void EmitCs(Cmd&& command) {
m_cmdData = nullptr;
if (unlikely(!m_csChunk->push(command))) {
EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
m_csChunk->push(command);
}
}
template<typename M, typename Cmd, typename... Args>
M* EmitCsCmd(Cmd&& command, Args&&... args) {
M* data = m_csChunk->pushCmd<M, Cmd, Args...>(
command, std::forward<Args>(args)...);
if (unlikely(!data)) {
EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
data = m_csChunk->pushCmd<M, Cmd, Args...>(
command, std::forward<Args>(args)...);
}
m_cmdData = data;
return data;
}
void FlushCsChunk() {
if (likely(!m_csChunk->empty())) {
EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
m_cmdData = nullptr;
}
}
void TrackResourceSequenceNumber(
ID3D11Resource* pResource);
virtual void EmitCsChunk(DxvkCsChunkRef&& chunk) = 0;
virtual void TrackTextureSequenceNumber(
D3D11CommonTexture* pResource,
UINT Subresource) = 0;

View File

@ -9,9 +9,12 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags)
: D3D11DeviceContext(pParent, Device, CsFlags),
: D3D11DeviceContext(pParent, Device),
m_contextExt(GetTypedContext()),
m_annotation(GetTypedContext(), Device) {
m_annotation(GetTypedContext(), Device),
m_csFlags (CsFlags),
m_csChunk (AllocCsChunk()),
m_cmdData (nullptr) {
}
@ -2979,6 +2982,12 @@ namespace dxvk {
}
template<typename ContextType>
DxvkCsChunkRef D3D11CommonContext<ContextType>::AllocCsChunk() {
return m_parent->AllocCsChunk(m_csFlags);
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::ApplyInputLayout() {
auto inputLayout = m_state.ia.inputLayout.prvRef();

View File

@ -743,6 +743,12 @@ namespace dxvk {
D3D11DeviceContextExt<ContextType> m_contextExt;
D3D11UserDefinedAnnotation<ContextType> m_annotation;
DxvkCsChunkFlags m_csFlags;
DxvkCsChunkRef m_csChunk;
D3D11CmdData* m_cmdData;
DxvkCsChunkRef AllocCsChunk();
void ApplyInputLayout();
void ApplyPrimitiveTopology();
@ -987,6 +993,43 @@ namespace dxvk {
ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView);
template<typename Cmd>
void EmitCs(Cmd&& command) {
m_cmdData = nullptr;
if (unlikely(!m_csChunk->push(command))) {
GetTypedContext()->EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
m_csChunk->push(command);
}
}
template<typename M, typename Cmd, typename... Args>
M* EmitCsCmd(Cmd&& command, Args&&... args) {
M* data = m_csChunk->pushCmd<M, Cmd, Args...>(
command, std::forward<Args>(args)...);
if (unlikely(!data)) {
GetTypedContext()->EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
data = m_csChunk->pushCmd<M, Cmd, Args...>(
command, std::forward<Args>(args)...);
}
m_cmdData = data;
return data;
}
void FlushCsChunk() {
if (likely(!m_csChunk->empty())) {
GetTypedContext()->EmitCsChunk(std::move(m_csChunk));
m_csChunk = AllocCsChunk();
m_cmdData = nullptr;
}
}
private:
ContextType* GetTypedContext() {