microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
6.07k stars 2.03k forks source link

VSGD frame capture with ExecuteIndirect modifying root constants will not open #176

Open KolyaNaichuk opened 8 years ago

KolyaNaichuk commented 8 years ago

Hello!

I am running into pretty much the same issue described here https://github.com/Microsoft/DirectX-Graphics-Samples/issues/158. According to the thread, it is supposed to be fixed in Windows Insider Fast build (14361). I am running Windows Insider build (14379.rs1_release.160627-1607) and have VS of version 14.0.25421.03 with update 3.

During the capture, VS will crash. Before the crash occurs, I get in VS output window the following warning:

"D3D12 WARNING: ID3D12Resource::ID3D12Resource::Map: pReadRange is NULL and the heap page property is WRITE_BACK. This can be an indicator of inefficiencies that will result on mobile systems, as the range should be as tight as possible. But, it is also possible the range must encompass the whole subresource.A NULL pReadRange parameter indicates all resource memory will be read by the CPU. [ EXECUTION WARNING #930: MAP_INVALID_NULLRANGE] D3D12: BREAK enabled for the previous message, which was: [ WARNING EXECUTION #930: MAP_INVALID_NULLRANGE ]"

Below is VS callstack with downloaded debug symbols:

KernelBase.dll!_RaiseException@16() Unknown DXGIDebug.dll!CInfoQueue::AddMessage(struct _GUID,void ,enum DXGI_INFO_QUEUE_MESSAGE_CATEGORY,enum DXGI_INFO_QUEUE_MESSAGE_SEVERITY,int,char const ) Unknown d3d12SDKLayers.dll!CInfoQueue::AddMessage(enum D3D12_MESSAGE_CATEGORY,enum D3D12_MESSAGE_SEVERITY,enum D3D12_MESSAGE_ID,char const ) Unknown d3d12SDKLayers.dll!NDebug::CInterfaceSentinel::CFunctionSentinel::ReportMessageImpl(enum D3D12_MESSAGE_ID,char const ,bool,char ) Unknown d3d12SDKLayers.dll!NDebug::CInterfaceSentinel::CFunctionSentinel::operator()(enum D3D12_MESSAGE_ID,char const ,...) Unknown d3d12SDKLayers.dll!ValidateMapOrUnmapCall(class NDebug::CInterfaceSentinel::CFunctionSentinel &,struct ResourceValidationInfo const &,struct DeviceValidationInfo const &,unsigned int,struct D3D12_RANGE const ,void * ,bool) Unknown d3d12SDKLayers.dll!NDebug::CResource::Map(unsigned int,struct D3D12_RANGE const ,void * ) Unknown DXCaptureReplay.dll!GRFXTool::D3D12ResourceReadback::Initialize(class GRFXTool::CAutoExecutionContext &,struct DXSerialization::SResourceCurrentUsage const ,enum D3D12_HEAP_TYPE,unsigned int,struct ID3D12Resource ) Unknown DXCaptureReplay.dll!GRFXTool::ResourceCapture::ResourceCaptureHelper12::CaptureResourceWithInitialData<class >(class ) Unknown DXCaptureReplay.dll!GRFXTool::ResourceCapture::DXGISwapChainBufferCapture(class GRFXTool::ToolResource ,class GRFXTool::CaptureContext &) Unknown DXCaptureReplay.dll!GRFXTool::CaptureToolLayer::WriteRecreation(class GRFXTool::CaptureContext &,class GRFXTool::OutputSerializer ,class GRFXTool::ToolResource ,struct GRFXTool::RecreateInfo const &) Unknown DXCaptureReplay.dll!GRFXTool::CaptureToolLayer::CheckResourceForRecreation(class GRFXTool::ToolResource ,bool) Unknown DXCaptureReplay.dll!GRFXTool::DependencyTracker::MarkDependency(class GRFXTool::ToolResource ) Unknown DXCaptureReplay.dll!GRFXTool::ResourceCapture::ID3D12CommandListDependency(class GRFXTool::ToolResource ,class GRFXTool::DependencyTracker &) Unknown DXCaptureReplay.dll!GRFXTool::CaptureToolLayer::WriteRecreation(class GRFXTool::CaptureContext &,class GRFXTool::OutputSerializer ,class GRFXTool::ToolResource ,struct GRFXTool::RecreateInfo const &) Unknown DXCaptureReplay.dll!GRFXTool::CaptureToolLayer::CheckResourceForRecreation(class GRFXTool::ToolResource ,bool) Unknown DXCaptureReplay.dll!GRFXTool::CaptureToolLayer::OnOutputResource(class GRFXTool::ToolResource ,bool) Unknown DXCaptureReplay.dll!GRFXTool::SerializeRes(class GRFXTool::OutputSerializer ,struct ID2D1Device ,char const ,bool) Unknown DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::ToolD3D12GraphicsCommandListGenerated::Reset(struct ID3D12CommandAllocator ,struct ID3D12PipelineState ) Unknown DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::ToolD3D12VirtualGraphicsCommandList::Reset(struct ID3D12CommandAllocator ,struct ID3D12PipelineState *) Unknown

Following the advice from the previous thread, I disabled debug layer and info queue. I was able to make capture but still no luck with opening it. I am getting the error "The Graphics Diagnostics engine has encountered a fatal error. Please try to reopen the document again, and if the problem persists, please contact the support team".

I am not able to save .vsglog file since "Save Seleted Items As" menu option is disabled in File menu. I have uploaded .diagsession file in case it is sufficient https://dl.dropboxusercontent.com/u/96151288/CaptureReport.diagsession

Many thanks!

KolyaNaichuk commented 8 years ago

Hello guys! Have you had a chance to go trough the issue description? It has been more than 23 days since I reported it.

bobbrow commented 8 years ago

Sorry @KolyaNaichuk, I have not had a chance to investigate this yet. I wasn't able to get to it before I took vacation, but it is in my backlog.

KolyaNaichuk commented 8 years ago

@bobbrow Sounds great!

Also, I am wondering if VS Graphics Debugger supports frame capture containing IndirectExecute call. I am getting the same error while trying to open the frame capture after.

Thanks!

bobbrow commented 8 years ago

The VS Graphics Debugger works with the ExecuteIndirect sample in our repository. Our sample is quite simple though, so it is possible there is a bug in the Graphics Debugger.

KolyaNaichuk commented 8 years ago

@bobbrow I discovered that the capture will not open if I have ExecuteIndirect pass. Otherwise, I am able to open it successfully, provided that debug layer and info queue are disabled.

bobbrow commented 8 years ago

When I played back the capture it looked like the crash was in a SetGraphicsRoot32BitConstants method. It's trying to set one constant value on parameter 1 of your root signature, but the input data is null. Do you update root constants in your ExecuteIndirect packet? Can you share your command signature?

KolyaNaichuk commented 8 years ago

@bobbrow Wow, thanks for such a prompt response! Please check the uploaded source code: https://dl.dropboxusercontent.com/u/96151288/FrameCaptureCrash.zip Judging from the final image, material index which is passed as 32 bit constant corresponds to the expected result.

bobbrow commented 8 years ago

Based on what I see in the code, your root signature is assigning both the root CBV and the 32bit constant to shader register 0, but your execute indirect packet is trying to update constants in register 1 which is invalid.

Let me know if fixing your argumentDescs to point to the correct shader register allows VSGD to capture and playback your frames successfully. If not, we can try assigning unique shader registers to the root CBV and the 32bit constants and see if that works. Let me know what works and I can update the bug on our side.

KolyaNaichuk commented 8 years ago

"Based on what I see in the code, your root signature is assigning both the root CBV and the 32bit constant to shader register 0" I am not sure I am following you here.

CBV is assigned to register b0 and visible only to VS // cbuffer ObjectTransformBuffer : register(b0) 32 bit constant is assigned to register b0 and visible only to PS // cbuffer MaterialIndexBuffer : register(b0) Should not shader visibility suffice to handle this?

"but your execute indirect packet is trying to update constants in register 1 which is invalid." D3D12_INDIRECT_ARGUMENT_DESC argumentDescs[] = { // UINT rootParameterIndex, UINT destOffsetIn32BitValues, UINT num32BitValues Constant32BitArgument(1/rootParamIndex/, 0, 1), DrawIndexedArgument() };

// UINT shaderRegister, D3D12_SHADER_VISIBILITY shaderVisibility, UINT num32BitValues rootParams[1] = Root32BitConstantsParameter(0/shaderRegister/, D3D12_SHADER_VISIBILITY_PIXEL, 1);

Are you referring to "1" as root param index or shader register because shader register is 0. Please correct me I misunderstand something.

I tried to set shader register to 1 rootParams[1] = Root32BitConstantsParameter(1/shaderRegister/, D3D12_SHADER_VISIBILITY_PIXEL, 1); and cbuffer MaterialIndexBuffer : register(b1) but it did not work either.

bobbrow commented 8 years ago

You're right. I made a mistake while rushing to get a comment out before heading to a meeting. But I have enough information at this point to code up a simple repro app and send it to the debugger team.

KolyaNaichuk commented 8 years ago

Sweet. Please keep me posted when you have more info. Thanks!

adamrankin commented 8 years ago

Hello all,

I'm experiencing a similar error and though I would chime in. If there's any updates it would be much appreciated. This happens on 2 of my 3 machines (work machine seems ok).

I'll attach my related files in the hopes that they may shed some light.

Edit: only half a brain working, I'll add more detail. I'm working with the HoloLens emulator (10.0.14342.1018) writing a C++/CX application. Visual Studio Info, System Info, and DxDiag are located in text files in the zip.

graphics_analyzer_fatal_error.zip

bobbrow commented 8 years ago

You are using ExecuteIndirect as well? I'm a bit behind since I was out with a sick family yesterday, but will find some time today or tomorrow to take a look at your frame capture.

adamrankin commented 8 years ago

Ah pardon me! No I am using D3D11, DrawIndexedInstanced. Sorry about that.

bobbrow commented 8 years ago

Thanks for confirming.

KolyaNaichuk commented 7 years ago

Hi guys! Do you have any progress with the bug? :-)