Results 1 to 10 of 10

Thread: texture savings question

  1. #1
    Senior Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    592

    texture savings question

    This is one question I've been wondering about for a long time. Say I had RGB and RGBA images, I put into texture atlases. I could mix the RGB and RGBA images, but then all texture atlases would have to be RGBA. Can savings in terms of GPU memory and/or performance be made by making RGB-only and RGBA-only texture atlases?

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: texture savings question

    From performance point of view, if you use 8-bits per component then most probably RGBA is better anyway. Of course, if you store RGB textures in an RGBA atlas then maybe you loose some memory, but I think most probably nowadays every GPU represents RGB textures as RGBX (due to memory access peformance/capability limitations) so maybe there is no any memory saving if you use an RGB atlas as well.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: texture savings question

    It depends. What image format are you using? RGB and RGBA are very large classes of image formats.

    For example an RGB8 image, in all likelihood, takes up the same space as an RGBA8 images. So you'd gain nothing from this. However, this is probably not true for 16F or 32F formats. And unless you're using DXT1, it's not true of any compressed format either.

    However, you should remember that the purpose of a texture atlas is to improve performance by reducing the number of texture binds you do per frame. Performance improvements often come with drawbacks, like increased memory usage. So how much is the performance improvement of using a texture atlas worth?

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: texture savings question

    OpenGL specifies that any texture image that has less than 4 components per-texel will be expanded to 4 components.

    Unless you have really funky hardware that (1) is actually capable of supporting less than 4 components natively, and (2) doesn't conform to the spec, then there is no memory saving whatsoever from using less than 4 components.

    http://www.opengl.org/sdk/docs/man/x...TexImage2D.xml (GL_RGB/GL_BGR description)
    Each element is an RGB triple. The GL converts it to floating point and assembles it into an RGBA element by attaching 1 for alpha.

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: texture savings question

    I'm pretty sure that this is not the case with 32F, 32I or 32UI component formats, as Alfonse said.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: texture savings question

    Quote Originally Posted by mhagain
    Unless you have really funky hardware that [...] (2) doesn't conform to the spec, then there is no memory saving whatsoever from using less than 4 components.

    http://www.opengl.org/sdk/docs/man/x...TexImage2D.xml (GL_RGB/GL_BGR description)
    Each element is an RGB triple. The GL converts it to floating point and assembles it into an RGBA element by attaching 1 for alpha.
    I understand that differently. It does not say anything how this will be implemented and stored in the GPU memory, only defines the alpha value when dealing with RGB formats. Storage can still be 3 component RBG, but when you use the A part, it will be 1.

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: texture savings question

    Quote Originally Posted by ZbuffeR
    I understand that differently. It does not say anything how this will be implemented and stored in the GPU memory, only defines the alpha value when dealing with RGB formats. Storage can still be 3 component RBG, but when you use the A part, it will be 1.
    I also think that your interpretation is right. The GL spec does rarely talk about any internal representation. This part rather refers to how texturing will interpret the underlying data.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  8. #8
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: texture savings question


  9. #9
    Senior Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    992

    Re: texture savings question

    As I already said, nowadays drivers in fact usually convert RGB8 to RGBX8 but this is only because of alignment issues. However, this is not the case with RGB32F for example.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  10. #10
    Senior Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    592

    Re: texture savings question

    So, in the case of RGB8 and RGBA8 formats, it probably doesn't matter. Otherwise, one has to bench.

Similar Threads

  1. Question about 3d texture on GF4
    By Zeno in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 04-25-2003, 02:04 PM
  2. texture question
    By Melekor in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 11-27-2002, 06:57 PM
  3. Multiple 3D Texture on different texture unit question
    By SW in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-04-2002, 06:39 AM
  4. another texture question
    By jankri in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 08-03-2001, 07:00 AM
  5. Texture question and sphere question...
    By detzel in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-19-2001, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean