VkDescriptorSetLayoutSupport* pSupport)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- const struct anv_physical_device *pdevice =
- &device->instance->physicalDevice;
+ const struct anv_physical_device *pdevice = device->physical;
uint32_t surface_count[MESA_SHADER_STAGES] = { 0, };
bool needs_descriptor_buffer = false;
anv_multialloc_add(&ma, &bindings, max_binding + 1);
anv_multialloc_add(&ma, &samplers, immutable_sampler_count);
- if (!anv_multialloc_alloc(&ma, &device->alloc,
+ if (!anv_multialloc_alloc(&ma, &device->vk.alloc,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE))
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
memset(set_layout, 0, sizeof(*set_layout));
+ vk_object_base_init(&device->vk, &set_layout->base,
+ VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
set_layout->ref_cnt = 1;
set_layout->binding_count = max_binding + 1;
}
set_layout->binding[b].data =
- anv_descriptor_data_for_type(&device->instance->physicalDevice,
+ anv_descriptor_data_for_type(device->physical,
binding->descriptorType);
set_layout->binding[b].array_size = binding->descriptorCount;
set_layout->binding[b].descriptor_index = set_layout->size;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
set_layout->binding[b].dynamic_offset_index = dynamic_offset_count;
+ anv_foreach_stage(s, binding->stageFlags) {
+ STATIC_ASSERT(MAX_DYNAMIC_BUFFERS <=
+ sizeof(set_layout->stage_dynamic_offsets[s]) * 8);
+ set_layout->stage_dynamic_offsets[s] |=
+ BITFIELD_RANGE(set_layout->binding[b].dynamic_offset_index,
+ binding->descriptorCount);
+ }
dynamic_offset_count += binding->descriptorCount;
+ assert(dynamic_offset_count < MAX_DYNAMIC_BUFFERS);
break;
default:
return VK_SUCCESS;
}
+void
+anv_descriptor_set_layout_destroy(struct anv_device *device,
+ struct anv_descriptor_set_layout *layout)
+{
+ assert(layout->ref_cnt == 0);
+ vk_object_base_finish(&layout->base);
+ vk_free(&device->vk.alloc, layout);
+}
+
void anv_DestroyDescriptorSetLayout(
VkDevice _device,
VkDescriptorSetLayout _set_layout,
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
- layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
+ layout = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*layout), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (layout == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_object_base_init(&device->vk, &layout->base,
+ VK_OBJECT_TYPE_PIPELINE_LAYOUT);
layout->num_sets = pCreateInfo->setLayoutCount;
unsigned dynamic_offset_count = 0;
dynamic_offset_count += set_layout->binding[b].array_size;
}
}
+ assert(dynamic_offset_count < MAX_DYNAMIC_BUFFERS);
struct mesa_sha1 ctx;
_mesa_sha1_init(&ctx);
for (uint32_t i = 0; i < pipeline_layout->num_sets; i++)
anv_descriptor_set_layout_unref(device, pipeline_layout->set[i].layout);
- vk_free2(&device->alloc, pAllocator, pipeline_layout);
+ vk_object_base_finish(&pipeline_layout->base);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline_layout);
}
/*
uint32_t descriptor_bo_size = 0;
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {
enum anv_descriptor_data desc_data =
- anv_descriptor_data_for_type(&device->instance->physicalDevice,
+ anv_descriptor_data_for_type(device->physical,
pCreateInfo->pPoolSizes[i].type);
if (desc_data & ANV_DESCRIPTOR_BUFFER_VIEW)
buffer_view_count * sizeof(struct anv_buffer_view);
const size_t total_size = sizeof(*pool) + pool_size;
- pool = vk_alloc2(&device->alloc, pAllocator, total_size, 8,
+ pool = vk_alloc2(&device->vk.alloc, pAllocator, total_size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!pool)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_object_base_init(&device->vk, &pool->base,
+ VK_OBJECT_TYPE_DESCRIPTOR_POOL);
pool->size = pool_size;
pool->next = 0;
pool->free_list = EMPTY;
descriptor_bo_size,
ANV_BO_ALLOC_MAPPED |
ANV_BO_ALLOC_SNOOPED,
+ 0 /* explicit_address */,
&pool->bo);
if (result != VK_SUCCESS) {
- vk_free2(&device->alloc, pAllocator, pool);
+ vk_free2(&device->vk.alloc, pAllocator, pool);
return result;
}
anv_device_release_bo(device, pool->bo);
anv_state_stream_finish(&pool->surface_state_stream);
- vk_free2(&device->alloc, pAllocator, pool);
+ vk_object_base_finish(&pool->base);
+ vk_free2(&device->vk.alloc, pAllocator, pool);
}
VkResult anv_ResetDescriptorPool(
set->desc_surface_state = ANV_STATE_NULL;
}
+ vk_object_base_init(&device->vk, &set->base,
+ VK_OBJECT_TYPE_DESCRIPTOR_SET);
set->pool = pool;
set->layout = layout;
anv_descriptor_set_layout_ref(layout);
* will always write in the immutable sampler regardless of what
* is in the sampler parameter.
*/
- struct VkDescriptorImageInfo info = { };
+ VkDescriptorImageInfo info = { };
anv_descriptor_set_write_image_view(device, set, &info,
VK_DESCRIPTOR_TYPE_SAMPLER,
b, i);
list_del(&set->pool_link);
+ vk_object_base_finish(&set->base);
anv_descriptor_pool_free_set(pool, set);
}
switch (type) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
- sampler = anv_sampler_from_handle(info->sampler);
+ sampler = bind_layout->immutable_samplers ?
+ bind_layout->immutable_samplers[element] :
+ anv_sampler_from_handle(info->sampler);
break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
image_view = anv_image_view_from_handle(info->imageView);
- sampler = anv_sampler_from_handle(info->sampler);
+ sampler = bind_layout->immutable_samplers ?
+ bind_layout->immutable_samplers[element] :
+ anv_sampler_from_handle(info->sampler);
break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
unreachable("invalid descriptor type");
}
- /* If this descriptor has an immutable sampler, we don't want to stomp on
- * it.
- */
- sampler = bind_layout->immutable_samplers ?
- bind_layout->immutable_samplers[element] :
- sampler;
-
*desc = (struct anv_descriptor) {
.type = type,
.layout = info->imageLayout,
void *desc_map = set->desc_mem.map + bind_layout->descriptor_offset +
element * anv_descriptor_size(bind_layout);
+ memset(desc_map, 0, anv_descriptor_size(bind_layout));
if (bind_layout->data & ANV_DESCRIPTOR_SAMPLED_IMAGE) {
struct anv_sampled_image_descriptor desc_data[3];
MAX2(1, bind_layout->max_plane_count) * sizeof(desc_data[0]));
}
+ if (image_view == NULL)
+ return;
+
if (bind_layout->data & ANV_DESCRIPTOR_STORAGE_IMAGE) {
assert(!(bind_layout->data & ANV_DESCRIPTOR_IMAGE_PARAM));
assert(image_view->n_planes == 1);
anv_descriptor_set_write_image_param(desc_map, image_param);
}
- if (image_view && (bind_layout->data & ANV_DESCRIPTOR_TEXTURE_SWIZZLE)) {
+ if (bind_layout->data & ANV_DESCRIPTOR_TEXTURE_SWIZZLE) {
assert(!(bind_layout->data & ANV_DESCRIPTOR_SAMPLED_IMAGE));
assert(image_view);
struct anv_texture_swizzle_descriptor desc_data[3];
assert(type == bind_layout->type);
+ void *desc_map = set->desc_mem.map + bind_layout->descriptor_offset +
+ element * anv_descriptor_size(bind_layout);
+
+ if (buffer_view == NULL) {
+ *desc = (struct anv_descriptor) { .type = type, };
+ memset(desc_map, 0, anv_descriptor_size(bind_layout));
+ return;
+ }
+
*desc = (struct anv_descriptor) {
.type = type,
.buffer_view = buffer_view,
};
- void *desc_map = set->desc_mem.map + bind_layout->descriptor_offset +
- element * anv_descriptor_size(bind_layout);
-
if (bind_layout->data & ANV_DESCRIPTOR_SAMPLED_IMAGE) {
struct anv_sampled_image_descriptor desc_data = {
.image = anv_surface_state_to_handle(buffer_view->surface_state),
assert(type == bind_layout->type);
+ void *desc_map = set->desc_mem.map + bind_layout->descriptor_offset +
+ element * anv_descriptor_size(bind_layout);
+
+ if (buffer == NULL) {
+ *desc = (struct anv_descriptor) { .type = type, };
+ memset(desc_map, 0, anv_descriptor_size(bind_layout));
+ return;
+ }
+
struct anv_address bind_addr = anv_address_add(buffer->address, offset);
uint64_t bind_range = anv_buffer_get_range(buffer, offset, range);
+ /* We report a bounds checking alignment of 32B for the sake of block
+ * messages which read an entire register worth at a time.
+ */
+ if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
+ type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)
+ bind_range = align_u64(bind_range, ANV_UBO_ALIGNMENT);
+
if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
*desc = (struct anv_descriptor) {
};
}
- void *desc_map = set->desc_mem.map + bind_layout->descriptor_offset +
- element * anv_descriptor_size(bind_layout);
-
if (bind_layout->data & ANV_DESCRIPTOR_ADDRESS_RANGE) {
- struct anv_address_range_descriptor desc = {
+ struct anv_address_range_descriptor desc_data = {
.address = anv_address_physical(bind_addr),
.range = bind_range,
};
- memcpy(desc_map, &desc, sizeof(desc));
+ memcpy(desc_map, &desc_data, sizeof(desc_data));
}
}
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
for (uint32_t j = 0; j < write->descriptorCount; j++) {
- assert(write->pBufferInfo[j].buffer);
ANV_FROM_HANDLE(anv_buffer, buffer, write->pBufferInfo[j].buffer);
- assert(buffer);
anv_descriptor_set_write_buffer(device, set,
NULL,
size_t size = sizeof(*template) +
pCreateInfo->descriptorUpdateEntryCount * sizeof(template->entries[0]);
- template = vk_alloc2(&device->alloc, pAllocator, size, 8,
+ template = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (template == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_object_base_init(&device->vk, &template->base,
+ VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
template->bind_point = pCreateInfo->pipelineBindPoint;
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)
ANV_FROM_HANDLE(anv_descriptor_update_template, template,
descriptorUpdateTemplate);
- vk_free2(&device->alloc, pAllocator, template);
+ vk_object_base_finish(&template->base);
+ vk_free2(&device->vk.alloc, pAllocator, template);
}
void anv_UpdateDescriptorSetWithTemplate(