};
static void
-dzn_descriptor_set_ptr_validate(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_validate(const struct dzn_descriptor_set_layout *layout,
struct dzn_descriptor_set_ptr *ptr)
{
- if (ptr->binding >= set->layout->binding_count) {
+ if (ptr->binding >= layout->binding_count) {
ptr->binding = ~0;
ptr->elem = ~0;
return;
}
uint32_t desc_count =
- dzn_descriptor_set_layout_get_desc_count(set->layout, ptr->binding);
+ dzn_descriptor_set_layout_get_desc_count(layout, ptr->binding);
if (ptr->elem >= desc_count) {
ptr->binding = ~0;
ptr->elem = ~0;
}
static void
-dzn_descriptor_set_ptr_init(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_init(const struct dzn_descriptor_set_layout *layout,
struct dzn_descriptor_set_ptr *ptr,
uint32_t binding, uint32_t elem)
{
ptr->binding = binding;
ptr->elem = elem;
- dzn_descriptor_set_ptr_validate(set, ptr);
+ dzn_descriptor_set_ptr_validate(layout, ptr);
}
static void
-dzn_descriptor_set_ptr_move(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_move(const struct dzn_descriptor_set_layout *layout,
struct dzn_descriptor_set_ptr *ptr,
uint32_t count)
{
while (count) {
uint32_t desc_count =
- dzn_descriptor_set_layout_get_desc_count(set->layout, ptr->binding);
+ dzn_descriptor_set_layout_get_desc_count(layout, ptr->binding);
if (count >= desc_count - ptr->elem) {
count -= desc_count - ptr->elem;
}
}
- dzn_descriptor_set_ptr_validate(set, ptr);
+ dzn_descriptor_set_ptr_validate(layout, ptr);
}
static bool
}
static uint32_t
-dzn_descriptor_set_remaining_descs_in_binding(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_remaining_descs_in_binding(const struct dzn_descriptor_set_layout *layout,
const struct dzn_descriptor_set_ptr *ptr)
{
- if (ptr->binding >= set->layout->binding_count)
+ if (ptr->binding >= layout->binding_count)
return 0;
uint32_t desc_count =
- dzn_descriptor_set_layout_get_desc_count(set->layout, ptr->binding);
+ dzn_descriptor_set_layout_get_desc_count(layout, ptr->binding);
return desc_count >= ptr->elem ? desc_count - ptr->elem : 0;
}
static uint32_t
-dzn_descriptor_set_ptr_get_heap_offset(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_get_heap_offset(const struct dzn_descriptor_set_layout *layout,
D3D12_DESCRIPTOR_HEAP_TYPE type,
const struct dzn_descriptor_set_ptr *ptr,
bool writeable)
return ~0;
uint32_t base =
- dzn_descriptor_set_layout_get_heap_offset(set->layout, ptr->binding, type, writeable);
+ dzn_descriptor_set_layout_get_heap_offset(layout, ptr->binding, type, writeable);
if (base == ~0)
return ~0;
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
uint32_t heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
if (heap_offset != ~0) {
mtx_lock(&set->pool->defragment_lock);
}
static uint32_t
-dzn_descriptor_set_ptr_get_dynamic_buffer_idx(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_get_dynamic_buffer_idx(const struct dzn_descriptor_set_layout *layout,
const struct dzn_descriptor_set_ptr *ptr)
{
if (ptr->binding == ~0)
return ~0;
- uint32_t base = set->layout->bindings[ptr->binding].dynamic_buffer_idx;
+ uint32_t base = layout->bindings[ptr->binding].dynamic_buffer_idx;
if (base == ~0)
return ~0;
const struct dzn_buffer_desc *info)
{
uint32_t dynamic_buffer_idx =
- dzn_descriptor_set_ptr_get_dynamic_buffer_idx(set, ptr);
+ dzn_descriptor_set_ptr_get_dynamic_buffer_idx(set->layout, ptr);
if (dynamic_buffer_idx == ~0)
return;
}
static VkDescriptorType
-dzn_descriptor_set_ptr_get_vk_type(const struct dzn_descriptor_set *set,
+dzn_descriptor_set_ptr_get_vk_type(const struct dzn_descriptor_set_layout *layout,
const struct dzn_descriptor_set_ptr *ptr)
{
- if (ptr->binding >= set->layout->binding_count)
+ if (ptr->binding >= layout->binding_count)
return (VkDescriptorType)~0;
- return set->layout->bindings[ptr->binding].type;
+ return layout->bindings[ptr->binding].type;
}
static void
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
uint32_t heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
if (heap_offset == ~0)
return;
false, cube_as_2darray,
iview);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set, ptr);
+ VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, true);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
assert(heap_offset != ~0);
dzn_descriptor_heap_write_image_view_desc(&set->pool->heaps[type],
set->heap_offsets[type] + heap_offset,
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
uint32_t heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
if (heap_offset == ~0)
return;
set->heap_offsets[type] + heap_offset,
false, bview);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set, ptr);
+ VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, true);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
assert(heap_offset != ~0);
dzn_descriptor_heap_write_buffer_view_desc(&set->pool->heaps[type],
set->heap_offsets[type] + heap_offset,
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
uint32_t heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
if (heap_offset == ~0)
return;
set->heap_offsets[type] + heap_offset,
false, bdesc);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set, ptr);
+ VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set, type, ptr, true);
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
assert(heap_offset != ~0);
dzn_descriptor_heap_write_buffer_desc(&set->pool->heaps[type],
set->heap_offsets[type] + heap_offset,
struct dzn_descriptor_set_ptr ptr;
const struct dzn_sampler **sampler =
&layout->immutable_samplers[layout->bindings[b].immutable_sampler_idx];
- for (dzn_descriptor_set_ptr_init(set, &ptr, b, 0);
+ for (dzn_descriptor_set_ptr_init(set->layout, &ptr, b, 0);
dzn_descriptor_set_ptr_is_valid(&ptr);
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
dzn_descriptor_set_ptr_write_sampler_desc(set, &ptr, *sampler);
sampler++;
}
struct dzn_descriptor_set_ptr ptr;
- dzn_descriptor_set_ptr_init(set, &ptr,
+ dzn_descriptor_set_ptr_init(set->layout, &ptr,
pDescriptorWrite->dstBinding,
pDescriptorWrite->dstArrayElement);
uint32_t desc_count = pDescriptorWrite->descriptorCount;
switch (pDescriptorWrite->descriptorType) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
const VkDescriptorImageInfo *pImageInfo = pDescriptorWrite->pImageInfo + d;
VK_FROM_HANDLE(dzn_sampler, sampler, pImageInfo->sampler);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
const VkDescriptorImageInfo *pImageInfo = pDescriptorWrite->pImageInfo + d;
VK_FROM_HANDLE(dzn_sampler, sampler, pImageInfo->sampler);
VK_FROM_HANDLE(dzn_image_view, iview, pImageInfo->imageView);
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
const VkDescriptorImageInfo *pImageInfo = pDescriptorWrite->pImageInfo + d;
VK_FROM_HANDLE(dzn_image_view, iview, pImageInfo->imageView);
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
const VkDescriptorBufferInfo *binfo = &pDescriptorWrite->pBufferInfo[d];
struct dzn_buffer_desc desc = {
pDescriptorWrite->descriptorType,
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
const VkDescriptorBufferInfo *binfo = &pDescriptorWrite->pBufferInfo[d];
struct dzn_buffer_desc desc = {
pDescriptorWrite->descriptorType,
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
for (; dzn_descriptor_set_ptr_is_valid(&ptr) && d < desc_count;
- dzn_descriptor_set_ptr_move(set, &ptr, 1)) {
- assert(dzn_descriptor_set_ptr_get_vk_type(set, &ptr) == pDescriptorWrite->descriptorType);
+ dzn_descriptor_set_ptr_move(set->layout, &ptr, 1)) {
+ assert(dzn_descriptor_set_ptr_get_vk_type(set->layout, &ptr) == pDescriptorWrite->descriptorType);
VK_FROM_HANDLE(dzn_buffer_view, bview, pDescriptorWrite->pTexelBufferView[d]);
if (bview)
VK_FROM_HANDLE(dzn_descriptor_set, dst_set, pDescriptorCopy->dstSet);
struct dzn_descriptor_set_ptr src_ptr, dst_ptr;
- dzn_descriptor_set_ptr_init(src_set, &src_ptr,
+ dzn_descriptor_set_ptr_init(src_set->layout, &src_ptr,
pDescriptorCopy->srcBinding,
pDescriptorCopy->srcArrayElement);
- dzn_descriptor_set_ptr_init(dst_set, &dst_ptr,
+ dzn_descriptor_set_ptr_init(dst_set->layout, &dst_ptr,
pDescriptorCopy->dstBinding,
pDescriptorCopy->dstArrayElement);
dzn_descriptor_set_ptr_is_valid(&dst_ptr) &&
copied_count < pDescriptorCopy->descriptorCount) {
VkDescriptorType src_type =
- dzn_descriptor_set_ptr_get_vk_type(src_set, &src_ptr);
+ dzn_descriptor_set_ptr_get_vk_type(src_set->layout, &src_ptr);
VkDescriptorType dst_type =
- dzn_descriptor_set_ptr_get_vk_type(dst_set, &dst_ptr);
+ dzn_descriptor_set_ptr_get_vk_type(dst_set->layout, &dst_ptr);
assert(src_type == dst_type);
uint32_t count =
- MIN2(dzn_descriptor_set_remaining_descs_in_binding(src_set, &src_ptr),
- dzn_descriptor_set_remaining_descs_in_binding(dst_set, &dst_ptr));
+ MIN2(dzn_descriptor_set_remaining_descs_in_binding(src_set->layout, &src_ptr),
+ dzn_descriptor_set_remaining_descs_in_binding(dst_set->layout, &dst_ptr));
if (src_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
src_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
uint32_t src_idx =
- dzn_descriptor_set_ptr_get_dynamic_buffer_idx(src_set, &src_ptr);
+ dzn_descriptor_set_ptr_get_dynamic_buffer_idx(src_set->layout, &src_ptr);
uint32_t dst_idx =
- dzn_descriptor_set_ptr_get_dynamic_buffer_idx(dst_set, &dst_ptr);
+ dzn_descriptor_set_ptr_get_dynamic_buffer_idx(dst_set->layout, &dst_ptr);
memcpy(&dst_set->dynamic_buffers[dst_idx],
&src_set->dynamic_buffers[src_idx],
} else {
dzn_foreach_pool_type(type) {
uint32_t src_heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(src_set, type, &src_ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(src_set->layout, type, &src_ptr, false);
uint32_t dst_heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(dst_set, type, &dst_ptr, false);
+ dzn_descriptor_set_ptr_get_heap_offset(dst_set->layout, type, &dst_ptr, false);
if (src_heap_offset == ~0) {
assert(dst_heap_offset == ~0);
if (dzn_descriptor_type_depends_on_shader_usage(src_type)) {
src_heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(src_set, type, &src_ptr, true);
+ dzn_descriptor_set_ptr_get_heap_offset(src_set->layout, type, &src_ptr, true);
dst_heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(dst_set, type, &dst_ptr, true);
+ dzn_descriptor_set_ptr_get_heap_offset(dst_set->layout, type, &dst_ptr, true);
assert(src_heap_offset != ~0);
assert(dst_heap_offset != ~0);
dzn_descriptor_heap_copy(&dst_set->pool->heaps[type],
}
}
- dzn_descriptor_set_ptr_move(src_set, &src_ptr, count);
- dzn_descriptor_set_ptr_move(dst_set, &dst_ptr, count);
+ dzn_descriptor_set_ptr_move(src_set->layout, &src_ptr, count);
+ dzn_descriptor_set_ptr_move(dst_set->layout, &dst_ptr, count);
copied_count += count;
}