baldurk / renderdoc

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

OpenGL Program run through RenderDoc crashes when a frame capture is taken #3410

Closed SEGenjoysBlivits closed 2 months ago

SEGenjoysBlivits commented 2 months ago

Description

I'm currently trying to create a frame capture of my Program. This works fine on my PC, on my Laptop (of which the specs are listed below) however, the Program freezes for 5 seconds then crashes with this error without producing a capture. X is a very large number that is not consistent.

Fatal - Allocation for X bytes failed

Steps to reproduce

  1. Extract the zip file I have provided
  2. Run ResontideServer
  3. Run ResontideClient through RenderDoc
  4. Attempt to create a capture
  5. If the program doesn't crash here you probably don't have the same Hardware or Drivers as I do.

If I was able to show a capture, I wouldn't be creating this issue.

Environment

Resontide.zip

SEGenjoysBlivits commented 2 months ago

I just tested it again and it printed this "Fatal - Allocation for 159642125736800 bytes failed". Why is it trying to allocate 159 TB of RAM?

baldurk commented 2 months ago

The out of memory error is because a texture is being created that would require that many bytes for storage. The program looks to create a single 2D texture and its dimensions seem to vary unpredictably but width and height are usually both out of valid bounds with width being quite massive, e.g. 1626870080x29282 or 1102582080x29072.

This is invalid use of the API as GL requires all dimensions to be less than GL_MAX_TEXTURE_SIZE (16384 on my system). You should run you program with validation enabled and maybe check for uninitialised memory given that the values are not consistent and look like they are random.

SEGenjoysBlivits commented 2 months ago

That checks out, I added a texture to my game recently with a resolution of 3072 x 3072 recently. I'll try running with validation enabled and see what I get. Thanks for your help!

SEGenjoysBlivits commented 2 months ago

How do I run my Program with validation enabled?

baldurk commented 2 months ago

You should look for GL documentation on how to enable validation. I do not recommend trying to enable or run validation with RenderDoc as this can cause false positives or false negatives.

Especially in this case because the error is most likely in your code itself and not your API use if there is uninitialised memory use, you would be best put at looking at regular CPU debugging or memory sanitisers.

SEGenjoysBlivits commented 2 months ago

It turns out that my asset embedder had a bug where the file size and file name length got mixed up making OpenGL think that "blocks.png" was just 10 bytes large. Yikes!