GLSL: Passing variable length buffer array to function
Asked Answered
U

0

6

I am interested in passing a variable length array (attached SSBO) to a function, i.e.:

layout(std430) buffer ssbo {
    type buffer[];
};

void func(buffer) {
    buffer[...]
}

func(buffer);

EDIT: The extension spec clearly states that this is unsupported (issue #2 - https://www.opengl.org/registry/specs/ARB/shader_storage_buffer_object.txt). Therefore work-arounds are welcome.

Unbelt answered 27/4, 2016 at 5:53 Comment(3)
Um, why do you need to pass this type around?Punkie
Clearer code. Method reuse. The usual. I want to pass buffers into code from included files, and I want to avoid referencing global declarations. Nothing fancy, nothing I can't live without.Unbelt
Have you looked at texture buffer objects? There's a GL_TEXTURE_BUFFER target for buffers which makes 1D texture maps look like vertex buffers in the C/C++ side, but are accessed using standard texture code in the shaders.Benzaldehyde

© 2022 - 2024 — McMap. All rights reserved.