summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-22 23:06:54 -0400
committerGravatar bunnei2018-03-22 23:06:54 -0400
commita0b1235f82b2632651cb817f8216cc9af37759a2 (patch)
tree5e04ad7b280f355a77a5c4dc813fad663e4f97a4 /src/video_core
parentLoadGLBuffer: Use bytes_per_pixel, not bits. (diff)
downloadyuzu-a0b1235f82b2632651cb817f8216cc9af37759a2.tar.gz
yuzu-a0b1235f82b2632651cb817f8216cc9af37759a2.tar.xz
yuzu-a0b1235f82b2632651cb817f8216cc9af37759a2.zip
gl_rasterizer: Implement AccelerateDisplay method from Citra.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp34
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h12
2 files changed, 44 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 20e192ec9..b51614c25 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -229,7 +229,39 @@ bool RasterizerOpenGL::AccelerateFill(const void* config) {
229bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer, 229bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer,
230 VAddr framebuffer_addr, u32 pixel_stride, 230 VAddr framebuffer_addr, u32 pixel_stride,
231 ScreenInfo& screen_info) { 231 ScreenInfo& screen_info) {
232 ASSERT_MSG(false, "Unimplemented"); 232 if (framebuffer_addr == 0) {
233 return false;
234 }
235 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
236
237 SurfaceParams src_params;
238 src_params.addr = framebuffer_addr;
239 src_params.width = std::min(framebuffer.width, pixel_stride);
240 src_params.height = framebuffer.height;
241 src_params.stride = pixel_stride;
242 src_params.is_tiled = false;
243 src_params.pixel_format =
244 SurfaceParams::PixelFormatFromGPUPixelFormat(framebuffer.pixel_format);
245 src_params.UpdateParams();
246
247 MathUtil::Rectangle<u32> src_rect;
248 Surface src_surface;
249 std::tie(src_surface, src_rect) =
250 res_cache.GetSurfaceSubRect(src_params, ScaleMatch::Ignore, true);
251
252 if (src_surface == nullptr) {
253 return false;
254 }
255
256 u32 scaled_width = src_surface->GetScaledWidth();
257 u32 scaled_height = src_surface->GetScaledHeight();
258
259 screen_info.display_texcoords = MathUtil::Rectangle<float>(
260 (float)src_rect.bottom / (float)scaled_height, (float)src_rect.left / (float)scaled_width,
261 (float)src_rect.top / (float)scaled_height, (float)src_rect.right / (float)scaled_width);
262
263 screen_info.display_texture = src_surface->texture.handle;
264
233 return true; 265 return true;
234} 266}
235 267
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 2172a9d24..14f3cdc38 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -22,6 +22,7 @@
22#include "common/common_funcs.h" 22#include "common/common_funcs.h"
23#include "common/common_types.h" 23#include "common/common_types.h"
24#include "common/math_util.h" 24#include "common/math_util.h"
25#include "video_core/gpu.h"
25#include "video_core/renderer_opengl/gl_resource_manager.h" 26#include "video_core/renderer_opengl/gl_resource_manager.h"
26 27
27struct CachedSurface; 28struct CachedSurface;
@@ -115,6 +116,15 @@ struct SurfaceParams {
115 return GetFormatBpp(pixel_format); 116 return GetFormatBpp(pixel_format);
116 } 117 }
117 118
119 static PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) {
120 switch (format) {
121 case Tegra::FramebufferConfig::PixelFormat::ABGR8:
122 return PixelFormat::RGBA8;
123 default:
124 UNREACHABLE();
125 }
126 }
127
118 static bool CheckFormatsBlittable(PixelFormat pixel_format_a, PixelFormat pixel_format_b) { 128 static bool CheckFormatsBlittable(PixelFormat pixel_format_a, PixelFormat pixel_format_b) {
119 SurfaceType a_type = GetFormatType(pixel_format_a); 129 SurfaceType a_type = GetFormatType(pixel_format_a);
120 SurfaceType b_type = GetFormatType(pixel_format_b); 130 SurfaceType b_type = GetFormatType(pixel_format_b);
@@ -257,7 +267,7 @@ struct CachedSurface : SurfaceParams {
257 std::unique_ptr<u8[]> gl_buffer; 267 std::unique_ptr<u8[]> gl_buffer;
258 size_t gl_buffer_size = 0; 268 size_t gl_buffer_size = 0;
259 269
260 // Read/Write data in 3DS memory to/from gl_buffer 270 // Read/Write data in Switch memory to/from gl_buffer
261 void LoadGLBuffer(VAddr load_start, VAddr load_end); 271 void LoadGLBuffer(VAddr load_start, VAddr load_end);
262 void FlushGLBuffer(VAddr flush_start, VAddr flush_end); 272 void FlushGLBuffer(VAddr flush_start, VAddr flush_end);
263 273