summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2014-08-26 17:34:52 -0400
committerGravatar bunnei2014-08-26 17:34:52 -0400
commit20d169e4a1753bf85c19c2799ace8b50fa2e3fa3 (patch)
tree9b90eb8eda2a89eeb7302d9fa5af79a466cd695b /src/video_core
parentMerge pull request #74 from kevinhartman/master (diff)
downloadyuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.gz
yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.xz
yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.zip
VideoCore: Fixes rendering issues on Qt and corrects framebuffer output size.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/clipper.cpp2
-rw-r--r--src/video_core/rasterizer.cpp6
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp14
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h1
4 files changed, 15 insertions, 8 deletions
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp
index b7180328c..592f2f476 100644
--- a/src/video_core/clipper.cpp
+++ b/src/video_core/clipper.cpp
@@ -92,7 +92,7 @@ static void InitScreenCoordinates(OutputVertex& vtx)
92 viewport.offset_z = float24::FromRawFloat24(registers.viewport_depth_far_plane); 92 viewport.offset_z = float24::FromRawFloat24(registers.viewport_depth_far_plane);
93 93
94 // TODO: Not sure why the viewport width needs to be divided by 2 but the viewport height does not 94 // TODO: Not sure why the viewport width needs to be divided by 2 but the viewport height does not
95 vtx.screenpos[0] = (vtx.pos.x / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_x / float24::FromFloat32(2.0) + viewport.offset_x; 95 vtx.screenpos[0] = (vtx.pos.x / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_x + viewport.offset_x;
96 vtx.screenpos[1] = (vtx.pos.y / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_y + viewport.offset_y; 96 vtx.screenpos[1] = (vtx.pos.y / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_y + viewport.offset_y;
97 vtx.screenpos[2] = viewport.offset_z - vtx.pos.z / vtx.pos.w * viewport.zscale; 97 vtx.screenpos[2] = viewport.offset_z - vtx.pos.z / vtx.pos.w * viewport.zscale;
98} 98}
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index cdfdb6215..b55391e5e 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -22,21 +22,21 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) {
22 u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b(); 22 u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b();
23 23
24 // Assuming RGBA8 format until actual framebuffer format handling is implemented 24 // Assuming RGBA8 format until actual framebuffer format handling is implemented
25 *(color_buffer + x + y * registers.framebuffer.GetWidth() / 2) = value; 25 *(color_buffer + x + y * registers.framebuffer.GetWidth()) = value;
26} 26}
27 27
28static u32 GetDepth(int x, int y) { 28static u32 GetDepth(int x, int y) {
29 u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); 29 u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress());
30 30
31 // Assuming 16-bit depth buffer format until actual format handling is implemented 31 // Assuming 16-bit depth buffer format until actual format handling is implemented
32 return *(depth_buffer + x + y * registers.framebuffer.GetWidth() / 2); 32 return *(depth_buffer + x + y * registers.framebuffer.GetWidth());
33} 33}
34 34
35static void SetDepth(int x, int y, u16 value) { 35static void SetDepth(int x, int y, u16 value) {
36 u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); 36 u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress());
37 37
38 // Assuming 16-bit depth buffer format until actual format handling is implemented 38 // Assuming 16-bit depth buffer format until actual format handling is implemented
39 *(depth_buffer + x + y * registers.framebuffer.GetWidth() / 2) = value; 39 *(depth_buffer + x + y * registers.framebuffer.GetWidth()) = value;
40} 40}
41 41
42void ProcessTriangle(const VertexShader::OutputVertex& v0, 42void ProcessTriangle(const VertexShader::OutputVertex& v0,
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index dc1b8e28b..6470245e6 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -49,12 +49,17 @@ RendererOpenGL::RendererOpenGL() {
49 resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight; 49 resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight;
50 50
51 // Initialize screen info 51 // Initialize screen info
52 screen_info.Top().width = VideoCore::kScreenTopWidth; 52 const auto& framebuffer_top = GPU::g_regs.framebuffer_config[0];
53 screen_info.Top().height = VideoCore::kScreenTopHeight; 53 const auto& framebuffer_sub = GPU::g_regs.framebuffer_config[1];
54 screen_info.Top().flipped_xfb_data = xfb_top_flipped; 54
55 screen_info.Top().width = VideoCore::kScreenTopWidth;
56 screen_info.Top().height = VideoCore::kScreenTopHeight;
57 screen_info.Top().stride = framebuffer_top.stride;
58 screen_info.Top().flipped_xfb_data = xfb_top_flipped;
55 59
56 screen_info.Bottom().width = VideoCore::kScreenBottomWidth; 60 screen_info.Bottom().width = VideoCore::kScreenBottomWidth;
57 screen_info.Bottom().height = VideoCore::kScreenBottomHeight; 61 screen_info.Bottom().height = VideoCore::kScreenBottomHeight;
62 screen_info.Bottom().stride = framebuffer_sub.stride;
58 screen_info.Bottom().flipped_xfb_data = xfb_bottom_flipped; 63 screen_info.Bottom().flipped_xfb_data = xfb_bottom_flipped;
59} 64}
60 65
@@ -90,8 +95,8 @@ void RendererOpenGL::SwapBuffers() {
90 * @todo Early on hack... I'd like to find a more efficient way of doing this /bunnei 95 * @todo Early on hack... I'd like to find a more efficient way of doing this /bunnei
91 */ 96 */
92void RendererOpenGL::FlipFramebuffer(const u8* raw_data, ScreenInfo& screen_info) { 97void RendererOpenGL::FlipFramebuffer(const u8* raw_data, ScreenInfo& screen_info) {
93 int in_coord = 0;
94 for (int x = 0; x < screen_info.width; x++) { 98 for (int x = 0; x < screen_info.width; x++) {
99 int in_coord = x * screen_info.stride;
95 for (int y = screen_info.height-1; y >= 0; y--) { 100 for (int y = screen_info.height-1; y >= 0; y--) {
96 // TODO: Properly support other framebuffer formats 101 // TODO: Properly support other framebuffer formats
97 int out_coord = (x + y * screen_info.width) * 3; 102 int out_coord = (x + y * screen_info.width) * 3;
@@ -184,6 +189,7 @@ void RendererOpenGL::InitFramebuffer() {
184} 189}
185 190
186void RendererOpenGL::RenderFramebuffer() { 191void RendererOpenGL::RenderFramebuffer() {
192 glViewport(0, 0, resolution_width, resolution_height);
187 glClear(GL_COLOR_BUFFER_BIT); 193 glClear(GL_COLOR_BUFFER_BIT);
188 194
189 glUseProgram(program_id); 195 glUseProgram(program_id);
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index b21092f07..423467e4c 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -57,6 +57,7 @@ private:
57 // Properties 57 // Properties
58 int width; 58 int width;
59 int height; 59 int height;
60 int stride; ///< Number of bytes between the coordinates (0,0) and (1,0)
60 61
61 // OpenGL object IDs 62 // OpenGL object IDs
62 GLuint texture_id; 63 GLuint texture_id;