| 941 | } |
| 942 | |
| 943 | bool TimestampQueries::prepare(const vkb::ApplicationOptions &options) |
| 944 | { |
| 945 | if (!ApiVulkanSample::prepare(options)) |
| 946 | { |
| 947 | return false; |
| 948 | } |
| 949 | |
| 950 | // Check if the selected device supports timestamps. A value of zero means no support. |
| 951 | VkPhysicalDeviceLimits device_limits = get_device().get_gpu().get_properties().limits; |
| 952 | if (device_limits.timestampPeriod == 0) |
| 953 | { |
| 954 | throw std::runtime_error{"The selected device does not support timestamp queries!"}; |
| 955 | } |
| 956 | |
| 957 | // Check if all queues support timestamp queries, if not we need to check on a per-queue basis |
| 958 | if (!device_limits.timestampComputeAndGraphics) |
| 959 | { |
| 960 | // Check if the graphics queue used in this sample supports time stamps |
| 961 | VkQueueFamilyProperties graphics_queue_family_properties = get_device().get_queue_by_flags(VK_QUEUE_GRAPHICS_BIT, 0).get_properties(); |
| 962 | if (graphics_queue_family_properties.timestampValidBits == 0) |
| 963 | { |
| 964 | throw std::runtime_error{"The selected graphics queue family does not support timestamp queries!"}; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | camera.type = vkb::CameraType::LookAt; |
| 969 | camera.set_position(glm::vec3(0.0f, 0.0f, -4.0f)); |
| 970 | camera.set_rotation(glm::vec3(0.0f, 180.0f, 0.0f)); |
| 971 | |
| 972 | // Note: Using reversed depth-buffer for increased precision, so Znear and Zfar are flipped |
| 973 | camera.set_perspective(60.0f, static_cast<float>(width) / static_cast<float>(height), 256.0f, 0.1f); |
| 974 | |
| 975 | load_assets(); |
| 976 | prepare_uniform_buffers(); |
| 977 | prepare_offscreen_buffer(); |
| 978 | setup_descriptor_set_layout(); |
| 979 | prepare_pipelines(); |
| 980 | setup_descriptor_pool(); |
| 981 | setup_descriptor_sets(); |
| 982 | prepare_time_stamp_queries(); |
| 983 | build_command_buffers(); |
| 984 | prepared = true; |
| 985 | return true; |
| 986 | } |
| 987 | |
| 988 | void TimestampQueries::render(float delta_time) |
| 989 | { |
nothing calls this directly
no test coverage detected