diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-12-08 05:21:06 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-12-08 05:21:06 +0100 |
commit | 31764c48fb8f78b998b6627ef4ea4f1b2ec83903 (patch) | |
tree | 61533db5c3b250e4f3bc557e442b589e307201ca /src/video_core/renderer_opengl | |
parent | Merge pull request #1271 from lioncash/dyncom-misc (diff) | |
parent | VideoCore: Unify interface to OpenGL and SW rasterizers (diff) | |
download | yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar.gz yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar.bz2 yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar.lz yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar.xz yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.tar.zst yuzu-31764c48fb8f78b998b6627ef4ea4f1b2ec83903.zip |
Diffstat (limited to 'src/video_core/renderer_opengl')
5 files changed, 22 insertions, 56 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 822739088..681fdca8d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -135,7 +135,7 @@ void RasterizerOpenGL::Reset() { SetShader(); - res_cache.FullFlush(); + res_cache.InvalidateAll(); } void RasterizerOpenGL::AddTriangle(const Pica::Shader::OutputVertex& v0, @@ -176,11 +176,11 @@ void RasterizerOpenGL::DrawTriangles() { u32 cur_fb_depth_size = Pica::Regs::BytesPerDepthPixel(regs.framebuffer.depth_format) * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); - res_cache.NotifyFlush(cur_fb_color_addr, cur_fb_color_size, true); - res_cache.NotifyFlush(cur_fb_depth_addr, cur_fb_depth_size, true); + res_cache.InvalidateInRange(cur_fb_color_addr, cur_fb_color_size, true); + res_cache.InvalidateInRange(cur_fb_depth_addr, cur_fb_depth_size, true); } -void RasterizerOpenGL::CommitFramebuffer() { +void RasterizerOpenGL::FlushFramebuffer() { CommitColorBuffer(); CommitDepthBuffer(); } @@ -188,9 +188,6 @@ void RasterizerOpenGL::CommitFramebuffer() { void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { const auto& regs = Pica::g_state.regs; - if (!Settings::values.use_hw_renderer) - return; - switch(id) { // Culling case PICA_REG_INDEX(cull_mode): @@ -284,12 +281,9 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { } } -void RasterizerOpenGL::NotifyPreRead(PAddr addr, u32 size) { +void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) { const auto& regs = Pica::g_state.regs; - if (!Settings::values.use_hw_renderer) - return; - PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); @@ -306,12 +300,9 @@ void RasterizerOpenGL::NotifyPreRead(PAddr addr, u32 size) { CommitDepthBuffer(); } -void RasterizerOpenGL::NotifyFlush(PAddr addr, u32 size) { +void RasterizerOpenGL::InvalidateRegion(PAddr addr, u32 size) { const auto& regs = Pica::g_state.regs; - if (!Settings::values.use_hw_renderer) - return; - PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); @@ -328,7 +319,7 @@ void RasterizerOpenGL::NotifyFlush(PAddr addr, u32 size) { ReloadDepthBuffer(); // Notify cache of flush in case the region touches a cached resource - res_cache.NotifyFlush(addr, size); + res_cache.InvalidateInRange(addr, size); } void RasterizerOpenGL::SamplerInfo::Create() { diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 5ba898189..92b1f812e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -14,7 +14,7 @@ #include "common/hash.h" #include "video_core/pica.h" -#include "video_core/hwrasterizer_base.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_opengl/gl_rasterizer_cache.h" #include "video_core/renderer_opengl/gl_state.h" #include "video_core/shader/shader_interpreter.h" @@ -102,37 +102,22 @@ struct hash<PicaShaderConfig> { } // namespace std -class RasterizerOpenGL : public HWRasterizer { +class RasterizerOpenGL : public VideoCore::RasterizerInterface { public: RasterizerOpenGL(); ~RasterizerOpenGL() override; - /// Initialize API-specific GPU objects void InitObjects() override; - - /// Reset the rasterizer, such as flushing all caches and updating all state void Reset() override; - - /// Queues the primitive formed by the given vertices for rendering void AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v1, const Pica::Shader::OutputVertex& v2) override; - - /// Draw the current batch of triangles void DrawTriangles() override; - - /// Commit the rasterizer's framebuffer contents immediately to the current 3DS memory framebuffer - void CommitFramebuffer() override; - - /// Notify rasterizer that the specified PICA register has been changed + void FlushFramebuffer() override; void NotifyPicaRegisterChanged(u32 id) override; - - /// Notify rasterizer that the specified 3DS memory region will be read from after this notification - void NotifyPreRead(PAddr addr, u32 size) override; - - /// Notify rasterizer that a 3DS memory region has been changed - void NotifyFlush(PAddr addr, u32 size) override; + void FlushRegion(PAddr addr, u32 size) override; + void InvalidateRegion(PAddr addr, u32 size) override; /// OpenGL shader generated for a given Pica register state struct PicaShader { diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 10d4ab0b6..a9ad46fe0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -15,7 +15,7 @@ #include "video_core/renderer_opengl/pica_to_gl.h" RasterizerCacheOpenGL::~RasterizerCacheOpenGL() { - FullFlush(); + InvalidateAll(); } MICROPROFILE_DEFINE(OpenGL_TextureUpload, "OpenGL", "Texture Upload", MP_RGB(128, 64, 192)); @@ -58,8 +58,7 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text } } -void RasterizerCacheOpenGL::NotifyFlush(PAddr addr, u32 size, bool ignore_hash) { - // Flush any texture that falls in the flushed region +void RasterizerCacheOpenGL::InvalidateInRange(PAddr addr, u32 size, bool ignore_hash) { // TODO: Optimize by also inserting upper bound (addr + size) of each texture into the same map and also narrow using lower_bound auto cache_upper_bound = texture_cache.upper_bound(addr + size); @@ -77,6 +76,6 @@ void RasterizerCacheOpenGL::NotifyFlush(PAddr addr, u32 size, bool ignore_hash) } } -void RasterizerCacheOpenGL::FullFlush() { +void RasterizerCacheOpenGL::InvalidateAll() { texture_cache.clear(); } diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 98a48ffbe..b69651427 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -23,11 +23,11 @@ public: LoadAndBindTexture(state, texture_unit, Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format)); } - /// Flush any cached resource that touches the flushed region - void NotifyFlush(PAddr addr, u32 size, bool ignore_hash = false); + /// Invalidate any cached resource intersecting the specified region. + void InvalidateInRange(PAddr addr, u32 size, bool ignore_hash = false); - /// Flush all cached OpenGL resources tracked by this cache manager - void FullFlush(); + /// Invalidate all cached OpenGL resources tracked by this cache manager + void InvalidateAll(); private: struct CachedTexture { diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 1420229cc..c14bdb8ab 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -93,7 +93,6 @@ static std::array<GLfloat, 3*2> MakeOrthographicMatrix(const float width, const /// RendererOpenGL constructor RendererOpenGL::RendererOpenGL() { - hw_rasterizer.reset(new RasterizerOpenGL()); resolution_width = std::max(VideoCore::kScreenTopWidth, VideoCore::kScreenBottomWidth); resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight; } @@ -157,15 +156,7 @@ void RendererOpenGL::SwapBuffers() { profiler.BeginFrame(); - bool hw_renderer_enabled = VideoCore::g_hw_renderer_enabled; - if (Settings::values.use_hw_renderer != hw_renderer_enabled) { - // TODO: Save new setting value to config file for next startup - Settings::values.use_hw_renderer = hw_renderer_enabled; - - if (Settings::values.use_hw_renderer) { - hw_rasterizer->Reset(); - } - } + RefreshRasterizerSetting(); if (Pica::g_debug_context && Pica::g_debug_context->recorder) { Pica::g_debug_context->recorder->FrameFinished(); @@ -286,8 +277,6 @@ void RendererOpenGL::InitOpenGLObjects() { state.texture_units[0].texture_2d = 0; state.Apply(); - - hw_rasterizer->InitObjects(); } void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, @@ -419,6 +408,8 @@ void RendererOpenGL::Init() { LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); InitOpenGLObjects(); + + RefreshRasterizerSetting(); } /// Shutdown the renderer |