[d3d11] Move remaining D3D11DeviceContext members to D3D11CommonContext

This commit is contained in:
Philip Rebohle 2022-08-03 21:29:06 +02:00
parent b20bfe763e
commit a3ed84c0c1
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 59 additions and 62 deletions

View File

@ -11,11 +11,8 @@
namespace dxvk {
D3D11DeviceContext::D3D11DeviceContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device)
: D3D11DeviceChild<ID3D11DeviceContext4>(pParent),
m_device (Device),
m_staging (Device, StagingBufferSize) {
D3D11Device* pParent)
: D3D11DeviceChild<ID3D11DeviceContext4>(pParent) {
}
@ -48,39 +45,6 @@ namespace dxvk {
}
DxvkDataSlice D3D11DeviceContext::AllocUpdateBufferSlice(size_t Size) {
constexpr size_t UpdateBufferSize = 1 * 1024 * 1024;
if (Size >= UpdateBufferSize) {
Rc<DxvkDataBuffer> buffer = new DxvkDataBuffer(Size);
return buffer->alloc(Size);
} else {
if (m_updateBuffer == nullptr)
m_updateBuffer = new DxvkDataBuffer(UpdateBufferSize);
DxvkDataSlice slice = m_updateBuffer->alloc(Size);
if (slice.ptr() == nullptr) {
m_updateBuffer = new DxvkDataBuffer(UpdateBufferSize);
slice = m_updateBuffer->alloc(Size);
}
return slice;
}
}
DxvkBufferSlice D3D11DeviceContext::AllocStagingBuffer(
VkDeviceSize Size) {
return m_staging.alloc(256, Size);
}
void D3D11DeviceContext::ResetStagingBuffer() {
m_staging.reset();
}
void D3D11DeviceContext::InitDefaultPrimitiveTopology(
DxvkInputAssemblyState* pIaState) {
pIaState->primitiveTopology = VK_PRIMITIVE_TOPOLOGY_MAX_ENUM;

View File

@ -19,41 +19,20 @@ namespace dxvk {
class D3D11Device;
class D3D11DeviceContext : public D3D11DeviceChild<ID3D11DeviceContext4> {
template<typename T>
friend class D3D11DeviceContextExt;
// Needed in order to call EmitCs for pushing markers
template<typename T>
friend class D3D11UserDefinedAnnotation;
constexpr static VkDeviceSize StagingBufferSize = 4ull << 20;
public:
D3D11DeviceContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device);
D3D11Device* pParent);
~D3D11DeviceContext();
protected:
Rc<DxvkDevice> m_device;
Rc<DxvkDataBuffer> m_updateBuffer;
DxvkStagingBuffer m_staging;
D3D11ContextState m_state;
VkClearValue ConvertColorValue(
const FLOAT Color[4],
const DxvkFormatInfo* pFormatInfo);
DxvkDataSlice AllocUpdateBufferSlice(size_t Size);
DxvkBufferSlice AllocStagingBuffer(
VkDeviceSize Size);
void ResetStagingBuffer();
static void InitDefaultPrimitiveTopology(
DxvkInputAssemblyState* pIaState);

View File

@ -9,10 +9,12 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
DxvkCsChunkFlags CsFlags)
: D3D11DeviceContext(pParent, Device),
: D3D11DeviceContext(pParent),
m_contextExt(GetTypedContext()),
m_annotation(GetTypedContext(), Device),
m_multithread(this, false),
m_device (Device),
m_staging (Device, StagingBufferSize),
m_csFlags (CsFlags),
m_csChunk (AllocCsChunk()),
m_cmdData (nullptr) {
@ -2987,7 +2989,37 @@ namespace dxvk {
DxvkCsChunkRef D3D11CommonContext<ContextType>::AllocCsChunk() {
return m_parent->AllocCsChunk(m_csFlags);
}
template<typename ContextType>
DxvkDataSlice D3D11CommonContext<ContextType>::AllocUpdateBufferSlice(size_t Size) {
constexpr size_t UpdateBufferSize = 1 * 1024 * 1024;
if (Size >= UpdateBufferSize) {
Rc<DxvkDataBuffer> buffer = new DxvkDataBuffer(Size);
return buffer->alloc(Size);
} else {
if (m_updateBuffer == nullptr)
m_updateBuffer = new DxvkDataBuffer(UpdateBufferSize);
DxvkDataSlice slice = m_updateBuffer->alloc(Size);
if (slice.ptr() == nullptr) {
m_updateBuffer = new DxvkDataBuffer(UpdateBufferSize);
slice = m_updateBuffer->alloc(Size);
}
return slice;
}
}
template<typename ContextType>
DxvkBufferSlice D3D11CommonContext<ContextType>::AllocStagingBuffer(
VkDeviceSize Size) {
return m_staging.alloc(256, Size);
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::ApplyInputLayout() {
@ -3890,6 +3922,12 @@ namespace dxvk {
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::ResetStagingBuffer() {
m_staging.reset();
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::ResetState() {
EmitCs([] (DxvkContext* ctx) {

View File

@ -58,6 +58,8 @@ namespace dxvk {
template<typename T> friend class D3D11DeviceContextExt;
template<typename T> friend class D3D11UserDefinedAnnotation;
constexpr static VkDeviceSize StagingBufferSize = 4ull << 20;
public:
D3D11CommonContext(
@ -748,12 +750,24 @@ namespace dxvk {
D3D11UserDefinedAnnotation<ContextType> m_annotation;
D3D10Multithread m_multithread;
Rc<DxvkDevice> m_device;
D3D11ContextState m_state;
DxvkStagingBuffer m_staging;
Rc<DxvkDataBuffer> m_updateBuffer;
DxvkCsChunkFlags m_csFlags;
DxvkCsChunkRef m_csChunk;
D3D11CmdData* m_cmdData;
DxvkCsChunkRef AllocCsChunk();
DxvkDataSlice AllocUpdateBufferSlice(size_t Size);
DxvkBufferSlice AllocStagingBuffer(
VkDeviceSize Size);
void ApplyInputLayout();
void ApplyPrimitiveTopology();
@ -871,6 +885,8 @@ namespace dxvk {
UINT NumSamplers,
ID3D11SamplerState** ppSamplers);
void ResetStagingBuffer();
void ResetState();
template<DxbcProgramType ShaderStage, typename T>