- removed the conversion helper code and fixed a few places where FMaterial was only used to access the hardware textures in the FTexture class.

This commit is contained in:
Christoph Oelckers 2020-04-16 00:21:13 +02:00
commit 662fa6e667
18 changed files with 68 additions and 56 deletions

View file

@ -94,30 +94,32 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
FBTextureIndex = (FBTextureIndex + 1) % 2;
auto &fbtex = FBTexture[FBTextureIndex];
if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr ||
fbtex->GetDisplayWidth() != screen->GetWidth() ||
fbtex->GetDisplayHeight() != screen->GetHeight() ||
(V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat())
auto GetSystemTexture = [&]() { return fbtex->GetTexture()->SystemTextures.GetHardwareTexture(0, false); };
if (fbtex == nullptr || GetSystemTexture() == nullptr ||
fbtex->GetTexelWidth() != screen->GetWidth() ||
fbtex->GetTexelHeight() != screen->GetHeight() ||
(V_IsTrueColor() ? 1:0) != static_cast<FWrapperTexture*>(fbtex->GetTexture())->GetColorFormat())
{
// This manually constructs its own material here.
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(reinterpret_cast<FGameTexture*>(fbtex.get()), false);
fbtex.reset(MakeGameTexture(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())));
GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
mat->AddTextureLayer(PaletteTexture);
Canvas.reset();
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
}
IHardwareTexture *systemTexture = fbtex->GetSystemTexture();
IHardwareTexture *systemTexture = GetSystemTexture();
auto buf = systemTexture->MapBuffer();
if (!buf) I_FatalError("Unable to map buffer for software rendering");
SWRenderer->RenderView(player, Canvas.get(), buf, systemTexture->GetBufferPitch());
systemTexture->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, "swbuffer");
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
DrawTexture(twod, reinterpret_cast<FGameTexture*>(fbtex.get()), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
screen->Draw2D();
screen->Clear2D();
screen->PostProcessScene(CM_DEFAULT, [&]() {

View file

@ -13,7 +13,7 @@ class FWrapperTexture;
class SWSceneDrawer
{
FTexture *PaletteTexture;
std::unique_ptr<FWrapperTexture> FBTexture[2];
std::unique_ptr<FGameTexture> FBTexture[2];
int FBTextureIndex = 0;
bool FBIsTruecolor = false;
std::unique_ptr<DCanvas> Canvas;