当管线中存在片元着色阶段,片元着色器输出与当前subpass的输出附件之间 形成了一个接口。 片元着色器输出变量通过Location
和Component
修饰,与颜色附件匹配, 颜色附件由VkSubpassDescription
类型的数组指定, 该数据类型描述了片元着色器执行所在的subpass。
通过Output
存储类型修饰,被OpEntryPoint
列举的 片元着色器输出变量 形成了 片元输出接口。 这些变量必须被不同的Location
所修饰。 它们也可以被Component
和Index
联合唯一修饰。 为了接口匹配:没有Component
修饰的变量被认为其隐式的 Component
为0, 没有Index
修饰的变量被认为其有一个隐式的 Index
,值为0.
一个片元着色器输出变量有唯一的 Location
i 修饰, 颜色附件由pColorAttachments
[i] 表示,若其被启用了,如混合中所描述的 在传递万blending单元之后,将被定向到颜色附件, Locations 的情况如 Location Assignment所述。
可用的片元输出locations数量由VkPhysicalDeviceLimits
数据结构的maxFragmentOutputAttachments
所指定。
Components of the output variables are assigned as described in Component Assignment. Output components identified as 0, 1, 2, and 3 will be directed to the R, G, B, and A inputs to the blending unit, respectively, or to the output attachment if blending is disabled. If two variables are placed within the same location, they must have the same underlying type (floating-point or integer). The input to blending or color attachment writes is undefined for components which do not correspond to a fragment shader output.
Index
为0的片元输出被导向关联的对应Location
的第一个blending单元输入。 Index
为1的输出被导向对应的blending单元输入。
No component aliasing of output variables is allowed, that is there must not be two output variables which have the same location, component, and index, either explicitly declared or implied.
Output values written by a fragment shader must be declared with either OpTypeFloat
or OpTypeInt
, and a Width of 32. Composites of these types are also permitted. If the color attachment has a signed or unsigned normalized fixed-point format, color values are assumed to be floating-point and are converted to fixed-point as described in Conversion from Normalized Fixed-Point to Floating-Point; otherwise no type conversion is applied. If the type of the values written by the fragment shader do not match the format of the corresponding color attachment, the result is undefined for those components.