summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-22 23:28:37 -0400
committerGravatar bunnei2018-03-22 23:28:37 -0400
commitc2c55e0811bf6314047c0b907157c84cad14981f (patch)
tree982823be89a0e1c1b67dd029298cddffe43f49ac /src/video_core
parentnvdisp_disp0: Always flush and invalidate framebuffer region. (diff)
downloadyuzu-c2c55e0811bf6314047c0b907157c84cad14981f.tar.gz
yuzu-c2c55e0811bf6314047c0b907157c84cad14981f.tar.xz
yuzu-c2c55e0811bf6314047c0b907157c84cad14981f.zip
renderer_opengl: Use accelerated framebuffer load with LoadFBToScreenInfo.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index a65270222..047389fee 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -140,49 +140,43 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf
140 const u32 bpp{Tegra::FramebufferConfig::BytesPerPixel(framebuffer.pixel_format)}; 140 const u32 bpp{Tegra::FramebufferConfig::BytesPerPixel(framebuffer.pixel_format)};
141 const u32 size_in_bytes{framebuffer.stride * framebuffer.height * bpp}; 141 const u32 size_in_bytes{framebuffer.stride * framebuffer.height * bpp};
142 const VAddr framebuffer_addr{framebuffer.address}; 142 const VAddr framebuffer_addr{framebuffer.address};
143 const size_t pixel_stride{framebuffer.stride / bpp};
144
145 // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately
146 ASSERT(pixel_stride * bpp == framebuffer.stride);
147
148 MortonCopyPixels128(framebuffer.width, framebuffer.height, bpp, 4,
149 Memory::GetPointer(framebuffer.address), gl_framebuffer_data.data(), true);
150
151 LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%llx(%dx%d), fmt %x", size_in_bytes,
152 framebuffer.address, framebuffer.width, framebuffer.height,
153 (int)framebuffer.pixel_format);
154 143
155 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default 144 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default
156 // only allows rows to have a memory alignement of 4. 145 // only allows rows to have a memory alignement of 4.
157 ASSERT(framebuffer.stride % 4 == 0); 146 ASSERT(framebuffer.stride % 4 == 0);
158 147
159 framebuffer_flip_vertical = framebuffer.flip_vertical; 148 if (!Rasterizer()->AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride,
149 screen_info)) {
150 // Reset the screen info's display texture to its own permanent texture
151 screen_info.display_texture = screen_info.texture.resource.handle;
152 screen_info.display_texcoords = MathUtil::Rectangle<float>(0.f, 0.f, 1.f, 1.f);
160 153
161 // Reset the screen info's display texture to its own permanent texture 154 Rasterizer()->FlushRegion(framebuffer_addr, framebuffer.stride * framebuffer.height);
162 screen_info.display_texture = screen_info.texture.resource.handle;
163 screen_info.display_texcoords = MathUtil::Rectangle<float>(0.f, 0.f, 1.f, 1.f);
164 155
165 Rasterizer()->FlushRegion(framebuffer.address, size_in_bytes); 156 VideoCore::MortonCopyPixels128(framebuffer.width, framebuffer.height, bpp, 4,
157 Memory::GetPointer(framebuffer.address),
158 gl_framebuffer_data.data(), true);
166 159
167 state.texture_units[0].texture_2d = screen_info.texture.resource.handle; 160 state.texture_units[0].texture_2d = screen_info.texture.resource.handle;
168 state.Apply(); 161 state.Apply();
169 162
170 glActiveTexture(GL_TEXTURE0); 163 glActiveTexture(GL_TEXTURE0);
171 glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)framebuffer.stride); 164 glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(framebuffer.stride));
172 165
173 // Update existing texture 166 // Update existing texture
174 // TODO: Test what happens on hardware when you change the framebuffer dimensions so that 167 // TODO: Test what happens on hardware when you change the framebuffer dimensions so that
175 // they differ from the LCD resolution. 168 // they differ from the LCD resolution.
176 // TODO: Applications could theoretically crash Citra here by specifying too large 169 // TODO: Applications could theoretically crash yuzu here by specifying too large
177 // framebuffer sizes. We should make sure that this cannot happen. 170 // framebuffer sizes. We should make sure that this cannot happen.
178 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, 171 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height,
179 screen_info.texture.gl_format, screen_info.texture.gl_type, 172 screen_info.texture.gl_format, screen_info.texture.gl_type,
180 gl_framebuffer_data.data()); 173 gl_framebuffer_data.data());
181 174
182 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 175 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
183 176
184 state.texture_units[0].texture_2d = 0; 177 state.texture_units[0].texture_2d = 0;
185 state.Apply(); 178 state.Apply();
179 }
186} 180}
187 181
188/** 182/**