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

[rlgl] rlLoadShaderBuffer() data clear just after data copying #3104

Closed
Ka-lua opened this issue Jun 11, 2023 · 2 comments
Closed

[rlgl] rlLoadShaderBuffer() data clear just after data copying #3104

Ka-lua opened this issue Jun 11, 2023 · 2 comments

Comments

@Ka-lua
Copy link

Ka-lua commented Jun 11, 2023

The buffer clearing is probably some debugging artifact? This line should be removed:

raylib/src/rlgl.h

Line 4102 in 2e00d16

glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 0);

@raysan5
Copy link
Owner

raysan5 commented Jun 18, 2023

@Ka-lua Afaik, that line makes sure the loaded buffer is filled with 0, in case a NULL data buffer is created (as used in the provided example).

That code was contributed so I don't know if that's the best approach, is there any reason we don't want that kind of initialization for the buffer? Could there be any issue if we avoid that kind of initialization?

@raysan5 raysan5 changed the title rlLoadShaderBuffer(size, *data, usageHint) copies the data to the buffer, then immediately clears it [rlgl] rlLoadShaderBuffer() data clear just after data copying Jun 18, 2023
@Ka-lua
Copy link
Author

Ka-lua commented Jun 18, 2023

That's right, it clears the buffer to 0 which might be what you want, but that makes the data parameter useless. You could do this to only clear the buffer if data is the null pointer:

glBufferData(GL_SHADER_STORAGE_BUFFER, size, data, usageHint? usageHint : RL_STREAM_COPY);
if (data == NULL)
    glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 0);

raysan5 added a commit that referenced this issue Jun 24, 2023
@raysan5 raysan5 closed this as completed Jun 24, 2023
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

2 participants