Skip to content

Commit 06550d2

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 c12611d commit 06550d2

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
@@ -93,11 +93,14 @@ void OGLVideoDevice::UpdateTextures() {
9393
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
9494
};
9595

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

100-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gba_screen_width,
103+
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, gba_screen_width,
101104
gba_screen_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
102105

103106
set_texture_params(texture_filter);
@@ -110,12 +113,13 @@ void OGLVideoDevice::UpdateTextures() {
110113
const bool xbrz_ghosting =
111114
config->video.filter == Video::Filter::xBRZ && config->video.lcd_ghosting;
112115
if(config->video.lcd_ghosting) {
116+
const GLint history_texture_format = (!color_correction_active || xbrz_ghosting) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
113117
const GLsizei texture_width = xbrz_ghosting ? view_width : gba_screen_width;
114118
const GLsizei texture_height = xbrz_ghosting ? view_height : gba_screen_height;
115119

116120
glBindTexture(GL_TEXTURE_2D, textures[history_index]);
117121

118-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture_width, texture_height, 0,
122+
glTexImage2D(GL_TEXTURE_2D, 0, history_texture_format, texture_width, texture_height, 0,
119123
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
120124

121125
set_texture_params(GL_NEAREST);
@@ -124,7 +128,7 @@ void OGLVideoDevice::UpdateTextures() {
124128
if(xbrz_ghosting) {
125129
glBindTexture(GL_TEXTURE_2D, textures[xbrz_output_index]);
126130

127-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, view_width, view_height, 0,
131+
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, view_width, view_height, 0,
128132
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
129133

130134
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)