ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_cmd_pool *pool;
- pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
+ pool = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (pAllocator)
pool->alloc = *pAllocator;
else
- pool->alloc = device->alloc;
+ pool->alloc = device->vk.alloc;
list_inithead(&pool->cmd_buffers);
anv_cmd_buffer_destroy(cmd_buffer);
}
- vk_free2(&device->alloc, pAllocator, pool);
+ vk_free2(&device->vk.alloc, pAllocator, pool);
}
VkResult anv_ResetCommandPool(
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);
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);
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_free2(&device->vk.alloc, pAllocator, pipeline_layout);
}
/*
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);
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_free2(&device->vk.alloc, pAllocator, pool);
}
VkResult anv_ResetDescriptorPool(
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);
ANV_FROM_HANDLE(anv_descriptor_update_template, template,
descriptorUpdateTemplate);
- vk_free2(&device->alloc, pAllocator, template);
+ vk_free2(&device->vk.alloc, pAllocator, template);
}
void anv_UpdateDescriptorSetWithTemplate(
if (!device)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_device_init(&device->vk, pCreateInfo,
+ &physical_device->instance->alloc, pAllocator);
+
if (INTEL_DEBUG & DEBUG_BATCH) {
const unsigned decode_flags =
GEN_BATCH_DECODE_FULL |
decode_get_bo, NULL, device);
}
- device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->physical = physical_device;
device->no_hw = physical_device->no_hw;
device->_lost = false;
- if (pAllocator)
- device->alloc = *pAllocator;
- else
- device->alloc = physical_device->instance->alloc;
-
/* XXX(chadv): Can we dup() physicalDevice->fd here? */
device->fd = open(physical_device->path, O_RDWR | O_CLOEXEC);
if (device->fd == -1) {
fail_fd:
close(device->fd);
fail_device:
- vk_free(&device->alloc, device);
+ vk_free(&device->vk.alloc, device);
return result;
}
close(device->fd);
- vk_free(&device->alloc, device);
+ vk_device_finish(&device->vk);
+ vk_free(&device->vk.alloc, device);
}
VkResult anv_EnumerateInstanceLayerProperties(
if (mem_heap_used + aligned_alloc_size > mem_heap->size)
return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
- mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
+ mem = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
fail:
- vk_free2(&device->alloc, pAllocator, mem);
+ vk_free2(&device->vk.alloc, pAllocator, mem);
return result;
}
AHardwareBuffer_release(mem->ahw);
#endif
- vk_free2(&device->alloc, pAllocator, mem);
+ vk_free2(&device->vk.alloc, pAllocator, mem);
}
VkResult anv_MapMemory(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
- buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,
+ buffer = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (!buffer)
return;
- vk_free2(&device->alloc, pAllocator, buffer);
+ vk_free2(&device->vk.alloc, pAllocator, buffer);
}
VkDeviceAddress anv_GetBufferDeviceAddress(
sampler->bindless_state);
}
- vk_free2(&device->alloc, pAllocator, sampler);
+ vk_free2(&device->vk.alloc, pAllocator, sampler);
}
VkResult anv_CreateFramebuffer(
*/
if (!(pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR)) {
size += sizeof(struct anv_image_view *) * pCreateInfo->attachmentCount;
- framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8,
+ framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (framebuffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
framebuffer->attachment_count = pCreateInfo->attachmentCount;
} else {
- framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8,
+ framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (framebuffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (!fb)
return;
- vk_free2(&device->alloc, pAllocator, fb);
+ vk_free2(&device->vk.alloc, pAllocator, fb);
}
static const VkTimeDomainEXT anv_time_domains[] = {
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
- conversion = vk_alloc2(&device->alloc, pAllocator, sizeof(*conversion), 8,
+ conversion = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*conversion), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!conversion)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (!conversion)
return;
- vk_free2(&device->alloc, pAllocator, conversion);
+ vk_free2(&device->vk.alloc, pAllocator, conversion);
}
anv_assert(pCreateInfo->extent.height > 0);
anv_assert(pCreateInfo->extent.depth > 0);
- image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
+ image = vk_zalloc2(&device->vk.alloc, alloc, sizeof(*image), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!image)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
fail:
if (image)
- vk_free2(&device->alloc, alloc, image);
+ vk_free2(&device->vk.alloc, alloc, image);
return r;
}
}
}
- vk_free2(&device->alloc, pAllocator, image);
+ vk_free2(&device->vk.alloc, pAllocator, image);
}
static void anv_image_bind_memory_plane(struct anv_device *device,
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_image_view *iview;
- iview = vk_zalloc2(&device->alloc, pAllocator, sizeof(*iview), 8,
+ iview = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*iview), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (iview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
}
- vk_free2(&device->alloc, pAllocator, iview);
+ vk_free2(&device->vk.alloc, pAllocator, iview);
}
ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer);
struct anv_buffer_view *view;
- view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
+ view = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*view), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!view)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_state_pool_free(&device->surface_state_pool,
view->writeonly_storage_surface_state);
- vk_free2(&device->alloc, pAllocator, view);
+ vk_free2(&device->vk.alloc, pAllocator, view);
}
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL);
- mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
+ mem = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*mem), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
fail_import:
- vk_free2(&device->alloc, pAllocator, image);
+ vk_free2(&device->vk.alloc, pAllocator, image);
fail:
- vk_free2(&device->alloc, pAllocator, mem);
+ vk_free2(&device->vk.alloc, pAllocator, mem);
return result;
}
}
anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count);
- if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator,
+ if (!anv_multialloc_alloc2(&ma, &device->vk.alloc, pAllocator,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count);
- if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator,
+ if (!anv_multialloc_alloc2(&ma, &device->vk.alloc, pAllocator,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
- vk_free2(&device->alloc, pAllocator, pass);
+ vk_free2(&device->vk.alloc, pAllocator, pass);
}
void anv_GetRenderAreaGranularity(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
assert(pCreateInfo->flags == 0);
- module = vk_alloc2(&device->alloc, pAllocator,
+ module = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*module) + pCreateInfo->codeSize, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (module == NULL)
if (!module)
return;
- vk_free2(&device->alloc, pAllocator, module);
+ vk_free2(&device->vk.alloc, pAllocator, module);
}
#define SPIR_V_MAGIC_NUMBER 0x07230203
return;
anv_reloc_list_finish(&pipeline->batch_relocs,
- pAllocator ? pAllocator : &device->alloc);
+ pAllocator ? pAllocator : &device->vk.alloc);
ralloc_free(pipeline->mem_ctx);
unreachable("invalid pipeline type");
}
- vk_free2(&device->alloc, pAllocator, pipeline);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
}
static const uint32_t vk_to_gen_primitive_type[] = {
anv_pipeline_validate_create_info(pCreateInfo);
if (alloc == NULL)
- alloc = &device->alloc;
+ alloc = &device->vk.alloc;
pipeline->base.device = device;
pipeline->base.type = ANV_PIPELINE_GRAPHICS;
anv_multialloc_add(&ma, &sampler_to_descriptor,
bind_map->sampler_count);
- if (!anv_multialloc_alloc(&ma, &device->alloc,
+ if (!anv_multialloc_alloc(&ma, &device->vk.alloc,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE))
return NULL;
assert(shader->ref_cnt == 0);
anv_state_pool_free(&device->instruction_state_pool, shader->kernel);
anv_state_pool_free(&device->dynamic_state_pool, shader->constant_data);
- vk_free(&device->alloc, shader);
+ vk_free(&device->vk.alloc, shader);
}
static bool
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);
assert(pCreateInfo->flags == 0);
- cache = vk_alloc2(&device->alloc, pAllocator,
+ cache = vk_alloc2(&device->vk.alloc, pAllocator,
sizeof(*cache), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (cache == NULL)
anv_pipeline_cache_finish(cache);
- vk_free2(&device->alloc, pAllocator, cache);
+ vk_free2(&device->vk.alloc, pAllocator, cache);
}
VkResult anv_GetPipelineCacheData(
#include "util/xmlconfig.h"
#include "vk_alloc.h"
#include "vk_debug_report.h"
+#include "vk_object.h"
/* Pre-declarations needed for WSI entrypoints */
struct wl_surface;
unsigned char sha1_key[20]);
struct anv_device {
- VK_LOADER_DATA _loader_data;
-
- VkAllocationCallbacks alloc;
+ struct vk_device vk;
struct anv_physical_device * physical;
bool no_hw;
{
assert(layout && layout->ref_cnt >= 1);
if (p_atomic_dec_zero(&layout->ref_cnt))
- vk_free(&device->alloc, layout);
+ vk_free(&device->vk.alloc, layout);
}
struct anv_descriptor {
&timeline->free_points, link) {
list_del(&point->link);
anv_device_release_bo(device, point->bo);
- vk_free(&device->alloc, point);
+ vk_free(&device->vk.alloc, point);
}
list_for_each_entry_safe(struct anv_timeline_point, point,
&timeline->points, link) {
list_del(&point->link);
anv_device_release_bo(device, point->bo);
- vk_free(&device->alloc, point);
+ vk_free(&device->vk.alloc, point);
}
}
if (list_is_empty(&timeline->free_points)) {
*point =
- vk_zalloc(&device->alloc, sizeof(**point),
+ vk_zalloc(&device->vk.alloc, sizeof(**point),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!(*point))
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
0 /* explicit_address */,
&(*point)->bo);
if (result != VK_SUCCESS)
- vk_free(&device->alloc, *point);
+ vk_free(&device->vk.alloc, *point);
}
} else {
*point = list_first_entry(&timeline->free_points,
static struct anv_queue_submit *
anv_queue_submit_alloc(struct anv_device *device)
{
- const VkAllocationCallbacks *alloc = &device->alloc;
+ const VkAllocationCallbacks *alloc = &device->vk.alloc;
VkSystemAllocationScope alloc_scope = VK_SYSTEM_ALLOCATION_SCOPE_DEVICE;
struct anv_queue_submit *submit = vk_zalloc(alloc, sizeof(*submit), 8, alloc_scope);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
- fence = vk_zalloc2(&device->alloc, pAllocator, sizeof(*fence), 8,
+ fence = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*fence), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (fence == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_fence_impl_cleanup(device, &fence->temporary);
anv_fence_impl_cleanup(device, &fence->permanent);
- vk_free2(&device->alloc, pAllocator, fence);
+ vk_free2(&device->vk.alloc, pAllocator, fence);
}
VkResult anv_ResetFences(
bool waitAll,
uint64_t abs_timeout_ns)
{
- uint32_t *syncobjs = vk_zalloc(&device->alloc,
+ uint32_t *syncobjs = vk_zalloc(&device->vk.alloc,
sizeof(*syncobjs) * fenceCount, 8,
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (!syncobjs)
abs_timeout_ns, waitAll);
} while (ret == -1 && errno == ETIME && anv_gettime_ns() < abs_timeout_ns);
- vk_free(&device->alloc, syncobjs);
+ vk_free(&device->vk.alloc, syncobjs);
if (ret == -1) {
if (errno == ETIME) {
uint64_t timeline_value = 0;
VkSemaphoreTypeKHR sem_type = get_semaphore_type(pCreateInfo->pNext, &timeline_value);
- semaphore = vk_alloc(&device->alloc, sizeof(*semaphore), 8,
+ semaphore = vk_alloc(&device->vk.alloc, sizeof(*semaphore), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (semaphore == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
else
result = timeline_semaphore_create(device, &semaphore->permanent, timeline_value);
if (result != VK_SUCCESS) {
- vk_free2(&device->alloc, pAllocator, semaphore);
+ vk_free2(&device->vk.alloc, pAllocator, semaphore);
return result;
}
} else if (handleTypes & VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT) {
assert(sem_type == VK_SEMAPHORE_TYPE_BINARY_KHR);
result = binary_semaphore_create(device, &semaphore->permanent, true);
if (result != VK_SUCCESS) {
- vk_free2(&device->alloc, pAllocator, semaphore);
+ vk_free2(&device->vk.alloc, pAllocator, semaphore);
return result;
}
} else if (handleTypes & VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) {
semaphore->permanent.type = ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ;
semaphore->permanent.syncobj = anv_gem_syncobj_create(device, 0);
if (!semaphore->permanent.syncobj) {
- vk_free2(&device->alloc, pAllocator, semaphore);
+ vk_free2(&device->vk.alloc, pAllocator, semaphore);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
} else {
}
} else {
assert(!"Unknown handle type");
- vk_free2(&device->alloc, pAllocator, semaphore);
+ vk_free2(&device->vk.alloc, pAllocator, semaphore);
return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE);
}
anv_semaphore_impl_cleanup(device, &semaphore->temporary);
anv_semaphore_impl_cleanup(device, &semaphore->permanent);
- vk_free(&device->alloc, semaphore);
+ vk_free(&device->vk.alloc, semaphore);
}
void anv_DestroySemaphore(
return VK_SUCCESS;
struct anv_timeline **timelines =
- vk_alloc(&device->alloc,
+ vk_alloc(&device->vk.alloc,
pWaitInfo->semaphoreCount * sizeof(*timelines),
8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (!timelines)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- uint64_t *values = vk_alloc(&device->alloc,
+ uint64_t *values = vk_alloc(&device->vk.alloc,
pWaitInfo->semaphoreCount * sizeof(*values),
8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (!values) {
- vk_free(&device->alloc, timelines);
+ vk_free(&device->vk.alloc, timelines);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
timeout);
}
- vk_free(&device->alloc, timelines);
- vk_free(&device->alloc, values);
+ vk_free(&device->vk.alloc, timelines);
+ vk_free(&device->vk.alloc, values);
return result;
}
if (pAllocator)
alloc = pAllocator;
else
- alloc = &device->alloc;
+ alloc = &device->vk.alloc;
return wsi_common_create_swapchain(wsi_device, _device,
pCreateInfo, alloc, pSwapchain);
if (pAllocator)
alloc = pAllocator;
else
- alloc = &device->alloc;
+ alloc = &device->vk.alloc;
wsi_common_destroy_swapchain(_device, swapchain, alloc);
}
struct anv_fence *fence;
VkResult ret;
- fence = vk_zalloc2(&device->alloc, allocator, sizeof (*fence), 8,
+ fence = vk_zalloc2(&device->vk.alloc, allocator, sizeof (*fence), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!fence)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (ret == VK_SUCCESS)
*_fence = anv_fence_to_handle(fence);
else
- vk_free2(&device->alloc, allocator, fence);
+ vk_free2(&device->vk.alloc, allocator, fence);
return ret;
}
struct anv_fence *fence;
VkResult ret;
- fence = vk_zalloc2(&device->alloc, allocator, sizeof (*fence), 8,
+ fence = vk_zalloc2(&device->vk.alloc, allocator, sizeof (*fence), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!fence)
return VK_ERROR_OUT_OF_HOST_MEMORY;
if (ret == VK_SUCCESS)
*_fence = anv_fence_to_handle(fence);
else
- vk_free2(&device->alloc, allocator, fence);
+ vk_free2(&device->vk.alloc, allocator, fence);
return ret;
}
if (cache == NULL && device->physical->instance->pipeline_cache_enabled)
cache = &device->default_pipeline_cache;
- pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
+ pipeline = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
result = anv_pipeline_init(pipeline, device, cache,
pCreateInfo, pAllocator);
if (result != VK_SUCCESS) {
- vk_free2(&device->alloc, pAllocator, pipeline);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
return result;
}
if (cache == NULL && device->physical->instance->pipeline_cache_enabled)
cache = &device->default_pipeline_cache;
- pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
+ pipeline = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pipeline), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
pipeline->base.type = ANV_PIPELINE_COMPUTE;
const VkAllocationCallbacks *alloc =
- pAllocator ? pAllocator : &device->alloc;
+ pAllocator ? pAllocator : &device->vk.alloc;
result = anv_reloc_list_init(&pipeline->base.batch_relocs, alloc);
if (result != VK_SUCCESS) {
- vk_free2(&device->alloc, pAllocator, pipeline);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
return result;
}
pipeline->base.batch.alloc = alloc;
pCreateInfo->stage.pSpecializationInfo);
if (result != VK_SUCCESS) {
ralloc_free(pipeline->base.mem_ctx);
- vk_free2(&device->alloc, pAllocator, pipeline);
+ vk_free2(&device->vk.alloc, pAllocator, pipeline);
return result;
}
assert(!"Invalid query type");
}
- pool = vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
+ pool = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
fail:
- vk_free2(&device->alloc, pAllocator, pool);
+ vk_free2(&device->vk.alloc, pAllocator, pool);
return result;
}
return;
anv_device_release_bo(device, pool->bo);
- vk_free2(&device->alloc, pAllocator, pool);
+ vk_free2(&device->vk.alloc, pAllocator, pool);
}
static struct anv_address
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
- sampler = vk_zalloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
+ sampler = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*sampler), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
util/vk_debug_report.c \
util/vk_debug_report.h \
util/vk_format.c \
+ util/vk_object.c \
+ util/vk_object.h \
util/vk_util.c \
util/vk_util.h
'vk_debug_report.c',
'vk_debug_report.h',
'vk_format.c',
+ 'vk_object.c',
+ 'vk_object.h',
'vk_util.c',
'vk_util.h',
)
--- /dev/null
+/*
+ * Copyright © 2020 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "vk_object.h"
+
+void
+vk_device_init(struct vk_device *device,
+ UNUSED const VkDeviceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *instance_alloc,
+ const VkAllocationCallbacks *device_alloc)
+{
+ device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+ if (device_alloc)
+ device->alloc = *device_alloc;
+ else
+ device->alloc = *instance_alloc;
+}
+
+void
+vk_device_finish(UNUSED struct vk_device *device)
+{
+}
--- /dev/null
+/*
+ * Copyright © 2020 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#ifndef VK_OBJECT_H
+#define VK_OBJECT_H
+
+#include <vulkan/vulkan.h>
+#include <vulkan/vk_icd.h>
+
+#include "util/macros.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct vk_device {
+ VK_LOADER_DATA _loader_data;
+ VkAllocationCallbacks alloc;
+};
+
+void vk_device_init(struct vk_device *device,
+ const VkDeviceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *instance_alloc,
+ const VkAllocationCallbacks *device_alloc);
+void vk_device_finish(struct vk_device *device);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VK_OBJECT_H */