hanatos / vkdt

raw photography workflow that sucks less
https://jo.dreggn.org/vkdt
BSD 2-Clause "Simplified" License
378 stars 35 forks source link

VK_ERROR_OUT_OF_POOL_MEMORY in allocate_outputs3 on MacOS #88

Closed LucaZulberti closed 1 year ago

LucaZulberti commented 1 year ago

As explained in #87, the code in graph.c that initialises pool_sizes does not count for the correct number of uniform buffers allocated after pool creation.

Code:

VkDescriptorPoolSize pool_sizes[] = {{
        .type            = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
        .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*graph->dset_cnt_image_read,
      }, {
        .type            = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
        .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*graph->dset_cnt_image_write,
      }, {
        .type            = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
        .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*graph->dset_cnt_buffer,
      }, {
        .type            = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
>>>>>
        .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*(graph->num_nodes+graph->dset_cnt_uniform),
<<<<<
      }, {
        .type            = qvk.raytracing_supported ?
          VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR :
          VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, // dummy for validation layer
        .descriptorCount = DT_GRAPH_MAX_FRAMES,
      }};

Using dt_log() I found that there are more Descriptors allocated than accounted. Example:

[pipe] Graph 0x100b0e448, export = 0x16f499918
[pipe] Graph 0x100b0e448, run = ffffffff
[pipe] Destroying DescriptorPool 0x14a25b000
[pipe] Created DescriptorPool for maxSets = 50 (0x14a2a7e00)
[pipe]   Pool size [0]: type = 1, descriptorCount = 20
[pipe]   Pool size [1]: type = 3, descriptorCount = 12
[pipe]   Pool size [2]: type = 7, descriptorCount = 1
[pipe]   Pool size [3]: type = 6, descriptorCount = 22
[pipe]   Pool size [4]: type = 7, descriptorCount = 2
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x129700000, i = 0
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x1297018d0, i = 1
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x1297031a0, i = 2
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x129704a70, i = 3
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x129706340, i = 4
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x129707c10, i = 5
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[pipe] alloc_outputs3 for graph 0x100b0e448, node = 0x1297094e0, i = 6
[pipe] Allocating 2 node->dset DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[0] DescriptorSets from pool 0x14a2a7e00
[pipe] Allocating 1 node->uniform_dset[1] DescriptorSets from pool 0x14a2a7e00
[qvk] error VK_ERROR_OUT_OF_POOL_MEMORY executing vkAllocateDescriptorSets(qvk.device, &dset_info_u, node->uniform_dset+1)!
[qvk] error VK_ERROR_OUT_OF_POOL_MEMORY executing alloc_outputs3(graph, graph->node+nodeid[i])!

The number of descriptor set is ok, but each descriptor set has a layout with two bindings, each one with one UBO descriptor. In the example, there are 22 available descriptors in the pool, but 12 sets (24 descriptors) are requested (even more in reality if I increment the pool).

hanatos commented 1 year ago

okay maybe this particular thing doesn't count the same descriptor for the global uniforms as one but as one extra for each node? does it work if you instead place

--- .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*(graph->num_nodes+graph->dset_cnt_uniform)
+++ .descriptorCount = 1+DT_GRAPH_MAX_FRAMES*2*graph->num_nodes

?

LucaZulberti commented 1 year ago

Yes with this patch it works (no errors during allocation). During the following days, I will investigate the missing GUI.