The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/vk: Add printing functions for create info structs

+103
+16
src/xrt/auxiliary/vk/vk_helpers.h
··· 657 657 void 658 658 vk_print_external_handles_info(struct vk_bundle *vk, enum u_logging_level log_level); 659 659 660 + /*! 661 + * Print a @p VkSwapchainCreateInfoKHR, used to log during creation. 662 + */ 663 + void 664 + vk_print_swapchain_create_info(struct vk_bundle *vk, VkSwapchainCreateInfoKHR *i, enum u_logging_level log_level); 665 + 666 + #ifdef VK_KHR_display 667 + /*! 668 + * Print a @p VkDisplaySurfaceCreateInfoKHR, used to log during creation. 669 + */ 670 + void 671 + vk_print_display_surface_create_info(struct vk_bundle *vk, 672 + VkDisplaySurfaceCreateInfoKHR *i, 673 + enum u_logging_level log_level); 674 + #endif 675 + 660 676 661 677 /* 662 678 *
+87
src/xrt/auxiliary/vk/vk_print.c
··· 9 9 * @ingroup aux_vk 10 10 */ 11 11 12 + #include "util/u_pretty_print.h" 12 13 #include "vk/vk_helpers.h" 13 14 15 + 16 + /* 17 + * 18 + * Helpers. 19 + * 20 + */ 21 + 22 + #define P(...) u_pp(dg, __VA_ARGS__) 23 + #define PNT(...) u_pp(dg, "\n\t" __VA_ARGS__) 24 + #define PNTT(...) u_pp(dg, "\n\t\t" __VA_ARGS__) 25 + #define PRINT_BITS(BITS, FUNC) \ 26 + do { \ 27 + for (uint32_t index = 0; index < 32; index++) { \ 28 + uint32_t bit = (BITS) & (1u << index); \ 29 + if (!bit) { \ 30 + continue; \ 31 + } \ 32 + const char *str = FUNC(bit, true); \ 33 + if (str != NULL) { \ 34 + PNTT("%s", str); \ 35 + } else { \ 36 + PNTT("0x%08x", bit); \ 37 + } \ 38 + } \ 39 + } while (false) 40 + 41 + 42 + /* 43 + * 44 + * 'Exported' functions. 45 + * 46 + */ 14 47 15 48 void 16 49 vk_print_device_info(struct vk_bundle *vk, ··· 160 193 #error "Need port for fence sync handles printers" 161 194 #endif 162 195 } 196 + 197 + void 198 + vk_print_swapchain_create_info(struct vk_bundle *vk, VkSwapchainCreateInfoKHR *i, enum u_logging_level log_level) 199 + { 200 + struct u_pp_sink_stack_only sink; 201 + u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); 202 + P("VkSwapchainCreateInfoKHR:"); 203 + PNT("surface: %p", (void *)i->surface); 204 + PNT("minImageCount: %u", i->minImageCount); 205 + PNT("imageFormat: %s", vk_format_string(i->imageFormat)); 206 + PNT("imageColorSpace: %s", vk_color_space_string(i->imageColorSpace)); 207 + PNT("imageExtent: {%u, %u}", i->imageExtent.width, i->imageExtent.height); 208 + PNT("imageArrayLayers: %u", i->imageArrayLayers); 209 + PNT("imageUsage:"); 210 + PRINT_BITS(i->imageUsage, vk_image_usage_flag_string); 211 + PNT("imageSharingMode: %s", vk_sharing_mode_string(i->imageSharingMode)); 212 + PNT("queueFamilyIndexCount: %u", i->queueFamilyIndexCount); 213 + PNT("preTransform: %s", vk_surface_transform_flag_string(i->preTransform, false)); 214 + PNT("compositeAlpha: %s", vk_composite_alpha_flag_string(i->compositeAlpha, false)); 215 + PNT("presentMode: %s", vk_present_mode_string(i->presentMode)); 216 + PNT("clipped: %s", i->clipped ? "VK_TRUE" : "VK_FALSE"); 217 + PNT("oldSwapchain: %p", (void *)i->oldSwapchain); 218 + 219 + U_LOG_IFL(log_level, vk->log_level, "%s", sink.buffer); 220 + } 221 + 222 + #ifdef VK_KHR_display 223 + void 224 + vk_print_display_surface_create_info(struct vk_bundle *vk, 225 + VkDisplaySurfaceCreateInfoKHR *i, 226 + enum u_logging_level log_level) 227 + { 228 + struct u_pp_sink_stack_only sink; 229 + u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); 230 + 231 + P("VkDisplaySurfaceCreateInfoKHR:"); 232 + if (i->flags == 0) { 233 + // No flags defined so only zero is valid. 234 + PNT("flags:"); 235 + } else { 236 + // Field reserved for future use, just in case. 237 + PNT("flags: UNKNOWN FLAG(S) 0x%x", i->flags); 238 + } 239 + PNT("displayMode: %p", (void *)i->displayMode); 240 + PNT("planeIndex: %u", i->planeIndex); 241 + PNT("planeStackIndex: %u", i->planeStackIndex); 242 + PNT("transform: %s", vk_surface_transform_flag_string(i->transform, false)); 243 + PNT("planeIndex: %f", i->globalAlpha); 244 + PNT("alphaMode: %s", vk_display_plane_alpha_flag_string(i->alphaMode, false)); 245 + PNT("imageExtent: {%u, %u}", i->imageExtent.width, i->imageExtent.height); 246 + 247 + U_LOG_IFL(log_level, vk->log_level, "%s", sink.buffer); 248 + } 249 + #endif