fix: 修复 V15 WeatherColor Metal 纹理生命周期
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
tei
2026-09-27 18:41:56 +09:00
parent cd71640a84
commit 5af91fe7a1
7 changed files with 236 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ add_library(
${PROJECT_SOURCE_DIR}/test/renderer/image_manager.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/pattern_atlas.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/particle_viewport_reseed.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/weather_color_texture_lifecycle.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/retained_underlay_cache.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/render_orchestrator_error.test.cpp
${PROJECT_SOURCE_DIR}/test/renderer/shader_registry.test.cpp

View File

@@ -0,0 +1,61 @@
#include <mbgl/renderer/layers/weather_color_texture_lifecycle.hpp>
#include <gtest/gtest.h>
using namespace mbgl;
TEST(WeatherColorTextureLifecycle, KeepsDrawablesForUnchangedEndpoints) {
int texture0 = 0;
int texture1 = 1;
EXPECT_FALSE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &texture0, &texture1, false));
// mix, opacity and color stops are dynamic UBO values and are not inputs
// to the binding decision.
}
TEST(WeatherColorTextureLifecycle, RebuildsForEitherOrBothReplacedEndpoints) {
int texture0 = 0;
int texture1 = 1;
int replacement0 = 2;
int replacement1 = 3;
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &replacement0, &texture1, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &texture0, &replacement1, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &replacement0, &replacement1, false));
}
TEST(WeatherColorTextureLifecycle, RebuildsWhenEndpointsAreCrossReusedOrCollapsed) {
int texture0 = 0;
int texture1 = 1;
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &texture1, &texture0, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &texture0, &texture0, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture0, &texture0, &texture1, false));
EXPECT_FALSE(weatherColorDrawableBindingsChanged(&texture0, &texture0, &texture0, &texture0, false));
}
TEST(WeatherColorTextureLifecycle, RebuildsWhenWrapRangeChangesWithoutTextureChanges) {
int texture0 = 0;
int texture1 = 1;
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&texture0, &texture1, &texture0, &texture1, true));
}
TEST(WeatherColorTextureLifecycle, DetectsEndpointReplacementAfterHiddenPeriod) {
int previous0 = 0;
int previous1 = 1;
int resumed0 = 2;
int resumed1 = 1;
// The layer may skip updates while hidden; on resume, the next update must
// rebuild before drawable upload if its selected endpoint changed.
EXPECT_TRUE(weatherColorDrawableBindingsChanged(&previous0, &previous1, &resumed0, &resumed1, false));
}
TEST(WeatherColorTextureLifecycle, HandlesInitialAndClearedEndpoints) {
int texture0 = 0;
EXPECT_FALSE(weatherColorDrawableBindingsChanged<int>(nullptr, nullptr, nullptr, nullptr, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged<int>(nullptr, nullptr, &texture0, &texture0, false));
EXPECT_TRUE(weatherColorDrawableBindingsChanged<int>(&texture0, &texture0, nullptr, nullptr, false));
}