"description": "vulkan: use instance allocator for `object_name` in some objects",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
if (!cb)
return VK_ERROR_OUT_OF_HOST_MEMORY;
- vk_object_base_init(NULL, &cb->base,
- VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT);
+ vk_object_base_instance_init(instance, &cb->base,
+ VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT);
cb->flags = pCreateInfo->flags;
cb->callback = pCreateInfo->pfnCallback;
vk_object_base_from_u64_handle(pNameInfo->objectHandle,
pNameInfo->objectType);
+ assert(object->device != NULL || object->instance != NULL);
+ VkAllocationCallbacks *alloc = object->device != NULL ?
+ &object->device->alloc : &object->instance->alloc;
if (object->object_name) {
- vk_free(&device->alloc, object->object_name);
+ vk_free(alloc, object->object_name);
object->object_name = NULL;
}
- object->object_name = vk_strdup(&device->alloc, pNameInfo->pObjectName,
+ object->object_name = vk_strdup(alloc, pNameInfo->pObjectName,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!object->object_name)
return VK_ERROR_OUT_OF_HOST_MEMORY;
const VkAllocationCallbacks *alloc)
{
memset(instance, 0, sizeof(*instance));
- vk_object_base_init(NULL, &instance->base, VK_OBJECT_TYPE_INSTANCE);
+ vk_object_base_instance_init(instance, &instance->base, VK_OBJECT_TYPE_INSTANCE);
instance->alloc = *alloc;
util_cpu_trace_init();
if (!messenger)
return vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
- vk_object_base_init(NULL, &messenger->base,
- VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT);
+ vk_object_base_instance_init(instance, &messenger->base,
+ VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT);
messenger->alloc = *alloc;
messenger->severity = debugMessengerCreateInfo->messageSeverity;
#include "vk_alloc.h"
#include "vk_common_entrypoints.h"
+#include "vk_instance.h"
#include "vk_device.h"
#include "util/hash_table.h"
#include "util/ralloc.h"
base->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
base->type = obj_type;
base->device = device;
+ base->instance = NULL;
+ base->client_visible = false;
+ base->object_name = NULL;
+ util_sparse_array_init(&base->private_data, sizeof(uint64_t), 8);
+}
+
+void vk_object_base_instance_init(struct vk_instance *instance,
+ struct vk_object_base *base,
+ VkObjectType obj_type)
+{
+ base->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+ base->type = obj_type;
+ base->device = NULL;
+ base->instance = instance;
base->client_visible = false;
base->object_name = NULL;
util_sparse_array_init(&base->private_data, sizeof(uint64_t), 8);
{
util_sparse_array_finish(&base->private_data);
- if (base->object_name != NULL)
+ if (base->object_name == NULL)
+ return;
+
+ assert(base->device != NULL || base->instance != NULL);
+ if (base->device)
vk_free(&base->device->alloc, base->object_name);
+ else
+ vk_free(&base->instance->alloc, base->object_name);
}
void
*/
struct vk_device *device;
+ /** Pointer to the instance in which this object exists
+ *
+ * This is NULL for device level objects as it's main purpose is to make
+ * the instance allocator reachable for freeing data owned by instance
+ * level objects.
+ */
+ struct vk_instance *instance;
+
/* True if this object is fully constructed and visible to the client */
bool client_visible;
struct vk_object_base *base,
VkObjectType obj_type);
+/** Initialize a vk_base_object for an instance level object
+ *
+ * :param instance: |in| The vk_instance this object was created from
+ * :param base: |out| The vk_object_base to initialize
+ * :param obj_type: |in| The VkObjectType of the object being initialized
+ */
+void vk_object_base_instance_init(struct vk_instance *instance,
+ struct vk_object_base *base,
+ VkObjectType obj_type);
+
/** Tear down a vk_object_base
*
* @param[out] base The vk_object_base being torn down
const struct vk_physical_device_dispatch_table *dispatch_table)
{
memset(pdevice, 0, sizeof(*pdevice));
- vk_object_base_init(NULL, &pdevice->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
+ vk_object_base_instance_init(instance, &pdevice->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
pdevice->instance = instance;
if (supported_extensions != NULL)