diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_framebuffer_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 41 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 2 |
3 files changed, 15 insertions, 32 deletions
diff --git a/src/video_core/renderer_opengl/gl_framebuffer_cache.h b/src/video_core/renderer_opengl/gl_framebuffer_cache.h index 424344c48..3b5ff2149 100644 --- a/src/video_core/renderer_opengl/gl_framebuffer_cache.h +++ b/src/video_core/renderer_opengl/gl_framebuffer_cache.h | |||
| @@ -19,8 +19,8 @@ | |||
| 19 | namespace OpenGL { | 19 | namespace OpenGL { |
| 20 | 20 | ||
| 21 | struct alignas(sizeof(u64)) FramebufferCacheKey { | 21 | struct alignas(sizeof(u64)) FramebufferCacheKey { |
| 22 | bool stencil_enable = false; | 22 | bool stencil_enable; |
| 23 | u16 colors_count = 0; | 23 | u16 colors_count; |
| 24 | 24 | ||
| 25 | std::array<GLenum, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> color_attachments{}; | 25 | std::array<GLenum, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> color_attachments{}; |
| 26 | std::array<View, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> colors; | 26 | std::array<View, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> colors; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a568a4343..18c122228 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -93,7 +93,6 @@ RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWind | |||
| 93 | shader_program_manager = std::make_unique<GLShader::ProgramManager>(); | 93 | shader_program_manager = std::make_unique<GLShader::ProgramManager>(); |
| 94 | state.draw.shader_program = 0; | 94 | state.draw.shader_program = 0; |
| 95 | state.Apply(); | 95 | state.Apply(); |
| 96 | clear_framebuffer.Create(); | ||
| 97 | 96 | ||
| 98 | LOG_DEBUG(Render_OpenGL, "Sync fixed function OpenGL state here"); | 97 | LOG_DEBUG(Render_OpenGL, "Sync fixed function OpenGL state here"); |
| 99 | CheckExtensions(); | 98 | CheckExtensions(); |
| @@ -405,46 +404,32 @@ void RasterizerOpenGL::ConfigureFramebuffers() { | |||
| 405 | 404 | ||
| 406 | void RasterizerOpenGL::ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb, | 405 | void RasterizerOpenGL::ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb, |
| 407 | bool using_depth_fb, bool using_stencil_fb) { | 406 | bool using_depth_fb, bool using_stencil_fb) { |
| 407 | using VideoCore::Surface::SurfaceType; | ||
| 408 | |||
| 408 | auto& gpu = system.GPU().Maxwell3D(); | 409 | auto& gpu = system.GPU().Maxwell3D(); |
| 409 | const auto& regs = gpu.regs; | 410 | const auto& regs = gpu.regs; |
| 410 | 411 | ||
| 411 | texture_cache.GuardRenderTargets(true); | 412 | texture_cache.GuardRenderTargets(true); |
| 412 | View color_surface{}; | 413 | View color_surface; |
| 413 | if (using_color_fb) { | 414 | if (using_color_fb) { |
| 414 | color_surface = texture_cache.GetColorBufferSurface(regs.clear_buffers.RT, false); | 415 | color_surface = texture_cache.GetColorBufferSurface(regs.clear_buffers.RT, false); |
| 415 | } | 416 | } |
| 416 | View depth_surface{}; | 417 | View depth_surface; |
| 417 | if (using_depth_fb || using_stencil_fb) { | 418 | if (using_depth_fb || using_stencil_fb) { |
| 418 | depth_surface = texture_cache.GetDepthBufferSurface(false); | 419 | depth_surface = texture_cache.GetDepthBufferSurface(false); |
| 419 | } | 420 | } |
| 420 | texture_cache.GuardRenderTargets(false); | 421 | texture_cache.GuardRenderTargets(false); |
| 421 | 422 | ||
| 422 | current_state.draw.draw_framebuffer = clear_framebuffer.handle; | 423 | FramebufferCacheKey key; |
| 423 | current_state.ApplyFramebufferState(); | 424 | key.colors_count = color_surface ? 1 : 0; |
| 425 | key.colors[0] = color_surface; | ||
| 426 | key.color_attachments[0] = GL_COLOR_ATTACHMENT0; | ||
| 427 | key.zeta = depth_surface; | ||
| 428 | key.stencil_enable = depth_surface && depth_surface->GetSurfaceParams().type == | ||
| 429 | VideoCore::Surface::SurfaceType::DepthStencil; | ||
| 424 | 430 | ||
| 425 | if (color_surface) { | 431 | current_state.draw.draw_framebuffer = framebuffer_cache.GetFramebuffer(key); |
| 426 | color_surface->Attach(GL_COLOR_ATTACHMENT0, GL_DRAW_FRAMEBUFFER); | 432 | current_state.ApplyFramebufferState(); |
| 427 | } else { | ||
| 428 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | ||
| 429 | } | ||
| 430 | |||
| 431 | if (depth_surface) { | ||
| 432 | const auto& params = depth_surface->GetSurfaceParams(); | ||
| 433 | switch (params.type) { | ||
| 434 | case VideoCore::Surface::SurfaceType::Depth: | ||
| 435 | depth_surface->Attach(GL_DEPTH_ATTACHMENT, GL_DRAW_FRAMEBUFFER); | ||
| 436 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); | ||
| 437 | break; | ||
| 438 | case VideoCore::Surface::SurfaceType::DepthStencil: | ||
| 439 | depth_surface->Attach(GL_DEPTH_STENCIL_ATTACHMENT, GL_DRAW_FRAMEBUFFER); | ||
| 440 | break; | ||
| 441 | default: | ||
| 442 | UNIMPLEMENTED(); | ||
| 443 | } | ||
| 444 | } else { | ||
| 445 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, | ||
| 446 | 0); | ||
| 447 | } | ||
| 448 | } | 433 | } |
| 449 | 434 | ||
| 450 | void RasterizerOpenGL::Clear() { | 435 | void RasterizerOpenGL::Clear() { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 0e47d71df..04c1ca551 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -223,8 +223,6 @@ private: | |||
| 223 | 223 | ||
| 224 | enum class AccelDraw { Disabled, Arrays, Indexed }; | 224 | enum class AccelDraw { Disabled, Arrays, Indexed }; |
| 225 | AccelDraw accelerate_draw = AccelDraw::Disabled; | 225 | AccelDraw accelerate_draw = AccelDraw::Disabled; |
| 226 | |||
| 227 | OGLFramebuffer clear_framebuffer; | ||
| 228 | }; | 226 | }; |
| 229 | 227 | ||
| 230 | } // namespace OpenGL | 228 | } // namespace OpenGL |