-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDS loader crash fix #21
Conversation
Fix for crash when loading a dds file of 3136x3104 with full mipchain. The calculation to calculate the mip size was different from what two separate dds compressors are using.
|
Good questions, I found a few more issues with my pull request because of them. I'm going to look into it a bit more.
The texture I am trying to load is here: https://www.dropbox.com/s/l3xwi5msfo5ahfp/sizetest.dds?dl=0 I'll need to look into the issues above a bit more, so I'm fine if you want to reject this pull request for now. Or you can leave it open, up to you. :) |
Yeah, I want more testing... But good you attached texture so I can take look at it. |
Btw, this sizetest is just black texture? Or should I expect to see something? |
Do some programmer art so that when I fix it I can see that it's not skewed or messed up in some other way. |
Here's a folder with a bunch of images: To test I copied the files into examples/runtime/textures and run example-06-bump, and replace the filename on line 156: m_textureColor = loadTexture("textures/sizetest.png");
Could it be that the non DX10 format has a different formula for storing mipmaps? My original fix was to not round the width/height to a multiple of 4 at every halving-step, but just do the rounding for each mipmap width/height only. That seems to load the DXT5 format dds's correctly. |
Also, just to give some more contexts on that last remark about making it a multiple of 4, here are each mip size exported by the compressonator, versus the mipsize exported by texturec. Note that starting at mip 6, the resolutions and data size of the mipdata start to diverge because texturec rounds the width and height to a multiple of 4 for each step, and continues with that rounded number, and the compressonator doesn't: texturec: |
Fix for crash when loading a dds file of 3136x3104 with full mip-chain. The calculation to calculate the mip size was different from what two separate dds compressors seem to be using.
Repro case: create a DDS texture of the given resolution, and create a full mip chain for it. Try to load it, and during loading the application will crash because it is reading memory it shouldn't. I used
both TheCompressonator and Paint.NET to export the DDS, both failed to load.