Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)

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
Posted
58 minutes ago, duzenko said:

Btw i have an ubuntu 22 virtual machine and I cannot get past the main menu. Mouse cursor is not working for me.

Did you see the TDM main menu?

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

Posted
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

  • 4 weeks later...
Posted (edited)

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
Posted

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.

Posted (edited)
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
Posted (edited)

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
Posted (edited)

 

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
  • 3 weeks later...
  • 1 year later...
Posted

@stgatilov This was fixed by the following commit:

r10914 | stgatilov | 2024-12-08 | 8 lines

Added a way to force-disable tonemapping everywhere if 3D game is not running (r_tonemapOnlyGame3d).

This can be useful because the new tonemapping settings affect main menu rather negatively.
Well, in fact even the simple gamma already affects cinematics the bad way, introducing ugly color banding on dark colors.

Note: normally we should do tonemapping after 3D game is rendered but before GUI overlays are rendered.
But this is a hard topic, because some of the GUI overlays are not actually GUI (e.g. underwater overlay), so this requires some kind of manual tagging.
Better leave this for the future.

When launching TDM:

  • r_tonemapOnlyGame3d 1: first frame is fine.
  • r_tonemapOnlyGame3d 0: first frame is distorted.
Posted
20 hours ago, Daft Mugi said:

This was fixed by the following commit

Yeah, I guess it is sort-of expected.

Because when you start TDM, you don't have 3D game on your screen, so this new cvar effectively disables tonemapping.
And since you wrote above that the problem goes away if tonemapping is disabled... indeed it does go away 😉

  • 5 weeks later...
Posted

@stgatilov Even better news! The following commit fixed this issue regardless of r_tonemapOnlyGame3d setting.

r10930 | stgatilov | 2025-01-25 | 7 lines

Clear background during main menu.

This fixes the issue e.g. with AT1: Lucy and tonemap disabled.
The briefing there does not use any backgrounds, and no-clear policy results in HOM-like effects.

Originally reported here:
  https://forums.thedarkmod.com/index.php?/topic/22635-beta-testing-213/#findComment-499723
  • Like 1
Posted
6 minutes ago, Daft Mugi said:

@stgatilov Even better news! The following commit fixed this issue regardless of r_tonemapOnlyGame3d setting.

Yeah, I thought it might happen 😉

So I guess the explanation is something like this.

The main menu was previously rendered as overlay, on top of the previous contents. When the game starts, the previous contents is probably undefined. If tonemap is disabled, then rendering goes directly to OS window buffer, and it is probably cleared to black in all systems. But if tonemap is enabled, then rendering goes to framebuffer, and its initial contents is undefined. Perhaps it happens to be black usually, but e.g. mesa drivers don't clear it unlike other drivers.

Now there is forced clear to black at the beginning of frame render while main menu is active, so the issue is fixed.

  • Thanks 1

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

    • Ansome

      Terribly difficult juggling map designing with work, but I'm still alive and chipping away at something very special. I'm actually making a collaboration of sorts with a friend, I make the map itself and he acts as my "Chief Scope Creep Consultant" that checks in every so often to make sure this project isn't getting out of hand. It's a good system!
      · 0 replies
    • JackFarmer

      We don't need artificial intelligence; we need artistic intelligence. 
      Ralf Hütter, Kraftwerk
      · 5 replies
    • taaaki

      The post editor for the dark themes should be working again. Apologies for the inconvenience.
      · 1 reply
    • jaxa

      Talk GabeCube:
      https://forums.thedarkmod.com/index.php?/topic/18055-2016-cpugpu-news/page/39/#findComment-508710
      · 3 replies
    • The Black Arrow

      Things have been so bad these days for me...
      Just a year ago, I've been feeling dizzy, I thought it was nothing, today's stress, that type of thing, went to sleep...Still dizzy! 9 more days dizzy, went to doctor (I would have gone on the first day if NOT for the long appointment time)
      Said it may be Neck Dizziness...I did exercises for 6 months, no changes.
      Went to a Physical Therapist, went to another, no changes.
      I've asked my doctor for a full check this time.
      I hated yesteryear so much due to personal reasons, this year might be the same.
      To be brutally honest, I'd rather have cancer or/and chronic pain than suffer dizziness any second longer, especially when nothing helps.
      Hard to enjoy Thief when you're dizzy so I was hoping this year, Winter will be best for me.
      · 7 replies
×
×
  • Create New...