From 1ba58ba84a7708cd5e15e9dcc5dd7cc6a42e9bb7 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Sun, 28 Jul 2024 14:46:14 -0700 Subject: [PATCH] Remove references to unused custom uniforms. (#6587) * Remove references to unused custom uniforms. Some graphics cards/drivers do not allow uniforms that are unused because they are optimized away by the GLSL compiler. The uniforms "subCamerasResolutionX" and "subCamerasResolutionY" were present in merge_spherical.frag but were never used. As a result, when trying to call to glGetUniformLocation() would return -1 for those names, crashing webots. * Updated changelog. --------- Co-authored-by: Olivier Michel --- docs/reference/changelog-r2024.md | 1 + resources/wren/shaders/merge_spherical.frag | 2 -- src/webots/wren/WbWrenCamera.cpp | 8 -------- src/webots/wren/WbWrenShaders.cpp | 5 ----- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/docs/reference/changelog-r2024.md b/docs/reference/changelog-r2024.md index cee92ad3825..b443f32060a 100644 --- a/docs/reference/changelog-r2024.md +++ b/docs/reference/changelog-r2024.md @@ -14,4 +14,5 @@ Released on December **th, 2023. - Fixed length of arrays returned by `getPose()` in Java ([#6556](https://github.com/cyberbotics/webots/pull/6556)). - Fixed length of arrays returned by `CameraRecognitionObject.getColors()` in Java ([#6564](https://github.com/cyberbotics/webots/pull/6564)). - Fixed handling of device objects with the same name in the controller API ([#6579](https://github.com/cyberbotics/webots/pull/6579)). + - Fixed crashes (with some graphics cards) caused by references to unused GLSL uniforms ([#6587](https://github.com/cyberbotics/webots/pull/6587)). - Fixed `Brake`s added to the second axis of a `Hinge2Joint` being applied to the non-transformed axis ([#6584](https://github.com/cyberbotics/webots/pull/6584)). diff --git a/resources/wren/shaders/merge_spherical.frag b/resources/wren/shaders/merge_spherical.frag index 0c3558caddd..7cc1578a451 100644 --- a/resources/wren/shaders/merge_spherical.frag +++ b/resources/wren/shaders/merge_spherical.frag @@ -23,8 +23,6 @@ out vec4 fragColor; uniform bool rangeCamera; uniform bool cylindrical; -uniform int subCamerasResolutionX; -uniform int subCamerasResolutionY; uniform float maxRange; uniform float minRange; diff --git a/src/webots/wren/WbWrenCamera.cpp b/src/webots/wren/WbWrenCamera.cpp index a692032c4ee..f507904b2d1 100644 --- a/src/webots/wren/WbWrenCamera.cpp +++ b/src/webots/wren/WbWrenCamera.cpp @@ -979,14 +979,6 @@ void WbWrenCamera::applySphericalPostProcessingEffect() { WR_SHADER_PROGRAM_UNIFORM_TYPE_BOOL, reinterpret_cast(&isCylindrical)); - wr_shader_program_set_custom_uniform_value(WbWrenShaders::mergeSphericalShader(), "subCamerasResolutionX", - WR_SHADER_PROGRAM_UNIFORM_TYPE_INT, - reinterpret_cast(&mSubCamerasResolutionX)); - - wr_shader_program_set_custom_uniform_value(WbWrenShaders::mergeSphericalShader(), "subCamerasResolutionY", - WR_SHADER_PROGRAM_UNIFORM_TYPE_INT, - reinterpret_cast(&mSubCamerasResolutionY)); - wr_shader_program_set_custom_uniform_value(WbWrenShaders::mergeSphericalShader(), "minRange", WR_SHADER_PROGRAM_UNIFORM_TYPE_FLOAT, reinterpret_cast(&mMinRange)); diff --git a/src/webots/wren/WbWrenShaders.cpp b/src/webots/wren/WbWrenShaders.cpp index fc55088235e..c42841de18a 100644 --- a/src/webots/wren/WbWrenShaders.cpp +++ b/src/webots/wren/WbWrenShaders.cpp @@ -735,16 +735,11 @@ WrShaderProgram *WbWrenShaders::mergeSphericalShader() { wr_shader_program_use_uniform(gShaders[SHADER_MERGE_SPHERICAL], WR_GLSL_LAYOUT_UNIFORM_TEXTURE4); wr_shader_program_use_uniform(gShaders[SHADER_MERGE_SPHERICAL], WR_GLSL_LAYOUT_UNIFORM_TEXTURE5); - const int defaultInt = 0; const bool defaultBool = false; wr_shader_program_create_custom_uniform(gShaders[SHADER_MERGE_SPHERICAL], "rangeCamera", WR_SHADER_PROGRAM_UNIFORM_TYPE_BOOL, reinterpret_cast(&defaultBool)); wr_shader_program_create_custom_uniform(gShaders[SHADER_MERGE_SPHERICAL], "cylindrical", WR_SHADER_PROGRAM_UNIFORM_TYPE_BOOL, reinterpret_cast(&defaultBool)); - wr_shader_program_create_custom_uniform(gShaders[SHADER_MERGE_SPHERICAL], "subCamerasResolutionX", - WR_SHADER_PROGRAM_UNIFORM_TYPE_INT, reinterpret_cast(&defaultInt)); - wr_shader_program_create_custom_uniform(gShaders[SHADER_MERGE_SPHERICAL], "subCamerasResolutionY", - WR_SHADER_PROGRAM_UNIFORM_TYPE_INT, reinterpret_cast(&defaultInt)); const float defaultFloat = 0.0f; wr_shader_program_create_custom_uniform(gShaders[SHADER_MERGE_SPHERICAL], "minRange", WR_SHADER_PROGRAM_UNIFORM_TYPE_FLOAT,