MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / InitState

Method InitState

tests/framework/render.cpp:616–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616void VkRenderFramework::InitState(VkPhysicalDeviceFeatures* features, void* create_device_pnext,
617 const VkCommandPoolCreateFlags flags) {
618 const auto ExtensionIncludedInDeviceApiVersion = [&](const char* extension) {
619 if (IsPromotedDeviceExtension(extension)) {
620 // Replicate the core entry points into the extension entry points
621 vk::InitExtensionFromCore(extension);
622
623 // Handle special cases which did not have a feature flag in the extension
624 // but do have one in their core promoted form
625 static const std::unordered_map<std::string, std::vector<vkt::Feature>> vk12_ext_features = {
626 {VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, {vkt::Feature::drawIndirectCount}},
627 {VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, {vkt::Feature::samplerFilterMinmax}},
628 {VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME,
629 {vkt::Feature::shaderOutputViewportIndex, vkt::Feature::shaderOutputLayer}},
630 {VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, {vkt::Feature::descriptorIndexing}},
631 {VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME, {vkt::Feature::scalarBlockLayout}}};
632 auto it = vk12_ext_features.find(extension);
633 if (it != vk12_ext_features.end()) {
634 for (const auto feature : it->second) {
635 AddRequiredFeature(feature);
636 }
637 }
638
639 return true;
640 }
641 return false;
642 };
643 const auto ExtensionNotSupportedWithReporting = [this](const char* extension) {
644 if (DeviceExtensionSupported(extension))
645 return false;
646 else {
647 ADD_FAILURE() << "InitState(): Requested device extension \"" << extension
648 << "\" is not supported. It will be disabled.";
649 return true;
650 }
651 };
652
653 // Remove promoted extensions from both the instance and required extension lists
654 if (!allow_promoted_extensions_) {
655 RemoveIf(m_required_extensions, ExtensionIncludedInDeviceApiVersion);
656 RemoveIf(m_optional_extensions, ExtensionIncludedInDeviceApiVersion);
657 RemoveIf(m_device_extension_names, ExtensionIncludedInDeviceApiVersion);
658 }
659
660 RemoveIf(m_device_extension_names, ExtensionNotSupportedWithReporting);
661
662 // Apply required features after we are done with handling promoted extensions
663 if (!features) {
664 if (requested_features_.HasFeatures2()) {
665 if (vk::GetPhysicalDeviceFeatures2KHR) {
666 vk::GetPhysicalDeviceFeatures2KHR(Gpu(), requested_features_.GetQueriedFeatures2());
667 } else {
668 vk::GetPhysicalDeviceFeatures2(Gpu(), requested_features_.GetQueriedFeatures2());
669 }
670 } else {
671 GetPhysicalDeviceFeatures(requested_features_.GetQueriedFeatures());
672 }
673

Callers

nothing calls this directly

Calls 15

InitExtensionFromCoreFunction · 0.85
RemoveIfFunction · 0.85
InitDeviceExtensionFunction · 0.85
AppendFunction · 0.85
ContainsFunction · 0.85
HasFeatures2Method · 0.80
GetQueriedFeatures2Method · 0.80
GetQueriedFeaturesMethod · 0.80
GetEnabledFeatures2Method · 0.80

Tested by

no test coverage detected