2014-09-13 11:15:18 +00:00
|
|
|
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-01-09 22:27:53 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2017-02-19 23:45:07 +00:00
|
|
|
#include <memory>
|
2016-01-09 22:27:53 +00:00
|
|
|
|
2014-09-13 11:15:18 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-01-09 22:27:53 +00:00
|
|
|
#include "Common/MemoryUtil.h"
|
2016-04-30 22:07:56 +00:00
|
|
|
#include "Core/TextureReplacer.h"
|
2017-02-14 15:56:53 +00:00
|
|
|
#include "Core/System.h"
|
2016-04-30 20:44:31 +00:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2017-02-08 14:24:27 +00:00
|
|
|
#include "GPU/Common/TextureDecoder.h"
|
2014-09-13 11:15:18 +00:00
|
|
|
|
2015-03-16 02:25:34 +00:00
|
|
|
enum TextureFiltering {
|
|
|
|
TEX_FILTER_AUTO = 1,
|
|
|
|
TEX_FILTER_NEAREST = 2,
|
|
|
|
TEX_FILTER_LINEAR = 3,
|
|
|
|
TEX_FILTER_LINEAR_VIDEO = 4,
|
|
|
|
};
|
|
|
|
|
2015-11-28 20:41:37 +00:00
|
|
|
enum FramebufferNotification {
|
|
|
|
NOTIFY_FB_CREATED,
|
|
|
|
NOTIFY_FB_UPDATED,
|
|
|
|
NOTIFY_FB_DESTROYED,
|
|
|
|
};
|
|
|
|
|
2017-02-08 14:24:27 +00:00
|
|
|
// Changes more frequent than this will be considered "frequent" and prevent texture scaling.
|
|
|
|
#define TEXCACHE_FRAME_CHANGE_FREQUENT 6
|
|
|
|
// Note: only used when hash backoff is disabled.
|
|
|
|
#define TEXCACHE_FRAME_CHANGE_FREQUENT_REGAIN_TRUST 33
|
|
|
|
|
2017-02-19 22:39:35 +00:00
|
|
|
#define TEXCACHE_MAX_TEXELS_SCALED (256*256) // Per frame
|
|
|
|
|
2015-03-16 02:46:36 +00:00
|
|
|
struct VirtualFramebuffer;
|
|
|
|
|
2017-02-05 18:51:50 +00:00
|
|
|
namespace Draw {
|
|
|
|
class DrawContext;
|
|
|
|
}
|
|
|
|
|
2017-02-08 17:07:34 +00:00
|
|
|
// Used by D3D11 and Vulkan, could be used by modern GL
|
|
|
|
struct SamplerCacheKey {
|
|
|
|
union {
|
2017-11-14 14:56:05 +00:00
|
|
|
uint64_t fullKey;
|
2017-02-08 17:07:34 +00:00
|
|
|
struct {
|
2017-11-14 14:56:05 +00:00
|
|
|
// These are 8.8 fixed point.
|
|
|
|
int16_t maxLevel;
|
|
|
|
int16_t minLevel;
|
|
|
|
int16_t lodBias;
|
|
|
|
|
2017-02-08 17:07:34 +00:00
|
|
|
bool mipEnable : 1;
|
|
|
|
bool minFilt : 1;
|
|
|
|
bool mipFilt : 1;
|
|
|
|
bool magFilt : 1;
|
|
|
|
bool sClamp : 1;
|
|
|
|
bool tClamp : 1;
|
2017-11-15 18:07:41 +00:00
|
|
|
bool aniso : 1;
|
2017-02-08 17:07:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
bool operator < (const SamplerCacheKey &other) const {
|
|
|
|
return fullKey < other.fullKey;
|
|
|
|
}
|
2017-12-06 15:01:56 +00:00
|
|
|
void ToString(std::string *str) const {
|
|
|
|
str->resize(sizeof(*this));
|
|
|
|
memcpy(&(*str)[0], this, sizeof(*this));
|
|
|
|
}
|
|
|
|
void FromString(const std::string &str) {
|
|
|
|
memcpy(this, &str[0], sizeof(*this));
|
|
|
|
}
|
2017-02-08 17:07:34 +00:00
|
|
|
};
|
|
|
|
|
2017-11-19 16:37:56 +00:00
|
|
|
class GLRTexture;
|
2018-04-05 21:23:14 +00:00
|
|
|
class VulkanTexture;
|
2017-11-19 16:37:56 +00:00
|
|
|
|
2017-02-20 20:35:34 +00:00
|
|
|
// TODO: Shrink this struct. There is some fluff.
|
2017-02-19 17:53:30 +00:00
|
|
|
struct TexCacheEntry {
|
2017-02-20 20:35:34 +00:00
|
|
|
~TexCacheEntry() {
|
|
|
|
if (texturePtr || textureName || vkTex)
|
|
|
|
Crash();
|
|
|
|
}
|
2017-02-19 17:53:30 +00:00
|
|
|
// After marking STATUS_UNRELIABLE, if it stays the same this many frames we'll trust it again.
|
|
|
|
const static int FRAMES_REGAIN_TRUST = 1000;
|
|
|
|
|
2017-12-13 22:11:40 +00:00
|
|
|
enum TexStatus {
|
2017-02-19 17:53:30 +00:00
|
|
|
STATUS_HASHING = 0x00,
|
|
|
|
STATUS_RELIABLE = 0x01, // Don't bother rehashing.
|
|
|
|
STATUS_UNRELIABLE = 0x02, // Always recheck hash.
|
|
|
|
STATUS_MASK = 0x03,
|
|
|
|
|
|
|
|
STATUS_ALPHA_UNKNOWN = 0x04,
|
|
|
|
STATUS_ALPHA_FULL = 0x00, // Has no alpha channel, or always full alpha.
|
2017-11-13 00:10:53 +00:00
|
|
|
STATUS_ALPHA_MASK = 0x04,
|
|
|
|
|
2018-02-18 20:26:00 +00:00
|
|
|
STATUS_CLUT_VARIANTS = 0x08, // Has multiple CLUT variants.
|
2017-02-19 17:53:30 +00:00
|
|
|
STATUS_CHANGE_FREQUENT = 0x10, // Changes often (less than 6 frames in between.)
|
|
|
|
STATUS_CLUT_RECHECK = 0x20, // Another texture with same addr had a hashfail.
|
|
|
|
STATUS_DEPALETTIZE = 0x40, // Needs to go through a depalettize pass.
|
|
|
|
STATUS_TO_SCALE = 0x80, // Pending texture scaling in a later frame.
|
|
|
|
STATUS_IS_SCALED = 0x100, // Has been scaled (can't be replaceImages'd.)
|
2017-03-18 19:08:06 +00:00
|
|
|
// When hashing large textures, we optimize 512x512 down to 512x272 by default, since this
|
|
|
|
// is commonly the only part accessed. If access is made above 272, we hash the entire
|
|
|
|
// texture, and set this flag to allow scaling the texture just once for the new hash.
|
2017-02-19 17:53:30 +00:00
|
|
|
STATUS_FREE_CHANGE = 0x200, // Allow one change before marking "frequent".
|
2017-06-01 04:23:20 +00:00
|
|
|
|
|
|
|
STATUS_BAD_MIPS = 0x400, // Has bad or unusable mipmap levels.
|
2017-02-19 17:53:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Status, but int so we can zero initialize.
|
|
|
|
int status;
|
|
|
|
u32 addr;
|
|
|
|
u32 hash;
|
2017-02-20 20:35:34 +00:00
|
|
|
VirtualFramebuffer *framebuffer; // if null, not sourced from an FBO. TODO: Collapse into texturePtr
|
|
|
|
u32 sizeInRAM; // Could be computed
|
2017-02-19 17:53:30 +00:00
|
|
|
u8 format;
|
|
|
|
u8 maxLevel;
|
|
|
|
u16 dim;
|
|
|
|
u16 bufw;
|
|
|
|
union {
|
2017-11-19 16:37:56 +00:00
|
|
|
GLRTexture *textureName;
|
2017-02-19 17:53:30 +00:00
|
|
|
void *texturePtr;
|
2018-04-05 21:23:14 +00:00
|
|
|
VulkanTexture *vkTex;
|
2017-02-19 17:53:30 +00:00
|
|
|
};
|
|
|
|
#ifdef _WIN32
|
|
|
|
void *textureView; // Used by D3D11 only for the shader resource view.
|
|
|
|
#endif
|
|
|
|
int invalidHint;
|
2017-02-20 20:35:34 +00:00
|
|
|
int lastFrame;
|
|
|
|
int numFrames;
|
|
|
|
int numInvalidated;
|
|
|
|
u32 framesUntilNextFullHash;
|
2017-02-19 17:53:30 +00:00
|
|
|
u32 fullhash;
|
|
|
|
u32 cluthash;
|
|
|
|
u16 maxSeenV;
|
|
|
|
|
2017-12-13 22:11:40 +00:00
|
|
|
TexStatus GetHashStatus() {
|
|
|
|
return TexStatus(status & STATUS_MASK);
|
2017-02-19 17:53:30 +00:00
|
|
|
}
|
2017-12-13 22:11:40 +00:00
|
|
|
void SetHashStatus(TexStatus newStatus) {
|
2017-02-19 17:53:30 +00:00
|
|
|
status = (status & ~STATUS_MASK) | newStatus;
|
|
|
|
}
|
2017-12-13 22:11:40 +00:00
|
|
|
TexStatus GetAlphaStatus() {
|
|
|
|
return TexStatus(status & STATUS_ALPHA_MASK);
|
2017-02-19 17:53:30 +00:00
|
|
|
}
|
2017-12-13 22:11:40 +00:00
|
|
|
void SetAlphaStatus(TexStatus newStatus) {
|
2017-02-19 17:53:30 +00:00
|
|
|
status = (status & ~STATUS_ALPHA_MASK) | newStatus;
|
|
|
|
}
|
2017-12-13 22:11:40 +00:00
|
|
|
void SetAlphaStatus(TexStatus newStatus, int level) {
|
2017-02-19 17:53:30 +00:00
|
|
|
// For non-level zero, only set more restrictive.
|
|
|
|
if (newStatus == STATUS_ALPHA_UNKNOWN || level == 0) {
|
|
|
|
SetAlphaStatus(newStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Matches(u16 dim2, u8 format2, u8 maxLevel2) const;
|
|
|
|
u64 CacheKey() const;
|
|
|
|
static u64 CacheKey(u32 addr, u8 format, u16 dim, u32 cluthash);
|
|
|
|
};
|
|
|
|
|
2017-02-08 14:58:46 +00:00
|
|
|
class FramebufferManagerCommon;
|
2017-02-19 21:50:04 +00:00
|
|
|
// Can't be unordered_map, we use lower_bound ... although for some reason that compiles on MSVC.
|
2017-08-20 17:03:16 +00:00
|
|
|
// Would really like to replace this with DenseHashMap but can't as long as we need lower_bound.
|
2017-02-19 23:45:07 +00:00
|
|
|
typedef std::map<u64, std::unique_ptr<TexCacheEntry>> TexCache;
|
2017-02-08 14:58:46 +00:00
|
|
|
|
2014-09-13 11:15:18 +00:00
|
|
|
class TextureCacheCommon {
|
|
|
|
public:
|
2017-02-05 18:51:50 +00:00
|
|
|
TextureCacheCommon(Draw::DrawContext *draw);
|
2014-09-13 11:15:18 +00:00
|
|
|
virtual ~TextureCacheCommon();
|
|
|
|
|
2015-11-28 20:41:37 +00:00
|
|
|
void LoadClut(u32 clutAddr, u32 loadBytes);
|
2016-01-10 17:25:19 +00:00
|
|
|
bool GetCurrentClutBuffer(GPUDebugBuffer &buffer);
|
2015-11-28 20:41:37 +00:00
|
|
|
|
2017-02-19 23:05:23 +00:00
|
|
|
void SetTexture(bool force = false);
|
2017-02-19 22:25:09 +00:00
|
|
|
void ApplyTexture();
|
2017-02-08 14:48:36 +00:00
|
|
|
bool SetOffsetTexture(u32 offset);
|
2017-02-08 14:24:33 +00:00
|
|
|
void Invalidate(u32 addr, int size, GPUInvalidationType type);
|
|
|
|
void InvalidateAll(GPUInvalidationType type);
|
|
|
|
void ClearNextFrame();
|
2017-02-19 22:07:00 +00:00
|
|
|
|
2017-02-06 23:24:38 +00:00
|
|
|
virtual void ForgetLastTexture() = 0;
|
2017-02-19 23:13:09 +00:00
|
|
|
virtual void InvalidateLastTexture(TexCacheEntry *entry = nullptr) = 0;
|
2017-02-19 21:31:07 +00:00
|
|
|
virtual void Clear(bool delete_them);
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-11-28 20:41:37 +00:00
|
|
|
// FramebufferManager keeps TextureCache updated about what regions of memory are being rendered to.
|
|
|
|
void NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffer, FramebufferNotification msg);
|
2016-01-04 07:06:15 +00:00
|
|
|
void NotifyConfigChanged();
|
2016-05-01 15:39:18 +00:00
|
|
|
void NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt);
|
2015-11-28 20:41:37 +00:00
|
|
|
|
2015-09-24 06:59:13 +00:00
|
|
|
int AttachedDrawingHeight();
|
|
|
|
|
2017-02-08 14:37:40 +00:00
|
|
|
size_t NumLoadedTextures() const {
|
2017-02-19 23:19:58 +00:00
|
|
|
return cache_.size();
|
2017-02-08 14:37:40 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 15:56:53 +00:00
|
|
|
bool IsFakeMipmapChange() {
|
|
|
|
return PSP_CoreParameter().compat.flags().FakeMipmapChange && gstate.getTexLevelMode() == GE_TEXLEVEL_MODE_CONST;
|
|
|
|
}
|
2017-09-13 04:42:47 +00:00
|
|
|
bool VideoIsPlaying() {
|
|
|
|
return !videos_.empty();
|
|
|
|
}
|
2017-03-06 15:46:15 +00:00
|
|
|
virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { return false; }
|
|
|
|
|
2015-03-16 02:25:34 +00:00
|
|
|
protected:
|
2017-02-19 22:07:00 +00:00
|
|
|
virtual void BindTexture(TexCacheEntry *entry) = 0;
|
2017-02-08 14:43:53 +00:00
|
|
|
virtual void Unbind() = 0;
|
2017-02-23 16:31:24 +00:00
|
|
|
virtual void ReleaseTexture(TexCacheEntry *entry, bool delete_them) = 0;
|
2017-02-19 21:50:04 +00:00
|
|
|
void DeleteTexture(TexCache::iterator it);
|
2018-04-07 04:25:35 +00:00
|
|
|
void Decimate(bool forcePressure = false);
|
2017-02-08 14:43:53 +00:00
|
|
|
|
2017-02-19 22:25:09 +00:00
|
|
|
virtual void ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) = 0;
|
2018-03-25 08:49:28 +00:00
|
|
|
void HandleTextureChange(TexCacheEntry *const entry, const char *reason, bool initialMatch, bool doDelete);
|
|
|
|
virtual void BuildTexture(TexCacheEntry *const entry) = 0;
|
2017-02-19 23:05:23 +00:00
|
|
|
virtual void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) = 0;
|
2017-02-19 23:45:07 +00:00
|
|
|
bool CheckFullHash(TexCacheEntry *entry, bool &doDelete);
|
2017-02-08 14:24:27 +00:00
|
|
|
|
2016-06-19 14:14:31 +00:00
|
|
|
// Separate to keep main texture cache size down.
|
|
|
|
struct AttachedFramebufferInfo {
|
|
|
|
u32 xOffset;
|
|
|
|
u32 yOffset;
|
|
|
|
};
|
|
|
|
|
2017-02-22 16:26:52 +00:00
|
|
|
void DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA, bool expandTo32Bit);
|
2016-03-27 04:50:49 +00:00
|
|
|
void UnswizzleFromMem(u32 *dest, u32 destPitch, const u8 *texptr, u32 bufw, u32 height, u32 bytesPerPixel);
|
2017-02-22 16:26:52 +00:00
|
|
|
void ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw, bool expandTo32Bit);
|
2016-06-19 14:14:31 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline const T *GetCurrentClut() {
|
|
|
|
return (const T *)clutBuf_;
|
|
|
|
}
|
2015-11-29 01:51:15 +00:00
|
|
|
|
2016-03-26 18:49:16 +00:00
|
|
|
u32 EstimateTexMemoryUsage(const TexCacheEntry *entry);
|
2017-11-15 15:31:17 +00:00
|
|
|
void GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, int maxLevel, u32 addr, GETexLevelMode &mode);
|
2017-11-14 14:56:05 +00:00
|
|
|
void UpdateSamplingParams(TexCacheEntry &entry, SamplerCacheKey &key); // Used by D3D11 and Vulkan.
|
2016-05-01 18:17:55 +00:00
|
|
|
void UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode);
|
2015-09-24 06:59:13 +00:00
|
|
|
|
2017-02-08 14:37:40 +00:00
|
|
|
bool AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, u32 texaddrOffset = 0);
|
2016-06-19 14:14:31 +00:00
|
|
|
void AttachFramebufferValid(TexCacheEntry *entry, VirtualFramebuffer *framebuffer, const AttachedFramebufferInfo &fbInfo);
|
|
|
|
void AttachFramebufferInvalid(TexCacheEntry *entry, VirtualFramebuffer *framebuffer, const AttachedFramebufferInfo &fbInfo);
|
|
|
|
void DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer);
|
2015-11-28 20:41:37 +00:00
|
|
|
|
2017-02-08 14:43:53 +00:00
|
|
|
void SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer);
|
|
|
|
|
2016-05-01 15:39:18 +00:00
|
|
|
void DecimateVideos();
|
|
|
|
|
2017-02-19 13:33:59 +00:00
|
|
|
inline u32 QuickTexHash(TextureReplacer &replacer, u32 addr, int bufw, int w, int h, GETextureFormat format, TexCacheEntry *entry) const {
|
2017-02-08 14:24:27 +00:00
|
|
|
if (replacer.Enabled()) {
|
|
|
|
return replacer.ComputeHash(addr, bufw, w, h, format, entry->maxSeenV);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h == 512 && entry->maxSeenV < 512 && entry->maxSeenV != 0) {
|
|
|
|
h = (int)entry->maxSeenV;
|
|
|
|
}
|
|
|
|
|
|
|
|
const u32 sizeInRAM = (textureBitsPerPixel[format] * bufw * h) / 8;
|
|
|
|
const u32 *checkp = (const u32 *)Memory::GetPointer(addr);
|
|
|
|
|
|
|
|
if (Memory::IsValidAddress(addr + sizeInRAM)) {
|
|
|
|
return DoQuickTexHash(checkp, sizeInRAM);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-19 23:05:23 +00:00
|
|
|
static inline u32 MiniHash(const u32 *ptr) {
|
|
|
|
return ptr[0];
|
|
|
|
}
|
|
|
|
|
2017-02-05 18:51:50 +00:00
|
|
|
Draw::DrawContext *draw_;
|
2017-02-19 23:19:58 +00:00
|
|
|
TextureReplacer replacer_;
|
2017-02-08 14:58:46 +00:00
|
|
|
FramebufferManagerCommon *framebufferManager_;
|
2016-04-30 20:44:31 +00:00
|
|
|
|
2017-02-08 14:24:27 +00:00
|
|
|
bool clearCacheNextFrame_;
|
|
|
|
bool lowMemoryMode_;
|
|
|
|
|
2017-02-08 14:24:33 +00:00
|
|
|
int decimationCounter_;
|
|
|
|
int texelsScaledThisFrame_;
|
|
|
|
int timesInvalidatedAllThisFrame_;
|
|
|
|
|
2017-02-19 23:19:58 +00:00
|
|
|
TexCache cache_;
|
2016-03-26 18:49:16 +00:00
|
|
|
u32 cacheSizeEstimate_;
|
|
|
|
|
2017-02-19 23:19:58 +00:00
|
|
|
TexCache secondCache_;
|
2017-02-08 14:24:27 +00:00
|
|
|
u32 secondCacheSizeEstimate_;
|
|
|
|
|
2015-11-28 20:41:37 +00:00
|
|
|
std::vector<VirtualFramebuffer *> fbCache_;
|
2016-03-26 19:07:49 +00:00
|
|
|
std::map<u64, AttachedFramebufferInfo> fbTexInfo_;
|
2015-11-28 20:41:37 +00:00
|
|
|
|
2016-05-01 15:39:18 +00:00
|
|
|
std::map<u32, int> videos_;
|
|
|
|
|
2017-02-19 23:19:58 +00:00
|
|
|
SimpleBuf<u32> tmpTexBuf32_;
|
|
|
|
SimpleBuf<u16> tmpTexBuf16_;
|
|
|
|
SimpleBuf<u32> tmpTexBufRearrange_;
|
2015-11-29 01:51:15 +00:00
|
|
|
|
2015-09-24 06:59:13 +00:00
|
|
|
TexCacheEntry *nextTexture_;
|
2015-11-28 20:41:37 +00:00
|
|
|
|
2017-02-19 21:50:04 +00:00
|
|
|
u32 clutHash_ = 0;
|
|
|
|
|
2015-11-28 20:41:37 +00:00
|
|
|
// Raw is where we keep the original bytes. Converted is where we swap colors if necessary.
|
|
|
|
u32 *clutBufRaw_;
|
|
|
|
u32 *clutBufConverted_;
|
2016-06-19 14:14:31 +00:00
|
|
|
// This is the active one.
|
|
|
|
u32 *clutBuf_;
|
2015-11-28 20:41:37 +00:00
|
|
|
u32 clutLastFormat_;
|
|
|
|
u32 clutTotalBytes_;
|
|
|
|
u32 clutMaxBytes_;
|
|
|
|
u32 clutRenderAddress_;
|
2016-01-05 08:02:58 +00:00
|
|
|
u32 clutRenderOffset_;
|
2016-06-19 14:55:38 +00:00
|
|
|
// True if the clut is just alpha values in the same order (RGBA4444-bit only.)
|
|
|
|
bool clutAlphaLinear_;
|
|
|
|
u16 clutAlphaLinearColor_;
|
|
|
|
|
2016-01-04 07:06:15 +00:00
|
|
|
int standardScaleFactor_;
|
2017-02-08 14:37:40 +00:00
|
|
|
|
|
|
|
const char *nextChangeReason_;
|
|
|
|
bool nextNeedsRehash_;
|
|
|
|
bool nextNeedsChange_;
|
|
|
|
bool nextNeedsRebuild_;
|
2017-02-19 23:05:23 +00:00
|
|
|
|
|
|
|
bool isBgraBackend_;
|
2017-02-22 16:26:52 +00:00
|
|
|
|
|
|
|
u32 expandClut_[256];
|
2015-03-16 02:46:36 +00:00
|
|
|
};
|
|
|
|
|
2017-02-19 17:53:30 +00:00
|
|
|
inline bool TexCacheEntry::Matches(u16 dim2, u8 format2, u8 maxLevel2) const {
|
2015-03-16 02:46:36 +00:00
|
|
|
return dim == dim2 && format == format2 && maxLevel == maxLevel2;
|
|
|
|
}
|
2016-03-26 19:01:55 +00:00
|
|
|
|
2017-02-19 17:53:30 +00:00
|
|
|
inline u64 TexCacheEntry::CacheKey() const {
|
2016-03-26 19:01:55 +00:00
|
|
|
return CacheKey(addr, format, dim, cluthash);
|
|
|
|
}
|
|
|
|
|
2017-02-19 17:53:30 +00:00
|
|
|
inline u64 TexCacheEntry::CacheKey(u32 addr, u8 format, u16 dim, u32 cluthash) {
|
2016-03-26 19:01:55 +00:00
|
|
|
u64 cachekey = ((u64)(addr & 0x3FFFFFFF) << 32) | dim;
|
|
|
|
bool hasClut = (format & 4) != 0;
|
|
|
|
if (hasClut) {
|
|
|
|
cachekey ^= cluthash;
|
|
|
|
}
|
|
|
|
return cachekey;
|
|
|
|
}
|