Skip to content

Commit

Permalink
[XR/XrSession] Depth test always passes when copying to swapchains
Browse files Browse the repository at this point in the history
- This allows the whole frame to be copied, not just fragments that have an actual depth
  - This also fixes cubemap rendering, which simply resulted in flickering without it

- The same is done for the default framebuffer (window) copy
  • Loading branch information
Razakhel committed Nov 13, 2024
1 parent 1256254 commit a5b512f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
24 changes: 12 additions & 12 deletions include/RaZ/Render/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,18 +409,18 @@ enum class TextureInternalFormat : unsigned int {
RGB16_SNORM = 36762 /* GL_RGB16_SNORM */, ///<
RGBA16_SNORM = 36763 /* GL_RGBA16_SNORM */, ///<

R32I = 33333 /* GL_R32I */, ///<
RG32I = 33339 /* GL_RG32I */, ///<
RGB32I = 36227 /* GL_RGB32I */, ///<
RGBA32I = 36226 /* GL_RGBA32I */, ///<
R32UI = 33334 /* GL_R32UI */, ///<
RG32UI = 33340 /* GL_RG32UI */, ///<
RGB32UI = 36209 /* GL_RGB32UI */, ///<
RGBA32UI = 36208 /* GL_RGBA32UI */, ///<
R32F = 33326 /* GL_R32F */, ///<
RG32F = 33328 /* GL_RG32F */, ///<
RGB32F = 34837 /* GL_RGB32F */, ///<
RGBA32F = 34836 /* GL_RGBA32F */, ///<
R32I = 33333 /* GL_R32I */, ///<
RG32I = 33339 /* GL_RG32I */, ///<
RGB32I = 36227 /* GL_RGB32I */, ///<
RGBA32I = 36226 /* GL_RGBA32I */, ///<
R32UI = 33334 /* GL_R32UI */, ///<
RG32UI = 33340 /* GL_RG32UI */, ///<
RGB32UI = 36209 /* GL_RGB32UI */, ///<
RGBA32UI = 36208 /* GL_RGBA32UI */, ///<
R32F = 33326 /* GL_R32F */, ///<
RG32F = 33328 /* GL_RG32F */, ///<
RGB32F = 34837 /* GL_RGB32F */, ///<
RGBA32F = 34836 /* GL_RGBA32F */, ///<

RGB10_A2 = 32857 /* GL_RGB10_A2 */, ///<
RGB10_A2UI = 36975 /* GL_RGB10_A2UI */, ///<
Expand Down
5 changes: 1 addition & 4 deletions src/RaZ/Render/Cubemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,14 @@ void Cubemap::draw() const {
ZoneScopedN("Cubemap::draw");
TracyGpuZone("Cubemap::draw")

Renderer::setDepthFunction(DepthStencilFunction::LESS_EQUAL);

const MeshRenderer& displayCube = getDisplayCube();

displayCube.getMaterials().front().getProgram().use();

Renderer::activateTexture(0);
bind();

Renderer::setDepthFunction(DepthStencilFunction::LESS_EQUAL);
displayCube.draw();

Renderer::setDepthFunction(DepthStencilFunction::LESS);
}

Expand Down
3 changes: 3 additions & 0 deletions src/RaZ/Render/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ void RenderSystem::copyToWindow(const Texture2D& colorBuffer, const Texture2D& d

Renderer::bindFramebuffer(0);
Renderer::clear(MaskType::COLOR | MaskType::DEPTH | MaskType::STENCIL);

Renderer::setDepthFunction(DepthStencilFunction::ALWAYS);
windowCopyPass.execute();
Renderer::setDepthFunction(DepthStencilFunction::LESS);
}

} // namespace Raz
3 changes: 2 additions & 1 deletion src/RaZ/XR/XrSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,11 @@ void XrSession::copyToSwapchains(const Texture2D& colorBuffer, const Texture2D&
Renderer::bindFramebuffer(m_swapchainCopyPass.getFramebuffer().getIndex(), FramebufferType::DRAW_FRAMEBUFFER);
Renderer::setFramebufferTexture2D(FramebufferAttachment::COLOR0, colorSwapchainImage, 0);
Renderer::setFramebufferTexture2D(FramebufferAttachment::DEPTH, depthSwapchainImage, 0);

Renderer::clear(MaskType::COLOR | MaskType::DEPTH | MaskType::STENCIL);

Renderer::setDepthFunction(DepthStencilFunction::ALWAYS);
m_swapchainCopyPass.execute();
Renderer::setDepthFunction(DepthStencilFunction::LESS);
}

} // namespace Raz

0 comments on commit a5b512f

Please sign in to comment.