diff options
| author | 2014-10-12 22:40:26 -0700 | |
|---|---|---|
| committer | 2015-03-09 15:51:41 -0700 | |
| commit | 041e99b6132775ff52822060512b8384b735e582 (patch) | |
| tree | cd8dee92a0b578e512a188cd7e70239b627a5341 /src/video_core | |
| parent | Implement SetLcdForceBlack, move register enum to hw.h (diff) | |
| download | yuzu-041e99b6132775ff52822060512b8384b735e582.tar.gz yuzu-041e99b6132775ff52822060512b8384b735e582.tar.xz yuzu-041e99b6132775ff52822060512b8384b735e582.zip | |
Added LCD registers, and implementation for color filling in OGL 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 272695174..2fcbb0cca 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 | #include "common/emu_window.h" | 9 | #include "common/emu_window.h" |
| 8 | #include "video_core/video_core.h" | 10 | #include "video_core/video_core.h" |
| @@ -61,16 +63,33 @@ void RendererOpenGL::SwapBuffers() { | |||
| 61 | for(int i : {0, 1}) { | 63 | for(int i : {0, 1}) { |
| 62 | const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; | 64 | const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; |
| 63 | 65 | ||
| 64 | if (textures[i].width != (GLsizei)framebuffer.width || | 66 | // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04 |
| 65 | textures[i].height != (GLsizei)framebuffer.height || | 67 | u32 lcd_color_addr = (i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom); |
| 66 | textures[i].format != framebuffer.color_format) { | 68 | lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr; |
| 67 | // Reallocate texture if the framebuffer size has changed. | 69 | LCD::Regs::ColorFill color_fill = {0}; |
| 68 | // This is expected to not happen very often and hence should not be a | 70 | LCD::Read(color_fill.raw, lcd_color_addr); |
| 69 | // performance problem. | 71 | |
| 70 | ConfigureFramebufferTexture(textures[i], framebuffer); | 72 | if (color_fill.is_enabled) { |
| 73 | LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, textures[i]); | ||
| 74 | |||
| 75 | // Resize the texture in case the framebuffer size has changed | ||
| 76 | textures[i].width = 1; | ||
| 77 | textures[i].height = 1; | ||
| 78 | } else { | ||
| 79 | if (textures[i].width != (GLsizei)framebuffer.width || | ||
| 80 | textures[i].height != (GLsizei)framebuffer.height || | ||
| 81 | textures[i].format != framebuffer.color_format) { | ||
| 82 | // Reallocate texture if the framebuffer size has changed. | ||
| 83 | // This is expected to not happen very often and hence should not be a | ||
| 84 | // performance problem. | ||
| 85 | ConfigureFramebufferTexture(textures[i], framebuffer); | ||
| 86 | } | ||
| 87 | LoadFBToActiveGLTexture(framebuffer, textures[i]); | ||
| 88 | |||
| 89 | // Resize the texture in case the framebuffer size has changed | ||
| 90 | textures[i].width = framebuffer.width; | ||
| 91 | textures[i].height = framebuffer.height; | ||
| 71 | } | 92 | } |
| 72 | |||
| 73 | LoadFBToActiveGLTexture(GPU::g_regs.framebuffer_config[i], textures[i]); | ||
| 74 | } | 93 | } |
| 75 | 94 | ||
| 76 | DrawScreens(); | 95 | DrawScreens(); |
| @@ -115,10 +134,25 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& | |||
| 115 | // TODO: Applications could theoretically crash Citra here by specifying too large | 134 | // TODO: Applications could theoretically crash Citra here by specifying too large |
| 116 | // framebuffer sizes. We should make sure that this cannot happen. | 135 | // framebuffer sizes. We should make sure that this cannot happen. |
| 117 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, | 136 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, framebuffer.width, framebuffer.height, |
| 118 | texture.gl_format, texture.gl_type, framebuffer_data); | 137 | texture.gl_format, texture.gl_type, framebuffer_data); |
| 119 | 138 | ||
| 120 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 139 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 140 | glBindTexture(GL_TEXTURE_2D, 0); | ||
| 141 | } | ||
| 121 | 142 | ||
| 143 | /** | ||
| 144 | * Fills active OpenGL texture with the given RGB color. | ||
| 145 | * Since the color is solid, the texture can be 1x1 but will stretch across whatever it's rendered on. | ||
| 146 | * This has the added benefit of being *really fast*. | ||
| 147 | */ | ||
| 148 | void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, | ||
| 149 | const TextureInfo& texture) { | ||
| 150 | glBindTexture(GL_TEXTURE_2D, texture.handle); | ||
| 151 | |||
| 152 | u8 framebuffer_data[3] = { color_r, color_g, color_b }; | ||
| 153 | |||
| 154 | // Update existing texture | ||
| 155 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, framebuffer_data); | ||
| 122 | glBindTexture(GL_TEXTURE_2D, 0); | 156 | glBindTexture(GL_TEXTURE_2D, 0); |
| 123 | } | 157 | } |
| 124 | 158 | ||
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; |