Switching default texture format to DDS: Difference between revisions

Jump to navigation Jump to search
m
→‎DDS Debate in 2012 (points made by Mathias): update with proper cquotes (thanks to User:bigstones for saving us a ton of time here !)
(First section: Not limited to terrain textures)
m (→‎DDS Debate in 2012 (points made by Mathias): update with proper cquotes (thanks to User:bigstones for saving us a ton of time here !))
Line 163: Line 163:
}}
}}


== DDS Debate in 2012 (points made by Mathias)==
== DDS Debate in 2012 ==
 
=== Legalities ===
{{FGCquote
  |These kind of precompressed images limits their usage to a specific set of <br/>
drivers. And no, due to the patent issues no open source code including ours <br/>
is allowed to implement compression/decompression code for these image <br/>
formats. Even if this is easy implementation wise.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28604650/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}
 
{{FGCquote
  |t is technically incorrect to provide these s3 patent <br/>
precompressed textures to a driver that does not announce the apropriate <br/>
extension and since we are not allowed to code something that deompresses <br/>
this, I think we should avoid using this compression for all the provided <br/>
models/textures.<br/>
<br/>
I think of a warning that is issued from the image loader in flightgear that <br/>
detects when these precompressed textures are seen. So even people using <br/>
drivers that just offer this extension have a chance to see that the provided <br/>
textures will not work for others.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28612879/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-01</nowiki>
  }}
}}


=== Portability Concerns  ===
=== Portability Concerns  ===
These kind of precompressed images limits their usage to a specific set of drivers. And no, due to the patent issues no open source code including ours  
{{FGCquote
is allowed to implement compression/decompression code for these image formats. Even if this is easy implementation wise.
  |These kind of precompressed images limits their usage to a specific set of <br/>
 
drivers. And no, due to the patent issues no open source code including ours <br/>
I do not care for the on disk format of any image file we have. But the problem  is that some kind of precompression that can be stored in these DDS files
is allowed to implement compression/decompression code for these image <br/>
cannot be used with other drivers than the closed ATI and NVIDIA ones. As long as these patented compression techniques are not used, every OpenGL
formats. Even if this is easy implementation wise.
driver can use this and displays this fine.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28604650/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}


Think: Intel has the hugest marketshare in graphics today. If I remember right, they sell more than ATI and NVIDIA together (*). This kind of change in  
{{FGCquote
effect rules out the majority of users as Intel cannot work with these files.
  |And this is what I try to do now:<br/>
Object against using these patented compression algorithms.<br/>
I do not care for the on disk format of any image file we have. But the problem <br/>
is that some kind of precompression that can be stored in these dds files <br/>
cannot be used with other drivers than the closed ati and nvidia ones.<br/>
As long as these patented compression techiques are not used, every OpenGL <br/>
driver can use this and displays this fine.<br/>
<br/>
Think: Intel has the hugest marketshare in graphics today. If I remember <br/>
right, they sell more than ati and nvidia together (*). This kind of change in <br/>
effect rules out the majority of users as intel cannot work with these files.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28604650/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}


(*) There are several statistics out there, this is the Intel one that counts all sold computers. AMD does usually counts the revenue made with graphics
{{FGCquote
boards (where ATI wins I believe) or NVIDIA that usually limit statistics to professional systems (where NVIDIA wins).
  |It's not limited to dds. If you use osgconv xxx.dds xxx.ivs you will probably <br/>
have the same effect. So I think simply ommitting DDS is ok?<br/>
<br/>
Also, much more important, the comment is not about 'your video driver'. It is <br/>
in your (Vivian) case even wrong. Your driver will display this fine.<br/>
So, in the end I do not care if it is 'your particular video driver' that does <br/>
not like this. You will just see this in the best case as the models look <br/>
wrong, and in the worst case fgfs just crashes the driver if these textures <br/>
are used.<br/>
What I really care about is that these files are expected not to work on a huge <br/>
amount of graphics boards out there. The point is to tell people doing <br/>
textures that they should omit compression so that this message disapears.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678235/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


I would like to have a FlightGear that is by default just running on every average system. Having this run faster on a special configured system with some
better configuration options and hand tuned hardware and drivers is very fine. But without tuning it must at least work in an acceptable way.


I have checked in a change to FlightGear to make the use of the compressed internal formats a start time configuration option.
{{FGCquote
I am still interested if we have that hangs also with texture compression disabled and without providing precompressed DDS textures?
  |I would like to have a flightgear that is by default just running on every <br/>
average system. Having this run faster on a special configured system with some <br/>
better configuration options and hand tuned hardware and drivers is very fine.<br/>
But without tuning it must at least work in an acceptable way.<br/>
<br/>
I have checked in a change to flightgear to make the use of the compressed <br/>
internal formats a starttime configuration option.<br/>
I am still interrested if we have that hangs also with texture compression <br/>
disabled and without providing precompressed dds textures?
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28602775/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}


this is the reason for the (warning) message. If your machine would refuse to display this you, developing that, would probably just say 'nice try, but it does not work' before you check in something. In the case it displays fine, you probably say 'it works here, so I assume it works also for others, lets do'.
{{FGCquote
And the message tells you, 'despite of just seeing this working on this current machine, it does not work for others'.
  |this is the reason for the message. If your machine would refuse to display this you, <br/>
developing that, would probably just say 'nice try, but it does not work' <br/>
before you check in something. In the case it displays fine, you probably say <br/>
'it works here, so I assume it works also for others, lets do'.<br/>
And the message tells you, 'despite of just seeing this working on this <br/>
current machine, it does not work for others'.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678784/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


Seriously, I think plenty people not being on this list today and probably never will be in touch with anybody here, will run into this issue.
{{FGCquote
People here are those few guys from the power users that want to develop this stuff.
  |Seriously, I think plenty people not being on this list today and probably <br/>
never will be in touch with anybody here, will run into this issue.<br/>
People here are those few guys from the power users that want to develop this <br/>
stuff.<br/>
<br/>
I am not going to discuss the patent stuff. Please search the mesa-dev archives <br/>
for the discussion and see there why they think that the nvidia tools and <br/>
other stuff out there cannot be used. Really - it is not that the code for that <br/>
is too dificult or unavailable. I am not a lawyer and I cannot change this <br/>
world - even if I would like to in this regard.<br/>
<br/>
I agree that techically for drivers/gpus supporting these compression formats <br/>
it would be best to use these precompressed files.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678784/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


Your driver will display this fine. So, in the end I do not care if it is 'your particular video driver' that does
{{FGCquote
not like this. You will just see this in the best case as the models look wrong, and in the worst case fgfs just crashes the driver if these textures
  |Seriously, I think plenty people not being on this list today and probably <br/>
are used. What I really care about is that these files are expected not to work on a huge  amount of graphics boards out there. The point is to tell people doing
never will be in touch with anybody here, will run into this issue.<br/>
textures that they should omit compression so that this message disappears.
People here are those few guys from the power users that want to develop this <br/>
stuff.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678784/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


The motivation behind this mentioned change is to sort out the best compromise so that the hangs hopefully disappear - which I hope to get with precomputed
{{FGCquote
mipmaps - and being able to display fine with any driver/GPU.
  |Your driver will display this fine.<br/>
So, in the end I do not care if it is 'your particular video driver' that does <br/>
not like this. You will just see this in the best case as the models look <br/>
wrong, and in the worst case fgfs just crashes the driver if these textures <br/>
are used.<br/>
What I really care about is that these files are expected not to work on a huge <br/>
amount of graphics boards out there. The point is to tell people doing <br/>
textures that they should omit compression so that this message disapears.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678235/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


=== Approaches ===
=== Approaches ===
Ideas raised by Mathias in 2012 [https://www.mail-archive.com/flightgear-devel%40lists.sourceforge.net/msg35523.html]:


I have to say, that not all OpenGL drivers support texture compression, and the models with dds files, are those that I cannot display, because of that.
{{FGCquote
And in fact this will not happen to the open source drivers before something about 2020 because of patent issues.
  |Well, the default f16 does not work anymore for example.<br/>
I have also never tried the new textures, but I assume that these also contain <br/>
precompressed data? Also you claimed that the old texture files start to bitrot <br/>
comared to the new ones which makes me think that the new standard should be <br/>
the dds files. This together makes me think that the dds files should replace <br/>
the traditional image files.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28604650/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}


Sorry to step in this so late - probably way too late - but is there a reason that the on disk format must be compressed?
The previous strategy to have on disk an format that everybody can read and to make the driver compress them as needed/possible is better I think?


I hope that we can get rid of the compression. Can somebody with the appropriate tools convert the compressed textures to non  compressed ones? That could still be DDS, but DDS without these compressions that produce the warning. So no problem with cubemaps in DDS as long as the  
{{FGCquote
compression is not there. Then *everybody* is again able to use this stuff.
  |Hmm, regarding dds.<br/>
I have to say, that not all OpenGL drivers support texture compression, and <br/>
the models with dds files, are those that I cannot display, because of that.<br/>
And in fact this will not happen to the open source drivers before something <br/>
about 2020 because of patent issues.<br/>
<br/>
Sorry to step in this so late - probably way too late - but is there a reason <br/>
that the on disk format must be compressed?<br/>
The previous strategy to have on disk an format that everybody can read and to <br/>
make the driver compress them as needed/possible is better I think?<br/>
<br/>
So, for me the f16 lost its livery lately - where I can live with this for the <br/>
f16, I hope that this does not happen to flightgear as a whole ...
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28594472/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-27</nowiki>
  }}
}}


* Just do not use the patented compression stuff. The precomputed mipmaps could probably do the job of avoiding the hangs (hopefully? to be checked?). May be we could lower disk space usage by providing a dds.gz or similar wrapper?
{{FGCquote
  |Well, I hope that we can get rid of the compression.<br/>
Can somebody with the apropriate tools convert the compressed textures to non <br/>
compressed ones? That could still be dds, but dds without these compressions <br/>
that produce the warning. So no problem with cubemaps in dds as long as the <br/>
compression is not there.<br/>
Then *everybody* is again able to use this stuff.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678109/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


* If it's just the mipmaps. May be we can precompute the mipmaps using the CPU in the database loader thread. This would help all textures not only the ones that could be converted. May be this is the most generic solution.
{{FGCquote
 
  |I can see several approaches:<br/>
* Implement some kind of image lookup order that knows if the compressed files could be handled or not. On loading an image in case of available compression  
<br/>
first try to find a DDS file with the same name of the original one. That involves some 'magic' which often leads to problems but that could at least work.
* Just do not use the patented compression stuff. The precomputed mipmaps could <br/>
 
probably do the job of avoiding the hangs (hopefully? to be checked?). May be <br/>
Other ideas? Also may be creative ones?
we could lower disk space usage by providing a dds.gz or similar wrapper?<br/>
 
<br/>
Next step is to make sure that compression is not required to avoid the hangs. My favorite bet would be that then the new configure option regarding texture compression needs to be set to none.
* If it's just the mipmaps. May be we can precompute the mipmaps using the cpu <br/>
in the database loader thread. This would help all textures not only the ones <br/>
that could be converted. May be this is the most generic solution.<br/>
<br/>
* Implement some kind of image lookup order that knows if the compressed files <br/>
could be handled or not. On loading an image in case of available compression <br/>
first try to find a dds file with the same name of the original one. That <br/>
involves some 'magic' which often leads to problems but that could at least <br/>
work.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28606576/
    |title=<nowiki>[Flightgear-devel] DDS texures (Was: Improving random trees &
buildings)</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-30</nowiki>
  }}
}}


{{FGCquote
  |Next step is to make sure that compression is not required to avoid the hangs.<br/>
My favorite bet would be that then the new configure option regarding texture <br/>
compression needs to be set to none.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28606576/
    |title=<nowiki>[Flightgear-devel] DDS texures (Was: Improving random trees &
buildings)</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-30</nowiki>
  }}
}}
=== Precomputed mipmaps  ===
=== Precomputed mipmaps  ===
points made by Mathias in 2012[https://www.mail-archive.com/flightgear-devel%40lists.sourceforge.net/msg37848.html]:
Could we do DDS files without compression but with precomputed mipmaps?


So at next, can you try out which combination of compression/provided mipmaps/forced simgear compression still work fine?
{{FGCquote
  |Could we do dds files without compression but with precomputed mipmaps?<br/>
<br/>
So at next, can you try out which combination of compression/provided <br/>
mipmaps/forced simgear compression still work fine?
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28603114/
    |title=<nowiki>Re: [Flightgear-devel] Improving random trees & buildings</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2011-12-29</nowiki>
  }}
}}


"precompute the mipmaps in the loader. IIRC tests with some of the guys suffering from this problem, providing premipmapped but uncompressed DDS files had helped to get a fluent viewer. The argument against providing these dds files in general was that these files are really huge because of not including any compression and having all the  mipmaps. But that means we could at the point where the warning happens compute the  mipmap levels on the CPU in the loader thread. osg::gluScaleImage could be
used to do this I think (or something similar not requiring a context). This one is an imported version of the original glu function that is included in
OSG for running on an EGL stack which no longer provides GLU. That is take the image scale this to the 1st mipmap, take the 1.st mipmap and scale this to the 2. mipmap and so forth.
This would have the advantage that the png's do not deviate from the DDS files over time."


computing mipmaps for any texture file on the CPU in the loader thread should globally improve the situation.
{{FGCquote
Also avoiding the compression already in the files should help every use case. Except that the on disk memory consumption is higher. Well and except that the database loader has more work to do on the CPU.
  |The 4. Method that I can imagine is to precompute the mipmaps in the loader.<br/>
IIRC tests with some of the guys suffering from this problem, providing <br/>
premipmapped but uncompressed dds files had helped to get a fluent viewer.<br/>
The argument against providing these dds files in general was that these files <br/>
are really huge because of not including any compression and having all the <br/>
mipmaps.<br/>
But that means we could at the point where the warning happens compute the <br/>
mipmap levels on the cpu in the loader thread. osg::gluScaleImage could be <br/>
used to do this I think (or something similar not requireing a context). This <br/>
one is an imported version of the original glu function that is included in <br/>
osg for running on an EGL stack which no longer provides GLU.<br/>
That is take the image scale this to the 1st mipmap, take the 1.st mipmap and <br/>
scale this to the 2. mipmap and so forth.<br/>
<br/>
This would have the advantage that the png's do not deviate from the dds files <br/>
over time.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/29571679/
    |title=<nowiki>Re: [Flightgear-devel] DDS usage in effects files</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-07-21</nowiki>
  }}
}}


Doing that differently will provide some overhead that could be kept at a minimum I think:
{{FGCquote
For the disk usage, I think gzip compressing these will work sufficiently fine. Ram usage of the images should not hurt too much. Sure the images are bigger
  |I think then, computing mipmaps for any texture file on the CPU in the loader <br/>
in memory. But fgfs is not just about images - far from that. On the GPU, you can still use compression for the textures as the internal
thread should globally improove the situation.<br/>
format. This is what FlightGear tries to do if the extension is supported (checked by OSG).
Also avoiding the compression already in the files should help every use case. <br/>
Except that the on disk memory consumption is higher.<br/>
Well and except that the database loader has more work to do on the CPU.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28612897/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-01</nowiki>
  }}
}}


The major point is that there are several ways that use slightly more resources to get around this problem.
{{FGCquote
But once the patented compression is on disk, there is *no* way back for people not having this feature.
  |Doing that differently will provide some overhead that could be kept at a <br/>
minimum I think:<br/>
For the disk usage, I think gzip compressing these will work sufficiently fine.<br/>
Ram usage of the images should not hurt too much. Sure the images are bigger <br/>
in memory. But fgfs is not just about images - far from that.<br/>
On the GPU, you can still use compression for the textures as the internal <br/>
format. This is what flightgear tries to do if the extension is supported <br/>
(checked by osg).<br/>
<br/>
The major point is that there are several ways that use slightly more <br/>
resources to get around this problem.<br/>
But once the patented compression is on disk, there is *no* way back for <br/>
people not having this feature.<br/>
<br/>
If you have better ideas that do not rule out intel and the oss drivers, you <br/>
are welcome!
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678784/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


If you have better ideas that do not rule out Intel and the OSS drivers, you are welcome!
{{FGCquote
  |On unix I usually get the gzip plugin installed by osg (osgdb_gz.so). Is this <br/>
also the case for the default win32 case? Is there a osgdb_gz.dll or something <br/>
along the lines in the directory containing the plugins?<br/>
<br/>
If yes, we can already tackle the size problem of the uncompressed dds files on <br/>
disk by just gzip compressing these makging a xxx.dds.gz from a xxx.dds and <br/>
just refering to xxx.dds.gz instead of xxx.dds. At least this works fine here. <br/>
And I assume that this works fine for all unix like operating systems including <br/>
mac?!<br/>
James?
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28678235/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees &</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-01-15</nowiki>
  }}
}}


On linux this should work as long as you have zlib installed which could be regarded as a system library there. Can we rely on zlib being compiled into our OSG distributions on win32? We do need zlib in any case, it's mostly about teaching OSG that it finds our zlib on configure and build the gz plugin.
{{FGCquote
  |What about solution 6 with (uncompressed premipmapped dds).gz?<br/>
On linux this should work as long as you have zlib installed which could be <br/>
regarded as a system library there.<br/>
Can we rely on zlib being compield into our osg distributions on win32? We do <br/>
need zlib in any case, it's mostly about teaching osg that it finds our zlib on <br/>
configure and build the gz plugin.
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/29571819/
    |title=<nowiki>Re: [Flightgear-devel] DDS usage in effects files</nowiki>
    |author=<nowiki>Mathias Fröhlich</nowiki>
    |date=<nowiki>2012-07-21</nowiki>
  }}
}}


FredB implemented a mipmap control and generation tool in effects when he last updated the urban shader. For the moment, it relies on hardware when the average operator is used for all texture channels but it could easily be modified to compute all mipmap on the CPU. look the <mipmap-control> effect option and  
{{FGCquote
  |I implemented a mipmap control and generation tool in effects when I last updated<br/>
the urban shader. For the moment, it relies on hardware when the average operator <br/>
is used for all texture channels but it could easily be modified to compute <br/>
all mipmap on the CPU. look the <mipmap-control> effect option and <br/>
mipmap.[ch]xx in SG material lib
mipmap.[ch]xx in SG material lib
  |{{cite web |url=http://sourceforge.net/p/flightgear/mailman/message/28606692/
    |title=<nowiki>Re: [Flightgear-devel] DDS texures (Was: Improving random trees
& buildings)</nowiki>
    |author=<nowiki>Frederic Bouvier</nowiki>
    |date=<nowiki>2011-12-30</nowiki>
  }}
}}


== Challenges ==
== Challenges ==

Navigation menu