diff --git a/engine/src/flutter/impeller/compiler/compiler.cc b/engine/src/flutter/impeller/compiler/compiler.cc index ea2e0b0082..63c1323c2d 100644 --- a/engine/src/flutter/impeller/compiler/compiler.cc +++ b/engine/src/flutter/impeller/compiler/compiler.cc @@ -463,9 +463,10 @@ Compiler::Compiler(const fml::Mapping& source_mapping, } spirv_options.SetAutoBindUniforms(true); -#ifdef IMPELLER_ENABLE_VULKAN - SetBindingBase(spirv_options); -#endif + if (source_options.target_platform == TargetPlatform::kVulkan || + source_options.target_platform == TargetPlatform::kRuntimeStageVulkan) { + SetBindingBase(spirv_options); + } spirv_options.SetAutoMapLocations(true); std::vector included_file_names; diff --git a/engine/src/flutter/impeller/compiler/compiler_unittests.cc b/engine/src/flutter/impeller/compiler/compiler_unittests.cc index ed59fb8e5d..cf70a62cee 100644 --- a/engine/src/flutter/impeller/compiler/compiler_unittests.cc +++ b/engine/src/flutter/impeller/compiler/compiler_unittests.cc @@ -78,9 +78,9 @@ TEST_P(CompilerTest, MustFailDueToMultipleLocationPerStructMember) { } TEST_P(CompilerTest, BindingBaseForFragShader) { -#ifndef IMPELLER_ENABLE_VULKAN - GTEST_SKIP(); -#endif + if (!TargetPlatformIsVulkan(GetParam())) { + GTEST_SKIP(); + } ASSERT_TRUE(CanCompileAndReflect("sample.vert", SourceType::kVertexShader)); ASSERT_TRUE(CanCompileAndReflect("sample.frag", SourceType::kFragmentShader)); diff --git a/engine/src/flutter/impeller/compiler/types.cc b/engine/src/flutter/impeller/compiler/types.cc index 29efbea165..ab78492177 100644 --- a/engine/src/flutter/impeller/compiler/types.cc +++ b/engine/src/flutter/impeller/compiler/types.cc @@ -314,6 +314,24 @@ bool TargetPlatformIsMetal(TargetPlatform platform) { FML_UNREACHABLE(); } +bool TargetPlatformIsVulkan(TargetPlatform platform) { + switch (platform) { + case TargetPlatform::kRuntimeStageVulkan: + case TargetPlatform::kVulkan: + return true; + case TargetPlatform::kMetalDesktop: + case TargetPlatform::kMetalIOS: + case TargetPlatform::kRuntimeStageMetal: + case TargetPlatform::kUnknown: + case TargetPlatform::kSkSL: + case TargetPlatform::kOpenGLES: + case TargetPlatform::kOpenGLDesktop: + case TargetPlatform::kRuntimeStageGLES: + return false; + } + FML_UNREACHABLE(); +} + bool TargetPlatformBundlesSkSL(TargetPlatform platform) { switch (platform) { case TargetPlatform::kSkSL: diff --git a/engine/src/flutter/impeller/compiler/types.h b/engine/src/flutter/impeller/compiler/types.h index 226b988d64..52c57edb4a 100644 --- a/engine/src/flutter/impeller/compiler/types.h +++ b/engine/src/flutter/impeller/compiler/types.h @@ -48,6 +48,8 @@ bool TargetPlatformIsMetal(TargetPlatform platform); bool TargetPlatformIsOpenGL(TargetPlatform platform); +bool TargetPlatformIsVulkan(TargetPlatform platform); + SourceType SourceTypeFromFileName(const std::string& file_name); std::string SourceTypeToString(SourceType type);