citra/src/video_core/renderer_opengl/gl_rasterizer_cache.h

44 lines
1.4 KiB
C
Raw Normal View History

2015-05-19 06:21:33 +02:00
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <map>
2015-09-11 13:20:02 +02:00
#include <memory>
#include "video_core/pica.h"
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
#include "video_core/renderer_opengl/gl_state.h"
2015-05-19 06:21:33 +02:00
class RasterizerCacheOpenGL : NonCopyable {
public:
~RasterizerCacheOpenGL();
/// Loads a texture from 3DS memory to OpenGL and caches it (if not already cached)
void LoadAndBindTexture(OpenGLState &state, unsigned texture_unit, const Pica::DebugUtils::TextureInfo& info);
void LoadAndBindTexture(OpenGLState &state, unsigned texture_unit, const Pica::Regs::FullTextureConfig& config) {
LoadAndBindTexture(state, texture_unit, Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format));
}
2015-05-19 06:21:33 +02:00
/// Invalidate any cached resource intersecting the specified region.
void InvalidateInRange(PAddr addr, u32 size, bool ignore_hash = false);
2015-05-19 06:21:33 +02:00
/// Invalidate all cached OpenGL resources tracked by this cache manager
void InvalidateAll();
2015-05-19 06:21:33 +02:00
private:
struct CachedTexture {
OGLTexture texture;
GLuint width;
GLuint height;
u32 size;
u64 hash;
PAddr addr;
2015-05-19 06:21:33 +02:00
};
std::map<PAddr, std::unique_ptr<CachedTexture>> texture_cache;
};