diff options
| author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-12-09 20:35:15 -0800 |
|---|---|---|
| committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-12-09 20:35:15 -0800 |
| commit | 402692c08d7abf5e2ac3a9b039ac00670fc45ae1 (patch) | |
| tree | f13604c0bcadbad87f55b9157ad98bab1ac3765e /src/video_core/renderer_opengl/gl_rasterizer.cpp | |
| parent | 3013f26d706acfc1ad6f2e6c74c19be4f9257b62 (diff) | |
| parent | cf81e0838974f33b3f85c1db9f2d0eeab67713d9 (diff) | |
Merge pull request #1267 from yuriks/flipped-framebuffer
OpenGL: Flip framebuffers during transfer rather than when rendering
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 681fdca8d..092351dce 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -587,12 +587,12 @@ void RasterizerOpenGL::SyncCullMode() { case Pica::Regs::CullMode::KeepClockWise: state.cull.enabled = true; - state.cull.mode = GL_BACK; + state.cull.front_face = GL_CW; break; case Pica::Regs::CullMode::KeepCounterClockWise: state.cull.enabled = true; - state.cull.mode = GL_FRONT; + state.cull.front_face = GL_CCW; break; default: @@ -683,9 +683,8 @@ void RasterizerOpenGL::SyncDrawState() { // OpenGL uses different y coordinates, so negate corner offset and flip origin // TODO: Ensure viewport_corner.x should not be negated or origin flipped // TODO: Use floating-point viewports for accuracy if supported - glViewport((GLsizei)static_cast<float>(regs.viewport_corner.x), - -(GLsizei)static_cast<float>(regs.viewport_corner.y) - + regs.framebuffer.GetHeight() - viewport_height, + glViewport((GLsizei)regs.viewport_corner.x, + (GLsizei)regs.viewport_corner.y, viewport_width, viewport_height); // Sync bound texture(s), upload if not cached @@ -724,7 +723,7 @@ void RasterizerOpenGL::ReloadColorBuffer() { for (int x = 0; x < fb_color_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel; - u32 gl_pixel_index = (x + y * fb_color_texture.width) * bytes_per_pixel; + u32 gl_pixel_index = (x + (fb_color_texture.height - 1 - y) * fb_color_texture.width) * bytes_per_pixel; u8* pixel = color_buffer + dst_offset; memcpy(&temp_fb_color_buffer[gl_pixel_index], pixel, bytes_per_pixel); @@ -770,7 +769,7 @@ void RasterizerOpenGL::ReloadDepthBuffer() { for (int x = 0; x < fb_depth_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; - u32 gl_pixel_index = (x + y * fb_depth_texture.width); + u32 gl_pixel_index = (x + (fb_depth_texture.height - 1 - y) * fb_depth_texture.width); u8* pixel = depth_buffer + dst_offset; u32 depth_stencil = *(u32*)pixel; @@ -782,7 +781,7 @@ void RasterizerOpenGL::ReloadDepthBuffer() { for (int x = 0; x < fb_depth_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; - u32 gl_pixel_index = (x + y * fb_depth_texture.width) * gl_bpp; + u32 gl_pixel_index = (x + (fb_depth_texture.height - 1 - y) * fb_depth_texture.width) * gl_bpp; u8* pixel = depth_buffer + dst_offset; memcpy(&temp_fb_depth_data[gl_pixel_index], pixel, bytes_per_pixel); @@ -837,7 +836,7 @@ void RasterizerOpenGL::CommitColorBuffer() { for (int x = 0; x < fb_color_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_color_texture.width * bytes_per_pixel; - u32 gl_pixel_index = x * bytes_per_pixel + y * fb_color_texture.width * bytes_per_pixel; + u32 gl_pixel_index = x * bytes_per_pixel + (fb_color_texture.height - 1 - y) * fb_color_texture.width * bytes_per_pixel; u8* pixel = color_buffer + dst_offset; memcpy(pixel, &temp_gl_color_buffer[gl_pixel_index], bytes_per_pixel); @@ -879,7 +878,7 @@ void RasterizerOpenGL::CommitDepthBuffer() { for (int x = 0; x < fb_depth_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; - u32 gl_pixel_index = (x + y * fb_depth_texture.width); + u32 gl_pixel_index = (x + (fb_depth_texture.height - 1 - y) * fb_depth_texture.width); u8* pixel = depth_buffer + dst_offset; u32 depth_stencil = ((u32*)temp_gl_depth_data)[gl_pixel_index]; @@ -891,7 +890,7 @@ void RasterizerOpenGL::CommitDepthBuffer() { for (int x = 0; x < fb_depth_texture.width; ++x) { const u32 coarse_y = y & ~7; u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * fb_depth_texture.width * bytes_per_pixel; - u32 gl_pixel_index = (x + y * fb_depth_texture.width) * gl_bpp; + u32 gl_pixel_index = (x + (fb_depth_texture.height - 1 - y) * fb_depth_texture.width) * gl_bpp; u8* pixel = depth_buffer + dst_offset; memcpy(pixel, &temp_gl_depth_data[gl_pixel_index], bytes_per_pixel); |
