MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / prepare

Method prepare

samples/performance/constant_data/constant_data.cpp:83–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool ConstantData::prepare(const vkb::ApplicationOptions &options)
84{
85 if (!VulkanSample::prepare(options))
86 {
87 return false;
88 }
89
90 // If descriptor indexing and its dependencies were enabled, then we can mark the update after bind method as supported
91 if (get_instance().is_extension_enabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) &&
92 get_device().is_extension_enabled(VK_KHR_MAINTENANCE3_EXTENSION_NAME) &&
93 get_device().is_extension_enabled(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME))
94 {
95 methods[Method::UpdateAfterBindDescriptorSets].supported = true;
96 }
97 else
98 {
99 LOGW("Update-after-bind descriptor sets are not supported by your device, this sample option will be disabled.");
100 }
101
102 // Load a scene from the assets folder
103 load_scene("scenes/bonza/Bonza4X.gltf");
104
105 // Attach a move script to the camera component in the scene
106 auto &camera_node = vkb::add_free_camera(get_scene(), "main_camera", get_render_context().get_surface_extent());
107 camera = dynamic_cast<vkb::sg::PerspectiveCamera *>(&camera_node.get_component<vkb::sg::Camera>());
108
109 // Create the render pipelines
110
111 // Shader data passing depends on max. push constant size of the implementation
112 auto push_constant_limit = get_device().get_gpu().get_properties().limits.maxPushConstantsSize;
113
114 push_constant_render_pipeline = create_render_pipeline<PushConstantSubpass>(push_constant_limit >= 256 ? "constant_data/push_constant_large.vert.spv" : "constant_data/push_constant_small.vert.spv", "constant_data/push_constant.frag.spv");
115 descriptor_set_render_pipeline = create_render_pipeline<DescriptorSetSubpass>(push_constant_limit >= 256 ? "constant_data/ubo_large.vert.spv" : "constant_data/ubo_small.vert.spv", "constant_data/ubo.frag.spv");
116 buffer_array_render_pipeline = create_render_pipeline<BufferArraySubpass>("constant_data/buffer_array.vert.spv", "constant_data/buffer_array.frag.spv");
117
118 // Add a GUI with the stats you want to monitor
119 get_stats().request_stats(std::set<vkb::StatIndex>{vkb::StatIndex::frame_times, vkb::StatIndex::gpu_load_store_cycles});
120 create_gui(*window, &get_stats());
121
122 return true;
123}
124
125void ConstantData::request_gpu_features(vkb::core::PhysicalDeviceC &gpu)
126{

Callers 1

draw_renderpassMethod · 0.45

Calls 2

request_statsMethod · 0.80
is_extension_enabledMethod · 0.45

Tested by

no test coverage detected