-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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] rlReadShaderBufferElements()
for compute shader does not work
#2911
Comments
@ffwqo, firstly note that rlUpdateShaderBufferElement is the "old name" of the rlUpdateShaderBuffer function... secondly, how did you compile raylib? Did you make sure that you compile it for OpenGL4.3? Are you sure that your GPU supports OpenGL 4.3? |
@ffwqo You have to recompile raylib with |
note: I think that this |
using |
still not sure that it really means that your GPU supports OpenGL 4.3 but ok.
that seems fine to me. may you send the complete console log? it seems that the current log that you sent is missing the shader compilation ouput stuff... |
Going through the disscussion forum it seems I am not the only one with the issue @FranciscoJintoFox in #2734
|
@ffwqo, just tested your code and it seems to work well for me. #include <iostream>
#include <vector>
#include <raylib.h>
#include <cassert>
#include <rlgl.h>
const char* shaderSource =
R"(
#version 430
layout(local_size_x = 1) in;
layout(std430, binding=1) buffer shaderBuffer {
float[] data;
};
void main() {
uint idx= gl_GlobalInvocationID.x;
data[idx] = 2.0 * idx;
}
)";
int main() {
InitWindow(100, 100, "some");
unsigned int shaderID = rlCompileShader(shaderSource, RL_COMPUTE_SHADER);
unsigned int shaderProgram = rlLoadComputeShaderProgram(shaderID);
std::vector<float> data{1,2,3,4,5,6,7,8,9,10};
std::vector<float> target{0,2,4,6,8,10,12,14,16,18};
unsigned int ssboA = rlLoadShaderBuffer(data.size() * sizeof(float), data.data(), RL_DYNAMIC_DRAW);
rlEnableShader(shaderProgram);
rlBindShaderBuffer(ssboA, 1);
rlComputeShaderDispatch(data.size(), 1, 1);
while(!WindowShouldClose()) {
ClearBackground(BLACK);
BeginDrawing();
DrawRectangle(0, 0, 50, 50, GREEN);
EndDrawing();
}
puts("##unloading##");
rlReadShaderBuffer(ssboA, data.data(), data.size() * sizeof(float), 0);
for(int i=0; i < data.size(); ++i) assert(data[i] == target[i]);
rlUnloadShaderProgram(shaderProgram);
rlUnloadShaderBuffer(ssboA);
CloseWindow();
} |
so, as I see. it seems that there aren't any problems with raylib itself. check again if your GPU supports openGL4.3... |
@ffwqo did you test the compute shader example provided ib
I also recommend you to use latest raylib from GitHub master branch, that's the upcoming |
rlReadShaderBufferElements()
for compute shader does not work
I have compiled the rlgl_computer_shader example from master branch with
|
@ffwqo I'm afraid you are not compiling or linking raylib for OpenGL 4.3. You should review building. I don't use CMake, only the plain Makefiles and it works for me. |
It seems this issue could be related to user build configuration not raylib so I'm closing the issue. Feel free to reopen it if further investigation provides more details. |
I ran into a similar issue. The problem was not successfully defining What 'worked' was adding
to the top of rlgl.h I put 'worked' in quotes because the game of life example works after doing this, but there are warnings during compilation like:
|
For some reason rlReadShaderBufferElements or rlReadShaderBuffer doesn't work the dest array remains unchanged. I have tested the compute shader via a normal opengl program and it works as expected. I have tried the master branch version of raylib but there I get the error
symbol lookup error: ./build/main: undefined symbol: rlReadShaderBuffer
at runtime. The compute GoL example in example/others also doesn't work.using linux.
The text was updated successfully, but these errors were encountered: