Some pitch alignment fixes. Fixes issue 168.
This commit is contained in:
@ -1419,7 +1419,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
|
||||
{
|
||||
nvDebugCheck((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE));
|
||||
|
||||
uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
|
||||
uint pitch = computeBytePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects.
|
||||
|
||||
return pitch * h * d;
|
||||
}
|
||||
|
@ -321,6 +321,7 @@ float nv::spatialCieLabError(const FloatImage * img0, const FloatImage * img1)
|
||||
*/
|
||||
// @@ Measure Delta E between lab0 and lab1.
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
#ifndef NV_IMAGE_H
|
||||
#define NV_IMAGE_H
|
||||
|
||||
#include <nvcore/nvcore.h>
|
||||
#include "nvcore/nvcore.h"
|
||||
#include "nvcore/Debug.h" // nvDebugCheck
|
||||
#include "nvcore/Utils.h" // isPowerOfTwo
|
||||
|
||||
// Function linkage
|
||||
#if NVIMAGE_SHARED
|
||||
@ -21,13 +23,27 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Some utility functions:
|
||||
namespace nv {
|
||||
|
||||
inline uint computePitch(uint w, uint bitsize, uint alignment)
|
||||
{
|
||||
return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
|
||||
}
|
||||
// Some utility functions:
|
||||
|
||||
inline uint computeBitPitch(uint w, uint bitsize, uint alignmentInBits)
|
||||
{
|
||||
nvDebugCheck(isPowerOfTwo(alignmentInBits));
|
||||
|
||||
return ((w * bitsize + alignmentInBits - 1) / alignmentInBits) * alignmentInBits;
|
||||
}
|
||||
|
||||
inline uint computeBytePitch(uint w, uint bitsize, uint alignmentInBits)
|
||||
{
|
||||
nvDebugCheck(alignmentInBits >= 8);
|
||||
|
||||
uint pitch = computeBitPitch(w, bitsize, alignmentInBits);
|
||||
|
||||
return (pitch + 7) / 8;
|
||||
}
|
||||
|
||||
|
||||
} // nv namespace
|
||||
|
||||
#endif // NV_IMAGE_H
|
||||
|
Reference in New Issue
Block a user