mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
dzn: Bind buffers for bindless descriptor sets
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21913>
This commit is contained in:
parent
5f61e66024
commit
8bd5fbf8ed
1 changed files with 108 additions and 41 deletions
|
|
@ -28,6 +28,8 @@
|
||||||
#include "vk_format.h"
|
#include "vk_format.h"
|
||||||
#include "vk_util.h"
|
#include "vk_util.h"
|
||||||
|
|
||||||
|
#include "dxil_spirv_nir.h"
|
||||||
|
|
||||||
#if D3D12_SDK_VERSION >= 608
|
#if D3D12_SDK_VERSION >= 608
|
||||||
static const D3D12_BARRIER_SYNC D3D12_BARRIER_SYNC_INPUT_ASSEMBLER = D3D12_BARRIER_SYNC_INDEX_INPUT;
|
static const D3D12_BARRIER_SYNC D3D12_BARRIER_SYNC_INPUT_ASSEMBLER = D3D12_BARRIER_SYNC_INDEX_INPUT;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -3061,9 +3063,12 @@ dzn_cmd_buffer_update_heaps(struct dzn_cmd_buffer *cmdbuf, uint32_t bindpoint)
|
||||||
cmdbuf->state.bindpoint[bindpoint].pipeline;
|
cmdbuf->state.bindpoint[bindpoint].pipeline;
|
||||||
|
|
||||||
if (!(cmdbuf->state.bindpoint[bindpoint].dirty & DZN_CMD_BINDPOINT_DIRTY_HEAPS))
|
if (!(cmdbuf->state.bindpoint[bindpoint].dirty & DZN_CMD_BINDPOINT_DIRTY_HEAPS))
|
||||||
goto set_heaps;
|
return;
|
||||||
|
|
||||||
dzn_foreach_pool_type (type) {
|
dzn_foreach_pool_type (type) {
|
||||||
|
if (device->bindless) {
|
||||||
|
new_heaps[type] = &device->device_heaps[type].heap;
|
||||||
|
} else {
|
||||||
uint32_t desc_count = pipeline->desc_count[type];
|
uint32_t desc_count = pipeline->desc_count[type];
|
||||||
if (!desc_count)
|
if (!desc_count)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -3116,8 +3121,8 @@ dzn_cmd_buffer_update_heaps(struct dzn_cmd_buffer *cmdbuf, uint32_t bindpoint)
|
||||||
|
|
||||||
new_heaps[type] = dst_heap;
|
new_heaps[type] = dst_heap;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set_heaps:
|
|
||||||
if (new_heaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] != cmdbuf->state.heaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] ||
|
if (new_heaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] != cmdbuf->state.heaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] ||
|
||||||
new_heaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER] != cmdbuf->state.heaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER]) {
|
new_heaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER] != cmdbuf->state.heaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER]) {
|
||||||
ID3D12DescriptorHeap *desc_heaps[2];
|
ID3D12DescriptorHeap *desc_heaps[2];
|
||||||
|
|
@ -3146,6 +3151,68 @@ set_heaps:
|
||||||
else
|
else
|
||||||
ID3D12GraphicsCommandList1_SetComputeRootDescriptorTable(cmdbuf->cmdlist, r, handle);
|
ID3D12GraphicsCommandList1_SetComputeRootDescriptorTable(cmdbuf->cmdlist, r, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->bindless) {
|
||||||
|
for (uint32_t s = 0; s < MAX_SETS; ++s) {
|
||||||
|
const struct dzn_descriptor_set *set = desc_state->sets[s].set;
|
||||||
|
if (!set || !set->pool->bindless.buf)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint32_t dirty_bit = DZN_CMD_BINDPOINT_DIRTY_DESC_SET0 << s;
|
||||||
|
if (cmdbuf->state.bindpoint[bindpoint].dirty & dirty_bit) {
|
||||||
|
uint64_t gpuva = set->pool->bindless.gpuva + (set->heap_offsets[0] * sizeof(struct dxil_spirv_bindless_entry));
|
||||||
|
if (bindpoint == VK_PIPELINE_BIND_POINT_GRAPHICS)
|
||||||
|
ID3D12GraphicsCommandList1_SetGraphicsRootShaderResourceView(cmdbuf->cmdlist, s, gpuva);
|
||||||
|
else
|
||||||
|
ID3D12GraphicsCommandList1_SetComputeRootShaderResourceView(cmdbuf->cmdlist, s, gpuva);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pipeline->dynamic_buffer_count &&
|
||||||
|
(cmdbuf->state.bindpoint[bindpoint].dirty & DZN_CMD_BINDPOINT_DIRTY_DYNAMIC_BUFFERS)) {
|
||||||
|
ID3D12Resource *dynamic_buffer_buf = NULL;
|
||||||
|
VkResult result =
|
||||||
|
dzn_cmd_buffer_alloc_internal_buf(cmdbuf, sizeof(struct dxil_spirv_bindless_entry) * pipeline->dynamic_buffer_count,
|
||||||
|
D3D12_HEAP_TYPE_UPLOAD,
|
||||||
|
D3D12_RESOURCE_STATE_GENERIC_READ,
|
||||||
|
&dynamic_buffer_buf);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint64_t gpuva = ID3D12Resource_GetGPUVirtualAddress(dynamic_buffer_buf);
|
||||||
|
struct dxil_spirv_bindless_entry *map;
|
||||||
|
ID3D12Resource_Map(dynamic_buffer_buf, 0, NULL, (void **)&map);
|
||||||
|
|
||||||
|
for (uint32_t s = 0; s < MAX_SETS; ++s) {
|
||||||
|
const struct dzn_descriptor_set *set = desc_state->sets[s].set;
|
||||||
|
if (!set)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint32_t dynamic_buffer_count = pipeline->sets[s].dynamic_buffer_count;
|
||||||
|
for (uint32_t o = 0; o < dynamic_buffer_count; o++) {
|
||||||
|
const struct dzn_buffer_desc *bdesc = &set->dynamic_buffers[o];
|
||||||
|
struct dxil_spirv_bindless_entry *map_entry = &map[pipeline->sets[s].dynamic_buffer_heap_offsets[o].primary];
|
||||||
|
if (*bdesc->bindless_descriptor_slot >= 0) {
|
||||||
|
map_entry->buffer_idx = *bdesc->bindless_descriptor_slot;
|
||||||
|
map_entry->buffer_offset = desc_state->sets[s].dynamic_offsets[o];
|
||||||
|
} else {
|
||||||
|
map_entry->buffer_idx = bdesc->type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ?
|
||||||
|
bdesc->buffer->uav_bindless_slot : bdesc->buffer->cbv_bindless_slot;
|
||||||
|
map_entry->buffer_offset = bdesc->offset + desc_state->sets[s].dynamic_offsets[o];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D12Resource_Unmap(dynamic_buffer_buf, 0, NULL);
|
||||||
|
if (bindpoint == VK_PIPELINE_BIND_POINT_GRAPHICS)
|
||||||
|
ID3D12GraphicsCommandList1_SetGraphicsRootShaderResourceView(cmdbuf->cmdlist,
|
||||||
|
pipeline->root.dynamic_buffer_bindless_param_idx,
|
||||||
|
gpuva);
|
||||||
|
else
|
||||||
|
ID3D12GraphicsCommandList1_SetComputeRootShaderResourceView(cmdbuf->cmdlist,
|
||||||
|
pipeline->root.dynamic_buffer_bindless_param_idx,
|
||||||
|
gpuva);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue