How to load DXT5 compressed pixel data created using a GPU without a copy of the processor?

So what I want to do:

  • Download the file encrypted by any algorithm (in my case AES-256) into the GPU memory (with CUDA).

  • Decrypt the file with all the evidence that we have on the GPU, and let it remain in the memory of the GPU.

  • Now tell OpenGL (4.3) that there is a texture in memory that needs to be read and decompressed from DDS DXT5.

Point 3 is where I doubt it. Since to load compressed DDS DXT5 in OpenGL you need to call openGL :: glCompressedTexImage [+ 2D | 3D | 2DARB ...] with the compression type (GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) and a pointer to the image data buffer.

So, to make it short → is there a way to pass the texture buffer address already in the GPU memory to OpenGL (in DDS format)? Without this option, I will need to transfer the AES decrypted file back to the CPU and tell OpenGL to load it again into the GPU ....

Thanks so much for any help or short examples;)

+5
source share
2 answers

You need to do two things.

First, you must provide synchronization and visibility for the operation that generates this data. If you use compute shader to generate data in SSBO, a buffer texture, or something else, then you will need to use glMemoryBarrier , with the set GL_PIXEL_BUFFER_BARRIER_BIT . If you generate this data using a render operation in a buffer texture, then you do not need an explicit barrier. But if FS writes to SSBO or through image loading / saving, you still need an explicit barrier, as described above.

If you are using OpenCL, you will have to use the OpenCL OpenGL interaction function to make the CL result visible to GL.

After that, you simply use the buffer as a buffer to decompress the pixels, as with any asynchronous pixel transfer operation. Compressed textures work with GL_PIXEL_UNPACK_BUFFER in the same way as uncompressed textures.

Remember: in OpenGL, all buffer objects are the same. OpenGL doesn't care if you use the buffer as an SSBO in one minute, and then use it to transfer pixels next. As long as you synchronize it, everything is in order.

+3
source

Bind the buffer to GL_PIXEL_UNPACK_BUFFER and call glCompressedTexSubImage2D when data is an offset in the buffer.

Read more about PBO here .

+1
source

All Articles