Skip to content

Commit 98d30e9

Browse files
committed
PlatformCore: Conditionally set texture format
sRGB texture format is needed for the output to look right with sRGB framebuffer enabled and no color correction shader applied.
1 parent 3d59449 commit 98d30e9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/platform/core/src/device/ogl_video_device.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ void OGLVideoDevice::UpdateTextures() {
9191
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
9292
};
9393

94+
const bool color_correction_active = config->video.color != Video::Color::No;
95+
const auto texture_format = color_correction_active ? GL_RGBA8 : GL_SRGB8_ALPHA8;
96+
9497
// Alternating input sampler and output framebuffer attachment.
9598
for(const auto texture : {textures[input_index], textures[output_index]}) {
9699
glBindTexture(GL_TEXTURE_2D, texture);
97100

98-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gba_screen_width,
101+
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, gba_screen_width,
99102
gba_screen_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
100103

101104
set_texture_params(texture_filter);
@@ -108,12 +111,13 @@ void OGLVideoDevice::UpdateTextures() {
108111
const bool xbrz_ghosting =
109112
config->video.filter == Video::Filter::xBRZ && config->video.lcd_ghosting;
110113
if(config->video.lcd_ghosting) {
114+
const GLint history_texture_format = (!color_correction_active || xbrz_ghosting) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
111115
const GLsizei texture_width = xbrz_ghosting ? view_width : gba_screen_width;
112116
const GLsizei texture_height = xbrz_ghosting ? view_height : gba_screen_height;
113117

114118
glBindTexture(GL_TEXTURE_2D, textures[history_index]);
115119

116-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture_width, texture_height, 0,
120+
glTexImage2D(GL_TEXTURE_2D, 0, history_texture_format, texture_width, texture_height, 0,
117121
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
118122

119123
set_texture_params(GL_NEAREST);
@@ -122,7 +126,7 @@ void OGLVideoDevice::UpdateTextures() {
122126
if(xbrz_ghosting) {
123127
glBindTexture(GL_TEXTURE_2D, textures[xbrz_output_index]);
124128

125-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, view_width, view_height, 0,
129+
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, view_width, view_height, 0,
126130
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
127131

128132
set_texture_params(GL_NEAREST);

src/platform/qt/src/widget/screen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void Screen::SetForceClear(bool force_clear) {
2929
}
3030

3131
void Screen::ReloadConfig() {
32+
makeCurrent(); // Workaround for Intel graphics.
3233
ogl_video_device.ReloadConfig();
3334
UpdateViewport();
3435
}

0 commit comments

Comments
 (0)