From 6f58c680c74cf8407bb84d24c4256465d57b2a3e Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 17 Dec 2019 17:59:52 +0000 Subject: [PATCH] Ensure chunks are explicitly handled so we get a warning if we miss one --- renderdoc/driver/d3d11/d3d11_context.cpp | 103 ++++++++++--- renderdoc/driver/d3d11/d3d11_device.cpp | 161 +++++++++++++++---- renderdoc/driver/d3d12/d3d12_commands.cpp | 103 +++++++++---- renderdoc/driver/d3d12/d3d12_device.cpp | 180 +++++++++++++++------- renderdoc/driver/vulkan/vk_core.cpp | 117 +++++++------- 5 files changed, 462 insertions(+), 202 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index df5baf3f7..9052b8b2f 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -859,31 +859,86 @@ bool WrappedID3D11DeviceContext::ProcessChunk(ReadSerialiser &ser, D3D11Chunk ch ret = Serialise_SwapDeviceContextState(ser, NULL, NULL); break; - case D3D11Chunk::SwapchainPresent: ret = Serialise_Present(ser, 0, 0); break; - default: - { - SystemChunk system = (SystemChunk)chunk; - - if(system == SystemChunk::CaptureEnd) - { - if(IsLoading(m_State) && m_LastChunk != D3D11Chunk::SwapchainPresent) - { - DrawcallDescription draw; - draw.name = "End of Capture"; - draw.flags |= DrawFlags::Present; - - draw.copyDestination = m_pDevice->GetBackbufferResourceID(); - - AddDrawcall(draw, true); - } - - ret = true; - } - else - { - RDCERR("Unrecognised Chunk type %d", chunk); - } + case D3D11Chunk::SwapchainPresent: + ret = Serialise_Present(ser, 0, 0); break; + + // in order to get a warning if we miss a case, we explicitly handle the device creation chunks + // here. If we actually encounter one it's an error (we shouldn't see these inside the captured + // frame itself) + case D3D11Chunk::DeviceInitialisation: + case D3D11Chunk::SetResourceName: + case D3D11Chunk::CreateSwapBuffer: + case D3D11Chunk::CreateTexture1D: + case D3D11Chunk::CreateTexture2D: + case D3D11Chunk::CreateTexture2D1: + case D3D11Chunk::CreateTexture3D: + case D3D11Chunk::CreateTexture3D1: + case D3D11Chunk::CreateBuffer: + case D3D11Chunk::CreateVertexShader: + case D3D11Chunk::CreateHullShader: + case D3D11Chunk::CreateDomainShader: + case D3D11Chunk::CreateGeometryShader: + case D3D11Chunk::CreateGeometryShaderWithStreamOutput: + case D3D11Chunk::CreatePixelShader: + case D3D11Chunk::CreateComputeShader: + case D3D11Chunk::GetClassInstance: + case D3D11Chunk::CreateClassInstance: + case D3D11Chunk::CreateClassLinkage: + case D3D11Chunk::CreateShaderResourceView: + case D3D11Chunk::CreateShaderResourceView1: + case D3D11Chunk::CreateRenderTargetView: + case D3D11Chunk::CreateRenderTargetView1: + case D3D11Chunk::CreateDepthStencilView: + case D3D11Chunk::CreateUnorderedAccessView: + case D3D11Chunk::CreateUnorderedAccessView1: + case D3D11Chunk::CreateInputLayout: + case D3D11Chunk::CreateBlendState: + case D3D11Chunk::CreateBlendState1: + case D3D11Chunk::CreateDepthStencilState: + case D3D11Chunk::CreateRasterizerState: + case D3D11Chunk::CreateRasterizerState1: + case D3D11Chunk::CreateRasterizerState2: + case D3D11Chunk::CreateSamplerState: + case D3D11Chunk::CreateQuery: + case D3D11Chunk::CreateQuery1: + case D3D11Chunk::CreatePredicate: + case D3D11Chunk::CreateCounter: + case D3D11Chunk::CreateDeferredContext: + case D3D11Chunk::SetExceptionMode: + case D3D11Chunk::ExternalDXGIResource: + case D3D11Chunk::OpenSharedResource: + case D3D11Chunk::OpenSharedResource1: + case D3D11Chunk::OpenSharedResourceByName: + case D3D11Chunk::SetShaderDebugPath: + RDCERR("Unexpected chunk while processing frame: %s", ToStr(chunk).c_str()); + return false; + + // no explicit default so that we have compiler warnings if a chunk isn't explicitly handled. + case D3D11Chunk::Max: break; + } + + { + SystemChunk system = (SystemChunk)chunk; + + if(system == SystemChunk::CaptureEnd) + { + if(IsLoading(m_State) && m_LastChunk != D3D11Chunk::SwapchainPresent) + { + DrawcallDescription draw; + draw.name = "End of Capture"; + draw.flags |= DrawFlags::Present; + + draw.copyDestination = m_pDevice->GetBackbufferResourceID(); + + AddDrawcall(draw, true); + } + + ret = true; + } + else + { + RDCERR("Unrecognised Chunk type %d", chunk); } } diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 308d09a32..0d2a113dd 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -1034,44 +1034,137 @@ bool WrappedID3D11Device::ProcessChunk(ReadSerialiser &ser, D3D11Chunk context) IID nul; return Serialise_OpenSharedResource(ser, 0, nul, NULL); } - case D3D11Chunk::SetShaderDebugPath: return Serialise_SetShaderDebugPath(ser, NULL, NULL); - default: + case D3D11Chunk::SetShaderDebugPath: + return Serialise_SetShaderDebugPath(ser, NULL, NULL); + + // In order to get a warning if we miss a case, we explicitly handle the context chunks here. + // for legacy reasons we forward to the immediate context's chunk processing here, since some + // chunks like CopyResource can be serialised in the initialisation phase. + case D3D11Chunk::IASetInputLayout: + case D3D11Chunk::IASetVertexBuffers: + case D3D11Chunk::IASetIndexBuffer: + case D3D11Chunk::IASetPrimitiveTopology: + case D3D11Chunk::VSSetConstantBuffers: + case D3D11Chunk::VSSetShaderResources: + case D3D11Chunk::VSSetSamplers: + case D3D11Chunk::VSSetShader: + case D3D11Chunk::HSSetConstantBuffers: + case D3D11Chunk::HSSetShaderResources: + case D3D11Chunk::HSSetSamplers: + case D3D11Chunk::HSSetShader: + case D3D11Chunk::DSSetConstantBuffers: + case D3D11Chunk::DSSetShaderResources: + case D3D11Chunk::DSSetSamplers: + case D3D11Chunk::DSSetShader: + case D3D11Chunk::GSSetConstantBuffers: + case D3D11Chunk::GSSetShaderResources: + case D3D11Chunk::GSSetSamplers: + case D3D11Chunk::GSSetShader: + case D3D11Chunk::SOSetTargets: + case D3D11Chunk::PSSetConstantBuffers: + case D3D11Chunk::PSSetShaderResources: + case D3D11Chunk::PSSetSamplers: + case D3D11Chunk::PSSetShader: + case D3D11Chunk::CSSetConstantBuffers: + case D3D11Chunk::CSSetShaderResources: + case D3D11Chunk::CSSetUnorderedAccessViews: + case D3D11Chunk::CSSetSamplers: + case D3D11Chunk::CSSetShader: + case D3D11Chunk::RSSetViewports: + case D3D11Chunk::RSSetScissorRects: + case D3D11Chunk::RSSetState: + case D3D11Chunk::OMSetRenderTargets: + case D3D11Chunk::OMSetRenderTargetsAndUnorderedAccessViews: + case D3D11Chunk::OMSetBlendState: + case D3D11Chunk::OMSetDepthStencilState: + case D3D11Chunk::DrawIndexedInstanced: + case D3D11Chunk::DrawInstanced: + case D3D11Chunk::DrawIndexed: + case D3D11Chunk::Draw: + case D3D11Chunk::DrawAuto: + case D3D11Chunk::DrawIndexedInstancedIndirect: + case D3D11Chunk::DrawInstancedIndirect: + case D3D11Chunk::Map: + case D3D11Chunk::Unmap: + case D3D11Chunk::CopySubresourceRegion: + case D3D11Chunk::CopyResource: + case D3D11Chunk::UpdateSubresource: + case D3D11Chunk::CopyStructureCount: + case D3D11Chunk::ResolveSubresource: + case D3D11Chunk::GenerateMips: + case D3D11Chunk::ClearDepthStencilView: + case D3D11Chunk::ClearRenderTargetView: + case D3D11Chunk::ClearUnorderedAccessViewUint: + case D3D11Chunk::ClearUnorderedAccessViewFloat: + case D3D11Chunk::ClearState: + case D3D11Chunk::ExecuteCommandList: + case D3D11Chunk::Dispatch: + case D3D11Chunk::DispatchIndirect: + case D3D11Chunk::FinishCommandList: + case D3D11Chunk::Flush: + case D3D11Chunk::SetPredication: + case D3D11Chunk::SetResourceMinLOD: + case D3D11Chunk::Begin: + case D3D11Chunk::End: + case D3D11Chunk::CopySubresourceRegion1: + case D3D11Chunk::UpdateSubresource1: + case D3D11Chunk::ClearView: + case D3D11Chunk::VSSetConstantBuffers1: + case D3D11Chunk::HSSetConstantBuffers1: + case D3D11Chunk::DSSetConstantBuffers1: + case D3D11Chunk::GSSetConstantBuffers1: + case D3D11Chunk::PSSetConstantBuffers1: + case D3D11Chunk::CSSetConstantBuffers1: + case D3D11Chunk::PushMarker: + case D3D11Chunk::SetMarker: + case D3D11Chunk::PopMarker: + case D3D11Chunk::DiscardResource: + case D3D11Chunk::DiscardView: + case D3D11Chunk::DiscardView1: + case D3D11Chunk::PostExecuteCommandList: + case D3D11Chunk::PostFinishCommandListSet: + case D3D11Chunk::SwapDeviceContextState: + case D3D11Chunk::SwapchainPresent: + return m_pImmediateContext->ProcessChunk(ser, context); + + // no explicit default so that we have compiler warnings if a chunk isn't explicitly handled. + case D3D11Chunk::Max: break; + } + + { + SystemChunk system = (SystemChunk)context; + if(system == SystemChunk::DriverInit) { - SystemChunk system = (SystemChunk)context; - if(system == SystemChunk::DriverInit) - { - D3D11InitParams InitParams; - SERIALISE_ELEMENT(InitParams); + D3D11InitParams InitParams; + SERIALISE_ELEMENT(InitParams); - SERIALISE_CHECK_READ_ERRORS(); - } - else if(system == SystemChunk::InitialContentsList) - { - GetResourceManager()->CreateInitialContents(ser); + SERIALISE_CHECK_READ_ERRORS(); + } + else if(system == SystemChunk::InitialContentsList) + { + GetResourceManager()->CreateInitialContents(ser); - SERIALISE_CHECK_READ_ERRORS(); - } - else if(system == SystemChunk::InitialContents) - { - return Serialise_InitialState(ser, ResourceId(), NULL, NULL); - } - else if(system == SystemChunk::CaptureScope) - { - return Serialise_CaptureScope(ser); - } - else if(system < SystemChunk::FirstDriverChunk) - { - RDCERR("Unexpected system chunk in capture data: %u", system); - ser.SkipCurrentChunk(); + SERIALISE_CHECK_READ_ERRORS(); + } + else if(system == SystemChunk::InitialContents) + { + return Serialise_InitialState(ser, ResourceId(), NULL, NULL); + } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } + else if(system < SystemChunk::FirstDriverChunk) + { + RDCERR("Unexpected system chunk in capture data: %u", system); + ser.SkipCurrentChunk(); - SERIALISE_CHECK_READ_ERRORS(); - } - else - { - return m_pImmediateContext->ProcessChunk(ser, context); - } - - break; + SERIALISE_CHECK_READ_ERRORS(); + } + else + { + RDCERR("Unrecognised Chunk type %d", context); + return false; } } diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 414a82b61..0fadb534b 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -708,41 +708,76 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu case D3D12Chunk::Swapchain_Present: ret = m_pDevice->Serialise_Present(ser, NULL, 0, 0); break; - case D3D12Chunk::List_ClearState: ret = m_ReplayList->Serialise_ClearState(ser, NULL); break; - - default: - { - SystemChunk system = (SystemChunk)chunk; - - if(system == SystemChunk::CaptureEnd) - { - SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()).TypedAs("ID3D12Resource *"_lit); - - SERIALISE_CHECK_READ_ERRORS(); - - if(PresentedImage != ResourceId()) - m_Cmd.m_LastPresentedImage = PresentedImage; - - if(IsLoading(m_State) && m_Cmd.m_LastChunk != D3D12Chunk::Swapchain_Present) - { - m_Cmd.AddEvent(); - - DrawcallDescription draw; - draw.name = "End of Capture"; - draw.flags |= DrawFlags::Present; - - draw.copyDestination = m_Cmd.m_LastPresentedImage; - - m_Cmd.AddDrawcall(draw, true); - } - - ret = true; - } - else - { - RDCERR("Unrecognised Chunk type %s", ToStr(chunk).c_str()); - } + case D3D12Chunk::List_ClearState: + ret = m_ReplayList->Serialise_ClearState(ser, NULL); break; + + // in order to get a warning if we miss a case, we explicitly handle the device creation chunks + // here. If we actually encounter one it's an error (we shouldn't see these inside the captured + // frame itself) + case D3D12Chunk::Device_CreateCommandQueue: + case D3D12Chunk::Device_CreateCommandAllocator: + case D3D12Chunk::Device_CreateCommandList: + case D3D12Chunk::Device_CreateGraphicsPipeline: + case D3D12Chunk::Device_CreateComputePipeline: + case D3D12Chunk::Device_CreateDescriptorHeap: + case D3D12Chunk::Device_CreateRootSignature: + case D3D12Chunk::Device_CreateCommandSignature: + case D3D12Chunk::Device_CreateHeap: + case D3D12Chunk::Device_CreateCommittedResource: + case D3D12Chunk::Device_CreatePlacedResource: + case D3D12Chunk::Device_CreateReservedResource: + case D3D12Chunk::Device_CreateQueryHeap: + case D3D12Chunk::Device_CreateFence: + case D3D12Chunk::SetName: + case D3D12Chunk::SetShaderDebugPath: + case D3D12Chunk::CreateSwapBuffer: + case D3D12Chunk::Device_CreatePipelineState: + case D3D12Chunk::Device_CreateHeapFromAddress: + case D3D12Chunk::Device_CreateHeapFromFileMapping: + case D3D12Chunk::Device_OpenSharedHandle: + case D3D12Chunk::Device_CreateCommandList1: + case D3D12Chunk::Device_CreateCommittedResource1: + case D3D12Chunk::Device_CreateHeap1: + case D3D12Chunk::Device_ExternalDXGIResource: + RDCERR("Unexpected chunk while processing frame: %s", ToStr(chunk).c_str()); + return false; + + // no explicit default so that we have compiler warnings if a chunk isn't explicitly handled. + case D3D12Chunk::Max: break; + } + + { + SystemChunk system = (SystemChunk)chunk; + + if(system == SystemChunk::CaptureEnd) + { + SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()).TypedAs("ID3D12Resource *"_lit); + + SERIALISE_CHECK_READ_ERRORS(); + + if(PresentedImage != ResourceId()) + m_Cmd.m_LastPresentedImage = PresentedImage; + + if(IsLoading(m_State) && m_Cmd.m_LastChunk != D3D12Chunk::Swapchain_Present) + { + m_Cmd.AddEvent(); + + DrawcallDescription draw; + draw.name = "End of Capture"; + draw.flags |= DrawFlags::Present; + + draw.copyDestination = m_Cmd.m_LastPresentedImage; + + m_Cmd.AddDrawcall(draw, true); + } + + ret = true; + } + else + { + RDCERR("Unrecognised Chunk type %s", ToStr(chunk).c_str()); + return false; } } diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 135ae6c06..94bf7d5d1 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -2930,68 +2930,49 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context) { case D3D12Chunk::Device_CreateCommandQueue: return Serialise_CreateCommandQueue(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateCommandAllocator: return Serialise_CreateCommandAllocator(ser, D3D12_COMMAND_LIST_TYPE_DIRECT, IID(), NULL); - break; case D3D12Chunk::Device_CreateCommandList: return Serialise_CreateCommandList(ser, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, NULL, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateGraphicsPipeline: return Serialise_CreateGraphicsPipelineState(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateComputePipeline: return Serialise_CreateComputePipelineState(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateDescriptorHeap: return Serialise_CreateDescriptorHeap(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateRootSignature: return Serialise_CreateRootSignature(ser, 0, NULL, 0, IID(), NULL); - break; case D3D12Chunk::Device_CreateCommandSignature: return Serialise_CreateCommandSignature(ser, NULL, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateHeap: return Serialise_CreateHeap(ser, NULL, IID(), NULL); break; case D3D12Chunk::Device_CreateCommittedResource: return Serialise_CreateCommittedResource(ser, NULL, D3D12_HEAP_FLAG_NONE, NULL, D3D12_RESOURCE_STATE_COMMON, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreatePlacedResource: return Serialise_CreatePlacedResource(ser, NULL, 0, NULL, D3D12_RESOURCE_STATE_COMMON, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateReservedResource: return Serialise_CreateReservedResource(ser, NULL, D3D12_RESOURCE_STATE_COMMON, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateQueryHeap: return Serialise_CreateQueryHeap(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateFence: return Serialise_CreateFence(ser, 0, D3D12_FENCE_FLAG_NONE, IID(), NULL); - break; - case D3D12Chunk::SetName: return Serialise_SetName(ser, 0x0, ""); break; - case D3D12Chunk::SetShaderDebugPath: - return Serialise_SetShaderDebugPath(ser, NULL, NULL); - break; + case D3D12Chunk::SetName: return Serialise_SetName(ser, 0x0, ""); + case D3D12Chunk::SetShaderDebugPath: return Serialise_SetShaderDebugPath(ser, NULL, NULL); case D3D12Chunk::CreateSwapBuffer: return Serialise_WrapSwapchainBuffer(ser, NULL, DXGI_FORMAT_UNKNOWN, 0, NULL); - break; case D3D12Chunk::Device_CreatePipelineState: return Serialise_CreatePipelineState(ser, NULL, IID(), NULL); - break; // these functions are serialised as-if they are a real heap. case D3D12Chunk::Device_CreateHeapFromAddress: case D3D12Chunk::Device_CreateHeapFromFileMapping: return Serialise_CreateHeap(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_OpenSharedHandle: return Serialise_OpenSharedHandle(ser, NULL, IID(), NULL); - break; case D3D12Chunk::Device_CreateCommandList1: return Serialise_CreateCommandList1(ser, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_LIST_FLAG_NONE, IID(), NULL); @@ -3001,44 +2982,133 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context) case D3D12Chunk::Device_CreateHeap1: return Serialise_CreateHeap1(ser, NULL, NULL, IID(), NULL); case D3D12Chunk::Device_ExternalDXGIResource: return Serialise_OpenSharedHandle(ser, NULL, IID(), NULL); - break; - default: + + // in order to get a warning if we miss a case, we explicitly handle the list/queue chunks here. + // If we actually encounter one it's an error (we should hit CaptureBegin first and switch to + // D3D12CommandData::ProcessChunk) + case D3D12Chunk::Device_CreateConstantBufferView: + case D3D12Chunk::Device_CreateShaderResourceView: + case D3D12Chunk::Device_CreateUnorderedAccessView: + case D3D12Chunk::Device_CreateRenderTargetView: + case D3D12Chunk::Device_CreateDepthStencilView: + case D3D12Chunk::Device_CreateSampler: + case D3D12Chunk::Device_CopyDescriptors: + case D3D12Chunk::Device_CopyDescriptorsSimple: + case D3D12Chunk::Queue_ExecuteCommandLists: + case D3D12Chunk::Queue_Signal: + case D3D12Chunk::Queue_Wait: + case D3D12Chunk::Queue_UpdateTileMappings: + case D3D12Chunk::Queue_CopyTileMappings: + case D3D12Chunk::Queue_BeginEvent: + case D3D12Chunk::Queue_SetMarker: + case D3D12Chunk::Queue_EndEvent: + case D3D12Chunk::List_Close: + case D3D12Chunk::List_Reset: + case D3D12Chunk::List_ResourceBarrier: + case D3D12Chunk::List_BeginQuery: + case D3D12Chunk::List_EndQuery: + case D3D12Chunk::List_ResolveQueryData: + case D3D12Chunk::List_SetPredication: + case D3D12Chunk::List_DrawIndexedInstanced: + case D3D12Chunk::List_DrawInstanced: + case D3D12Chunk::List_Dispatch: + case D3D12Chunk::List_ExecuteIndirect: + case D3D12Chunk::List_ExecuteBundle: + case D3D12Chunk::List_CopyBufferRegion: + case D3D12Chunk::List_CopyTextureRegion: + case D3D12Chunk::List_CopyResource: + case D3D12Chunk::List_ResolveSubresource: + case D3D12Chunk::List_ClearRenderTargetView: + case D3D12Chunk::List_ClearDepthStencilView: + case D3D12Chunk::List_ClearUnorderedAccessViewUint: + case D3D12Chunk::List_ClearUnorderedAccessViewFloat: + case D3D12Chunk::List_DiscardResource: + case D3D12Chunk::List_IASetPrimitiveTopology: + case D3D12Chunk::List_IASetIndexBuffer: + case D3D12Chunk::List_IASetVertexBuffers: + case D3D12Chunk::List_SOSetTargets: + case D3D12Chunk::List_RSSetViewports: + case D3D12Chunk::List_RSSetScissorRects: + case D3D12Chunk::List_SetPipelineState: + case D3D12Chunk::List_SetDescriptorHeaps: + case D3D12Chunk::List_OMSetRenderTargets: + case D3D12Chunk::List_OMSetStencilRef: + case D3D12Chunk::List_OMSetBlendFactor: + case D3D12Chunk::List_SetGraphicsRootDescriptorTable: + case D3D12Chunk::List_SetGraphicsRootSignature: + case D3D12Chunk::List_SetGraphicsRoot32BitConstant: + case D3D12Chunk::List_SetGraphicsRoot32BitConstants: + case D3D12Chunk::List_SetGraphicsRootConstantBufferView: + case D3D12Chunk::List_SetGraphicsRootShaderResourceView: + case D3D12Chunk::List_SetGraphicsRootUnorderedAccessView: + case D3D12Chunk::List_SetComputeRootDescriptorTable: + case D3D12Chunk::List_SetComputeRootSignature: + case D3D12Chunk::List_SetComputeRoot32BitConstant: + case D3D12Chunk::List_SetComputeRoot32BitConstants: + case D3D12Chunk::List_SetComputeRootConstantBufferView: + case D3D12Chunk::List_SetComputeRootShaderResourceView: + case D3D12Chunk::List_SetComputeRootUnorderedAccessView: + case D3D12Chunk::List_CopyTiles: + case D3D12Chunk::List_AtomicCopyBufferUINT: + case D3D12Chunk::List_AtomicCopyBufferUINT64: + case D3D12Chunk::List_OMSetDepthBounds: + case D3D12Chunk::List_ResolveSubresourceRegion: + case D3D12Chunk::List_SetSamplePositions: + case D3D12Chunk::List_SetViewInstanceMask: + case D3D12Chunk::List_WriteBufferImmediate: + case D3D12Chunk::List_BeginRenderPass: + case D3D12Chunk::List_EndRenderPass: + case D3D12Chunk::List_RSSetShadingRate: + case D3D12Chunk::List_RSSetShadingRateImage: + case D3D12Chunk::PushMarker: + case D3D12Chunk::PopMarker: + case D3D12Chunk::SetMarker: + case D3D12Chunk::Resource_Unmap: + case D3D12Chunk::Resource_WriteToSubresource: + case D3D12Chunk::List_IndirectSubCommand: + case D3D12Chunk::Swapchain_Present: + case D3D12Chunk::List_ClearState: + RDCERR("Unexpected chunk while processing initialisation: %s", ToStr(context).c_str()); + return false; + + // no explicit default so that we have compiler warnings if a chunk isn't explicitly handled. + case D3D12Chunk::Max: break; + } + + { + SystemChunk system = (SystemChunk)context; + if(system == SystemChunk::DriverInit) { - SystemChunk system = (SystemChunk)context; - if(system == SystemChunk::DriverInit) - { - D3D12InitParams InitParams; - SERIALISE_ELEMENT(InitParams); + D3D12InitParams InitParams; + SERIALISE_ELEMENT(InitParams); - SERIALISE_CHECK_READ_ERRORS(); - } - else if(system == SystemChunk::InitialContentsList) - { - GetResourceManager()->CreateInitialContents(ser); + SERIALISE_CHECK_READ_ERRORS(); + } + else if(system == SystemChunk::InitialContentsList) + { + GetResourceManager()->CreateInitialContents(ser); - SERIALISE_CHECK_READ_ERRORS(); - } - else if(system == SystemChunk::InitialContents) - { - return GetResourceManager()->Serialise_InitialState(ser, ResourceId(), NULL, NULL); - } - else if(system == SystemChunk::CaptureScope) - { - return Serialise_CaptureScope(ser); - } - else if(system < SystemChunk::FirstDriverChunk) - { - RDCERR("Unexpected system chunk in capture data: %u", system); - ser.SkipCurrentChunk(); + SERIALISE_CHECK_READ_ERRORS(); + } + else if(system == SystemChunk::InitialContents) + { + return GetResourceManager()->Serialise_InitialState(ser, ResourceId(), NULL, NULL); + } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } + else if(system < SystemChunk::FirstDriverChunk) + { + RDCERR("Unexpected system chunk in capture data: %u", system); + ser.SkipCurrentChunk(); - SERIALISE_CHECK_READ_ERRORS(); - } - else - { - RDCERR("Unexpected chunk %s", ToStr(context).c_str()); - return false; - } - break; + SERIALISE_CHECK_READ_ERRORS(); + } + else + { + RDCERR("Unexpected chunk %s", ToStr(context).c_str()); + return false; } } diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 9b240c493..d3fe41863 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -2917,68 +2917,75 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) case VulkanChunk::vkQueuePresentKHR: return Serialise_vkQueuePresentKHR(ser, VK_NULL_HANDLE, NULL); - default: + // chunks that are reserved but not yet serialised + case VulkanChunk::vkResetCommandPool: + case VulkanChunk::vkCreateDepthTargetView: + RDCERR("Unexpected Chunk type %s", ToStr(chunk).c_str()); + + // no explicit default so that we have compiler warnings if a chunk isn't explicitly handled. + case VulkanChunk::Max: break; + } + + { + SystemChunk system = (SystemChunk)chunk; + if(system == SystemChunk::DriverInit) { - SystemChunk system = (SystemChunk)chunk; - if(system == SystemChunk::DriverInit) + VkInitParams InitParams; + SERIALISE_ELEMENT(InitParams); + + SERIALISE_CHECK_READ_ERRORS(); + + AddResourceCurChunk(InitParams.InstanceID); + } + else if(system == SystemChunk::InitialContentsList) + { + GetResourceManager()->CreateInitialContents(ser); + + SERIALISE_CHECK_READ_ERRORS(); + } + else if(system == SystemChunk::InitialContents) + { + return Serialise_InitialState(ser, ResourceId(), NULL, NULL); + } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } + else if(system == SystemChunk::CaptureEnd) + { + SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()).TypedAs("VkImage"_lit); + + SERIALISE_CHECK_READ_ERRORS(); + + if(PresentedImage != ResourceId()) + m_LastPresentedImage = PresentedImage; + + if(IsLoading(m_State) && m_LastChunk != VulkanChunk::vkQueuePresentKHR) { - VkInitParams InitParams; - SERIALISE_ELEMENT(InitParams); + AddEvent(); - SERIALISE_CHECK_READ_ERRORS(); + DrawcallDescription draw; + draw.name = "End of Capture"; + draw.flags |= DrawFlags::Present; - AddResourceCurChunk(InitParams.InstanceID); + draw.copyDestination = m_LastPresentedImage; + + AddDrawcall(draw, true); } - else if(system == SystemChunk::InitialContentsList) - { - GetResourceManager()->CreateInitialContents(ser); - SERIALISE_CHECK_READ_ERRORS(); - } - else if(system == SystemChunk::InitialContents) - { - return Serialise_InitialState(ser, ResourceId(), NULL, NULL); - } - else if(system == SystemChunk::CaptureScope) - { - return Serialise_CaptureScope(ser); - } - else if(system == SystemChunk::CaptureEnd) - { - SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()).TypedAs("VkImage"_lit); + return true; + } + else if(system < SystemChunk::FirstDriverChunk) + { + RDCERR("Unexpected system chunk in capture data: %u", system); + ser.SkipCurrentChunk(); - SERIALISE_CHECK_READ_ERRORS(); - - if(PresentedImage != ResourceId()) - m_LastPresentedImage = PresentedImage; - - if(IsLoading(m_State) && m_LastChunk != VulkanChunk::vkQueuePresentKHR) - { - AddEvent(); - - DrawcallDescription draw; - draw.name = "End of Capture"; - draw.flags |= DrawFlags::Present; - - draw.copyDestination = m_LastPresentedImage; - - AddDrawcall(draw, true); - } - - return true; - } - else if(system < SystemChunk::FirstDriverChunk) - { - RDCERR("Unexpected system chunk in capture data: %u", system); - ser.SkipCurrentChunk(); - - SERIALISE_CHECK_READ_ERRORS(); - } - else - { - RDCERR("Unrecognised Chunk type %d", chunk); - return false; - } + SERIALISE_CHECK_READ_ERRORS(); + } + else + { + RDCERR("Unrecognised Chunk type %d", chunk); + return false; } }