summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_framebuffer_cache.h
diff options
context:
space:
mode:
authorZach Hilman <DarkLordZach@users.noreply.github.com>2019-07-05 19:39:13 +0200
committerGitHub <noreply@github.com>2019-07-05 19:39:13 +0200
commit772c86a260eb446b0fe4232b0a50666511bef25c (patch)
tree013d92268c06454c93565c83eff2b79b56a00839 /src/video_core/renderer_opengl/gl_framebuffer_cache.h
parentMerge pull request #2669 from FearlessTobi/move-cpujit-setting (diff)
parenttexture_cache: Address Feedback (diff)
downloadyuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.gz
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.bz2
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.lz
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.xz
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.tar.zst
yuzu-772c86a260eb446b0fe4232b0a50666511bef25c.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_framebuffer_cache.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_framebuffer_cache.h b/src/video_core/renderer_opengl/gl_framebuffer_cache.h
new file mode 100644
index 000000000..a3a996353
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_framebuffer_cache.h
@@ -0,0 +1,68 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <cstddef>
+#include <unordered_map>
+
+#include <glad/glad.h>
+
+#include "common/common_types.h"
+#include "video_core/engines/maxwell_3d.h"
+#include "video_core/renderer_opengl/gl_resource_manager.h"
+#include "video_core/renderer_opengl/gl_state.h"
+#include "video_core/renderer_opengl/gl_texture_cache.h"
+
+namespace OpenGL {
+
+struct alignas(sizeof(u64)) FramebufferCacheKey {
+ bool is_single_buffer = false;
+ bool stencil_enable = false;
+ u16 colors_count = 0;
+
+ std::array<GLenum, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> color_attachments{};
+ std::array<View, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> colors;
+ View zeta;
+
+ std::size_t Hash() const;
+
+ bool operator==(const FramebufferCacheKey& rhs) const;
+
+ bool operator!=(const FramebufferCacheKey& rhs) const {
+ return !operator==(rhs);
+ }
+};
+
+} // namespace OpenGL
+
+namespace std {
+
+template <>
+struct hash<OpenGL::FramebufferCacheKey> {
+ std::size_t operator()(const OpenGL::FramebufferCacheKey& k) const noexcept {
+ return k.Hash();
+ }
+};
+
+} // namespace std
+
+namespace OpenGL {
+
+class FramebufferCacheOpenGL {
+public:
+ FramebufferCacheOpenGL();
+ ~FramebufferCacheOpenGL();
+
+ GLuint GetFramebuffer(const FramebufferCacheKey& key);
+
+private:
+ OGLFramebuffer CreateFramebuffer(const FramebufferCacheKey& key);
+
+ OpenGLState local_state;
+ std::unordered_map<FramebufferCacheKey, OGLFramebuffer> cache;
+};
+
+} // namespace OpenGL