Jump to content
The Dark Mod Forums

[Bug] On Launch, Distorted First Frame When AA


Daft Mugi

Recommended Posts

When launching the game (from the OS desktop) with antialiasing turned on, there is a distorted frame before the main menu is shown. After the brief distortion, the main menu displays correctly and the game can be played without issue. I've included a photo of my screen that I took with a camera.

With antialiasing turned off, I do not see any distortion when launching the game.

Anyone else notice this or just me?

 

Linux, Ubuntu 22.04
AMD Radeon RX 6000 Series
OpenGL version: 4.6 (Core Profile) Mesa 22.0.5 core

Bug: https://bugs.thedarkmod.com/view.php?id=6150

tdm-launch-distorted-first-frame.jpg

Edited by Daft Mugi
  • Confused 1
Link to comment
Share on other sites

On 11/4/2022 at 11:37 PM, Daft Mugi said:

Did you see the TDM main menu?

The distorted frame shows after launching the game from the desktop and before the main menu displays.

Can't remember ever seeing it although I'm on AMD as well

But I never tried it with the MESA drivers - and usually my AA is off

Link to comment
Share on other sites

  • 4 weeks later...

I narrowed down this issue to the following line when msaa is "2" or greater:

// Line 226:renderer/FrameBuffer.cpp
qglRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, format, width, height);

In the function, "FrameBuffer::AddRenderBuffer()":

217  void FrameBuffer::AddRenderBuffer( GLuint &buffer, GLenum attachment, GLenum format, const idStr &name ) {
218    if (buffer != 0) {
219      qglDeleteRenderbuffers(1, &buffer);
220    }
221    qglGenRenderbuffers(1, &buffer);
222    qglBindRenderbuffer(GL_RENDERBUFFER, buffer);
223    GL_SetDebugLabel( GL_RENDERBUFFER, buffer, name );
224  
225    if (msaa > 1) {
226      qglRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, format, width, height);
227    } else {
228      qglRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
229    }
230  
231    Bind();
232    qglFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, buffer);
233  }

As I stated in the first post, this issue is not present when "r_multiSamples 0". So, the following code path is fine:

// Line 228:renderer/FrameBuffer.cpp
qglRenderbufferStorage(GL_RENDERBUFFER, format, width, height);

Also, if "qglRenderbufferStorageMultisample()" is called with msaa as "0", that is also fine.

// Line 226:renderer/FrameBuffer.cpp
qglRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, format, width, height);

I guess this is a bug in the Glad library.

I found this by commenting out code related to "r_multiSamples" and narrowed it down.

@duzenko @stgatilov What's a good next step?

Edited by Daft Mugi
Link to comment
Share on other sites

This is framebuffer setup code.
You have learnt that it you disable multisampling = antialiasing, then the issue does not happen.

I know that there is one frame during mission startup when GL error occurs.
And as far as I recall, it occured because of some FBO weirdness.
Maybe it's the source of the problem.

If you enable:

  • r_ignoreGlErrors 0
  • r_glDebugContext 1
  • r_glDebugOutput 2

Then I suppose you'll see it in game console.

Catching a problem on a single frame is quote hard.
Recently I used apitrace for this: it records all GL calls from the very start and allows to replay them to any moment.
We can try to use it if you want, but if the problem is visible only for you, then most likely only replaying on your machine will show it, so investigation will only be possible on your machine anyway.

Link to comment
Share on other sites

12 hours ago, stgatilov said:

I know that there is one frame during mission startup when GL error occurs.

This happens during game launch and not mission startup, if mission startup means entering the game world. This happens before the main menu is displayed for the first time. I've attached a series of screenshots.

12 hours ago, stgatilov said:

And as far as I recall, it occured because of some FBO weirdness.

Does FBO code run before the main menu displays for the first time?

12 hours ago, stgatilov said:

If you enable:

  • r_ignoreGlErrors 0
  • r_glDebugContext 1
  • r_glDebugOutput 2

I tried these settings and did not see any difference in console output.

12 hours ago, stgatilov said:

This is framebuffer setup code.

To me, it looks like that first frame is showing garbage memory - whatever happens to be in memory at the time. In other words, it seems that the "qglRenderbufferStorageMultisample()" function is not clearing/initializing the buffers before rendering. I'm not a graphics programmer, so I don't know. That's how it seems to me.

Maybe an updated Glad library would have a fix?

I tried running apitrace. Here's some output:

apitrace: loaded into ./thedarkmod.x64
apitrace: redirecting dlopen("libGL.so.1", 0x1) from ./thedarkmod.x64
apitrace: tracing to application.trace
apitrace: redirecting dlopen("libGL.so.1", 0x102) from ./thedarkmod.x64
apitrace: warning: unknown function "glRenderbufferStorageMultisampleAdvancedAMD"
apitrace: warning: unknown function "glNamedRenderbufferStorageMultisampleAdvancedAMD"
apitrace: warning: unknown function "glPolygonOffsetClamp"
apitrace: warning: unknown function "glEGLImageTargetTexStorageEXT"
apitrace: warning: unknown function "glEGLImageTargetTextureStorageEXT"
apitrace: warning: unknown function "glGetUnsignedBytevEXT"
apitrace: warning: unknown function "glGetUnsignedBytei_vEXT"
apitrace: warning: unknown function "glDeleteMemoryObjectsEXT"
apitrace: warning: unknown function "glIsMemoryObjectEXT"
apitrace: warning: unknown function "glCreateMemoryObjectsEXT"
apitrace: warning: unknown function "glMemoryObjectParameterivEXT"
apitrace: warning: unknown function "glGetMemoryObjectParameterivEXT"
apitrace: warning: unknown function "glTexStorageMem2DEXT"
apitrace: warning: unknown function "glTexStorageMem2DMultisampleEXT"
apitrace: warning: unknown function "glTexStorageMem3DEXT"
apitrace: warning: unknown function "glTexStorageMem3DMultisampleEXT"
apitrace: warning: unknown function "glBufferStorageMemEXT"
apitrace: warning: unknown function "glTextureStorageMem2DEXT"
apitrace: warning: unknown function "glTextureStorageMem2DMultisampleEXT"
apitrace: warning: unknown function "glTextureStorageMem3DEXT"
apitrace: warning: unknown function "glTextureStorageMem3DMultisampleEXT"
apitrace: warning: unknown function "glNamedBufferStorageMemEXT"
apitrace: warning: unknown function "glTexStorageMem1DEXT"
apitrace: warning: unknown function "glTextureStorageMem1DEXT"
apitrace: warning: unknown function "glImportMemoryFdEXT"
apitrace: warning: unknown function "glGetUnsignedBytevEXT"
apitrace: warning: unknown function "glGetUnsignedBytei_vEXT"
apitrace: warning: unknown function "glGenSemaphoresEXT"
apitrace: warning: unknown function "glDeleteSemaphoresEXT"
apitrace: warning: unknown function "glIsSemaphoreEXT"
apitrace: warning: unknown function "glSemaphoreParameterui64vEXT"
apitrace: warning: unknown function "glGetSemaphoreParameterui64vEXT"
apitrace: warning: unknown function "glWaitSemaphoreEXT"
apitrace: warning: unknown function "glSignalSemaphoreEXT"
apitrace: warning: unknown function "glImportSemaphoreFdEXT"
apitrace: warning: unknown function "glWindowRectanglesEXT"
apitrace: warning: unknown function "glMaxShaderCompilerThreadsKHR"
apitrace: warning: unknown function "glAlphaToCoverageDitherControlNV"

 

tdm-launch-distorted-first-frame-plus.webp

Edited by Daft Mugi
Link to comment
Share on other sites

Screenshots from qapitrace, MSAA 2x.

MSAA 2x

In case it matters, the visible distortion is on frames 1 and 2 as the GL_BACK framebuffer. GL_DEPTH_COMPONENT and GL_STENCIL_INDEX framebuffers look distorted as well. Frame 1 is the first frame to have shaders, glprogs/tonemap.fs and glprogs/tonemap.vs. Frame 2 is the frame I notice on thedarkmod.x64 launch.

Frames 0 and 3 GL_BACK framebuffers look ok, but their GL_DEPTH_COMPONENT and GL_STENCIL_INDEX framebuffers look distorted.

MSAA off

Frame 2 does not have a distorted GL_BACK framebuffer; its GL_DEPTH_COMPONENT and GL_STENCIL_INDEX framebuffers look distorted. Frame 1 GL_BACK framebuffer looks similar to frame 1 when MSAA 2x.

 

(Screenshots MSAA 2x)

apitrace-01.webp

Edited by Daft Mugi
  • Like 1
Link to comment
Share on other sites

 

26 minutes ago, stgatilov said:

If these are the very first frames, then it's probably something about initial clear or SMP.

Yes, these are the very first frames.

26 minutes ago, stgatilov said:

Do you have the issue if you set "com_smp 0" ?

Same issue with "com_smp 0".

26 minutes ago, stgatilov said:

(I assume you use the latest svn trunk)

Yes, r10199 currently.

Edited by Daft Mugi
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...