Issues with binding image texture to compute shader #2613
Replies: 1 comment 1 reply
|
Your texture is mipmap-incomplete, so the shader's Why You never touch Per the A 1x1 texture is the one size where this never bites you: level 0 is the only mip level that can possibly exist ( Fix Either set a non-mipmapping min filter: rend.gl.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);or, better, use immutable storage ( rend.gl.TexStorage2D(TextureTarget.Texture2D, 1, GLEnum.Rgba8, sx, sy);( One more thing worth fixing while you're in there: you're calling rend.gl.MemoryBarrier(MemoryBarrierMask.TextureUpdateBarrierBit);It happens to work without it on most drivers for a trivial single-invocation shader like yours, but it's undefined per spec, and you don't want it becoming your next "works on my machine" bug. Sources: GL_ARB_shader_image_load_store spec, "Texture Image Loads and Stores", OpenGL wiki, Texture completeness, Silk.NET's own |
Uh oh!
There was an error while loading. Please reload this page.
I have been trying to get compute shaders working with Silk.NET OpenGL, and i have got it to a point where they compile and link fine with no errors, however the issues start with trying to bind an image to the compute shader for reading and writing. if i use a 1x1 texture it works just fine, and then i can read the data back and print a pixel (the test shader simply sets pixel 0, 0 to red), but when i change the texture size to 2x2 or anything else, it suddenly stops working, pixel 0,0 suddenly reads 0,0,0,0 and I cannot figure out why.
Compute is just an object to store the program id etc
the above code is my test code for the shader, I tried to change dispatch sizes to 1, 1, 1, or width, height, 1, or a few different combinations. it works perfectly fine with sx=sy=1 which tells me there is no issues with the compilation, linking or dispatching of the shader. For those curious the shader is:
I have verified as well that there are no errors after pretty much every line of code, gl.GetError prints NoError every time. I am curious if anyone else has had this issue/has a solution.
All reactions