Reputation: 351
I am a newbie of OpenGL. I am trying to update some variables of a constant block. For example, I have a block like(Copied from opengl learnopengl.com):
layout (std140) uniform ExampleBlock
{
// base alignment // aligned offset
float value; // 4 // 0
vec3 vector; // 16 // 16 (offset must be multiple of 16 so 4->16)
mat4 matrix; // 16 // 32 (column 0)
// 16 // 48 (column 1)
// 16 // 64 (column 2)
// 16 // 80 (column 3)
float values[3]; // 16 // 96 (values[0])
// 16 // 112 (values[1])
// 16 // 128 (values[2])
bool boolean; // 4 // 144
int integer; // 4 // 148
};
Can I have two buffers, and use glBindBufferRange to update some of values in it? Some of varibles in the block will not be changed after initialization. So I will create a immutable buffer for it. Then I will create a dynamic buffer to pack all remaining variables(varibles changed every frame).
I am now facing a problem. I am trying to use glBindBufferRange to bind varibles to different slots. However, it only supports an offset of multiple of 256 bytes.
Is my approach impossible?
Upvotes: 3
Views: 168
Reputation: 22168
What you want is not possible. A single interface block may only be served by a single buffer. The offset of the glBindBufferRange
method is an offset into the buffers memory, it describes where the first variable in the interface block will start reading. It is not an offset into the interface block.
The obvious solution to your problem is to split the interface block into to blocks, one for immutable stuff and one for the dynamic stuff.
Upvotes: 2