From 7c1ab0bfaa9a2ea955caa778bea01d0bd8c53d09 Mon Sep 17 00:00:00 2001 From: h4570 Date: Sun, 24 Jul 2022 23:03:06 +0200 Subject: [PATCH] texture allocation bugfix --- .../texture/renderer_core_texture_sender.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/engine/src/renderer/core/texture/renderer_core_texture_sender.cpp b/engine/src/renderer/core/texture/renderer_core_texture_sender.cpp index ca2df10..7e47a1c 100644 --- a/engine/src/renderer/core/texture/renderer_core_texture_sender.cpp +++ b/engine/src/renderer/core/texture/renderer_core_texture_sender.cpp @@ -30,7 +30,8 @@ RendererCoreTextureBuffers RendererCoreTextureSender::allocate( texbuffer_t* core = allocateTextureCore(t_texture); texbuffer_t* clut = nullptr; - if (t_texture->getClutData() != nullptr) { + auto texClut = t_texture->getClutData(); + if (texClut != nullptr && texClut->width + texClut->height > 0) { clut = allocateTextureClut(t_texture); } return {t_texture->getId(), core, clut}; @@ -66,12 +67,11 @@ texbuffer_t* RendererCoreTextureSender::allocateTextureCore( TYRA_ASSERT(t_texture->getSizeInMB() <= getFreeVRamInMB(), "Not enough VRAM memory for texture!"); - result->address = + auto address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), result->psm, GRAPH_ALIGN_BLOCK); - - TYRA_ASSERT(result->address > 0, - "Texture buffer allocation error. No memory!"); + TYRA_ASSERT(address > 0, "Texture buffer allocation error, no memory!"); + result->address = address; allocatedVRamMemForTextures += t_texture->getSizeInMB(); result->info.width = draw_log2(t_texture->getWidth()); @@ -89,8 +89,10 @@ texbuffer_t* RendererCoreTextureSender::allocateTextureClut( result->psm = clut->psm; result->info.components = clut->components; - result->address = graph_vram_allocate(clut->width, clut->height, result->psm, - GRAPH_ALIGN_BLOCK); + auto address = graph_vram_allocate(clut->width, clut->height, result->psm, + GRAPH_ALIGN_BLOCK); + TYRA_ASSERT(address > 0, "Texture clut buffer allocation error, no memory!"); + result->address = address; result->info.width = draw_log2(clut->width); result->info.height = draw_log2(clut->height);