Fixed threading issue pointed out by unknownbrackets and made texture scaling changes apply immediately

This commit is contained in:
Peter Thoman 2013-04-30 17:20:28 +02:00 committed by Peter Thoman
parent 37a33d9daf
commit 2212e7f609
7 changed files with 26 additions and 3 deletions

View file

@ -997,6 +997,11 @@ void GLES_GPU::InvalidateCacheHint(u32 addr, int size) {
textureCache_.InvalidateAll(false); textureCache_.InvalidateAll(false);
} }
void GLES_GPU::ClearCacheNextFrame() {
textureCache_.ClearNextFrame();
}
void GLES_GPU::Flush() { void GLES_GPU::Flush() {
transformDraw_.Flush(); transformDraw_.Flush();
} }

View file

@ -46,6 +46,7 @@ public:
virtual void UpdateStats(); virtual void UpdateStats();
virtual void InvalidateCache(u32 addr, int size); virtual void InvalidateCache(u32 addr, int size);
virtual void InvalidateCacheHint(u32 addr, int size); virtual void InvalidateCacheHint(u32 addr, int size);
virtual void ClearCacheNextFrame();
virtual void DeviceLost(); // Only happens on Android. Drop all textures and shaders. virtual void DeviceLost(); // Only happens on Android. Drop all textures and shaders.
virtual void DumpNextFrame(); virtual void DumpNextFrame();

View file

@ -44,7 +44,7 @@ u32 RoundUpToPowerOf2(u32 v)
return v; return v;
} }
TextureCache::TextureCache() { TextureCache::TextureCache() : clearCacheNextFrame_(false) {
lastBoundTexture = -1; lastBoundTexture = -1;
// This is 5MB of temporary storage. Might be possible to shrink it. // This is 5MB of temporary storage. Might be possible to shrink it.
tmpTexBuf32.resize(1024 * 512); // 2MB tmpTexBuf32.resize(1024 * 512); // 2MB
@ -120,6 +120,11 @@ void TextureCache::InvalidateAll(bool force) {
Invalidate(0, 0xFFFFFFFF, force); Invalidate(0, 0xFFFFFFFF, force);
} }
void TextureCache::ClearNextFrame() {
clearCacheNextFrame_ = true;
}
TextureCache::TexCacheEntry *TextureCache::GetEntryAt(u32 texaddr) { TextureCache::TexCacheEntry *TextureCache::GetEntryAt(u32 texaddr) {
// If no CLUT, as in framebuffer textures, cache key is simply texaddr. // If no CLUT, as in framebuffer textures, cache key is simply texaddr.
auto iter = cache.find(texaddr); auto iter = cache.find(texaddr);
@ -654,7 +659,12 @@ static void convertColors(u8 *finalBuf, GLuint dstFmt, int numPixels) {
void TextureCache::StartFrame() { void TextureCache::StartFrame() {
lastBoundTexture = -1; lastBoundTexture = -1;
if(clearCacheNextFrame_) {
Clear(true);
clearCacheNextFrame_ = false;
} else {
Decimate(); Decimate();
}
} }
static const u8 bitsPerPixel[11] = { static const u8 bitsPerPixel[11] = {

View file

@ -36,6 +36,7 @@ public:
void StartFrame(); void StartFrame();
void Invalidate(u32 addr, int size, bool force); void Invalidate(u32 addr, int size, bool force);
void InvalidateAll(bool force); void InvalidateAll(bool force);
void ClearNextFrame();
// FramebufferManager keeps TextureCache updated about what regions of memory // FramebufferManager keeps TextureCache updated about what regions of memory
// are being rendered to. This is barebones so far. // are being rendered to. This is barebones so far.
@ -100,6 +101,8 @@ private:
typedef std::map<u64, TexCacheEntry> TexCache; typedef std::map<u64, TexCacheEntry> TexCache;
TexCache cache; TexCache cache;
bool clearCacheNextFrame_;
template <typename T> template <typename T>
class SimpleBuf { class SimpleBuf {
public: public:

View file

@ -174,6 +174,9 @@ public:
virtual void InvalidateCache(u32 addr, int size) = 0; virtual void InvalidateCache(u32 addr, int size) = 0;
virtual void InvalidateCacheHint(u32 addr, int size) = 0; virtual void InvalidateCacheHint(u32 addr, int size) = 0;
// Will cause the texture cache to be cleared at the start of the next frame.
virtual void ClearCacheNextFrame() = 0;
// Internal hack to avoid interrupts from "PPGe" drawing (utility UI, etc) // Internal hack to avoid interrupts from "PPGe" drawing (utility UI, etc)
virtual void EnableInterrupts(bool enable) = 0; virtual void EnableInterrupts(bool enable) = 0;

View file

@ -36,6 +36,7 @@ public:
virtual void UpdateStats(); virtual void UpdateStats();
virtual void InvalidateCache(u32 addr, int size); virtual void InvalidateCache(u32 addr, int size);
virtual void InvalidateCacheHint(u32 addr, int size); virtual void InvalidateCacheHint(u32 addr, int size);
virtual void ClearCacheNextFrame() {};
virtual void Flush() {} virtual void Flush() {}
virtual void DeviceLost() {} virtual void DeviceLost() {}

View file

@ -177,7 +177,7 @@ namespace MainWindow
void setXbrzTexScaling(int num) { void setXbrzTexScaling(int num) {
g_Config.iXBRZTexScalingLevel = num; g_Config.iXBRZTexScalingLevel = num;
if(gpu) gpu->InvalidateCache(0,0); if(gpu) gpu->ClearCacheNextFrame();
} }
BOOL Show(HINSTANCE hInstance, int nCmdShow) BOOL Show(HINSTANCE hInstance, int nCmdShow)