Update D3D11 context wrapping to new serialisation scheme

This commit is contained in:
baldurk
2017-11-08 18:24:03 +00:00
parent 0027ff1a10
commit 2fe0193b49
6 changed files with 2334 additions and 3095 deletions
+13 -25
View File
@@ -776,23 +776,10 @@ void WrappedID3D11DeviceContext::ProcessChunk(ReadSerialiser &ser, D3D11Chunk ch
case D3D11Chunk::DiscardView1: Serialise_DiscardView1(ser, NULL, NULL, 0); break;
case D3D11Chunk::PostExecuteCommandListRestore:
{
// apply saved state.
if(m_DeferredSavedState)
{
m_DeferredSavedState->ApplyState(this);
SAFE_DELETE(m_DeferredSavedState);
}
Serialise_PostExecuteCommandListRestore(ser);
break;
}
case D3D11Chunk::PostFinishCommandListSet:
{
D3D11RenderState RenderState(D3D11RenderState::Empty);
SERIALISE_ELEMENT(RenderState);
RenderState.ApplyState(this);
break;
}
case D3D11Chunk::PostFinishCommandListSet: Serialise_PostFinishCommandListSet(ser); break;
case D3D11Chunk::SwapDeviceContextState:
Serialise_SwapDeviceContextState(ser, NULL, NULL);
@@ -814,7 +801,7 @@ void WrappedID3D11DeviceContext::ProcessChunk(ReadSerialiser &ser, D3D11Chunk ch
if(IsLoading(m_State))
{
if(!m_PresentChunk)
AddEvent("End of Frame");
AddEvent();
DrawcallDescription draw;
draw.name = "End of Frame";
@@ -849,7 +836,7 @@ void WrappedID3D11DeviceContext::ProcessChunk(ReadSerialiser &ser, D3D11Chunk ch
else
{
if(!m_AddedDrawcall)
AddEvent("");
AddEvent();
}
}
@@ -1010,14 +997,15 @@ void WrappedID3D11DeviceContext::AddDrawcall(const DrawcallDescription &d, bool
RDCERR("Somehow lost drawcall stack!");
}
void WrappedID3D11DeviceContext::AddEvent(string description)
void WrappedID3D11DeviceContext::AddEvent()
{
APIEvent apievent;
apievent.fileOffset = m_CurChunkOffset;
apievent.eventID = m_CurEventID;
apievent.eventDesc = description;
// TODO structured data?
apievent.eventDesc = "TODO";
apievent.callstack = m_ChunkMetadata.callstack;
@@ -1328,7 +1316,7 @@ void WrappedID3D11DeviceContext::RecordIndexBindStats(ID3D11Buffer *Buffer)
indices.nulls += (Buffer == NULL);
}
void WrappedID3D11DeviceContext::RecordVertexBindStats(UINT NumBuffers, ID3D11Buffer *Buffers[])
void WrappedID3D11DeviceContext::RecordVertexBindStats(UINT NumBuffers, ID3D11Buffer *const Buffers[])
{
FrameStatistics &stats = m_pDevice->GetFrameStats();
VertexBindStats &vertices = stats.vertices;
@@ -1355,7 +1343,7 @@ void WrappedID3D11DeviceContext::RecordLayoutBindStats(ID3D11InputLayout *Layout
}
void WrappedID3D11DeviceContext::RecordConstantStats(ShaderStage stage, UINT NumBuffers,
ID3D11Buffer *Buffers[])
ID3D11Buffer *const Buffers[])
{
FrameStatistics &stats = m_pDevice->GetFrameStats();
RDCASSERT(size_t(stage) < ARRAY_COUNT(stats.constants));
@@ -1385,7 +1373,7 @@ void WrappedID3D11DeviceContext::RecordConstantStats(ShaderStage stage, UINT Num
}
void WrappedID3D11DeviceContext::RecordResourceStats(ShaderStage stage, UINT NumResources,
ID3D11ShaderResourceView *Resources[])
ID3D11ShaderResourceView *const Resources[])
{
FrameStatistics &stats = m_pDevice->GetFrameStats();
RDCASSERT(size_t(stage) < ARRAY_COUNT(stats.resources));
@@ -1426,7 +1414,7 @@ void WrappedID3D11DeviceContext::RecordResourceStats(ShaderStage stage, UINT Num
}
void WrappedID3D11DeviceContext::RecordSamplerStats(ShaderStage stage, UINT NumSamplers,
ID3D11SamplerState *Samplers[])
ID3D11SamplerState *const Samplers[])
{
FrameStatistics &stats = m_pDevice->GetFrameStats();
RDCASSERT(size_t(stage) < ARRAY_COUNT(stats.samplers));
@@ -1517,8 +1505,8 @@ void WrappedID3D11DeviceContext::RecordShaderStats(ShaderStage stage, ID3D11Devi
shaders.redundants += (Current == Shader);
}
void WrappedID3D11DeviceContext::RecordBlendStats(ID3D11BlendState *Blend, FLOAT BlendFactor[4],
UINT SampleMask)
void WrappedID3D11DeviceContext::RecordBlendStats(ID3D11BlendState *Blend,
const FLOAT BlendFactor[4], UINT SampleMask)
{
FrameStatistics &stats = m_pDevice->GetFrameStats();
BlendStats &blends = stats.blends;
+16 -10
View File
@@ -213,21 +213,21 @@ private:
void AddUsage(const DrawcallDescription &d);
void AddEvent(string description);
void AddEvent();
void AddDrawcall(const DrawcallDescription &d, bool hasEvents);
void RecordIndexBindStats(ID3D11Buffer *Buffer);
void RecordVertexBindStats(UINT NumBuffers, ID3D11Buffer *Buffers[]);
void RecordVertexBindStats(UINT NumBuffers, ID3D11Buffer *const Buffers[]);
void RecordLayoutBindStats(ID3D11InputLayout *Layout);
void RecordConstantStats(ShaderStage stage, UINT NumBuffers, ID3D11Buffer *Buffers[]);
void RecordConstantStats(ShaderStage stage, UINT NumBuffers, ID3D11Buffer *const Buffers[]);
void RecordResourceStats(ShaderStage stage, UINT NumResources,
ID3D11ShaderResourceView *Resources[]);
void RecordSamplerStats(ShaderStage stage, UINT NumSamplers, ID3D11SamplerState *Samplers[]);
ID3D11ShaderResourceView *const Resources[]);
void RecordSamplerStats(ShaderStage stage, UINT NumSamplers, ID3D11SamplerState *const Samplers[]);
void RecordUpdateStats(ID3D11Resource *res, uint32_t Size, bool Server);
void RecordDrawStats(bool instanced, bool indirect, UINT InstanceCount);
void RecordDispatchStats(bool indirect);
void RecordShaderStats(ShaderStage stage, ID3D11DeviceChild *Current, ID3D11DeviceChild *Shader);
void RecordBlendStats(ID3D11BlendState *Blend, FLOAT BlendFactor[4], UINT SampleMask);
void RecordBlendStats(ID3D11BlendState *Blend, const FLOAT BlendFactor[4], UINT SampleMask);
void RecordDepthStencilStats(ID3D11DepthStencilState *DepthStencil, UINT StencilRef);
void RecordRasterizationStats(ID3D11RasterizerState *Rasterizer);
void RecordViewportStats(UINT NumViewports, const D3D11_VIEWPORT *viewports);
@@ -242,9 +242,9 @@ private:
// this is defined as a macro so that we can re-use it to explicitly instantiate these functions as
// templates in the wrapper definition file.
#define SERIALISED_ID3D11CONTEXT_MARKER_FUNCTIONS() \
IMPLEMENT_FUNCTION_SERIALISED(void, SetMarker, uint32_t col, const wchar_t *name); \
IMPLEMENT_FUNCTION_SERIALISED(int, PushMarker, uint32_t col, const wchar_t *name); \
#define SERIALISED_ID3D11CONTEXT_MARKER_FUNCTIONS() \
IMPLEMENT_FUNCTION_SERIALISED(void, SetMarker, uint32_t Color, const wchar_t *MarkerName); \
IMPLEMENT_FUNCTION_SERIALISED(int, PushMarker, uint32_t Color, const wchar_t *MarkerName); \
IMPLEMENT_FUNCTION_SERIALISED(int, PopMarker);
SERIALISED_ID3D11CONTEXT_MARKER_FUNCTIONS();
@@ -522,6 +522,9 @@ public:
IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, ExecuteCommandList, \
ID3D11CommandList *pCommandList, BOOL RestoreContextState); \
\
/* Fake function used to restore state after ExecuteCommandList */ \
IMPLEMENT_FUNCTION_SERIALISED(void, PostExecuteCommandListRestore); \
\
IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, HSSetShaderResources, \
UINT StartSlot, UINT NumViews, \
ID3D11ShaderResourceView *const *ppShaderResourceViews); \
@@ -713,7 +716,10 @@ public:
\
IMPLEMENT_FUNCTION_SERIALISED(virtual HRESULT STDMETHODCALLTYPE, FinishCommandList, \
BOOL RestoreDeferredContextState, \
ID3D11CommandList **ppCommandList);
ID3D11CommandList **ppCommandList); \
\
/* Fake function used to restore state after FinishCommandList */ \
IMPLEMENT_FUNCTION_SERIALISED(void, PostFinishCommandListSet);
SERIALISED_ID3D11CONTEXT_FUNCTIONS();
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -1090,8 +1090,9 @@ void D3D11RenderState::UnbindRangeForRead(const ResourceRange &range)
}
}
bool D3D11RenderState::ValidOutputMerger(ID3D11RenderTargetView **RTs, ID3D11DepthStencilView *depth,
ID3D11UnorderedAccessView **uavs)
bool D3D11RenderState::ValidOutputMerger(ID3D11RenderTargetView *const RTs[], UINT NumRTs,
ID3D11DepthStencilView *depth,
ID3D11UnorderedAccessView *const uavs[], UINT NumUAVs)
{
D3D11_RENDER_TARGET_VIEW_DESC RTDescs[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
D3D11_DEPTH_STENCIL_VIEW_DESC DepthDesc;
@@ -1106,7 +1107,7 @@ bool D3D11RenderState::ValidOutputMerger(ID3D11RenderTargetView **RTs, ID3D11Dep
D3D11_RESOURCE_DIMENSION_UNKNOWN};
D3D11_RESOURCE_DIMENSION depthdim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
for(int i = 0; RTs && i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
for(UINT i = 0; RTs && i < NumRTs; i++)
{
if(RTs[i])
{
@@ -1151,7 +1152,7 @@ bool D3D11RenderState::ValidOutputMerger(ID3D11RenderTargetView **RTs, ID3D11Dep
ResourceRange::Null, ResourceRange::Null, ResourceRange::Null, ResourceRange::Null,
};
for(int i = 0; RTs && i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
for(UINT i = 0; RTs && i < NumRTs; i++)
{
if(RTs[i])
rtvRanges[i] = GetResourceRange(RTs[i]);
@@ -1164,7 +1165,7 @@ bool D3D11RenderState::ValidOutputMerger(ID3D11RenderTargetView **RTs, ID3D11Dep
int numUAVs = 0;
for(int i = 0; uavs && i < D3D11_1_UAV_SLOT_COUNT; i++)
for(UINT i = 0; uavs && i < NumUAVs; i++)
{
if(uavs[i])
{
+4 -3
View File
@@ -198,8 +198,9 @@ struct D3D11RenderState
// that might not be obvious/intended.
// validate an output merger combination of render targets and depth view
bool ValidOutputMerger(ID3D11RenderTargetView **RTs, ID3D11DepthStencilView *depth,
ID3D11UnorderedAccessView **uavs);
bool ValidOutputMerger(ID3D11RenderTargetView *const RTs[], UINT NumRTs,
ID3D11DepthStencilView *depth, ID3D11UnorderedAccessView *const uavs[],
UINT NumUAVs);
struct inputassembler
{
@@ -275,7 +276,7 @@ struct D3D11RenderState
void SetDevice(WrappedID3D11Device *device) { m_pDevice = device; }
void MarkReferenced(WrappedID3D11DeviceContext *ctx, bool initial) const;
void CacheViewportPartial();
bool IsViewportPartial() { return m_ViewportScissorPartial; }
private:
void AddRefs();
void ReleaseRefs();
+2 -2
View File
@@ -1312,8 +1312,8 @@ public:
WrappedID3D11DeviceContext *GetContext() { return m_pContext; }
bool IsCaptured() { return m_Successful; }
void SetReferences(set<ResourceId> &refs) { m_References.swap(refs); }
void SetDirtyResources(set<ResourceId> &dirty) { m_Dirty.swap(dirty); }
void SwapReferences(set<ResourceId> &refs) { m_References.swap(refs); }
void SwapDirtyResources(set<ResourceId> &dirty) { m_Dirty.swap(dirty); }
void MarkDirtyResources(D3D11ResourceManager *manager)
{
for(auto it = m_Dirty.begin(); it != m_Dirty.end(); ++it)