Un-ifdef vulkan code in impellerc (flutter/engine#40797)

[Impeller] Un-ifdef vulkan code in impellerc
This commit is contained in:
Zachary Anderson
2023-03-30 13:56:02 -07:00
committed by GitHub
parent f944e918a1
commit a1119ed629
4 changed files with 27 additions and 6 deletions

View File

@@ -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<std::string> included_file_names;

View File

@@ -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));

View File

@@ -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:

View File

@@ -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);