Skip to content

Commit

Permalink
[Impeller] Remove unactionable error logs and use structure chains fo…
Browse files Browse the repository at this point in the history
…r instance creation. (flutter#43629)

I didn't know this when I wrote it initially but structure chains will throw a compile time error if a chain member violates the Vulkan spec. pNext chaining is easy to mess up otherwise and we should use structure chains where possible. We are already doing this during pipeline construction.
  • Loading branch information
chinmaygarde authored and harryterkelsen committed Jul 20, 2023
1 parent 9265fc6 commit bff04a5
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions impeller/renderer/backend/vulkan/context_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,21 @@ void ContextVK::Setup(Settings settings) {
application_info.setPEngineName("Impeller");
application_info.setPApplicationName("Impeller");

vk::StructureChain<vk::InstanceCreateInfo, vk::ValidationFeaturesEXT>
instance_chain;

if (!caps->AreValidationsEnabled()) {
instance_chain.unlink<vk::ValidationFeaturesEXT>();
}

std::vector<vk::ValidationFeatureEnableEXT> enabled_validations = {
vk::ValidationFeatureEnableEXT::eSynchronizationValidation,
};

vk::ValidationFeaturesEXT validation;
auto validation = instance_chain.get<vk::ValidationFeaturesEXT>();
validation.setEnabledValidationFeatures(enabled_validations);

vk::InstanceCreateInfo instance_info;
if (caps->AreValidationsEnabled()) {
std::stringstream ss;
ss << "Enabling validation layers, features: [";
for (const auto& validation : enabled_validations) {
ss << vk::to_string(validation) << " ";
}
ss << "]";
FML_LOG(ERROR) << ss.str();
#if !defined(IMPELLER_ENABLE_VULKAN_VALIDATION_LAYERS) && FML_OS_ANDROID
FML_LOG(ERROR) << "Vulkan validation layers turned on but the gn argument "
"`--enable-vulkan-validation-layers` is missing.";
#endif
instance_info.pNext = &validation;
}
auto instance_info = instance_chain.get<vk::InstanceCreateInfo>();
instance_info.setPEnabledLayerNames(enabled_layers_c);
instance_info.setPEnabledExtensionNames(enabled_extensions_c);
instance_info.setPApplicationInfo(&application_info);
Expand Down

0 comments on commit bff04a5

Please sign in to comment.