You definitely can. The straight way to do it is to bind the buffer as you have done, set the data prior to render call (if you wish to modify it) and then read it on your shader.
Depending on your use you also need to sotre the size of the arrya either in the SSBO directly or on a uniform.
So the the full solution would be:
C++
//Create SSBO
glGenBuffers(1, &m_ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(m_blocksToRender), m_blocksToRender.data(), GL_STATIC_DRAW);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
void render()
{
/* additional code */
//Only needed if another buffer has been bound to the binding point 0
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_ssbo);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_ssbo);
//Only needed if the buffer data needs to be changed
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(m_blocksToRender)
//If you use the uniform option
glUniform1i(glGetUniformLocation(programID, "size"), m_blocksToRender.size());
}
Fragment
If you use the uniform method:
uniform int size;
layout(std430, binding = 0) buffer blocksData
{
uvec4 data[];
};
If you use the metadata version:
layout(std430, binding = 0) buffer blocksData
{
uint size;
uvec4 data[];
};
If you choose the second option you need to be carfeul about alignment problems, and you also need to implement a way to append the data size to the beggining of the buffer you send to the SSBO.
Edit:
To disable the driver warning (which btw is NVIDIA specific, AMD cards seem to not throw this error)
Add the following line somwhere in your code before binding your buffer:
GLuint copy_warning = 0x20072;
glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_PERFORMANCE,
GL_DONT_CARE, 1, ©_warning, GL_FALSE);