summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/core/hw/gpu.cpp17
-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
5 files changed, 23 insertions, 17 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index 87cf93bac..f1f3e7ab3 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -84,7 +84,7 @@ inline void Write(u32 addr, const T data) {
84 84
85 for (int y = 0; y < config.output_height; ++y) { 85 for (int y = 0; y < config.output_height; ++y) {
86 // TODO: Why does the register seem to hold twice the framebuffer width? 86 // TODO: Why does the register seem to hold twice the framebuffer width?
87 for (int x = 0; x < config.output_width / 2; ++x) { 87 for (int x = 0; x < config.output_width; ++x) {
88 struct { 88 struct {
89 int r, g, b, a; 89 int r, g, b, a;
90 } source_color = { 0, 0, 0, 0 }; 90 } source_color = { 0, 0, 0, 0 };
@@ -93,7 +93,7 @@ inline void Write(u32 addr, const T data) {
93 case Regs::FramebufferFormat::RGBA8: 93 case Regs::FramebufferFormat::RGBA8:
94 { 94 {
95 // TODO: Most likely got the component order messed up. 95 // TODO: Most likely got the component order messed up.
96 u8* srcptr = source_pointer + x * 4 + y * config.input_width * 4 / 2; 96 u8* srcptr = source_pointer + x * 4 + y * config.input_width * 4;
97 source_color.r = srcptr[0]; // blue 97 source_color.r = srcptr[0]; // blue
98 source_color.g = srcptr[1]; // green 98 source_color.g = srcptr[1]; // green
99 source_color.b = srcptr[2]; // red 99 source_color.b = srcptr[2]; // red
@@ -121,7 +121,7 @@ inline void Write(u32 addr, const T data) {
121 case Regs::FramebufferFormat::RGB8: 121 case Regs::FramebufferFormat::RGB8:
122 { 122 {
123 // TODO: Most likely got the component order messed up. 123 // TODO: Most likely got the component order messed up.
124 u8* dstptr = dest_pointer + x * 3 + y * config.output_width * 3 / 2; 124 u8* dstptr = dest_pointer + x * 3 + y * config.output_width * 3;
125 dstptr[0] = source_color.r; // blue 125 dstptr[0] = source_color.r; // blue
126 dstptr[1] = source_color.g; // green 126 dstptr[1] = source_color.g; // green
127 dstptr[2] = source_color.b; // red 127 dstptr[2] = source_color.b; // red
@@ -217,16 +217,15 @@ void Init() {
217 framebuffer_sub.address_right1 = 0x184C7800; 217 framebuffer_sub.address_right1 = 0x184C7800;
218 //framebuffer_sub.address_right2 = unknown; 218 //framebuffer_sub.address_right2 = unknown;
219 219
220 // TODO: Width should be 240 instead? 220 framebuffer_top.width = 240;
221 framebuffer_top.width = 480;
222 framebuffer_top.height = 400; 221 framebuffer_top.height = 400;
223 framebuffer_top.stride = 480*3; 222 framebuffer_top.stride = 3 * 240;
224 framebuffer_top.color_format = Regs::FramebufferFormat::RGB8; 223 framebuffer_top.color_format = Regs::FramebufferFormat::RGB8;
225 framebuffer_top.active_fb = 0; 224 framebuffer_top.active_fb = 0;
226 225
227 framebuffer_sub.width = 480; 226 framebuffer_sub.width = 240;
228 framebuffer_sub.height = 400; 227 framebuffer_sub.height = 320;
229 framebuffer_sub.stride = 480*3; 228 framebuffer_sub.stride = 3 * 240;
230 framebuffer_sub.color_format = Regs::FramebufferFormat::RGB8; 229 framebuffer_sub.color_format = Regs::FramebufferFormat::RGB8;
231 framebuffer_sub.active_fb = 0; 230 framebuffer_sub.active_fb = 0;
232 231
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;