baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.
https://renderdoc.org
MIT License
8.86k stars 1.33k forks source link

RenderDoc capture fails and gpu data is tampered #1176

Closed manhnt9 closed 5 years ago

manhnt9 commented 5 years ago

Description

May relate to #677

1. RenderDoc fails to capture:

Terminal log after launching, F12 and Queue Capture produce no logs.

./qrenderdoc 
Log     - QRenderDoc initialising.
Irrlicht Engine version 1.8.3-baw
Linux 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64
Creating X window...
Log     - Got remote handshake: GPU_Mesh [2877]
Using renderer: OpenGL 4.5.0
GeForce GTX 1050 Ti/PCIe/SSE2: NVIDIA Corporation
GLSL version: 45.0
Loaded texture: /home/manh/Desktop/gpu_buffer/skydome.jpg
Log     - Used API: OpenGL (Not presenting & supported)
Log     - Used API: OpenGL (Presenting & supported)

2. GPU buffer data

When running with RenderDoc (no frame capturing), the app should render the cube on screen but it doesn't. Cube still appears when running outside RenderDoc such as from Terminal.

Repro steps

gpu_buffer.zip

Extract above file, Open RenderDoc and run GPU_Mesh executabe.

Source code: https://github.com/buildaworldnet/IrrlichtBAW/tree/master/examples_tests/03.GPU_Mesh (uploaded version has been removed std::cin sky choice and changed shader/texture path for simplicity)

Environment

devshgraphicsprogramming commented 5 years ago

The worst part is that it actually stops the "straight forward" pipeline from working.

Persistently Mapped Buffer -> OpenGL copy buffers -> immutable device local unmappable unupdatable buffer

This can also be duplicated with example 05 (runs as standalone executable without needing any textures) https://github.com/buildaworldnet/IrrlichtBAW/blob/ad42894989fc9c45bf1f9eca659dea089d3dec0c/examples_tests/05.SpherePoints/bin/SpherePoints

This is worrying, as not only the capturing of a buffer is broken, but whole program operation while running through RenderDoc

I use

RenderDoc nightly from 12 Nov Ubuntu 18.04 Nvidia Driver 410 on 1060 Mobile

baldurk commented 5 years ago

Buffer mapping, particularly persistent mapped buffers, requires interception to capture in most cases so it's not too surprising that there can be bugs with some paths based on how many possible combinations and interactions there are in GL.

I'm trying to build the IrrlichtBAW project on windows so I can debug, just running into some compile problems that I'm fixing up as I go (I'll let you know what I come up with separately in case you find it useful).

devshgraphicsprogramming commented 5 years ago

In that case we flush explicitly so you should know what we've written.

The interesting thing is that we now use a WRITE_ONLY buffer for uploads whereas before we used read/write buffers for everything.

baldurk commented 5 years ago

Thanks, I think I understand the problem. I've got it building now so I'm investigating.

For reference these are the problems I ran into while building on VS2015. Some of these fixes might be invalid but you might know how to fix better:

baldurk commented 5 years ago

I believe this is a bug in the Irrlicht code:

struct IDriver declares a function virtual void flushMappedMemoryRanges with a default empty implementation. class COpenGLDriver declares it as flushBufferRanges which doesn't override the interface function - meaning the empty base class implementation is run and the map is never flushed in the first place.

Fixing the presumed typo in COpenGLDriver causes the example to work correctly and capture fine in RenderDoc with all data coming through for me. I'd recommend using the override specifier liberally - particularly with virtual interfaces being implemented - to turn problems like this into compile errors.

devshgraphicsprogramming commented 5 years ago

oh crap, sorry for wasting your time!

manhnt9 commented 5 years ago

Glad that it's resolved. Thank you @baldurk.