Compressed Textures (DXT1 and such) on DirectX

I noticed that texture compression (I mean the DXTn formats) currently (Panda 1.3.2) only works for OpenGL, but not for DirectX.

What’s the reason for this?

Is there an ETA when these features will be available in DX as well?

Thanks,

Erik

Support for compressed textures in DX8 and DX9 was recently added to Panda3D in the CVS version, at some point after version 1.3.2 had been released. This code will be included in the next public release of Panda.

David

:smiley:
Well, I should have checked… I just hacked DXT1 support into panda 1.3.2… was fun to do though.

I’m now going to pick up the changes from cvs and compare them to mine…

Thanks,

Erik

From looking at the sources in CVS, it seemed to me that the compressed texture support for direct X is still incomplete.
I verified this by getting the head revision and recompiling it.

My results are that compressed textures are still not really available for dx. If I try

egg2bam -mipmap -txo -ctex -o somefile.bam somefile.egg

I always get the error message that the textures cannot be compressed, whereas it works for opengl.

Also when looking at the code / stepping through it, I found lots of missing things, for example in graphicsStateGuardian.cxx, everything is initialized to not supporting compressed textures:

  _supports_compressed_texture = false;
  _compressed_texture_formats.clear();
  _compressed_texture_formats.set_bit(Texture::CM_off);

and DXGraphicsStateGuardian9.cxx doesn’t change these flags in its reset function.
Therefore the DXGraphicsStateGuardian9::prepare_texture function will bail out right at the beginning:

if (!get_supports_compressed_texture_format(tex->get_ram_image_compression())) {
    dxgsg9_cat.error()
      << *dtc->get_texture() << " is stored in an unsupported compressed format.\n";
    return NULL;
  }

even though DXTextureContext9::create_texture has most bits in it to support compressed textures.

So maybe I just misunderstood something but anyway I wanted to report that the compressed texture support for DX isn’t quite as mature as for OpenGL.

I just consulted with the engineer who implemented this; it appears that when he added the code into dx8 and dx9 to support compressed textures, he based it on the setting of the compressed-textures Config.prc variable. Thus, you need to have “compressed-textures 1” in your Config.prc file in order to use compressed textures at all in DX8 or DX9.

This is a mistake, but a small one; the intended design is that the GSG should respect the compression setting of each individual texture, regardless of the global setting of the compressed-textures variable. (The compressed-textures variable works by changing the default value of Texture::get_compression(), not by directly controlling the GSG’s behavior.)

If you would like to submit the necessary fixes for this, I’d be happy to accept them. :slight_smile:

David

Hm, I always had that turned on and it still doesn’t work. No prob. I’ll fix it locally and will send the necessary changes to you for review.

Cheers,

Erik