y2jinc / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
Other
0 stars 0 forks source link

Bug in DirectDrawSurface::mipmapSize #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) on last 
mipmap of a 24 bit uncompressed DDS.

What is the expected output? What do you see instead?
Expected output is the final 1 pixel mipmap of the image - instead it throws an 
exception [nvDebugCheck(!isError())] in MemoryInputStream::seek( uint pos )

What version of the product are you using? On what operating system?
2.0.6 - WinXP

Please provide any additional information below.

When the library seeks to the start of a mipmap, it makes the assumption that 
the data is 4-byte aligned – which in the case of nvtt::Format_RGB is not 
true.  No attempt is made to align data to 4-byte boundaries - the bytes simply 
show up in order.  This calculation only fails for the last mipmap – which is 
1 pixel in size, and thus 3-byes long.  The offset function returns a value 
that is 4 bytes past the real data, and past the end of the file.

For the 24 bit uncompressed case, DirectDrawSurface::mipmapSize(uint mipmap) 
should return

w * h * byteCount

Original issue reported on code.google.com by lars.m.w...@gmail.com on 23 Aug 2010 at 10:39

GoogleCodeExporter commented 9 years ago
Sample file

Original comment by lars.m.w...@gmail.com on 23 Aug 2010 at 11:56

Attachments:

GoogleCodeExporter commented 9 years ago
I thought that the DDS spec said that the pitch of DDS files was supposed to be 
aligned to 32 bits. This should be true for files generated by NVTT. However, I 
cannot find anything on the web about this requirement anymore. I'll contact 
Chuck Walbourn @ Microsoft for clarification.

Original comment by cast...@gmail.com on 24 Aug 2010 at 7:25

GoogleCodeExporter commented 9 years ago
BTW, I like your hole filling algorithm, is that a push-pull filter?

Original comment by cast...@gmail.com on 24 Aug 2010 at 7:31

GoogleCodeExporter commented 9 years ago
Alas, I can't take credit, so don't know.

FYI, the sample DDS was produced from Photoshop using (I believe) a plug-in 
from NVIDIA.

Original comment by lars.m.w...@gmail.com on 24 Aug 2010 at 7:46

GoogleCodeExporter commented 9 years ago
Chuck confirms that the pitch is only byte-aligned. I'll fix this shortly then.

Original comment by cast...@gmail.com on 26 Aug 2010 at 12:15

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1148.

Original comment by cast...@gmail.com on 7 Sep 2010 at 6:24

GoogleCodeExporter commented 9 years ago
OK, this is now fixed. The 2.0 branch now uses byte alignment by default, while 
in trunk you can select the desired alignment with the setPitchAlignment 
function. By default it's set to 8.

I've also updated the documentation:
http://code.google.com/p/nvidia-texture-tools/wiki/ApiDocumentation#Pixel_Format
_Conversion

Note that the image loading code now assumes that the input is 8 bit aligned. 
So, it may have problems loading images generated with previous versions of 
NVTT.

Original comment by cast...@gmail.com on 7 Sep 2010 at 6:29