TextureCacheBase: Add XFB specific functions

This commit is contained in:
iwubcode
2017-09-29 00:32:04 -05:00
parent 4964fc87ae
commit 74610646ce
3 changed files with 433 additions and 1 deletions

View File

@ -8,6 +8,8 @@
#include <bitset>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
@ -64,6 +66,44 @@ struct EFBCopyParams
float y_scale;
};
struct TextureLookupInformation
{
u32 address;
u32 block_width;
u32 block_height;
u32 bytes_per_block;
u32 expanded_width;
u32 expanded_height;
u32 native_width;
u32 native_height;
u32 total_bytes;
u32 native_levels = 1;
u32 computed_levels;
u64 base_hash;
u64 full_hash;
TextureAndTLUTFormat full_format;
u32 tlut_address = 0;
bool is_palette_texture = false;
u32 palette_size = 0;
bool use_mipmaps = false;
bool from_tmem = false;
u32 tmem_address_even = 0;
u32 tmem_address_odd = 0;
int texture_cache_safety_color_sample_size = 0; // Default to safe hashing
u8* src_data;
std::string dump_base_name;
};
class TextureCacheBase
{
private:
@ -92,6 +132,8 @@ public:
float gamma = 1.0f;
u64 id;
bool reference_changed = false; // used by xfb to determine when a reference xfb changed
unsigned int native_width,
native_height; // Texture dimensions from the GameCube's point of view
unsigned int native_levels;
@ -190,6 +232,16 @@ public:
TLUTFormat tlutfmt = TLUTFormat::IA8, bool use_mipmaps = false,
u32 tex_levels = 1, bool from_tmem = false, u32 tmem_address_even = 0,
u32 tmem_address_odd = 0);
TCacheEntry* GetXFBTexture(u32 address, u32 width, u32 height, TextureFormat texformat,
int textureCacheSafetyColorSampleSize);
std::optional<TextureLookupInformation> ComputeTextureInformation(u32 address, u32 width, u32 height, TextureFormat texformat,
int textureCacheSafetyColorSampleSize, bool from_tmem, u32 tmem_address_even, u32 tmem_address_odd, u32 tlutaddr, TLUTFormat tlutfmt, u32 levels);
TCacheEntry* GetXFBFromCache(const TextureLookupInformation& tex_info);
bool LoadTextureFromOverlappingTextures(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info);
TCacheEntry* CreateNormalTexture(const TextureLookupInformation& tex_info);
void LoadTextureFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info);
void LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_update, const TextureLookupInformation& tex_info, bool decode_on_gpu);
virtual void BindTextures();
void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride,
bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity,