Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] V3.8.0 rt #16438

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion native/cocos/renderer/pipeline/custom/NativeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ PersistentRenderPassAndFramebuffer createPersistentRenderPassAndFramebuffer(
// data.framebuffer = fb;
},
[&](const RenderSwapchain& sc) {
fbInfo.colorTextures.emplace_back(sc.swapchain->getColorTexture());
if (sc.swapchain) {
fbInfo.colorTextures.emplace_back(sc.swapchain->getColorTexture());
} else {
CC_EXPECTS(sc.renderWindow);
fbInfo.colorTextures.emplace_back(sc.renderWindow->getFramebuffer()->getColorTextures().front());
}
},
[&](const FormatView& view) {
// TODO(zhouzhenglong): add ImageView support
Expand Down
35 changes: 26 additions & 9 deletions native/cocos/renderer/pipeline/custom/NativePipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ uint32_t NativePipeline::addRenderWindow(const ccstd::string &name, gfx::Format
if (!renderWindow->getSwapchain()) {
CC_ASSERT(renderWindow->getFramebuffer()->getColorTextures().size() == 1);
CC_ASSERT(renderWindow->getFramebuffer()->getColorTextures().at(0));
RenderSwapchain sc{};
sc.renderWindow = renderWindow;
return addVertex(
FramebufferTag{},
SwapchainTag{},
std::forward_as_tuple(name.c_str()),
std::forward_as_tuple(desc),
std::forward_as_tuple(ResourceTraits{ResourceResidency::EXTERNAL}),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(IntrusivePtr<gfx::Framebuffer>(renderWindow->getFramebuffer())),
std::forward_as_tuple(sc),
resourceGraph);
}

Expand Down Expand Up @@ -364,22 +366,37 @@ void NativePipeline::updateRenderWindow(const ccstd::string &name, scene::Render
visitObject(
resID, resourceGraph,
[&](IntrusivePtr<gfx::Framebuffer> &fb) {
// deprecated
CC_EXPECTS(false);
CC_EXPECTS(!renderWindow->getSwapchain());
desc.width = renderWindow->getWidth();
desc.height = renderWindow->getHeight();
fb = renderWindow->getFramebuffer();
},
[&](RenderSwapchain &sc) {
CC_EXPECTS(renderWindow->getSwapchain());
auto *newSwapchain = renderWindow->getSwapchain();
if (sc.generation != newSwapchain->getGeneration()) {
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(
sc.swapchain->getColorTexture());
const auto& oldTexture = resourceGraph.getTexture(resID);
resourceGraph.invalidatePersistentRenderPassAndFramebuffer(oldTexture);
if (newSwapchain) {
desc.width = newSwapchain->getWidth();
desc.height = newSwapchain->getHeight();

sc.renderWindow = nullptr;
sc.swapchain = renderWindow->getSwapchain();
sc.generation = newSwapchain->getGeneration();
} else {
CC_EXPECTS(renderWindow->getFramebuffer());
CC_EXPECTS(renderWindow->getFramebuffer()->getColorTextures().size() == 1);
CC_EXPECTS(renderWindow->getFramebuffer()->getColorTextures().front());

const auto& texture = renderWindow->getFramebuffer()->getColorTextures().front();
desc.width = texture->getWidth();
desc.height = texture->getHeight();

sc.renderWindow = renderWindow;
sc.swapchain = nullptr;
sc.generation = 0xFFFFFFFF;
}
desc.width = renderWindow->getSwapchain()->getWidth();
desc.height = renderWindow->getSwapchain()->getHeight();
sc.swapchain = renderWindow->getSwapchain();
},
[](const auto & /*res*/) {});
}
Expand Down
25 changes: 21 additions & 4 deletions native/cocos/renderer/pipeline/custom/NativeResourceGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "details/Range.h"
#include "gfx-base/GFXDef-common.h"
#include "pipeline/custom/RenderCommonFwd.h"
#include "cocos/scene/RenderWindow.h"

namespace cc {

Expand Down Expand Up @@ -172,6 +173,9 @@ bool ManagedTexture::checkResource(const ResourceDesc& desc) const {
void ResourceGraph::validateSwapchains() {
bool swapchainInvalidated = false;
for (auto& sc : swapchains) {
if (!sc.swapchain) {
continue;
}
if (sc.generation != sc.swapchain->getGeneration()) {
swapchainInvalidated = true;
sc.generation = sc.swapchain->getGeneration();
Expand Down Expand Up @@ -217,12 +221,14 @@ void ResourceGraph::mount(gfx::Device* device, vertex_descriptor vertID) {
std::ignore = texture;
},
[&](const IntrusivePtr<gfx::Framebuffer>& fb) {
// deprecated
CC_EXPECTS(false);
CC_EXPECTS(fb);
std::ignore = fb;
},
[&](const RenderSwapchain& queue) {
CC_EXPECTS(queue.swapchain);
std::ignore = queue;
[&](const RenderSwapchain& window) {
CC_EXPECTS(window.swapchain || window.renderWindow);
std::ignore = window;
},
[&](const FormatView& view) { // NOLINT(misc-no-recursion)
std::ignore = view;
Expand Down Expand Up @@ -339,12 +345,23 @@ gfx::Texture* ResourceGraph::getTexture(vertex_descriptor resID) {
texture = tex.get();
},
[&](const IntrusivePtr<gfx::Framebuffer>& fb) {
// deprecated
CC_EXPECTS(false);
CC_EXPECTS(fb->getColorTextures().size() == 1);
CC_EXPECTS(fb->getColorTextures().at(0));
texture = fb->getColorTextures()[0];
},
[&](const RenderSwapchain& sc) {
texture = sc.swapchain->getColorTexture();
if (sc.swapchain) {
texture = sc.swapchain->getColorTexture();
} else {
CC_EXPECTS(sc.renderWindow);
const auto& fb = sc.renderWindow->getFramebuffer();
CC_EXPECTS(fb);
CC_EXPECTS(fb->getColorTextures().size() == 1);
CC_EXPECTS(fb->getColorTextures().at(0));
texture = fb->getColorTextures()[0];
}
},
[&](const FormatView& view) {
// TODO(zhouzhenglong): add ImageView support
Expand Down
Loading