[graphics] Initialize shadows FB with a depth buffer#90
Merged
Conversation
Closed
Owner
Author
|
The following patch also helps. I think the driver trips on diff --git a/include/reone/scene/render/pipeline/retro.h b/include/reone/scene/render/pipeline/retro.h
index d621a68d6..53cbd45f3 100644
--- a/include/reone/scene/render/pipeline/retro.h
+++ b/include/reone/scene/render/pipeline/retro.h
@@ -76,6 +76,7 @@ private:
};
RenderTargets _targets;
+ bool _shouldClear { false };
void initRenderTargets();
};
diff --git a/src/libs/scene/render/pipeline/retro.cpp b/src/libs/scene/render/pipeline/retro.cpp
index 9f0d893e3..b7bda0f49 100644
--- a/src/libs/scene/render/pipeline/retro.cpp
+++ b/src/libs/scene/render/pipeline/retro.cpp
@@ -176,7 +176,9 @@ Texture &RetroRenderPipeline::render() {
if (dirLightShadows || pointLightShadows) {
_context.bindDrawFramebuffer(*_targets.shadows, {});
_context.withViewport(glm::ivec4 {0, 0, _options.shadowResolution, _options.shadowResolution}, [this, &pass, &dirLightShadows]() {
- _context.clearDepth();
+ if (_shouldClear) {
+ _context.clearDepth();
+ }
if (dirLightShadows) {
_targets.shadows->attachTexture(*_targets.dirLightShadowsDepth, Framebuffer::Attachment::Depth);
_passCallbacks.at(RenderPassName::DirLightShadowsPass)(pass);
@@ -184,6 +186,7 @@ Texture &RetroRenderPipeline::render() {
_targets.shadows->attachTexture(*_targets.pointLightShadowsDepth, Framebuffer::Attachment::Depth);
_passCallbacks.at(RenderPassName::PointLightShadows)(pass);
}
+ _shouldClear = true;
});
}
|
c8c3279 to
45f07d7
Compare
Always attach a depth buffer during initialization. Render calls glClear(GL_DEPTH_BUFFER_BIT) before a depth buffer is attached. If nothing is attached before glClear, some drivers trip and never recover. Reproduced on Linux with Nvidia GTX 1070 and driver versions 535.261 and 550.163. Fixes #82 "Retro renderer is broken".
45f07d7 to
60d40d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Always attach a depth buffer during initialization. Render calls
glClear(GL_DEPTH_BUFFER_BIT)before a depth buffer is attached. If nothing is attached beforeglClear, some drivers trip and never recover.Reproduced on Linux with Nvidia GTX 1070 and driver versions 535.261 and 550.163.
Fixes #82 "Retro renderer is broken".