fixed textures overlapping

This commit is contained in:
h4570
2022-07-29 19:04:55 +02:00
parent 7ec6bb71b8
commit 97946e1c6d
16 changed files with 221 additions and 434 deletions
@@ -11,6 +11,7 @@
#pragma once
#include "renderer/renderer_settings.hpp"
#include "./renderer_core_gs_vram.hpp"
namespace Tyra {
@@ -22,23 +23,16 @@ class RendererCoreGS {
prim_t prim;
lod_t lod;
zbuffer_t zBuffer;
RendererCoreGSVRam vram;
void init(RendererSettings* settings);
void flipBuffers();
float getVRamFreeSpaceInMB() const {
return 4.0F - spaceOccupiedByFrameBuffers - spaceOccupiedByZBuffer -
vramMargin;
}
private:
constexpr static float gsCenter = 4096.0F;
constexpr static float screenCenter = gsCenter / 2.0F;
constexpr static float vramMargin =
0.003F; // We don't have perfectly 4MB of VRAM
float spaceOccupiedByFrameBuffers, spaceOccupiedByZBuffer;
RendererSettings* settings;
framebuffer_t frameBuffers[2];
packet2_t* flipPacket;
@@ -0,0 +1,49 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "renderer/renderer_settings.hpp"
#include "renderer/core/texture/models/texture.hpp"
namespace Tyra {
class RendererCoreGSVRam {
public:
RendererCoreGSVRam();
~RendererCoreGSVRam();
const float& getFreeSpaceInMB();
float getSizeInMB(const Texture& texture);
float getSizeInMB(const TextureData& texData);
float getSizeInMB(int width, const int& height, const int& psm,
const int& alignment);
int allocate(const TextureData& texData);
int allocateBuffer(const int& width, const int& height, const int& psm);
/** Free texture, FIFO order */
void free(const int& address);
private:
int allocate(const int& width, const int& height, const int& psm,
const int& alignment);
int getSize(int width, const int& height, const int& psm,
const int& alignment);
static constexpr float ptr2MB = 262144.0F;
bool touched;
int pointer;
float cachedFreeSpace;
};
} // namespace Tyra