- cleaned up the sampler manager's content names and added the missing types to allow easier switching between indexed (no filtering) and non-indexed (filter as per user option).

This commit is contained in:
Christoph Oelckers 2019-10-19 19:10:09 +02:00
parent 2152780806
commit d4fc13fba5
8 changed files with 40 additions and 44 deletions

View file

@ -365,11 +365,11 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && gltexfiltermode == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER ||
(!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs
{
sampler = Sampler2DFiltered;
sampler = SamplerClampXY;
}
else
{
sampler = Sampler2DNoFilter;
sampler = SamplerNoFilterClampXY;
}
texuploaded = 0;

View file

@ -55,7 +55,7 @@ void glsurface_setPalette(void* pPalette)
paletteTexture->CreateTexture(256, 1, false, false);
}
paletteTexture->LoadTexture(palette);
GLInterface.BindTexture(1, paletteTexture, Sampler2DNoFilter);
GLInterface.BindTexture(1, paletteTexture, SamplerNoFilterClampXY);
}
void* glsurface_getBuffer()
@ -74,7 +74,7 @@ void glsurface_blitBuffer()
return;
bufferTexture->LoadTexture(buffer.Data());
GLInterface.BindTexture(0, bufferTexture, Sampler2DNoFilter);
GLInterface.BindTexture(0, bufferTexture, SamplerNoFilterClampXY);
auto data = GLInterface.AllocVertices(4);
auto vt = data.second;

View file

@ -171,13 +171,8 @@ void gltexapplyprops(void)
glanisotropy = (int32_t)GLInterface.glinfo.maxanisotropy;
}
#if 1
GLInterface.mSamplers->SetTextureFilterMode(0, 1);
r_useindexedcolortextures = true;// !gltexfiltermode;
#else
GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy);
r_useindexedcolortextures = false;// !gltexfiltermode;
#endif
// do not force switch indexed textures with the filter.
}
//--------------------------------------------------------------------------------------------------
@ -4670,7 +4665,6 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
}
if (videoGetRenderMode() < REND_POLYMER)
{
Bmemset(m, 0, sizeof(m));
@ -5237,7 +5231,7 @@ static int32_t gen_font_glyph_tex(void)
polymosttext->CreateTexture(256, 128, false, false);
polymosttext->LoadTexture((uint8_t*)tbuf);
polymosttext->SetSampler(Sampler2DNoFilter);
polymosttext->SetSampler(SamplerNoFilterClampXY);
Xfree(tbuf);
return 0;

View file

@ -157,6 +157,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
if (mtex)
{
auto sampler = (method & DAMETH_CLAMPED) ? (sampleroverride != -1 ? sampleroverride : SamplerClampXY) : SamplerRepeat;
if (TextureType == TT_INDEXED) sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat;
BindTexture(0, mtex, sampler);
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f || xpanning != 0 || ypanning != 0))

View file

@ -71,7 +71,7 @@ FHardwareTexture *gloadtex(const int32_t *picbuf, int32_t xsiz, int32_t ysiz, in
auto tex = GLInterface.NewTexture();
tex->CreateTexture(xsiz, ysiz, false, false);
tex->LoadTexture((uint8_t*)pic2);
tex->SetSampler(SamplerNoFilter);
tex->SetSampler(SamplerNoFilterClampXY);
Xfree(pic2);
return tex;

View file

@ -210,7 +210,7 @@ void PaletteManager::BindPalette(int index)
auto p = GLInterface.NewTexture();
p->CreateTexture(256, 1, false, false);
p->LoadTexture((uint8_t*)transientpalette.colors);
p->SetSampler(Sampler2DNoFilter);
p->SetSampler(SamplerNoFilterClampXY);
transientpalette.paltexture = p;
}
inst->BindTexture(2, transientpalette.paltexture);
@ -226,7 +226,7 @@ void PaletteManager::BindPalette(int index)
auto p = GLInterface.NewTexture();
p->CreateTexture(256, 1, false, false);
p->LoadTexture((uint8_t*)palettes[uindex].colors);
p->SetSampler(Sampler2DNoFilter);
p->SetSampler(SamplerNoFilterClampXY);
palettes[uindex].paltexture = p;
}
inst->BindTexture(2, palettes[uindex].paltexture);
@ -268,7 +268,7 @@ void PaletteManager::BindPalswap(int index)
auto p = GLInterface.NewTexture();
p->CreateTexture(256, numshades, true, false);
p->LoadTexture((uint8_t*)ps.lookup);
p->SetSampler(Sampler2DNoFilter);
p->SetSampler(SamplerNoFilterClampXY);
ps.swaptexture = p;
}
inst->BindTexture(1, ps.swaptexture);

View file

@ -50,34 +50,34 @@ TexFilter_s TexFilter[]={
{GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR, true},
{GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST, true},
{GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, true},
//{GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST, true},
{GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST, true},
};
FSamplerManager::FSamplerManager()
{
glGenSamplers(NumSamplers, mSamplers);
glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameterf(mSamplers[5], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
glSamplerParameterf(mSamplers[4], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
glSamplerParameterf(mSamplers[6], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
glSamplerParameteri(mSamplers[6], GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(mSamplers[6], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameterf(mSamplers[7], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
glSamplerParameteri(mSamplers[7], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glSamplerParameteri(mSamplers[7], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(mSamplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[2], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[6], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[6], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[7], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[7], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
for (int i = SamplerNoFilterRepeat; i <= SamplerNoFilterClampXY; i++)
{
glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
}
glSamplerParameteri(mSamplers[SamplerClampX], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerClampY], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerClampXY], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerClampXY], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerNoFilterClampX], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerNoFilterClampY], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerNoFilterClampXY], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[SamplerNoFilterClampXY], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[Sampler2DFiltered], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[Sampler2DFiltered], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
FSamplerManager::~FSamplerManager()
@ -106,12 +106,12 @@ void FSamplerManager::SetTextureFilterMode(int filter, int anisotropy)
{
UnbindAll();
for (int i = 0; i < 4; i++)
for (int i = SamplerRepeat; i <= SamplerClampXY; i++)
{
glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter);
glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter);
glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
}
glSamplerParameteri(mSamplers[4], GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter);
glSamplerParameteri(mSamplers[4], GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter);
glSamplerParameteri(mSamplers[Sampler2DFiltered], GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter);
glSamplerParameteri(mSamplers[Sampler2DFiltered], GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter);
}

View file

@ -10,10 +10,11 @@ enum ESampler
SamplerClampX,
SamplerClampY,
SamplerClampXY,
Sampler2D,
SamplerNoFilter,
Sampler2DFiltered,
Sampler2DNoFilter,
SamplerNoFilterRepeat,
SamplerNoFilterClampX,
SamplerNoFilterClampY,
SamplerNoFilterClampXY,
Sampler2DFiltered, // Currently unused shpuld be used for 2D content
NumSamplers
};