From ca26b205ba494c7d4049716cfd1fe19c29c52379 Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 9 Aug 2022 11:48:02 +0800 Subject: [PATCH 01/13] fix undefined mode for building separate-engine (#12365) * fix undefined mode * publish @cocos/build-engine@4.3.16 * optimize --- scripts/build-engine/package-lock.json | 2 +- scripts/build-engine/package.json | 2 +- scripts/build-engine/src/index.ts | 28 ++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/scripts/build-engine/package-lock.json b/scripts/build-engine/package-lock.json index 41b0b83599..5ad0c496ff 100644 --- a/scripts/build-engine/package-lock.json +++ b/scripts/build-engine/package-lock.json @@ -1,6 +1,6 @@ { "name": "@cocos/build-engine", - "version": "4.3.15", + "version": "4.3.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/scripts/build-engine/package.json b/scripts/build-engine/package.json index 8aff389813..2cccebcdb5 100644 --- a/scripts/build-engine/package.json +++ b/scripts/build-engine/package.json @@ -1,6 +1,6 @@ { "name": "@cocos/build-engine", - "version": "4.3.15", + "version": "4.3.17", "description": "", "repository": { "type": "git", diff --git a/scripts/build-engine/src/index.ts b/scripts/build-engine/src/index.ts index 8de4598f80..3d81f4faf0 100644 --- a/scripts/build-engine/src/index.ts +++ b/scripts/build-engine/src/index.ts @@ -273,17 +273,37 @@ async function doBuild ({ const featureUnits = statsQuery.getUnitsOfFeatures(features); - // HACK: get flags from build time constants + // HACK: get platform, mode, flags from build time constants const flags: Record = {}; - ['SERVER_MODE', 'NOT_PACK_PHYSX_LIBS', 'DEBUG', 'NET_MODE'].forEach(key => { + ['SERVER_MODE', 'NOT_PACK_PHYSX_LIBS', 'DEBUG', 'NET_MODE'].forEach((key) => { flags[key] = buildTimeConstants[key]; }); + let platform = options.platform as PlatformType; + if (!platform) { + ["HTML5", "NATIVE", "WECHAT", "BAIDU", "XIAOMI", "ALIPAY", "BYTEDANCE", "OPPO", "VIVO", "HUAWEI", "COCOSPLAY", "QTT", "LINKSURE"].some(key => { + if (buildTimeConstants[key]) { + platform = key as PlatformType; + return true; + } + return false; + }); + } + let mode = options.mode as ModeType; + if (!mode) { + ["EDITOR", "PREVIEW", "BUILD", "TEST"].some((key) => { + if (buildTimeConstants[key]) { + mode = key as ModeType; + return true; + } + return false; + }); + } const rpVirtualOptions: Record = {}; const vmInternalConstants = statsQuery.constantManager.exportStaticConstants({ - platform: options.platform as PlatformType, - mode: options.mode as ModeType, + platform, + mode, flags, }); console.debug(`Module source "internal-constants":\n${vmInternalConstants}`); From d08a11244d2a31da1aac7af7d2aa8f1b6152e30c Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 9 Aug 2022 11:49:53 +0800 Subject: [PATCH 02/13] debug-renderer and occlusion-query is not wechatPlugin (#12366) --- editor/engine-features/render-config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index 47c1977ee6..0b76c5917c 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -133,7 +133,7 @@ "label": "i18n:ENGINE.features.occlusion_query.label", "description": "i18n:ENGINE.features.occlusion_query.description", "native": "USE_OCCLUSION_QUERY", - "wechatPlugin": true, + "wechatPlugin": false, "category": "3d" }, "geometry-renderer": { @@ -149,7 +149,7 @@ "label": "i18n:ENGINE.features.debug_renderer.label", "description": "i18n:ENGINE.features.debug_renderer.description", "native": "USE_DEBUG_RENDERER", - "wechatPlugin": true, + "wechatPlugin": false, "category": "3d" }, "particle-2d": { From ca9c80146d191303902294c37745e07604a3fe4b Mon Sep 17 00:00:00 2001 From: timlyeee <43355299+timlyeee@users.noreply.github.com> Date: Tue, 16 Aug 2022 16:03:01 +0800 Subject: [PATCH 03/13] append cmake argument as APP_NAME for all build phase on Windows (#12439) --- scripts/native-pack-tool/source/platforms/windows.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/native-pack-tool/source/platforms/windows.ts b/scripts/native-pack-tool/source/platforms/windows.ts index ba32427aea..1350dd8773 100644 --- a/scripts/native-pack-tool/source/platforms/windows.ts +++ b/scripts/native-pack-tool/source/platforms/windows.ts @@ -49,8 +49,9 @@ export class WindowsPackTool extends NativePackTool { } else { generateArgs = generateArgs.concat(await this.windowsSelectCmakeGeneratorArgs()); } - this.appendCmakeResDirArgs(generateArgs); + } + this.appendCmakeResDirArgs(generateArgs); await toolHelper.runCmake([`-S"${cchelper.fixPath(this.paths.platformTemplateDirInPrj)}"`, `-B"${cchelper.fixPath(this.paths.nativePrjDir)}"`].concat(generateArgs)); return true; } From ac8b1f6527324214b13c2be78581422720670211 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Tue, 16 Aug 2022 16:06:56 +0800 Subject: [PATCH 04/13] [optimization] Use define to replace uniform (#12368) --- .../3d/lights/directional-light-component.ts | 36 ++++++++---- cocos/core/pipeline/pipeline-ubo.ts | 4 +- cocos/core/pipeline/shadow/shadow-flow.ts | 13 ++++- .../core/renderer/scene/directional-light.ts | 22 ++++++- cocos/core/renderer/scene/shadows.ts | 28 ++++++--- .../builtin/functionalities/shadow-map.chunk | 57 +++++++++++-------- .../chunks/common/shadow/native-pcf.chunk | 5 ++ .../legacy/shading-cluster-additive.chunk | 2 +- .../legacy/shading-standard-additive.chunk | 2 +- .../chunks/legacy/shading-standard-base.chunk | 10 +++- .../assets/chunks/legacy/shading-toon.chunk | 10 +++- .../assets/chunks/legacy/shadow-map-fs.chunk | 2 +- .../lighting-flow/common-flow.chunk | 14 +++-- .../renderer/pipeline/shadow/ShadowFlow.cpp | 15 +++++ native/cocos/scene/DirectionalLight.cpp | 16 ++++++ native/cocos/scene/DirectionalLight.h | 22 +++++-- native/cocos/scene/Shadow.cpp | 15 +++++ 17 files changed, 207 insertions(+), 66 deletions(-) diff --git a/cocos/3d/lights/directional-light-component.ts b/cocos/3d/lights/directional-light-component.ts index a20a5fd904..2d1b04d0cf 100644 --- a/cocos/3d/lights/directional-light-component.ts +++ b/cocos/3d/lights/directional-light-component.ts @@ -115,7 +115,8 @@ export class DirectionalLight extends Light { * @en Whether activate real time shadow. * @zh 是否启用实时阴影? */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } }) @editable @type(CCBoolean) @@ -133,7 +134,8 @@ export class DirectionalLight extends Light { * @en The shadow pcf for real time shadow. * @zh 实时阴影计算中的阴影 pcf 等级。 */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 5 } }) @editable @type(PCFType) @@ -151,7 +153,8 @@ export class DirectionalLight extends Light { * @en The shadow map sampler offset for real time shadow. * @zh 实时阴影计算中的阴影纹理偏移值。 */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 6 } }) @editable @type(CCFloat) @@ -169,7 +172,8 @@ export class DirectionalLight extends Light { * @en The global normal bias for real time shadow. * @zh 实时阴影计算中的法线偏移。 */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 7 } }) @editable @type(CCFloat) @@ -187,7 +191,8 @@ export class DirectionalLight extends Light { * @en The shadow color saturation for real time shadow. * @zh 实时阴影计算中的阴影颜色饱和度。 */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 8 } }) @editable @range([0.0, 1.0, 0.01]) @@ -209,7 +214,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中潜在阴影产生的范围 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 9 } }) @@ -235,7 +241,8 @@ export class DirectionalLight extends Light { * @zh 实时阴影计算中剔除阴影的范围 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 10 } }) @@ -280,7 +287,8 @@ export class DirectionalLight extends Light { * @zh 开启或关闭 csm 模式 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === false; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 12 } }) @@ -346,7 +354,8 @@ export class DirectionalLight extends Light { * @en Whether to use fixed area shadow in real time shadow. * @zh 实时阴影计算中是否使用固定区域阴影。 */ - @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) + @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 15 } }) @editable @type(CCBoolean) @@ -365,7 +374,8 @@ export class DirectionalLight extends Light { * @zh 固定区域阴影设置中阴影相机近裁剪面 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 16 } }) @@ -386,7 +396,8 @@ export class DirectionalLight extends Light { * @zh 固定区域阴影设置中阴影相机远裁剪面。 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 17 } }) @@ -407,7 +418,8 @@ export class DirectionalLight extends Light { * @zh 固定区域阴影设置中阴影相机的正交尺寸 */ @visible(function (this: DirectionalLight) { - return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type + return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled + && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap && this._shadowFixedArea === true; }) @property({ group: { name: 'DynamicShadowSettings', displayOrder: 18 } }) diff --git a/cocos/core/pipeline/pipeline-ubo.ts b/cocos/core/pipeline/pipeline-ubo.ts index dcfb7d9f85..1a84ab35cb 100644 --- a/cocos/core/pipeline/pipeline-ubo.ts +++ b/cocos/core/pipeline/pipeline-ubo.ts @@ -194,8 +194,8 @@ export class PipelineUBO { return 1.0 / (shadowMapSize * 0.5); case PCFType.SOFT_2X: return 2.0 / (shadowMapSize * 0.5); - // case PCFType.SOFT_4X: - // return 3.0 / (shadowMapSize * 0.5); + case PCFType.SOFT_4X: + return 3.0 / (shadowMapSize * 0.5); default: } return 0.0; diff --git a/cocos/core/pipeline/shadow/shadow-flow.ts b/cocos/core/pipeline/shadow/shadow-flow.ts index 5444843e43..bfc9f2e0f5 100644 --- a/cocos/core/pipeline/shadow/shadow-flow.ts +++ b/cocos/core/pipeline/shadow/shadow-flow.ts @@ -35,7 +35,7 @@ import { RenderPass, LoadOp, StoreOp, import { RenderFlowTag } from '../pipeline-serialization'; import { ForwardPipeline } from '../forward/forward-pipeline'; import { RenderPipeline } from '..'; -import { ShadowType } from '../../renderer/scene/shadows'; +import { PCFType, ShadowType } from '../../renderer/scene/shadows'; import { Light, LightType } from '../../renderer/scene/light'; import { Camera } from '../../renderer/scene'; import { SpotLight } from '../../renderer/scene/spot-light'; @@ -88,6 +88,15 @@ export class ShadowFlow extends RenderFlow { >= (UBOGlobal.COUNT + UBOCamera.COUNT + UBOShadow.COUNT + UBOCSM.COUNT) / 4; pipeline.macros.CC_SUPPORT_CASCADED_SHADOW_MAP = pipeline.pipelineSceneData.csmSupported; + // 0: CC_SHADOW_NONE, 1: CC_SHADOW_PLANAR, 2: CC_SHADOW_MAP + pipeline.macros.CC_SHADOW_TYPE = 0; + + // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X + pipeline.macros.CC_DIR_SHADOW_PCF_TYPE = PCFType.HARD; + + // 0: CC_DIR_LIGHT_SHADOW_NONE, 1: CC_DIR_LIGHT_SHADOW_UNIFORM, 2: CC_DIR_LIGHT_SHADOW_CASCADED, 3: CC_DIR_LIGHT_SHADOW_VARIANCE + pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 0; + pipeline.onGlobalPipelineStateChanged(); } @@ -165,7 +174,7 @@ export class ShadowFlow extends RenderFlow { if (!frameBuffer) { continue; } const renderTargets = frameBuffer.colorTextures; for (let j = 0; j < renderTargets.length; j++) { - const renderTarget = renderTargets[i]; + const renderTarget = renderTargets[j]; if (renderTarget) { renderTarget.destroy(); } } renderTargets.length = 0; diff --git a/cocos/core/renderer/scene/directional-light.ts b/cocos/core/renderer/scene/directional-light.ts index 85c7728935..81490ca736 100644 --- a/cocos/core/renderer/scene/directional-light.ts +++ b/cocos/core/renderer/scene/directional-light.ts @@ -27,7 +27,7 @@ import { legacyCC } from '../../global-exports'; import { Vec3 } from '../../math'; import { Ambient } from './ambient'; import { Light, LightType } from './light'; -import { CSMLevel, CSMOptimizationMode, PCFType, Shadows } from './shadows'; +import { CSMLevel, CSMOptimizationMode, PCFType, Shadows, ShadowType } from './shadows'; const _forward = new Vec3(0, 0, -1); const _v3 = new Vec3(); @@ -127,6 +127,7 @@ export class DirectionalLight extends Light { } set shadowEnabled (val) { this._shadowEnabled = val; + this._activate(); } /** @@ -138,6 +139,7 @@ export class DirectionalLight extends Light { } set shadowPcf (val) { this._shadowPcf = val; + this._activate(); } /** @@ -204,6 +206,7 @@ export class DirectionalLight extends Light { } set csmLevel (val) { this._csmLevel = val; + this._activate(); } /** @@ -248,6 +251,7 @@ export class DirectionalLight extends Light { } set shadowFixedArea (val) { this._shadowFixedArea = val; + this._activate(); } /** @@ -304,4 +308,20 @@ export class DirectionalLight extends Light { this.direction = Vec3.transformQuat(_v3, _forward, this._node.worldRotation); } } + + private _activate () { + const root = legacyCC.director.root; + const pipeline = root.pipeline; + if (this._shadowEnabled) { + if (this._shadowFixedArea) { + pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 1; + } else { + pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = this.csmLevel > 1 ? 2 : 1; + } + pipeline.macros.CC_DIR_SHADOW_PCF_TYPE = this._shadowPcf; + } else { + pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 0; + } + root.onGlobalPipelineStateChanged(); + } } diff --git a/cocos/core/renderer/scene/shadows.ts b/cocos/core/renderer/scene/shadows.ts index dce5ae3697..a03baeb487 100644 --- a/cocos/core/renderer/scene/shadows.ts +++ b/cocos/core/renderer/scene/shadows.ts @@ -121,12 +121,12 @@ export const PCFType = Enum({ */ SOFT_2X: 2, - // /** - // * @zh x16 次采样 - // * @en x16 times - // * @readonly - // */ - // SOFT_4X: 3, + /** + * @zh x16 次采样 + * @en x16 times + * @readonly + */ + SOFT_4X: 3, }); /** @@ -389,10 +389,20 @@ export class Shadows { } public activate () { - if (this.enabled) { + if (this._enabled) { if (this.type === ShadowType.Planar) { this._updatePlanarInfo(); + } else { + const root = legacyCC.director.root; + const pipeline = root.pipeline; + pipeline.macros.CC_SHADOW_TYPE = 2; + root.onGlobalPipelineStateChanged(); } + } else { + const root = legacyCC.director.root; + const pipeline = root.pipeline; + pipeline.macros.CC_SHADOW_TYPE = 0; + root.onGlobalPipelineStateChanged(); } } @@ -405,6 +415,10 @@ export class Shadows { this._instancingMaterial = new Material(); this._instancingMaterial.initialize({ effectName: 'pipeline/planar-shadow', defines: { USE_INSTANCING: true } }); } + const root = legacyCC.director.root; + const pipeline = root.pipeline; + pipeline.macros.CC_SHADOW_TYPE = 1; + root.onGlobalPipelineStateChanged(); } public destroy () { diff --git a/editor/assets/chunks/builtin/functionalities/shadow-map.chunk b/editor/assets/chunks/builtin/functionalities/shadow-map.chunk index 735b9ffe71..bce1a85732 100644 --- a/editor/assets/chunks/builtin/functionalities/shadow-map.chunk +++ b/editor/assets/chunks/builtin/functionalities/shadow-map.chunk @@ -9,6 +9,15 @@ #pragma define SHADOWMAP_FORMAT_RGBA8 1 #pragma define SHADOWMAP_FORMAT_FLOAT 0 +#pragma define CC_DIR_LIGHT_SHADOW_NONE 0 +#pragma define CC_DIR_LIGHT_SHADOW_UNIFORM 1 +#pragma define CC_DIR_LIGHT_SHADOW_CASCADED 2 +#pragma define CC_DIR_LIGHT_SHADOW_VARIANCE 3 + +#pragma define CC_SHADOW_NONE 0 +#pragma define CC_SHADOW_PLANAR 1 +#pragma define CC_SHADOW_MAP 2 + float CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) { vec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0); viewPos.z += viewSpaceBias; @@ -196,11 +205,9 @@ float CCGetLinearDepth(vec3 worldPos) { pos = ApplyShadowDepthBias_Perspective(shadowPos, shadowBias.x); #endif - /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance - if (pcf > 2.9) { - return CCGetSpotLightShadowFactorSoft5X(pos, worldPos); - } else */ - if (pcf > 1.9) { + if (pcf > 2.9) { + return CCGetSpotLightShadowFactorSoft5X(pos, worldPos); + }else if (pcf > 1.9) { return CCGetSpotLightShadowFactorSoft3X(pos, worldPos); }else if (pcf > 0.9) { return CCGetSpotLightShadowFactorSoft(pos, worldPos); @@ -211,22 +218,23 @@ float CCGetLinearDepth(vec3 worldPos) { float CCShadowFactorBase(vec4 shadowPos, vec3 N, vec2 shadowBias) { - float realtimeShadow = 1.0; vec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N, shadowBias.y, cc_matLightView, cc_shadowProjInfo.xy); pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, cc_shadowProjDepthInfo.x, cc_shadowProjDepthInfo.y); - float pcf = cc_shadowWHPBInfo.z; - /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance - if (pcf > 2.9) { - realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos); - } else */ - if (pcf > 1.9) { + float realtimeShadow = 1.0; + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_5X + realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos); + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_3X realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos); - }else if (pcf > 0.9) { + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT realtimeShadow = CCGetDirLightShadowFactorSoft(pos); - }else { + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_HARD realtimeShadow = CCGetDirLightShadowFactorHard(pos); - } + #endif + return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w); } @@ -260,23 +268,24 @@ float CCGetLinearDepth(vec3 worldPos) { vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2; int level = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos); if (level < 0) { return 1.0; } - float realtimeShadow = 1.0; vec4 pos = ApplyShadowDepthBias_FaceNormal(csmPos, N, shadowBias.y, shadowViewDir0, shadowViewDir1, shadowViewDir2, shadowProjInfo.xy); pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, shadowProjDepthInfo.x, shadowProjDepthInfo.y); - float pcf = cc_shadowWHPBInfo.z; - /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance - if (pcf > 2.9) { + float realtimeShadow = 1.0; + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_5X realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos); - } else */ - if (pcf > 1.9) { + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_3X realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos); - } else if (pcf > 0.9) { + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT realtimeShadow = CCGetDirLightShadowFactorSoft(pos); - }else { + #endif + #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_HARD realtimeShadow = CCGetDirLightShadowFactorHard(pos); - } + #endif + return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w); } #else diff --git a/editor/assets/chunks/common/shadow/native-pcf.chunk b/editor/assets/chunks/common/shadow/native-pcf.chunk index 78057bb9a5..bc0e41a15d 100644 --- a/editor/assets/chunks/common/shadow/native-pcf.chunk +++ b/editor/assets/chunks/common/shadow/native-pcf.chunk @@ -1,5 +1,10 @@ // NDC shadowPos applied with normal bias and depth bias +#pragma define CC_SHADOW_PCF_HARD 0 +#pragma define CC_SHADOW_PCF_SOFT 1 +#pragma define CC_SHADOW_PCF_SOFT_3X 2 +#pragma define CC_SHADOW_PCF_SOFT_5X 3 + float NativePCFShadowFactorHard (vec3 shadowNDCPos, sampler2D shadowMap, vec2 shadowMapResolution) { #if CC_SHADOWMAP_FORMAT == SHADOWMAP_FORMAT_RGBA8 diff --git a/editor/assets/chunks/legacy/shading-cluster-additive.chunk b/editor/assets/chunks/legacy/shading-cluster-additive.chunk index 8fd4ff28f8..6e413e6684 100644 --- a/editor/assets/chunks/legacy/shading-cluster-additive.chunk +++ b/editor/assets/chunks/legacy/shading-cluster-additive.chunk @@ -132,7 +132,7 @@ vec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) { vec3 lightColor = light.cc_lightColor.rgb; float shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if (light.cc_lightPos.w > 0.0) { shadow = CCSpotShadowFactorBase(shadowPos, position, s.shadowBias); } diff --git a/editor/assets/chunks/legacy/shading-standard-additive.chunk b/editor/assets/chunks/legacy/shading-standard-additive.chunk index af5a2963e3..62455a3da7 100644 --- a/editor/assets/chunks/legacy/shading-standard-additive.chunk +++ b/editor/assets/chunks/legacy/shading-standard-additive.chunk @@ -47,7 +47,7 @@ vec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) { vec3 lightColor = cc_lightColor[i].rgb; float shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) { shadow = CCSpotShadowFactorBase(shadowPos, position, s.shadowBias); } diff --git a/editor/assets/chunks/legacy/shading-standard-base.chunk b/editor/assets/chunks/legacy/shading-standard-base.chunk index d00c287b82..0a0c91c944 100644 --- a/editor/assets/chunks/legacy/shading-standard-base.chunk +++ b/editor/assets/chunks/legacy/shading-standard-base.chunk @@ -103,12 +103,16 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) { float NL = max(dot(N, L), 0.0); float shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if (NL > 0.0 && cc_mainLitDir.w > 0.0) { if (cc_shadowLPNNInfo.w > 0.0) { - shadow = CCCSMFactorBase(position, N, s.shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED + shadow = CCCSMFactorBase(position, N, s.shadowBias); + #endif } else { - shadow = CCShadowFactorBase(shadowPos, N, s.shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM + shadow = CCShadowFactorBase(shadowPos, N, s.shadowBias); + #endif } } #endif diff --git a/editor/assets/chunks/legacy/shading-toon.chunk b/editor/assets/chunks/legacy/shading-toon.chunk index f13f95c37b..2aa7b6e54c 100644 --- a/editor/assets/chunks/legacy/shading-toon.chunk +++ b/editor/assets/chunks/legacy/shading-toon.chunk @@ -100,12 +100,16 @@ struct ToonSurface { vec3 dirlightContrib = diffuse + specular; float shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if(s.shadowCover < NL && cc_mainLitDir.w > 0.0) { if (cc_shadowLPNNInfo.w > 0.0) { - shadow = CCCSMFactorBase(position, N, s.shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED + shadow = CCCSMFactorBase(position, N, s.shadowBias); + #endif } else { - shadow = CCShadowFactorBase(CC_SHADOW_POSITION, N, s.shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM + shadow = CCShadowFactorBase(CC_SHADOW_POSITION, N, s.shadowBias); + #endif } } #endif diff --git a/editor/assets/chunks/legacy/shadow-map-fs.chunk b/editor/assets/chunks/legacy/shadow-map-fs.chunk index cc9e947dc4..1ad503d1f0 100644 --- a/editor/assets/chunks/legacy/shadow-map-fs.chunk +++ b/editor/assets/chunks/legacy/shadow-map-fs.chunk @@ -7,7 +7,7 @@ in highp vec4 v_shadowPos; #pragma define CC_SHADOW_POSITION v_shadowPos // Just to be compatible with old projects only -#if CC_RECEIVE_SHADOW +#if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP void CC_SPOT_SHADOW_FACTOR(out float realtimeShadow, vec3 worldPos, vec3 lightPos, vec3 normal, vec2 shadowBias) { realtimeShadow = CCSpotShadowFactorBase(CC_SHADOW_POSITION, worldPos, shadowBias); } diff --git a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk index 52d1c761bf..bf63ab23b0 100644 --- a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk +++ b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk @@ -23,7 +23,7 @@ CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]); float shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) { if (CCSurfacesLightingEnableShadow(lightingData.NoL)) { vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0); @@ -64,14 +64,18 @@ // CCSurfacesLightingCalculateShadow: lightingResult.shadow = 1.0; - #if CC_RECEIVE_SHADOW + #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP if (cc_mainLitDir.w > 0.0) { if (CCSurfacesLightingEnableShadow(lightingData.NoL)) { if (cc_shadowLPNNInfo.w > 0.0) { - lightingResult.shadow = CCCSMFactorBase(surfaceData.worldPos, lightingData.N, shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED + lightingResult.shadow = CCCSMFactorBase(surfaceData.worldPos, lightingData.N, shadowBias); + #endif } else { - vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0); - lightingResult.shadow = CCShadowFactorBase(shadowPos, lightingData.N, shadowBias); + #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM + vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0); + lightingResult.shadow = CCShadowFactorBase(shadowPos, lightingData.N, shadowBias); + #endif } } } diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp index 1d74b2c699..777d836519 100644 --- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp +++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp @@ -84,6 +84,21 @@ void ShadowFlow::activate(RenderPipeline *pipeline) { pipeline->getPipelineSceneData()->setCSMSupported(csmSupported); pipeline->setValue("CC_SUPPORT_CASCADED_SHADOW_MAP", csmSupported); + // 0: CC_SHADOW_NONE, 1: CC_SHADOW_PLANAR, 2: CC_SHADOW_MAP + pipeline->setValue("CC_SHADOW_TYPE", 0); + + // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X + pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", static_cast(scene::PCFType::HARD)); + + // 0: CC_DIR_LIGHT_SHADOW_UNIFORM, 1: CC_DIR_LIGHT_SHADOW_CASCADED, 2: CC_DIR_LIGHT_SHADOW_VARIANCE + pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 0); + + // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X + pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", 0); + + // 0: CC_DIR_LIGHT_SHADOW_PLANAR, 1: CC_DIR_LIGHT_SHADOW_UNIFORM, 2: CC_DIR_LIGHT_SHADOW_CASCADED, 3: CC_DIR_LIGHT_SHADOW_VARIANCE + pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE ", 0); + pipeline->onGlobalPipelineStateChanged(); } diff --git a/native/cocos/scene/DirectionalLight.cpp b/native/cocos/scene/DirectionalLight.cpp index 76046d25bc..7506856157 100644 --- a/native/cocos/scene/DirectionalLight.cpp +++ b/native/cocos/scene/DirectionalLight.cpp @@ -69,5 +69,21 @@ void DirectionalLight::setIlluminance(float value) { } } +void DirectionalLight::activate() const { + auto *pipeline = pipeline::RenderPipeline::getInstance(); + if (pipeline) { + if (_shadowEnabled) { + if (_shadowFixedArea) { + pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 1); + } else { + pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", static_cast(_csmLevel) > 1 ? 2 : 1); + } + pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", static_cast(_shadowPcf)); + } else { + pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 0); + } + } +} + } // namespace scene } // namespace cc diff --git a/native/cocos/scene/DirectionalLight.h b/native/cocos/scene/DirectionalLight.h index 0c4a23c3f1..fe9fc98de3 100644 --- a/native/cocos/scene/DirectionalLight.h +++ b/native/cocos/scene/DirectionalLight.h @@ -41,18 +41,30 @@ public: void initialize() override; void update() override; - inline void setShadowEnabled(bool enabled) { _shadowEnabled = enabled; } - inline void setShadowPcf(PCFType pcf) { _shadowPcf = pcf; } + inline void setShadowEnabled(bool enabled) { + _shadowEnabled = enabled; + activate(); + } + inline void setShadowPcf(PCFType pcf) { + _shadowPcf = pcf; + activate(); + } inline void setShadowBias(float bias) { _shadowBias = bias; } inline void setShadowNormalBias(float normalBias) { _shadowNormalBias = normalBias; } inline void setShadowSaturation(float saturation) { _shadowSaturation = saturation; } inline void setShadowDistance(float distance) { _shadowDistance = distance; } inline void setShadowInvisibleOcclusionRange(float invisibleOcclusionRange) { _shadowInvisibleOcclusionRange = invisibleOcclusionRange; } - inline void setCSMLevel(CSMLevel csmLevel) { _csmLevel = csmLevel; } + inline void setCSMLevel(CSMLevel csmLevel) { + _csmLevel = csmLevel; + activate(); + } inline void setCSMLayerLambda(float lambda) { _csmLayerLambda = lambda; } inline void setCSMNeedUpdate(bool isCSMNeedUpdate) { _isCSMNeedUpdate = isCSMNeedUpdate; } inline void setCSMOptimizationMode(CSMOptimizationMode csmOptimizationMode) { _csmOptimizationMode = csmOptimizationMode; } - inline void setShadowFixedArea(bool fixedArea) { _shadowFixedArea = fixedArea; } + inline void setShadowFixedArea(bool fixedArea) { + _shadowFixedArea = fixedArea; + activate(); + } inline void setShadowNear(float nearValue) { _shadowNear = nearValue; } inline void setShadowFar(float farValue) { _shadowFar = farValue; } inline void setShadowOrthoSize(float orthoSize) { _shadowOrthoSize = orthoSize; } @@ -83,6 +95,8 @@ public: void setIlluminance(float value); private: + void activate() const; + float _illuminanceHDR{Ambient::SUN_ILLUM}; float _illuminanceLDR{1.F}; Vec3 _dir{1.0F, -1.0F, -1.0F}; diff --git a/native/cocos/scene/Shadow.cpp b/native/cocos/scene/Shadow.cpp index 571f24b039..ee2405bae3 100644 --- a/native/cocos/scene/Shadow.cpp +++ b/native/cocos/scene/Shadow.cpp @@ -157,6 +157,16 @@ void Shadows::activate() { if (_enabled) { if (_type == ShadowType::PLANAR) { updatePlanarInfo(); + } else { + auto *pipeline = pipeline::RenderPipeline::getInstance(); + if (pipeline) { + pipeline->setValue("CC_SHADOW_TYPE", 2); + } + } + } else { + auto *pipeline = pipeline::RenderPipeline::getInstance(); + if (pipeline) { + pipeline->setValue("CC_SHADOW_TYPE", 0); } } } @@ -168,6 +178,11 @@ void Shadows::updatePlanarInfo() { if (!_instancingMaterial) { createInstanceMaterial(); } + + auto *pipeline = pipeline::RenderPipeline::getInstance(); + if (pipeline) { + pipeline->setValue("CC_SHADOW_TYPE", 1); + } } void Shadows::createInstanceMaterial() { From 502e48653b6e4c12f61493e18d217265cdeca11b Mon Sep 17 00:00:00 2001 From: Cocos Robot <48829427+cocos-robot@users.noreply.github.com> Date: Tue, 16 Aug 2022 16:14:13 +0800 Subject: [PATCH 05/13] [ci skip][AUTO]: Automated code generating update: b7d5d702ff06f38e3d7425a36ccd4779dcc3d272 (#12368) (#12441) Co-authored-by: cocos-robot --- .../cocos/bindings/auto/jsb_pipeline_auto.cpp | 1358 ++++++++--------- .../cocos/bindings/auto/jsb_pipeline_auto.h | 80 +- 2 files changed, 719 insertions(+), 719 deletions(-) diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp index 7e26bfe96a..36d54e04ac 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp @@ -391,6 +391,685 @@ bool js_register_pipeline_RenderQueueDesc(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_RenderQueueDesc_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderStageInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderStageInfo_class = nullptr; // NOLINT + +static bool js_pipeline_RenderStageInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_name) + +static bool js_pipeline_RenderStageInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_name) + +static bool js_pipeline_RenderStageInfo_get_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_priority) + +static bool js_pipeline_RenderStageInfo_set_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_priority) + +static bool js_pipeline_RenderStageInfo_get_tag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->tag, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->tag, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_tag) + +static bool js_pipeline_RenderStageInfo_set_tag(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->tag, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_tag) + +static bool js_pipeline_RenderStageInfo_get_renderQueues(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->renderQueues, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->renderQueues, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_renderQueues) + +static bool js_pipeline_RenderStageInfo_set_renderQueues(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->renderQueues, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_renderQueues) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderStageInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("priority", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->priority), ctx); + } + json->getProperty("tag", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->tag), ctx); + } + json->getProperty("renderQueues", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->renderQueues), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderStageInfo_finalize) + +static bool js_pipeline_RenderStageInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->priority), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->tag), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->renderQueues), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_RenderStageInfo_constructor, __jsb_cc_pipeline_RenderStageInfo_class, js_cc_pipeline_RenderStageInfo_finalize) + +static bool js_cc_pipeline_RenderStageInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderStageInfo_finalize) + +bool js_register_pipeline_RenderStageInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderStageInfo", obj, nullptr, _SE(js_pipeline_RenderStageInfo_constructor)); + +#if CC_DEBUG + cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); +#endif + cls->defineProperty("name", _SE(js_pipeline_RenderStageInfo_get_name), _SE(js_pipeline_RenderStageInfo_set_name)); + cls->defineProperty("priority", _SE(js_pipeline_RenderStageInfo_get_priority), _SE(js_pipeline_RenderStageInfo_set_priority)); + cls->defineProperty("tag", _SE(js_pipeline_RenderStageInfo_get_tag), _SE(js_pipeline_RenderStageInfo_set_tag)); + cls->defineProperty("renderQueues", _SE(js_pipeline_RenderStageInfo_get_renderQueues), _SE(js_pipeline_RenderStageInfo_set_renderQueues)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderStageInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderStageInfo_proto = cls->getProto(); + __jsb_cc_pipeline_RenderStageInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderStage_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderStage_class = nullptr; // NOLINT + +static bool js_pipeline_RenderStage_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + HolderType arg0 = {}; + HolderType arg1 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + cobj->activate(arg0.value(), arg1.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderStage_activate) + +static bool js_pipeline_RenderStage_getFlow(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cc::pipeline::RenderFlow* result = cobj->getFlow(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderStage_getFlow) + +static bool js_pipeline_RenderStage_getTag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getTag(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderStage_getTag) + +static bool js_pipeline_RenderStage_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + bool result = cobj->initialize(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderStage_initialize) + +bool js_register_pipeline_RenderStage(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderStage", obj, nullptr, nullptr); + +#if CC_DEBUG + cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); +#endif + cls->defineFunction("activate", _SE(js_pipeline_RenderStage_activate)); + cls->defineFunction("getFlow", _SE(js_pipeline_RenderStage_getFlow)); + cls->defineFunction("getTag", _SE(js_pipeline_RenderStage_getTag)); + cls->defineFunction("initialize", _SE(js_pipeline_RenderStage_initialize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderStage_proto = cls->getProto(); + __jsb_cc_pipeline_RenderStage_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderFlowInfo_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderFlowInfo_class = nullptr; // NOLINT + +static bool js_pipeline_RenderFlowInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_name) + +static bool js_pipeline_RenderFlowInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_name) + +static bool js_pipeline_RenderFlowInfo_get_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_priority) + +static bool js_pipeline_RenderFlowInfo_set_priority(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_priority) + +static bool js_pipeline_RenderFlowInfo_get_tag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->tag, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->tag, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_tag) + +static bool js_pipeline_RenderFlowInfo_set_tag(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->tag, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_tag) + +static bool js_pipeline_RenderFlowInfo_get_stages(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + + CC_UNUSED bool ok = true; + se::Value jsret; + ok &= nativevalue_to_se(cobj->stages, jsret, s.thisObject() /*ctx*/); + s.rval() = jsret; + SE_HOLD_RETURN_VALUE(cobj->stages, s.thisObject(), s.rval()); + return true; +} +SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_stages) + +static bool js_pipeline_RenderFlowInfo_set_stages(se::State& s) // NOLINT(readability-identifier-naming) +{ + const auto& args = s.args(); + auto* cobj = SE_THIS_OBJECT(s); + SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + + CC_UNUSED bool ok = true; + ok &= sevalue_to_native(args[0], &cobj->stages, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing new value"); + return true; +} +SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_stages) + + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderFlowInfo * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + json->getProperty("name", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->name), ctx); + } + json->getProperty("priority", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->priority), ctx); + } + json->getProperty("tag", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->tag), ctx); + } + json->getProperty("stages", &field, true); + if(!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->stages), ctx); + } + return ok; +} + +SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderFlowInfo_finalize) + +static bool js_pipeline_RenderFlowInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + if(argc == 0) + { + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + s.thisObject()->setPrivateObject(ptr); + return true; + } + + if(argc == 1 && args[0].isObject()) + { + se::Object *json = args[0].toObject(); + se::Value field; + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + auto cobj = ptr->get(); + ok &= sevalue_to_native(args[0], cobj, s.thisObject()); + if(!ok) { + delete ptr; + SE_REPORT_ERROR("argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; + } + auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); + auto cobj = ptr->get(); + if (argc > 0 && !args[0].isUndefined()) { + ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); + } + if (argc > 1 && !args[1].isUndefined()) { + ok &= sevalue_to_native(args[1], &(cobj->priority), nullptr); + } + if (argc > 2 && !args[2].isUndefined()) { + ok &= sevalue_to_native(args[2], &(cobj->tag), nullptr); + } + if (argc > 3 && !args[3].isUndefined()) { + ok &= sevalue_to_native(args[3], &(cobj->stages), nullptr); + } + + if(!ok) { + delete ptr; + SE_REPORT_ERROR("Argument convertion error"); + return false; + } + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_pipeline_RenderFlowInfo_constructor, __jsb_cc_pipeline_RenderFlowInfo_class, js_cc_pipeline_RenderFlowInfo_finalize) + +static bool js_cc_pipeline_RenderFlowInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) +{ + return true; +} +SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderFlowInfo_finalize) + +bool js_register_pipeline_RenderFlowInfo(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderFlowInfo", obj, nullptr, _SE(js_pipeline_RenderFlowInfo_constructor)); + +#if CC_DEBUG + cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); +#endif + cls->defineProperty("name", _SE(js_pipeline_RenderFlowInfo_get_name), _SE(js_pipeline_RenderFlowInfo_set_name)); + cls->defineProperty("priority", _SE(js_pipeline_RenderFlowInfo_get_priority), _SE(js_pipeline_RenderFlowInfo_set_priority)); + cls->defineProperty("tag", _SE(js_pipeline_RenderFlowInfo_get_tag), _SE(js_pipeline_RenderFlowInfo_set_tag)); + cls->defineProperty("stages", _SE(js_pipeline_RenderFlowInfo_get_stages), _SE(js_pipeline_RenderFlowInfo_set_stages)); + cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderFlowInfo_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderFlowInfo_proto = cls->getProto(); + __jsb_cc_pipeline_RenderFlowInfo_class = cls; + + + se::ScriptEngine::getInstance()->clearException(); + return true; +} +se::Object* __jsb_cc_pipeline_RenderFlow_proto = nullptr; // NOLINT +se::Class* __jsb_cc_pipeline_RenderFlow_class = nullptr; // NOLINT + +static bool js_pipeline_RenderFlow_activate(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + cobj->activate(arg0.value()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderFlow_activate) + +static bool js_pipeline_RenderFlow_getRenderstageByName(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + cc::pipeline::RenderStage* result = cobj->getRenderstageByName(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderFlow_getRenderstageByName) + +static bool js_pipeline_RenderFlow_getTag(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + unsigned int result = cobj->getTag(); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderFlow_getTag) + +static bool js_pipeline_RenderFlow_initialize(se::State& s) // NOLINT(readability-identifier-naming) +{ + auto* cobj = SE_THIS_OBJECT(s); + // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); + if (nullptr == cobj) return true; + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + HolderType arg0 = {}; + ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + bool result = cobj->initialize(arg0.value()); + ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_pipeline_RenderFlow_initialize) + +bool js_register_pipeline_RenderFlow(se::Object* obj) // NOLINT(readability-identifier-naming) +{ + auto* cls = se::Class::create("RenderFlow", obj, nullptr, nullptr); + +#if CC_DEBUG + cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); +#endif + cls->defineFunction("activate", _SE(js_pipeline_RenderFlow_activate)); + cls->defineFunction("getRenderstageByName", _SE(js_pipeline_RenderFlow_getRenderstageByName)); + cls->defineFunction("getTag", _SE(js_pipeline_RenderFlow_getTag)); + cls->defineFunction("initialize", _SE(js_pipeline_RenderFlow_initialize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_RenderFlow_proto = cls->getProto(); + __jsb_cc_pipeline_RenderFlow_class = cls; + + se::ScriptEngine::getInstance()->clearException(); return true; } @@ -1470,346 +2149,6 @@ bool js_register_pipeline_ForwardPipeline(se::Object* obj) // NOLINT(readability __jsb_cc_pipeline_ForwardPipeline_class = cls; - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_pipeline_RenderFlowInfo_proto = nullptr; // NOLINT -se::Class* __jsb_cc_pipeline_RenderFlowInfo_class = nullptr; // NOLINT - -static bool js_pipeline_RenderFlowInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_name) - -static bool js_pipeline_RenderFlowInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_name) - -static bool js_pipeline_RenderFlowInfo_get_priority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_priority) - -static bool js_pipeline_RenderFlowInfo_set_priority(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_priority) - -static bool js_pipeline_RenderFlowInfo_get_tag(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->tag, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->tag, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_tag) - -static bool js_pipeline_RenderFlowInfo_set_tag(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->tag, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_tag) - -static bool js_pipeline_RenderFlowInfo_get_stages(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->stages, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->stages, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderFlowInfo_get_stages) - -static bool js_pipeline_RenderFlowInfo_set_stages(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->stages, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderFlowInfo_set_stages) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderFlowInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("name", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->name), ctx); - } - json->getProperty("priority", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->priority), ctx); - } - json->getProperty("tag", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->tag), ctx); - } - json->getProperty("stages", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->stages), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderFlowInfo_finalize) - -static bool js_pipeline_RenderFlowInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); - s.thisObject()->setPrivateObject(ptr); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); - auto cobj = ptr->get(); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - delete ptr; - SE_REPORT_ERROR("argument convertion error"); - return false; - } - s.thisObject()->setPrivateObject(ptr); - return true; - } - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderFlowInfo); - auto cobj = ptr->get(); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->priority), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->tag), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->stages), nullptr); - } - - if(!ok) { - delete ptr; - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - s.thisObject()->setPrivateObject(ptr); - return true; -} -SE_BIND_CTOR(js_pipeline_RenderFlowInfo_constructor, __jsb_cc_pipeline_RenderFlowInfo_class, js_cc_pipeline_RenderFlowInfo_finalize) - -static bool js_cc_pipeline_RenderFlowInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderFlowInfo_finalize) - -bool js_register_pipeline_RenderFlowInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("RenderFlowInfo", obj, nullptr, _SE(js_pipeline_RenderFlowInfo_constructor)); - -#if CC_DEBUG - cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); -#endif - cls->defineProperty("name", _SE(js_pipeline_RenderFlowInfo_get_name), _SE(js_pipeline_RenderFlowInfo_set_name)); - cls->defineProperty("priority", _SE(js_pipeline_RenderFlowInfo_get_priority), _SE(js_pipeline_RenderFlowInfo_set_priority)); - cls->defineProperty("tag", _SE(js_pipeline_RenderFlowInfo_get_tag), _SE(js_pipeline_RenderFlowInfo_set_tag)); - cls->defineProperty("stages", _SE(js_pipeline_RenderFlowInfo_get_stages), _SE(js_pipeline_RenderFlowInfo_set_stages)); - cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderFlowInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_pipeline_RenderFlowInfo_proto = cls->getProto(); - __jsb_cc_pipeline_RenderFlowInfo_class = cls; - - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_pipeline_RenderFlow_proto = nullptr; // NOLINT -se::Class* __jsb_cc_pipeline_RenderFlow_class = nullptr; // NOLINT - -static bool js_pipeline_RenderFlow_activate(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - cobj->activate(arg0.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderFlow_activate) - -static bool js_pipeline_RenderFlow_getRenderstageByName(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - cc::pipeline::RenderStage* result = cobj->getRenderstageByName(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderFlow_getRenderstageByName) - -static bool js_pipeline_RenderFlow_getTag(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - unsigned int result = cobj->getTag(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderFlow_getTag) - -static bool js_pipeline_RenderFlow_initialize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - bool result = cobj->initialize(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderFlow_initialize) - -bool js_register_pipeline_RenderFlow(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("RenderFlow", obj, nullptr, nullptr); - -#if CC_DEBUG - cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); -#endif - cls->defineFunction("activate", _SE(js_pipeline_RenderFlow_activate)); - cls->defineFunction("getRenderstageByName", _SE(js_pipeline_RenderFlow_getRenderstageByName)); - cls->defineFunction("getTag", _SE(js_pipeline_RenderFlow_getTag)); - cls->defineFunction("initialize", _SE(js_pipeline_RenderFlow_initialize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_pipeline_RenderFlow_proto = cls->getProto(); - __jsb_cc_pipeline_RenderFlow_class = cls; - - se::ScriptEngine::getInstance()->clearException(); return true; } @@ -1865,345 +2204,6 @@ bool js_register_pipeline_ForwardFlow(se::Object* obj) // NOLINT(readability-ide __jsb_cc_pipeline_ForwardFlow_class = cls; - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_pipeline_RenderStageInfo_proto = nullptr; // NOLINT -se::Class* __jsb_cc_pipeline_RenderStageInfo_class = nullptr; // NOLINT - -static bool js_pipeline_RenderStageInfo_get_name(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->name, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->name, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_name) - -static bool js_pipeline_RenderStageInfo_set_name(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->name, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_name) - -static bool js_pipeline_RenderStageInfo_get_priority(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->priority, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->priority, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_priority) - -static bool js_pipeline_RenderStageInfo_set_priority(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->priority, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_priority) - -static bool js_pipeline_RenderStageInfo_get_tag(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->tag, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->tag, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_tag) - -static bool js_pipeline_RenderStageInfo_set_tag(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->tag, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_tag) - -static bool js_pipeline_RenderStageInfo_get_renderQueues(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - - CC_UNUSED bool ok = true; - se::Value jsret; - ok &= nativevalue_to_se(cobj->renderQueues, jsret, s.thisObject() /*ctx*/); - s.rval() = jsret; - SE_HOLD_RETURN_VALUE(cobj->renderQueues, s.thisObject(), s.rval()); - return true; -} -SE_BIND_PROP_GET(js_pipeline_RenderStageInfo_get_renderQueues) - -static bool js_pipeline_RenderStageInfo_set_renderQueues(se::State& s) // NOLINT(readability-identifier-naming) -{ - const auto& args = s.args(); - auto* cobj = SE_THIS_OBJECT(s); - SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - - CC_UNUSED bool ok = true; - ok &= sevalue_to_native(args[0], &cobj->renderQueues, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing new value"); - return true; -} -SE_BIND_PROP_SET(js_pipeline_RenderStageInfo_set_renderQueues) - - -template<> -bool sevalue_to_native(const se::Value &from, cc::pipeline::RenderStageInfo * to, se::Object *ctx) -{ - assert(from.isObject()); - se::Object *json = from.toObject(); - auto* data = reinterpret_cast(json->getPrivateData()); - if (data) { - *to = *data; - return true; - } - se::Value field; - bool ok = true; - json->getProperty("name", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->name), ctx); - } - json->getProperty("priority", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->priority), ctx); - } - json->getProperty("tag", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->tag), ctx); - } - json->getProperty("renderQueues", &field, true); - if(!field.isNullOrUndefined()) { - ok &= sevalue_to_native(field, &(to->renderQueues), ctx); - } - return ok; -} - -SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_RenderStageInfo_finalize) - -static bool js_pipeline_RenderStageInfo_constructor(se::State& s) // NOLINT(readability-identifier-naming) -{ - CC_UNUSED bool ok = true; - const auto& args = s.args(); - size_t argc = args.size(); - - if(argc == 0) - { - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); - s.thisObject()->setPrivateObject(ptr); - return true; - } - - if(argc == 1 && args[0].isObject()) - { - se::Object *json = args[0].toObject(); - se::Value field; - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); - auto cobj = ptr->get(); - ok &= sevalue_to_native(args[0], cobj, s.thisObject()); - if(!ok) { - delete ptr; - SE_REPORT_ERROR("argument convertion error"); - return false; - } - s.thisObject()->setPrivateObject(ptr); - return true; - } - auto *ptr = JSB_MAKE_PRIVATE_OBJECT(cc::pipeline::RenderStageInfo); - auto cobj = ptr->get(); - if (argc > 0 && !args[0].isUndefined()) { - ok &= sevalue_to_native(args[0], &(cobj->name), nullptr); - } - if (argc > 1 && !args[1].isUndefined()) { - ok &= sevalue_to_native(args[1], &(cobj->priority), nullptr); - } - if (argc > 2 && !args[2].isUndefined()) { - ok &= sevalue_to_native(args[2], &(cobj->tag), nullptr); - } - if (argc > 3 && !args[3].isUndefined()) { - ok &= sevalue_to_native(args[3], &(cobj->renderQueues), nullptr); - } - - if(!ok) { - delete ptr; - SE_REPORT_ERROR("Argument convertion error"); - return false; - } - s.thisObject()->setPrivateObject(ptr); - return true; -} -SE_BIND_CTOR(js_pipeline_RenderStageInfo_constructor, __jsb_cc_pipeline_RenderStageInfo_class, js_cc_pipeline_RenderStageInfo_finalize) - -static bool js_cc_pipeline_RenderStageInfo_finalize(se::State& s) // NOLINT(readability-identifier-naming) -{ - return true; -} -SE_BIND_FINALIZE_FUNC(js_cc_pipeline_RenderStageInfo_finalize) - -bool js_register_pipeline_RenderStageInfo(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("RenderStageInfo", obj, nullptr, _SE(js_pipeline_RenderStageInfo_constructor)); - -#if CC_DEBUG - cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); -#endif - cls->defineProperty("name", _SE(js_pipeline_RenderStageInfo_get_name), _SE(js_pipeline_RenderStageInfo_set_name)); - cls->defineProperty("priority", _SE(js_pipeline_RenderStageInfo_get_priority), _SE(js_pipeline_RenderStageInfo_set_priority)); - cls->defineProperty("tag", _SE(js_pipeline_RenderStageInfo_get_tag), _SE(js_pipeline_RenderStageInfo_set_tag)); - cls->defineProperty("renderQueues", _SE(js_pipeline_RenderStageInfo_get_renderQueues), _SE(js_pipeline_RenderStageInfo_set_renderQueues)); - cls->defineFinalizeFunction(_SE(js_cc_pipeline_RenderStageInfo_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_pipeline_RenderStageInfo_proto = cls->getProto(); - __jsb_cc_pipeline_RenderStageInfo_class = cls; - - - se::ScriptEngine::getInstance()->clearException(); - return true; -} -se::Object* __jsb_cc_pipeline_RenderStage_proto = nullptr; // NOLINT -se::Class* __jsb_cc_pipeline_RenderStage_class = nullptr; // NOLINT - -static bool js_pipeline_RenderStage_activate(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - HolderType arg0 = {}; - HolderType arg1 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - ok &= sevalue_to_native(args[1], &arg1, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - cobj->activate(arg0.value(), arg1.value()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderStage_activate) - -static bool js_pipeline_RenderStage_getFlow(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cc::pipeline::RenderFlow* result = cobj->getFlow(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderStage_getFlow) - -static bool js_pipeline_RenderStage_getTag(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - unsigned int result = cobj->getTag(); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderStage_getTag) - -static bool js_pipeline_RenderStage_initialize(se::State& s) // NOLINT(readability-identifier-naming) -{ - auto* cobj = SE_THIS_OBJECT(s); - // SE_PRECONDITION2(cobj, false, "Invalid Native Object"); - if (nullptr == cobj) return true; - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - HolderType arg0 = {}; - ok &= sevalue_to_native(args[0], &arg0, s.thisObject()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - bool result = cobj->initialize(arg0.value()); - ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_pipeline_RenderStage_initialize) - -bool js_register_pipeline_RenderStage(se::Object* obj) // NOLINT(readability-identifier-naming) -{ - auto* cls = se::Class::create("RenderStage", obj, nullptr, nullptr); - -#if CC_DEBUG - cls->defineStaticProperty("isJSBClass", _SE(js_pipeline_getter_return_true), nullptr); -#endif - cls->defineFunction("activate", _SE(js_pipeline_RenderStage_activate)); - cls->defineFunction("getFlow", _SE(js_pipeline_RenderStage_getFlow)); - cls->defineFunction("getTag", _SE(js_pipeline_RenderStage_getTag)); - cls->defineFunction("initialize", _SE(js_pipeline_RenderStage_initialize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cc_pipeline_RenderStage_proto = cls->getProto(); - __jsb_cc_pipeline_RenderStage_class = cls; - - se::ScriptEngine::getInstance()->clearException(); return true; } diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.h b/native/cocos/bindings/auto/jsb_pipeline_auto.h index 05b9c37ad0..f05cb43f3b 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.h +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.h @@ -33,14 +33,14 @@ bool register_all_pipeline(se::Object *obj); // NOLINT JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderObject); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderQueueDesc); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStageInfo); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStage); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlowInfo); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlow); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipelineInfo); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderPipeline); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardPipeline); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlowInfo); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderFlow); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardFlow); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStageInfo); -JSB_REGISTER_OBJECT_TYPE(cc::pipeline::RenderStage); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ForwardStage); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowFlow); JSB_REGISTER_OBJECT_TYPE(cc::pipeline::ShadowStage); @@ -75,6 +75,42 @@ bool js_register_cc_pipeline_RenderQueueDesc(se::Object *obj); // NOLINT template <> bool sevalue_to_native(const se::Value &, cc::pipeline::RenderQueueDesc *, se::Object *ctx); //NOLINT +extern se::Object *__jsb_cc_pipeline_RenderStageInfo_proto; // NOLINT +extern se::Class *__jsb_cc_pipeline_RenderStageInfo_class; // NOLINT + +bool js_register_cc_pipeline_RenderStageInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderStageInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_RenderStage_proto; // NOLINT +extern se::Class *__jsb_cc_pipeline_RenderStage_class; // NOLINT + +bool js_register_cc_pipeline_RenderStage(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_pipeline_RenderStage_activate); +SE_DECLARE_FUNC(js_pipeline_RenderStage_getFlow); +SE_DECLARE_FUNC(js_pipeline_RenderStage_getTag); +SE_DECLARE_FUNC(js_pipeline_RenderStage_initialize); + +extern se::Object *__jsb_cc_pipeline_RenderFlowInfo_proto; // NOLINT +extern se::Class *__jsb_cc_pipeline_RenderFlowInfo_class; // NOLINT + +bool js_register_cc_pipeline_RenderFlowInfo(se::Object *obj); // NOLINT + +template <> +bool sevalue_to_native(const se::Value &, cc::pipeline::RenderFlowInfo *, se::Object *ctx); //NOLINT + +extern se::Object *__jsb_cc_pipeline_RenderFlow_proto; // NOLINT +extern se::Class *__jsb_cc_pipeline_RenderFlow_class; // NOLINT + +bool js_register_cc_pipeline_RenderFlow(se::Object *obj); // NOLINT + +SE_DECLARE_FUNC(js_pipeline_RenderFlow_activate); +SE_DECLARE_FUNC(js_pipeline_RenderFlow_getRenderstageByName); +SE_DECLARE_FUNC(js_pipeline_RenderFlow_getTag); +SE_DECLARE_FUNC(js_pipeline_RenderFlow_initialize); + extern se::Object *__jsb_cc_pipeline_RenderPipelineInfo_proto; // NOLINT extern se::Class *__jsb_cc_pipeline_RenderPipelineInfo_class; // NOLINT @@ -122,24 +158,6 @@ bool js_register_cc_pipeline_ForwardPipeline(se::Object *obj); // NOLINT SE_DECLARE_FUNC(js_pipeline_ForwardPipeline_ForwardPipeline); -extern se::Object *__jsb_cc_pipeline_RenderFlowInfo_proto; // NOLINT -extern se::Class *__jsb_cc_pipeline_RenderFlowInfo_class; // NOLINT - -bool js_register_cc_pipeline_RenderFlowInfo(se::Object *obj); // NOLINT - -template <> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderFlowInfo *, se::Object *ctx); //NOLINT - -extern se::Object *__jsb_cc_pipeline_RenderFlow_proto; // NOLINT -extern se::Class *__jsb_cc_pipeline_RenderFlow_class; // NOLINT - -bool js_register_cc_pipeline_RenderFlow(se::Object *obj); // NOLINT - -SE_DECLARE_FUNC(js_pipeline_RenderFlow_activate); -SE_DECLARE_FUNC(js_pipeline_RenderFlow_getRenderstageByName); -SE_DECLARE_FUNC(js_pipeline_RenderFlow_getTag); -SE_DECLARE_FUNC(js_pipeline_RenderFlow_initialize); - extern se::Object *__jsb_cc_pipeline_ForwardFlow_proto; // NOLINT extern se::Class *__jsb_cc_pipeline_ForwardFlow_class; // NOLINT @@ -148,24 +166,6 @@ bool js_register_cc_pipeline_ForwardFlow(se::Object *obj); // NOLINT SE_DECLARE_FUNC(js_pipeline_ForwardFlow_getInitializeInfo); SE_DECLARE_FUNC(js_pipeline_ForwardFlow_ForwardFlow); -extern se::Object *__jsb_cc_pipeline_RenderStageInfo_proto; // NOLINT -extern se::Class *__jsb_cc_pipeline_RenderStageInfo_class; // NOLINT - -bool js_register_cc_pipeline_RenderStageInfo(se::Object *obj); // NOLINT - -template <> -bool sevalue_to_native(const se::Value &, cc::pipeline::RenderStageInfo *, se::Object *ctx); //NOLINT - -extern se::Object *__jsb_cc_pipeline_RenderStage_proto; // NOLINT -extern se::Class *__jsb_cc_pipeline_RenderStage_class; // NOLINT - -bool js_register_cc_pipeline_RenderStage(se::Object *obj); // NOLINT - -SE_DECLARE_FUNC(js_pipeline_RenderStage_activate); -SE_DECLARE_FUNC(js_pipeline_RenderStage_getFlow); -SE_DECLARE_FUNC(js_pipeline_RenderStage_getTag); -SE_DECLARE_FUNC(js_pipeline_RenderStage_initialize); - extern se::Object *__jsb_cc_pipeline_ForwardStage_proto; // NOLINT extern se::Class *__jsb_cc_pipeline_ForwardStage_class; // NOLINT From d821ae4e5d2e20848ed5fe2710d8cc1b99eb9d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=88=98?= <40414978+PatriceJiang@users.noreply.github.com> Date: Tue, 16 Aug 2022 16:24:24 +0800 Subject: [PATCH 06/13] Bugfix: shared_ptr type conversion & sebind constructor (#12397) --- .../cocos/bindings/manual/jsb_conversions.h | 2 +- native/cocos/bindings/sebind/class.inl | 2 +- native/cocos/bindings/sebind/class_v8.h | 10 ++++++++-- .../common/Classes/demo/Coconut.h | 11 +++++++++++ .../common/Classes/demo/sebind_fruits.cpp | 19 +++++++++++++++++-- native/tests/sebind-tests/data/main.js | 10 ++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/native/cocos/bindings/manual/jsb_conversions.h b/native/cocos/bindings/manual/jsb_conversions.h index 47357671d9..a8b58f674c 100644 --- a/native/cocos/bindings/manual/jsb_conversions.h +++ b/native/cocos/bindings/manual/jsb_conversions.h @@ -1082,7 +1082,7 @@ bool sevalue_to_native(const se::Value &from, std::shared_ptr *out, se::Objec } auto *privateObject = from.toObject()->getPrivateObject(); CC_ASSERT(privateObject->isSharedPtr()); - *out = static_cast>(privateObject).share(); + *out = static_cast*>(privateObject)->share(); return true; } diff --git a/native/cocos/bindings/sebind/class.inl b/native/cocos/bindings/sebind/class.inl index 916b0eff60..ba078e5a87 100644 --- a/native/cocos/bindings/sebind/class.inl +++ b/native/cocos/bindings/sebind/class.inl @@ -273,7 +273,7 @@ class_ &class_::constructor() { template template class_ &class_::constructor(F callback) { - using FTYPE = intl::FunctionWrapper; + using FTYPE = intl::StaticFunctionWrapper; static_assert(std::is_same::value, "Function should return a instance pointer"); using CTYPE = intl::Constructor; auto *constructp = ccnew CTYPE(); diff --git a/native/cocos/bindings/sebind/class_v8.h b/native/cocos/bindings/sebind/class_v8.h index 374745c8d3..ff084fc74a 100644 --- a/native/cocos/bindings/sebind/class_v8.h +++ b/native/cocos/bindings/sebind/class_v8.h @@ -51,7 +51,7 @@ void genericConstructor(const v8::FunctionCallbackInfo &v8args) { using context_type = typename class_::Context; v8::Isolate *isolate = v8args.GetIsolate(); v8::HandleScope handleScope(isolate); - bool ret = false; + std::optional ret; se::ValueArray &args = se::gValueArrayPool.get(v8args.Length()); se::CallbackDepthGuard depthGuard{args, se::gValueArrayPool._depth}; se::internal::jsToSeArgs(v8args, args); @@ -70,7 +70,11 @@ void genericConstructor(const v8::FunctionCallbackInfo &v8args) { if (ret) break; } } - if (!ret) { + + if (!ret.has_value()) { + SE_LOGE("[ERROR] Failed match constructor for class %s, %d args, location: %s:%d\n", self->className.c_str(), + static_cast(args.size()), __FILE__, __LINE__); + } else if (!ret.value()) { SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", "constructor", __FILE__, __LINE__); } assert(ret); // construction failure is not allowed. @@ -189,6 +193,8 @@ bool class_::install(se::Object *nsObject) { _ctx->kls->defineStaticProperty(std::get<0>(prop).c_str(), fieldGetter, fieldSetter, std::get<1>(prop).get()); } _ctx->kls->install(); + JSBClassType::registerClass(_ctx->kls); + return true; } } // namespace sebind diff --git a/native/tests/sebind-tests/common/Classes/demo/Coconut.h b/native/tests/sebind-tests/common/Classes/demo/Coconut.h index 709ef90501..63bb24d7ac 100644 --- a/native/tests/sebind-tests/common/Classes/demo/Coconut.h +++ b/native/tests/sebind-tests/common/Classes/demo/Coconut.h @@ -24,6 +24,17 @@ public: return std::make_shared(other->_radius + _radius); } + std::shared_ptr combine1(Coconut &other) const { + return std::make_shared(other._radius + _radius); + } + std::shared_ptr combine2(std::shared_ptr &other) const { + return std::make_shared(other->_radius + _radius); + } + + std::shared_ptr combine3(const std::shared_ptr &other) const { + return std::make_shared(other->_radius + _radius); + } + std::string callJSFunction(const std::string &name); static std::vector OneTwoThree() { diff --git a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp index 309d52a03f..33d17cf967 100644 --- a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp +++ b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp @@ -47,6 +47,16 @@ bool Coconut_weight(se::State &s) { return true; } + +demo::Coconut *Coconut_create(int, int, int, int) { + return new demo::Coconut(); +} + +class CoconutExt : public demo::Coconut { +public: + using Coconut::Coconut; +}; + } // namespace bool jsb_register_fruits(se::Object *globalThis) { @@ -78,9 +88,13 @@ bool jsb_register_fruits(se::Object *globalThis) { { coconutClass.constructor() .constructor() + .constructor(&Coconut_create) .property("radius", &demo::Coconut::getRadius, nullptr) .property("radius2", nullptr, &demo::Coconut::setRadius) .function("combine", &demo::Coconut::combine) + .function("combine1", &demo::Coconut::combine1) + .function("combine2", &demo::Coconut::combine2) + .function("combine3", &demo::Coconut::combine3) .function("setRadius", &demo::Coconut::setRadius) .function("getRadius", &demo::Coconut::getRadius) .function("doNothing", &demo::Coconut::doNothing) @@ -102,16 +116,17 @@ bool jsb_register_fruits(se::Object *globalThis) { .install(globalThis); } - sebind::class_ coconutExtClass("CoconutExt", fruitClass.prototype()); + sebind::class_ coconutExtClass("CoconutExt", fruitClass.prototype()); { coconutExtClass.constructor() .staticProperty("time", &Coconut_time, nullptr) .staticFunction("getTime", &Coconut_time) + .staticFunction("staticGetWeight", &Coconut_weight) .property("area", &Coconut_area, nullptr) .function("getArea", &Coconut_area) .property("weight", &Coconut_weight, &Coconut_weight) .function("getWeight", &Coconut_weight) - .finalizer([](demo::Coconut *) { + .finalizer([](CoconutExt *) { }) .install(ns); diff --git a/native/tests/sebind-tests/data/main.js b/native/tests/sebind-tests/data/main.js index 8b498a9474..f199d76588 100644 --- a/native/tests/sebind-tests/data/main.js +++ b/native/tests/sebind-tests/data/main.js @@ -22,6 +22,9 @@ function flush() { try { + l("create Coconut static function"); + let e = new demo.Coconut(1,2,3,4); + let f1 = new demo.Fruit("Banana"); block("create fruit", () => { f1 = new demo.Fruit("Banana"); @@ -75,6 +78,13 @@ try { block("call inherited function", () => { assert(typeof c.fullInfo === 'function', "function fullInfo/toString found"); }); + block("test combine", ()=>{ + let d = new demo.Coconut(); + d.combine(c); + d.combine1(c); + d.combine2(c); + d.combine3(c); + }) l("create CoconutExt"); From 19b69a9d909bbf6558e910bd069a7d3d45429dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=85=B5?= <49358166+xubing0906@users.noreply.github.com> Date: Tue, 16 Aug 2022 16:41:13 +0800 Subject: [PATCH 07/13] optimize reflection convolution map (#12430) --- editor/inspector/contributions/node.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index f99d2668be..10d7eccd8d 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -750,6 +750,11 @@ const Elements = { $prop.regenerate = Elements.scene.regenerate.bind(panel); $prop.addEventListener('change-dump', $prop.regenerate); } + + if (!$prop.setReflectionConvolutionMap && $prop.dump.name === 'envmap') { + $prop.setReflectionConvolutionMap = Elements.scene.setReflectionConvolutionMap.bind(panel); + $prop.addEventListener('change-dump', $prop.setReflectionConvolutionMap); + } } }); }, @@ -783,6 +788,17 @@ const Elements = { }); } }, + async setReflectionConvolutionMap() { + const panel = this; + const envMapData = panel.dump._globals.skybox.value['envmap']; + if (envMapData.value && envMapData.value.uuid) { + await Editor.Message.request('scene', 'execute-scene-script', { + name: 'inspector', + method: 'setReflectionConvolutionMap', + args: [envMapData.value.uuid], + }); + } + }, async skyboxReflectionConvolution() { const panel = this; From 39af5ff285875d9dcc23274ff8592e9ae344aa4b Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 17 Aug 2022 11:14:38 +0800 Subject: [PATCH 08/13] add reset function (#12429) --- native/cocos/base/Ptr.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/native/cocos/base/Ptr.h b/native/cocos/base/Ptr.h index b869a90acd..d3742c3c38 100644 --- a/native/cocos/base/Ptr.h +++ b/native/cocos/base/Ptr.h @@ -130,14 +130,7 @@ public: // As reference count is 1 after creating a RefCounted object, so do not have to // invoke p->addRef(); IntrusivePtr &operator=(T *p) { - // AddRef first so that self assignment should work - if (p) { - p->addRef(); - } - if (_ptr) { - _ptr->release(); - } - _ptr = p; + reset(p); return *this; } @@ -177,6 +170,24 @@ public: return _ptr != r; } + void reset() noexcept { + if (_ptr) { + _ptr->release(); + } + _ptr = nullptr; + } + + void reset(T *p) { + // AddRef first so that self assignment should work + if (p) { + p->addRef(); + } + if (_ptr) { + _ptr->release(); + } + _ptr = p; + } + void swap(T **pp) noexcept { T *p = _ptr; _ptr = *pp; From dc3147c761762f21b0fa76e68c3cbefa56924bb2 Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Wed, 17 Aug 2022 11:15:28 +0800 Subject: [PATCH 09/13] fix text changed while set oblique to 0 (#12431) --- .../modules/CanvasRenderingContext2DDelegate.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm index 7cb0f5a9ac..0e79e12d8a 100644 --- a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm +++ b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm @@ -222,10 +222,6 @@ self.fontName = fontName; self.font = [self _createSystemFont]; - float obliqueValue = 0.f; - if (_italic) { - obliqueValue = 0.25f; - } NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail; @@ -238,11 +234,19 @@ alpha:1.0f]; // attribute - self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: + if (_italic) { + self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: foregroundColor, NSForegroundColorAttributeName, _font, NSFontAttributeName, - @(obliqueValue), NSObliquenessAttributeName, + @(0.25f), NSObliquenessAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; + } else { + self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: + foregroundColor, NSForegroundColorAttributeName, + _font, NSFontAttributeName, + paragraphStyle, NSParagraphStyleAttributeName, nil]; + } + } - (void)recreateBufferWithWidth:(NSInteger)width height:(NSInteger)height { From 73885a89095b8d87279c0eb7fd4762a5ba0e8178 Mon Sep 17 00:00:00 2001 From: ChiaNing Date: Wed, 17 Aug 2022 11:33:42 +0800 Subject: [PATCH 10/13] fix api link bug (#12425) --- cocos/2d/assets/sprite-frame.ts | 12 ++++++------ cocos/core/renderer/core/render-scene.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/2d/assets/sprite-frame.ts b/cocos/2d/assets/sprite-frame.ts index 2875dfd046..060bee8c14 100644 --- a/cocos/2d/assets/sprite-frame.ts +++ b/cocos/2d/assets/sprite-frame.ts @@ -106,8 +106,8 @@ interface ISpriteFrameOriginal { */ interface ISpriteFrameInitInfo { /** - * @en The texture of the sprite frame, could be [[TextureBase]] - * @zh 贴图对象资源,可以是 [[TextureBase]] 类型 + * @en The texture of the sprite frame, could be `TextureBase` + * @zh 贴图对象资源,可以是 `TextureBase` 类型 */ texture?: TextureBase; /** @@ -173,7 +173,7 @@ const temp_uvs: IUV[] = [{ u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, * 2. Sliced 9 sprite frame * 3. Mesh sprite frame * It mainly contains:
- * - texture: A [[TextureBase]] that will be used by render process
+ * - texture: A `TextureBase` that will be used by render process
* - rectangle: A rectangle of the texture * - Sliced 9 border insets: The distance of each side from the internal rect to the sprite frame rect * - vertices: Vertex list for the mesh type sprite frame @@ -187,7 +187,7 @@ const temp_uvs: IUV[] = [{ u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, * 2. 九宫格精灵帧 * 3. 网格精灵帧 * 它主要包含下列数据:
- * - 纹理:会被渲染流程使用的 [[TextureBase]] 资源。
+ * - 纹理:会被渲染流程使用的 `TextureBase` 资源。
* - 矩形:在纹理中的矩形区域。 * - 九宫格信息:九宫格的内部矩形四个边距离 SpriteFrame 外部矩形的距离 * - 网格信息:网格类型精灵帧的所有顶点列表 @@ -416,8 +416,8 @@ export class SpriteFrame extends Asset { } /** - * @en The texture of the sprite frame, could be [[TextureBase]] - * @zh 贴图对象资源,可以是 [[TextureBase]] 类型 + * @en The texture of the sprite frame, could be `TextureBase` + * @zh 贴图对象资源,可以是 `TextureBase` 类型 */ get texture () { return this._texture; diff --git a/cocos/core/renderer/core/render-scene.ts b/cocos/core/renderer/core/render-scene.ts index f640c3245c..399c2f9ef8 100644 --- a/cocos/core/renderer/core/render-scene.ts +++ b/cocos/core/renderer/core/render-scene.ts @@ -56,11 +56,11 @@ export interface IRaycastResult { * It manages: * 1. [[Camera]]s * 2. [[Light]]s - * 3. Renderable objects: [[Model]]s and [[DrawBatch2D]]s + * 3. Renderable objects: [[Model]]s and `DrawBatchs` * @zh 渲染场景,由 [[Root]] 创建,并提供用于渲染流程的所有场景基础元素。它管理: * 1. [[Camera]]s:相机 * 2. [[Light]]s:光源 - * 3. 渲染元素:[[Model]]s 和 [[DrawBatch2D]]s + * 3. 渲染元素:[[Model]]s 和 `DrawBatchs` */ export class RenderScene { /** From 58a720a1bf89a562a8ead9441312cb0853b5cb77 Mon Sep 17 00:00:00 2001 From: zhakesi Date: Wed, 17 Aug 2022 11:38:35 +0800 Subject: [PATCH 11/13] fix tiled-tile (#12377) --- cocos/tiledmap/tiled-tile.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cocos/tiledmap/tiled-tile.ts b/cocos/tiledmap/tiled-tile.ts index b15b399b02..2891057e30 100644 --- a/cocos/tiledmap/tiled-tile.ts +++ b/cocos/tiledmap/tiled-tile.ts @@ -39,6 +39,7 @@ import { Component } from '../core/components'; import { TiledLayer } from './tiled-layer'; import { CCInteger, warn } from '../core'; import { UITransform } from '../2d/framework'; +import { NodeEventType } from '../core/scene-graph/node-event'; @ccclass('cc.TiledTile') @help('i18n:cc.TiledTile') @@ -121,12 +122,16 @@ export class TiledTile extends Component { onEnable () { const parent = this.node.parent!; this._layer = parent.getComponent('cc.TiledLayer') as TiledLayer; + this.node.on(NodeEventType.TRANSFORM_CHANGED, this._updatePosition, this); + this.node.on(NodeEventType.SIZE_CHANGED, this._updatePosition, this); this._resetTile(); this.updateInfo(); } onDisable () { this._resetTile(); + this.node.off(NodeEventType.TRANSFORM_CHANGED, this._updatePosition, this); + this.node.off(NodeEventType.SIZE_CHANGED, this._updatePosition, this); } private _resetTile () { @@ -147,5 +152,10 @@ export class TiledTile extends Component { const p = this._layer.getPositionAt(x, y); this.node.setPosition(p!.x, p!.y); this._layer.setTiledTileAt(x, y, this); + this._layer.markForUpdateRenderData(); + } + + private _updatePosition () { + this._layer!.markForUpdateRenderData(); } } From c28ee043efae1de134e8727db5ba4850cb6631f4 Mon Sep 17 00:00:00 2001 From: PP Date: Wed, 17 Aug 2022 16:56:55 +0800 Subject: [PATCH 12/13] fix API docs (#12423) * fix model API docs * fix vfmtPosUvColor API docs * update RenderWindow docs style --- cocos/core/assets/render-texture.ts | 4 ++-- cocos/core/components/renderer.ts | 4 ++-- cocos/core/platform/macro.ts | 4 ++-- cocos/core/renderer/core/render-scene.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/core/assets/render-texture.ts b/cocos/core/assets/render-texture.ts index 4f9a6ec4b9..d85ab66f7b 100644 --- a/cocos/core/assets/render-texture.ts +++ b/cocos/core/assets/render-texture.ts @@ -55,8 +55,8 @@ const _windowInfo: IRenderWindowInfo = { /** * @en Render texture is a render target for [[Camera]] or [[Canvas]] component, - * the render pipeline will use its [[RenderWindow]] as the target of the rendering process. - * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 [[RenderWindow]] 作为渲染的目标窗口。 + * the render pipeline will use its `RenderWindow` as the target of the rendering process. + * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 `RenderWindow` 作为渲染的目标窗口。 */ @ccclass('cc.RenderTexture') export class RenderTexture extends TextureBase { diff --git a/cocos/core/components/renderer.ts b/cocos/core/components/renderer.ts index 0d4f7c57eb..9eadcc15e7 100644 --- a/cocos/core/components/renderer.ts +++ b/cocos/core/components/renderer.ts @@ -40,14 +40,14 @@ const _matInsInfo: IMaterialInstanceInfo = { /** * @en Base class for all components which can submit contents for the rendering process. - * It manages a series of [[Model]]s and the visibility, the materials and the material instances of the models. + * It manages a series of [[renderer.Model]]s and the visibility, the materials and the material instances of the models. * There are several different material properties that must be distinguished clearly and used with caution: * - [[sharedMaterials]] are shared for all component instances that are using the same material asset, modification will be applied universally. * - [[materials]] are instances created independently for the component instance, modification will only be applied for the component instance. * - Render Materials retrieved by [[getRenderMaterial]] are materials used for the actual rendering process, material instances are used if exist. * By default, shared materials are used for rendering. * Material instances are created only when user try to retrieve a material instance with [[material]], [[materials]] and [[getMaterialInstance]]. - * @zh 所有可以提交内容到渲染流程的可渲染类的基类,它管理着一组 [[Model]],以及它们的可见性、材质和材质实例。 + * @zh 所有可以提交内容到渲染流程的可渲染类的基类,它管理着一组 [[renderer.Model]],以及它们的可见性、材质和材质实例。 * 下面是这个组件所管理的各种材质属性的解释,需要正确区分并小心使用: * - [[sharedMaterials]] 是共享材质,所有使用此材质资源的组件实例都默认使用材质的共享实例对象,所有修改都会影响所有使用它的组件实例。 * - [[materials]] 是专为组件对象创建的独立材质实例,所有修改仅会影响当前组件对象。 diff --git a/cocos/core/platform/macro.ts b/cocos/core/platform/macro.ts index cfb92e4550..c67cb306b1 100644 --- a/cocos/core/platform/macro.ts +++ b/cocos/core/platform/macro.ts @@ -1059,13 +1059,13 @@ interface Macro { * @zh Batcher2D 中内存增量的大小(KB) * 这个值决定了当场景中存在的 2d 渲染组件的顶点数量超过当前 batcher2D 中可容纳的顶点数量时,内存扩充的增加量 * 这个值越大,共用同一个 meshBuffer 的 2d 渲染组件数量会更多,但每次扩充所占用的内存也会更大 - * 默认值在标准格式([[vfmtPosUvColor]])下可容纳 4096 个顶点(4096*9*4/1024),你可以增加容量来提升每个批次可容纳的元素数量 + * 默认值在标准格式([[VertexFormat.vfmtPosUvColor]])下可容纳 4096 个顶点(4096*9*4/1024),你可以增加容量来提升每个批次可容纳的元素数量 * @en The MeshBuffer chunk size in Batcher2D (KB) * This value determines the increase in memory expansion, * when the number of vertices of 2d rendering components present in the scene exceeds the number of vertices, * that can be accommodated in the current batcher2D. * The larger this value is, the more 2d rendering components will share the same meshBuffer, but the more memory will be used for each expansion - * The default size can contain 4096 standard vertex ([[vfmtPosUvColor]]) in one buffer, + * The default size can contain 4096 standard vertex ([[VertexFormat.vfmtPosUvColor]]) in one buffer, * you can user larger buffer size to increase the elements count per 2d draw batch. * @default 144 KB */ diff --git a/cocos/core/renderer/core/render-scene.ts b/cocos/core/renderer/core/render-scene.ts index 399c2f9ef8..aa752f0ec1 100644 --- a/cocos/core/renderer/core/render-scene.ts +++ b/cocos/core/renderer/core/render-scene.ts @@ -56,11 +56,11 @@ export interface IRaycastResult { * It manages: * 1. [[Camera]]s * 2. [[Light]]s - * 3. Renderable objects: [[Model]]s and `DrawBatchs` + * 3. Renderable objects: [[renderer.Model]]s and `DrawBatchs` * @zh 渲染场景,由 [[Root]] 创建,并提供用于渲染流程的所有场景基础元素。它管理: * 1. [[Camera]]s:相机 * 2. [[Light]]s:光源 - * 3. 渲染元素:[[Model]]s 和 `DrawBatchs` + * 3. 渲染元素:[[renderer.Model]]s 和 `DrawBatchs` */ export class RenderScene { /** From 9d5ea47fc4e83f49b08df302e98effae81cd140a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=88=98?= <40414978+PatriceJiang@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:31:52 +0800 Subject: [PATCH 13/13] Fix header pragma once (#12450) --- native/CMakeLists.txt | 7 ------- native/cocos/application/BaseGame.h | 1 + native/cocos/audio/android/utils/Utils.h | 1 + native/cocos/audio/include/Export.h | 4 +--- native/cocos/base/job-system/JobSystem.h | 2 ++ native/cocos/bindings/jswrapper/v8/MissingSymbols.h | 2 ++ native/cocos/cocos.h | 2 ++ native/cocos/core/CoreModuleHeader.h | 0 native/cocos/core/event/EventModuleHeader.h | 0 native/cocos/core/event/EventTarget.cpp | 0 native/cocos/core/event/EventTarget.h | 0 native/cocos/core/event/EventTargetFactory.cpp | 0 native/cocos/core/event/EventTargetFactory.h | 0 native/cocos/core/scene-graph/SceneGraphModuleHeader.h | 2 ++ native/cocos/platform/mac/AppDelegate.h | 2 ++ native/cocos/platform/mac/KeyCodeHelper.h | 3 ++- native/cocos/platform/mac/View.h | 2 ++ native/cocos/platform/mac/ViewController.h | 2 ++ native/cocos/renderer/pipeline/custom/test/test.h | 2 ++ .../tests/sebind-tests/common/Classes/demo/sebind_fruits.h | 2 ++ templates/ios/AppDelegate.h | 2 ++ templates/ios/ViewController.h | 2 ++ templates/ios/service/SDKWrapper.h | 2 ++ 23 files changed, 29 insertions(+), 11 deletions(-) delete mode 100644 native/cocos/core/CoreModuleHeader.h delete mode 100644 native/cocos/core/event/EventModuleHeader.h delete mode 100644 native/cocos/core/event/EventTarget.cpp delete mode 100644 native/cocos/core/event/EventTarget.h delete mode 100644 native/cocos/core/event/EventTargetFactory.cpp delete mode 100644 native/cocos/core/event/EventTargetFactory.h diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index dcc7e3f7d2..a6a1b45666 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -1778,7 +1778,6 @@ cocos_source_files( cocos/core/Any.h cocos/core/ArrayBuffer.h - cocos/core/CoreModuleHeader.h cocos/core/DataView.h cocos/core/DataView.cpp # cocos/core/Director.cpp @@ -1945,12 +1944,6 @@ cocos_source_files( cocos/core/event/EventTypesToJS.cpp # cocos/core/event/Event.cpp # cocos/core/event/Event.h - cocos/core/event/EventModuleHeader.h - cocos/core/event/EventTarget.cpp - cocos/core/event/EventTarget.h - cocos/core/event/EventTargetFactory.cpp - cocos/core/event/EventTargetFactory.h - # cocos/core/scene-graph/Find.cpp # cocos/core/scene-graph/Find.h cocos/core/scene-graph/Layers.h diff --git a/native/cocos/application/BaseGame.h b/native/cocos/application/BaseGame.h index bb412446b2..d4e16bd4ef 100644 --- a/native/cocos/application/BaseGame.h +++ b/native/cocos/application/BaseGame.h @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#pragma once #include #include "CocosApplication.h" diff --git a/native/cocos/audio/android/utils/Utils.h b/native/cocos/audio/android/utils/Utils.h index dbed904d18..7995dfe972 100644 --- a/native/cocos/audio/android/utils/Utils.h +++ b/native/cocos/audio/android/utils/Utils.h @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#pragma once #include "base/std/container/string.h" namespace cc { diff --git a/native/cocos/audio/include/Export.h b/native/cocos/audio/include/Export.h index a3819ee2d1..a3b526f09a 100644 --- a/native/cocos/audio/include/Export.h +++ b/native/cocos/audio/include/Export.h @@ -25,8 +25,7 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __EXPORT_COMMON__ -#define __EXPORT_COMMON__ +#pragma once #if defined(SHP) #include @@ -51,4 +50,3 @@ #endif #endif -#endif // end of __EXPORT_COMMON__ diff --git a/native/cocos/base/job-system/JobSystem.h b/native/cocos/base/job-system/JobSystem.h index 3a4def2c0e..8888854a37 100644 --- a/native/cocos/base/job-system/JobSystem.h +++ b/native/cocos/base/job-system/JobSystem.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #if CC_USE_JOB_SYSTEM_TASKFLOW #include "job-system-taskflow/TFJobGraph.h" #include "job-system-taskflow/TFJobSystem.h" diff --git a/native/cocos/bindings/jswrapper/v8/MissingSymbols.h b/native/cocos/bindings/jswrapper/v8/MissingSymbols.h index a68086020c..2da7b4eedf 100644 --- a/native/cocos/bindings/jswrapper/v8/MissingSymbols.h +++ b/native/cocos/bindings/jswrapper/v8/MissingSymbols.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #include #include #include diff --git a/native/cocos/cocos.h b/native/cocos/cocos.h index 29baa35b9a..ec3edc74cc 100644 --- a/native/cocos/cocos.h +++ b/native/cocos/cocos.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + // public headers for user application #include "application/ApplicationManager.h" diff --git a/native/cocos/core/CoreModuleHeader.h b/native/cocos/core/CoreModuleHeader.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/event/EventModuleHeader.h b/native/cocos/core/event/EventModuleHeader.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/event/EventTarget.cpp b/native/cocos/core/event/EventTarget.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/event/EventTarget.h b/native/cocos/core/event/EventTarget.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/event/EventTargetFactory.cpp b/native/cocos/core/event/EventTargetFactory.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/event/EventTargetFactory.h b/native/cocos/core/event/EventTargetFactory.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/native/cocos/core/scene-graph/SceneGraphModuleHeader.h b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h index 1fb9af1d00..9847e03b59 100644 --- a/native/cocos/core/scene-graph/SceneGraphModuleHeader.h +++ b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + //#include "core/scene-graph/ComponentScheduler.h" //#include "core/scene-graph/Find.h" #include "core/scene-graph/Layers.h" diff --git a/native/cocos/platform/mac/AppDelegate.h b/native/cocos/platform/mac/AppDelegate.h index 37a15c3f23..70cc630a1d 100644 --- a/native/cocos/platform/mac/AppDelegate.h +++ b/native/cocos/platform/mac/AppDelegate.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #import @interface AppDelegate : NSObject diff --git a/native/cocos/platform/mac/KeyCodeHelper.h b/native/cocos/platform/mac/KeyCodeHelper.h index 275613fa51..abca2d2970 100644 --- a/native/cocos/platform/mac/KeyCodeHelper.h +++ b/native/cocos/platform/mac/KeyCodeHelper.h @@ -23,9 +23,10 @@ THE SOFTWARE. ****************************************************************************/ -#import "cocos/bindings/event/EventDispatcher.h" #pragma once +#import "cocos/bindings/event/EventDispatcher.h" + extern int translateKeycode(int); extern void updateModifierKeyState(int keyCodeInWeb); extern cc::KeyboardEvent::Action getModifierKeyAction(int keyCodeInWeb); diff --git a/native/cocos/platform/mac/View.h b/native/cocos/platform/mac/View.h index e49a72b8b5..282e355d26 100644 --- a/native/cocos/platform/mac/View.h +++ b/native/cocos/platform/mac/View.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #import #import diff --git a/native/cocos/platform/mac/ViewController.h b/native/cocos/platform/mac/ViewController.h index f716829646..56a33ac433 100644 --- a/native/cocos/platform/mac/ViewController.h +++ b/native/cocos/platform/mac/ViewController.h @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #import #import diff --git a/native/cocos/renderer/pipeline/custom/test/test.h b/native/cocos/renderer/pipeline/custom/test/test.h index b32a9a9166..30ec30673e 100644 --- a/native/cocos/renderer/pipeline/custom/test/test.h +++ b/native/cocos/renderer/pipeline/custom/test/test.h @@ -22,6 +22,8 @@ THE SOFTWARE. ****************************************************************************/ +#pragma once + #include #include #include diff --git a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h index b3bd639322..4d0ec4f543 100644 --- a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h +++ b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h @@ -1,3 +1,5 @@ +#pragma once + #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_conversions.h" #include "bindings/manual/jsb_global.h" diff --git a/templates/ios/AppDelegate.h b/templates/ios/AppDelegate.h index 5e8e48f50c..d91c20ec3f 100644 --- a/templates/ios/AppDelegate.h +++ b/templates/ios/AppDelegate.h @@ -26,6 +26,8 @@ you. THE SOFTWARE. ****************************************************************************/ +#pragma once + #import "platform/ios/AppDelegateBridge.h" #import diff --git a/templates/ios/ViewController.h b/templates/ios/ViewController.h index abf7b9555b..caeb7ee98c 100644 --- a/templates/ios/ViewController.h +++ b/templates/ios/ViewController.h @@ -26,6 +26,8 @@ you. THE SOFTWARE. ****************************************************************************/ +#pragma once + #import @interface ViewController : UIViewController diff --git a/templates/ios/service/SDKWrapper.h b/templates/ios/service/SDKWrapper.h index 9a3ff770d0..e933342c04 100644 --- a/templates/ios/service/SDKWrapper.h +++ b/templates/ios/service/SDKWrapper.h @@ -24,6 +24,8 @@ you. THE SOFTWARE. ****************************************************************************/ +#pragma once + #import #import NS_ASSUME_NONNULL_BEGIN