The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Follow style of using vk variable for vk_bundle interactions

authored by

Jakob Bornecrantz and committed by
Ryan Pavlik
bd6e15c7 3af65d60

+131 -92
+21 -25
src/xrt/compositor/main/comp_compositor.c
··· 559 559 comp_resources_close(c, &c->nr); 560 560 561 561 // As long as vk_bundle is valid it's safe to call this function. 562 - comp_shaders_close(&c->vk, &c->shaders); 562 + comp_shaders_close(vk, &c->shaders); 563 563 564 564 // Does NULL checking. 565 565 comp_target_destroy(&c->target); ··· 645 645 * 646 646 */ 647 647 648 - #define GET_DEV_PROC(c, name) (PFN_##name) c->vk.vkGetDeviceProcAddr(c->vk.device, #name); 649 - #define GET_INS_PROC(c, name) (PFN_##name) c->vk.vkGetInstanceProcAddr(c->vk.instance, #name); 650 - #define GET_DEV_PROC(c, name) (PFN_##name) c->vk.vkGetDeviceProcAddr(c->vk.device, #name); 651 - 652 648 // NOLINTNEXTLINE // don't remove the forward decl. 653 649 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL 654 650 vkGetInstanceProcAddr(VkInstance instance, const char *pName); 655 651 656 - static VkResult 657 - find_get_instance_proc_addr(struct comp_compositor *c) 658 - { 659 - //! @todo Do any library loading here. 660 - return vk_get_loader_functions(&c->vk, vkGetInstanceProcAddr); 661 - } 662 - 663 652 664 653 // If any of these lists are updated, please also update the appropriate column 665 654 // in `vulkan-extensions.md` ··· 809 798 static VkResult 810 799 create_instance(struct comp_compositor *c) 811 800 { 801 + struct vk_bundle *vk = &c->vk; 812 802 const char **instance_extensions; 813 803 uint32_t num_extensions; 814 804 VkResult ret; ··· 833 823 .ppEnabledExtensionNames = instance_extensions, 834 824 }; 835 825 836 - ret = c->vk.vkCreateInstance(&instance_info, NULL, &c->vk.instance); 826 + ret = vk->vkCreateInstance(&instance_info, NULL, &vk->instance); 837 827 if (ret != VK_SUCCESS) { 838 828 CVK_ERROR(c, "vkCreateInstance", "Failed to create Vulkan instance", ret); 839 829 return ret; 840 830 } 841 831 842 - ret = vk_get_instance_functions(&c->vk); 832 + ret = vk_get_instance_functions(vk); 843 833 if (ret != VK_SUCCESS) { 844 834 CVK_ERROR(c, "vk_get_instance_functions", "Failed to get Vulkan instance functions.", ret); 845 835 return ret; ··· 873 863 static bool 874 864 compositor_init_vulkan(struct comp_compositor *c) 875 865 { 866 + struct vk_bundle *vk = &c->vk; 876 867 VkResult ret; 877 868 878 - c->vk.ll = c->settings.log_level; 869 + vk->ll = c->settings.log_level; 879 870 880 - ret = find_get_instance_proc_addr(c); 871 + //! @todo Do any library loading here. 872 + ret = vk_get_loader_functions(vk, vkGetInstanceProcAddr); 881 873 if (ret != VK_SUCCESS) { 882 - CVK_ERROR(c, "find_get_instance_proc_addr", "Failed to get VkInstance get process address.", ret); 874 + CVK_ERROR(c, "vk_get_loader_functions", "Failed to get VkInstance get process address.", ret); 883 875 return false; 884 876 } 885 877 ··· 904 896 // No other way then to try to see if realtime is available. 905 897 for (size_t i = 0; i < ARRAY_SIZE(prios); i++) { 906 898 ret = vk_create_device( // 907 - &c->vk, // 899 + vk, // 908 900 c->settings.selected_gpu_index, // 909 901 prios[i], // global_priority 910 902 required_device_extensions, // ··· 928 920 return false; 929 921 } 930 922 931 - ret = vk_init_mutex(&c->vk); 923 + ret = vk_init_mutex(vk); 932 924 if (ret != VK_SUCCESS) { 933 925 CVK_ERROR(c, "vk_init_mutex", "Failed to init mutex.", ret); 934 926 return false; 935 927 } 936 928 937 - c->settings.selected_gpu_index = c->vk.physical_device_index; 929 + c->settings.selected_gpu_index = vk->physical_device_index; 938 930 939 931 // store physical device UUID for compositor in settings 940 932 if (c->settings.selected_gpu_index >= 0) { 941 - if (get_device_uuid(&c->vk, c, c->settings.selected_gpu_index, c->settings.selected_gpu_deviceUUID)) { 933 + if (get_device_uuid(vk, c, c->settings.selected_gpu_index, c->settings.selected_gpu_deviceUUID)) { 942 934 char uuid_str[XRT_GPU_UUID_SIZE * 3 + 1] = {0}; 943 935 for (int i = 0; i < XRT_GPU_UUID_SIZE; i++) { 944 936 sprintf(uuid_str + i * 3, "%02x ", c->settings.selected_gpu_deviceUUID[i]); ··· 956 948 957 949 // store physical device UUID suggested to clients in settings 958 950 if (c->settings.client_gpu_index >= 0) { 959 - if (get_device_uuid(&c->vk, c, c->settings.client_gpu_index, c->settings.client_gpu_deviceUUID)) { 951 + if (get_device_uuid(vk, c, c->settings.client_gpu_index, c->settings.client_gpu_deviceUUID)) { 960 952 char uuid_str[XRT_GPU_UUID_SIZE * 3 + 1] = {0}; 961 953 for (int i = 0; i < XRT_GPU_UUID_SIZE; i++) { 962 954 sprintf(uuid_str + i * 3, "%02x ", c->settings.client_gpu_deviceUUID[i]); ··· 967 959 } 968 960 } 969 961 970 - ret = vk_init_cmd_pool(&c->vk); 962 + ret = vk_init_cmd_pool(vk); 971 963 if (ret != VK_SUCCESS) { 972 964 CVK_ERROR(c, "vk_init_cmd_pool", "Failed to init command pool.", ret); 973 965 return false; ··· 1295 1287 static bool 1296 1288 compositor_init_shaders(struct comp_compositor *c) 1297 1289 { 1298 - return comp_shaders_load(&c->vk, &c->shaders); 1290 + struct vk_bundle *vk = &c->vk; 1291 + 1292 + return comp_shaders_load(vk, &c->shaders); 1299 1293 } 1300 1294 1301 1295 static bool ··· 1312 1306 bool 1313 1307 comp_is_format_supported(struct comp_compositor *c, VkFormat format) 1314 1308 { 1309 + struct vk_bundle *vk = &c->vk; 1315 1310 VkFormatProperties prop; 1316 - c->vk.vkGetPhysicalDeviceFormatProperties(c->vk.physical_device, format, &prop); 1311 + 1312 + vk->vkGetPhysicalDeviceFormatProperties(vk->physical_device, format, &prop); 1317 1313 1318 1314 // This is a fairly crude way of checking support, 1319 1315 // but works well enough.
+77 -39
src/xrt/compositor/main/comp_layer.c
··· 51 51 static bool 52 52 _init_ubos(struct comp_render_layer *self) 53 53 { 54 + struct vk_bundle *vk = self->vk; 55 + 54 56 VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; 55 57 VkMemoryPropertyFlags properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; 56 58 57 59 for (uint32_t i = 0; i < 2; i++) { 58 60 math_matrix_4x4_identity(&self->transformation[i].mvp); 59 61 60 - if (!vk_buffer_init(self->vk, sizeof(struct layer_transformation), usage, properties, 61 - &self->transformation_ubos[i].handle, &self->transformation_ubos[i].memory)) 62 + if (!vk_buffer_init(vk, // 63 + sizeof(struct layer_transformation), // 64 + usage, // 65 + properties, // 66 + &self->transformation_ubos[i].handle, // 67 + &self->transformation_ubos[i].memory)) { 62 68 return false; 69 + } 63 70 64 - VkResult res = self->vk->vkMapMemory(self->vk->device, self->transformation_ubos[i].memory, 0, 65 - VK_WHOLE_SIZE, 0, &self->transformation_ubos[i].data); 71 + VkResult res = vk->vkMapMemory(vk->device, self->transformation_ubos[i].memory, 0, VK_WHOLE_SIZE, 0, 72 + &self->transformation_ubos[i].data); 66 73 vk_check_error("vkMapMemory", res, false); 67 74 68 75 memcpy(self->transformation_ubos[i].data, &self->transformation[i], ··· 75 82 static bool 76 83 _init_equirect1_ubo(struct comp_render_layer *self) 77 84 { 85 + struct vk_bundle *vk = self->vk; 86 + 78 87 VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; 79 88 VkMemoryPropertyFlags properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; 80 89 81 - if (!vk_buffer_init(self->vk, sizeof(struct layer_transformation), usage, properties, 82 - &self->equirect1_ubo.handle, &self->equirect1_ubo.memory)) 90 + if (!vk_buffer_init(vk, // 91 + sizeof(struct layer_transformation), // 92 + usage, // 93 + properties, // 94 + &self->equirect1_ubo.handle, // 95 + &self->equirect1_ubo.memory)) { 83 96 return false; 97 + } 84 98 85 - VkResult res = self->vk->vkMapMemory(self->vk->device, self->equirect1_ubo.memory, 0, VK_WHOLE_SIZE, 0, 86 - &self->equirect1_ubo.data); 99 + VkResult res = 100 + vk->vkMapMemory(vk->device, self->equirect1_ubo.memory, 0, VK_WHOLE_SIZE, 0, &self->equirect1_ubo.data); 87 101 vk_check_error("vkMapMemory", res, false); 88 102 89 103 memcpy(self->equirect1_ubo.data, &self->equirect1_data, sizeof(struct layer_equirect1_data)); ··· 95 109 static bool 96 110 _init_equirect2_ubo(struct comp_render_layer *self) 97 111 { 112 + struct vk_bundle *vk = self->vk; 113 + 98 114 VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; 99 115 VkMemoryPropertyFlags properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; 100 116 101 - if (!vk_buffer_init(self->vk, sizeof(struct layer_transformation), usage, properties, 102 - &self->equirect2_ubo.handle, &self->equirect2_ubo.memory)) 117 + if (!vk_buffer_init(vk, // 118 + sizeof(struct layer_transformation), // 119 + usage, // 120 + properties, // 121 + &self->equirect2_ubo.handle, // 122 + &self->equirect2_ubo.memory)) { 103 123 return false; 124 + } 104 125 105 - VkResult res = self->vk->vkMapMemory(self->vk->device, self->equirect2_ubo.memory, 0, VK_WHOLE_SIZE, 0, 106 - &self->equirect2_ubo.data); 126 + VkResult res = 127 + vk->vkMapMemory(vk->device, self->equirect2_ubo.memory, 0, VK_WHOLE_SIZE, 0, &self->equirect2_ubo.data); 107 128 vk_check_error("vkMapMemory", res, false); 108 129 109 130 memcpy(self->equirect2_ubo.data, &self->equirect2_data, sizeof(struct layer_equirect2_data)); ··· 159 180 static void 160 181 _update_descriptor_equirect(struct comp_render_layer *self, VkDescriptorSet set, VkBuffer buffer) 161 182 { 183 + struct vk_bundle *vk = self->vk; 184 + 162 185 VkWriteDescriptorSet *sets = (VkWriteDescriptorSet[]){ 163 186 { 164 187 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, ··· 176 199 }, 177 200 }; 178 201 179 - self->vk->vkUpdateDescriptorSets(self->vk->device, 1, sets, 0, NULL); 202 + vk->vkUpdateDescriptorSets(vk->device, 1, sets, 0, NULL); 180 203 } 181 204 #endif 182 205 183 206 void 184 207 comp_layer_update_descriptors(struct comp_render_layer *self, VkSampler sampler, VkImageView image_view) 185 208 { 186 - for (uint32_t eye = 0; eye < 2; eye++) 187 - _update_descriptor(self, self->vk, self->descriptor_sets[eye], self->transformation_ubos[eye].handle, 188 - sampler, image_view); 209 + struct vk_bundle *vk = self->vk; 210 + 211 + for (uint32_t eye = 0; eye < 2; eye++) { 212 + _update_descriptor(self, vk, self->descriptor_sets[eye], self->transformation_ubos[eye].handle, sampler, 213 + image_view); 214 + } 189 215 } 190 216 191 217 #ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1 ··· 225 251 VkImageView left_image_view, 226 252 VkImageView right_image_view) 227 253 { 228 - _update_descriptor(self, self->vk, self->descriptor_sets[0], self->transformation_ubos[0].handle, left_sampler, 254 + struct vk_bundle *vk = self->vk; 255 + 256 + _update_descriptor(self, vk, self->descriptor_sets[0], self->transformation_ubos[0].handle, left_sampler, 229 257 left_image_view); 230 258 231 - _update_descriptor(self, self->vk, self->descriptor_sets[1], self->transformation_ubos[1].handle, right_sampler, 259 + _update_descriptor(self, vk, self->descriptor_sets[1], self->transformation_ubos[1].handle, right_sampler, 232 260 right_image_view); 233 261 } 234 262 ··· 268 296 }, 269 297 }; 270 298 271 - if (!vk_init_descriptor_pool(self->vk, pool_sizes, ARRAY_SIZE(pool_sizes), 3, &self->descriptor_pool)) 299 + if (!vk_init_descriptor_pool(vk, pool_sizes, ARRAY_SIZE(pool_sizes), 3, &self->descriptor_pool)) 272 300 return false; 273 301 274 302 for (uint32_t eye = 0; eye < 2; eye++) 275 - if (!vk_allocate_descriptor_sets(self->vk, self->descriptor_pool, 1, layout, 276 - &self->descriptor_sets[eye])) 303 + if (!vk_allocate_descriptor_sets(vk, self->descriptor_pool, 1, layout, &self->descriptor_sets[eye])) 277 304 return false; 278 305 279 306 #if defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT1) || defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT2) 280 - if (!vk_allocate_descriptor_sets(self->vk, self->descriptor_pool, 1, layout_equirect, 281 - &self->descriptor_equirect)) 307 + if (!vk_allocate_descriptor_sets(vk, self->descriptor_pool, 1, layout_equirect, &self->descriptor_equirect)) 282 308 return false; 283 309 #endif 284 310 return true; ··· 294 320 const struct xrt_matrix_4x4 *vp_world, 295 321 const struct xrt_matrix_4x4 *vp_eye) 296 322 { 323 + struct vk_bundle *vk = self->vk; 324 + 297 325 if (eye == 0 && (self->visibility & XRT_LAYER_EYE_VISIBILITY_LEFT_BIT) == 0) { 298 326 return; 299 327 } ··· 302 330 return; 303 331 } 304 332 305 - self->vk->vkCmdBindPipeline(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); 333 + vk->vkCmdBindPipeline(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); 306 334 307 335 // Is this layer viewspace or not. 308 336 const struct xrt_matrix_4x4 *vp = self->view_space ? vp_eye : vp_world; ··· 326 354 self->descriptor_equirect, 327 355 }; 328 356 329 - self->vk->vkCmdBindDescriptorSets(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, 330 - sets, 0, NULL); 357 + vk->vkCmdBindDescriptorSets(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, sets, 0, 358 + NULL); 331 359 332 360 } else { 333 - self->vk->vkCmdBindDescriptorSets(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, 334 - &self->descriptor_sets[eye], 0, NULL); 361 + vk->vkCmdBindDescriptorSets(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, 362 + &self->descriptor_sets[eye], 0, NULL); 335 363 } 336 364 337 365 VkDeviceSize offsets[1] = {0}; 338 - self->vk->vkCmdBindVertexBuffers(cmd_buffer, 0, 1, &vertex_buffer->handle, &offsets[0]); 366 + vk->vkCmdBindVertexBuffers(cmd_buffer, 0, 1, &vertex_buffer->handle, &offsets[0]); 339 367 340 - self->vk->vkCmdDraw(cmd_buffer, vertex_buffer->size, 1, 0, 0); 368 + vk->vkCmdDraw(cmd_buffer, vertex_buffer->size, 1, 0, 0); 341 369 } 342 370 343 371 // clang-format off ··· 444 472 VkBufferUsageFlags usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; 445 473 VkMemoryPropertyFlags properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; 446 474 447 - if (!vk_buffer_init(vk, sizeof(float) * ARRAY_SIZE(cylinder_vertices), usage, properties, 448 - &self->cylinder.vertex_buffer.handle, &self->cylinder.vertex_buffer.memory)) 475 + if (!vk_buffer_init(vk, // 476 + sizeof(float) * ARRAY_SIZE(cylinder_vertices), // 477 + usage, // 478 + properties, // 479 + &self->cylinder.vertex_buffer.handle, // 480 + &self->cylinder.vertex_buffer.memory)) { 449 481 return false; 482 + } 450 483 451 484 self->cylinder.vertex_buffer.size = CYLINDER_VERTICES; 485 + 452 486 return true; 453 487 } 454 488 ··· 465 499 466 500 _init(q, vk, layout, layout_equirect); 467 501 468 - if (!_init_cylinder_vertex_buffer(q)) 502 + if (!_init_cylinder_vertex_buffer(q)) { 469 503 return NULL; 504 + } 470 505 471 506 return q; 472 507 } ··· 474 509 void 475 510 comp_layer_destroy(struct comp_render_layer *self) 476 511 { 477 - for (uint32_t eye = 0; eye < 2; eye++) 478 - vk_buffer_destroy(&self->transformation_ubos[eye], self->vk); 512 + struct vk_bundle *vk = self->vk; 513 + 514 + for (uint32_t eye = 0; eye < 2; eye++) { 515 + vk_buffer_destroy(&self->transformation_ubos[eye], vk); 516 + } 479 517 480 518 #ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1 481 - vk_buffer_destroy(&self->equirect1_ubo, self->vk); 519 + vk_buffer_destroy(&self->equirect1_ubo, vk); 482 520 #endif 483 521 #ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2 484 - vk_buffer_destroy(&self->equirect2_ubo, self->vk); 522 + vk_buffer_destroy(&self->equirect2_ubo, vk); 485 523 #endif 486 - self->vk->vkDestroyDescriptorPool(self->vk->device, self->descriptor_pool, NULL); 524 + vk->vkDestroyDescriptorPool(vk->device, self->descriptor_pool, NULL); 487 525 488 - vk_buffer_destroy(&self->cylinder.vertex_buffer, self->vk); 526 + vk_buffer_destroy(&self->cylinder.vertex_buffer, vk); 489 527 490 528 free(self); 491 529 }
+5 -4
src/xrt/compositor/main/comp_renderer.c
··· 103 103 renderer_wait_gpu_idle(struct comp_renderer *r) 104 104 { 105 105 COMP_TRACE_MARKER(); 106 + struct vk_bundle *vk = &r->c->vk; 106 107 107 - os_mutex_lock(&r->c->vk.queue_mutex); 108 - r->c->vk.vkDeviceWaitIdle(r->c->vk.device); 109 - os_mutex_unlock(&r->c->vk.queue_mutex); 108 + os_mutex_lock(&vk->queue_mutex); 109 + vk->vkDeviceWaitIdle(vk->device); 110 + os_mutex_unlock(&vk->queue_mutex); 110 111 } 111 112 112 113 static void ··· 453 454 454 455 struct vk_bundle *vk = &r->c->vk; 455 456 456 - vk->vkGetDeviceQueue(vk->device, r->c->vk.queue_family_index, 0, &r->queue); 457 + vk->vkGetDeviceQueue(vk->device, vk->queue_family_index, 0, &r->queue); 457 458 renderer_init_semaphores(r); 458 459 459 460 // Try to early-allocate these, in case we can.
+13 -10
src/xrt/compositor/main/comp_swapchain.c
··· 132 132 const struct xrt_swapchain_create_info *info, 133 133 struct comp_swapchain *sc) 134 134 { 135 + struct vk_bundle *vk = &c->vk; 135 136 uint32_t num_images = sc->vkic.num_images; 136 137 VkCommandBuffer cmd_buffer; 137 138 ··· 172 173 sc->images[i].views.no_alpha = U_TYPED_ARRAY_CALLOC(VkImageView, info->array_size); 173 174 sc->images[i].array_size = info->array_size; 174 175 175 - vk_create_sampler(&c->vk, VK_SAMPLER_ADDRESS_MODE_REPEAT, &sc->images[i].repeat_sampler); 176 + vk_create_sampler(vk, VK_SAMPLER_ADDRESS_MODE_REPEAT, &sc->images[i].repeat_sampler); 176 177 177 - vk_create_sampler(&c->vk, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, &sc->images[i].sampler); 178 + vk_create_sampler(vk, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, &sc->images[i].sampler); 178 179 179 180 180 181 for (uint32_t layer = 0; layer < info->array_size; ++layer) { ··· 186 187 .layerCount = 1, 187 188 }; 188 189 189 - vk_create_view(&c->vk, sc->vkic.images[i].handle, (VkFormat)info->format, subresource_range, 190 + vk_create_view(vk, sc->vkic.images[i].handle, (VkFormat)info->format, subresource_range, 190 191 &sc->images[i].views.alpha[layer]); 191 - vk_create_view_swizzle(&c->vk, sc->vkic.images[i].handle, format, subresource_range, components, 192 + vk_create_view_swizzle(vk, sc->vkic.images[i].handle, format, subresource_range, components, 192 193 &sc->images[i].views.no_alpha[layer]); 193 194 } 194 195 } ··· 205 206 * 206 207 */ 207 208 208 - vk_init_cmd_buffer(&c->vk, &cmd_buffer); 209 + vk_init_cmd_buffer(vk, &cmd_buffer); 209 210 210 211 VkImageSubresourceRange subresource_range = { 211 212 .aspectMask = aspect, ··· 216 217 }; 217 218 218 219 for (uint32_t i = 0; i < num_images; i++) { 219 - vk_set_image_layout(&c->vk, cmd_buffer, sc->vkic.images[i].handle, 0, VK_ACCESS_SHADER_READ_BIT, 220 + vk_set_image_layout(vk, cmd_buffer, sc->vkic.images[i].handle, 0, VK_ACCESS_SHADER_READ_BIT, 220 221 VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 221 222 subresource_range); 222 223 } 223 224 224 - vk_submit_cmd_buffer(&c->vk, cmd_buffer); 225 + vk_submit_cmd_buffer(vk, cmd_buffer); 225 226 } 226 227 227 228 static void ··· 282 283 struct xrt_swapchain **out_xsc) 283 284 { 284 285 struct comp_compositor *c = comp_compositor(xc); 286 + struct vk_bundle *vk = &c->vk; 285 287 uint32_t num_images = 3; 286 288 VkResult ret; 287 289 ··· 306 308 vk_color_format_string(info->format)); 307 309 308 310 // Use the image helper to allocate the images. 309 - ret = vk_ic_allocate(&c->vk, info, num_images, &sc->vkic); 311 + ret = vk_ic_allocate(vk, info, num_images, &sc->vkic); 310 312 if (ret == VK_ERROR_FEATURE_NOT_PRESENT) { 311 313 free(sc); 312 314 return XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED; ··· 321 323 322 324 xrt_graphics_buffer_handle_t handles[ARRAY_SIZE(sc->vkic.images)]; 323 325 324 - vk_ic_get_handles(&c->vk, &sc->vkic, ARRAY_SIZE(handles), handles); 326 + vk_ic_get_handles(vk, &sc->vkic, ARRAY_SIZE(handles), handles); 325 327 for (uint32_t i = 0; i < sc->vkic.num_images; i++) { 326 328 sc->base.images[i].handle = handles[i]; 327 329 sc->base.images[i].size = sc->vkic.images[i].size; ··· 343 345 struct xrt_swapchain **out_xsc) 344 346 { 345 347 struct comp_compositor *c = comp_compositor(xc); 348 + struct vk_bundle *vk = &c->vk; 346 349 VkResult ret; 347 350 348 351 struct comp_swapchain *sc = alloc_and_set_funcs(c, num_images); ··· 350 353 COMP_DEBUG(c, "CREATE FROM NATIVE %p %dx%d", (void *)sc, info->width, info->height); 351 354 352 355 // Use the image helper to get the images. 353 - ret = vk_ic_from_natives(&c->vk, info, native_images, num_images, &sc->vkic); 356 + ret = vk_ic_from_natives(vk, info, native_images, num_images, &sc->vkic); 354 357 if (ret != VK_SUCCESS) { 355 358 return XRT_ERROR_VULKAN; 356 359 }
+11 -12
src/xrt/compositor/main/comp_target_swapchain.c
··· 586 586 comp_target_swapchain_update_timings(struct comp_target *ct) 587 587 { 588 588 struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct; 589 - struct comp_compositor *c = ct->c; 590 - struct vk_bundle *vk = &c->vk; 589 + struct vk_bundle *vk = get_vk(cts); 591 590 592 591 if (!vk->has_GOOGLE_display_timing) { 593 592 return VK_SUCCESS; ··· 598 597 } 599 598 600 599 uint32_t count = 0; 601 - c->vk.vkGetPastPresentationTimingGOOGLE( // 602 - vk->device, // 603 - cts->swapchain.handle, // 604 - &count, // 605 - NULL); // 600 + vk->vkGetPastPresentationTimingGOOGLE( // 601 + vk->device, // 602 + cts->swapchain.handle, // 603 + &count, // 604 + NULL); // 606 605 if (count <= 0) { 607 606 return VK_SUCCESS; 608 607 } 609 608 610 609 VkPastPresentationTimingGOOGLE *timings = U_TYPED_ARRAY_CALLOC(VkPastPresentationTimingGOOGLE, count); 611 - c->vk.vkGetPastPresentationTimingGOOGLE( // 612 - vk->device, // 613 - cts->swapchain.handle, // 614 - &count, // 615 - timings); // 610 + vk->vkGetPastPresentationTimingGOOGLE( // 611 + vk->device, // 612 + cts->swapchain.handle, // 613 + &count, // 614 + timings); // 616 615 617 616 for (uint32_t i = 0; i < count; i++) { 618 617 u_ft_info(cts->uft, //
+2 -1
src/xrt/compositor/main/comp_window_direct_nvidia.c
··· 163 163 comp_window_direct_nvidia_init(struct comp_target *ct) 164 164 { 165 165 struct comp_window_direct_nvidia *w_direct = (struct comp_window_direct_nvidia *)ct; 166 + struct vk_bundle *vk = &ct->c->vk; 166 167 167 168 // Sanity check. 168 - if (ct->c->vk.instance == VK_NULL_HANDLE) { 169 + if (vk->instance == VK_NULL_HANDLE) { 169 170 COMP_ERROR(ct->c, "Vulkan not initialized before NVIDIA init!"); 170 171 return false; 171 172 }
+2 -1
src/xrt/compositor/main/comp_window_vk_display.c
··· 152 152 comp_window_vk_display_init(struct comp_target *ct) 153 153 { 154 154 struct comp_window_vk_display *w_direct = (struct comp_window_vk_display *)ct; 155 + struct vk_bundle *vk = &ct->c->vk; 155 156 156 157 // Sanity check. 157 - if (ct->c->vk.instance == VK_NULL_HANDLE) { 158 + if (vk->instance == VK_NULL_HANDLE) { 158 159 COMP_ERROR(ct->c, "Vulkan not initialized before vk display init!"); 159 160 return false; 160 161 }