mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- fixed caching of texture sampler state for old hardware.
- fixed handling of CLAMP_XY_NOMIP sampler mode. This cannot be lumped together with CLAMP_XY because it has different mipmap requirements.
This commit is contained in:
parent
4d7be0e20e
commit
0e14f00b51
4 changed files with 22 additions and 20 deletions
|
@ -168,7 +168,7 @@ void gl_LoadExtensions()
|
|||
gl.vendorstring = (char*)glGetString(GL_VENDOR);
|
||||
gl.lightmethod = LM_SOFTWARE;
|
||||
|
||||
if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects"))
|
||||
if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler"))
|
||||
{
|
||||
gl.flags |= RFL_SAMPLER_OBJECTS;
|
||||
}
|
||||
|
|
|
@ -346,7 +346,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
delete[] buffer;
|
||||
}
|
||||
if (tex->bHasCanvas) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
|
||||
if (lastSampler != clampmode || lastTranslation != translation)
|
||||
if (translation != lastTranslation) lastSampler = 254;
|
||||
if (lastSampler != clampmode)
|
||||
lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler);
|
||||
lastTranslation = translation;
|
||||
return hwtex;
|
||||
|
|
|
@ -86,7 +86,6 @@ void FSamplerManager::UnbindAll()
|
|||
{
|
||||
for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++)
|
||||
{
|
||||
mLastBound[i] = 0;
|
||||
glBindSampler(i, 0);
|
||||
}
|
||||
}
|
||||
|
@ -97,12 +96,8 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval)
|
|||
if (gl.flags & RFL_SAMPLER_OBJECTS)
|
||||
{
|
||||
unsigned int samp = mSamplers[num];
|
||||
//if (samp != mLastBound[texunit])
|
||||
{
|
||||
glBindSampler(texunit, samp);
|
||||
mLastBound[texunit] = samp;
|
||||
return 255;
|
||||
}
|
||||
glBindSampler(texunit, samp);
|
||||
return 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -112,7 +107,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval)
|
|||
case CLAMP_NONE:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
if (lastval > CLAMP_XY_NOMIP)
|
||||
if (lastval >= CLAMP_XY_NOMIP)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
|
@ -123,7 +118,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval)
|
|||
case CLAMP_X:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
if (lastval > CLAMP_XY_NOMIP)
|
||||
if (lastval >= CLAMP_XY_NOMIP)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
|
@ -134,7 +129,18 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval)
|
|||
case CLAMP_Y:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
if (lastval > CLAMP_XY_NOMIP)
|
||||
if (lastval >= CLAMP_XY_NOMIP)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic);
|
||||
}
|
||||
break;
|
||||
|
||||
case CLAMP_XY:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
if (lastval >= CLAMP_XY_NOMIP)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
|
@ -143,15 +149,11 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval)
|
|||
break;
|
||||
|
||||
case CLAMP_XY_NOMIP:
|
||||
case CLAMP_XY:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
if (lastval > CLAMP_XY_NOMIP)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic);
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
|
||||
break;
|
||||
|
||||
case CLAMP_NOFILTER:
|
||||
|
|
|
@ -8,7 +8,6 @@ class FSamplerManager
|
|||
// We need 6 different samplers: 4 for the different clamping modes,
|
||||
// one for 2D-textures and one for voxel textures
|
||||
unsigned int mSamplers[7];
|
||||
unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES];
|
||||
|
||||
void UnbindAll();
|
||||
|
||||
|
|
Loading…
Reference in a new issue