Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Compressing a texture that's already in VRAM

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Dec 2012
    Posts
    2

    Question Compressing a texture that's already in VRAM

    Hello, is it possible to compress a texture that's already in vram?

    I'm creating textures using fractals so I have to render to them uncompressed, I then load them back into CPU memory, and then send them over again compressed.
    Something like this:-

    glGetTexImage(GL_TEXTURE_2D, 0, colour_format, colour_type, image);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB, width, height, 0, colour_format, colour_type, image);

    It seems like wasteful bandwidth to me, is there any other way of doing this without the transfer? I'm guessing not, but I'd like to be certain.

    Thanks again,
    Dave.

  2. #2
    Newbie Newbie
    Join Date
    Dec 2012
    Posts
    2
    Quote Originally Posted by VelociChicken View Post
    Hello, is it possible to compress a texture that's already in vram?

    I'm creating textures using fractals so I have to render to them uncompressed, I then load them back into CPU memory, and then send them over again compressed.
    Something like this:-

    glGetTexImage(GL_TEXTURE_2D, 0, colour_format, colour_type, image);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB, width, height, 0, colour_format, colour_type, image);

    It seems like wasteful bandwidth to me, is there any other way of doing this without the transfer? I'm guessing not, but I'd like to be certain.

    Thanks again,
    Dave.
    OK I got a great reply from the comp.graphics.api.opengl newsgroup:-

    GLuint buf;
    glGenBuffers(1, &buf);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, buf);
    glBufferData(GL_PIXEL_PACK_BUFFER, width * height * bytes_per_pixel,
    (const GLvoid*)0, GL_STREAM_COPY);
    glGetTexImage(GL_TEXTURE_2D, 0, colour_format, colour_type, (GLvoid*)0);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB, width, height, 0, colour_format, colour_type, (const GLvoid*)0);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •