- more texture cleanup.

It is now in a state where FTexture really needs to be separated from FGameTexture.
This commit is contained in:
Christoph Oelckers 2020-04-15 18:59:14 +02:00
parent 31035a6cea
commit 83817080bb
21 changed files with 92 additions and 104 deletions

View file

@ -415,8 +415,6 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
FImageTexture *tex = new FImageTexture(image, "");
tex->SetUseType(ETextureType::FontChar);
tex->bMultiPatch = true;
tex->Width = width;
tex->Height = height;
tex->_LeftOffset[0] =
tex->_LeftOffset[1] =
tex->_TopOffset[0] =

View file

@ -36,21 +36,21 @@ IHardwareTexture* CreateHardwareTexture();
//
//===========================================================================
FMaterial::FMaterial(FTexture * tx, bool expanded)
FMaterial::FMaterial(FGameTexture * tx, bool expanded)
{
mShaderIndex = SHADER_Default;
sourcetex = tx;
imgtex = tx;
imgtex = tx->GetTexture();
if (tx->UseType == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(tx)->GetColorFormat() == 0)
if (tx->GetUseType() == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(imgtex)->GetColorFormat() == 0)
{
mShaderIndex = SHADER_Paletted;
}
else if (tx->isHardwareCanvas())
{
if (tx->shaderindex >= FIRST_USER_SHADER)
if (tx->GetShaderIndex() >= FIRST_USER_SHADER)
{
mShaderIndex = tx->shaderindex;
mShaderIndex = tx->GetShaderIndex();
}
// no brightmap for cameratexture
}
@ -60,17 +60,17 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
{
mShaderIndex = tx->isWarped(); // This picks SHADER_Warp1 or SHADER_Warp2
}
else if (tx->Normal && tx->Specular)
else if (imgtex->Normal && imgtex->Specular)
{
for (auto &texture : { tx->Normal, tx->Specular })
for (auto &texture : { imgtex->Normal, imgtex->Specular })
{
mTextureLayers.Push(texture);
}
mShaderIndex = SHADER_Specular;
}
else if (tx->Normal && tx->Metallic && tx->Roughness && tx->AmbientOcclusion)
else if (imgtex->Normal && imgtex->Metallic && imgtex->Roughness && imgtex->AmbientOcclusion)
{
for (auto &texture : { tx->Normal, tx->Metallic, tx->Roughness, tx->AmbientOcclusion })
for (auto &texture : { imgtex->Normal, imgtex->Metallic, imgtex->Roughness, imgtex->AmbientOcclusion })
{
mTextureLayers.Push(texture);
}
@ -78,28 +78,28 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
}
// Note that these layers must present a valid texture even if not used, because empty TMUs in the shader are an undefined condition.
tx->CreateDefaultBrightmap();
if (tx->Brightmap)
imgtex->CreateDefaultBrightmap();
if (imgtex->Brightmap)
{
mTextureLayers.Push(tx->Brightmap);
mTextureLayers.Push(imgtex->Brightmap);
mLayerFlags |= TEXF_Brightmap;
}
else
{
mTextureLayers.Push(TexMan.ByIndex(1));
}
if (tx->Detailmap)
if (imgtex->Detailmap)
{
mTextureLayers.Push(tx->Detailmap);
mTextureLayers.Push(imgtex->Detailmap);
mLayerFlags |= TEXF_Detailmap;
}
else
{
mTextureLayers.Push(TexMan.ByIndex(1));
}
if (tx->Glowmap)
if (imgtex->Glowmap)
{
mTextureLayers.Push(tx->Glowmap);
mTextureLayers.Push(imgtex->Glowmap);
mLayerFlags |= TEXF_Glowmap;
}
else
@ -107,25 +107,25 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
mTextureLayers.Push(TexMan.ByIndex(1));
}
if (tx->shaderindex >= FIRST_USER_SHADER)
if (imgtex->shaderindex >= FIRST_USER_SHADER)
{
const UserShaderDesc &usershader = usershaders[tx->shaderindex - FIRST_USER_SHADER];
const UserShaderDesc &usershader = usershaders[imgtex->shaderindex - FIRST_USER_SHADER];
if (usershader.shaderType == mShaderIndex) // Only apply user shader if it matches the expected material
{
for (auto &texture : tx->CustomShaderTextures)
for (auto &texture : imgtex->CustomShaderTextures)
{
if (texture == nullptr) continue;
mTextureLayers.Push(texture);
}
mShaderIndex = tx->shaderindex;
mShaderIndex = tx->GetShaderIndex();
}
}
}
mExpanded = expanded;
mTextureLayers.ShrinkToFit();
tx->Material[expanded] = this;
if (tx->isHardwareCanvas()) tx->bTranslucent = 0;
imgtex->Material[expanded] = this;
if (tx->isHardwareCanvas()) tx->SetTranslucent(false);
}
//===========================================================================
@ -170,16 +170,17 @@ IHardwareTexture *FMaterial::GetLayer(int i, int translation, FTexture **pLayer)
//
//==========================================================================
FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand, bool create)
FMaterial * FMaterial::ValidateTexture(FGameTexture * gtex, bool expand, bool create)
{
if (tex && tex->isValid())
if (gtex && gtex->isValid())
{
auto tex = gtex->GetTexture();
if (!tex->ShouldExpandSprite()) expand = false;
FMaterial *hwtex = tex->Material[expand];
if (hwtex == NULL && create)
{
hwtex = new FMaterial(tex, expand);
hwtex = new FMaterial(gtex, expand);
}
return hwtex;
}
@ -188,7 +189,7 @@ FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand, bool create)
FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate, bool create)
{
return ValidateTexture(TexMan.GetTexture(no, translate), expand, create);
return ValidateTexture(TexMan.GetGameTexture(no, translate), expand, create);
}

View file

@ -8,18 +8,6 @@
struct FRemapTable;
class IHardwareTexture;
enum
{
CLAMP_NONE = 0,
CLAMP_X = 1,
CLAMP_Y = 2,
CLAMP_XY = 3,
CLAMP_XY_NOMIP = 4,
CLAMP_NOFILTER = 5,
CLAMP_CAMTEX = 6,
};
//===========================================================================
//
// this is the material class for OpenGL.
@ -35,15 +23,15 @@ class FMaterial
bool mExpanded;
public:
FTexture *sourcetex; // the owning texture.
FTexture* imgtex; // the master texture for the backing image. Can be different from sourcetex and should not be in the layer array because that'd confuse the precacher.
FGameTexture *sourcetex; // the owning texture.
FTexture* imgtex; // the first layer's texture image - should be moved into the array
FMaterial(FTexture *tex, bool forceexpand);
FMaterial(FGameTexture *tex, bool forceexpand);
~FMaterial();
int GetLayerFlags() const { return mLayerFlags; }
int GetShaderIndex() const { return mShaderIndex; }
FTexture* Source() const
FGameTexture* Source() const
{
return sourcetex;
}
@ -54,7 +42,7 @@ public:
}
void AddTextureLayer(FTexture *tex)
{
ValidateTexture(tex, false);
//ValidateTexture(tex, false);
mTextureLayers.Push(tex);
}
bool isExpanded() const
@ -70,7 +58,7 @@ public:
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr);
static FMaterial *ValidateTexture(FTexture * tex, bool expand, bool create = true);
static FMaterial *ValidateTexture(FGameTexture * tex, bool expand, bool create = true);
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans, bool create = true);
const TArray<FTexture*> &GetLayerArray() const
{

View file

@ -140,8 +140,7 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u
FImageTexture *tex = new FImageTexture(nullptr, buildinfo.Name);
tex->SetUseType(usetype);
tex->bMultiPatch = true;
tex->Width = buildinfo.Width;
tex->Height = buildinfo.Height;
tex->SetSize(buildinfo.Width, buildinfo.Height);
tex->_LeftOffset[0] = buildinfo.LeftOffset[0];
tex->_LeftOffset[1] = buildinfo.LeftOffset[1];
tex->_TopOffset[0] = buildinfo.TopOffset[0];

View file

@ -1050,7 +1050,7 @@ void FTexCoordInfo::GetFromTexture(FTexture *tex, float x, float y, bool forcewo
{
if (x == 1.f)
{
mRenderWidth = tex->GetScaledWidth();
mRenderWidth = tex->GetDisplayWidth();
mScale.X = (float)tex->Scale.X;
mTempScale.X = 1.f;
}
@ -1064,7 +1064,7 @@ void FTexCoordInfo::GetFromTexture(FTexture *tex, float x, float y, bool forcewo
if (y == 1.f)
{
mRenderHeight = tex->GetScaledHeight();
mRenderHeight = tex->GetDisplayHeight();
mScale.Y = (float)tex->Scale.Y;
mTempScale.Y = 1.f;
}

View file

@ -245,25 +245,10 @@ struct SpritePositioningInfo
class FTexture
{
friend class FGameTexture; // only for the porting work
friend class GLDefsParser;
friend class FMultipatchTextureBuilder;
// The serializer also needs access to more specific info that shouldn't be accessible through the interface.
friend FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTextureID *defval);
// For now only give access to classes which cannot be reworked yet. None of these should remain here when all is done.
friend class FWarpTexture;
friend class FMaterial;
friend class OpenGLRenderer::FGLRenderState; // For now this needs access to some fields in ApplyMaterial. This should be rerouted through the Material class
friend class VkRenderState;
friend class PolyRenderState;
friend class FTexture;
friend struct FTexCoordInfo;
friend class OpenGLRenderer::FHardwareTexture;
friend class VkHardwareTexture;
friend class PolyHardwareTexture;
friend class FMultiPatchTexture;
friend class FSkyBox;
friend class FBrightmapTexture;
friend class FMultipatchTextureBuilder;
friend class FMaterial;
friend class FFont;
@ -623,6 +608,18 @@ struct FTexCoordInfo
void GetFromTexture(FGameTexture* tex, float x, float y, bool forceworldpanning);
};
enum
{
CLAMP_NONE = 0,
CLAMP_X = 1,
CLAMP_Y = 2,
CLAMP_XY = 3,
CLAMP_XY_NOMIP = 4,
CLAMP_NOFILTER = 5,
CLAMP_CAMTEX = 6,
};
//-----------------------------------------------------------------------------
//
// Todo: Get rid of this
@ -685,6 +682,7 @@ public:
void SetTranslucent(bool on) { wrapped.bTranslucent = on; }
ETextureType GetUseType() const { return wrapped.GetUseType(); }
void SetUseType(ETextureType type) { wrapped.SetUseType(type); }
int GetShaderIndex() const { return wrapped.shaderindex; }
float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); }
uint16_t GetRotations() const { return wrapped.GetRotations(); }
void SetRotations(int index) { wrapped.SetRotations(index); }
@ -712,6 +710,8 @@ public:
if (lay.CustomShaderTextures[i]) wrapped.CustomShaderTextures[i] = lay.CustomShaderTextures[i]->GetTexture();
}
}
float GetGlossiness() const { return wrapped.Glossiness; }
float GetSpecularLevel() const { return wrapped.SpecularLevel; }
void CopySize(FGameTexture* BaseTexture)
{
@ -757,6 +757,13 @@ public:
}
bool GetSkyFlip() { return isSkybox() ? static_cast<FSkyBox*>(&wrapped)->fliptop : false; }
int GetClampMode(int clampmode)
{
if (GetUseType() == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
else if (isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((isWarped() || wrapped.shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
return clampmode;
}
};

View file

@ -991,8 +991,9 @@ class GLDefsParser
sc.MustGetString();
FSkyBox * sb = new FSkyBox(sc.String);
sb->Name.ToUpper();
FString s = sc.String;
s.ToUpper();
FSkyBox * sb = new FSkyBox(s);
if (sc.CheckString("fliptop"))
{
sb->fliptop = true;
@ -1009,7 +1010,7 @@ class GLDefsParser
}
if (facecount != 3 && facecount != 6)
{
sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name.GetChars());
sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->GetName().GetChars());
}
sb->SetSize();
TexMan.AddTexture(sb);

View file

@ -336,7 +336,7 @@ void Wiper_Burn::SetTextures(FGameTexture *startscreen, FGameTexture *endscreen)
startScreen = startscreen;
endScreen = endscreen;
BurnTexture = new FBurnTexture(WIDTH, HEIGHT);
auto mat = FMaterial::ValidateTexture(endScreen->GetTexture(), false);
auto mat = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(endScreen->GetTexture()), false);
mat->AddTextureLayer(BurnTexture);
}

View file

@ -297,12 +297,13 @@ sector_t *FGLRenderer::RenderView(player_t* player)
void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
{
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0, 0));
FTexture* layer;
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0, 0, &layer));
if (BaseLayer == nullptr)
{
// must create the hardware texture first
BaseLayer->BindOrCreate(mat->sourcetex, 0, 0, 0, 0);
BaseLayer->BindOrCreate(layer, 0, 0, 0, 0);
FHardwareTexture::Unbind(0);
gl_RenderState.ClearLastMaterial();
}
@ -318,7 +319,7 @@ void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
{
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
FMaterial * gltex = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), false);
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();

View file

@ -308,12 +308,11 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
}
auto tex = mat->Source();
mEffectState = overrideshader >= 0 ? overrideshader : mat->GetShaderIndex();
mShaderTimer = tex->shaderspeed;
SetSpecular(tex->Glossiness, tex->SpecularLevel);
mShaderTimer = tex->GetShaderSpeed();
SetSpecular(tex->GetGlossiness(), tex->GetSpecularLevel());
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex->GetTexture())->NeedUpdate();
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
if (tex->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
clampmode = tex->GetClampMode(clampmode);
// avoid rebinding the same texture multiple times.
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
@ -328,7 +327,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
int numLayers = mat->GetLayers();
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation));
if (base->BindOrCreate(tex, 0, clampmode, translation, flags))
if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, flags))
{
for (int i = 1; i<numLayers; i++)
{

View file

@ -308,7 +308,7 @@ IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture()
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
if (mat->Source()->isSWCanvas()) return;
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->isExpanded() ? CTF_Expand : 0;
int numLayers = mat->GetLayers();

View file

@ -346,7 +346,6 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
return false;
}
}
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
return true;
}

View file

@ -572,7 +572,7 @@ public:
void SetMaterial(FGameTexture* tex, bool expandmode, int clampmode, int translation, int overrideshader)
{
expandmode &= tex->expandSprites();
SetMaterial(FMaterial::ValidateTexture(tex->GetTexture(), expandmode), clampmode, translation, overrideshader);
SetMaterial(FMaterial::ValidateTexture(tex, expandmode), clampmode, translation, overrideshader);
}
void SetClipSplit(float bottom, float top)

View file

@ -50,7 +50,7 @@ static void PrecacheTexture(FTexture *tex, int cache)
{
if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
{
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
FMaterial * gltex = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), false);
if (gltex) screen->PrecacheMaterial(gltex, 0);
}
}
@ -76,7 +76,7 @@ static void PrecacheList(FMaterial *gltex, SpriteHits& translations)
static void PrecacheSprite(FTexture *tex, SpriteHits &hits)
{
FMaterial * gltex = FMaterial::ValidateTexture(tex, true);
FMaterial * gltex = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), true);
if (gltex) PrecacheList(gltex, hits);
}
@ -198,7 +198,7 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
{
if (texhitlist[i] & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
{
FMaterial* mat = FMaterial::ValidateTexture(tex->GetTexture(), false, false);
FMaterial* mat = FMaterial::ValidateTexture(tex, false, false);
if (mat != nullptr)
{
for (auto ftex : mat->GetLayerArray())
@ -209,7 +209,7 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
}
if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CountUsed() > 0)
{
FMaterial *mat = FMaterial::ValidateTexture(tex->GetTexture(), true, false);
FMaterial *mat = FMaterial::ValidateTexture(tex, true, false);
if (mat != nullptr)
{
for (auto ftex : mat->GetLayerArray())

View file

@ -377,7 +377,7 @@ sector_t *PolyFrameBuffer::RenderViewpoint(FRenderViewpoint &mainvp, AActor * ca
void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
{
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
FMaterial *mat = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), false);
auto BaseLayer = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, 0));
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
@ -534,7 +534,7 @@ void PolyFrameBuffer::CleanForRestart()
void PolyFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
if (mat->Source()->isSWCanvas()) return;
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
int flags = mat->isExpanded() ? CTF_Expand : 0;
FTexture* layer;

View file

@ -64,8 +64,7 @@ void PolyHardwareTexture::Reset()
DCanvas *PolyHardwareTexture::GetImage(FTexture *baselayer, const FMaterialState &state)
{
FTexture *tex = state.mMaterial->Source();
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
FGameTexture *tex = state.mMaterial->Source();
if (!mCanvas)
{

View file

@ -281,7 +281,7 @@ void PolyRenderState::Apply()
}
if (mMaterial.mMaterial && mMaterial.mMaterial->Source())
mStreamData.timer = static_cast<float>((double)(screen->FrameTime - firstFrame) * (double)mMaterial.mMaterial->Source()->shaderspeed / 1000.);
mStreamData.timer = static_cast<float>((double)(screen->FrameTime - firstFrame) * (double)mMaterial.mMaterial->Source()->GetShaderSpeed() / 1000.);
else
mStreamData.timer = 0.0f;

View file

@ -102,7 +102,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
fbtex.reset();
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
auto mat = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(fbtex.get()), false);
mat->AddTextureLayer(PaletteTexture);
Canvas.reset();

View file

@ -338,7 +338,7 @@ void VkRenderState::ApplyStreamData()
mStreamData.useVertexData = passManager->GetVertexFormat(static_cast<VKVertexBuffer*>(mVertexBuffer)->VertexFormat)->UseVertexData;
if (mMaterial.mMaterial && mMaterial.mMaterial->Source())
mStreamData.timer = static_cast<float>((double)(screen->FrameTime - firstFrame) * (double)mMaterial.mMaterial->Source()->shaderspeed / 1000.);
mStreamData.timer = static_cast<float>((double)(screen->FrameTime - firstFrame) * (double)mMaterial.mMaterial->Source()->GetShaderSpeed() / 1000.);
else
mStreamData.timer = 0.0f;
@ -386,7 +386,7 @@ void VkRenderState::ApplyPushConstants()
if (mMaterial.mMaterial)
{
auto source = mMaterial.mMaterial->Source();
mPushConstants.uSpecularMaterial = { source->Glossiness, source->SpecularLevel };
mPushConstants.uSpecularMaterial = { source->GetGlossiness(), source->GetSpecularLevel() };
}
mPushConstants.uLightIndex = mLightIndex;

View file

@ -516,7 +516,7 @@ sector_t *VulkanFrameBuffer::RenderViewpoint(FRenderViewpoint &mainvp, AActor *
void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
{
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
FMaterial *mat = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), false);
auto BaseLayer = static_cast<VkHardwareTexture*>(mat->GetLayer(0, 0));
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
@ -647,7 +647,7 @@ void VulkanFrameBuffer::CleanForRestart()
void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
if (mat->Source()->isSWCanvas()) return;
if (mat->Source()->GetUseType() == ETextureType::SWCanvas) return;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : 0;

View file

@ -112,19 +112,15 @@ void VkHardwareTexture::ResetAllDescriptors()
VulkanDescriptorSet *VkHardwareTexture::GetDescriptorSet(const FMaterialState &state)
{
FMaterial *mat = state.mMaterial;
FTexture *base = state.mMaterial->Source();
auto base = state.mMaterial->Source();
int clampmode = state.mClampMode;
int translation = state.mTranslation;
if (base->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
if (base->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((base->isWarped() || base->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
clampmode = base->GetClampMode(clampmode);
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = state.mMaterial->isExpanded() ? CTF_Expand : 0;
if (base->isHardwareCanvas()) static_cast<FCanvasTexture*>(base)->NeedUpdate();
for (auto &set : mDescriptorSets)
{
if (set.descriptor && set.clampmode == clampmode && set.flags == flags) return set.descriptor.get();