return true;
}
-static struct intel_bo *
-tex_create_bo(const struct ilo_texture *tex,
+static bool
+tex_create_bo(struct ilo_texture *tex,
const struct winsys_handle *handle)
{
struct ilo_screen *is = ilo_screen(tex->base.screen);
tex->tiling, tex->bo_flags);
}
- return bo;
-}
+ if (!bo)
+ return false;
-static void
-tex_set_bo(struct ilo_texture *tex, struct intel_bo *bo)
-{
if (tex->bo)
tex->bo->unreference(tex->bo);
/* winsys may decide to use a different tiling */
tex->tiling = tex->bo->get_tiling(tex->bo);
tex->bo_stride = tex->bo->get_pitch(tex->bo);
+
+ return true;
}
static void
{
struct tex_layout layout;
struct ilo_texture *tex;
- struct intel_bo *bo;
tex = CALLOC_STRUCT(ilo_texture);
if (!tex)
tex_layout_apply(&layout, tex);
- bo = tex_create_bo(tex, handle);
- if (!bo) {
+ if (!tex_create_bo(tex, handle)) {
tex_free_slices(tex);
FREE(tex);
return NULL;
}
- tex_set_bo(tex, bo);
-
/* allocate separate stencil resource */
if (layout.separate_stencil) {
struct pipe_resource s8_templ = *layout.templ;
return tex_layout_estimate_size(&layout);
}
-static struct intel_bo *
-buf_create_bo(const struct ilo_buffer *buf)
+static bool
+buf_create_bo(struct ilo_buffer *buf)
{
struct ilo_screen *is = ilo_screen(buf->base.screen);
const char *name;
+ struct intel_bo *bo;
switch (buf->base.bind) {
case PIPE_BIND_VERTEX_BUFFER:
break;
}
- return is->winsys->alloc_buffer(is->winsys,
+ bo = is->winsys->alloc_buffer(is->winsys,
name, buf->bo_size, buf->bo_flags);
-}
+ if (!bo)
+ return false;
-static void
-buf_set_bo(struct ilo_buffer *buf, struct intel_bo *bo)
-{
if (buf->bo)
buf->bo->unreference(buf->bo);
buf->bo = bo;
+
+ return true;
}
static void
buf_create(struct pipe_screen *screen, const struct pipe_resource *templ)
{
struct ilo_buffer *buf;
- struct intel_bo *bo;
buf = CALLOC_STRUCT(ilo_buffer);
if (!buf)
buf->bo_size = templ->width0;
buf->bo_flags = 0;
- bo = buf_create_bo(buf);
- if (!bo) {
+ if (!buf_create_bo(buf)) {
FREE(buf);
return NULL;
}
- buf_set_bo(buf, bo);
-
return &buf->base;
}
bool
ilo_buffer_alloc_bo(struct ilo_buffer *buf)
{
- struct intel_bo *bo;
-
- bo = buf_create_bo(buf);
- if (!bo)
- return false;
-
- buf_set_bo(buf, bo);
-
- return true;
+ return buf_create_bo(buf);
}
bool
ilo_texture_alloc_bo(struct ilo_texture *tex)
{
- struct intel_bo *bo;
-
/* a shared bo cannot be reallocated */
if (tex->imported)
return false;
- bo = tex_create_bo(tex, NULL);
- if (!bo)
- return false;
-
- tex_set_bo(tex, bo);
-
- return true;
+ return tex_create_bo(tex, NULL);
}
/**