- 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:
parent
7bdef7fe9a
commit
662fa6e667
18 changed files with 68 additions and 56 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(reinterpret_cast<FGameTexture*>(endScreen->GetTexture()), false);
|
||||
auto mat = FMaterial::ValidateTexture(endScreen, false);
|
||||
mat->AddTextureLayer(BurnTexture);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,19 +295,18 @@ sector_t *FGLRenderer::RenderView(player_t* player)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
|
||||
void FGLRenderer::BindToFrameBuffer(FTexture *tex)
|
||||
{
|
||||
FTexture* layer;
|
||||
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0, 0, &layer));
|
||||
auto BaseLayer = static_cast<FHardwareTexture*>(tex->GetHardwareTexture(0, false));
|
||||
|
||||
if (BaseLayer == nullptr)
|
||||
{
|
||||
// must create the hardware texture first
|
||||
BaseLayer->BindOrCreate(layer, 0, 0, 0, 0);
|
||||
BaseLayer->BindOrCreate(tex, 0, 0, 0, 0);
|
||||
FHardwareTexture::Unbind(0);
|
||||
gl_RenderState.ClearLastMaterial();
|
||||
}
|
||||
BaseLayer->BindToFrameBuffer(mat->Source()->GetTexelWidth(), mat->Source()->GetTexelHeight());
|
||||
BaseLayer->BindToFrameBuffer(tex->GetTexelWidth(), tex->GetTexelHeight());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
@ -319,12 +318,11 @@ 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(reinterpret_cast<FGameTexture*>(tex), false);
|
||||
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
|
||||
StartOffscreen();
|
||||
BindToFrameBuffer(gltex);
|
||||
BindToFrameBuffer(tex);
|
||||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public:
|
|||
void EndOffscreen();
|
||||
void UpdateShadowMap();
|
||||
|
||||
void BindToFrameBuffer(FMaterial *mat);
|
||||
void BindToFrameBuffer(FTexture *mat);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ EXTERN_CVAR(Bool, gl_precache)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PrecacheTexture(FTexture *tex, int cache)
|
||||
static void PrecacheTexture(FGameTexture *tex, int cache)
|
||||
{
|
||||
if (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
|
||||
{
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), false);
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
||||
if (gltex) screen->PrecacheMaterial(gltex, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -74,9 +74,9 @@ static void PrecacheList(FMaterial *gltex, SpriteHits& translations)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PrecacheSprite(FTexture *tex, SpriteHits &hits)
|
||||
static void PrecacheSprite(FGameTexture *tex, SpriteHits &hits)
|
||||
{
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(reinterpret_cast<FGameTexture*>(tex), true);
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(tex, true);
|
||||
if (gltex) PrecacheList(gltex, hits);
|
||||
}
|
||||
|
||||
|
|
@ -273,13 +273,12 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
for (int i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
auto gtex = TexMan.GameByIndex(i);
|
||||
auto tex = gtex->GetTexture();
|
||||
if (tex != nullptr)
|
||||
if (gtex != nullptr)
|
||||
{
|
||||
PrecacheTexture(tex, texhitlist[i]);
|
||||
PrecacheTexture(gtex, texhitlist[i]);
|
||||
if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CountUsed() > 0)
|
||||
{
|
||||
PrecacheSprite(tex, *spritehitlist[i]);
|
||||
PrecacheSprite(gtex, *spritehitlist[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,8 +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(reinterpret_cast<FGameTexture*>(tex), false);
|
||||
auto BaseLayer = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, 0));
|
||||
auto BaseLayer = static_cast<PolyHardwareTexture*>(tex->GetHardwareTexture(0, false));
|
||||
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
|
||||
|
|
|
|||
|
|
@ -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, [&]() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -515,9 +515,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(reinterpret_cast<FGameTexture*>(tex), false);
|
||||
auto BaseLayer = static_cast<VkHardwareTexture*>(mat->GetLayer(0, 0));
|
||||
auto BaseLayer = static_cast<VkHardwareTexture*>(tex->GetHardwareTexture(0, false));
|
||||
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue