Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the shader source string after calling glShaderSource with count=0 #80

Open
ianromanick opened this issue Apr 27, 2021 · 3 comments
Assignees

Comments

@ianromanick
Copy link

What should be in buf when the code below is executed? The second call to glShaderSource should not generate an error, so it should presumably replace the existing shader source with... nothing?

    const GLchar *source = "/* Testing 1... 2... 3... */";
    const GLchar *junk = "/* Just some junk. */";

    glShaderSource(shader, 1, &source, NULL);

    glShaderSource(shader, 0, &junk, NULL);

    GLchar buf[512];
    GLsizei length;

    glGetShaderSource(shader, sizeof(buf), &length, buf);

See also https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/521 and https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10477.

@tarceri
Copy link

tarceri commented Apr 28, 2021

Just while we are discussing glShaderSource() we also have ES tests e.g. [1] that test to make sure a GL_INVALID_VALUE error is returned if the source string is NULL. But neither the ES or desktop GL specs say that this is an error.

We should update the specs to include this error.

[1] dEQP-GLES2.functional.negative_api.shader.shader_source

@ianromanick
Copy link
Author

Just while we are discussing glShaderSource() we also have ES tests e.g. [1] that test to make sure a GL_INVALID_VALUE error is returned if the source string is NULL. But neither the ES or desktop GL specs say that this is an error.

I thought this was one of the generic error conditions described in section 2.3.1 (Errors), but I don't see that language there. Many commands specifically call out the NULL pointer behavior (e.g. glTexImage3D), so perhaps this condition should be added to section 2.3.1?

@pdaniell-nv
Copy link

pdaniell-nv commented May 12, 2021

There is a generic error for count being less than 0, which returns GL_INVALID_VALUE, but I don't think there is anything that requires count to be greater than 0. For NVIDIA the call to glShaderSource(shader, 0, ) doesn't return an error and replaces the shader source for that object with an empty string so glGetShaderSource() sets buf[0]=0.

Note that I think the original question is about the "count" parameter to glShaderSource being zero, and not about the "string" parameter being NULL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants