From f0a1b0d06dfacbc77fbe8b8bad6cb43a87e01e7e Mon Sep 17 00:00:00 2001 From: shaoqiangcai <79490184+shaoqiangcai@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:20:36 +0800 Subject: [PATCH 1/5] Update run_test_cases.yml (#15810) Adjust Report Address --- .github/workflows/run_test_cases.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_test_cases.yml b/.github/workflows/run_test_cases.yml index 1621655ecd7..00a22f89d91 100644 --- a/.github/workflows/run_test_cases.yml +++ b/.github/workflows/run_test_cases.yml @@ -301,7 +301,7 @@ jobs: - Test Platform: PR-Test - Editor Version: ${process.env.EDITOR_VERSION} - Task Result: ${process.env.TASK_STATUS} - - Task URL: http://cctest.cocos.org/#/reportview/PR-TEST/${process.env.JOB_ID}/-1 + - Task URL: https://cctest.cocos.org/#/reportview/PR-TEST/${process.env.JOB_ID}/-1 - GitHub Action: https://github.com/cocos/cocos-engine/actions/runs/${process.env.GITHUB_RUN_ID} ## Task Details ${process.env.TASK_REPORT}`); @@ -317,4 +317,4 @@ jobs: name: comment.txt path: | comment.txt - \ No newline at end of file + From 933b644ba8fdc9ed2fe82a66a891a528261a8c6d Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 31 Jul 2023 14:50:43 +0800 Subject: [PATCH 2/5] use boolean instead (#15786) --- cocos/scene-graph/node.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index aeec01c7888..57b51f82615 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -1138,7 +1138,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * node.on(NodeEventType.TOUCH_END, callback, this); * ``` */ - public on (type: string | NodeEventType, callback: AnyFunction, target?: unknown, useCapture: any = false): void { + public on (type: string | NodeEventType, callback: AnyFunction, target?: unknown, useCapture: boolean = false): void { switch (type) { case NodeEventType.TRANSFORM_CHANGED: this._eventMask |= TRANSFORM_ON; @@ -1165,7 +1165,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * node.off(NodeEventType.TOUCH_START, callback, this.node); * ``` */ - public off (type: string, callback?: AnyFunction, target?: unknown, useCapture: any = false): void { + public off (type: string, callback?: AnyFunction, target?: unknown, useCapture: boolean = false): void { this._eventProcessor.off(type as NodeEventType, callback, target, useCapture); const hasListeners = this._eventProcessor.hasEventListener(type); @@ -1193,7 +1193,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * The callback is ignored if it is a duplicate (the callbacks are unique). * @param target - The target (this object) to invoke the callback, can be null */ - public once (type: string, callback: AnyFunction, target?: unknown, useCapture?: any): void { + public once (type: string, callback: AnyFunction, target?: unknown, useCapture?: boolean): void { this._eventProcessor.once(type as NodeEventType, callback, target, useCapture); } From c0e7c74e086876a2df849beec598790e3d69ad99 Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Tue, 1 Aug 2023 13:45:35 +0800 Subject: [PATCH 3/5] add hz --- .../pipeline/custom/NativePipeline.cpp | 248 +++++++++++++++++- .../pipeline/custom/NativeSceneCulling.cpp | 1 + 2 files changed, 238 insertions(+), 11 deletions(-) diff --git a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp index ff89a8cd6dc..4f7d2f1d362 100644 --- a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp +++ b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp @@ -29,6 +29,7 @@ #include "cocos/renderer/pipeline/custom/NativeBuiltinUtils.h" #include "cocos/renderer/pipeline/custom/NativePipelineTypes.h" #include "cocos/renderer/pipeline/custom/NativeRenderGraphUtils.h" +#include "cocos/renderer/pipeline/custom/NativeUtils.h" #include "cocos/renderer/pipeline/custom/RenderGraphGraphs.h" #include "cocos/renderer/pipeline/custom/RenderingModule.h" #include "cocos/renderer/pipeline/custom/details/GslUtils.h" @@ -205,7 +206,8 @@ uint32_t NativePipeline::addDepthStencil(const ccstd::string &name, gfx::Format resourceGraph); } -uint32_t NativePipeline::addResource(const ccstd::string& name, ResourceDimension dimension, +uint32_t NativePipeline::addResource( + const ccstd::string &name, ResourceDimension dimension, gfx::Format format, uint32_t width, uint32_t height, uint32_t depth, uint32_t arraySize, uint32_t mipLevels, gfx::SampleCount sampleCount, ResourceFlags flags, ResourceResidency residency) { @@ -232,10 +234,14 @@ uint32_t NativePipeline::addResource(const ccstd::string& name, ResourceDimensio resourceGraph); } -void NativePipeline::updateResource(const ccstd::string& name, gfx::Format format, +namespace { + +void updateResourceImpl( + ResourceGraph &resourceGraph, + const ccstd::pmr::string &name, gfx::Format format, uint32_t width, uint32_t height, uint32_t depth, uint32_t arraySize, uint32_t mipLevels, // NOLINT(bugprone-easily-swappable-parameters) gfx::SampleCount sampleCount) { - auto resID = findVertex(ccstd::pmr::string(name, get_allocator()), resourceGraph); + auto resID = findVertex(name, resourceGraph); if (resID == ResourceGraph::null_vertex()) { return; } @@ -266,6 +272,17 @@ void NativePipeline::updateResource(const ccstd::string& name, gfx::Format forma [](const auto & /*res*/) {}); } +} // namespace + +void NativePipeline::updateResource(const ccstd::string &name, gfx::Format format, + uint32_t width, uint32_t height, uint32_t depth, uint32_t arraySize, uint32_t mipLevels, // NOLINT(bugprone-easily-swappable-parameters) + gfx::SampleCount sampleCount) { + updateResourceImpl( + resourceGraph, + ccstd::pmr::string(name, &unsyncPool), + format, width, height, depth, arraySize, mipLevels, sampleCount); +} + // NOLINTNEXTLINE uint32_t NativePipeline::addStorageTexture(const ccstd::string &name, gfx::Format format, uint32_t width, uint32_t height, ResourceResidency residency) { ResourceDesc desc{}; @@ -277,7 +294,7 @@ uint32_t NativePipeline::addStorageTexture(const ccstd::string &name, gfx::Forma desc.format = format; desc.sampleCount = gfx::SampleCount::X1; desc.textureFlags = gfx::TextureFlagBit::NONE; - desc.flags = ResourceFlags::STORAGE | ResourceFlags::SAMPLED | ResourceFlags::TRANSFER_SRC | ResourceFlags::TRANSFER_DST;; + desc.flags = ResourceFlags::STORAGE | ResourceFlags::SAMPLED | ResourceFlags::TRANSFER_SRC | ResourceFlags::TRANSFER_DST; CC_EXPECTS(residency == ResourceResidency::MANAGED || residency == ResourceResidency::MEMORYLESS); @@ -652,7 +669,7 @@ void NativePipeline::addMovePass(const ccstd::vector &movePairs) { namespace { void setupGpuDrivenResources( - NativePipeline& ppl, uint32_t cullingID, ResourceGraph& resg, const std::string &hzbName) { + NativePipeline &ppl, uint32_t cullingID, ResourceGraph &resg, const std::string &hzbName) { ccstd::pmr::string name(resg.get_allocator()); { // init resource name = "_GpuInit"; @@ -729,7 +746,6 @@ void setupGpuDrivenResources( } } if (!hzbName.empty()) { - } } @@ -764,7 +780,8 @@ void NativePipeline::addBuiltinGpuCullingPass( copyPass.copyPairs.emplace_back(std::move(copyPair)); } - auto copyID = addVertex2(CopyTag{}, + auto copyID = addVertex2( + CopyTag{}, std::forward_as_tuple("CopyInitialIndirectBuffer"), std::forward_as_tuple(), std::forward_as_tuple(), @@ -781,7 +798,7 @@ void NativePipeline::addBuiltinGpuCullingPass( std::piecewise_construct, std::forward_as_tuple(drawIndirectBuffer), std::forward_as_tuple()); - auto& view = res.first->second.emplace_back(); + auto &view = res.first->second.emplace_back(); view.name = "CCDrawIndirectBuffer"; view.accessType = AccessType::WRITE; view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; @@ -791,7 +808,7 @@ void NativePipeline::addBuiltinGpuCullingPass( std::piecewise_construct, std::forward_as_tuple(drawInstanceBuffer), std::forward_as_tuple()); - auto& view = res.first->second.emplace_back(); + auto &view = res.first->second.emplace_back(); view.name = "CCDrawInstanceBuffer"; view.accessType = AccessType::WRITE; view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; @@ -801,13 +818,14 @@ void NativePipeline::addBuiltinGpuCullingPass( std::piecewise_construct, std::forward_as_tuple(visibilityBuffer), std::forward_as_tuple()); - auto& view = res.first->second.emplace_back(); + auto &view = res.first->second.emplace_back(); view.name = "CCVisibilityBuffer"; view.accessType = AccessType::WRITE; view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; } - auto computePassID = addVertex2(ComputeTag{}, + auto computePassID = addVertex2( + ComputeTag{}, std::forward_as_tuple("Scene"), std::forward_as_tuple(), std::forward_as_tuple(), @@ -818,9 +836,217 @@ void NativePipeline::addBuiltinGpuCullingPass( } } +namespace { + +constexpr uint32_t getHalfSize(uint32_t x) noexcept { + x /= 2; + return x ? x : 1; +} + +constexpr uint32_t getGroupCount(uint32_t x, uint32_t batch) noexcept { // NOLINT(bugprone-easily-swappable-parameters) + return (x + batch - 1) / batch; +} + +} // namespace + void NativePipeline::addBuiltinHzbGenerationPass( // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) const std::string &sourceDepthStencilName, const std::string &targetHzbName) { + const auto &lg = programLibrary->layoutGraph; + const auto sourceID = findVertex(ccstd::pmr::string{sourceDepthStencilName, &unsyncPool}, resourceGraph); + if (sourceID == ResourceGraph::null_vertex()) { + return; + } + const auto targetID = findVertex(ccstd::pmr::string{targetHzbName, &unsyncPool}, resourceGraph); + if (targetID == ResourceGraph::null_vertex()) { + return; + } + + const auto &targetDesc = get(ResourceGraph::DescTag{}, resourceGraph, targetID); + + boost::container::pmr::memory_resource *scratch = &unsyncPool; + ccstd::pmr::string currMipName(scratch); + currMipName.reserve(targetHzbName.size() + 6); + currMipName.append(targetHzbName); + // register all mips + { + CC_EXPECTS(targetDesc.mipLevels && targetDesc.mipLevels != std::numeric_limits::max()); + auto desc = targetDesc; + desc.mipLevels = 1; + CC_EXPECTS(desc.depthOrArraySize == 1); + CC_EXPECTS(desc.sampleCount == gfx::SampleCount::X1); + for (uint32_t k = 0; k != targetDesc.mipLevels; ++k) { + currMipName.resize(targetHzbName.size()); + CC_ENSURES(currMipName == std::string_view{targetHzbName}); + currMipName.append("_Mip"); + currMipName.append(std::to_string(k)); + auto resID = findVertex(currMipName, resourceGraph); + if (resID == ResourceGraph::null_vertex()) { + resID = addVertex( + ManagedTextureTag{}, + std::forward_as_tuple(name.c_str()), + std::forward_as_tuple(), + std::forward_as_tuple(ResourceTraits{ResourceResidency::MANAGED}), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + resourceGraph); + } else { + CC_EXPECTS(holds(resID, resourceGraph)); + updateResourceImpl( + resourceGraph, + currMipName, + gfx::Format::UNKNOWN, + desc.width, + desc.height, + 1, 1, 1, gfx::SampleCount::X1); + } + desc.width = getHalfSize(desc.width); + desc.height = getHalfSize(desc.height); + } + } + + // add passes + ccstd::pmr::string prevMipName(scratch); + prevMipName.reserve(targetHzbName.size() + 6); + prevMipName.append(std::string_view{targetHzbName}); + uint32_t width = targetDesc.width; + uint32_t height = targetDesc.height; + for (uint32_t k = 0; k != targetDesc.mipLevels; ++k) { + // add HZ ComputePass + auto passID = addVertex2( + ComputeTag{}, + std::forward_as_tuple("HZPass"), + std::forward_as_tuple("hiz-cs"), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + renderGraph); + auto &pass = get(ComputeTag{}, passID, renderGraph); + // source + if (k == 0) { + auto res = pass.computeViews.emplace( + std::piecewise_construct, + std::forward_as_tuple(std::string_view{sourceDepthStencilName}), // source depth stencil + std::forward_as_tuple()); + CC_ENSURES(res.second); + + res.first->second.emplace_back( + ccstd::pmr::string{"sourceImage", res.first->second.get_allocator()}, // descriptor name in shader + AccessType::READ, + gfx::ClearFlagBit::NONE, + ClearValueType::NONE, + ClearValue{}, + gfx::ShaderStageFlagBit::COMPUTE); + } else { + prevMipName.resize(targetHzbName.size()); + CC_ENSURES(prevMipName == std::string_view{targetHzbName}); + prevMipName.append("_Mip"); + CC_EXPECTS(k > 0); + prevMipName.append(std::to_string(k - 1)); // previous mip, k - 1 + + auto res = pass.computeViews.emplace( + std::piecewise_construct, + std::forward_as_tuple(prevMipName), // previous mip + std::forward_as_tuple()); + CC_ENSURES(res.second); + + res.first->second.emplace_back( + ccstd::pmr::string{"sourceImage", res.first->second.get_allocator()}, // descriptor name in shader + AccessType::READ, + gfx::ClearFlagBit::NONE, + ClearValueType::NONE, + ClearValue{}, + gfx::ShaderStageFlagBit::COMPUTE); + } + // target + currMipName.resize(targetHzbName.size()); + CC_ENSURES(currMipName == std::string_view{targetHzbName}); + currMipName.append("_Mip"); + currMipName.append(std::to_string(k)); + auto res = pass.computeViews.emplace( + std::piecewise_construct, + std::forward_as_tuple(std::string_view{currMipName}), + std::forward_as_tuple()); + CC_ENSURES(res.second); + + res.first->second.emplace_back( + ccstd::pmr::string{"targetImage", res.first->second.get_allocator()}, + AccessType::WRITE, + gfx::ClearFlagBit::NONE, + ClearValueType::NONE, + ClearValue{}, + gfx::ShaderStageFlagBit::COMPUTE); + + // uniforms + auto &data = get(RenderGraph::DataTag{}, renderGraph, passID); + setVec2Impl( + data, lg, "imageSize", + Vec2{ + static_cast(width), + static_cast(height), + }); + + // add HZ Dispatch + CC_ENSURES(passID != RenderGraph::null_vertex()); + auto queueID = addVertex2( + QueueTag{}, + std::forward_as_tuple("HZQueue"), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + renderGraph, + passID); + + CC_ENSURES(queueID != RenderGraph::null_vertex()); + auto dispatchID = addVertex2( + DispatchTag{}, + std::forward_as_tuple("HZDispatch"), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple( + IntrusivePtr{}, + 0, + getGroupCount(width, 32), + getGroupCount(height, 32), + 1), + renderGraph, + queueID); + CC_ENSURES(dispatchID != RenderGraph::null_vertex()); + + width = getHalfSize(width); + height = getHalfSize(height); + } + + // add MovePass + { + MovePass move(renderGraph.get_allocator()); + move.movePairs.reserve(targetDesc.mipLevels); + for (uint32_t k = 0; k != targetDesc.mipLevels; ++k) { + currMipName.resize(targetHzbName.size()); + CC_ENSURES(currMipName == std::string_view{targetHzbName}); + currMipName.append("_Mip"); + currMipName.append(std::to_string(k)); + MovePair pair(move.get_allocator()); + pair.source = currMipName; + pair.target = targetHzbName; + pair.mipLevels = 1; + pair.numSlices = 1; + move.movePairs.emplace_back(std::move(pair)); + } + + auto moveID = addVertex2( + MoveTag{}, + std::forward_as_tuple("HZMove"), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + std::forward_as_tuple(), + renderGraph); + CC_ENSURES(moveID != RenderGraph::null_vertex()); + } } void NativePipeline::addCopyPass(const ccstd::vector ©Pairs) { diff --git a/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp b/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp index f2cfd0111b0..557eb020025 100644 --- a/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeSceneCulling.cpp @@ -445,6 +445,7 @@ void SceneCulling::clear() noexcept { sceneQueryIndex.clear(); numCullingQueries = 0; numRenderQueues = 0; + gpuCullingPassID = 0xFFFFFFFF; } } // namespace render From d194adde28dade672a8cb925d4b0e2496a9d728a Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Tue, 1 Aug 2023 13:51:22 +0800 Subject: [PATCH 4/5] simplify --- .../pipeline/custom/NativePipeline.cpp | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp index 4f7d2f1d362..9015daafe63 100644 --- a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp +++ b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp @@ -931,13 +931,10 @@ void NativePipeline::addBuiltinHzbGenerationPass( std::forward_as_tuple()); CC_ENSURES(res.second); - res.first->second.emplace_back( - ccstd::pmr::string{"sourceImage", res.first->second.get_allocator()}, // descriptor name in shader - AccessType::READ, - gfx::ClearFlagBit::NONE, - ClearValueType::NONE, - ClearValue{}, - gfx::ShaderStageFlagBit::COMPUTE); + auto &view = res.first->second.emplace_back(); + view.name = "sourceImage"; + view.accessType = AccessType::READ; + view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; } else { prevMipName.resize(targetHzbName.size()); CC_ENSURES(prevMipName == std::string_view{targetHzbName}); @@ -951,13 +948,10 @@ void NativePipeline::addBuiltinHzbGenerationPass( std::forward_as_tuple()); CC_ENSURES(res.second); - res.first->second.emplace_back( - ccstd::pmr::string{"sourceImage", res.first->second.get_allocator()}, // descriptor name in shader - AccessType::READ, - gfx::ClearFlagBit::NONE, - ClearValueType::NONE, - ClearValue{}, - gfx::ShaderStageFlagBit::COMPUTE); + auto &view = res.first->second.emplace_back(); + view.name = "sourceImage"; + view.accessType = AccessType::READ; + view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; } // target currMipName.resize(targetHzbName.size()); @@ -970,13 +964,10 @@ void NativePipeline::addBuiltinHzbGenerationPass( std::forward_as_tuple()); CC_ENSURES(res.second); - res.first->second.emplace_back( - ccstd::pmr::string{"targetImage", res.first->second.get_allocator()}, - AccessType::WRITE, - gfx::ClearFlagBit::NONE, - ClearValueType::NONE, - ClearValue{}, - gfx::ShaderStageFlagBit::COMPUTE); + auto &view = res.first->second.emplace_back(); + view.name = "targetImage"; + view.accessType = AccessType::WRITE; + view.shaderStageFlags = gfx::ShaderStageFlagBit::COMPUTE; // uniforms auto &data = get(RenderGraph::DataTag{}, renderGraph, passID); From bc232ee53697ed2af531fd4b5d5eabdca8a01c01 Mon Sep 17 00:00:00 2001 From: Zhou Zhenglong Date: Tue, 1 Aug 2023 14:03:07 +0800 Subject: [PATCH 5/5] fix typo --- native/cocos/renderer/pipeline/custom/NativePipeline.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp index 9015daafe63..fda79cdf147 100644 --- a/native/cocos/renderer/pipeline/custom/NativePipeline.cpp +++ b/native/cocos/renderer/pipeline/custom/NativePipeline.cpp @@ -1025,6 +1025,7 @@ void NativePipeline::addBuiltinHzbGenerationPass( pair.target = targetHzbName; pair.mipLevels = 1; pair.numSlices = 1; + pair.targetMostDetailedMip = k; move.movePairs.emplace_back(std::move(pair)); }