summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-06-11 18:51:22 +0800
committerChia-I Wu <[email protected]>2013-06-12 17:46:52 +0800
commit3f79188854fd7f63ad1eb0d4ab1fc24117fd0d78 (patch)
treef249c522e5dbf9f55cf64fcea5d4d1db8f35dde6 /src/gallium/drivers
parentb00d61151dba9904197ad3b5156b182dcca8a152 (diff)
ilo: remove unnecessary tex_set_bo/buf_set_bo
Merge the bodies to tex_create_bo/buf_create_bo respectively.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c60
1 files changed, 18 insertions, 42 deletions
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 270724c4126..85cff908800 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -861,8 +861,8 @@ tex_alloc_slices(struct ilo_texture *tex)
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);
@@ -909,12 +909,9 @@ tex_create_bo(const struct ilo_texture *tex,
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);
@@ -923,6 +920,8 @@ tex_set_bo(struct ilo_texture *tex, struct intel_bo *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
@@ -943,7 +942,6 @@ tex_create(struct pipe_screen *screen,
{
struct tex_layout layout;
struct ilo_texture *tex;
- struct intel_bo *bo;
tex = CALLOC_STRUCT(ilo_texture);
if (!tex)
@@ -1003,15 +1001,12 @@ tex_create(struct pipe_screen *screen,
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;
@@ -1074,11 +1069,12 @@ tex_estimate_size(struct pipe_screen *screen,
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:
@@ -1098,17 +1094,17 @@ buf_create_bo(const struct ilo_buffer *buf)
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
@@ -1122,7 +1118,6 @@ static struct pipe_resource *
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)
@@ -1135,14 +1130,11 @@ buf_create(struct pipe_screen *screen, const struct pipe_resource *templ)
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;
}
@@ -1224,33 +1216,17 @@ ilo_init_resource_functions(struct ilo_screen *is)
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);
}
/**