diff options
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 225596415..db5b649da 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -22,7 +22,8 @@ #include "video_core/renderer_opengl/gl_resource_manager.h" namespace MathUtil { -template <class T> struct Rectangle; +template <class T> +struct Rectangle; } struct CachedSurface; @@ -32,38 +33,38 @@ using SurfaceCache = boost::icl::interval_map<PAddr, std::set<std::shared_ptr<Ca struct CachedSurface { enum class PixelFormat { // First 5 formats are shared between textures and color buffers - RGBA8 = 0, - RGB8 = 1, - RGB5A1 = 2, - RGB565 = 3, - RGBA4 = 4, + RGBA8 = 0, + RGB8 = 1, + RGB5A1 = 2, + RGB565 = 3, + RGBA4 = 4, // Texture-only formats - IA8 = 5, - RG8 = 6, - I8 = 7, - A8 = 8, - IA4 = 9, - I4 = 10, - A4 = 11, - ETC1 = 12, - ETC1A4 = 13, + IA8 = 5, + RG8 = 6, + I8 = 7, + A8 = 8, + IA4 = 9, + I4 = 10, + A4 = 11, + ETC1 = 12, + ETC1A4 = 13, // Depth buffer-only formats - D16 = 14, + D16 = 14, // gap - D24 = 16, - D24S8 = 17, + D24 = 16, + D24S8 = 17, - Invalid = 255, + Invalid = 255, }; enum class SurfaceType { - Color = 0, - Texture = 1, - Depth = 2, + Color = 0, + Texture = 1, + Depth = 2, DepthStencil = 3, - Invalid = 4, + Invalid = 4, }; static unsigned int GetFormatBpp(CachedSurface::PixelFormat format) { @@ -101,7 +102,8 @@ struct CachedSurface { } static PixelFormat PixelFormatFromDepthFormat(Pica::Regs::DepthFormat format) { - return ((unsigned int)format < 4) ? (PixelFormat)((unsigned int)format + 14) : PixelFormat::Invalid; + return ((unsigned int)format < 4) ? (PixelFormat)((unsigned int)format + 14) + : PixelFormat::Invalid; } static PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format) { @@ -120,7 +122,8 @@ struct CachedSurface { SurfaceType a_type = GetFormatType(pixel_format_a); SurfaceType b_type = GetFormatType(pixel_format_b); - if ((a_type == SurfaceType::Color || a_type == SurfaceType::Texture) && (b_type == SurfaceType::Color || b_type == SurfaceType::Texture)) { + if ((a_type == SurfaceType::Color || a_type == SurfaceType::Texture) && + (b_type == SurfaceType::Color || b_type == SurfaceType::Texture)) { return true; } @@ -187,22 +190,30 @@ public: ~RasterizerCacheOpenGL(); /// Blits one texture to another - bool BlitTextures(GLuint src_tex, GLuint dst_tex, CachedSurface::SurfaceType type, const MathUtil::Rectangle<int>& src_rect, const MathUtil::Rectangle<int>& dst_rect); + bool BlitTextures(GLuint src_tex, GLuint dst_tex, CachedSurface::SurfaceType type, + const MathUtil::Rectangle<int>& src_rect, + const MathUtil::Rectangle<int>& dst_rect); /// Attempt to blit one surface's texture to another - bool TryBlitSurfaces(CachedSurface* src_surface, const MathUtil::Rectangle<int>& src_rect, CachedSurface* dst_surface, const MathUtil::Rectangle<int>& dst_rect); + bool TryBlitSurfaces(CachedSurface* src_surface, const MathUtil::Rectangle<int>& src_rect, + CachedSurface* dst_surface, const MathUtil::Rectangle<int>& dst_rect); /// Loads a texture from 3DS memory to OpenGL and caches it (if not already cached) - CachedSurface* GetSurface(const CachedSurface& params, bool match_res_scale, bool load_if_create); + CachedSurface* GetSurface(const CachedSurface& params, bool match_res_scale, + bool load_if_create); - /// Attempt to find a subrect (resolution scaled) of a surface, otherwise loads a texture from 3DS memory to OpenGL and caches it (if not already cached) - CachedSurface* GetSurfaceRect(const CachedSurface& params, bool match_res_scale, bool load_if_create, MathUtil::Rectangle<int>& out_rect); + /// Attempt to find a subrect (resolution scaled) of a surface, otherwise loads a texture from + /// 3DS memory to OpenGL and caches it (if not already cached) + CachedSurface* GetSurfaceRect(const CachedSurface& params, bool match_res_scale, + bool load_if_create, MathUtil::Rectangle<int>& out_rect); /// Gets a surface based on the texture configuration CachedSurface* GetTextureSurface(const Pica::Regs::FullTextureConfig& config); - /// Gets the color and depth surfaces and rect (resolution scaled) based on the framebuffer configuration - std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>> GetFramebufferSurfaces(const Pica::Regs::FramebufferConfig& config); + /// Gets the color and depth surfaces and rect (resolution scaled) based on the framebuffer + /// configuration + std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>> + GetFramebufferSurfaces(const Pica::Regs::FramebufferConfig& config); /// Attempt to get a surface that exactly matches the fill region and format CachedSurface* TryGetFillSurface(const GPU::Regs::MemoryFillConfig& config); @@ -210,7 +221,8 @@ public: /// Write the surface back to memory void FlushSurface(CachedSurface* surface); - /// Write any cached resources overlapping the region back to memory (if dirty) and optionally invalidate them in the cache + /// Write any cached resources overlapping the region back to memory (if dirty) and optionally + /// invalidate them in the cache void FlushRegion(PAddr addr, u32 size, const CachedSurface* skip_surface, bool invalidate); /// Flush all cached resources tracked by this cache manager |