I built a simple Ray Tracer which takes use of OpenGL's Compute Shader and traces ".obj" Files. The results are passed to the Host-Program via glMapBufferRange after finishing computing. From there I will output the result as png to validate the result... When I change the dimensions for the output the computation will obviously take longer.
Now to the problem/question:
Let's say the computation works fine with a 300x300 .png image file and I get the result I want. When I increase the size of the image to something like 500x500 I'll get a GL_OUT_OF_MEMORY Error after some time. And only when I try to copy data with glMapBufferRange.
When I'm using a BVH-Structure to accelerate the computation it works with 500x500 and larger images within a shorter time period.
So I think that the Operating System is shutting down the GPU after some time and thus resulting into a invalid Memory Access. Not sure though.
I've been using Ubuntu 20.04 for the program.
Can someone explain why I get an GL_OUT_OF_MEMORY? Is it more likly that I just have some Memory Leaks?
the probably critical part of the Code:
/* Some ssbo's and glsl-program defined above */
glDispatchCompute(workgroup_x, workgroup_y, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
glBindBuffer(GL_SHADER_STORAGE_BARRIER_BIT, defined_ssbo_buffer_idx);
// Error occurs here when computation took around 5 sec or longer
void* gpuData = glMapBufferRange(GL_SHADER_STORAGE_BARRIER_BIT, 0, size_of_buffer, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
memcpy(copyDestination, gpuData, size_of_buffer);
glUnmapBuffer(GL_SHADER_STORAGE_BARRIER_BIT)
glBindBuffer(GL_SHADER_STORAGE_BARRIER_BIT, 0);
I really appreciate any help! Thank you very much and have a great day!