I've been debugging a bit. This is what I have so far :Noman wrote:I just updated to the latest SVN navi, and im getting an error :
Unhandled exception at 0x0043fcd8 in TeamEditorDebug.exe: 0xC0000005: Access violation writing location 0x03765020.
navi.cpp (void Navi::update), line 426
y was 469, x was 0, pitch was 4096 (resolution is 1024x768, so it makes sense)Code: Select all
size_t destx = x * destPixelSize; pDest[y*pitch+destx] = naviCache[y*pitch+destx] = B; pDest[y*pitch+destx+1] = naviCache[y*pitch+destx+1] = G; pDest[y*pitch+destx+2] = naviCache[y*pitch+destx+2] = R; pDest[y*pitch+destx+3] = A * fadeMod; naviCache[y*pitch+destx+3] = A;
Any idea what it could be?
pDest points to the pixelBox's raw data :
Code: Select all
uint8* pDest = static_cast<uint8*>(pixelBox.data);
I had a look at some sizes :
The texture is created at 800x600, so its size (if not rounded up to a power of two) is 800x600x4 (pixel size) = 1920000 bytes.
I get the crash when y (line number) is 469. The pitch is the rounded up size (1024 in our case) multiplied by the pixel size.
The first time i get the crash is when i try to write to the buffer in position
469*1024*4 = 1921024, which is right after the texture size (1920000).
I think that the texture being created does not get its dimensions rounded up. Does that make sense? Should we be writing to position [y*width*pixelsize+x*pixelsize] rather than [y*roundedupwidth*pixelsize+x*pixelsize] ?
[Edit]
I solved it (i think, it works here). The pDest is rounded up, but the naviCache isnt. So the lines
Code: Select all
size_t destx = x * destPixelSize;
pDest[y*pitch+destx] = naviCache[y*pitch+destx] = B; <------------------
pDest[y*pitch+destx+1] = naviCache[y*pitch+destx+1] = G;
pDest[y*pitch+destx+2] = naviCache[y*pitch+destx+2] = R;
pDest[y*pitch+destx+3] = A * fadeMod;
naviCache[y*pitch+destx+3] = A;
Code: Select all
size_t destx = x * destPixelSize;
pDest[y*pitch+destx] = naviCache[y*destPixelSize*naviWidth+destx] = B;
pDest[y*pitch+destx+1] = naviCache[y*destPixelSize*naviWidth+destx+1] = G;
pDest[y*pitch+destx+2] = naviCache[y*destPixelSize*naviWidth+destx+2] = R;
pDest[y*pitch+destx+3] = A * fadeMod;
naviCache[y*destPixelSize*naviWidth+destx+3] = A;
That's all for now