GPU Texture Compression demo

Discussion in 'Rendering Technology and APIs' started by Humus, Apr 12, 2008.

  1. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    I have a new demo showing how to do texture compression entirely on the GPU in Direct3D 10.1. I'm compressing a luminance texture to the BC4 format. The shader is merely 49 hardware ALU instructions on an HD 3870, which for 16 pixels in a block is ~3 instructions per pixel. Since it's just a single channel texture I've also optimized the compression by sampling with Gather (AKA Fetch4) to reduce the texture fetches from 16 down to 4. :)

    Not so much eye-candy in this demo as it just shows you a static texture (which obviously is just a photo), but here's the usual screenshot:
    [​IMG]

    You can toggle between the compressed and uncompressed with F5.

    Download here
     
    #1 Humus, Apr 12, 2008
    Last edited by a moderator: Oct 21, 2009
  2. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,494
    Likes Received:
    405
    Location:
    Varna, Bulgaria
    Works flawless here on 3870 CF setup and Vista64 -- average of 3000 FPS.
     
  3. Jawed

    Legend

    Joined:
    Oct 2, 2004
    Messages:
    10,873
    Likes Received:
    767
    Location:
    London
  4. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Well, it's not really comparable. Those are offline compressors, even if the latest NV one can use the GPU to speed up the process. Clearly those are aimed at quality, whereas in my implementation I went with a quick and reasonably good implementation, which is what you'd likely want in a real-time application. I don't know what format they were compressing to in the chart in your link (probably DXT1), but at 2.29 textures / second that's not real-time. This demo could compress thousands hi-res textures in a second. The bottleneck would be reading them in from disk. Although I should say that BC4 clearly is the fastest format to compress to since it's only a single dimension to deal with, so selecting reasonable control points is trivial, whereas it's a much harder problem for DXT1. DXT1 should be possible in real-time too though, although a fair amount slower than BC4.
     
  5. silent_guy

    Veteran Subscriber

    Joined:
    Mar 7, 2006
    Messages:
    3,754
    Likes Received:
    1,379
    Interesting!

    If you have a game with render-to-texture, would it be beneficial to texture compress it by the GPU first before using the texture later on? I guess the answer will be 'it depends on how much you're using that compressed texture and how much BW you're otherwise consuming.' :wink:
    So let's rephrase: is real time texture compression something that's already being done in current games? Does it result in significant speedups in practice?
     
  6. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    15,365
    Likes Received:
    2,558
    Very nice but its not a bloody fireworks screensaver is it :D
     
  7. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    No. It's only in DX10.1 it's a reasonable thing to do.

    It could potentially. Depends on how many reads there will be for each time you compress. A guesstimate is that you'd need to read maybe 5 times or more before it pays off. One place where it almost certainly would have been beneficial is if I integrated it into my DynamicLightmapping demo. There the lightmap could be reused for thousands of frames before it's regenerated.

    :razz:
    Yeah, this is mostly going to be interesting to programmers.
     
  8. silent_guy

    Veteran Subscriber

    Joined:
    Mar 7, 2006
    Messages:
    3,754
    Likes Received:
    1,379
    Is this because of the Fetch4?

    I can't wait to see the results. :wink:

    Thanks!
     
  9. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    No, it's because in earlier APIs there's no way to copy data on the GPU from a resource of another type into a compressed texture. So to make this work you would have to transfer the data back to the system memory across the PCIe/AGP bus, and then copy it back to a compressed texture in video memory.
     
  10. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    15,365
    Likes Received:
    2,558
    of course you wouldnt run into that problem if you made a fireworks screensaver ;)
     
  11. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Are you trying to tell me something? ;)
     
  12. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    15,365
    Likes Received:
    2,558
    Yes, I have a rubber chicken and im not afraid to use it, you have been warned.......
     
  13. frameavenger

    Newcomer

    Joined:
    Oct 27, 2006
    Messages:
    32
    Likes Received:
    0
    WTF? Screensaver?
     
  14. frameavenger

    Newcomer

    Joined:
    Oct 27, 2006
    Messages:
    32
    Likes Received:
    0
    Humus, nice demo.

    I hope that Futurmark enjoy with TC 10.1.
     
  15. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Long overdue, but I've uploaded another demo on this theme, except it's now compressing to DXT1 format, which is probably more useful although a bit more complex to compress to, but it's still certainly real-time. :)

    [​IMG]

    Download here
     
    #15 Humus, Jul 6, 2008
    Last edited by a moderator: Oct 21, 2009
  16. Albuquerque

    Albuquerque Red-headed step child
    Veteran

    Joined:
    Jun 17, 2004
    Messages:
    3,845
    Likes Received:
    329
    Location:
    35.1415,-90.056
    Framerate is a bit sporadic, but it hovers between 1500 and 2100 on my 3.6Ghz Q9450 and a pair of 3870's in crossfire on Vista64 Ultimate. Cool :)
     
  17. sebbbi

    Veteran

    Joined:
    Nov 14, 2007
    Messages:
    2,924
    Likes Received:
    5,293
    Location:
    Helsinki, Finland
    Resurrecting and old tread...

    I just wanted to ask if you (Humus) or anyone else has done this kind of GPU DTX compression with only using floating point instructions (instead of all the DX10 integer ops in the code)?

    I am programming a virtual texture system (to current consoles) and I'd like to compress textures to DXT on fly to optimize the system memory and BW usage. Doing the compression on GPU sounds like the best choice for my system.
     
  18. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    I haven't attempted that. Most of it is done with floating point math though, but there's some bit crunching in the end, but it should be possible to accomplish that with floating point math. On xbox360 I suppose a memexport shader is the way to go, but on PS3 I would guess using the SPUs might be faster than using the GPU.
     
  19. Mendel

    Mendel Mr. Upgrade
    Veteran

    Joined:
    Nov 28, 2003
    Messages:
    1,350
    Likes Received:
    17
    Location:
    Finland
    btw the download link doesn't seem to work anymore. Is the demo still available?
     
  20. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    It's available, but my site has moved from .ca to .name since the thread was originally posted. I've updated the links.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...