SSBO doesn't receive any values from a buffer

I’m currently trying to write 4 values to an SSBO in a compute shader using this code:

float[] data = { 1.0f, 2.0f, 3.0f, 4.0f };
ssbo = glGenBuffer();
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);glBufferData(GL_SHADER_STORAGE_BUFFER, data.Length * sizeof(float), data, GL_DYNAMIC_DRAW);

Which is then rendered with this code:

glBindImageTexture(0, texture.Handle, 0, false, 0, GL_READ_WRITE, GL_RGBA32F);
glBindTexture(GL_TEXTURE_2D, texture.Handle);
glDispatchCompute((uint)Width / 8, (uint)Height / 8, 1);

I’m using the compute shader below:

#version 460 core 
layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout (rgba32f) uniform image2D imgOutput;

layout(std430, binding = 0) buffer VertexData
    float vertexData[];

void main() 

    vec4 value = vec4(0.1, 0.1, 0.1, 1.0);
    ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);

    if (vertexData.length() == 0)
    imageStore(imgOutput, texelCoord, vec4(1));
    imageStore(imgOutput, texelCoord, vec4(0, 1, 0, 1));

The screen always shows as white, indicating that there are no values in the vertexData array. There are no error codes thrown during this code, why doesn’t the buffer receive any of the data?

The bit for memory barriers always specifies how you intend to use the data written before the barrier. Not how you wrote that data. It’s not clear from your post how you’re using the data in question.

The four float values don’t serve any real purpose, they’re just being used to see if the shader storage buffer receives any data. I eventually want to use it to store vertex data, for something path-tracing related. I’ve changed GL_SHADER_IMAGE_ACCESS_BARRIER_BIT to GL_ALL_BARRIER_BITS, but without any result.

   glGetProgramResourceIndex(computeProgram, GL_SHADER_STORAGE_BLOCK, "VertexData");

I get 0 returned, so I’m assuming the buffer can be found, just not assigned to.

I’ve fixed the issue. I changed




and added

glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssbo);



It seems like the buffer base needed to be bound before using the shader.