summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp49
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h4
2 files changed, 31 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d83c38cf8..911890f16 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -263,28 +263,7 @@ void RasterizerOpenGL::DrawArrays() {
263 surfaces_rect.bottom, surfaces_rect.top))}; // Bottom 263 surfaces_rect.bottom, surfaces_rect.top))}; // Bottom
264 264
265 // Bind the framebuffer surfaces 265 // Bind the framebuffer surfaces
266 state.draw.draw_framebuffer = framebuffer.handle; 266 BindFramebufferSurfaces(color_surface, depth_surface, has_stencil);
267 state.Apply();
268
269 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
270 color_surface != nullptr ? color_surface->texture.handle : 0, 0);
271 if (depth_surface != nullptr) {
272 if (has_stencil) {
273 // attach both depth and stencil
274 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
275 depth_surface->texture.handle, 0);
276 } else {
277 // attach depth
278 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
279 depth_surface->texture.handle, 0);
280 // clear stencil attachment
281 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
282 }
283 } else {
284 // clear both depth and stencil attachment
285 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
286 0);
287 }
288 267
289 // Sync the viewport 268 // Sync the viewport
290 SyncViewport(surfaces_rect, res_scale); 269 SyncViewport(surfaces_rect, res_scale);
@@ -530,6 +509,32 @@ void main() {
530 } 509 }
531} 510}
532 511
512void RasterizerOpenGL::BindFramebufferSurfaces(const Surface& color_surface,
513 const Surface& depth_surface, bool has_stencil) {
514 state.draw.draw_framebuffer = framebuffer.handle;
515 state.Apply();
516
517 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
518 color_surface != nullptr ? color_surface->texture.handle : 0, 0);
519 if (depth_surface != nullptr) {
520 if (has_stencil) {
521 // attach both depth and stencil
522 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
523 depth_surface->texture.handle, 0);
524 } else {
525 // attach depth
526 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
527 depth_surface->texture.handle, 0);
528 // clear stencil attachment
529 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
530 }
531 } else {
532 // clear both depth and stencil attachment
533 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
534 0);
535 }
536}
537
533void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) { 538void RasterizerOpenGL::SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale) {
534 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; 539 const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
535 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()}; 540 const MathUtil::Rectangle<s32> viewport_rect{regs.viewport[0].GetRect()};
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 1cd46c96a..fd53e94cd 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -87,6 +87,10 @@ public:
87private: 87private:
88 struct SamplerInfo {}; 88 struct SamplerInfo {};
89 89
90 /// Binds the framebuffer color and depth surface
91 void BindFramebufferSurfaces(const Surface& color_surface, const Surface& depth_surface,
92 bool has_stencil);
93
90 /// Syncs the viewport to match the guest state 94 /// Syncs the viewport to match the guest state
91 void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale); 95 void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale);
92 96