diff options
author | bunnei <bunneidev@gmail.com> | 2014-08-26 23:34:52 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-08-26 23:34:52 +0200 |
commit | 20d169e4a1753bf85c19c2799ace8b50fa2e3fa3 (patch) | |
tree | 9b90eb8eda2a89eeb7302d9fa5af79a466cd695b | |
parent | Merge pull request #74 from kevinhartman/master (diff) | |
download | yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.gz yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.bz2 yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.lz yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.xz yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.tar.zst yuzu-20d169e4a1753bf85c19c2799ace8b50fa2e3fa3.zip |
-rw-r--r-- | src/core/hw/gpu.cpp | 17 | ||||
-rw-r--r-- | src/video_core/clipper.cpp | 2 | ||||
-rw-r--r-- | src/video_core/rasterizer.cpp | 6 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 14 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 1 |
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) { for (int y = 0; y < config.output_height; ++y) { // TODO: Why does the register seem to hold twice the framebuffer width? - for (int x = 0; x < config.output_width / 2; ++x) { + for (int x = 0; x < config.output_width; ++x) { struct { int r, g, b, a; } source_color = { 0, 0, 0, 0 }; @@ -93,7 +93,7 @@ inline void Write(u32 addr, const T data) { case Regs::FramebufferFormat::RGBA8: { // TODO: Most likely got the component order messed up. - u8* srcptr = source_pointer + x * 4 + y * config.input_width * 4 / 2; + u8* srcptr = source_pointer + x * 4 + y * config.input_width * 4; source_color.r = srcptr[0]; // blue source_color.g = srcptr[1]; // green source_color.b = srcptr[2]; // red @@ -121,7 +121,7 @@ inline void Write(u32 addr, const T data) { case Regs::FramebufferFormat::RGB8: { // TODO: Most likely got the component order messed up. - u8* dstptr = dest_pointer + x * 3 + y * config.output_width * 3 / 2; + u8* dstptr = dest_pointer + x * 3 + y * config.output_width * 3; dstptr[0] = source_color.r; // blue dstptr[1] = source_color.g; // green dstptr[2] = source_color.b; // red @@ -217,16 +217,15 @@ void Init() { framebuffer_sub.address_right1 = 0x184C7800; //framebuffer_sub.address_right2 = unknown; - // TODO: Width should be 240 instead? - framebuffer_top.width = 480; + framebuffer_top.width = 240; framebuffer_top.height = 400; - framebuffer_top.stride = 480*3; + framebuffer_top.stride = 3 * 240; framebuffer_top.color_format = Regs::FramebufferFormat::RGB8; framebuffer_top.active_fb = 0; - framebuffer_sub.width = 480; - framebuffer_sub.height = 400; - framebuffer_sub.stride = 480*3; + framebuffer_sub.width = 240; + framebuffer_sub.height = 320; + framebuffer_sub.stride = 3 * 240; framebuffer_sub.color_format = Regs::FramebufferFormat::RGB8; framebuffer_sub.active_fb = 0; 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) viewport.offset_z = float24::FromRawFloat24(registers.viewport_depth_far_plane); // TODO: Not sure why the viewport width needs to be divided by 2 but the viewport height does not - vtx.screenpos[0] = (vtx.pos.x / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_x / float24::FromFloat32(2.0) + viewport.offset_x; + vtx.screenpos[0] = (vtx.pos.x / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_x + viewport.offset_x; vtx.screenpos[1] = (vtx.pos.y / vtx.pos.w + float24::FromFloat32(1.0)) * viewport.halfsize_y + viewport.offset_y; vtx.screenpos[2] = viewport.offset_z - vtx.pos.z / vtx.pos.w * viewport.zscale; } 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) { u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b(); // Assuming RGBA8 format until actual framebuffer format handling is implemented - *(color_buffer + x + y * registers.framebuffer.GetWidth() / 2) = value; + *(color_buffer + x + y * registers.framebuffer.GetWidth()) = value; } static u32 GetDepth(int x, int y) { u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); // Assuming 16-bit depth buffer format until actual format handling is implemented - return *(depth_buffer + x + y * registers.framebuffer.GetWidth() / 2); + return *(depth_buffer + x + y * registers.framebuffer.GetWidth()); } static void SetDepth(int x, int y, u16 value) { u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); // Assuming 16-bit depth buffer format until actual format handling is implemented - *(depth_buffer + x + y * registers.framebuffer.GetWidth() / 2) = value; + *(depth_buffer + x + y * registers.framebuffer.GetWidth()) = value; } void 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() { resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight; // Initialize screen info - screen_info.Top().width = VideoCore::kScreenTopWidth; - screen_info.Top().height = VideoCore::kScreenTopHeight; - screen_info.Top().flipped_xfb_data = xfb_top_flipped; + const auto& framebuffer_top = GPU::g_regs.framebuffer_config[0]; + const auto& framebuffer_sub = GPU::g_regs.framebuffer_config[1]; + + screen_info.Top().width = VideoCore::kScreenTopWidth; + screen_info.Top().height = VideoCore::kScreenTopHeight; + screen_info.Top().stride = framebuffer_top.stride; + screen_info.Top().flipped_xfb_data = xfb_top_flipped; screen_info.Bottom().width = VideoCore::kScreenBottomWidth; screen_info.Bottom().height = VideoCore::kScreenBottomHeight; + screen_info.Bottom().stride = framebuffer_sub.stride; screen_info.Bottom().flipped_xfb_data = xfb_bottom_flipped; } @@ -90,8 +95,8 @@ void RendererOpenGL::SwapBuffers() { * @todo Early on hack... I'd like to find a more efficient way of doing this /bunnei */ void RendererOpenGL::FlipFramebuffer(const u8* raw_data, ScreenInfo& screen_info) { - int in_coord = 0; for (int x = 0; x < screen_info.width; x++) { + int in_coord = x * screen_info.stride; for (int y = screen_info.height-1; y >= 0; y--) { // TODO: Properly support other framebuffer formats int out_coord = (x + y * screen_info.width) * 3; @@ -184,6 +189,7 @@ void RendererOpenGL::InitFramebuffer() { } void RendererOpenGL::RenderFramebuffer() { + glViewport(0, 0, resolution_width, resolution_height); glClear(GL_COLOR_BUFFER_BIT); 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: // Properties int width; int height; + int stride; ///< Number of bytes between the coordinates (0,0) and (1,0) // OpenGL object IDs GLuint texture_id; |