From 69cedf4144293153d0b40749ae178501db529c89 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Thu, 9 Mar 2017 14:14:47 -0800 Subject: extract OGL::FramebufferManager::CreateTexture --- Source/Core/VideoBackends/OGL/FramebufferManager.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Source/Core/VideoBackends/OGL/FramebufferManager.h') diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.h b/Source/Core/VideoBackends/OGL/FramebufferManager.h index 84270777c4..6083d97f34 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.h +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.h @@ -102,6 +102,8 @@ public: static void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points); private: + GLuint CreateTexture(GLenum texture_type, GLenum internal_format, GLenum pixel_format, + GLenum data_type); std::unique_ptr CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override; -- cgit v1.2.3 From 56fe938366950062984e11364af5ce1ffe474f27 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Thu, 9 Mar 2017 14:55:31 -0800 Subject: extract OGL::FramebufferManager::BindLayeredTexture --- Source/Core/VideoBackends/OGL/FramebufferManager.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/VideoBackends/OGL/FramebufferManager.h') diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.h b/Source/Core/VideoBackends/OGL/FramebufferManager.h index 6083d97f34..54dd93936b 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.h +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.h @@ -104,6 +104,7 @@ public: private: GLuint CreateTexture(GLenum texture_type, GLenum internal_format, GLenum pixel_format, GLenum data_type); + void BindLayeredTexture(GLuint texture, const std::vector& framebuffers, GLenum attachment, GLenum texture_type); std::unique_ptr CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override; -- cgit v1.2.3 From ba6e917b49fcb192bc658557742106e29159dff7 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 5 Mar 2017 15:34:30 -0800 Subject: OGL: implement Bounding Box on systems w/o SSBO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit should have zero performance effect if SSBOs are supported. If they aren't (e.g. on all Macs), this commit alters FramebufferManager to attach a new stencil buffer and VertexManager to draw to it when bounding box is active. `BBoxRead` gets the pixel data from the buffer and dumbly loops through it to find the bounding box. This patch can run Paper Mario: The Thousand-Year Door at almost full speed (50–60 FPS) without Dual-Core enabled for all common bounding box-using actions I tested (going through pipes, Plane Mode, Paper Mode, Prof. Frankly's gate, combat, walking around the overworld, etc.) on my computer (macOS 10.12.3, 2.8 GHz Intel Core i7, 16 GB 1600 MHz DDR3, and Intel Iris 1536 MB). A few more demanding scenes (e.g. the self-building bridge on the way to Petalburg) slow to ~15% of their speed without this patch (though they don't run quite at full speed even on master). The slowdown is caused almost solely by `glReadPixels` in `OGL::BoundingBox::Get`. Other implementation ideas: - Use a stencil buffer that's separate from the depth buffer. This would require ARB_texture_stencil8 / OpenGL 4.4, which isn't available on macOS. - Use `glGetTexImage` instead of `glReadPixels`. This is ~5 FPS slower on my computer, presumably because it has to transfer the entire combined depth-stencil buffer instead of only the stencil data. Getting only stencil data from `glGetTexImage` requires ARB_texture_stencil8 / OpenGL 4.4, which (again) is not available on macOS. - Don't use a PBO, and use `glReadPixels` synchronously. This has no visible performance effect on my computer, and is theoretically slower. --- Source/Core/VideoBackends/OGL/FramebufferManager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/OGL/FramebufferManager.h') diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.h b/Source/Core/VideoBackends/OGL/FramebufferManager.h index 54dd93936b..93f8e5bad3 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.h +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.h @@ -70,6 +70,7 @@ public: // the EFB to a resolved texture first. static GLuint GetEFBColorTexture(const EFBRectangle& sourceRc); static GLuint GetEFBDepthTexture(const EFBRectangle& sourceRc); + static void ResolveEFBStencilTexture(); static GLuint GetEFBFramebuffer(unsigned int layer = 0) { @@ -77,7 +78,7 @@ public: } static GLuint GetXFBFramebuffer() { return m_xfbFramebuffer; } // Resolved framebuffer is only used in MSAA mode. - static GLuint GetResolvedFramebuffer() { return m_resolvedFramebuffer[0]; } + static GLuint GetResolvedFramebuffer(); static void SetFramebuffer(GLuint fb); static void FramebufferTexture(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -- cgit v1.2.3 From 53224d41d05a9ec70d0a2715e1a7601a0e60bb14 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Thu, 9 Mar 2017 15:33:10 -0800 Subject: OGL: only create stencil buffer when needed --- Source/Core/VideoBackends/OGL/FramebufferManager.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/FramebufferManager.h') diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.h b/Source/Core/VideoBackends/OGL/FramebufferManager.h index 93f8e5bad3..62b2f5ce3c 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.h +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.h @@ -63,7 +63,8 @@ struct XFBSource : public XFBSourceBase class FramebufferManager : public FramebufferManagerBase { public: - FramebufferManager(int targetWidth, int targetHeight, int msaaSamples); + FramebufferManager(int targetWidth, int targetHeight, int msaaSamples, + bool enable_stencil_buffer); ~FramebufferManager(); // To get the EFB in texture form, these functions may have to transfer @@ -101,11 +102,13 @@ public: static void ReinterpretPixelData(unsigned int convtype); static void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points); + static bool HasStencilBuffer(); private: GLuint CreateTexture(GLenum texture_type, GLenum internal_format, GLenum pixel_format, GLenum data_type); - void BindLayeredTexture(GLuint texture, const std::vector& framebuffers, GLenum attachment, GLenum texture_type); + void BindLayeredTexture(GLuint texture, const std::vector& framebuffers, + GLenum attachment, GLenum texture_type); std::unique_ptr CreateXFBSource(unsigned int target_width, unsigned int target_height, unsigned int layers) override; @@ -126,6 +129,8 @@ private: static GLuint m_efbColorSwap; // will be hot swapped with m_efbColor when reinterpreting EFB pixel formats + static bool m_enable_stencil_buffer; + // Only used in MSAA mode, TODO: try to avoid them static std::vector m_resolvedFramebuffer; static GLuint m_resolvedColorTexture; -- cgit v1.2.3