- implemented a proper texture composition cache.
This will mostly ensure that each patch used for composition is only loaded once and automatically unloaded once no longer needed. So far only for paletted rendering, but the same logic can be used for true color as well.
This commit is contained in:
parent
796c0fe931
commit
2e7bcf9e41
32 changed files with 367 additions and 60 deletions
|
|
@ -818,6 +818,7 @@ namespace swrenderer
|
|||
|
||||
FTexture *tex = TexMan.GetPalettedTexture(sidedef->GetTexture(side_t::top), true);
|
||||
mTopPart.Texture = tex && tex->isValid() ? tex->GetSoftwareTexture() : nullptr;
|
||||
if (mTopPart.Texture == nullptr) return;
|
||||
|
||||
mTopPart.TextureOffsetU = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::top));
|
||||
double rowoffset = sidedef->GetTextureYOffset(side_t::top);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
#include "polyrenderer/poly_renderer.h"
|
||||
#include "p_setup.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "image.h"
|
||||
|
||||
// [BB] Use ZDoom's freelook limit for the sotfware renderer.
|
||||
// Note: ZDoom's limit is chosen such that the sky is rendered properly.
|
||||
|
|
@ -80,6 +81,25 @@ FRenderer *CreateSWRenderer()
|
|||
return new FSoftwareRenderer;
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::PreparePrecache(FTexture *ttex, int cache)
|
||||
{
|
||||
bool isbgra = V_IsTrueColor();
|
||||
|
||||
if (ttex != NULL && ttex->isValid())
|
||||
{
|
||||
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||
|
||||
if (tex->CheckPixels())
|
||||
{
|
||||
if (cache == 0) tex->Unload();
|
||||
}
|
||||
else if (cache != 0)
|
||||
{
|
||||
FImageSource::RegisterForPrecache(ttex->GetImage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::PrecacheTexture(FTexture *ttex, int cache)
|
||||
{
|
||||
bool isbgra = V_IsTrueColor();
|
||||
|
|
@ -102,10 +122,6 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *ttex, int cache)
|
|||
else
|
||||
tex->GetPixels (DefaultRenderStyle());
|
||||
}
|
||||
else
|
||||
{
|
||||
tex->Unload ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,10 +168,18 @@ void FSoftwareRenderer::Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &
|
|||
delete[] spritelist;
|
||||
|
||||
int cnt = TexMan.NumTextures();
|
||||
|
||||
FImageSource::BeginPrecaching();
|
||||
for (int i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
PreparePrecache(TexMan.ByIndex(i), texhitlist[i]);
|
||||
}
|
||||
|
||||
for (int i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
PrecacheTexture(TexMan.ByIndex(i), texhitlist[i]);
|
||||
}
|
||||
FImageSource::EndPrecaching();
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::RenderView(player_t *player, DCanvas *target, void *videobuffer)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ struct FSoftwareRenderer : public FRenderer
|
|||
void Init() override;
|
||||
|
||||
private:
|
||||
void PreparePrecache(FTexture *tex, int cache);
|
||||
void PrecacheTexture(FTexture *tex, int cache);
|
||||
|
||||
swrenderer::RenderScene mScene;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "textures/textures.h"
|
||||
|
||||
#include "v_video.h"
|
||||
|
||||
struct FSoftwareTextureSpan
|
||||
{
|
||||
|
|
@ -130,6 +130,12 @@ public:
|
|||
return GetPixels(alpha);
|
||||
}
|
||||
|
||||
// Checks if the pixel data is loaded.
|
||||
bool CheckPixels() const
|
||||
{
|
||||
return V_IsTrueColor() ? PixelsBgra.Size() > 0 : Pixels.Size() > 0;
|
||||
}
|
||||
|
||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||
{
|
||||
bool alpha = !!(style.Flags & STYLEF_RedIsAlpha);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue