Skip to content

Commit fa9f41d

Browse files
jschwemrobinson
authored andcommitted
Fix missing optimized shaders on OpenHarmony
We use GLES on OpenHarmony, so the shaders should be optimizied accordingly. Cargo guarantees that the CARG_CFG variables are set. Using expect instead of matching improves the readability. Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
1 parent 8c1bfc3 commit fa9f41d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

webrender/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ fn write_optimized_shaders(
128128

129129
// The full set of optimized shaders can be quite large, so only optimize
130130
// for the GL version we expect to be used on the target platform. If a different GL
131-
// version is used we will simply fall back to the unoptimized shaders.
132-
let shader_versions = match env::var("CARGO_CFG_TARGET_OS").as_ref().map(|s| &**s) {
133-
Ok("android") | Ok("windows") => [ShaderVersion::Gles],
131+
// version is used we will simply fall back to the unoptimized shaders.
132+
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("Cargo error");
133+
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("Cargo error");
134+
let shader_versions = match (target_os.as_str(), target_env.as_str()) {
135+
("android", _) | ("windows", _) | ("linux", "ohos") => [ShaderVersion::Gles],
134136
_ => [ShaderVersion::Gl],
135137
};
136138

wrench/src/test_shaders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn test_varying_explicit_precision(
119119

120120
pub fn test_shaders() {
121121
let mut flags = ShaderFeatureFlags::all();
122-
if cfg!(any(target_os = "windows", target_os = "android")) {
122+
if cfg!(any(target_os = "windows", target_os = "android", target_env = "ohos")) {
123123
flags.remove(ShaderFeatureFlags::GL);
124124
} else {
125125
flags.remove(ShaderFeatureFlags::GLES);

0 commit comments

Comments
 (0)