-
Notifications
You must be signed in to change notification settings - Fork 2k
Shader precompile #18944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Changdw
wants to merge
2
commits into
cocos:v3.8.8
Choose a base branch
from
Changdw:shader-precompile
base: v3.8.8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Shader precompile #18944
+851
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code Size Check Report
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: