The open source OpenXR runtime
0
fork

Configure Feed

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

c/render: Make gfx descriptor pool shareable

+40 -34
+9 -9
src/xrt/compositor/render/render_gfx.c
··· 581 581 struct render_resources *r = rr->r; 582 582 583 583 // Reclaim all descriptor sets. 584 - vk->vkResetDescriptorPool( // 585 - vk->device, // 586 - r->mesh.descriptor_pool, // 587 - 0); // 584 + vk->vkResetDescriptorPool( // 585 + vk->device, // 586 + r->gfx.ubo_and_src_descriptor_pool, // 587 + 0); // 588 588 589 589 // This "reclaims" the allocated UBOs. 590 590 U_ZERO(rr); ··· 721 721 * Create and fill out destriptor. 722 722 */ 723 723 724 - ret = vk_create_descriptor_set( // 725 - vk, // vk_bundle 726 - r->mesh.descriptor_pool, // descriptor_pool 727 - r->mesh.descriptor_set_layout, // descriptor_set_layout 728 - &descriptor_set); // descriptor_set 724 + ret = vk_create_descriptor_set( // 725 + vk, // vk_bundle 726 + r->gfx.ubo_and_src_descriptor_pool, // descriptor_pool 727 + r->mesh.descriptor_set_layout, // descriptor_set_layout 728 + &descriptor_set); // descriptor_set 729 729 VK_CHK_AND_RET(ret, "vk_create_descriptor_set"); 730 730 731 731 update_mesh_discriptor_set( //
+3 -3
src/xrt/compositor/render/render_interface.h
··· 388 388 389 389 struct 390 390 { 391 + //! Pool for shaders that uses one ubo and sampler. 392 + VkDescriptorPool ubo_and_src_descriptor_pool; 393 + 391 394 /*! 392 395 * Shared UBO buffer that we sub-allocate out of, this is to 393 396 * have fewer buffers that the kernel needs to validate on ··· 420 423 uint32_t stride; 421 424 uint32_t index_offsets[2]; 422 425 uint32_t index_count_total; 423 - 424 - //! Descriptor pool for mesh shaders. 425 - VkDescriptorPool descriptor_pool; 426 426 427 427 //! Info ubos, only supports two views currently. 428 428 struct render_buffer ubos[2];
+28 -22
src/xrt/compositor/render/render_resources.c
··· 661 661 */ 662 662 663 663 { 664 + // Number of layer shader runs (views) times number of layers. 665 + const uint32_t layer_shader_count = RENDER_MAX_LAYER_RUNS * RENDER_MAX_LAYERS; 666 + 667 + // Two mesh distortion runs. 668 + const uint32_t mesh_shader_count = 2; 669 + 670 + struct vk_descriptor_pool_info mesh_pool_info = { 671 + .uniform_per_descriptor_count = 1, 672 + .sampler_per_descriptor_count = 1, 673 + .storage_image_per_descriptor_count = 0, 674 + .storage_buffer_per_descriptor_count = 0, 675 + .descriptor_count = layer_shader_count + mesh_shader_count, 676 + .freeable = false, 677 + }; 678 + 679 + ret = vk_create_descriptor_pool( // 680 + vk, // vk_bundle 681 + &mesh_pool_info, // info 682 + &r->gfx.ubo_and_src_descriptor_pool); // out_descriptor_pool 683 + VK_CHK_WITH_RET(ret, "vk_create_descriptor_pool", false); 684 + 664 685 VkBufferUsageFlags usage_flags = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; 665 686 VkMemoryPropertyFlags memory_property_flags = // 666 687 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | // 667 688 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; // 668 689 669 - uint32_t num_buffers = 0; 690 + uint32_t buffer_count = 0; 670 691 671 - // Number of layer shader runs (views), number of layers, two UBOs per layer. 672 - num_buffers += RENDER_MAX_LAYER_RUNS * RENDER_MAX_LAYERS * 2; 692 + // One UBO per layer shader. 693 + buffer_count += layer_shader_count; 673 694 674 - // Two mesh distortion runs with one UBO each. 675 - num_buffers += 2; 695 + // One UBO per mesh shader. 696 + buffer_count += 2; 676 697 677 698 // We currently use the aligmnent as max UBO size. 678 699 static_assert(sizeof(struct render_gfx_mesh_ubo_data) <= RENDER_ALWAYS_SAFE_UBO_ALIGNMENT, "MAX"); 679 700 680 701 // Calculate size. 681 - VkDeviceSize size = num_buffers * RENDER_ALWAYS_SAFE_UBO_ALIGNMENT; 702 + VkDeviceSize size = buffer_count * RENDER_ALWAYS_SAFE_UBO_ALIGNMENT; 682 703 683 704 ret = render_buffer_init( // 684 705 vk, // vk_bundle ··· 698 719 /* 699 720 * Mesh static. 700 721 */ 701 - 702 - struct vk_descriptor_pool_info mesh_pool_info = { 703 - .uniform_per_descriptor_count = 1, 704 - .sampler_per_descriptor_count = 1, 705 - .storage_image_per_descriptor_count = 0, 706 - .storage_buffer_per_descriptor_count = 0, 707 - .descriptor_count = 16 * 2, 708 - .freeable = false, 709 - }; 710 - 711 - ret = vk_create_descriptor_pool( // 712 - vk, // vk_bundle 713 - &mesh_pool_info, // info 714 - &r->mesh.descriptor_pool); // out_descriptor_pool 715 - VK_CHK_WITH_RET(ret, "vk_create_descriptor_pool", false); 716 722 717 723 ret = create_mesh_descriptor_set_layout( // 718 724 vk, // vk_bundle ··· 1002 1008 DF(Memory, r->mock.color.memory); 1003 1009 1004 1010 render_buffer_close(vk, &r->gfx.shared_ubo); 1011 + D(DescriptorPool, r->gfx.ubo_and_src_descriptor_pool); 1005 1012 1006 1013 D(DescriptorSetLayout, r->mesh.descriptor_set_layout); 1007 1014 D(PipelineLayout, r->mesh.pipeline_layout); 1008 1015 D(PipelineCache, r->pipeline_cache); 1009 - D(DescriptorPool, r->mesh.descriptor_pool); 1010 1016 D(QueryPool, r->query_pool); 1011 1017 render_buffer_close(vk, &r->mesh.vbo); 1012 1018 render_buffer_close(vk, &r->mesh.ibo);