major cleanup of the texture manager:
- use sampler objects to avoid creating up to 4 different system textures for one game texture just because of different clamping settings. - avoids flushing all textures for change of texture filter mode. - separate sprite and regular dimensions on the material level to have better control over which one gets used. It's now an explicit parameter of ValidateTexture. The main reason for this change is better handling of wall sprites which may not be subjected to such handling. - create mipmaps based on use case, not texture type. - allows removal of FCloneTexture hack for proper sharing of the same sprite for decals and other purposes. - better precaching of skyboxes.
This commit is contained in:
parent
7a727b6807
commit
1050013017
31 changed files with 596 additions and 700 deletions
|
|
@ -52,6 +52,7 @@
|
|||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/textures/gl_texture.h"
|
||||
#include "gl/textures/gl_material.h"
|
||||
#include "gl/textures/gl_samplers.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
//==========================================================================
|
||||
CUSTOM_CVAR(Float,gl_texture_filter_anisotropic,8.0f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
{
|
||||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||
}
|
||||
|
||||
CCMD(gl_flush)
|
||||
|
|
@ -71,7 +72,7 @@ CCMD(gl_flush)
|
|||
CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
{
|
||||
if (self < 0 || self > 5) self=4;
|
||||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, gl_texture_format, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
|
|
@ -235,37 +236,34 @@ FTexture::MiscGLInfo::MiscGLInfo() throw()
|
|||
bBrightmapDisablesFullbright = false;
|
||||
bNoFilter = false;
|
||||
bNoCompress = false;
|
||||
mExpanded = false;
|
||||
areas = NULL;
|
||||
areacount = 0;
|
||||
mIsTransparent = -1;
|
||||
shaderspeed = 1.f;
|
||||
shaderindex = 0;
|
||||
precacheTime = 0;
|
||||
|
||||
Material = NULL;
|
||||
SystemTexture = NULL;
|
||||
Material[1] = Material[0] = NULL;
|
||||
SystemTexture[1] = SystemTexture[0] = NULL;
|
||||
Brightmap = NULL;
|
||||
DecalTexture = NULL;
|
||||
}
|
||||
|
||||
FTexture::MiscGLInfo::~MiscGLInfo()
|
||||
{
|
||||
if (Material != NULL) delete Material;
|
||||
Material = NULL;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (Material[i] != NULL) delete Material[i];
|
||||
Material[i] = NULL;
|
||||
|
||||
if (SystemTexture != NULL) delete SystemTexture;
|
||||
SystemTexture = NULL;
|
||||
if (SystemTexture[i] != NULL) delete SystemTexture[i];
|
||||
SystemTexture[i] = NULL;
|
||||
}
|
||||
|
||||
// this is managed by the texture manager so it may not be deleted here.
|
||||
//if (Brightmap != NULL) delete Brightmap;
|
||||
// this is just a reference to another texture in the texture manager.
|
||||
Brightmap = NULL;
|
||||
|
||||
if (areas != NULL) delete [] areas;
|
||||
areas = NULL;
|
||||
|
||||
if (DecalTexture != NULL) delete DecalTexture;
|
||||
DecalTexture = NULL;
|
||||
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
@ -319,12 +317,21 @@ void FTexture::CreateDefaultBrightmap()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FTexture::PrecacheGL()
|
||||
void FTexture::PrecacheGL(int cache)
|
||||
{
|
||||
if (gl_precache)
|
||||
{
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(this);
|
||||
if (gltex) gltex->Precache();
|
||||
if (cache & 2)
|
||||
{
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(this, false);
|
||||
if (gltex) gltex->Precache();
|
||||
}
|
||||
if (cache & 4)
|
||||
{
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(this, true);
|
||||
if (gltex) gltex->Precache();
|
||||
}
|
||||
gl_info.precacheTime = TexMan.precacheTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +343,12 @@ void FTexture::PrecacheGL()
|
|||
|
||||
void FTexture::UncacheGL()
|
||||
{
|
||||
if (gl_info.Material) gl_info.Material->Clean(true);
|
||||
if (gl_info.precacheTime != TexMan.precacheTime)
|
||||
{
|
||||
if (gl_info.Material[0]) gl_info.Material[0]->Clean(true);
|
||||
if (gl_info.Material[1]) gl_info.Material[1]->Clean(true);
|
||||
gl_info.precacheTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -640,49 +652,6 @@ int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotat
|
|||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A cloned texture. This is needed by the decal code which needs to assign
|
||||
// a different texture type to some of its graphics.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
FCloneTexture::FCloneTexture (FTexture *source, int usetype)
|
||||
{
|
||||
Name = "";
|
||||
SourcePic = source;
|
||||
CopySize(source);
|
||||
bNoDecals = source->bNoDecals;
|
||||
Rotations = source->Rotations;
|
||||
UseType = usetype;
|
||||
gl_info.bBrightmap = false;
|
||||
id.SetInvalid();
|
||||
SourceLump = -1;
|
||||
}
|
||||
|
||||
FCloneTexture::~FCloneTexture ()
|
||||
{
|
||||
}
|
||||
|
||||
const BYTE *FCloneTexture::GetColumn (unsigned int column, const Span **spans_out)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const BYTE *FCloneTexture::GetPixels ()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void FCloneTexture::Unload ()
|
||||
{
|
||||
}
|
||||
|
||||
int FCloneTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
{
|
||||
return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Parses a brightmap definition
|
||||
|
|
@ -829,3 +798,42 @@ void gl_ParseDetailTexture(FScanner &sc)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Prints some texture info
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD(textureinfo)
|
||||
{
|
||||
int cntt = 0;
|
||||
for (int i = 0; i < TexMan.NumTextures(); i++)
|
||||
{
|
||||
FTexture *tex = TexMan.ByIndex(i);
|
||||
if (tex->gl_info.SystemTexture[0] || tex->gl_info.SystemTexture[1] || tex->gl_info.Material[0] || tex->gl_info.Material[1])
|
||||
{
|
||||
int lump = tex->GetSourceLump();
|
||||
Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name, i, lump, Wads.GetLumpFullName(lump));
|
||||
if (tex->gl_info.Material[0])
|
||||
{
|
||||
Printf(PRINT_LOG, "in use (normal)\n");
|
||||
}
|
||||
else if (tex->gl_info.SystemTexture[0])
|
||||
{
|
||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||
}
|
||||
if (tex->gl_info.Material[1])
|
||||
{
|
||||
Printf(PRINT_LOG, "in use (expanded)\n");
|
||||
}
|
||||
else if (tex->gl_info.SystemTexture[1])
|
||||
{
|
||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||
}
|
||||
cntt++;
|
||||
}
|
||||
}
|
||||
Printf(PRINT_LOG, "%d system textures\n", cntt);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue