Skip to content

Conversation

Changdw
Copy link
Contributor

@Changdw Changdw commented Aug 26, 2025

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

Copy link

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1009429 bytes 1043287 bytes ⚠️ +33858 bytes
2D All (legacy pipeline) 2674774 bytes 2709151 bytes ⚠️ +34377 bytes
2D All (new pipeline) 2765676 bytes 2771532 bytes ⚠️ +5856 bytes
(2D + 3D) All 10022031 bytes 10027577 bytes ⚠️ +5546 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16841090 bytes 16846626 bytes ⚠️ +5536 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -24069,8 +24069,13 @@
          */
         protected _activate(): void;
         protected _updatePipeline(): void;
     }
+    /**
+     * @en Global shader precompilation instance
+     * @zh 全局着色器预编译实例
+     */
+    export const shaderPrecompile: __private._cocos_rendering_shader_precompile_shader_precompile__ShaderPrecompile;
     export const getPhaseID: (phaseName: string | number) => number;
     export class PipelineInputAssemblerData {
         quadIB: gfx.Buffer | null;
         quadVB: gfx.Buffer | null;
@@ -65250,16 +65255,20 @@
         export interface _cocos_render_scene_core_program_lib__IDefineRecord extends EffectAsset.IDefineInfo {
             _map: (value: any) => number;
             _offset: number;
         }
+        export interface _cocos_render_scene_core_program_lib__IShaderCollector {
+            collect(name: string, defines: renderer.MacroRecord, key: string): void;
+        }
         /**
          * @en The global maintainer of all shader resources.
          * @zh 维护 shader 资源实例的全局管理器。
          */
         export class _cocos_render_scene_core_program_lib__ProgramLib {
             protected _templates: Record<string, renderer.IProgramInfo>;
             protected _cache: Record<string, gfx.Shader>;
             protected _templateInfos: Record<number, renderer.ITemplateInfo>;
+            setShaderCollector(shaderCollector: _cocos_render_scene_core_program_lib__IShaderCollector): void;
             register(effect: EffectAsset): void;
             /**
              * @en Register the shader template with the given info
              * @zh 注册 shader 模板。
@@ -65312,8 +65321,10 @@
              * @param pipeline The [[RenderPipeline]] which owns the render command
              * @param key The shader cache key, if already known
              */
             getGFXShader(device: gfx.Device, name: string, defines: renderer.MacroRecord, pipeline: _cocos_rendering_custom_pipeline__PipelineRuntime, key?: string): gfx.Shader;
+            compile(device: gfx.Device, name: string, defines: renderer.MacroRecord, pipeline: _cocos_rendering_custom_pipeline__PipelineRuntime, key?: string): gfx.Shader;
+            getShadersCount(): number;
         }
         export type __types_globals__RecursivePartial<T> = {
             [P in keyof T]?: T[P] extends Array<infer U> ? Array<__types_globals__RecursivePartial<U>> : T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<__types_globals__RecursivePartial<V>> : __types_globals__RecursivePartial<T[P]>;
         };
@@ -66603,8 +66614,65 @@
             TRT = 15,
             TT = 16,
             MAX_BIT_COUNT = 17
         }
+        /**
+         * @en Export options for shader collection data
+         * @zh 着色器收集数据的导出选项
+         */
+        export interface _cocos_rendering_shader_precompile_def__ShaderCollectExportOptions {
+            /**
+             * @en Whether to compress the exported data
+             * @zh 是否压缩导出数据
+             */
+            compress?: boolean;
+            /**
+             * @en Whether to include timestamp information in exported data
+             * @zh 导出数据中是否包含时间戳信息
+             */
+            containTime?: boolean;
+            /**
+             * @en Whether to include shader keys in exported data
+             * @zh 导出数据中是否包含着色器键值
+             */
+            containKey?: boolean;
+        }
+        /**
+         * @en Shader precompilation manager. Provides functionality for collecting shader compilation info during runtime and precompiling shaders for optimization.
+         * @zh 着色器预编译管理器。提供运行时收集着色器编译信息和预编译着色器优化功能。
+         */
+        export class _cocos_rendering_shader_precompile_shader_precompile__ShaderPrecompile {
+            /**
+             * @en Start collecting shader compilation information
+             * @zh 开始收集着色器编译信息
+             */
+            startCollect(): void;
+            /**
+             * @en Export collected shader data
+             * @zh 导出收集的着色器数据
+             */
+            export(options?: _cocos_rendering_shader_precompile_def__ShaderCollectExportOptions): string | Uint8Array;
+            /**
+             * @en Import shader data for precompilation
+             * @zh 导入用于预编译的着色器数据
+             */
+            import(content: string | Uint8Array, compress?: boolean): void;
+            /**
+             * @en Compile all imported shaders
+             * @zh 编译所有导入的着色器
+             */
+            compileAll(): void;
+            /**
+             * @en Import and compile shaders in one step
+             * @zh 一步完成导入和编译着色器
+             */
+            precompile(content: string | Uint8Array, compress?: boolean): void;
+            /**
+             * @en Get the count of compiled shaders
+             * @zh 获取已编译着色器的数量
+             */
+            getShadersCount(): number;
+        }
         export enum _cocos_scene_graph_node_event_processor__DispatcherEventType {
             ADD_POINTER_EVENT_PROCESSOR = 0,
             REMOVE_POINTER_EVENT_PROCESSOR = 1,
             MARK_LIST_DIRTY = 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant