Compare commits

..

14 Commits

Author SHA1 Message Date
hyde zhou 47ebc462e5 bump version to 4.0.0-alpha.35 (#353) 2026-09-20 17:33:35 +08:00
Tianze-Chen b4bea55859 fix(label): abnormal font display when label text is too long (#348)
A very long label string (e.g. 8000+ characters) makes the text layout
canvas exceed MAX_SIZE, so the font is meant to be scaled down by the
shrink ratio. Clamping _fontScale to a minimum of 1 defeated that
downscale and the text displayed abnormally; lower the floor to 0.1 so
the font can shrink with the canvas.

Fixes #344

Co-authored-by: ctz <ctz@ctzdeMacBook-Air.local>
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-09-20 17:27:24 +08:00
Cocos Robot 82f13c86e9 [ci skip][AUTO]: Automated clang-format update: d67d6ac324 (#341) (#342)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-09-20 17:22:37 +08:00
zxx43 0fd910220e reset bone.active after updateCache (#340)
* reset bone.active after updateCache

* upload version
2026-09-20 10:13:12 +08:00
MagicX 557b06f7e6 fix(scene): LOD screen usage distance truncated to int (native platform) (#343)
* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks (custom pipeline).

* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (old pipeline)

* CI error: Function parameter names cannot be omitted.

* Move the devil string to macro

* fix(mesh): hoose index format by max index value in createMesh

* perf(pipeline): reduce render queue sort to two packed key compares (native platform).

* fix CI error caused by native/cocos/base/Utils.h

* fix(scene): LOD screen usage distance truncated to int (native platform)
2026-09-17 18:59:26 +08:00
MagicX b46553e615 perf(pipeline): reduce render queue sort to two packed key compares (native platform). (#341)
* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks (custom pipeline).

* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (old pipeline)

* CI error: Function parameter names cannot be omitted.

* Move the devil string to macro

* fix(mesh): hoose index format by max index value in createMesh

* perf(pipeline): reduce render queue sort to two packed key compares (native platform).

* fix CI error caused by native/cocos/base/Utils.h
2026-09-17 09:35:05 +08:00
hyde zhou fffd9a514a bump version to 4.0.0-alpha.34 (#339) 2026-09-14 17:55:42 +08:00
Cocos Robot 5678d0d17c [ci skip][AUTO]: Automated clang-format update: f264405b7e (#330) (#331)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-09-14 17:03:08 +08:00
Cocos Robot 2ce7b89be5 [ci skip][AUTO]: Automated clang-format update: ffc817b76f (#336) (#337)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
2026-09-14 17:02:34 +08:00
zxx43 6b455561f4 optimize noise function (#338)
* optimize noise function

* format
2026-09-14 16:06:30 +08:00
MagicX 60f9352c56 fix(mesh): hoose index format by max index value in createMesh (#336)
* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks (custom pipeline).

* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (old pipeline)

* CI error: Function parameter names cannot be omitted.

* Move the devil string to macro

* fix(mesh): hoose index format by max index value in createMesh
2026-09-14 14:10:33 +08:00
李吉林 f66365f959 add @visible(false) for TerrainInfo (#334) 2026-09-11 15:09:24 +08:00
MagicXHouse a3c3fcbea5 Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (#330)
* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks (custom pipeline).

* Changed the GeometryRenderer and DebugRenderer from using intrusive calls to registering callbacks. (old pipeline)

* CI error: Function parameter names cannot be omitted.

* Move the devil string to macro
2026-09-08 19:35:05 +08:00
Ming 2a75cfb9da fix(webgpu): fix error pipelinelayout order (#329)
Co-authored-by: vanitynie <vanitynie@qq.com>
2026-09-08 11:27:06 +08:00
24 changed files with 333 additions and 78 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ export class TextProcessing {
const maxValue = Math.max(outputLayoutData.canvasSize.width, outputLayoutData.canvasSize.height);
const canvasScaleToMaxSizeRatio = MAX_SIZE / maxValue;
this._fontScale *= canvasScaleToMaxSizeRatio;
this._fontScale = Math.max(1, this._fontScale);
this._fontScale = Math.max(0.1, this._fontScale);
}
this._updatePaddingRect(style, outputLayoutData);
+7 -2
View File
@@ -172,13 +172,18 @@ export function createMesh (geometry: IGeometry, out?: Mesh, options?: ICreateMe
// Fill index buffer.
let indexBuffer: ArrayBuffer | null = null;
let idxCount = 0;
const idxStride = 2;
let idxStride = 2;
let indexFormat = Format.R16UI;
if (geometry.indices) {
const { indices } = geometry;
idxCount = indices.length;
if (indices.some((i) => i > 0xFFFF)) {
idxStride = 4;
indexFormat = Format.R32UI;
}
indexBuffer = new ArrayBuffer(idxStride * idxCount);
const indexBufferView = new DataView(indexBuffer);
writeBuffer(indexBufferView, indices, Format.R16UI);
writeBuffer(indexBufferView, indices, indexFormat);
}
// Create primitive.
+14 -4
View File
@@ -29,7 +29,8 @@ import { Vec2, Vec3 } from '../core/math';
* @zh 此类生成噪声纹理。
*/
export class ParticleNoise {
private permutation: number[] = [151, 160, 137, 91, 90, 15,
private static readonly DEFAULT_PERMUTATION: readonly number[] = [
151, 160, 137, 91, 90, 15,
131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
@@ -44,9 +45,19 @@ export class ParticleNoise {
138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180,
];
private static build512 (src: readonly number[] | number[]): Uint8Array {
const p = new Uint8Array(512);
for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = src[i]; }
return p;
}
private permutation: number[] = ParticleNoise.DEFAULT_PERMUTATION as number[];
private permutation512: Uint8Array = ParticleNoise.build512(ParticleNoise.DEFAULT_PERMUTATION);
constructor (permutation?: number[]) {
if (permutation) {
this.permutation = permutation;
this.permutation = permutation.slice();
this.permutation512 = ParticleNoise.build512(this.permutation);
}
}
@@ -61,8 +72,7 @@ export class ParticleNoise {
* @returns @en Texture pixel generated. @zh 返回生成的噪声纹理值。
*/
public noise (x: number, y: number, z: number, min = 0, max = 1): number {
const p: number[] = new Array(512);
for (let i = 0; i < 256; i++) { p[256 + i] = p[i] = this.permutation[i]; }
const p: Uint8Array = this.permutation512;
const X = Math.floor(x) & 255; // FIND UNIT CUBE THAT
const Y = Math.floor(y) & 255; // CONTAINS POINT.
@@ -1264,15 +1264,6 @@ export class WebProgramLibrary implements ProgramLibrary {
if (passSet) {
info.setLayouts.push(passSet);
}
const phaseSet = getDescriptorSetLayout(
this.layoutGraph,
subpassOrPassID,
phaseID,
UpdateFrequency.PER_PHASE,
);
if (phaseSet) {
info.setLayouts.push(phaseSet);
}
const batchSet = getProgramDescriptorSetLayout(
device,
lg,
@@ -1293,6 +1284,15 @@ export class WebProgramLibrary implements ProgramLibrary {
if (instanceSet) {
info.setLayouts.push(instanceSet);
}
const phaseSet = getDescriptorSetLayout(
this.layoutGraph,
subpassOrPassID,
phaseID,
UpdateFrequency.PER_PHASE,
);
if (phaseSet) {
info.setLayouts.push(phaseSet);
}
programData.pipelineLayout = device.createPipelineLayout(info);
return programData.pipelineLayout;
}
+1
View File
@@ -1537,6 +1537,7 @@ export class Terrain extends Component {
* @zh 获得地形信息
*/
@type(TerrainInfo)
@visible(false)
public get info (): TerrainInfo {
const ti = new TerrainInfo();
ti.tileSize = this.tileSize;
+11 -2
View File
@@ -222,13 +222,22 @@ Mesh::ICreateInfo MeshUtils::createMeshInfo(const IGeometry &geometry, const ccs
// Fill index buffer.
ArrayBuffer::Ptr indexBuffer;
uint32_t idxCount = 0;
const uint32_t idxStride = 2;
uint32_t idxStride = 2;
gfx::Format indexFormat = gfx::Format::R16UI;
if (geometry.indices.has_value()) {
const ccstd::vector<uint32_t> &indices = geometry.indices.value();
uint32_t maxIndex = 0;
for (uint32_t idx : indices) {
maxIndex = std::max(maxIndex, idx);
}
if (maxIndex > std::numeric_limits<uint16_t>::max()) {
idxStride = 4;
indexFormat = gfx::Format::R32UI;
}
idxCount = static_cast<uint32_t>(indices.size());
indexBuffer = ccnew ArrayBuffer(idxStride * idxCount);
DataView indexBufferView(indexBuffer);
writeBuffer(indexBufferView, indices, gfx::Format::R16UI);
writeBuffer(indexBufferView, indices, indexFormat);
}
// Create primitive.
+20 -2
View File
@@ -30,6 +30,7 @@
#include <bitset>
#include <cerrno>
#include <climits>
#include <cstring>
#include <limits>
#include "base/Macros.h"
#include "base/TypeDef.h"
@@ -145,10 +146,27 @@ CC_FORCE_INLINE Tgt bit_cast(const Src &src) { // NOLINT(readability-identifier-
Tgt tgt;
// Load src into registers first. This allows the memcpy to be elided by CUDA.
const Src staged = src;
memcpy(&tgt, &staged, sizeof(Tgt));
std::memcpy(&tgt, &staged, sizeof(Tgt));
return tgt;
}
// Map a float to a uint32 whose unsigned-integer ordering matches the float's
// numeric ordering (the classic radix-sort "flip"):
// * non-negative: flip the sign bit
// * negative: complement all bits
// This maps [-inf, -0.0] to [0, 2^31) and [+0.0, +inf] to [2^31, 2^32), so the
// unsigned comparison orders floats correctly. NaN must be excluded by the caller.
//
// Requires IEEE 754 binary32 (32-bit) floats, which every Cocos platform has.
static_assert(sizeof(float) == sizeof(uint32_t), "float must be 32-bit");
static_assert(std::numeric_limits<float>::is_iec559, "float must be IEEE 754");
CC_FORCE_INLINE uint32_t floatToSortableUint(float value) {
constexpr uint32_t signBit = 0x80000000U;
const auto bits = bit_cast<uint32_t>(value);
return (bits & signBit) ? ~bits : (bits ^ signBit);
}
} // namespace numext
// Following the Arm ACLE arm_neon.h should also include arm_fp16.h but not all
@@ -164,7 +182,7 @@ struct HalfRaw {
#if defined(CC_HAS_ARM64_FP16_SCALAR_ARITHMETIC)
explicit HalfRaw(uint16_t raw) : x(numext::bit_cast<__fp16>(raw)) {
}
__fp16 x;
__fp16 x; // NOLINT(modernize-use-default-member-init)
#else
explicit constexpr HalfRaw(uint16_t raw) : x(raw) {}
uint16_t x; // NOLINT(modernize-use-default-member-init)
@@ -751,7 +751,19 @@ void SpineSkeletonInstance::resizeSlotRegion(const spine::String &slotName, uint
releaseSlotCacheInfo(cacheInfo);
}
_slotTextureSet.put(slot, info);
auto &bones = _skeleton->getBones();
const size_t boneCount = bones.size();
std::vector<bool> activeBackup(boneCount);
for (size_t i = 0; i < boneCount; ++i) {
activeBackup[i] = bones[i]->isActive();
}
_skeleton->updateCache();
for (size_t i = 0; i < boneCount; ++i) {
bones[i]->setActive(activeBackup[i]);
}
}
void SpineSkeletonInstance::setSlotTexture(const spine::String &slotName, const spine::String& textureUuid) {
+18 -24
View File
@@ -73,6 +73,15 @@ struct CC_DLL RenderPass {
uint32_t hash = 0;
float depth = 0.0F;
uint32_t shaderID = 0;
/**
* Packed sort keys, computed once in RenderQueue::insertRenderPass so the
* comparator degenerates to a single uint64 compare.
* opaque: primaryKey = hash, secondaryKey = depthKey << 32 | shaderID
* transparent: primaryKey = priority << 32 | hash, secondaryKey = ~depthKey << 32 | shaderID
* depthKey is the order-preserving uint32 mapping of depth.
*/
uint64_t primaryKey = 0;
uint64_t secondaryKey = 0;
uint32_t passIndex = 0;
const scene::SubModel *subModel = nullptr;
};
@@ -175,35 +184,17 @@ using RenderQueueDescList = ccstd::vector<IntrusivePtr<RenderQueueDesc>>;
uint32_t getPhaseID(const ccstd::string &phase);
inline bool opaqueCompareFn(const RenderPass &a, const RenderPass &b) {
if (a.hash != b.hash) {
return a.hash < b.hash;
if (a.primaryKey != b.primaryKey) {
return a.primaryKey < b.primaryKey;
}
CC_ASSERT(!std::isnan(a.depth) && !std::isnan(b.depth));
if (a.depth != b.depth) {
return a.depth < b.depth;
}
return a.shaderID < b.shaderID;
return a.secondaryKey < b.secondaryKey;
}
inline bool transparentCompareFn(const RenderPass &a, const RenderPass &b) {
if (a.priority != b.priority) {
return a.priority < b.priority;
if (a.primaryKey != b.primaryKey) {
return a.primaryKey < b.primaryKey;
}
if (a.hash != b.hash) {
return a.hash < b.hash;
}
CC_ASSERT(!std::isnan(a.depth) && !std::isnan(b.depth));
if (a.depth != b.depth) {
return b.depth < a.depth;
}
return a.shaderID < b.shaderID;
return a.secondaryKey < b.secondaryKey;
}
inline uint32_t convertPhase(const ccstd::vector<ccstd::string> &stages) {
@@ -688,6 +679,9 @@ static constexpr uint32_t CLUSTER_LIGHT_BINDING = 4;
static constexpr uint32_t CLUSTER_LIGHT_INDEX_BINDING = 5;
static constexpr uint32_t CLUSTER_LIGHT_GRID_BINDING = 6;
constexpr const char *GEOMETRY_RENDERER_COMMAND = "geometry-renderer";
constexpr const char *DEBUG_RENDERER_COMMAND = "debug-renderer";
void localDescriptorSetLayoutResizeMaxJoints(uint32_t maxCount);
} // namespace pipeline
@@ -47,6 +47,34 @@
namespace cc {
namespace pipeline {
#if CC_USE_DEBUG_RENDERER
DebugRendererRenderCommand::DebugRendererRenderCommand(PipelineSceneData *sceneData)
: _sceneData(sceneData) {
}
void DebugRendererRenderCommand::beginRenderCommand(const RenderCommandContext &ctx) {
renderDebugRenderer(ctx.renderPass, ctx.cmdBuff, _sceneData, ctx.camera);
}
void DebugRendererRenderCommand::endRenderCommand(const RenderCommandContext & /*ctx*/) {
}
#endif
#if CC_USE_GEOMETRY_RENDERER
GeometryRendererRenderCommand::GeometryRendererRenderCommand(PipelineSceneData *sceneData)
: _sceneData(sceneData) {
}
void GeometryRendererRenderCommand::beginRenderCommand(const RenderCommandContext &ctx) {
if (ctx.camera && ctx.camera->getGeometryRenderer()) {
ctx.camera->getGeometryRenderer()->render(ctx.renderPass, ctx.cmdBuff, _sceneData);
}
}
void GeometryRendererRenderCommand::endRenderCommand(const RenderCommandContext & /*ctx*/) {
}
#endif
framegraph::StringHandle RenderPipeline::fgStrHandleOutDepthTexture = framegraph::FrameGraph::stringToHandle("depthTexture");
framegraph::StringHandle RenderPipeline::fgStrHandleOutColorTexture = framegraph::FrameGraph::stringToHandle("outputTexture");
framegraph::StringHandle RenderPipeline::fgStrHandlePostprocessPass = framegraph::FrameGraph::stringToHandle("pipelinePostPass");
@@ -87,6 +115,10 @@ bool RenderPipeline::activate(gfx::Swapchain * /*swapchain*/) {
_pipelineSceneData->activate(_device);
#if CC_USE_DEBUG_RENDERER
CC_DEBUG_RENDERER->activate(_device);
addRenderCommand(cc::pipeline::DEBUG_RENDERER_COMMAND, std::make_shared<DebugRendererRenderCommand>(getPipelineSceneData()));
#endif
#if CC_USE_GEOMETRY_RENDERER
addRenderCommand(cc::pipeline::GEOMETRY_RENDERER_COMMAND, std::make_shared<GeometryRendererRenderCommand>(getPipelineSceneData()));
#endif
// generate macros here rather than construct func because _clusterEnabled
@@ -115,6 +147,15 @@ void RenderPipeline::onGlobalPipelineStateChanged() {
// do nothing
}
void RenderPipeline::addRenderCommand(const ccstd::string &name, std::shared_ptr<RenderCommand> ptr) {
_renderCommands[name] = std::move(ptr);
}
RenderCommand *RenderPipeline::getRenderCommand(const ccstd::string &name) const {
const auto iter = _renderCommands.find(name);
return iter == _renderCommands.end() ? nullptr : iter->second.get();
}
void RenderPipeline::destroyQuadInputAssembler() {
CC_SAFE_DESTROY_AND_DELETE(_quadIB);
@@ -34,11 +34,14 @@
#include "renderer/core/PassUtils.h"
#include "scene/Model.h"
#include <memory>
namespace cc {
namespace gfx {
class CommandBuffer;
class DescriptorSet;
class DescriptorSetLayout;
class RenderPass;
} // namespace gfx
namespace scene {
class Camera;
@@ -54,6 +57,53 @@ class PipelineSceneData;
class GlobalDSManager;
class RenderStage;
class GeometryRenderer;
struct RenderCommandContext {
gfx::RenderPass *renderPass{nullptr};
gfx::CommandBuffer *cmdBuff{nullptr};
PipelineSceneData *sceneData{nullptr};
const scene::Camera *camera{nullptr};
};
class RenderCommand {
public:
RenderCommand() noexcept = default;
RenderCommand(RenderCommand &&rhs) = delete;
RenderCommand(RenderCommand const &rhs) = delete;
RenderCommand &operator=(RenderCommand &&rhs) = delete;
RenderCommand &operator=(RenderCommand const &rhs) = delete;
virtual ~RenderCommand() noexcept = default;
virtual void beginRenderCommand(const RenderCommandContext &ctx) = 0;
virtual void endRenderCommand(const RenderCommandContext &ctx) = 0;
};
#if CC_USE_DEBUG_RENDERER
class DebugRendererRenderCommand final : public RenderCommand {
public:
explicit DebugRendererRenderCommand(PipelineSceneData *sceneData);
void beginRenderCommand(const RenderCommandContext &ctx) override;
void endRenderCommand(const RenderCommandContext &ctx) override;
private:
PipelineSceneData *_sceneData{nullptr};
};
#endif
#if CC_USE_GEOMETRY_RENDERER
class GeometryRendererRenderCommand final : public RenderCommand {
public:
explicit GeometryRendererRenderCommand(PipelineSceneData *sceneData);
void beginRenderCommand(const RenderCommandContext &ctx) override;
void endRenderCommand(const RenderCommandContext &ctx) override;
private:
PipelineSceneData *_sceneData{nullptr};
};
#endif
struct CC_DLL RenderPipelineInfo {
uint32_t tag = 0;
RenderFlowList flows;
@@ -140,6 +190,9 @@ public:
#endif
}
void addRenderCommand(const ccstd::string &name, std::shared_ptr<RenderCommand> ptr);
RenderCommand *getRenderCommand(const ccstd::string &name) const;
inline void resetRenderQueue(bool reset) { _resetRenderQueue = reset; }
inline bool isRenderQueueReset() const { return _resetRenderQueue; }
@@ -194,6 +247,7 @@ protected:
ccstd::unordered_map<Vec4, gfx::InputAssembler *, Hasher<Vec4>> _quadIA;
framegraph::FrameGraph _fg;
ccstd::unordered_map<ccstd::string, std::shared_ptr<RenderCommand>> _renderCommands;
ccstd::unordered_map<gfx::ClearFlags, gfx::RenderPass *> _renderPasses;
// use cluster culling or not
+24 -1
View File
@@ -24,10 +24,12 @@
#include "RenderQueue.h"
#include <cmath>
#include <utility>
#include "PipelineSceneData.h"
#include "PipelineStateManager.h"
#include "RenderPipeline.h"
#include "base/Utils.h"
#include "gfx-base/GFXCommandBuffer.h"
#include "gfx-base/GFXDevice.h"
#include "gfx-base/GFXShader.h"
@@ -60,7 +62,28 @@ bool RenderQueue::insertRenderPass(const RenderObject &renderObj, uint32_t subMo
auto shaderId = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(subModel->getShader(passIdx)));
const auto hash = (0 << 30) | (passPriority << 16) | (modelPriority << 8) | passIdx;
const auto priority = renderObj.model->getPriority();
RenderPass renderPass = {priority, hash, renderObj.depth, shaderId, passIdx, subModel};
RenderPass renderPass{};
renderPass.priority = priority;
renderPass.hash = hash;
renderPass.depth = renderObj.depth;
renderPass.shaderID = shaderId;
renderPass.passIndex = passIdx;
renderPass.subModel = subModel;
/**
* Pack the sort keys once here so the comparator only compares uint64 keys.
* secondaryKey: depthKey << 32 | shaderID (transparent inverts depth for back-to-front).
*/
CC_ASSERT(!std::isnan(renderObj.depth));
const uint32_t depthKey = utils::numext::floatToSortableUint(renderObj.depth);
if (isTransparent) {
const uint32_t invertedDepthKey = ~depthKey;
renderPass.primaryKey = (static_cast<uint64_t>(priority) << 32) | hash;
renderPass.secondaryKey = (static_cast<uint64_t>(invertedDepthKey) << 32) | shaderId;
} else {
renderPass.primaryKey = hash;
renderPass.secondaryKey = (static_cast<uint64_t>(depthKey) << 32) | shaderId;
}
_queue.emplace_back(renderPass);
return true;
@@ -63,6 +63,7 @@ struct CustomRenderGraphContext {
const RenderGraph* renderGraph{nullptr};
const ResourceGraph* resourceGraph{nullptr};
gfx::CommandBuffer* primaryCommandBuffer{nullptr};
gfx::RenderPass* currentRenderPass{nullptr};
};
class CustomRenderPass : public Customization {
@@ -44,12 +44,6 @@
#include "details/GraphView.h"
#include "details/GslUtils.h"
#include "details/Range.h"
#if CC_USE_DEBUG_RENDERER
#include "cocos/renderer/pipeline/helper/Utils.h"
#endif
#if CC_USE_GEOMETRY_RENDERER
#include "cocos/renderer/pipeline/GeometryRenderer.h"
#endif
namespace cc {
@@ -704,10 +698,14 @@ struct RenderGraphVisitor : boost::dfs_visitor<> {
ctx.cmdBuff, ctx.currentPass, ctx.subpassIndex, sceneData.flags);
#if CC_USE_GEOMETRY_RENDERER
if (any(sceneData.flags & SceneFlags::GEOMETRY) &&
camera && camera->getGeometryRenderer()) {
camera->getGeometryRenderer()->render(
ctx.currentPass, ctx.cmdBuff, ctx.ppl->getPipelineSceneData());
const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, sceneID);
if (!renderData.custom.empty()) {
const auto& commands = ctx.ppl->custom.renderCommands;
auto iter = commands.find(renderData.custom);
if (iter != commands.end()) {
ctx.customContext.currentRenderPass = ctx.currentPass;
iter->second->beginRenderCommand(ctx.customContext, sceneID);
}
}
#endif
@@ -786,24 +784,18 @@ struct RenderGraphVisitor : boost::dfs_visitor<> {
}
void begin(const Blit& blit, RenderGraph::vertex_descriptor vertID) const {
tryBindPassDescriptorSet(vertID);
tryBindQueueDescriptorSets(vertID);
const auto& renderData = get(RenderGraph::DataTag{}, ctx.g, vertID);
if (!renderData.custom.empty()) {
const auto& commands = ctx.ppl->custom.renderCommands;
auto iter = commands.find(renderData.custom);
if (iter != commands.end()) {
ctx.customContext.currentRenderPass = ctx.currentPass;
iter->second->beginRenderCommand(ctx.customContext, vertID);
return;
}
}
#if CC_USE_DEBUG_RENDERER
if (blit.blitType == BlitType::DRAW_PROFILE) {
auto* renderPass = ctx.currentPass;
auto* cmdBuff = ctx.cmdBuff;
renderDebugRenderer(renderPass, cmdBuff, ctx.ppl->getPipelineSceneData(), cc::pipeline::profilerCamera);
}
#endif
tryBindPassDescriptorSet(vertID);
tryBindQueueDescriptorSets(vertID);
switch (blit.blitType) {
case BlitType::FULLSCREEN_QUAD:
@@ -48,6 +48,10 @@
#include "profiler/DebugRenderer.h"
#endif
#if CC_USE_GEOMETRY_RENDERER
#include "cocos/renderer/pipeline/GeometryRenderer.h"
#endif
namespace cc {
namespace render {
@@ -106,6 +110,54 @@ void addSubresourceNode<gfx::Format::DEPTH_STENCIL>(ResourceGraph::vertex_descri
} // namespace
#if CC_USE_DEBUG_RENDERER
namespace {
class DebugRendererRenderCommand final : public CustomRenderCommand {
public:
explicit DebugRendererRenderCommand(pipeline::PipelineSceneData *sceneData)
: _sceneData(sceneData) {}
void beginRenderCommand(const CustomRenderGraphContext &rg, RenderGraph::vertex_descriptor vertID) override {
std::ignore = vertID;
if (rg.currentRenderPass) {
DebugRenderer::getInstance()->render(rg.currentRenderPass, rg.primaryCommandBuffer, _sceneData);
}
}
void endRenderCommand(const CustomRenderGraphContext &rg, RenderGraph::vertex_descriptor vertID) override {
std::ignore = rg;
std::ignore = vertID;
}
private:
pipeline::PipelineSceneData *_sceneData{nullptr};
};
} // namespace
#endif
#if CC_USE_GEOMETRY_RENDERER
class GeometryRendererRenderCommand final : public CustomRenderCommand {
public:
explicit GeometryRendererRenderCommand(pipeline::PipelineSceneData *sceneData)
: _sceneData(sceneData) {}
void beginRenderCommand(const CustomRenderGraphContext &rg, RenderGraph::vertex_descriptor vertID) override {
const auto &sceneData = get(SceneTag{}, vertID, *rg.renderGraph);
if (sceneData.camera && sceneData.camera->getGeometryRenderer()) {
sceneData.camera->getGeometryRenderer()->render(rg.currentRenderPass, rg.primaryCommandBuffer, _sceneData);
}
}
void endRenderCommand(const CustomRenderGraphContext &rg, RenderGraph::vertex_descriptor vertID) override {
std::ignore = vertID;
std::ignore = rg;
}
private:
pipeline::PipelineSceneData *_sceneData{nullptr};
};
#endif
NativePipeline::NativePipeline(const allocator_type &alloc) noexcept
: device(gfx::Device::getInstance()),
globalDSManager(std::make_unique<pipeline::GlobalDSManager>()),
@@ -1385,6 +1437,10 @@ bool NativePipeline::activate(gfx::Swapchain *swapchainIn) {
pipelineSceneData->activate(device);
#if CC_USE_DEBUG_RENDERER
DebugRenderer::getInstance()->activate(device);
addCustomRenderCommand(cc::pipeline::DEBUG_RENDERER_COMMAND, std::make_shared<DebugRendererRenderCommand>(getPipelineSceneData()));
#endif
#if CC_USE_GEOMETRY_RENDERER
addCustomRenderCommand(cc::pipeline::GEOMETRY_RENDERER_COMMAND, std::make_shared<GeometryRendererRenderCommand>(getPipelineSceneData()));
#endif
// generate macros here rather than construct func because _clusterEnabled
// switch may be changed in root.ts setRenderPipeline() function which is after
@@ -913,6 +913,13 @@ SceneBuilder *NativeRenderQueueBuilder::addScene(
data);
}
#if CC_USE_GEOMETRY_RENDERER
if (any(sceneFlags & SceneFlags::GEOMETRY)) {
auto &data = get(RenderGraph::DataTag{}, *renderGraph, sceneID);
data.custom = cc::pipeline::GEOMETRY_RENDERER_COMMAND;
}
#endif
if (any(sceneFlags & SceneFlags::UI)) {
CC_EXPECTS(camera);
const auto passOrSubpassId = parent(nodeID, *renderGraph);
@@ -1086,6 +1093,31 @@ void NativeRenderQueueBuilder::addProfiler(const scene::Camera *camera) {
*renderGraph,
passOrSubpassId);
#if CC_USE_DEBUG_RENDERER
const auto debugId = addVertex2(
BlitTag{},
std::forward_as_tuple("DebugRenderer"),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(),
std::forward_as_tuple(
IntrusivePtr<Material>{},
RenderGraph::null_vertex(),
SceneFlags::NONE,
nullptr,
BlitType::FULLSCREEN_QUAD),
*renderGraph,
queueId);
auto &debugData = get(RenderGraph::DataTag{}, *renderGraph, debugId);
debugData.custom = cc::pipeline::DEBUG_RENDERER_COMMAND;
setCameraUBOValues(
*camera,
*layoutGraph,
*pipelineRuntime->getPipelineSceneData(),
camera->getScene() ? camera->getScene()->getMainLight() : nullptr,
debugData);
#endif
const auto sceneId = addVertex2(
BlitTag{},
std::forward_as_tuple("Profiler"),
@@ -647,8 +647,8 @@ void LightingStage::fgTransparent(scene::Camera *camera) {
_planarShadowQueue->recordCommandBuffer(_device, table.getRenderPass(), cmdBuff);
#if CC_USE_GEOMETRY_RENDERER
if (camera->getGeometryRenderer()) {
camera->getGeometryRenderer()->render(table.getRenderPass(), cmdBuff, pipeline->getPipelineSceneData());
if (auto *command = pipeline->getRenderCommand(cc::pipeline::GEOMETRY_RENDERER_COMMAND)) {
command->beginRenderCommand({table.getRenderPass(), cmdBuff, pipeline->getPipelineSceneData(), camera});
}
#endif
};
@@ -228,7 +228,9 @@ void PostProcessStage::render(scene::Camera *camera) {
_uiPhase->render(camera, renderPass);
renderProfiler(renderPass, cmdBuff, pipeline->getProfiler(), camera);
#if CC_USE_DEBUG_RENDERER
renderDebugRenderer(renderPass, cmdBuff, pipeline->getPipelineSceneData(), camera);
if (auto *command = pipeline->getRenderCommand(cc::pipeline::DEBUG_RENDERER_COMMAND)) {
command->beginRenderCommand({renderPass, cmdBuff, pipeline->getPipelineSceneData(), camera});
}
#endif
};
@@ -23,9 +23,6 @@
****************************************************************************/
#include "ForwardStage.h"
#if CC_USE_GEOMETRY_RENDERER
#include "../GeometryRenderer.h"
#endif
#include "../InstancedBuffer.h"
#include "../PipelineSceneData.h"
#include "../PipelineUBO.h"
@@ -262,15 +259,17 @@ void ForwardStage::render(scene::Camera *camera) {
}
#if CC_USE_GEOMETRY_RENDERER
if (camera->getGeometryRenderer()) {
camera->getGeometryRenderer()->render(renderPass, cmdBuff, pipeline->getPipelineSceneData());
if (auto *command = pipeline->getRenderCommand(cc::pipeline::GEOMETRY_RENDERER_COMMAND)) {
command->beginRenderCommand({renderPass, cmdBuff, pipeline->getPipelineSceneData(), camera});
}
#endif
_uiPhase->render(camera, renderPass);
renderProfiler(renderPass, cmdBuff, _pipeline->getProfiler(), camera);
#if CC_USE_DEBUG_RENDERER
renderDebugRenderer(renderPass, cmdBuff, _pipeline->getPipelineSceneData(), camera);
if (auto *command = pipeline->getRenderCommand(cc::pipeline::DEBUG_RENDERER_COMMAND)) {
command->beginRenderCommand({renderPass, cmdBuff, pipeline->getPipelineSceneData(), camera});
}
#endif
};
+1 -1
View File
@@ -60,7 +60,7 @@ float LODGroup::getScreenUsagePercentage(const Camera *camera) const {
return 0;
}
auto distance = 0;
float distance = 0.0F;
if (camera->getProjectionType() == CameraProjection::PERSPECTIVE) {
Vec3 tmp{_localBoundaryCenter};
tmp.transformMat4(_node->getWorldMatrix());
+1 -1
View File
@@ -3,6 +3,6 @@
"type": "github",
"owner": "cocos",
"name": "cocos-engine-external",
"checkout": "v4.0.0-9"
"checkout": "v4.0.0-10"
}
}
+6
View File
@@ -105,6 +105,12 @@ using namespace cc;
%ignore cc::pipeline::GeometryRenderer::activate;
%ignore cc::pipeline::GeometryRenderer::render;
%ignore cc::pipeline::GeometryRenderer::destroy;
%ignore cc::pipeline::RenderCommand;
%ignore cc::pipeline::RenderCommandContext;
%ignore cc::pipeline::DebugRendererRenderCommand;
%ignore cc::pipeline::GeometryRendererRenderCommand;
%ignore cc::pipeline::RenderPipeline::addRenderCommand;
%ignore cc::pipeline::RenderPipeline::getRenderCommand;
// ----- Rename Section ------
// Brief: Classes, methods or attributes needs to be renamed
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.33",
"version": "4.0.0-alpha.35",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cocos-creator",
"version": "4.0.0-alpha.33",
"version": "4.0.0-alpha.35",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.33",
"version": "4.0.0-alpha.35",
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",