protected void updateShaderBufferBlock(final Shader shader, final ShaderBufferBlock bufferBlock) {

        assert bufferBlock.getName() != null;
        assert shader.getId() > 0;

        final BufferObject bufferObject = bufferBlock.getBufferObject();
        final BufferType bufferType = bufferBlock.getType();
        

        if (bufferObject.isUpdateNeeded()) {
            if (bufferType == BufferType.ShaderStorageBufferObject) {
                updateShaderStorageBufferObjectData(bufferObject);
            } else {
                updateUniformBufferObjectData(bufferObject);
            }
        }

        int usage = resolveUsageHint(bufferObject.getAccessHint(), bufferObject.getNatureHint());
        if (usage == -1) return; // cpu only

        bindProgram(shader);

        final int shaderId = shader.getId();

        int bindingPoint = bufferObject.getBinding();

        switch (bufferType) {
            case UniformBufferObject: {
                setUniformBufferObject(bindingPoint, bufferObject); // rebind buffer if needed
                if (bufferBlock.isUpdateNeeded()) {
                    int blockIndex = bufferBlock.getLocation();
                    if (blockIndex < 0) {
                        blockIndex = gl3.glGetUniformBlockIndex(shaderId, bufferBlock.getName());
                        bufferBlock.setLocation(blockIndex);
                    }
                    if (bufferBlock.getLocation() != NativeObject.INVALID_ID) {
                        gl3.glUniformBlockBinding(shaderId, bufferBlock.getLocation(), bindingPoint);
                    } 
                }
                break;
            }
            case ShaderStorageBufferObject: {
                setShaderStorageBufferObject(bindingPoint, bufferObject); // rebind buffer if needed
                if (bufferBlock.isUpdateNeeded() ) {
                    int blockIndex = bufferBlock.getLocation();
                    if (blockIndex < 0) {
                        blockIndex = gl4.glGetProgramResourceIndex(shaderId, GL4.GL_SHADER_STORAGE_BLOCK, bufferBlock.getName());
                        bufferBlock.setLocation(blockIndex);
                    }
                    if (bufferBlock.getLocation() != NativeObject.INVALID_ID) {
                        gl4.glShaderStorageBlockBinding(shaderId, bufferBlock.getLocation(), bindingPoint);
                    }
                }
                break;
            }
            default: {
                throw new IllegalArgumentException("Doesn't support binding of " + bufferType);
            }
        }

        bufferBlock.clearUpdateNeeded();
    }
Updates the buffer block for the shader.

@param shader the shader.
@param bufferBlock the storage block.
jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java