同时将单个缓冲区绑定到 SSBO 的多个索引目标
Binding a single buffer to multiple indexed targets of the SSBO, simultaneously
我可以同时将一个 opengl 缓冲区绑定到多个索引目标(SSBO 目标)吗?
例如,假设我的着色器有两个具有不同绑定索引的不同统一块。如果我需要的信息位于同一个缓冲区中,我是否可以使用 glBindBufferRange
,同时将同一缓冲区的不同范围绑定到这两个绑定索引?
我看到的另一个用例是,例如,如果我有一个带有两个统一块的着色器,同样具有不同的绑定索引,但是这次,两个统一块唯一的数据成员是一个开放数组(未指定尺寸)。我是否可以使用 glBindBuffer
将同一缓冲区绑定到两个统一块,并通过代码保证仅访问缓冲区中适当范围内的数组索引?
我觉得这样做没问题。
§6.1 (...) While a buffer object is bound, GL operations on the target to which it is bound
affect the bound buffer object, and queries of the target to which a buffer object is
bound return state from the bound object. Operations on the target also affect any
other bindings of that object
强调我的 - 这会直接表明它没问题。
§6.1.1. (...) Each target represents an indexed array of buffer object binding points, as well
as a single general binding point that can be used by other buffer object manipulation
functions, such as BindBuffer
or MapBuffer
. Both commands bind the
buffer object named by buffer to both the general binding point, and to the binding
point in the array given by index. If the binds are successful no change is made
to the state of the bound buffer object, and any previous bindings to the general
binding point or to the binding point in the array are broken
我从中提炼出的是,并没有明确禁止将缓冲区范围绑定到多个位置,因此,我认为这是允许的。它不会破坏该数组中的其他绑定,这意味着先前绑定的范围应保持不变且有效。
话虽这么说,如果范围重叠并且您正在写入它们,则可能需要障碍。
我可以同时将一个 opengl 缓冲区绑定到多个索引目标(SSBO 目标)吗?
例如,假设我的着色器有两个具有不同绑定索引的不同统一块。如果我需要的信息位于同一个缓冲区中,我是否可以使用 glBindBufferRange
,同时将同一缓冲区的不同范围绑定到这两个绑定索引?
我看到的另一个用例是,例如,如果我有一个带有两个统一块的着色器,同样具有不同的绑定索引,但是这次,两个统一块唯一的数据成员是一个开放数组(未指定尺寸)。我是否可以使用 glBindBuffer
将同一缓冲区绑定到两个统一块,并通过代码保证仅访问缓冲区中适当范围内的数组索引?
我觉得这样做没问题。
§6.1 (...) While a buffer object is bound, GL operations on the target to which it is bound affect the bound buffer object, and queries of the target to which a buffer object is bound return state from the bound object. Operations on the target also affect any other bindings of that object
强调我的 - 这会直接表明它没问题。
§6.1.1. (...) Each target represents an indexed array of buffer object binding points, as well as a single general binding point that can be used by other buffer object manipulation functions, such as
BindBuffer
orMapBuffer
. Both commands bind the buffer object named by buffer to both the general binding point, and to the binding point in the array given by index. If the binds are successful no change is made to the state of the bound buffer object, and any previous bindings to the general binding point or to the binding point in the array are broken
我从中提炼出的是,并没有明确禁止将缓冲区范围绑定到多个位置,因此,我认为这是允许的。它不会破坏该数组中的其他绑定,这意味着先前绑定的范围应保持不变且有效。
话虽这么说,如果范围重叠并且您正在写入它们,则可能需要障碍。