gpt4 book ai didi

opengl - Gsl 矩阵寄存器?

转载 作者:行者123 更新时间:2023-12-01 23:53:39 36 4
gpt4 key购买 nike

我记得读过 mat4x3 比 mat3x4 使用了更多的寄存器,因为它有四列,即使它们具有相同数量的元素。我似乎无法在任何地方找到它了。新规范是否对两种类型的矩阵使用相同数量的统一寄存器?

转置是否也会影响性能?

mat3x4 a; // transposed mat4x3

result = transpose(a) * vec4(val, 1); // keeps order
result = vec4(val, 1) * a; // better performance?

假设(我认为)他们做同样的事情。

最佳答案

在最新的 (4.4) 规范文档中,统一限制以组件表示。谈论 MAX_FRAGMENT_UNIFORM_COMPONENTS 以及可以使用 glGetIntegerv() 查询的其他着色器阶段的等效限制:

These values represent the numbers of individual floating-point, integer, or boolean values that can be held in uniform variable storage for a shader.

然后,关于矩阵:

A matrix uniform will consume no more than 4 × min(r,c) components, where r and c are the number of rows and columns in the matrix.

所以对于 mat3x4mat4x3,最小维度都是 3,所以消耗的组件数都是 12。

旧样式的容量查询仍然存在,但定义看起来主要是为了向后兼容而维护的:

The implementation-dependent constants MAX_VERTEX_UNIFORM_VECTORS and MAX_FRAGMENT_UNIFORM_VECTORS have values respectively equal to the values of MAX_VERTEX_UNIFORM_COMPONENTS and MAX_FRAGMENT_UNIFORM_COMPONENTS divided by four.

请注意,与制服不同,属性仍然是面向矢量的。根据表 11.2,mat3x4 消耗 3 个属性槽,而 mat4x3 消耗 4 个属性槽。

关于opengl - Gsl 矩阵寄存器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25226802/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com