temporary fix for texture system

This commit is contained in:
h4570
2022-07-28 23:54:53 +02:00
parent 19e99eee56
commit 7ec6bb71b8
3 changed files with 17 additions and 8 deletions
@@ -14,29 +14,23 @@ namespace Tyra {
enum TextureBpp { enum TextureBpp {
// Tyra has 2.27MB~ free VRAM for textures.
/** /**
* @brief 32-bit RGBA - Slowest * @brief 32-bit RGBA - Slowest
* Tyra can cache about 8~ of these textures (256x256)
*/ */
bpp32 = 32, bpp32 = 32,
/** /**
* @brief 24-bit RGB - Slow * @brief 24-bit RGB - Slow
* Tyra can cache about 11~ of these textures (256x256)
*/ */
bpp24 = 24, bpp24 = 24,
/** /**
* @brief 8-bit palletized (indexed) - Super fast * @brief 8-bit palletized (indexed) - Super fast
* Tyra can cache about 34~ of these textures (256x256)
*/ */
bpp8 = 8, bpp8 = 8,
/** /**
* @brief 4-bit palletized (indexed) - Super, super fast * @brief 4-bit palletized (indexed) - Super, super fast
* Tyra can cache about 69~ of these textures (256x256)
*/ */
bpp4 = 4, bpp4 = 4,
}; };
@@ -12,6 +12,7 @@
#include <draw_buffers.h> #include <draw_buffers.h>
#include <gs_psm.h> #include <gs_psm.h>
#include <stdlib.h> #include <stdlib.h>
#include <fastmath.h>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "renderer/core/texture/models/texture.hpp" #include "renderer/core/texture/models/texture.hpp"
@@ -23,6 +24,19 @@ Texture::Texture(TextureBuilderData* t_data) {
name = t_data->name; name = t_data->name;
TYRA_ASSERT(t_data->width <= 256 && t_data->height <= 256,
"Tyra supports only 256x256 textures max!");
TYRA_ASSERT(t_data->width == 8 || t_data->width == 16 ||
t_data->width == 32 || t_data->width == 64 ||
t_data->width == 128 || t_data->width == 256,
"Texture width/height should be 8/16/32/64/128/256!");
TYRA_ASSERT(t_data->height == 8 || t_data->height == 16 ||
t_data->height == 32 || t_data->height == 64 ||
t_data->height == 128 || t_data->height == 256,
"Texture width/height should be 8/16/32/64/128/256!");
core = new TextureData(t_data->data, t_data->bpp, t_data->gsComponents, core = new TextureData(t_data->data, t_data->bpp, t_data->gsComponents,
t_data->width, t_data->height); t_data->width, t_data->height);
@@ -44,8 +44,9 @@ RendererCoreTextureBuffers RendererCoreTexture::useTexture(Texture* t_tex) {
auto allocated = getAllocatedBuffersByTextureId(t_tex->getId()); auto allocated = getAllocatedBuffersByTextureId(t_tex->getId());
if (allocated.id != 0) return allocated; if (allocated.id != 0) return allocated;
// TODO: Dont like this..., but it works for now. // TODO: FIXME!
if (t_tex->getSizeInMB() > sender.getFreeVRamInMB()) { if (currentAllocations.size()) {
// if (t_tex->getSizeInMB() > sender.getFreeVRamInMB()) {
for (int i = currentAllocations.size() - 1; i >= 0; i--) { for (int i = currentAllocations.size() - 1; i >= 0; i--) {
sender.deallocate(currentAllocations[i]); sender.deallocate(currentAllocations[i]);
} }