Ogre Version: 14-3-4
Operating System: Windows 11
Render System: GL3+
Hey!
I have a GLSL fragment shader that uses a Shared Shader Buffer Object to store voxel data that looks like this:
Code: Select all
layout (std430, binding = 0) buffer VoxelData
{
uint voxelData[262144];
};
The voxel data is supplied to the shader as follows:
Code: Select all
constexpr auto bufferSize = 262144;
voxelData.resize(bufferSize);
for (int i = 0; i < bufferSize; i++) {
voxelData[i] = i;
}
const auto sharedParams =
Ogre::GpuProgramManager::getSingleton().getSharedParameters("VoxelData");
sharedParams->setNamedConstant("voxelData", voxelData.data(), bufferSize);
However, I need a dynamically-sized buffer whose length I can choose arbitrarily during runtime. As far as Iʼm aware, GLSL supports that using the following syntax, as long as the variable-length array is the last member of the buffer:
Code: Select all
layout (std430, binding = 0) buffer VoxelData
{
uint voxelData[];
};
However, the SSBO needs to be defined as a shared parameter in the material script, which I currently do like this:
Code: Select all
shared_params VoxelData
{
shared_param_named voxelData uint [262144]
}
I simply cannot figure out how to define a variable-size shared parameter in the material script. I tried using []
, but that didnʼt work. The documentation doesnʼt seem to cover that, either.
I have also considered using Hardware Buffers instead. Curiously though, the Ogre::HardwareBufferManager
class doesnʼt seem to provide a method for creating “plain” SSBO-related buffers, only vertex, uniform, or index buffers. I suspect that what I actually need is an Ogre::GL3PlusHardwareBuffer
, but there does not seem to be a way to obtain one through the hardware buffer manager. The documentation also isnʼt very clear about how to read the data back from the fragment shader once youʼve created the buffer on the CPU side.
At this point, I am honestly not sure if Iʼm on the right track anymore, so any help is greatly appreciated!