baldurk / renderdoc

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

RenderDoc opens the program panel for a second then closes #2954

Closed bwkam closed 1 year ago

bwkam commented 1 year ago

Description

I want to debug my program with RenderDoc, but the problem is that when I fill the Executable Path and Working directory, and launch it, but the problem is that at the moment I click 'Launch', it opens my program's panel for a second or two then closes for some reason. Of course, I'd expect it to stay open so I can debug. I also didn't find any errors or warnings in the Errors and Warnings panel.

Steps to reproduce

Environment

bwkam commented 1 year ago

Peek 2023-06-05 23-34

I don't know if that's helpful, but that's what literally happens, the program launches fine though when executing without RenderDoc.

baldurk commented 1 year ago

I'm trying to compile the project, at the moment on windows so I have access to a proper debugger, but I'm not familiar at all with your language or toolkits so I'm struggling a bit with how to do that.

I downloaded haxe from https://haxe.org and followed the instructions on https://github.com/Kode/Kha/wiki/Getting-Started for kha, assuming that's the right thing (including installing node). When I put it together and built your repository I get this error:

$ node Kha/make windows
Using Kha (3ca557db) from T:\tmp\rdoc_debug\issue\2954\kha-lightning-demo\Kha
Creating Kha project.
Error: Library zui not found.
Add it to the 'Libraries' subdirectory of your project. You may also install it via haxelib but that's less cool.
Error: khafile.js did not call resolve, no project created.
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Library zui not found.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.16.0
bwkam commented 1 year ago

oh, I think you should just run haxelib git zui https://github.com/armory3d/zui

baldurk commented 1 year ago

That revealed a new dependency on something called neko which I downloaded from https://nekovm.org/download/, but it got further before hitting a different error:

Using Kha (3ca557db) from T:\tmp\rdoc_debug\issue\2954\kha-lightning-demo\Kha
Creating Kha project.
Exporting asset 1 of 8 (black_white_gradient.png).
Exporting asset 2 of 8 (color_wheel.png).
Exporting asset 3 of 8 (container.jpg).
Exporting asset 4 of 8 (container2.png).
Exporting asset 5 of 8 (DroidSans.ttf).
Exporting asset 6 of 8 (kode.png).
Exporting asset 7 of 8 (specular.png).
Exporting asset 8 of 8 (uvtemplate.png).
Compiling shader 1 of 4 (cube.frag.glsl).
T:\tmp\rdoc_debug\issue\2954\kha-lightning-demo\build\temp\cube.frag.hlsl(73,69-77): error X3004: undeclared identifier '_material'

Compiling shader 1 of 4 (cube.frag.glsl) failed:
Shader compiler error.

Uploaded the hlsl file here: cube.frag.hlsl.

bwkam commented 1 year ago

I'm sorry I'm not sure what's causing that. Can you try a simpler program https://github.com/luboslenco/kha3d_examples/tree/master/tutorial01 instead. (the issue is also reproducible with it)

bwkam commented 1 year ago

Also forgot something, this was tested with OpenGL, so please use --graphics opengl flag when compiling.

baldurk commented 1 year ago

I wasn't able to reproduce on windows but repeating the setup on linux and working around a few compile problems I was able to get the crash to happen.

The issue is that your code is calling a GL function (specifically glGetIntegerv) with no GL context bound, which is what leads to the crash when running under RenderDoc. This is not legal and you should fix your code to make sure that you have a context properly bound to the thread before calling any GL functions.

I also noticed that you're using the Android egl... functions which mesa exports. I wouldn't recommend this when targetting proper OpenGL as this API is primarily for OpenGL ES, but mesa does seem to support this for Android compatibility and I think it does kind of work, so in theory it shouldn't be a problem if the error above is fixed.