Skip to content

Commit dfcff4e

Browse files
committed
OpenGL: Unconditionally do glDisable(GL_FRAMEBUFFER_SRGB) because we do our own sRGB conversion
1 parent 86c95d2 commit dfcff4e

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

drivers/gles3/rasterizer_gles3.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
#define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148
6363
#define _EXT_DEBUG_OUTPUT 0x92E0
6464

65+
#ifndef GL_FRAMEBUFFER_SRGB
66+
#define GL_FRAMEBUFFER_SRGB 0x8DB9
67+
#endif
68+
6569
#ifndef GLAPIENTRY
6670
#if defined(WINDOWS_ENABLED)
6771
#define GLAPIENTRY APIENTRY
@@ -345,6 +349,9 @@ RasterizerGLES3::RasterizerGLES3() {
345349
}
346350
}
347351

352+
// Disable OpenGL linear to sRGB conversion, because Godot will always do this conversion itself.
353+
glDisable(GL_FRAMEBUFFER_SRGB);
354+
348355
// OpenGL needs to be initialized before initializing the Rasterizers
349356
config = memnew(GLES3::Config);
350357
utilities = memnew(GLES3::Utilities);

modules/openxr/extensions/platform/openxr_opengl_extension.cpp

-22
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@
5656
// feature off.
5757
// See: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_sRGB_write_control.txt
5858

59-
// On OpenGLES this is not defined in our standard headers..
60-
#ifndef GL_FRAMEBUFFER_SRGB
61-
#define GL_FRAMEBUFFER_SRGB 0x8DB9
62-
#endif
63-
6459
HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() {
6560
HashMap<String, bool *> request_extensions;
6661

@@ -196,23 +191,6 @@ void OpenXROpenGLExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_d
196191
p_usable_depth_formats.push_back(GL_DEPTH_COMPONENT24);
197192
}
198193

199-
void OpenXROpenGLExtension::on_pre_draw_viewport(RID p_render_target) {
200-
if (srgb_ext_is_available) {
201-
hw_linear_to_srgb_is_enabled = glIsEnabled(GL_FRAMEBUFFER_SRGB);
202-
if (hw_linear_to_srgb_is_enabled) {
203-
// Disable this.
204-
glDisable(GL_FRAMEBUFFER_SRGB);
205-
}
206-
}
207-
}
208-
209-
void OpenXROpenGLExtension::on_post_draw_viewport(RID p_render_target) {
210-
if (srgb_ext_is_available && hw_linear_to_srgb_is_enabled) {
211-
// Re-enable this.
212-
glEnable(GL_FRAMEBUFFER_SRGB);
213-
}
214-
}
215-
216194
bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) {
217195
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
218196
ERR_FAIL_NULL_V(texture_storage, false);

modules/openxr/extensions/platform/openxr_opengl_extension.h

-6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {
4949
virtual void on_instance_created(const XrInstance p_instance) override;
5050
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
5151

52-
virtual void on_pre_draw_viewport(RID p_render_target) override;
53-
virtual void on_post_draw_viewport(RID p_render_target) override;
54-
5552
virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override;
5653
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override;
5754
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override;
@@ -76,9 +73,6 @@ class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {
7673
Vector<RID> texture_rids;
7774
};
7875

79-
bool srgb_ext_is_available = true;
80-
bool hw_linear_to_srgb_is_enabled = false;
81-
8276
bool check_graphics_api_support(XrVersion p_desired_version);
8377

8478
#ifdef ANDROID_ENABLED

0 commit comments

Comments
 (0)