add more jsb interface info && fix some types (#14628)

* add jsb interface info

* mark TODO

workaround

* fix type

* remove some new ts-expect-error

* fix type in strict mode
This commit is contained in:
PP
2023-03-22 15:22:09 +08:00
committed by GitHub
parent dcc0b8d52e
commit 3cb698c8aa
36 changed files with 428 additions and 144 deletions
+5 -1
View File
@@ -22,7 +22,11 @@
THE SOFTWARE.
*/
import { cclegacy } from '../core';
import type { GeometryRenderer as JsbGeometryRenderer } from './geometry-renderer';
export const GeometryRenderer = jsb.GeometryRenderer;
declare const jsb: any;
export const GeometryRenderer: typeof JsbGeometryRenderer = jsb.GeometryRenderer;
export type GeometryRenderer = JsbGeometryRenderer;
cclegacy.GeometryRenderer = jsb.GeometryRenderer;
+90 -38
View File
@@ -25,34 +25,71 @@
declare const nr: any;
declare const jsb: any;
import { getPhaseID } from './pass-phase';
import { ccenum, CCString, js } from '../core';
import * as pipeline from './define';
import { ccclass, serializable, editable, type } from '../core/data/class-decorator';
import { legacyCC } from '../core/global-exports';
import * as decors from '../native-binding/decorators';
import { RenderTexture } from '../asset/assets/render-texture';
import type {
RenderPipeline as NrRenderPipeline,
RenderFlow as NrRenderFlow,
RenderStage as NrRenderStage,
InstancedBuffer as NrInstancedBuffer,
PipelineStateManager as NrPipelineStateManager,
ForwardPipeline as NrForwardPipeline,
ForwardFlow as NrForwardFlow,
ShadowFlow as NrShadowFlow,
ForwardStage as NrForwardStage,
ShadowStage as NrShadowStage,
DeferredPipeline as NrDeferredPipeline,
MainFlow as NrMainFlow,
LightingStage as NrLightingStage,
PostProcessStage as NrPostProcessStage,
GbufferStage as NrGbufferStage,
BloomStage as NrBloomStage,
ReflectionProbeFlow as NrReflectionProbeFlow,
ReflectionProbeStage as NrReflectionProbeStage,
} from './index';
export { pipeline };
nr.getPhaseID = getPhaseID;
export const RenderPipeline = nr.RenderPipeline;
export const RenderFlow = nr.RenderFlow;
export const RenderStage = nr.RenderStage;
export const InstancedBuffer = nr.InstancedBuffer;
export const PipelineStateManager = nr.PipelineStateManager;
export const ForwardPipeline = nr.ForwardPipeline;
export const ForwardFlow = nr.ForwardFlow;
export const ShadowFlow = nr.ShadowFlow;
export const ForwardStage = nr.ForwardStage;
export const ShadowStage = nr.ShadowStage;
export const DeferredPipeline = nr.DeferredPipeline;
export const MainFlow = nr.MainFlow;
export const LightingStage = nr.LightingStage;
export const PostProcessStage = nr.PostProcessStage;
export const GbufferStage = nr.GbufferStage;
export const BloomStage = nr.BloomStage;
export const ReflectionProbeFlow = nr.ReflectionProbeFlow;
export const ReflectionProbeStage = nr.ReflectionProbeStage;
export * from './pass-phase';
export const RenderPipeline: typeof NrRenderPipeline = nr.RenderPipeline;
export type RenderPipeline = NrRenderPipeline;
export const RenderFlow: typeof NrRenderFlow = nr.RenderFlow;
export type RenderFlow = NrRenderFlow;
export const RenderStage: typeof NrRenderStage = nr.RenderStage;
export type RenderStage = NrRenderStage;
export const InstancedBuffer: typeof NrInstancedBuffer = nr.InstancedBuffer;
export type InstancedBuffer = NrInstancedBuffer;
export const PipelineStateManager: typeof NrPipelineStateManager = nr.PipelineStateManager;
export type PipelineStateManager = NrPipelineStateManager;
export const ForwardPipeline: typeof NrForwardPipeline = nr.ForwardPipeline;
export type ForwardPipeline = NrForwardPipeline;
export const ForwardFlow: typeof NrForwardFlow = nr.ForwardFlow;
export type ForwardFlow = NrForwardFlow;
export const ShadowFlow: typeof NrShadowFlow = nr.ShadowFlow;
export type ShadowFlow = NrShadowFlow;
export const ForwardStage: typeof NrForwardStage = nr.ForwardStage;
export type ForwardStage = NrForwardStage;
export const ShadowStage: typeof NrShadowStage = nr.ShadowStage;
export type ShadowStage = NrShadowStage;
export const DeferredPipeline: typeof NrDeferredPipeline = nr.DeferredPipeline;
export type DeferredPipeline = NrDeferredPipeline;
export const MainFlow: typeof NrMainFlow = nr.MainFlow;
export type MainFlow = NrMainFlow;
export const LightingStage: typeof NrLightingStage = nr.LightingStage;
export type LightingStage = NrLightingStage;
export const PostProcessStage: typeof NrPostProcessStage = nr.PostProcessStage;
export type PostProcessStage = NrPostProcessStage;
export const GbufferStage: typeof NrGbufferStage = nr.GbufferStage;
export type GbufferStage = NrGbufferStage;
export const BloomStage: typeof NrBloomStage = nr.BloomStage;
export type BloomStage = NrBloomStage;
export const ReflectionProbeFlow: typeof NrReflectionProbeFlow = nr.ReflectionProbeFlow;
export type ReflectionProbeFlow = NrReflectionProbeFlow;
export const ReflectionProbeStage: typeof NrReflectionProbeStage = nr.ReflectionProbeStage;
export type ReflectionProbeStage = NrReflectionProbeStage;
export { PipelineEventType } from './pipeline-event';
interface IRenderFlowInfo {
@@ -79,7 +116,8 @@ nr.PipelineStateManager.getOrCreatePipelineState = function (device, pass, shade
};
// ForwardPipeline
const forwardPipelineProto = ForwardPipeline.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const forwardPipelineProto: any = ForwardPipeline.prototype;
forwardPipelineProto._ctor = function () {
this._tag = 0;
this._flows = [];
@@ -104,7 +142,8 @@ forwardPipelineProto.onLoaded = function () {
this.initialize(info);
}
const forwardFlowProto = ForwardFlow.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const forwardFlowProto: any = ForwardFlow.prototype;
forwardFlowProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -119,7 +158,8 @@ forwardFlowProto.init = function (pipeline) {
this.initialize(info);
}
const shadowFlowProto = ShadowFlow.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const shadowFlowProto: any = ShadowFlow.prototype;
shadowFlowProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -134,7 +174,9 @@ shadowFlowProto.init = function (pipeline) {
this.initialize(info);
}
const reflectionProbeFlowProto = ReflectionProbeFlow.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const reflectionProbeFlowProto: any = ReflectionProbeFlow.prototype;
reflectionProbeFlowProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -149,7 +191,9 @@ reflectionProbeFlowProto.init = function (pipeline) {
this.initialize(info);
}
const forwardStageProto = ForwardStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const forwardStageProto: any = ForwardStage.prototype;
forwardStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -166,14 +210,17 @@ forwardStageProto.init = function (pipeline) {
this.initialize(info);
}
const shadowStageProto = ShadowStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const shadowStageProto: any = ShadowStage.prototype;
shadowStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
this._tag = 0;
}
const reflectionProbeStage = ReflectionProbeStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const reflectionProbeStage: any = ReflectionProbeStage.prototype;
reflectionProbeStage._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -235,7 +282,8 @@ export class RenderQueueDesc {
}
}
const deferredPipelineProto = DeferredPipeline.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const deferredPipelineProto: any = DeferredPipeline.prototype;
deferredPipelineProto._ctor = function () {
this._tag = 0;
this._flows = [];
@@ -255,7 +303,9 @@ deferredPipelineProto.onLoaded = function () {
this.initialize(info);
}
const mainFlowProto = MainFlow.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const mainFlowProto: any = MainFlow.prototype;
mainFlowProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -270,7 +320,8 @@ mainFlowProto.init = function (pipeline) {
this.initialize(info);
}
const gbufferStageProto = GbufferStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const gbufferStageProto: any = GbufferStage.prototype;
gbufferStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -287,8 +338,8 @@ gbufferStageProto.init = function (pipeline) {
this.initialize(info);
}
const lightingStageProto = LightingStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const lightingStageProto: any = LightingStage.prototype;
lightingStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -307,7 +358,8 @@ lightingStageProto.init = function (pipeline) {
this.initialize(info);
}
const bloomStageProto = BloomStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const bloomStageProto: any = BloomStage.prototype;
bloomStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -326,7 +378,9 @@ bloomStageProto.init = function (pipeline) {
this.initialize(info);
}
const postProcessStageProto = PostProcessStage.prototype;
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
const postProcessStageProto: any = PostProcessStage.prototype;
postProcessStageProto._ctor = function () {
this._name = 0;
this._priority = 0;
@@ -350,8 +404,6 @@ legacyCC.RenderFlow = RenderFlow;
legacyCC.RenderStage = RenderStage;
legacyCC.RenderPipeline = RenderPipeline;
const RenderTexture: any = jsb.RenderTexture;
@ccclass('RenderTextureConfig')
class RenderTextureConfig {
@serializable
-27
View File
@@ -1,27 +0,0 @@
/*
Copyright (c) 2020-2023 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
declare const nr: any;
export const getPhaseID = nr.getPhaseID;
+13 -1
View File
@@ -23,6 +23,18 @@
*/
import { cclegacy } from '../core';
export const RenderPipeline = nr.RenderPipeline;
import { RenderPipeline as NrRenderPipeline } from './render-pipeline';
import { Buffer, InputAssembler } from '../gfx';
declare const nr: any;
export const RenderPipeline: typeof NrRenderPipeline = nr.RenderPipeline;
export type RenderPipeline = NrRenderPipeline;
// Do not delete, for the class detection of editor
cclegacy.RenderPipeline = RenderPipeline;
export class PipelineInputAssemblerData {
quadIB: Buffer|null = null;
quadVB: Buffer|null = null;
quadIA: InputAssembler|null = null;
}
+15 -1
View File
@@ -25,6 +25,20 @@
declare var nr:any;
import { legacyCC } from '../core/global-exports';
export const RenderStage = nr.RenderStage;
import type { RenderStage as NrRenderStage } from './render-stage';
import type { RenderQueueDesc } from './pipeline-serialization';
export const RenderStage: typeof NrRenderStage = nr.RenderStage;
export type RenderStage = NrRenderStage;
// Do not delete, for the class detection of editor
legacyCC.RenderStage = RenderStage;
/**
* @en The render stage information descriptor
* @zh 渲染阶段描述信息。
*/
export interface IRenderStageInfo {
name: string;
priority: number;
tag?: number;
renderQueues?: RenderQueueDesc[];
}