Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL: Unconditionally do glDisable(GL_FRAMEBUFFER_SRGB) because we do our own sRGB conversion #95433

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
#define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148
#define _EXT_DEBUG_OUTPUT 0x92E0

#ifndef GL_FRAMEBUFFER_SRGB
#define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif

#ifndef GLAPIENTRY
#if defined(WINDOWS_ENABLED)
#define GLAPIENTRY APIENTRY
Expand Down Expand Up @@ -345,6 +349,9 @@ RasterizerGLES3::RasterizerGLES3() {
}
}

// Disable OpenGL linear to sRGB conversion, because Godot will always do this conversion itself.
glDisable(GL_FRAMEBUFFER_SRGB);

// OpenGL needs to be initialized before initializing the Rasterizers
config = memnew(GLES3::Config);
utilities = memnew(GLES3::Utilities);
Expand Down
22 changes: 0 additions & 22 deletions modules/openxr/extensions/platform/openxr_opengl_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
// feature off.
// See: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_sRGB_write_control.txt

// On OpenGLES this is not defined in our standard headers..
#ifndef GL_FRAMEBUFFER_SRGB
#define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif

HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() {
HashMap<String, bool *> request_extensions;

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

void OpenXROpenGLExtension::on_pre_draw_viewport(RID p_render_target) {
if (srgb_ext_is_available) {
hw_linear_to_srgb_is_enabled = glIsEnabled(GL_FRAMEBUFFER_SRGB);
if (hw_linear_to_srgb_is_enabled) {
// Disable this.
glDisable(GL_FRAMEBUFFER_SRGB);
}
}
}

void OpenXROpenGLExtension::on_post_draw_viewport(RID p_render_target) {
if (srgb_ext_is_available && hw_linear_to_srgb_is_enabled) {
// Re-enable this.
glEnable(GL_FRAMEBUFFER_SRGB);
}
}

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) {
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
ERR_FAIL_NULL_V(texture_storage, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {
virtual void on_instance_created(const XrInstance p_instance) override;
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;

virtual void on_pre_draw_viewport(RID p_render_target) override;
virtual void on_post_draw_viewport(RID p_render_target) override;

virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override;
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override;
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override;
Expand All @@ -76,9 +73,6 @@ class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {
Vector<RID> texture_rids;
};

bool srgb_ext_is_available = true;
bool hw_linear_to_srgb_is_enabled = false;

bool check_graphics_api_support(XrVersion p_desired_version);

#ifdef ANDROID_ENABLED
Expand Down
Loading