mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- make the engine consistently use BGRA data - the internal palettes were still RGBA, which caused problems down the line.
- increased cache size to 200 MB (Note: The cache really needs to be replaced with something better that can adapt better to a system's RAM size.)
This commit is contained in:
parent
8b1f2f5fc9
commit
bc986b8054
9 changed files with 39 additions and 33 deletions
|
@ -23,6 +23,8 @@ extern char textfont[2048], smalltextfont[2048];
|
||||||
bool playing_rr;
|
bool playing_rr;
|
||||||
bool playing_blood;
|
bool playing_blood;
|
||||||
|
|
||||||
|
int skytile;
|
||||||
|
|
||||||
int32_t rendmode=0;
|
int32_t rendmode=0;
|
||||||
int32_t usemodels=1;
|
int32_t usemodels=1;
|
||||||
int32_t usehightile=1;
|
int32_t usehightile=1;
|
||||||
|
@ -438,9 +440,9 @@ void uploadbasepalette(int32_t basepalnum, bool transient) // transient palettes
|
||||||
uint8_t basepalWFullBrightInfo[4*256];
|
uint8_t basepalWFullBrightInfo[4*256];
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
basepalWFullBrightInfo[i*4] = basepaltable[basepalnum][i*3];
|
basepalWFullBrightInfo[i*4+0] = basepaltable[basepalnum][i*3+2];
|
||||||
basepalWFullBrightInfo[i*4+1] = basepaltable[basepalnum][i*3+1];
|
basepalWFullBrightInfo[i*4+1] = basepaltable[basepalnum][i*3+1];
|
||||||
basepalWFullBrightInfo[i*4+2] = basepaltable[basepalnum][i*3+2];
|
basepalWFullBrightInfo[i*4+2] = basepaltable[basepalnum][i*3+0];
|
||||||
basepalWFullBrightInfo[i*4+3] = 0-(IsPaletteIndexFullbright(i) != 0);
|
basepalWFullBrightInfo[i*4+3] = 0-(IsPaletteIndexFullbright(i) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +641,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
||||||
else sampleroverride = SamplerClampXY;
|
else sampleroverride = SamplerClampXY;
|
||||||
|
|
||||||
|
|
||||||
bool success = GLInterface.SetTexture(TileFiles.tiles[globalpicnum], globalpal, method, sampleroverride);
|
bool success = GLInterface.SetTexture(globalpicnum, TileFiles.tiles[globalpicnum], globalpal, method, sampleroverride);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
tsiz.x = tsiz.y = 1;
|
tsiz.x = tsiz.y = 1;
|
||||||
|
@ -2115,6 +2117,8 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+ti;
|
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+ti;
|
||||||
|
if (skytile > 0)
|
||||||
|
globalpicnum = skytile;
|
||||||
if (npot)
|
if (npot)
|
||||||
{
|
{
|
||||||
fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
|
fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
|
||||||
|
@ -5254,7 +5258,7 @@ void polymost_fillpolygon(int32_t npoints)
|
||||||
|
|
||||||
if (gloy1 != -1) polymostSet2dView(); //disables blending, texturing, and depth testing
|
if (gloy1 != -1) polymostSet2dView(); //disables blending, texturing, and depth testing
|
||||||
GLInterface.EnableAlphaTest(true);
|
GLInterface.EnableAlphaTest(true);
|
||||||
GLInterface.SetTexture(TileFiles.tiles[globalpicnum], globalpal, DAMETH_NOMASK, -1);
|
GLInterface.SetTexture(globalpicnum, TileFiles.tiles[globalpicnum], globalpal, DAMETH_NOMASK, -1);
|
||||||
|
|
||||||
uint8_t const maskprops = (globalorientation>>7)&DAMETH_MASKPROPS;
|
uint8_t const maskprops = (globalorientation>>7)&DAMETH_MASKPROPS;
|
||||||
handle_blend(maskprops > DAMETH_MASK, 0, maskprops == DAMETH_TRANS2);
|
handle_blend(maskprops > DAMETH_MASK, 0, maskprops == DAMETH_TRANS2);
|
||||||
|
@ -5320,7 +5324,7 @@ static int32_t gen_font_glyph_tex(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
polymosttext->CreateTexture(256, 128, false, false);
|
polymosttext->CreateTexture(256, 128, false, false);
|
||||||
polymosttext->LoadTexture((uint8_t*)tbuf); // RGBA
|
polymosttext->LoadTexture((uint8_t*)tbuf);
|
||||||
polymosttext->SetSampler(Sampler2DNoFilter);
|
polymosttext->SetSampler(Sampler2DNoFilter);
|
||||||
Xfree(tbuf);
|
Xfree(tbuf);
|
||||||
|
|
||||||
|
@ -5647,11 +5651,13 @@ void polymost_initosdfuncs(void)
|
||||||
{ "r_swapinterval","sets the GL swap interval (VSync)",(void *) &vsync, CVAR_INT|CVAR_FUNCPTR, -1, 1 },
|
{ "r_swapinterval","sets the GL swap interval (VSync)",(void *) &vsync, CVAR_INT|CVAR_FUNCPTR, -1, 1 },
|
||||||
{ "r_texfilter", "changes the texture filtering settings (may require restart)", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 },
|
{ "r_texfilter", "changes the texture filtering settings (may require restart)", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 },
|
||||||
{ "r_useindexedcolortextures", "enable/disable indexed color texture rendering", (void *) &r_useindexedcolortextures, CVAR_INT, 0, 1 },
|
{ "r_useindexedcolortextures", "enable/disable indexed color texture rendering", (void *) &r_useindexedcolortextures, CVAR_INT, 0, 1 },
|
||||||
{ "r_palookupinfo", "", (void*)&r_palookupinfo, CVAR_INT|CVAR_FUNCPTR, 0, 1 },
|
{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 },
|
||||||
|
|
||||||
{ "r_yshearing", "enable/disable y-shearing", (void*) &r_yshearing, CVAR_BOOL, 0, 1 },
|
// For testing - will be removed later.
|
||||||
|
{ "r_palookupinfo", "", (void*)&r_palookupinfo, CVAR_INT|CVAR_FUNCPTR, 0, 1 },
|
||||||
{ "fixpalette", "", (void*)& fixpalette, CVAR_INT, 0, 256 },
|
{ "fixpalette", "", (void*)& fixpalette, CVAR_INT, 0, 256 },
|
||||||
{ "fixpalswap", "", (void*)& fixpalswap, CVAR_INT, 0, 256 },
|
{ "fixpalswap", "", (void*)& fixpalswap, CVAR_INT, 0, 256 },
|
||||||
|
{ "skytile", "", (void*)&skytile, CVAR_INT, 0, 30720 },
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5671,7 +5677,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
|
||||||
|
|
||||||
//OSD_Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype);
|
//OSD_Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype);
|
||||||
hicprecaching = 1;
|
hicprecaching = 1;
|
||||||
GLInterface.SetTexture(TileFiles.tiles[dapicnum], dapalnum, 0, -1);
|
GLInterface.SetTexture(dapicnum, TileFiles.tiles[dapicnum], dapalnum, 0, -1);
|
||||||
hicprecaching = 0;
|
hicprecaching = 0;
|
||||||
|
|
||||||
if (datype == 0 || !usemodels) return;
|
if (datype == 0 || !usemodels) return;
|
||||||
|
@ -5685,7 +5691,7 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype)
|
||||||
for (int i = 0; i <= surfaces; i++)
|
for (int i = 0; i <= surfaces; i++)
|
||||||
{
|
{
|
||||||
auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr);
|
auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr);
|
||||||
if (tex) GLInterface.SetTexture(tex, dapalnum, 0, -1);
|
if (tex) GLInterface.SetTexture(-1, tex, dapalnum, 0, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ FHardwareTexture* GLInstance::LoadTexture(FTexture* tex, int textype, int palid)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
bool GLInstance::SetTextureInternal(FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow)
|
bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow)
|
||||||
{
|
{
|
||||||
if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false;
|
if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false;
|
||||||
int usepalette = fixpalette >= 1 ? fixpalette - 1 : curbasepal;
|
int usepalette = fixpalette >= 1 ? fixpalette - 1 : curbasepal;
|
||||||
|
@ -242,7 +242,7 @@ bool GLInstance::SetTextureInternal(FTexture* tex, int palette, int method, int
|
||||||
float al = 0;
|
float al = 0;
|
||||||
if (TextureType == TT_HICREPLACE)
|
if (TextureType == TT_HICREPLACE)
|
||||||
{
|
{
|
||||||
al = /*alphahackarray[globalpicnum] != 0 ? alphahackarray[globalpicnum] * (1.f / 255.f) :*/
|
al = ((unsigned)picnum < MAXTILES && alphahackarray[picnum] != 0) ? alphahackarray[picnum] * (1.f / 255.f) :
|
||||||
(tex->alphaThreshold >= 0.f ? tex->alphaThreshold : 0.f);
|
(tex->alphaThreshold >= 0.f ? tex->alphaThreshold : 0.f);
|
||||||
}
|
}
|
||||||
GLInterface.SetAlphaThreshold(al);
|
GLInterface.SetAlphaThreshold(al);
|
||||||
|
|
|
@ -46,9 +46,9 @@ FHardwareTexture *gloadtex(const int32_t *picbuf, int32_t xsiz, int32_t ysiz, in
|
||||||
{
|
{
|
||||||
for (bssize_t i=xsiz*ysiz-1; i>=0; i--)
|
for (bssize_t i=xsiz*ysiz-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
pic2[i].r = pic[i].r;
|
pic2[i].r = pic[i].b;
|
||||||
pic2[i].g = pic[i].g;
|
pic2[i].g = pic[i].g;
|
||||||
pic2[i].b = pic[i].b;
|
pic2[i].b = pic[i].r;
|
||||||
pic2[i].a = 255;
|
pic2[i].a = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,16 +61,16 @@ FHardwareTexture *gloadtex(const int32_t *picbuf, int32_t xsiz, int32_t ysiz, in
|
||||||
{
|
{
|
||||||
const int32_t ii = palookup[dapal][pic[i].a];
|
const int32_t ii = palookup[dapal][pic[i].a];
|
||||||
|
|
||||||
pic2[i].r = curpalette[ii].r;
|
pic2[i].r = curpalette[ii].b;
|
||||||
pic2[i].g = curpalette[ii].g;
|
pic2[i].g = curpalette[ii].g;
|
||||||
pic2[i].b = curpalette[ii].b;
|
pic2[i].b = curpalette[ii].r;
|
||||||
pic2[i].a = 255;
|
pic2[i].a = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tex = GLInterface.NewTexture();
|
auto tex = GLInterface.NewTexture();
|
||||||
tex->CreateTexture(xsiz, ysiz, false, false);
|
tex->CreateTexture(xsiz, ysiz, false, false);
|
||||||
tex->LoadTexture((uint8_t*)pic2); // RGBA
|
tex->LoadTexture((uint8_t*)pic2);
|
||||||
tex->SetSampler(SamplerNoFilter);
|
tex->SetSampler(SamplerNoFilter);
|
||||||
Xfree(pic2);
|
Xfree(pic2);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ enum ECreateTexBufferFlags
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAXCACHE1DSIZE = (50 * 1024 * 1024),
|
MAXCACHE1DSIZE = (200 * 1024 * 1024),// Ion Fury really needs this much (and allocating less makes no difference for the other games on systems with multiple gigabytes of RAM)
|
||||||
|
|
||||||
MAXTILES = 30720,
|
MAXTILES = 30720,
|
||||||
MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end
|
MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end
|
||||||
|
|
|
@ -65,14 +65,14 @@ unsigned int FHardwareTexture::CreateTexture(int w, int h, bool eightbit, bool m
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
unsigned int FHardwareTexture::LoadTexture(const unsigned char * buffer, bool bgra)
|
unsigned int FHardwareTexture::LoadTexture(const unsigned char * buffer)
|
||||||
{
|
{
|
||||||
return LoadTexturePart(buffer, 0, 0, mWidth, mHeight, bgra);
|
return LoadTexturePart(buffer, 0, 0, mWidth, mHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FHardwareTexture::LoadTexture(FBitmap& bmp, bool bgra)
|
unsigned int FHardwareTexture::LoadTexture(FBitmap& bmp)
|
||||||
{
|
{
|
||||||
return LoadTexture(bmp.GetPixels(), bgra);
|
return LoadTexture(bmp.GetPixels());
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -81,12 +81,12 @@ unsigned int FHardwareTexture::LoadTexture(FBitmap& bmp, bool bgra)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
unsigned int FHardwareTexture::LoadTexturePart(const unsigned char* buffer, int x, int y, int w, int h, bool bgra)
|
unsigned int FHardwareTexture::LoadTexturePart(const unsigned char* buffer, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
if (glTexID == 0) return 0;
|
if (glTexID == 0) return 0;
|
||||||
|
|
||||||
int dstformat = glTextureBytes == 1 ? GL_R8 : GL_RGBA8;// TexFormat[gl_texture_format];
|
int dstformat = glTextureBytes == 1 ? GL_R8 : GL_RGBA8;// TexFormat[gl_texture_format];
|
||||||
int srcformat = glTextureBytes == 1 ? GL_RED : (bgra ? GL_BGRA : GL_RGBA);// TexFormat[gl_texture_format];
|
int srcformat = glTextureBytes == 1 ? GL_RED : GL_BGRA;// TexFormat[gl_texture_format];
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE15);
|
glActiveTexture(GL_TEXTURE15);
|
||||||
glBindTexture(GL_TEXTURE_2D, glTexID);
|
glBindTexture(GL_TEXTURE_2D, glTexID);
|
||||||
|
|
|
@ -27,9 +27,9 @@ public:
|
||||||
//bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags);
|
//bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags);
|
||||||
|
|
||||||
unsigned int CreateTexture(int w, int h, bool eightbit, bool mipmapped);
|
unsigned int CreateTexture(int w, int h, bool eightbit, bool mipmapped);
|
||||||
unsigned int LoadTexture(const unsigned char * buffer, bool brga = false);
|
unsigned int LoadTexture(const unsigned char * buffer);
|
||||||
unsigned int LoadTexturePart(const unsigned char* buffer, int x, int y, int w, int h, bool brga = false);
|
unsigned int LoadTexturePart(const unsigned char* buffer, int x, int y, int w, int h);
|
||||||
unsigned int LoadTexture(FBitmap &bmp, bool brga = false);
|
unsigned int LoadTexture(FBitmap &bmp);
|
||||||
unsigned int GetTextureHandle();
|
unsigned int GetTextureHandle();
|
||||||
int GetSampler() { return mSampler; }
|
int GetSampler() { return mSampler; }
|
||||||
void SetSampler(int sampler) { mSampler = sampler; }
|
void SetSampler(int sampler) { mSampler = sampler; }
|
||||||
|
|
|
@ -189,7 +189,7 @@ void PaletteManager::BindPalette(int index)
|
||||||
{
|
{
|
||||||
auto p = GLInterface.NewTexture();
|
auto p = GLInterface.NewTexture();
|
||||||
p->CreateTexture(256, 1, false, false);
|
p->CreateTexture(256, 1, false, false);
|
||||||
p->LoadTexture((uint8_t*)transientpalette.colors, true);
|
p->LoadTexture((uint8_t*)transientpalette.colors);
|
||||||
p->SetSampler(Sampler2DNoFilter);
|
p->SetSampler(Sampler2DNoFilter);
|
||||||
transientpalette.paltexture = p;
|
transientpalette.paltexture = p;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void PaletteManager::BindPalette(int index)
|
||||||
{
|
{
|
||||||
auto p = GLInterface.NewTexture();
|
auto p = GLInterface.NewTexture();
|
||||||
p->CreateTexture(256, 1, false, false);
|
p->CreateTexture(256, 1, false, false);
|
||||||
p->LoadTexture((uint8_t*)palettes[uindex].colors, true);
|
p->LoadTexture((uint8_t*)palettes[uindex].colors);
|
||||||
p->SetSampler(Sampler2DNoFilter);
|
p->SetSampler(Sampler2DNoFilter);
|
||||||
palettes[uindex].paltexture = p;
|
palettes[uindex].paltexture = p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,17 +381,17 @@ public:
|
||||||
FHardwareTexture* CreateIndexedTexture(FTexture* tex);
|
FHardwareTexture* CreateIndexedTexture(FTexture* tex);
|
||||||
FHardwareTexture* CreateTrueColorTexture(FTexture* tex, int palid, bool checkfulltransparency = false);
|
FHardwareTexture* CreateTrueColorTexture(FTexture* tex, int palid, bool checkfulltransparency = false);
|
||||||
FHardwareTexture *LoadTexture(FTexture* tex, int texturetype, int palid);
|
FHardwareTexture *LoadTexture(FTexture* tex, int texturetype, int palid);
|
||||||
bool SetTextureInternal(FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow);
|
bool SetTextureInternal(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow);
|
||||||
|
|
||||||
|
|
||||||
bool SetTexture(FTexture* tex, int palette, int method, int sampleroverride)
|
bool SetTexture(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride)
|
||||||
{
|
{
|
||||||
return SetTextureInternal(tex, palette, method, sampleroverride, 0, 0, nullptr, 1, nullptr);
|
return SetTextureInternal(globalpicnum, tex, palette, method, sampleroverride, 0, 0, nullptr, 1, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetModelTexture(FTexture *tex, int palette, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow)
|
bool SetModelTexture(FTexture *tex, int palette, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow)
|
||||||
{
|
{
|
||||||
return SetTextureInternal(tex, palette, 8/*DAMETH_MODEL*/, -1, xpanning, ypanning, det, detscale, glow);
|
return SetTextureInternal(-1, tex, palette, 8/*DAMETH_MODEL*/, -1, xpanning, ypanning, det, detscale, glow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ void main()
|
||||||
|
|
||||||
fullbright = palettedColor.a; // This only gets set for paletted rendering.
|
fullbright = palettedColor.a; // This only gets set for paletted rendering.
|
||||||
palettedColor.a = c_one-floor(color.r);
|
palettedColor.a = c_one-floor(color.r);
|
||||||
color = palettedColor.bgra;
|
color = palettedColor;
|
||||||
color.rgb *= detailColor.rgb; // with all this palettizing, this can only be applied afterward, even though it is wrong to do it this way.
|
color.rgb *= detailColor.rgb; // with all this palettizing, this can only be applied afterward, even though it is wrong to do it this way.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue