/**************************************************************************/ /* openxr_opengl_extension.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "openxr_opengl_extension.h" #ifdef GLES3_ENABLED #include "../../openxr_util.h" #include "drivers/gles3/effects/copy_effects.h" #include "drivers/gles3/storage/texture_storage.h" #include "servers/rendering/rendering_server_globals.h" #include "servers/rendering_server.h" // OpenXR requires us to submit sRGB textures so that it recognizes the content // as being in sRGB color space. We do fall back on "normal" textures but this // will likely result in incorrect colors as OpenXR will double the sRGB conversion. // All major XR runtimes support sRGB textures. // In OpenGL output of the fragment shader is assumed to be in the color space of // the developers choice, however a linear to sRGB HW conversion can be enabled // through enabling GL_FRAMEBUFFER_SRGB if an sRGB color attachment is used. // This is a global setting. // See: https://www.khronos.org/opengl/wiki/Framebuffer // In OpenGLES output of the fragment shader is assumed to be in linear color space // and will be converted by default to sRGB if an sRGB color attachment is used. // The extension GL_EXT_sRGB_write_control was introduced to enable turning this // feature off. // See: https://registry.khronos.org/OpenGL/extensions/EXT/EXT_sRGB_write_control.txt HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() { … } void OpenXROpenGLExtension::on_instance_created(const XrInstance p_instance) { … } bool OpenXROpenGLExtension::check_graphics_api_support(XrVersion p_desired_version) { … } #ifdef WIN32 XrGraphicsBindingOpenGLWin32KHR OpenXROpenGLExtension::graphics_binding_gl; #elif defined(ANDROID_ENABLED) XrGraphicsBindingOpenGLESAndroidKHR OpenXROpenGLExtension::graphics_binding_gl; #elif defined(LINUXBSD_ENABLED) #ifdef X11_ENABLED XrGraphicsBindingOpenGLXlibKHR OpenXROpenGLExtension::graphics_binding_gl; #endif #if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED) XrGraphicsBindingEGLMNDX OpenXROpenGLExtension::graphics_binding_egl; #endif #endif void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_next_pointer) { … } void OpenXROpenGLExtension::get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) { … } void OpenXROpenGLExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_depth_formats) { … } 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) { … } bool OpenXROpenGLExtension::create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) { … } RID OpenXROpenGLExtension::get_texture(void *p_swapchain_graphics_data, int p_image_index) { … } void OpenXROpenGLExtension::cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) { … } #define ENUM_TO_STRING_CASE(e) … String OpenXROpenGLExtension::get_swapchain_format_name(int64_t p_swapchain_format) const { … } #endif // GLES3_ENABLED