Displaying image to window using compute shader not working

44 Views Asked by At

I am having trouble with some code that I am writing. It involves me creating a compute shader which is called for every pixel in the window. The compute shader is supposed to output a color, for it's corresponding pixel.

I believe that it is working, as my framerate drops when I do more complex things inside the compute shader. However, I cannot seem to get the image that the compute shader is outputting to, to render in the window.

My compute shader currently looks like this:

#version 450
layout(local_size_x = 16, local_size_y = 16) in;
layout(binding = 0, rgba8) uniform writeonly image2D img;

void main()
{
    ivec2 pixelCoord = ivec2(gl_GlobalInvocationID.xy);

    vec4 color = vec4(1.0, 1.0, 1.0, 1.0);

    imageStore(img, pixelCoord, color);
}

Basically all it does here is just output the color white. It seems to be working, however it's my C code that's having the issue.

Does anyone here know how to fix this? I'm trying to get the image to display on the window.

I tried writing directly to the swapchain but that didn't seem to work for me either.

0

There are 0 best solutions below