ConfettiFX / The-Forge

The Forge Cross-Platform Rendering Framework PC Windows, Steamdeck (native), Ray Tracing, macOS / iOS, Android, XBOX, PS4, PS5, Switch, Quest 2
Apache License 2.0
4.8k stars 501 forks source link

Assert in the profiler (Win8.1) #119

Closed divinon closed 5 years ago

divinon commented 5 years ago

Hello, I have an assert on the example 02_Compute after about 30 seconds. The Forge targets Win 10 and I'm on a Win 8.1 so that could be the problem.

The failed assert is in the profiler when g_ProfileGpuLog is null, this happens here: https://github.com/ConfettiFX/The-Forge/blob/3cccad9a1364f5d7a21a245e9334a60234bb5656/Common_3/Tools/Profiler/ProfilerBase.cpp#L150 when the destructor of g_ForceProfileShutdown is called, this is the call stack:

02_Compute.exe!ForceProfileShutdown::~ForceProfileShutdown() Line 150
    at e:\engine\the-forge\common_3\tools\profiler\profilerbase.cpp(150)
02_Compute.exe!`dynamic atexit destructor for 'g_ForceProfileShutdown''()
02_Compute.exe!__dyn_tls_dtor(void * __formal, const unsigned long dwReason, void * __formal) Line 123
    at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\tls\tlsdtor.cpp(123)

Commenting this line solves the problem: https://github.com/ConfettiFX/The-Forge/blob/3cccad9a1364f5d7a21a245e9334a60234bb5656/Common_3/Tools/Profiler/ProfilerBase.cpp#L156

So from what I understand, a thread dies, since g_ForceProfileShutdown is P_THREAD_LOCAL it dies too and it resets g_ForceProfileShutdown g_ProfileGpuLog which is global and not thread local. I don't know what thread dies but it happens 100% after 28 seconds.

Not sure if related, but in the log I see this error every second: filesystem.cpp:367 ERR| Could not open file \\.\pipe\microprofile-contextswitch This error starts here: https://github.com/ConfettiFX/The-Forge/blob/3cccad9a1364f5d7a21a245e9334a60234bb5656/Common_3/Tools/Profiler/ProfilerBase.cpp#L3065 No idea about named pipes, but shouldn't it be created first? https://github.com/zeux/microprofile/blob/35291b789723221a9740c5b12e4e6a669330a2f9/src/contextswitch_etw/contextswitch_etw.cpp#L79

About Win 8.1, it works great with Vulkan. The only problem is 'GetDpiForSystem' missing in 8.1, it is here: https://github.com/ConfettiFX/The-Forge/blob/3cccad9a1364f5d7a21a245e9334a60234bb5656/Common_3/OS/Windows/WindowsBase.cpp#L625 but it could be loaded with GetModuleHandle or GetModuleHandleEx+FreeLibrary: https://github.com/Leandros/tracy/commit/34533ad4f13a5cec77f449c4b2ca200c54800a10

The DX11 works too but only after removing the flags D3DCOMPILE_ALL_RESOURCES_BOUND, D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES from the shader compiler. This seems to cause some errors (MaterialPLayground) and artifacts (LightShadowPlayground).

jdswebb commented 5 years ago

I believe there's a fix for the crash in the pipeline. You can work around it for now by changing line 100 of ProfilerBase.cpp from:

ProfileThreadLog* g_ProfileGpuLog = 0;

to

P_THREAD_LOCAL ProfileThreadLog* g_ProfileGpuLog = 0;

wolfgangfengel commented 5 years ago

A better fix comes with the next release ... hopefully tomorrow.

wolfgangfengel commented 5 years ago

On an unrelated note: we are testing more now on a Win 7 box ... so Win 8.1 should be supported better. One of our customers requires Win 7 ...

divinon commented 5 years ago

Thank you for quick replies. That's good, I'll wait for the next release and no worries I'm already all set now. Feel free to close this.