Skip to content

Conversation

slipher
Copy link
Member

@slipher slipher commented Sep 18, 2025

Depends on #1813.

Implement a code path for sampling u_DepthMap in shaders from a separate copy of the depth texture, instead of the same one that is attached to the rendering FBO. By default, this will be enabled if the driver does not implement TextureBarrier, in order to prevent texture feedback loops. Behavior is controlled by r_copyDepthBuffer. This is meant to fix #1783. Seems to work on my Mac system.

Also I keep having some issues with SSAO + bindless textures on a Mesa + AMD setup. In a game with map survival-pit I got the SSAO artifacts as shown below. (Same ones I used to get with dummygame. I still got those even after #1731 which I though would fix them but didn't, but they may have gone away after a Mesa update.) I can't reproduce the artifacts in a local game but if I play a demo recorded from an online game, I get the artifacts the whole time. Anyway set r_copyDepthBuffer 2 from this PR fixes those artifacts for me.

unvanquished_2025-09-05_142446_000

Things to do:

  • Check if I'm copying the depth buffer in the best way. Is there a depth-only format I should be using instead of the depth + stencil?
  • Disable depth buffer copy if r_depthShaders (incompatible debug cvar) is disabled
  • Ask @illwieckz to assess the performance of this on low-end cards
  • Determine which hardware/driver combinations still have issues with reading the depth buffer despite implementing texture barrier. (This could go in another PR)
  • Maybe skip texture barriers if the duplicated depth buffer is used?

slipher and others added 6 commits September 17, 2025 07:50
We don't use renderbuffers. The renderbuffer size limit does not apply
to an FBO.
Replace GL_FRAMEBUFFER with GL_DRAW_FRAMEBUFFER everywhere. Binding
GL_FRAMEBUFFER to x is defined as binding GL_DRAW_FRAMEBUFFER to x then
binding GL_READ_FRAMEBUFFER to x. Currently we only use the DRAW aspect.
The double binding can be a nuisance when adding functionality (blit)
that needs the read aspect.
@VReaperV
Copy link
Contributor

  • Check if I'm copying the depth buffer in the best way. Is there a depth-only format I should be using instead of the depth + stencil?

Depth and stencil buffers are always implemented as part of one render target.

slipher added a commit to slipher/Daemon that referenced this pull request Sep 19, 2025
Since it's about to be used more times. I named it like
PrepareForSamplingDepthMap instead of something about texture barrier,
because I may want to add more stuff in for DaemonEngine#1814 where there is the
possibility to use a copy of the depth texture instead.

Also attempt to track depth buffer dirtiness with material system.
slipher added a commit to slipher/Daemon that referenced this pull request Sep 19, 2025
Since it's about to be used more times. I named it like
PrepareForSamplingDepthMap instead of something about texture barrier,
because I may want to add more stuff in for DaemonEngine#1814 where there is the
possibility to use a copy of the depth texture instead.

Also, always mark depth buffer dirtiness with material system.
slipher added a commit that referenced this pull request Sep 20, 2025
Since it's about to be used more times. I named it like
PrepareForSamplingDepthMap instead of something about texture barrier,
because I may want to add more stuff in for #1814 where there is the
possibility to use a copy of the depth texture instead.

Also, always mark depth buffer dirtiness with material system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depth fade broken on Apple Silicon
2 participants