struct zink_sampler_view *sampler_view = CALLOC_STRUCT_CL(zink_sampler_view);
bool err;
+ if (!sampler_view) {
+ mesa_loge("ZINK: failed to allocate sampler_view!");
+ return NULL;
+ }
+
sampler_view->base = *state;
sampler_view->base.texture = NULL;
pipe_resource_reference(&sampler_view->base.texture, pres);
util_idalloc_alloc(&ctx->di.bindless[i].img_slots);
if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) {
ctx->di.bindless[i].db.buffer_infos = malloc(sizeof(VkDescriptorAddressInfoEXT) * ZINK_MAX_BINDLESS_HANDLES);
+ if (!ctx->di.bindless[i].db.buffer_infos) {
+ mesa_loge("ZINK: failed to allocate ctx->di.bindless[%d].db.buffer_infos!",i);
+ goto fail;
+ }
for (unsigned j = 0; j < ZINK_MAX_BINDLESS_HANDLES; j++) {
ctx->di.bindless[i].db.buffer_infos[j].sType = VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT;
ctx->di.bindless[i].db.buffer_infos[j].pNext = NULL;
}
} else {
ctx->di.bindless[i].t.buffer_infos = malloc(sizeof(VkBufferView) * ZINK_MAX_BINDLESS_HANDLES);
+ if (!ctx->di.bindless[i].t.buffer_infos) {
+ mesa_loge("ZINK: failed to allocate ctx->di.bindless[%d].t.buffer_infos!",i);
+ goto fail;
+ }
}
ctx->di.bindless[i].img_infos = malloc(sizeof(VkDescriptorImageInfo) * ZINK_MAX_BINDLESS_HANDLES);
+ if (!ctx->di.bindless[i].img_infos) {
+ mesa_loge("ZINK: failed to allocate ctx->di.bindless[%d].img_infos!",i);
+ goto fail;
+ }
util_dynarray_init(&ctx->di.bindless[i].updates, NULL);
util_dynarray_init(&ctx->di.bindless[i].resident, NULL);
}
if (error != VK_SUCCESS)
return error;
cswap->images = calloc(cswap->num_images, sizeof(struct kopper_swapchain_image));
+ if (!cswap->images) {
+ mesa_loge("ZINK: failed to allocate cswap->images!");
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
cswap->presents = _mesa_hash_table_create_u32_keys(NULL);
VkImage images[32];
error = VKSCR(GetSwapchainImagesKHR)(screen->dev, cswap->swapchain, &cswap->num_images, images);
arr = he->data;
else {
arr = malloc(sizeof(struct util_dynarray));
+ if (!arr) {
+ mesa_loge("ZINK: failed to allocate arr!");
+ return;
+ }
+
util_dynarray_init(arr, NULL);
_mesa_hash_table_insert(swapchain->presents, (void*)(uintptr_t)next, arr);
}
prune_old_swapchains(screen, cdt, false);
struct kopper_present_info *cpi = malloc(sizeof(struct kopper_present_info));
+ if (!cpi) {
+ mesa_loge("ZINK: failed to allocate cpi!");
+ return;
+ }
+
cpi->sem = res->obj->present;
cpi->res = res;
cpi->swapchain = cdt->swapchain;
prog->last_variant_hash = ctx->gfx_pipeline_state.optimal_key;
struct zink_gfx_library_key *gkey = CALLOC_STRUCT(zink_gfx_library_key);
+ if (!gkey) {
+ mesa_loge("ZINK: failed to allocate gkey!");
+ goto fail;
+ }
gkey->optimal_key = prog->last_variant_hash;
assert(gkey->optimal_key);
gkey->pipeline = zink_create_gfx_pipeline_combined(screen, prog, VK_NULL_HANDLE, libs, 2, VK_NULL_HANDLE, false);
zink_create_pipeline_lib(struct zink_screen *screen, struct zink_gfx_program *prog, struct zink_gfx_pipeline_state *state)
{
struct zink_gfx_library_key *gkey = CALLOC_STRUCT(zink_gfx_library_key);
+ if (!gkey) {
+ mesa_loge("ZINK: failed to allocate gkey!");
+ return NULL;
+ }
+
gkey->optimal_key = state->optimal_key;
assert(gkey->optimal_key);
memcpy(gkey->modules, prog->modules, sizeof(gkey->modules));
VkPipelineExecutableStatisticKHR *stats = NULL;
VKSCR(GetPipelineExecutableStatisticsKHR)(screen->dev, &info, &count, NULL);
stats = calloc(count, sizeof(VkPipelineExecutableStatisticKHR));
+ if (!stats) {
+ mesa_loge("ZINK: failed to allocate stats!");
+ return;
+ }
+
for (unsigned i = 0; i < count; i++)
stats[i].sType = VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_STATISTIC_KHR;
VKSCR(GetPipelineExecutableStatisticsKHR)(screen->dev, &info, &count, stats);
pool = find_or_allocate_qp(ctx, q, pool_idx);
}
vkq = CALLOC_STRUCT(zink_vk_query);
+ if (!vkq) {
+ mesa_loge("ZINK: failed to allocate vkq!");
+ return;
+ }
vkq->refcount = 1;
vkq->needs_reset = true;
pipe_reference_init(&obj->reference, 1);
if (loader_private) {
obj->bo = CALLOC_STRUCT(zink_bo);
+ if (!obj->bo) {
+ mesa_loge("ZINK: failed to allocate obj->bo!");
+ return NULL;
+ }
+
obj->transfer_dst = true;
return obj;
} else if (templ->target == PIPE_BUFFER) {
struct zink_screen *screen = zink_screen(pscreen);
struct zink_resource *res = CALLOC_STRUCT_CL(zink_resource);
+ if (!res) {
+ mesa_loge("ZINK: failed to allocate res!");
+ return NULL;
+ }
+
if (modifiers_count > 0 && screen->info.have_EXT_image_drm_format_modifier) {
/* for rebinds */
res->modifiers_count = modifiers_count;
if (bind & ZINK_BIND_DMABUF && !res->modifiers_count && screen->info.have_EXT_image_drm_format_modifier) {
res->modifiers_count = 1;
res->modifiers = malloc(res->modifiers_count * sizeof(uint64_t));
+ if (!res->modifiers) {
+ mesa_loge("ZINK: failed to allocate res->modifiers!");
+ return false;
+ }
+
res->modifiers[0] = DRM_FORMAT_MOD_LINEAR;
}
struct zink_resource_object *new_obj = resource_object_create(screen, &res->base.b, NULL, &res->linear, res->modifiers, res->modifiers_count, NULL);
assert(pdev_count > 0);
pdevs = malloc(sizeof(*pdevs) * pdev_count);
+ if (!pdevs) {
+ mesa_loge("ZINK: failed to allocate pdevs!");
+ return;
+ }
result = VKSCR(EnumeratePhysicalDevices)(screen->instance, &pdev_count, pdevs);
assert(result == VK_SUCCESS);
assert(pdev_count > 0);
assert(num_queues > 0);
VkQueueFamilyProperties *props = malloc(sizeof(*props) * num_queues);
+ if (!props) {
+ mesa_loge("ZINK: failed to allocate props!");
+ return;
+ }
+
VKSCR(GetPhysicalDeviceQueueFamilyProperties)(screen->pdev, &num_queues, props);
bool found_gfx = false;
uint32_t full_velem_mask)
{
struct zink_vertex_state *zstate = CALLOC_STRUCT(zink_vertex_state);
+ if (!zstate) {
+ mesa_loge("ZINK: failed to allocate zstate!");
+ return NULL;
+ }
util_init_pipe_vertex_state(pscreen, buffer, elements, num_elements, indexbuf, full_velem_mask,
&zstate->b);
wrap_surface(struct pipe_context *pctx, const struct pipe_surface *psurf)
{
struct zink_ctx_surface *csurf = CALLOC_STRUCT(zink_ctx_surface);
+ if (!csurf) {
+ mesa_loge("ZINK: failed to allocate csurf!");
+ return NULL;
+ }
+
csurf->base = *psurf;
pipe_reference_init(&csurf->base.reference, 1);
csurf->surf = (struct zink_surface*)psurf;
free(surface->swapchain);
surface->swapchain_size = cdt->swapchain->num_images;
surface->swapchain = calloc(surface->swapchain_size, sizeof(VkImageView));
+ if (!surface->swapchain) {
+ mesa_loge("ZINK: failed to allocate surface->swapchain!");
+ return;
+ }
surface->base.width = res->base.b.width0;
surface->base.height = res->base.b.height0;
init_surface_info(surface, res, &surface->ivci);