diff options
| author | 2015-03-10 18:08:55 -0400 | |
|---|---|---|
| committer | 2015-03-10 18:08:55 -0400 | |
| commit | b56829df020a81248dd04688ff2b307f3444a09f (patch) | |
| tree | 24a438627339b2d506e659adfa0873cdf037852a /src/video_core | |
| parent | Merge pull request #649 from lioncash/clean (diff) | |
| parent | Added LCD registers, and implementation for color filling in OGL code. (diff) | |
| download | yuzu-b56829df020a81248dd04688ff2b307f3444a09f.tar.gz yuzu-b56829df020a81248dd04688ff2b307f3444a09f.tar.xz yuzu-b56829df020a81248dd04688ff2b307f3444a09f.zip | |
Merge pull request #629 from archshift/lcdfb
Implement SetLcdForceBlack and add implementation for color filling in the GPU code
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 54 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 5 |
2 files changed, 48 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 95ab96340..4273a177f 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hw/gpu.h" | 5 | #include "core/hw/gpu.h" |
| 6 | #include "core/hw/hw.h" | ||
| 7 | #include "core/hw/lcd.h" | ||
| 6 | #include "core/mem_map.h" | 8 | #include "core/mem_map.h" |
| 7 | 9 | ||
| 8 | #include "common/emu_window.h" | 10 | #include "common/emu_window.h" |
| @@ -64,16 +66,33 @@ void RendererOpenGL::SwapBuffers() { | |||
| 64 | for(int i : {0, 1}) { | 66 | for(int i : {0, 1}) { |
| 65 | const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; | 67 | const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; |
| 66 | 68 | ||
| 67 | if (textures[i].width != (GLsizei)framebuffer.width || | 69 | // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04 |
| 68 | textures[i].height != (GLsizei)framebuffer.height || | 70 | u32 lcd_color_addr = (i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom); |
| 69 | textures[i].format != framebuffer.color_format) { | 71 | lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr; |
| 70 | // Reallocate texture if the framebuffer size has changed. | 72 | LCD::Regs::ColorFill color_fill = {0}; |
| 71 | // This is expected to not happen very often and hence should not be a | 73 | LCD::Read(color_fill.raw, lcd_color_addr); |
| 72 | // performance problem. | 74 | |
| 73 | ConfigureFramebufferTexture(textures[i], framebuffer); | 75 | if (color_fill.is_enabled) { |
| 76 | LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, textures[i]); | ||
| 77 | |||
| 78 | // Resize the texture in case the framebuffer size has changed | ||
| 79 | textures[i].width = 1; | ||
| 80 | textures[i].height = 1; | ||
| 81 | } else { | ||
| 82 | if (textures[i].width != (GLsizei)framebuffer.width || | ||
| 83 | textures[i].height != (GLsizei)framebuffer.height || | ||
| 84 | textures[i].format != framebuffer.color_format) { | ||
| 85 | // Reallocate texture if the framebuffer size has changed. | ||
| 86 | // This is expected to not happen very often and hence should not be a | ||
| 87 | // performance problem. | ||
| 88 | ConfigureFramebufferTexture(textures[i], framebuffer); | ||
| 89 | } | ||
| 90 | LoadFBToActiveGLTexture(framebuffer, textures[i]); | ||
| 91 | |||
| 92 | // Resize the texture in case the framebuffer size has changed | ||
| 93 | textures[i].width = framebuffer.width; | ||
| 94 | textures[i].height = framebuffer.height; | ||
| 74 | } | 95 | } |
| 75 | |||
| 76 | LoadFBToActiveGLTexture(GPU::g_regs.framebuffer_config[i], textures[i]); | ||
| 77 | } | 96 | } |
| 78 | 97 | ||
| 79 | DrawScreens(); | 98 | DrawScreens(); |
| @@ -127,10 +146,25 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& | |||
| 127 | // TODO: Applications could theoretically crash Citra here by specifying too large | 146 | // TODO: Applications could theoretically crash Citra here by specifying too large |
| 128 | // framebuffer sizes. We should make sure that this cannot happen. | 147 | // framebuffer sizes. We should make sure that this cannot happen. |
| 129 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, | 148 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, |
| 130 | texture.gl_format, texture.gl_type, framebuffer_data); | 149 | texture.gl_format, texture.gl_type, framebuffer_data); |
| 131 | 150 | ||
| 132 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 151 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 152 | glBindTexture(GL_TEXTURE_2D, 0); | ||
| 153 | } | ||
| 133 | 154 | ||
| 155 | /** | ||
| 156 | * Fills active OpenGL texture with the given RGB color. | ||
| 157 | * Since the color is solid, the texture can be 1x1 but will stretch across whatever it's rendered on. | ||
| 158 | * This has the added benefit of being *really fast*. | ||
| 159 | */ | ||
| 160 | void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, | ||
| 161 | const TextureInfo& texture) { | ||
| 162 | glBindTexture(GL_TEXTURE_2D, texture.handle); | ||
| 163 | |||
| 164 | u8 framebuffer_data[3] = { color_r, color_g, color_b }; | ||
| 165 | |||
| 166 | // Update existing texture | ||
| 167 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, framebuffer_data); | ||
| 134 | glBindTexture(GL_TEXTURE_2D, 0); | 168 | glBindTexture(GL_TEXTURE_2D, 0); |
| 135 | } | 169 | } |
| 136 | 170 | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index bcabab557..cd782428e 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -58,6 +58,9 @@ private: | |||
| 58 | // Loads framebuffer from emulated memory into the active OpenGL texture. | 58 | // Loads framebuffer from emulated memory into the active OpenGL texture. |
| 59 | static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer, | 59 | static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer, |
| 60 | const TextureInfo& texture); | 60 | const TextureInfo& texture); |
| 61 | // Fills active OpenGL texture with the given RGB color. | ||
| 62 | static void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, | ||
| 63 | const TextureInfo& texture); | ||
| 61 | 64 | ||
| 62 | /// Computes the viewport rectangle | 65 | /// Computes the viewport rectangle |
| 63 | MathUtil::Rectangle<unsigned> GetViewportExtent(); | 66 | MathUtil::Rectangle<unsigned> GetViewportExtent(); |
| @@ -72,7 +75,7 @@ private: | |||
| 72 | GLuint vertex_array_handle; | 75 | GLuint vertex_array_handle; |
| 73 | GLuint vertex_buffer_handle; | 76 | GLuint vertex_buffer_handle; |
| 74 | GLuint program_id; | 77 | GLuint program_id; |
| 75 | std::array<TextureInfo, 2> textures; | 78 | std::array<TextureInfo, 2> textures; ///< Textures for top and bottom screens respectively |
| 76 | // Shader uniform location indices | 79 | // Shader uniform location indices |
| 77 | GLuint uniform_modelview_matrix; | 80 | GLuint uniform_modelview_matrix; |
| 78 | GLuint uniform_color_texture; | 81 | GLuint uniform_color_texture; |