mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
- got rid of the gl_info substructure in FTexture and moved all elements into the main class.
This commit is contained in:
parent
1a024a9f54
commit
e24b597ae4
5 changed files with 86 additions and 93 deletions
|
@ -74,7 +74,7 @@ public:
|
||||||
WidthBits = bits;
|
WidthBits = bits;
|
||||||
UseType = ETextureType::SWCanvas;
|
UseType = ETextureType::SWCanvas;
|
||||||
bNoCompress = true;
|
bNoCompress = true;
|
||||||
gl_info.SystemTexture[0] = screen->CreateHardwareTexture(this);
|
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is just a wrapper around the hardware texture and should never call the bitmap getters - if it does, something is wrong.
|
// This is just a wrapper around the hardware texture and should never call the bitmap getters - if it does, something is wrong.
|
||||||
|
@ -100,7 +100,7 @@ SWSceneDrawer::~SWSceneDrawer()
|
||||||
void SWSceneDrawer::RenderView(player_t *player)
|
void SWSceneDrawer::RenderView(player_t *player)
|
||||||
{
|
{
|
||||||
DCanvas buffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor());
|
DCanvas buffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor());
|
||||||
if (FBTexture == nullptr || FBTexture->gl_info.SystemTexture[0] == nullptr ||
|
if (FBTexture == nullptr || FBTexture->SystemTexture[0] == nullptr ||
|
||||||
FBTexture->GetWidth() != screen->GetWidth() ||
|
FBTexture->GetWidth() != screen->GetWidth() ||
|
||||||
FBTexture->GetHeight() != screen->GetHeight() ||
|
FBTexture->GetHeight() != screen->GetHeight() ||
|
||||||
(V_IsTrueColor() ? 1:0) != FBTexture->WidthBits)
|
(V_IsTrueColor() ? 1:0) != FBTexture->WidthBits)
|
||||||
|
@ -108,15 +108,15 @@ void SWSceneDrawer::RenderView(player_t *player)
|
||||||
// This manually constructs its own material here.
|
// This manually constructs its own material here.
|
||||||
if (FBTexture != nullptr) delete FBTexture;
|
if (FBTexture != nullptr) delete FBTexture;
|
||||||
FBTexture = new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor());
|
FBTexture = new FSWSceneTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor());
|
||||||
FBTexture->gl_info.SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
FBTexture->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||||
auto mat = FMaterial::ValidateTexture(FBTexture, false);
|
auto mat = FMaterial::ValidateTexture(FBTexture, false);
|
||||||
mat->AddTextureLayer(PaletteTexture);
|
mat->AddTextureLayer(PaletteTexture);
|
||||||
}
|
}
|
||||||
auto buf = FBTexture->gl_info.SystemTexture[0]->MapBuffer();
|
auto buf = FBTexture->SystemTexture[0]->MapBuffer();
|
||||||
if (!buf) I_FatalError("Unable to map buffer for software rendering");
|
if (!buf) I_FatalError("Unable to map buffer for software rendering");
|
||||||
buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf);
|
buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf);
|
||||||
SWRenderer->RenderView(player, &buffer);
|
SWRenderer->RenderView(player, &buffer);
|
||||||
FBTexture->gl_info.SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
|
FBTexture->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
|
||||||
|
|
||||||
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
||||||
screen->Begin2D(false);
|
screen->Begin2D(false);
|
||||||
|
|
|
@ -106,34 +106,6 @@ int TexFormat[]={
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FTexture::GLTexInfo::~GLTexInfo()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
if (Material[i] != NULL) delete Material[i];
|
|
||||||
Material[i] = NULL;
|
|
||||||
|
|
||||||
if (SystemTexture[i] != NULL) delete SystemTexture[i];
|
|
||||||
SystemTexture[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Sprite adjust has changed.
|
|
||||||
// This needs to alter the material's sprite rect.
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FTexture::SetSpriteAdjust()
|
|
||||||
{
|
|
||||||
for(auto mat : gl_info.Material)
|
|
||||||
{
|
|
||||||
if (mat != nullptr) mat->SetSpriteRect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// DFrameBuffer :: PrecacheTexture
|
// DFrameBuffer :: PrecacheTexture
|
||||||
|
@ -280,11 +252,11 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
||||||
{
|
{
|
||||||
if (!texhitlist[i])
|
if (!texhitlist[i])
|
||||||
{
|
{
|
||||||
if (tex->gl_info.Material[0]) tex->gl_info.Material[0]->Clean(true);
|
if (tex->Material[0]) tex->Material[0]->Clean(true);
|
||||||
}
|
}
|
||||||
if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0)
|
if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0)
|
||||||
{
|
{
|
||||||
if (tex->gl_info.Material[1]) tex->gl_info.Material[1]->Clean(true);
|
if (tex->Material[1]) tex->Material[1]->Clean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,42 +291,3 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
||||||
delete[] modellist;
|
delete[] modellist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// 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.GetChars(), 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
|
#include "c_dispatch.h"
|
||||||
#include "hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
#include "hw_material.h"
|
#include "hw_material.h"
|
||||||
|
|
||||||
|
@ -103,10 +104,10 @@ IHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand)
|
||||||
{
|
{
|
||||||
if (tex && tex->UseType!=ETextureType::Null)
|
if (tex && tex->UseType!=ETextureType::Null)
|
||||||
{
|
{
|
||||||
IHardwareTexture *gltex = tex->gl_info.SystemTexture[expand];
|
IHardwareTexture *gltex = tex->SystemTexture[expand];
|
||||||
if (gltex == nullptr)
|
if (gltex == nullptr)
|
||||||
{
|
{
|
||||||
gltex = tex->gl_info.SystemTexture[expand] = screen->CreateHardwareTexture(tex);
|
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture(tex);
|
||||||
}
|
}
|
||||||
return gltex;
|
return gltex;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +230,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
mTextureLayers.ShrinkToFit();
|
mTextureLayers.ShrinkToFit();
|
||||||
mMaxBound = -1;
|
mMaxBound = -1;
|
||||||
mMaterials.Push(this);
|
mMaterials.Push(this);
|
||||||
tx->gl_info.Material[expanded] = this;
|
tx->Material[expanded] = this;
|
||||||
if (tx->bHasCanvas) tx->bTranslucent = 0;
|
if (tx->bHasCanvas) tx->bTranslucent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,16 +582,16 @@ FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand)
|
||||||
again:
|
again:
|
||||||
if (tex && tex->UseType!=ETextureType::Null)
|
if (tex && tex->UseType!=ETextureType::Null)
|
||||||
{
|
{
|
||||||
if (tex->gl_info.bNoExpand) expand = false;
|
if (tex->bNoExpand) expand = false;
|
||||||
|
|
||||||
FMaterial *gltex = tex->gl_info.Material[expand];
|
FMaterial *gltex = tex->Material[expand];
|
||||||
if (gltex == NULL)
|
if (gltex == NULL)
|
||||||
{
|
{
|
||||||
if (expand)
|
if (expand)
|
||||||
{
|
{
|
||||||
if (tex->bWarped || tex->bHasCanvas || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
if (tex->bWarped || tex->bHasCanvas || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
||||||
{
|
{
|
||||||
tex->gl_info.bNoExpand = true;
|
tex->bNoExpand = true;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
if (tex->Brightmap != NULL &&
|
if (tex->Brightmap != NULL &&
|
||||||
|
@ -599,7 +600,7 @@ again:
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// do not expand if the brightmap's size differs.
|
// do not expand if the brightmap's size differs.
|
||||||
tex->gl_info.bNoExpand = true;
|
tex->bNoExpand = true;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +635,7 @@ void FMaterial::FlushAll()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 2; j++)
|
for (int j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
auto gltex = TexMan.ByIndex(i)->gl_info.SystemTexture[j];
|
auto gltex = TexMan.ByIndex(i)->SystemTexture[j];
|
||||||
if (gltex != nullptr) gltex->Clean(true);
|
if (gltex != nullptr) gltex->Clean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,3 +651,42 @@ void FMaterial::Clean(bool f)
|
||||||
// This somehow needs to deal with the other layers as well, but they probably need some form of reference counting to work properly...
|
// This somehow needs to deal with the other layers as well, but they probably need some form of reference counting to work properly...
|
||||||
mBaseLayer->Clean(f);
|
mBaseLayer->Clean(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Prints some texture info
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
CCMD(textureinfo)
|
||||||
|
{
|
||||||
|
int cntt = 0;
|
||||||
|
for (int i = 0; i < TexMan.NumTextures(); i++)
|
||||||
|
{
|
||||||
|
FTexture *tex = TexMan.ByIndex(i);
|
||||||
|
if (tex->SystemTexture[0] || tex->SystemTexture[1] || tex->Material[0] || tex->Material[1])
|
||||||
|
{
|
||||||
|
int lump = tex->GetSourceLump();
|
||||||
|
Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump));
|
||||||
|
if (tex->Material[0])
|
||||||
|
{
|
||||||
|
Printf(PRINT_LOG, "in use (normal)\n");
|
||||||
|
}
|
||||||
|
else if (tex->SystemTexture[0])
|
||||||
|
{
|
||||||
|
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||||
|
}
|
||||||
|
if (tex->Material[1])
|
||||||
|
{
|
||||||
|
Printf(PRINT_LOG, "in use (expanded)\n");
|
||||||
|
}
|
||||||
|
else if (tex->SystemTexture[1])
|
||||||
|
{
|
||||||
|
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||||
|
}
|
||||||
|
cntt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Printf(PRINT_LOG, "%d system textures\n", cntt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "textures/warpbuffer.h"
|
#include "textures/warpbuffer.h"
|
||||||
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
|
|
||||||
FTexture *CreateBrightmapTexture(FTexture*);
|
FTexture *CreateBrightmapTexture(FTexture*);
|
||||||
|
|
||||||
|
@ -188,6 +189,7 @@ FTexture::FTexture (const char *name, int lumpnum)
|
||||||
bDisableFullbright = false;
|
bDisableFullbright = false;
|
||||||
bSkybox = false;
|
bSkybox = false;
|
||||||
bNoCompress = false;
|
bNoCompress = false;
|
||||||
|
bNoExpand = false;
|
||||||
bTranslucent = -1;
|
bTranslucent = -1;
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,6 +216,16 @@ FTexture::~FTexture ()
|
||||||
if (link == this) Wads.SetLinkedTexture(SourceLump, nullptr);
|
if (link == this) Wads.SetLinkedTexture(SourceLump, nullptr);
|
||||||
if (areas != nullptr) delete[] areas;
|
if (areas != nullptr) delete[] areas;
|
||||||
areas = nullptr;
|
areas = nullptr;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
if (Material[i] != nullptr) delete Material[i];
|
||||||
|
Material[i] = nullptr;
|
||||||
|
|
||||||
|
if (SystemTexture[i] != nullptr) delete SystemTexture[i];
|
||||||
|
SystemTexture[i] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FTexture::Unload()
|
void FTexture::Unload()
|
||||||
|
@ -1464,6 +1476,21 @@ bool FTexture::GetTranslucency()
|
||||||
return !!bTranslucent;
|
return !!bTranslucent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Sprite adjust has changed.
|
||||||
|
// This needs to alter the material's sprite rect.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
void FTexture::SetSpriteAdjust()
|
||||||
|
{
|
||||||
|
for (auto mat : Material)
|
||||||
|
{
|
||||||
|
if (mat != nullptr) mat->SetSpriteRect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// empty stubs to be overloaded by child classes.
|
// empty stubs to be overloaded by child classes.
|
||||||
|
|
|
@ -228,6 +228,9 @@ public:
|
||||||
int SourceLump;
|
int SourceLump;
|
||||||
FTextureID id;
|
FTextureID id;
|
||||||
|
|
||||||
|
FMaterial *Material[2] = { nullptr, nullptr };
|
||||||
|
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
||||||
|
|
||||||
// None of the following pointers are owned by this texture, they are all controlled by the texture manager.
|
// None of the following pointers are owned by this texture, they are all controlled by the texture manager.
|
||||||
|
|
||||||
// Paletted variant
|
// Paletted variant
|
||||||
|
@ -265,6 +268,7 @@ public:
|
||||||
uint8_t bDisableFullbright : 1; // This texture will not be displayed as fullbright sprite
|
uint8_t bDisableFullbright : 1; // This texture will not be displayed as fullbright sprite
|
||||||
uint8_t bSkybox : 1; // is a cubic skybox
|
uint8_t bSkybox : 1; // is a cubic skybox
|
||||||
uint8_t bNoCompress : 1;
|
uint8_t bNoCompress : 1;
|
||||||
|
uint8_t bNoExpand : 1;
|
||||||
int8_t bTranslucent : 2;
|
int8_t bTranslucent : 2;
|
||||||
bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures
|
bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures
|
||||||
|
|
||||||
|
@ -446,7 +450,6 @@ protected:
|
||||||
CopySize(other);
|
CopySize(other);
|
||||||
bNoDecals = other->bNoDecals;
|
bNoDecals = other->bNoDecals;
|
||||||
Rotations = other->Rotations;
|
Rotations = other->Rotations;
|
||||||
gl_info = other->gl_info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint32_t> PixelsBgra;
|
std::vector<uint32_t> PixelsBgra;
|
||||||
|
@ -481,16 +484,6 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct GLTexInfo
|
|
||||||
{
|
|
||||||
FMaterial *Material[2] = { nullptr, nullptr };
|
|
||||||
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
|
||||||
bool bNoExpand = false;
|
|
||||||
|
|
||||||
~GLTexInfo();
|
|
||||||
};
|
|
||||||
GLTexInfo gl_info;
|
|
||||||
|
|
||||||
void GetGlowColor(float *data);
|
void GetGlowColor(float *data);
|
||||||
bool isGlowing() { return bGlowing; }
|
bool isGlowing() { return bGlowing; }
|
||||||
bool isFullbright() { return bFullbright; }
|
bool isFullbright() { return bFullbright; }
|
||||||
|
|
Loading…
Reference in a new issue