Make Engine/Graphics/Texture.cpp 64bit-clean (hopefully!)

((ULONG*)td_ulObject)[iFr] is fishy - and ULONG td_ulObject already is
in an union with ULONG* td_pulObjects, so use td_pulObjects when
appropriate (i.e. if td_ctFrames>1)
Also fixed some checks accordingly.
This commit is contained in:
Daniel Gibson 2016-04-18 20:10:24 +02:00
parent 93daf905f1
commit ab5d0a584f

View File

@ -1312,7 +1312,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
// if not already generated, generate bind number(s) and force upload // if not already generated, generate bind number(s) and force upload
const PIX pixTextureSize = pixWidth*pixHeight; const PIX pixTextureSize = pixWidth*pixHeight;
if( td_ulObject==NONE) if((td_ctFrames>1 && td_pulObjects==NULL) || td_ulObject==NONE)
{ {
// check whether frames are present // check whether frames are present
ASSERT( td_pulFrames!=NULL && td_pulFrames[0]!=0xDEADBEEF); ASSERT( td_pulFrames!=NULL && td_pulFrames[0]!=0xDEADBEEF);
@ -1367,8 +1367,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
for( INDEX iFr=0; iFr<td_ctFrames; iFr++) for( INDEX iFr=0; iFr<td_ctFrames; iFr++)
{ // determine frame offset and upload texture frame { // determine frame offset and upload texture frame
ULONG *pulCurrentFrame = td_pulFrames + (iFr * td_slFrameSize/BYTES_PER_TEXEL); ULONG *pulCurrentFrame = td_pulFrames + (iFr * td_slFrameSize/BYTES_PER_TEXEL);
STUBBED("64-bit issue"); gfxSetTexture( td_pulObjects[iFr], td_tpLocal);
gfxSetTexture( ((ULONG*)td_ulObject)[iFr], td_tpLocal); // FIXME DG: use that union properly or something?!
gfxUploadTexture( pulCurrentFrame, pixWidth, pixHeight, td_ulInternalFormat, bNoDiscard); gfxUploadTexture( pulCurrentFrame, pixWidth, pixHeight, td_ulInternalFormat, bNoDiscard);
} }
} else { } else {
@ -1393,7 +1392,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
td_pulFrames = NULL; td_pulFrames = NULL;
} }
// done uploading // done uploading
ASSERT( td_ulObject!=NONE); ASSERT((td_ctFrames>1 && td_pulObjects!=NULL) || td_ulObject!=NONE);
return; return;
} }
@ -1402,14 +1401,11 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
// must reset local texture parameters for each frame of animated texture // must reset local texture parameters for each frame of animated texture
for( INDEX iFr=0; iFr<td_ctFrames; iFr++) { for( INDEX iFr=0; iFr<td_ctFrames; iFr++) {
td_tpLocal.Clear(); td_tpLocal.Clear();
STUBBED("64-bit issue"); gfxSetTexture( td_pulObjects[iFr], td_tpLocal); // FIXME DG: use that union properly or something?!
gfxSetTexture( ((ULONG*)td_ulObject)[iFr], td_tpLocal); // FIXME DG: use that union properly or something?!
} }
} }
// set corresponding probe or texture frame as current // set corresponding probe or texture frame as current
ULONG ulTexObject = td_ulObject; // single-frame ULONG ulTexObject = (td_ctFrames>1) ? td_pulObjects[iFrameNo] : td_ulObject; // single-frame or animation
STUBBED("64-bit issue"); // FIXME DG: same here...
if( td_ctFrames>1) ulTexObject = ((ULONG*)td_ulObject)[iFrameNo]; // animation
if( bUseProbe) { if( bUseProbe) {
// set probe if burst value doesn't allow real texture // set probe if burst value doesn't allow real texture
if( _pGfx->gl_slAllowedUploadBurst<0) { if( _pGfx->gl_slAllowedUploadBurst<0) {
@ -1440,17 +1436,22 @@ void CTextureData::Unbind(void)
// reset mark // reset mark
td_tvLastDrawn = (__int64) 0; td_tvLastDrawn = (__int64) 0;
// only if bound
if( td_ulObject==NONE) {
ASSERT( td_ulProbeObject==NONE);
return;
}
// free frame number(s) // free frame number(s)
if( td_ctFrames>1) { // animation if( td_ctFrames>1) { // animation
// only if bound
if( td_pulObjects == NULL || td_pulObjects[0]==NONE) {
ASSERT( td_pulObjects == NULL || td_pulObjects[0]==NONE);
return;
}
for( INDEX iFrame=0; iFrame<td_ctFrames; iFrame++) gfxDeleteTexture( td_pulObjects[iFrame]); for( INDEX iFrame=0; iFrame<td_ctFrames; iFrame++) gfxDeleteTexture( td_pulObjects[iFrame]);
FreeMemory( td_pulObjects); FreeMemory( td_pulObjects);
td_pulObjects = NULL; td_pulObjects = NULL;
} else { // single-frame } else { // single-frame
// only if bound
if( td_ulObject==NONE) {
ASSERT( td_ulProbeObject==NONE);
return;
}
gfxDeleteTexture(td_ulObject); gfxDeleteTexture(td_ulObject);
} }
// delete probe texture, too // delete probe texture, too
@ -1725,8 +1726,7 @@ BOOL CTextureData::IsAutoFreed(void)
SLONG CTextureData::GetUsedMemory(void) SLONG CTextureData::GetUsedMemory(void)
{ {
// readout texture object // readout texture object
ULONG ulTexObject = td_ulObject; ULONG ulTexObject = (td_ctFrames>1) ? td_pulObjects[0] : td_ulObject;
if( td_ctFrames>1) ulTexObject = td_pulObjects[0];
// add structure size and anim block size // add structure size and anim block size
SLONG slUsed = sizeof(*this) + CAnimData::GetUsedMemory()-sizeof(CAnimData); SLONG slUsed = sizeof(*this) + CAnimData::GetUsedMemory()-sizeof(CAnimData);