Pipeline depth load modification and camera visibility synchronization (#4098)

This commit is contained in:
GengineJS
2021-12-10 17:57:28 +08:00
committed by GitHub
parent 67b7de1948
commit 2405ce5bb0
2 changed files with 8 additions and 3 deletions
@@ -173,7 +173,8 @@ void ForwardStage::render(scene::Camera *camera) {
colorAttachmentInfo.clearColor = _clearColors[0];
colorAttachmentInfo.loadOp = gfx::LoadOp::CLEAR;
auto clearFlags = static_cast<gfx::ClearFlagBit>(camera->clearFlag);
if (!hasFlag(clearFlags, gfx::ClearFlagBit::COLOR)) {
bool isSwapchain = !!camera->window->swapchain;
if (isSwapchain && !hasFlag(clearFlags, gfx::ClearFlagBit::COLOR)) {
if (hasFlag(clearFlags, static_cast<gfx::ClearFlagBit>(skyboxFlag))) {
colorAttachmentInfo.loadOp = gfx::LoadOp::DISCARD;
} else {
@@ -198,8 +199,12 @@ void ForwardStage::render(scene::Camera *camera) {
depthAttachmentInfo.loadOp = gfx::LoadOp::CLEAR;
depthAttachmentInfo.clearDepth = camera->clearDepth;
depthAttachmentInfo.clearStencil = camera->clearStencil;
depthAttachmentInfo.beginAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE};
depthAttachmentInfo.endAccesses = {gfx::AccessType::DEPTH_STENCIL_ATTACHMENT_WRITE};
if (isSwapchain && static_cast<gfx::ClearFlagBit>(clearFlags & gfx::ClearFlagBit::DEPTH_STENCIL) != gfx::ClearFlagBit::DEPTH_STENCIL
&& (!hasFlag(clearFlags, gfx::ClearFlagBit::DEPTH) || !hasFlag(clearFlags, gfx::ClearFlagBit::STENCIL))) {
depthAttachmentInfo.loadOp = gfx::LoadOp::LOAD;
}
data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo);
data.depth = builder.write(data.depth, depthAttachmentInfo);
builder.writeToBlackboard(RenderPipeline::fgStrHandleOutDepthTexture, data.depth);
+1 -1
View File
@@ -52,7 +52,7 @@ struct Camera final {
float aspect{0.0F};
Vec4 viewPort;
uint32_t clearStencil{0};
uint32_t visibility{0};
int32_t visibility{0};
Node * node{nullptr};
RenderScene * scene{nullptr};
RenderWindow *window{nullptr};