- more texture cleanup.
It is now in a state where FTexture really needs to be separated from FGameTexture.
This commit is contained in:
parent
31035a6cea
commit
83817080bb
21 changed files with 91 additions and 103 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue