fixed textures overlapping
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <draw_buffers.h>
|
||||
#include <vector>
|
||||
#include "renderer/core/texture/models/texture.hpp"
|
||||
#include "./renderer_texture_cm_analysis.hpp"
|
||||
#include "../renderer_core_texture_buffers.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class RendererTextureCacheManager {
|
||||
public:
|
||||
RendererTextureCacheManager();
|
||||
~RendererTextureCacheManager();
|
||||
|
||||
void onFrameChange();
|
||||
|
||||
void addRequestedTexture(Texture* texture);
|
||||
|
||||
u32 getTextureIdToDealloc(
|
||||
const std::vector<RendererCoreTextureBuffers>& currentAllocs);
|
||||
|
||||
private:
|
||||
RendererTextureCMAnalysis statistics;
|
||||
|
||||
void tryAddIdThatNotExistInAnalysis(
|
||||
std::vector<u32>* result,
|
||||
const std::vector<RendererCoreTextureBuffers>& currentAllocs,
|
||||
const std::vector<u32>& analysis);
|
||||
|
||||
void addIdThatExistInAnalysisButIsOnTheBottom(
|
||||
std::vector<u32>* result,
|
||||
const std::vector<RendererCoreTextureBuffers>& currentAllocs,
|
||||
const std::vector<u32>& analysis);
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include "debug/debug.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
struct RendererTextureCMAnalysisWeight {
|
||||
u32 id;
|
||||
u16 weight;
|
||||
};
|
||||
|
||||
struct RendererTextureCMAnalysisOccurence {
|
||||
u32 id;
|
||||
u8 occurence;
|
||||
};
|
||||
|
||||
class RendererTextureCMAnalysis {
|
||||
public:
|
||||
RendererTextureCMAnalysis();
|
||||
~RendererTextureCMAnalysis();
|
||||
|
||||
void changeFrame();
|
||||
|
||||
void addNewRequest(const u32& id);
|
||||
|
||||
/**
|
||||
* @brief Returns top list (from most used to least used) of textures to be
|
||||
* deallocated.
|
||||
*
|
||||
* @param count Number of textures to be returned.
|
||||
*/
|
||||
std::vector<u32> getTopTextureIdsForNextChanges(const u8& count);
|
||||
|
||||
bool isReady();
|
||||
|
||||
bool isProbablyNotCorrect();
|
||||
|
||||
private:
|
||||
std::vector<u32>*current, *last;
|
||||
std::vector<u32> buffers[2];
|
||||
u32 currentIndex;
|
||||
|
||||
void flipBuffers();
|
||||
|
||||
std::vector<u32> getNextTextureIds(const u8& count);
|
||||
|
||||
std::vector<RendererTextureCMAnalysisOccurence> getOccurencesForTextureIds(
|
||||
const std::vector<u32>& textureIds);
|
||||
|
||||
std::vector<u32> getTextureIdsUnique(const std::vector<u32>& textureIds);
|
||||
|
||||
std::vector<RendererTextureCMAnalysisWeight> getWeights(
|
||||
const std::vector<u32>& uniqueTexIds,
|
||||
const std::vector<RendererTextureCMAnalysisOccurence>& occurencies);
|
||||
|
||||
std::vector<u32> weightsToResult(
|
||||
std::vector<RendererTextureCMAnalysisWeight>* weights);
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -47,7 +47,7 @@ class Texture {
|
||||
|
||||
const TextureData& getCoreData() const { return *core; }
|
||||
|
||||
TextureData* getClutData() { return clut; }
|
||||
const TextureData* getClutData() const { return clut; }
|
||||
|
||||
/**
|
||||
* Get texture name.
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "./texture_repository.hpp"
|
||||
#include "./renderer_core_texture_sender.hpp"
|
||||
#include "renderer/core/paths/path3/path3.hpp"
|
||||
#include "./cache_manager/renderer_texture_cache_manager.hpp"
|
||||
#include "./renderer_core_texture_buffers.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
@@ -33,14 +32,10 @@ class RendererCoreTexture {
|
||||
/** Called by renderer during initialization */
|
||||
void init(RendererCoreGS* gs, Path3* path3);
|
||||
|
||||
/** Called by renderer during beginFrame() */
|
||||
void onFrameChange();
|
||||
|
||||
/** Called by renderer during rendering */
|
||||
void updateClutBuffer(texbuffer_t* clutBuffer);
|
||||
|
||||
private:
|
||||
RendererTextureCacheManager cacheManager;
|
||||
std::vector<RendererCoreTextureBuffers> currentAllocations;
|
||||
|
||||
void initClut();
|
||||
@@ -48,6 +43,7 @@ class RendererCoreTexture {
|
||||
void unregisterAllocation(const u32& textureId);
|
||||
RendererCoreTextureBuffers getAllocatedBuffersByTextureId(const u32& id);
|
||||
|
||||
RendererCoreGS* gs;
|
||||
RendererCoreTextureSender sender;
|
||||
Path3* path3;
|
||||
};
|
||||
|
||||
@@ -31,19 +31,14 @@ class RendererCoreTextureSender {
|
||||
|
||||
void deallocate(const RendererCoreTextureBuffers& texBuffers);
|
||||
|
||||
float getFreeVRamInMB();
|
||||
|
||||
float getSizeInMB(texbuffer_t* texBuffer);
|
||||
|
||||
private:
|
||||
float allocatedVRamMemForTextures;
|
||||
RendererCoreGS* gs;
|
||||
Path3* path3;
|
||||
TextureBpp getBppByPsm(const u32& psm);
|
||||
texbuffer_t* allocateTextureCore(Texture* t_texture);
|
||||
texbuffer_t* allocateTextureClut(Texture* t_texture);
|
||||
|
||||
u8 isTextureVRAMAllocated, isVSyncEnabled;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
Reference in New Issue
Block a user