Attaching Graphics Debuggers to Minecraft

From shaderLABS

RenderDoc

RenderDoc is an open source, cross-platform graphics debugger for OpenGL, DirectX and Vulkan among other API-s. You can download it here: https://renderdoc.org/.

Attaching to Minecraft

By far the easiest way to attach RenderDoc to Minecraft is to first attach it to the launcher and capture the java process from there.

1. Launch RenderDoc and go to the "Launch Application" tab:

The "Launch Application" tab

2. Click on the 3 dots next to the "Executable Path" input field and find the executable file of the launcher. On Windows the easiest way to do this is to search for it in the Start Menu, right click on the program and select "Open file location". This should take you to the Windows Start menu program list, from there right click on the relevant icon again and select "Open file location", this will take you to the actual exe file.

The default Minecraft launcher can be hard to reach, so I recommend using an alternative launcher instead (e.g. Prism).

3. Under "Capture Options" check "Capture Child Processes", the end result should look like this:

The state of RenderDoc after the last step

4. Hit "Launch"

5. Launch the game as usual

6. RenderDoc should've redirected you to another tab with the name of the executable file. From here double click on "javaw.exe" under "Child Processes".

Capturing frames and basic overview

Once you're in game you can hit F12 to capture a frame. This might freeze the game and sometimes even your computer for a second, but it should recover. When it does, you can go back to RenderDoc and under the "javaw" tab double click on the latest image under "Captures collected".

From here the most useful window is the "Event Browser" on the left, this contains every draw call issued by the CPU to the GPU. The best way to find a specific pass is to click through the list on the left with the "Texture Viewer" tab active on the right, this shows the output of the current draw call. In Iris draw calls starting with "glMulti" are generally gbuffers and "glDrawElements(6)" calls are composite shaders.

Once you found the pass you want to analyze, here's what each tab can do for you:

  • Pipeline State: Collects the inputs and outputs of each stage of the pipeline, useful if you want to diagnose problems with uniforms or SSBO-s.
  • Texture Viewer: This tab lets you view the fragment shader outputs.
  • Mesh Viewer: Shows you what the input mesh is (usually irrelevant) and what the geometry and vertex shaders outputs.

Sharing captures

If you can't find the problem and want to ask for help, you can save the capture to a file and share that. Others can open it and check what the shader did. One caveat: This only saves the draw calls, the outputs will be recalculated on the fly, meaning issues caused by vendor differences might not show up.

Nsight Graphics

Nsight Graphics is the Nvidia-only graphics debugger and performance analyzer. You can get it here: https://developer.nvidia.com/nsight-graphics. It's less beginner friendly, than RenderDoc, but it has more features.

Attaching the debugger to Minecraft

The best way to attach Nsight to minecraft is through the launcher.

1. Launch Nsight Graphics

2. On the main page hit "Start Activity..."

3. Under target platform next to the "Application Executable" input field hit the 3 dots and select the executable file of the launcher. On Windows the easiest way to do this is to search for it in the Start Menu, right click on the program and select "Open file location". This should take you to the Windows Start menu program list, from there right click on the relevant icon again and select "Open file location", this will take you to the actual exe file.

The default Minecraft launcher can be hard to reach, so I recommend using an alternative launcher instead (e.g. Prism).

4. Under "Activity" make sure you have "Frame Debugger" and under that "OpenGL" selected. The result should look like this:

Launch settings

5. Click "Launch Frame Debugger"

6. If you get a message about interfering processes, click "Terminate".

7. Launch the game through your chosen launcher as usual.

Capturing and debugging a frame

Once you're in the game, you can hit F11 to capture a frame. You'll get a message warning you about an unsupported API, in this case hit enter. You'll also get a warning inside Nsight Graphics, you can click Ok on this too.

On the left side you'll see the "Events" window, this contains every draw call issued by the CPU to the GPU. The best way to find a specific pass is to click through the list on the left with while looking at the "Current Target" window on the right. In Iris draw calls starting with "glMulti" are generally gbuffers and "glDrawElements(6)" calls are composite shaders. Alternatively you can use the "Scrubber" window to look through the frame and roughly find the pass you're looking for. Once you found the pass you want to analyze, here's what each tab under "API Inspector" can do for you:

  • VS: The state of the vertex shader with inputs and uniforms.
  • FS: The state of the fragment with uniforms and outputs.
  • Textures, Images, Buffers: The various resources attached to the pass in some way.

Analyzing performance bottlenecks with Nsight

Make sure to launch Nsight with administrator rights. Instead of using "Frame Debugger" when launching an activity, select "GPU Trace Profiler" under "Activity", then hit "Launch GPU Trace". After this launch the game as usual. Disregard warnings about an unsupported OS if you're using Windows 11.

Once you're ingame, hit F11. If you get a warning, hit Enter. You can hit "Open" in Nsight when it loads in. The result of this page is too complicated for this page and requires a decent amount of knowledge about how GPUs work, you can check https://docs.nvidia.com/nsight-graphics/AdvancedLearning/index.html to get a general idea or ask people who know better and attach the trace.