着色缓存器 您所在的位置:网站首页 compilingshader 着色缓存器

着色缓存器

2024-01-27 05:17| 来源: 网络整理| 查看: 265

着色缓存器

Shader compilation is a lengthy process that involves several steps. One of the first steps is preprocessing the shader source. Unity 2020.1 beta introduces the Caching Shader Preprocessor, a new custom solution to perform this compilation step. It is up to 25% faster than the platform compilers’ preprocessor, closely follows the C standard, and offers new features.

着色器编译是一个漫长的过程,涉及多个步骤。 第一步之一是预处理着色器源。 Unity 2020.1 beta 引入了缓存着色器预处理器,这是一种新的自定义解决方案,可以执行此编译步骤。 它比平台编译器的预处理器快25%,紧密遵循C标准并提供新功能。

Anyone who uses Unity deals with shaders, directly or indirectly. Shaders are programs that run on the GPU. They determine how objects are rendered to the screen. When, for example, a point light is added to a scene, objects that need to react to it will use a different shader variant, which defines how to handle point lights.

使用Unity的任何人都直接或间接处理着色器。 着色器是在GPU上运行的程序。 它们确定如何将对象渲染到屏幕上。 例如,当将点光源添加到场景时,需要对其进行React的对象将使用不同的着色器变体,该变体定义了如何处理点光源。

Whenever a new shader variant is used that has not yet been encountered, the Unity Editor has to compile it. When building the application to run on your target device, the Editor needs to compile all of the required shaders.

每当使用尚未遇到的新着色器变体时,Unity编辑器都必须对其进行编译。 在构建要在目标设备上运行的应用程序时,编辑器需要编译所有必需的着色器。

A checkbox to switch the Caching Shader Preprocessor on or off can be found in Editor settings in the Shader Compilation section.

在“着色器编译”部分的“编辑器”设置中,可以找到用于打开或关闭“缓存着色器预处理器”的复选框。

The rest of this blog post covers technical details that you may find useful if you are writing shaders.

本博客文章的其余部分介绍了技术细节,如果您正在编写着色器,这些技术细节可能会有用。

专为速度而打造 (Built for speed)

The new preprocessor caches intermediate preprocessing data to speed up shader import and compilation time. With this caching, the Editor doesn’t need to parse include files until their contents change, and compiling multiple variants of the same shader is more efficient. Enabling the new preprocessor has the most noticeable effect when shaders within a project use a large set of common include files.

新的预处理器缓存中间预处理数据,以加快着色器的导入和编译时间。 通过这种缓存,编辑器不需要解析包含文件,直到它们的内容更改为止,并​​且编译同一着色器的多个变体更加有效。 当项目中的着色器使用大量公共包含文件时,启用新的预处理器具有最明显的效果。

统一性 (Unification)

Different shader compiler back ends come with their own preprocessors. Running a custom standardized preprocessing layer before the compiler is executed ensures that shader code is compatible with any compiler back end used currently or in the future, which in turn means easier project upgrades between Unity versions.

不同的着色器编译器后端带有自己的预处理器。 在执行编译器之前运行定制的标准化预处理层,以确保着色器代码与当前或将来使用的任何编译器后端兼容,这反过来又意味着在Unity版本之间进行更轻松的项目升级。

The same preprocessor is now used during shader importing, replacing the plain text parsing solution employed previously for checking shader compilation parameters (



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有