mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 00:21:34 +00:00
- remove the old incomplete VkHardwareTexture implementation
This commit is contained in:
parent
40ee32a0ce
commit
2429eba8f6
2 changed files with 0 additions and 261 deletions
|
@ -346,200 +346,3 @@ void VkHardwareTexture::CreateWipeTexture(int w, int h, const char *name)
|
|||
|
||||
fb->GetPostprocess()->BlitCurrentToImage(mImage.get(), &mImageLayout);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Creates the low level texture object
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
VkResult VkHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, bool mipmap, int translation)
|
||||
{
|
||||
int rh,rw;
|
||||
bool deletebuffer=false;
|
||||
auto tTex = GetTexID(translation);
|
||||
|
||||
// We cannot determine if the old texture is still needed, so if something is trying to recreate a still existing texture this must fail.
|
||||
// Normally it should never occur that a texture needs to be recreated in the middle of a frame.
|
||||
if (tTex->vkTexture != nullptr) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
tTex->vkTexture = new VkTexture(vDevice);;
|
||||
|
||||
rw = vDevice->GetTexDimension(w);
|
||||
rh = vDevice->GetTexDimension(h);
|
||||
if (rw < w || rh < h)
|
||||
{
|
||||
// The texture is larger than what the hardware can handle so scale it down.
|
||||
unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1));
|
||||
if (scaledbuffer)
|
||||
{
|
||||
ResizeTexture(w, h, rw, rh, buffer, scaledbuffer);
|
||||
deletebuffer=true;
|
||||
buffer=scaledbuffer;
|
||||
}
|
||||
}
|
||||
|
||||
auto res = tTex->vkTexture->Create(buffer, w, h, mipmap, vkTextureBytes);
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
delete tTex->vkTexture;
|
||||
tTex->vkTexture = nullptr;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Creates a texture
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
VkHardwareTexture::VkHardwareTexture(VulkanDevice *dev, bool nocompression)
|
||||
{
|
||||
forcenocompression = nocompression;
|
||||
|
||||
vkDefTex.vkTexture = nullptr;
|
||||
vkDefTex.translation = 0;
|
||||
vkDefTex.mipmapped = false;
|
||||
vDevice = dev;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes a texture id and unbinds it from the texture units
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void VkHardwareTexture::TranslatedTexture::Delete()
|
||||
{
|
||||
if (vkTexture != nullptr)
|
||||
{
|
||||
delete vkTexture;
|
||||
vkTexture = nullptr;
|
||||
mipmapped = false;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Frees all associated resources
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void VkHardwareTexture::Clean(bool all)
|
||||
{
|
||||
int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size();
|
||||
|
||||
if (all)
|
||||
{
|
||||
vkDefTex.Delete();
|
||||
}
|
||||
for(unsigned int i=0;i<vkTex_Translated.Size();i++)
|
||||
{
|
||||
vkTex_Translated[i].Delete();
|
||||
}
|
||||
vkTex_Translated.Clear();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes all allocated resources and considers translations
|
||||
// This will only be called for sprites
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void VkHardwareTexture::CleanUnused(SpriteHits &usedtranslations)
|
||||
{
|
||||
if (usedtranslations.CheckKey(0) == nullptr)
|
||||
{
|
||||
vkDefTex.Delete();
|
||||
}
|
||||
for (int i = vkTex_Translated.Size()-1; i>= 0; i--)
|
||||
{
|
||||
if (usedtranslations.CheckKey(vkTex_Translated[i].translation) == nullptr)
|
||||
{
|
||||
vkTex_Translated[i].Delete();
|
||||
vkTex_Translated.Delete(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Destroys the texture
|
||||
//
|
||||
//===========================================================================
|
||||
VkHardwareTexture::~VkHardwareTexture()
|
||||
{
|
||||
Clean(true);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Gets a texture ID address and validates all required data
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
VkHardwareTexture::TranslatedTexture *VkHardwareTexture::GetTexID(int translation)
|
||||
{
|
||||
if (translation == 0)
|
||||
{
|
||||
return &vkDefTex;
|
||||
}
|
||||
|
||||
// normally there aren't more than very few different
|
||||
// translations here so this isn't performance critical.
|
||||
// Maps only start to pay off for larger amounts of elements.
|
||||
for (auto &tex : vkTex_Translated)
|
||||
{
|
||||
if (tex.translation == translation)
|
||||
{
|
||||
return &tex;
|
||||
}
|
||||
}
|
||||
|
||||
int add = vkTex_Translated.Reserve(1);
|
||||
vkTex_Translated[add].translation = translation;
|
||||
vkTex_Translated[add].vkTexture = nullptr;
|
||||
vkTex_Translated[add].mipmapped = false;
|
||||
return &vkTex_Translated[add];
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
VkTexture *VkHardwareTexture::GetVkTexture(FTexture *tex, int translation, bool needmipmap, int flags)
|
||||
{
|
||||
int usebright = false;
|
||||
|
||||
if (translation <= 0)
|
||||
{
|
||||
translation = -translation;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto remap = TranslationToTable(translation);
|
||||
translation = remap == nullptr ? 0 : remap->GetUniqueIndex();
|
||||
}
|
||||
|
||||
TranslatedTexture *pTex = GetTexID(translation);
|
||||
|
||||
if (pTex->vkTexture == nullptr)
|
||||
{
|
||||
int w, h;
|
||||
auto buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData);
|
||||
auto res = CreateTexture(buffer, w, h, needmipmap, translation);
|
||||
delete[] buffer;
|
||||
}
|
||||
return pTex->vkTexture;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -65,67 +65,3 @@ private:
|
|||
VkImageLayout mImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
int mTexelsize = 4;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
class FCanvasTexture;
|
||||
class AActor;
|
||||
class VkTexture;
|
||||
class VkRenderTexture;
|
||||
class VulkanDevice;
|
||||
|
||||
class VkHardwareTexture : public IHardwareTexture
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_TEXTURES = 16
|
||||
};
|
||||
|
||||
private:
|
||||
struct TranslatedTexture
|
||||
{
|
||||
VkTexture *vkTexture;
|
||||
int translation;
|
||||
bool mipmapped;
|
||||
|
||||
void Delete();
|
||||
};
|
||||
|
||||
VulkanDevice *vDevice;
|
||||
|
||||
private:
|
||||
|
||||
bool forcenocompression;
|
||||
|
||||
TranslatedTexture vkDefTex;
|
||||
TArray<TranslatedTexture> vkTex_Translated;
|
||||
|
||||
int vkTextureBytes = 4;
|
||||
|
||||
TranslatedTexture * GetTexID(int translation);
|
||||
|
||||
public:
|
||||
VkHardwareTexture(VulkanDevice *dev, bool nocompress);
|
||||
~VkHardwareTexture();
|
||||
|
||||
//static void Unbind(int texunit);
|
||||
//static void UnbindAll();
|
||||
|
||||
//void BindToFrameBuffer(int w, int h);
|
||||
|
||||
//unsigned int Bind(int texunit, int translation, bool needmipmap);
|
||||
//bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags);
|
||||
|
||||
//void AllocateBuffer(int w, int h, int texelsize);
|
||||
//uint8_t *MapBuffer();
|
||||
|
||||
VkResult CreateTexture(unsigned char * buffer, int w, int h, bool mipmap, int translation);
|
||||
|
||||
void Clean(bool all);
|
||||
void CleanUnused(SpriteHits &usedtranslations);
|
||||
|
||||
VkTexture *GetVkTexture(FTexture *tex, int translation, bool needmipmap, int flags);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue