- add the hardware texture container to FTexture.

Currently it does not use the translated entries yet.

# Conflicts:
#	src/hwrenderer/textures/hw_material.cpp
This commit is contained in:
Christoph Oelckers 2018-12-12 02:28:42 +01:00
parent e6b4c63b99
commit fb6ee5046c
5 changed files with 24 additions and 19 deletions

View file

@ -515,9 +515,9 @@ FTexture *OpenGLFrameBuffer::WipeStartScreen()
const auto &viewport = screen->mScreenViewport; const auto &viewport = screen->mScreenViewport;
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1); auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
tex->GetSystemTexture(0)->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); tex->GetSystemTexture()->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
glFinish(); glFinish();
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false); static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false, false);
GLRenderer->mBuffers->BindCurrentFB(); GLRenderer->mBuffers->BindCurrentFB();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
@ -537,9 +537,9 @@ FTexture *OpenGLFrameBuffer::WipeEndScreen()
GLRenderer->Flush(); GLRenderer->Flush();
const auto &viewport = screen->mScreenViewport; const auto &viewport = screen->mScreenViewport;
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1); auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
tex->GetSystemTexture(0)->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); tex->GetSystemTexture()->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
glFinish(); glFinish();
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false); static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false, false);
GLRenderer->mBuffers->BindCurrentFB(); GLRenderer->mBuffers->BindCurrentFB();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
return tex; return tex;

View file

@ -1,8 +1,10 @@
#pragma once #pragma once
#include "tarray.h" #include "tarray.h"
#include "hwrenderer/textures/hw_ihwtexture.h"
struct FTextureBuffer; struct FTextureBuffer;
class IHardwareTexture;
class FHardwareTextureContainer class FHardwareTextureContainer
{ {
@ -49,10 +51,10 @@ private:
unsigned index = hwTex_Translated.FindEx([=](auto &element) unsigned index = hwTex_Translated.FindEx([=](auto &element)
{ {
return element.translation == translation; return element.translation == translation;
} });
if (index < hwTex_Translated.Size()) if (index < hwTex_Translated.Size())
{ {
return &hwTex_Translated[i]; return &hwTex_Translated[index];
} }
int add = hwTex_Translated.Reserve(1); int add = hwTex_Translated.Reserve(1);
@ -65,7 +67,11 @@ public:
void Clean(bool all) void Clean(bool all)
{ {
if (all) hwDefTex.Delete(); if (all)
{
hwDefTex[0].Delete();
hwDefTex[1].Delete();
}
hwTex_Translated.Clear(); hwTex_Translated.Clear();
} }
@ -90,7 +96,7 @@ public:
// //
//=========================================================================== //===========================================================================
void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations, bool expanded) void CleanUnused(SpriteHits &usedtranslations, bool expanded)
{ {
if (usedtranslations.CheckKey(0) == nullptr) if (usedtranslations.CheckKey(0) == nullptr)
{ {

View file

@ -91,7 +91,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
FBTextureIndex = (FBTextureIndex + 1) % 2; FBTextureIndex = (FBTextureIndex + 1) % 2;
auto &fbtex = FBTexture[FBTextureIndex]; auto &fbtex = FBTexture[FBTextureIndex];
if (fbtex == nullptr || fbtex->GetSystemTexture(0) == nullptr || if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr ||
fbtex->GetDisplayWidth() != screen->GetWidth() || fbtex->GetDisplayWidth() != screen->GetWidth() ||
fbtex->GetDisplayHeight() != screen->GetHeight() || fbtex->GetDisplayHeight() != screen->GetHeight() ||
(V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat()) (V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat())
@ -99,7 +99,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
// This manually constructs its own material here. // This manually constructs its own material here.
fbtex.reset(); fbtex.reset();
fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
auto mat = FMaterial::ValidateTexture(fbtex.get(), false); auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
mat->AddTextureLayer(PaletteTexture); mat->AddTextureLayer(PaletteTexture);
@ -107,10 +107,10 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()));
} }
auto buf = fbtex->GetSystemTexture(0)->MapBuffer(); auto buf = fbtex->GetSystemTexture()->MapBuffer();
if (!buf) I_FatalError("Unable to map buffer for software rendering"); if (!buf) I_FatalError("Unable to map buffer for software rendering");
SWRenderer->RenderView(player, Canvas.get(), buf); SWRenderer->RenderView(player, Canvas.get(), buf);
fbtex->GetSystemTexture(0)->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); fbtex->GetSystemTexture()->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);

View file

@ -178,9 +178,6 @@ FTexture::~FTexture ()
{ {
if (Material[i] != nullptr) delete Material[i]; if (Material[i] != nullptr) delete Material[i];
Material[i] = nullptr; Material[i] = nullptr;
if (SystemTexture[i] != nullptr) delete SystemTexture[i];
SystemTexture[i] = nullptr;
} }
if (SoftwareTexture != nullptr) if (SoftwareTexture != nullptr)
{ {
@ -793,7 +790,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
Format = bits; Format = bits;
UseType = ETextureType::SWCanvas; UseType = ETextureType::SWCanvas;
bNoCompress = true; bNoCompress = true;
SystemTexture[0] = screen->CreateHardwareTexture(); SystemTextures.AddHardwareTexture(0, false, screen->CreateHardwareTexture());
} }
//=========================================================================== //===========================================================================

View file

@ -42,6 +42,7 @@
#include "colormatcher.h" #include "colormatcher.h"
#include "r_data/renderstyle.h" #include "r_data/renderstyle.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "hwrenderer/textures/hw_texcontainer.h"
#include <vector> #include <vector>
// 15 because 0th texture is our texture // 15 because 0th texture is our texture
@ -344,7 +345,8 @@ protected:
FTextureID id; FTextureID id;
FMaterial *Material[2] = { nullptr, nullptr }; FMaterial *Material[2] = { nullptr, nullptr };
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; FHardwareTextureContainer SystemTextures;
//IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
FSoftwareTexture *SoftwareTexture = nullptr; FSoftwareTexture *SoftwareTexture = nullptr;
// None of the following pointers are owned by this texture, they are all controlled by the texture manager. // None of the following pointers are owned by this texture, they are all controlled by the texture manager.
@ -710,9 +712,9 @@ class FWrapperTexture : public FTexture
int Format; int Format;
public: public:
FWrapperTexture(int w, int h, int bits = 1); FWrapperTexture(int w, int h, int bits = 1);
IHardwareTexture *GetSystemTexture(int slot) IHardwareTexture *GetSystemTexture()
{ {
return SystemTexture[slot]; return SystemTextures.GetHardwareTexture(0, false);
} }
int GetColorFormat() const int GetColorFormat() const