lpr->num_slices_faces[level] = num_slices;
lpr->layout[level] = alloc_layout_array(num_slices, width, height);
+ if (!lpr->layout[level]) {
+ goto fail;
+ }
}
/* Compute size of next mipmap level */
}
return TRUE;
+
+fail:
+ for (level = 0; level <= pt->last_level; level++) {
+ if (lpr->layout[level]) {
+ FREE(lpr->layout[level]);
+ }
+ }
+
+ return FALSE;
}
lpr->img_stride[0] = 0;
lpr->layout[0] = alloc_layout_array(1, width, height);
- //lpr->layout[0][0] = LP_TEX_LAYOUT_LINEAR;
+ if (!lpr->layout[0]) {
+ return FALSE;
+ }
lpr->dt = winsys->displaytarget_create(winsys,
lpr->base.bind,
16,
&lpr->row_stride[0] );
- return lpr->dt != NULL;
+ if (lpr->dt == NULL)
+ return FALSE;
+
+ {
+ void *map = winsys->displaytarget_map(winsys, lpr->dt,
+ PIPE_TRANSFER_WRITE);
+
+ if (map)
+ memset(map, 0, height * lpr->row_stride[0]);
+
+ winsys->displaytarget_unmap(winsys, lpr->dt);
+ }
+
+ return TRUE;
}
lpr->data = align_malloc(bytes, 16);
if (!lpr->data)
goto fail;
+ memset(lpr->data, 0, bytes);
}
lpr->id = id_counter++;
struct winsys_handle *whandle)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
- struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
+ struct llvmpipe_resource *lpr;
unsigned width, height, width_t, height_t;
/* XXX Seems like from_handled depth textures doesn't work that well */
- if (!lpr)
- return NULL;
+ lpr = CALLOC_STRUCT(llvmpipe_resource);
+ if (!lpr) {
+ goto no_lpr;
+ }
lpr->base = *template;
pipe_reference_init(&lpr->base.reference, 1);
template,
whandle,
&lpr->row_stride[0]);
- if (!lpr->dt)
- goto fail;
+ if (!lpr->dt) {
+ goto no_dt;
+ }
lpr->layout[0] = alloc_layout_array(1, lpr->base.width0, lpr->base.height0);
+ if (!lpr->layout[0]) {
+ goto no_layout_0;
+ }
- assert(lpr->layout[0]);
assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
lpr->id = id_counter++;
return &lpr->base;
- fail:
+no_layout_0:
+ winsys->displaytarget_destroy(winsys, lpr->dt);
+no_dt:
FREE(lpr);
+no_lpr:
return NULL;
}
buffer->base.height0 = 1;
buffer->base.depth0 = 1;
buffer->base.array_size = 1;
+ buffer->base.user_ptr = ptr;
buffer->userBuffer = TRUE;
buffer->data = ptr;
/* tiled data is stored in regular memory */
uint buffer_size = tex_image_size(lpr, level, layout);
lpr->tiled[level].data = align_malloc(buffer_size, alignment);
+ if (lpr->tiled[level].data) {
+ memset(lpr->tiled[level].data, 0, buffer_size);
+ }
}
else {
assert(layout == LP_TEX_LAYOUT_LINEAR);
if (lpr->dt) {
- /* we get the linear memory from the winsys */
+ /* we get the linear memory from the winsys, and it has
+ * already been zeroed
+ */
struct llvmpipe_screen *screen = llvmpipe_screen(lpr->base.screen);
struct sw_winsys *winsys = screen->winsys;
/* not a display target - allocate regular memory */
uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR);
lpr->linear[level].data = align_malloc(buffer_size, alignment);
+ if (lpr->linear[level].data) {
+ memset(lpr->linear[level].data, 0, buffer_size);
+ }
}
}
}