Compute shaders. Buffers number limit

Hello,

I’m writing compute shaders on google version 2.79. When Google update to 81 version, my shaders show error (with empty description) on linking program with shaders. In Google update log I did not find the information.

After testing i saw that error is shown when i try write in buffer with index 11 and more.

Has anyone encountered this error? Why does she appear? How to avoid it?

You haven’t really given the reader much to go on here.

Presumably you’re getting an error trying to link an OpenGL ES compute shader. However… Google version 2.79 (and 81) … of what exactly? On what OS/GPU/driver/driver version? What exactly is the error message that you do get with empty description? Buffer index 11 for what – UBOs or SSBOs? What is the shader source code you’re providing when you get this link error?

What values do GL_MAX_COMPUTE_UNIFORM_BLOCKS and GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS have on your patform? Are you exceeding these limits with your buffer binding? FWIW, the OpenGL ES 3.2 spec (if you were using a GLES 3.2 profile) only requires 12 and 4 for these, respectively. If you’re getting this error for UBO bindings, index 11 is suspiciously close to the former,

Thank you for the answer!

Working fine in Google version 79.0.3945.79
Error in versin 81.0.4044.138

OS: Windows 10 64 bit
GPU: NVIDIA GeForce GTX 760
Driver version: 24.21.13.9811 (date 01.06.2018)

I can not send the full code. If necessary, I can write a similar program and send it
When I created buffers, i take type “SHADER_STORAGE_BUFFER”. When i bind it to arg of shader program i switch it to texture:

   glBindTexture(GL_TEXTURE_BUFFER, type, buffer);
   glBindTexture(GL_TEXTURE_BUFFER, 0);
   glBindImageTexture(index, tex, 0, GL_FALSE, 0, GL_READ_WRITE, gl_type);
   glUniform1i(glGetUniformLocation(prog, name), index);

In shader code source (version 310 es) I get it like:

 layout (std430, binding = 12) buffer BBuffer
 {
     Vector3 BData[]
 }

and write ( if not write, error is not occur):

 BData[index] = vec3_to_Vectore3(value)

GL_MAX_COMPUTE_UNIFORM_BLOCKS - 14
GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS - 16

Error:

Can you express any thoughts on this? do you need more information?

There’s so much confusion in your previous posts it’s hard to even know where to start.

First, Google is a company, not a software platform or library. So “Google version” makes no sense.

Websearching these version numbers reveals that you are talking about Chrome, a Google web browser.

So presumably you’re trying to run a compute shader in WebGL inside of Google Chrome.

Given all the confusion below, I’d suggest you put aside your current project, go grab an existing WebGL compute shader demo that says it runs in Google Chrome, and go study it carefully. Do some reading until you understand it. Then modify it to do what you want.

Ok, so this Google Chrome browser you’re trying to run a compute shader in (in WebGL) is running on Windows 10 and on top of NVIDIA graphics drivers, version 398.11 (circa 6/5/2018).

Why are you running such old graphics drivers rather than the latest version?

That’s not how it works. Buffer objects themselves have no type. They’re just (conceptually) a block of data in graphics memory. It’s what you do with a buffer object (e.g. what buffer bind target(s) you bind it to) that determine what it is being used for at that specific time in your OpenGL command sequence. Read about them here: Buffer Objects.

The 1st line isn’t even valid GL / GLES. I think you meant glTexBuffer() here. If that were it, it associates the specified buffer object handle with the texture previously bound to the texture buffer bind point on the default texture image unit.
The 2nd unbinds the last texture from the default texture image unit (NOTE: not the same thing as image unit).
The 3rd binds the specified texture to the specified image unit. Read more about that here: Image_Load_Store#Images_in_the_context
And the 4th could possibly be storing the image unit index in a shader uniform.

So we’re missing code here, but it appears you’re trying to create a TBO and then setup to access it as an image in the shader.

However, in the portion of your shader code you’ve quoted:

it does things with an SSBO, not a Image sampler. So I have no idea what you’re doing. If you’re trying to access tex as an image, why aren’t you doing it through the image unit you bound it to using an image sampler? And if you actually did want to access the underlying buffer object as an SSBO instead, why did you show setup code where you bind it to an image unit and pass that image unit to a shader uniform (presumably) backed by an image sampler?

Also, for what it’s worth, the relevant limit for the number of image units is GL_MAX_IMAGE_UNITS. In OpenGL ES 3.2, the minimum value for this is 4, and (though it doesn’t matter to you) under OpenGL 4.6, the minimum value for this is 8.

1 Like

Sorry for delay, now I wrote a code that gets the same error. It is one html file that try link program. In google chrome version 79 it works successfully, in later versions get error:

    <!DOCTYPE html>

    <html>
        <head>
            <style>
                html, body {
                    margin:0px;
                    padding:0px;
                    width:100%;
                    height:100%;
                }
                body {
                    background-color: #404040;
                }
                canvas {
                    border:1px solid black
                }
                div {
                    display:flex;
                    width:100%;
                    height:100%;
                    align-items: center;
                    justify-content: center;
                }
            </style>
            <script>
                let gl,                 // gl context to make shaders
                    gVertCnt = 0,       // Vertices count
                    uPointSizeLoc = -1, // VAO object setup
                    uAngle = 0,         // angle
                    gRLoop;             // global ref for our render loop
                window.addEventListener('load', function() {
                    // gl = GLInstance("glcanvas").fSetSize(500, 500).fClear();
                    let canvas = document.getElementById('glcanvas'),
                    gl = canvas.getContext('webgl2-compute');
                
                    // shaderProg = ShaderUtil.domShaderProgram(gl, "vertex_shader", "fragment_shader", true);
                    const shader = gl.createShader(gl.COMPUTE_SHADER);
                    const code = document.getElementById('compute_shader').text;
                    gl.shaderSource(shader, code);
                    gl.compileShader(shader);
                    if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) != true) {
                        console.log('ERROR');
                        throw Error(gl.getShaderInfoLog(shader));
                    }
                    const prog = gl.createProgram();
                    gl.attachShader(prog, shader);
                    gl.linkProgram(prog);
                    if (gl.getProgramParameter(prog, gl.LINK_STATUS) != true) {
                        console.log('ERROR');
                        throw Error(gl.getProgramInfoLog(prog));
                    }
                    console.log('SUCCESS');
                    
                });
            </script>
        </head>
        <body>
            <div>
                <canvas id='glcanvas'></canvas>
                <script id='compute_shader' type='x-shader/x-vertex'>#version 310 es
                    layout( local_size_x = 1000, local_size_y = 1, local_size_z = 1 ) in;
                    layout (std430, binding = 0) buffer aBuffer
                    {
                        int aData[];
                    };
                    layout (std430, binding = 1) buffer bBuffer
                    {
                        int bData[];
                    };
                    layout (std430, binding = 2) buffer cBuffer
                    {
                        int cData[];
                    };
                    layout (std430, binding = 3) buffer dBuffer
                    {
                        int dData[];
                    };
                    layout (std430, binding = 4) buffer eBuffer
                    {
                        int eData[];
                    };
                    layout (std430, binding = 5) buffer fBuffer
                    {
                        int fData[];
                    };
                    layout (std430, binding = 6) buffer gBuffer
                    {
                        int gData[];
                    };
                    layout (std430, binding = 7) buffer hBuffer
                    {
                        int hData[];
                    };
                    layout (std430, binding = 8) buffer rBuffer
                    {
                        int rData[];
                    };
                    layout (std430, binding = 9) buffer jBuffer
                    {
                        int jData[];
                    };
                    layout (std430, binding = 10) buffer kBuffer
                    {
                        int kData[];
                    };
                    layout (std430, binding = 11) buffer lBuffer
                    {
                        int lData[];
                    };
                    layout (std430, binding = 12) buffer mBuffer
                    {
                        int mData[];
                    };
                    void main(void) {
                        uint index = gl_GlobalInvocationID.x;
                        mData[index] = 2;
                    }
                </script>
            </div>
        </body>
    </html>

Are you got the same error? it looks like a buffer limitation

Try with less layout to check if it is a buffer limitation. Or change binding number from 12 to 11 to see if you got the same problem.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.