- Blood: fixed some issues with precaching.

This code was still unaware of hardware rendering and created useless software buffers for some textures.
This commit is contained in:
Christoph Oelckers 2020-09-01 19:59:15 +02:00
parent 31fc39b051
commit 0fa742f0ca
6 changed files with 14 additions and 26 deletions

View file

@ -497,7 +497,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
width2 += nOffset + tileWidth(nPicnum) / 2; width2 += nOffset + tileWidth(nPicnum) / 2;
if (width2 >= 0 && width2 < tileWidth(nPicnum)) if (width2 >= 0 && width2 < tileWidth(nPicnum))
{ {
auto pData = tileLoadTile(nPicnum); auto pData = tilePtr(nPicnum);
if (pData[width2*tileHeight(nPicnum)+height2] != TRANSPARENT_INDEX) if (pData[width2*tileHeight(nPicnum)+height2] != TRANSPARENT_INDEX)
return 3; return 3;
} }
@ -569,7 +569,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
nHOffset = pWall->xpanning + ((nHOffset*pWall->xrepeat) << 3) / nLength; nHOffset = pWall->xpanning + ((nHOffset*pWall->xrepeat) << 3) / nLength;
nHOffset %= nSizX; nHOffset %= nSizX;
nOffset %= nSizY; nOffset %= nSizY;
auto pData = tileLoadTile(nPicnum); auto pData = tilePtr(nPicnum);
int nPixel; int nPixel;
nPixel = nHOffset*nSizY + nOffset; nPixel = nHOffset*nSizY + nOffset;

View file

@ -125,9 +125,8 @@ extern char precachehightile[2][(MAXTILES+7)>>3];
int tileInit(char a1, const char *a2); int tileInit(char a1, const char *a2);
void tileProcessGLVoxels(void); void tileProcessGLVoxels(void);
const uint8_t * tileLoadTile(int nTile);
uint8_t * tileAllocTile(int nTile, int x, int y);
void tilePreloadTile(int nTile); void tilePreloadTile(int nTile);
void tilePrecacheTile(int nTile, int nType = 1); void tilePrecacheTile(int nTile, int nType = 1);
char tileGetSurfType(int hit); char tileGetSurfType(int hit);

View file

@ -270,6 +270,7 @@ void PreloadTiles(void)
void PreloadCache(void) void PreloadCache(void)
{ {
if (!r_precache) return;
PreloadTiles(); PreloadTiles();
int cnt = 0; int cnt = 0;
int percentDisplayed = -1; int percentDisplayed = -1;
@ -278,7 +279,7 @@ void PreloadCache(void)
{ {
if (TestBitString(gotpic, i)) if (TestBitString(gotpic, i))
{ {
if (r_precache) PrecacheHardwareTextures(i); PrecacheHardwareTextures(i);
if ((++cnt & 7) == 0) if ((++cnt & 7) == 0)
I_GetEvent(); I_GetEvent();

View file

@ -112,22 +112,9 @@ void tileProcessGLVoxels(void)
} }
#endif #endif
const uint8_t * tileLoadTile(int nTile)
{
tileLoad(nTile);
return (const uint8_t*)tilePtr(nTile);
}
uint8_t * tileAllocTile(int nTile, int x, int y)
{
dassert(nTile >= 0 && nTile < kMaxTiles);
uint8_t *p = TileFiles.tileCreate(nTile, x, y);
dassert(p != NULL);
return p;
}
void tilePreloadTile(int nTile) void tilePreloadTile(int nTile)
{ {
if (!r_precache) return;
int n = 1; int n = 1;
switch (picanm[nTile].extra&7) switch (picanm[nTile].extra&7)
{ {
@ -152,6 +139,7 @@ void tilePreloadTile(int nTile)
} }
break; break;
} }
while(n--) while(n--)
{ {
if (picanm[nTile].sf&PICANM_ANIMTYPE_MASK) if (picanm[nTile].sf&PICANM_ANIMTYPE_MASK)
@ -159,13 +147,13 @@ void tilePreloadTile(int nTile)
for (int frame = picanm[nTile].num; frame >= 0; frame--) for (int frame = picanm[nTile].num; frame >= 0; frame--)
{ {
if ((picanm[nTile].sf&PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK) if ((picanm[nTile].sf&PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
tileLoadTile(nTile-frame); PrecacheHardwareTextures(nTile-frame);
else else
tileLoadTile(nTile+frame); PrecacheHardwareTextures(nTile+frame);
} }
} }
else else
tileLoadTile(nTile); PrecacheHardwareTextures(nTile);
nTile += 1+picanm[nTile].num; nTile += 1+picanm[nTile].num;
} }
} }

View file

@ -220,7 +220,7 @@ void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int
void InitStatusBar(void) void InitStatusBar(void)
{ {
tileLoadTile(2200); if (r_precache) PrecacheHardwareTextures(2200);
} }
GameStats GameInterface::getStats() GameStats GameInterface::getStats()
{ {
@ -290,7 +290,7 @@ void viewInit(void)
lensTable[i] = LittleLong(lensTable[i]); lensTable[i] = LittleLong(lensTable[i]);
} }
#endif #endif
uint8_t *data = tileAllocTile(4077, kLensSize, kLensSize); uint8_t *data = TileFiles.tileCreate(4077, kLensSize, kLensSize);
memset(data, TRANSPARENT_INDEX, kLensSize*kLensSize); memset(data, TRANSPARENT_INDEX, kLensSize*kLensSize);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
@ -773,7 +773,7 @@ void viewDrawScreen(bool sceneonly)
//othercameraclock = gGameClock; //othercameraclock = gGameClock;
if (!tileData(4079)) if (!tileData(4079))
{ {
tileAllocTile(4079, 128, 128); TileFiles.tileCreate(4079, 128, 128);
} }
r enderSetTarget(4079, 128, 128); r enderSetTarget(4079, 128, 128);
renderSetAspect(65536, 78643); renderSetAspect(65536, 78643);

View file

@ -1761,7 +1761,7 @@ char WeaponFindLoaded(PLAYER *pPlayer, int *a2)
return v4; return v4;
} }
char sub_4F0E0(PLAYER *pPlayer) int sub_4F0E0(PLAYER *pPlayer)
{ {
switch (pPlayer->weaponState) switch (pPlayer->weaponState)
{ {