Its useful if you know the texture properties ahead of time (e.g., make all textures the same size and format). Use glTexSubImage2D () in the render thread Preallocating the textures saves time later.
I wanted to ask if the second method a common one and is at all possible without causing any throttles in the render thread? Are there any basic examples showing how to do that? Or am I overthinking it and should just go with the first method? I would highly appreciate any input on the matter. Preallocate textures on the GPU ahead of time (glTexStorage2D (), or glTexImage2D () with null data) Load the image in a background thread. I am concerned that with this technique, there might be a frame lag with the glTexImage2D call in the render thread if the image is too large, and there are several images of that size.Īnother technique I came across was to use a pixel buffer object (PBO) to asynchronously load image data onto the GPU in a background thread and then use DMA to unpack that data into a texture object avoiding any CPU cycle involvement in the main thread itself. When the textures are loaded onto the GPU, then the actual rendering would take place.Ī basic google search yielded that I can either load the image in a background thread, return the image data to the render/main thread and then pass that data to the GPU using glTexImage2D. I wanted to do that asynchronously using a resource loader while rendering a loading screen in the window.
I have an OpenGL app that loads a bunch of heavy images as textures and passes them onto the GPU as texture objects in the pre-render phase.