diff --git a/native/cocos/renderer/pipeline/custom/CustomTypes.h b/native/cocos/renderer/pipeline/custom/CustomTypes.h index e62a1e687ea..79904a4ff03 100644 --- a/native/cocos/renderer/pipeline/custom/CustomTypes.h +++ b/native/cocos/renderer/pipeline/custom/CustomTypes.h @@ -29,7 +29,6 @@ */ // clang-format off #pragma once -#include "cocos/base/std/container/string.h" #include "cocos/renderer/pipeline/custom/CustomFwd.h" #include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h index f8cbef31e18..855f2731d99 100644 --- a/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h +++ b/native/cocos/renderer/pipeline/custom/LayoutGraphGraphs.h @@ -739,32 +739,34 @@ tag(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { g._vertices[u].handle); } -inline LayoutGraph::VertexValue -value(LayoutGraph::vertex_descriptor u, LayoutGraph& g) noexcept { +template +auto visitObject(LayoutGraph::vertex_descriptor v, const LayoutGraph&g, Ts&&... args) { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return LayoutGraph::VertexValue{&g.stages[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return LayoutGraph::VertexValue{&g.phases[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + const auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.stages[ccstd::get>(var).value]); + case 1: + return visitor(g.phases[ccstd::get>(var).value]); + default: + std::terminate(); + } } -inline LayoutGraph::VertexConstValue -value(LayoutGraph::vertex_descriptor u, const LayoutGraph& g) noexcept { +template +auto visitObject(LayoutGraph::vertex_descriptor v, LayoutGraph&g, Ts&&... args) { using vertex_descriptor = LayoutGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return LayoutGraph::VertexConstValue{&g.stages[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return LayoutGraph::VertexConstValue{&g.phases[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.stages[ccstd::get>(var).value]); + case 1: + return visitor(g.phases[ccstd::get>(var).value]); + default: + std::terminate(); + } } template @@ -1439,32 +1441,34 @@ tag(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { g._vertices[u].handle); } -inline LayoutGraphData::VertexValue -value(LayoutGraphData::vertex_descriptor u, LayoutGraphData& g) noexcept { +template +auto visitObject(LayoutGraphData::vertex_descriptor v, const LayoutGraphData&g, Ts&&... args) { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return LayoutGraphData::VertexValue{&g.stages[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return LayoutGraphData::VertexValue{&g.phases[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + const auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.stages[ccstd::get>(var).value]); + case 1: + return visitor(g.phases[ccstd::get>(var).value]); + default: + std::terminate(); + } } -inline LayoutGraphData::VertexConstValue -value(LayoutGraphData::vertex_descriptor u, const LayoutGraphData& g) noexcept { +template +auto visitObject(LayoutGraphData::vertex_descriptor v, LayoutGraphData&g, Ts&&... args) { using vertex_descriptor = LayoutGraphData::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return LayoutGraphData::VertexConstValue{&g.stages[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return LayoutGraphData::VertexConstValue{&g.phases[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.stages[ccstd::get>(var).value]); + case 1: + return visitor(g.phases[ccstd::get>(var).value]); + default: + std::terminate(); + } } template diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h index 48f3d1ef4fd..9e5c1b57cf7 100644 --- a/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h +++ b/native/cocos/renderer/pipeline/custom/RenderGraphGraphs.h @@ -1347,74 +1347,62 @@ tag(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { g._vertices[u].handle); } -inline ResourceGraph::VertexValue -value(ResourceGraph::vertex_descriptor u, ResourceGraph& g) noexcept { +template +auto visitObject(ResourceGraph::vertex_descriptor v, const ResourceGraph&g, Ts&&... args) { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.resources[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.managedBuffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.managedTextures[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.buffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.textures[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.framebuffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.swapchains[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.formatViews[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexValue{&g.subresourceViews[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + const auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.resources[ccstd::get>(var).value]); + case 1: + return visitor(g.managedBuffers[ccstd::get>(var).value]); + case 2: + return visitor(g.managedTextures[ccstd::get>(var).value]); + case 3: + return visitor(g.buffers[ccstd::get>(var).value]); + case 4: + return visitor(g.textures[ccstd::get>(var).value]); + case 5: + return visitor(g.framebuffers[ccstd::get>(var).value]); + case 6: + return visitor(g.swapchains[ccstd::get>(var).value]); + case 7: + return visitor(g.formatViews[ccstd::get>(var).value]); + case 8: + return visitor(g.subresourceViews[ccstd::get>(var).value]); + default: + std::terminate(); + } } -inline ResourceGraph::VertexConstValue -value(ResourceGraph::vertex_descriptor u, const ResourceGraph& g) noexcept { +template +auto visitObject(ResourceGraph::vertex_descriptor v, ResourceGraph&g, Ts&&... args) { using vertex_descriptor = ResourceGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.resources[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.managedBuffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.managedTextures[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.buffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.textures[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.framebuffers[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.swapchains[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.formatViews[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return ResourceGraph::VertexConstValue{&g.subresourceViews[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.resources[ccstd::get>(var).value]); + case 1: + return visitor(g.managedBuffers[ccstd::get>(var).value]); + case 2: + return visitor(g.managedTextures[ccstd::get>(var).value]); + case 3: + return visitor(g.buffers[ccstd::get>(var).value]); + case 4: + return visitor(g.textures[ccstd::get>(var).value]); + case 5: + return visitor(g.framebuffers[ccstd::get>(var).value]); + case 6: + return visitor(g.swapchains[ccstd::get>(var).value]); + case 7: + return visitor(g.formatViews[ccstd::get>(var).value]); + case 8: + return visitor(g.subresourceViews[ccstd::get>(var).value]); + default: + std::terminate(); + } } template @@ -2877,104 +2865,82 @@ tag(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { g._vertices[u].handle); } -inline RenderGraph::VertexValue -value(RenderGraph::vertex_descriptor u, RenderGraph& g) noexcept { +template +auto visitObject(RenderGraph::vertex_descriptor v, const RenderGraph&g, Ts&&... args) { using vertex_descriptor = RenderGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.rasterPasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.rasterSubpasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.computeSubpasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.computePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.resolvePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.copyPasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.movePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.raytracePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.renderQueues[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.scenes[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.blits[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.dispatches[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.clearViews[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexValue{&g.viewports[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + const auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.rasterPasses[ccstd::get>(var).value]); + case 1: + return visitor(g.rasterSubpasses[ccstd::get>(var).value]); + case 2: + return visitor(g.computeSubpasses[ccstd::get>(var).value]); + case 3: + return visitor(g.computePasses[ccstd::get>(var).value]); + case 4: + return visitor(g.resolvePasses[ccstd::get>(var).value]); + case 5: + return visitor(g.copyPasses[ccstd::get>(var).value]); + case 6: + return visitor(g.movePasses[ccstd::get>(var).value]); + case 7: + return visitor(g.raytracePasses[ccstd::get>(var).value]); + case 8: + return visitor(g.renderQueues[ccstd::get>(var).value]); + case 9: + return visitor(g.scenes[ccstd::get>(var).value]); + case 10: + return visitor(g.blits[ccstd::get>(var).value]); + case 11: + return visitor(g.dispatches[ccstd::get>(var).value]); + case 12: + return visitor(g.clearViews[ccstd::get>(var).value]); + case 13: + return visitor(g.viewports[ccstd::get>(var).value]); + default: + std::terminate(); + } } -inline RenderGraph::VertexConstValue -value(RenderGraph::vertex_descriptor u, const RenderGraph& g) noexcept { +template +auto visitObject(RenderGraph::vertex_descriptor v, RenderGraph&g, Ts&&... args) { using vertex_descriptor = RenderGraph::vertex_descriptor; - return ccstd::visit( - overload( - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.rasterPasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.rasterSubpasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.computeSubpasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.computePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.resolvePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.copyPasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.movePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.raytracePasses[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.renderQueues[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.scenes[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.blits[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.dispatches[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.clearViews[h.value]}; - }, - [&](const impl::ValueHandle& h) { - return RenderGraph::VertexConstValue{&g.viewports[h.value]}; - }), - g._vertices[u].handle); + auto visitor = Overloaded{ std::forward(args)... }; + auto& var = g._vertices[v].handle; + switch (var.index()) { + case 0: + return visitor(g.rasterPasses[ccstd::get>(var).value]); + case 1: + return visitor(g.rasterSubpasses[ccstd::get>(var).value]); + case 2: + return visitor(g.computeSubpasses[ccstd::get>(var).value]); + case 3: + return visitor(g.computePasses[ccstd::get>(var).value]); + case 4: + return visitor(g.resolvePasses[ccstd::get>(var).value]); + case 5: + return visitor(g.copyPasses[ccstd::get>(var).value]); + case 6: + return visitor(g.movePasses[ccstd::get>(var).value]); + case 7: + return visitor(g.raytracePasses[ccstd::get>(var).value]); + case 8: + return visitor(g.renderQueues[ccstd::get>(var).value]); + case 9: + return visitor(g.scenes[ccstd::get>(var).value]); + case 10: + return visitor(g.blits[ccstd::get>(var).value]); + case 11: + return visitor(g.dispatches[ccstd::get>(var).value]); + case 12: + return visitor(g.clearViews[ccstd::get>(var).value]); + case 13: + return visitor(g.viewports[ccstd::get>(var).value]); + default: + std::terminate(); + } } template diff --git a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h index c3f2c10ee07..a4ec3ba80b7 100644 --- a/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h +++ b/native/cocos/renderer/pipeline/custom/RenderGraphTypes.h @@ -38,7 +38,6 @@ #include "cocos/base/std/container/vector.h" #include "cocos/base/std/hash/hash.h" #include "cocos/core/assets/Material.h" -#include "cocos/math/Geometry.h" #include "cocos/renderer/gfx-base/GFXBuffer.h" #include "cocos/renderer/gfx-base/GFXFramebuffer.h" #include "cocos/renderer/gfx-base/GFXRenderPass.h" diff --git a/native/cocos/renderer/pipeline/custom/details/GraphTypes.h b/native/cocos/renderer/pipeline/custom/details/GraphTypes.h index 5fc8041350d..be4d087b5b3 100644 --- a/native/cocos/renderer/pipeline/custom/details/GraphTypes.h +++ b/native/cocos/renderer/pipeline/custom/details/GraphTypes.h @@ -28,12 +28,12 @@ #include #include #include -#include +#include // IWYU pragma: export #include "cocos/base/memory/Memory.h" #include "cocos/base/std/container/list.h" -#include "cocos/base/std/container/string.h" -#include "cocos/base/std/variant.h" -#include "cocos/renderer/pipeline/custom/details/Overload.h" +#include "cocos/base/std/container/string.h" // IWYU pragma: export +#include "cocos/base/std/variant.h" // IWYU pragma: export +#include "cocos/renderer/pipeline/custom/details/Overload.h" // IWYU pragma: export namespace boost { @@ -54,21 +54,6 @@ using PmrList = ccstd::list>; namespace render { -template -struct VertexOverloaded : Overloaded { - VertexOverloaded(Ts &&...ts) // NOLINT - : Overloaded{std::forward(ts)...} {} - template - auto operator()(T *ptr) { - return this->Overloaded::operator()(*ptr); - } -}; - -template -auto visitObject(typename GraphT::vertex_descriptor v, GraphT &g, Ts &&...args) { - return ccstd::visit(VertexOverloaded{std::forward(args)...}, value(v, g)); -} - namespace impl { //--------------------------------------------------------------------