Fix alignment assumptions in DDS loading code. Fixes issue 132.
Merge misc changes from the-witness.
This commit is contained in:
@ -1404,11 +1404,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
|
||||
{
|
||||
nvDebugCheck((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE));
|
||||
|
||||
// Align pixels to bytes.
|
||||
uint byteCount = (header.pf.bitcount + 7) / 8;
|
||||
|
||||
// Align pitch to 4 bytes.
|
||||
uint pitch = 4 * ((w * byteCount + 3) / 4);
|
||||
uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
|
||||
|
||||
return pitch * h * d;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void FloatImage::exponentiate(uint base_component, uint num, float power)
|
||||
float * ptr = this->channel(base_component + c);
|
||||
|
||||
for(uint i = 0; i < size; i++) {
|
||||
ptr[i] = pow(ptr[i], power);
|
||||
ptr[i] = powf(max(0.0f, ptr[i]), power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,14 @@
|
||||
#define NVIMAGE_CLASS
|
||||
#endif
|
||||
|
||||
|
||||
// Some utility functions:
|
||||
|
||||
inline uint computePitch(uint w, uint bitsize, uint alignment)
|
||||
{
|
||||
return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // NV_IMAGE_H
|
||||
|
Reference in New Issue
Block a user