[PATCH vkd3d 4/6] vkd3d: Validate the base descriptor handle in d3d12_command_list_set_descriptor_table().
Henri Verbeet
hverbeet at gmail.com
Wed Dec 15 12:18:23 CST 2021
On Fri, 10 Dec 2021 at 06:07, Conor McCarthy <cmccarthy at codeweavers.com> wrote:
> @@ -4178,11 +4178,24 @@ static void d3d12_command_list_set_descriptor_table(struct d3d12_command_list *l
> {
> struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
> const struct d3d12_root_signature *root_signature = bindings->root_signature;
> + const struct d3d12_descriptor_heap *heap;
> + struct d3d12_desc *desc;
>
> assert(root_signature_get_descriptor_table(root_signature, index));
>
> assert(index < ARRAY_SIZE(bindings->descriptor_tables));
> - bindings->descriptor_tables[index] = d3d12_desc_from_gpu_handle(base_descriptor);
> + desc = d3d12_desc_from_gpu_handle(base_descriptor);
> +
> + if (desc && !(heap = vkd3d_gpu_descriptor_allocator_heap_from_descriptor(&list->device->gpu_descriptor_allocator,
> + desc)))
> + {
> + /* Failure to find the heap means the descriptor handle is from the wrong heap type or not a handle at all. */
> + ERR("Invalid heap for base descriptor %"PRIx64".\n", base_descriptor.ptr);
> + /* TODO: Mark list as invalid? */
> + return;
> + }
> +
I suppose we might use the "heap" pointer in future patches, but as
far as this patch is concerned, we might as well just call
vkd3d_gpu_descriptor_allocator_allocation_from_descriptor().
> +struct vkd3d_gpu_descriptor_allocation *vkd3d_gpu_descriptor_allocator_allocation_from_descriptor(
> + struct vkd3d_gpu_descriptor_allocator *allocator, const struct d3d12_desc *desc)
> +{
> + struct vkd3d_gpu_descriptor_allocation *allocation;
> + int rc;
> +
> + assert(allocator->allocation_count);
> +
Does that assertion make sense? Since we're mostly using this to check
for invalid descriptor handles above, I don't think we can assume a
descriptor heap would necessarily have been created either.
More information about the wine-devel
mailing list