Version: 2022.2
言語: 日本語
Experimental: this API is experimental and might be changed or removed in the future.

ShaderWarmup.WarmupShader

マニュアルに切り替える
public static void WarmupShader (Shader shader, Experimental.Rendering.ShaderWarmupSetup setup);

説明

Prewarms all shader variants for a given Shader, using a given rendering configuration.

For information on shader loading and prewarming, including a list of different prewarming techniques, see Shader loading.

Unity needs more information to correctly build GPU representations of the shader variants ('pipeline state objects' or PSOs) if your application runs on one of the following graphics APIs: DirectX 12 Metal Vulkan If Unity has this information, it's more likely the prewarmed variants match what the GPU needs when it renders your Scene.

To provide Unity with more information, you can do the following: Use the setup parameter to specify the vertex data layout you use with the shader. Before you call WarmupShader, set the render state so it's as close as possible to the state you use with the shader. For example, set the format of the render target, or use render state commands to set states such as blend mode. Unity also asynchronously prewarms shader variants using multiple background threads, if your application runs on a platform that supports it. Unity uses as many threads as it can. In your built application, you can use the -max-async-pso-job-count command line argument to set the number of threads Unity uses.

See Also: ShaderWarmup.WarmupShaderFromCollection, Shader.WarmupAllShaders, ShaderVariantCollection.WarmUp

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961