summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/ilo/core/ilo_image.h25
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter_blt.c8
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c48
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.h7
-rw-r--r--src/gallium/drivers/ilo/ilo_state_3d_bottom.c6
-rw-r--r--src/gallium/drivers/ilo/ilo_state_3d_top.c2
-rw-r--r--src/gallium/drivers/ilo/ilo_transfer.c6
7 files changed, 63 insertions, 39 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_image.h b/src/gallium/drivers/ilo/core/ilo_image.h
index 722a666991d..2ca48b7960f 100644
--- a/src/gallium/drivers/ilo/core/ilo_image.h
+++ b/src/gallium/drivers/ilo/core/ilo_image.h
@@ -29,6 +29,7 @@
#define ILO_IMAGE_H
#include "genhw/genhw.h"
+#include "intel_winsys.h"
#include "ilo_core.h"
#include "ilo_dev.h"
@@ -122,6 +123,9 @@ struct ilo_image {
unsigned aux_layer_height;
unsigned aux_stride;
unsigned aux_height;
+
+ struct intel_bo *bo;
+ struct intel_bo *aux_bo;
};
void
@@ -134,6 +138,27 @@ ilo_image_update_for_imported_bo(struct ilo_image *img,
enum gen_surface_tiling tiling,
unsigned bo_stride);
+static inline void
+ilo_image_cleanup(struct ilo_image *img)
+{
+ intel_bo_unref(img->bo);
+ intel_bo_unref(img->aux_bo);
+}
+
+static inline void
+ilo_image_set_bo(struct ilo_image *img, struct intel_bo *bo)
+{
+ intel_bo_unref(img->bo);
+ img->bo = intel_bo_ref(bo);
+}
+
+static inline void
+ilo_image_set_aux_bo(struct ilo_image *img, struct intel_bo *bo)
+{
+ intel_bo_unref(img->aux_bo);
+ img->aux_bo = intel_bo_ref(bo);
+}
+
/**
* Convert from pixel position to 2D memory offset.
*/
diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c
index 5e67198adb1..965f7f2b748 100644
--- a/src/gallium/drivers/ilo/ilo_blitter_blt.c
+++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c
@@ -258,14 +258,14 @@ tex_clear_region(struct ilo_blitter *blitter,
if (dst_box->width * cpp > gen6_blt_max_bytes_per_scanline)
return false;
- dst.bo = dst_tex->bo;
+ dst.bo = dst_tex->image.bo;
dst.offset = 0;
dst.pitch = dst_tex->image.bo_stride;
dst.tiling = dst_tex->image.tiling;
swctrl = ilo_blitter_blt_begin(blitter,
GEN6_XY_COLOR_BLT__SIZE * dst_box->depth,
- dst_tex->bo, dst_tex->image.tiling, NULL, GEN6_TILING_NONE);
+ dst_tex->image.bo, dst_tex->image.tiling, NULL, GEN6_TILING_NONE);
for (slice = 0; slice < dst_box->depth; slice++) {
unsigned x, y;
@@ -347,12 +347,12 @@ tex_copy_region(struct ilo_blitter *blitter,
break;
}
- dst.bo = dst_tex->bo;
+ dst.bo = dst_tex->image.bo;
dst.offset = 0;
dst.pitch = dst_tex->image.bo_stride;
dst.tiling = dst_tex->image.tiling;
- src.bo = src_tex->bo;
+ src.bo = src_tex->image.bo;
src.offset = 0;
src.pitch = src_tex->image.bo_stride;
src.tiling = src_tex->image.tiling;
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index f5038952f43..7e8d70083cb 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -161,20 +161,23 @@ tex_import_handle(struct ilo_texture *tex,
const char *name = resource_get_bo_name(&tex->base);
enum intel_tiling_mode tiling;
unsigned long pitch;
+ struct intel_bo *bo;
- tex->bo = intel_winsys_import_handle(is->dev.winsys, name, handle,
+ bo = intel_winsys_import_handle(is->dev.winsys, name, handle,
tex->image.bo_height, &tiling, &pitch);
- if (!tex->bo)
+ if (!bo)
return false;
if (!ilo_image_update_for_imported_bo(&tex->image,
winsys_to_surface_tiling(tiling), pitch)) {
ilo_err("imported handle has incompatible tiling/pitch\n");
- intel_bo_unref(tex->bo);
- tex->bo = NULL;
+ intel_bo_unref(bo);
return false;
}
+ ilo_image_set_bo(&tex->image, bo);
+ intel_bo_unref(bo);
+
return true;
}
@@ -200,10 +203,13 @@ tex_create_bo(struct ilo_texture *tex)
bo = NULL;
}
}
+ if (!bo)
+ return false;
- tex->bo = bo;
+ ilo_image_set_bo(&tex->image, bo);
+ intel_bo_unref(bo);
- return (tex->bo != NULL);
+ return true;
}
static bool
@@ -238,13 +244,16 @@ tex_create_hiz(struct ilo_texture *tex)
{
const struct pipe_resource *templ = &tex->base;
struct ilo_screen *is = ilo_screen(tex->base.screen);
+ struct intel_bo *bo;
unsigned lv;
- tex->aux_bo = intel_winsys_alloc_bo(is->dev.winsys, "hiz texture",
+ bo = intel_winsys_alloc_bo(is->dev.winsys, "hiz texture",
tex->image.aux_stride * tex->image.aux_height, false);
- if (!tex->aux_bo)
+ if (!bo)
return false;
+ ilo_image_set_aux_bo(&tex->image, bo);
+
for (lv = 0; lv <= templ->last_level; lv++) {
if (tex->image.aux_enables & (1 << lv)) {
const unsigned num_slices = (templ->target == PIPE_TEXTURE_3D) ?
@@ -266,14 +275,17 @@ static bool
tex_create_mcs(struct ilo_texture *tex)
{
struct ilo_screen *is = ilo_screen(tex->base.screen);
+ struct intel_bo *bo;
assert(tex->image.aux_enables == (1 << (tex->base.last_level + 1)) - 1);
- tex->aux_bo = intel_winsys_alloc_bo(is->dev.winsys, "mcs texture",
+ bo = intel_winsys_alloc_bo(is->dev.winsys, "mcs texture",
tex->image.aux_stride * tex->image.aux_height, false);
- if (!tex->aux_bo)
+ if (!bo)
return false;
+ ilo_image_set_aux_bo(&tex->image, bo);
+
return true;
}
@@ -283,8 +295,7 @@ tex_destroy(struct ilo_texture *tex)
if (tex->separate_s8)
tex_destroy(tex->separate_s8);
- intel_bo_unref(tex->aux_bo);
- intel_bo_unref(tex->bo);
+ ilo_image_cleanup(&tex->image);
tex_free_slices(tex);
FREE(tex);
@@ -396,7 +407,7 @@ tex_get_handle(struct ilo_texture *tex, struct winsys_handle *handle)
else
tiling = surface_to_winsys_tiling(tex->image.tiling);
- err = intel_winsys_export_handle(is->dev.winsys, tex->bo, tiling,
+ err = intel_winsys_export_handle(is->dev.winsys, tex->image.bo, tiling,
tex->image.bo_stride, tex->image.bo_height, handle);
return !err;
@@ -565,18 +576,9 @@ ilo_buffer_rename_bo(struct ilo_buffer *buf)
bool
ilo_texture_rename_bo(struct ilo_texture *tex)
{
- struct intel_bo *old_bo = tex->bo;
-
/* an imported texture cannot be renamed */
if (tex->imported)
return false;
- if (tex_create_bo(tex)) {
- intel_bo_unref(old_bo);
- return true;
- }
- else {
- tex->bo = old_bo;
- return false;
- }
+ return tex_create_bo(tex);
}
diff --git a/src/gallium/drivers/ilo/ilo_resource.h b/src/gallium/drivers/ilo/ilo_resource.h
index 3b520aa5b27..b5be9b5300d 100644
--- a/src/gallium/drivers/ilo/ilo_resource.h
+++ b/src/gallium/drivers/ilo/ilo_resource.h
@@ -111,11 +111,8 @@ struct ilo_texture {
struct ilo_image image;
/* XXX thread-safety */
- struct intel_bo *bo;
struct ilo_texture_slice *slices[PIPE_MAX_TEXTURE_LEVELS];
- struct intel_bo *aux_bo;
-
struct ilo_texture *separate_s8;
};
@@ -149,7 +146,7 @@ static inline struct intel_bo *
ilo_resource_get_bo(struct pipe_resource *res)
{
return (res->target == PIPE_BUFFER) ?
- ilo_buffer(res)->bo : ilo_texture(res)->bo;
+ ilo_buffer(res)->bo : ilo_texture(res)->image.bo;
}
static inline struct ilo_texture_slice *
@@ -206,7 +203,7 @@ ilo_texture_can_enable_hiz(const struct ilo_texture *tex, unsigned level,
const struct ilo_texture_slice *slice =
ilo_texture_get_slice(tex, level, 0);
- return (tex->aux_bo && (slice->flags & ILO_TEXTURE_HIZ));
+ return (tex->image.aux_bo && (slice->flags & ILO_TEXTURE_HIZ));
}
#endif /* ILO_RESOURCE_H */
diff --git a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c
index f4a850634f7..13c1a7feead 100644
--- a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c
+++ b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c
@@ -1031,7 +1031,7 @@ zs_init_info(const struct ilo_dev *dev,
}
if (format != PIPE_FORMAT_S8_UINT) {
- info->zs.bo = tex->bo;
+ info->zs.bo = tex->image.bo;
info->zs.stride = tex->image.bo_stride;
assert(tex->image.layer_height % 4 == 0);
@@ -1045,7 +1045,7 @@ zs_init_info(const struct ilo_dev *dev,
const struct ilo_texture *s8_tex =
(tex->separate_s8) ? tex->separate_s8 : tex;
- info->stencil.bo = s8_tex->bo;
+ info->stencil.bo = s8_tex->image.bo;
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 329:
@@ -1076,7 +1076,7 @@ zs_init_info(const struct ilo_dev *dev,
}
if (ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers)) {
- info->hiz.bo = tex->aux_bo;
+ info->hiz.bo = tex->image.aux_bo;
info->hiz.stride = tex->image.aux_stride;
assert(tex->image.aux_layer_height % 4 == 0);
diff --git a/src/gallium/drivers/ilo/ilo_state_3d_top.c b/src/gallium/drivers/ilo/ilo_state_3d_top.c
index 79cd8b5c3b0..f022972414e 100644
--- a/src/gallium/drivers/ilo/ilo_state_3d_top.c
+++ b/src/gallium/drivers/ilo/ilo_state_3d_top.c
@@ -1246,7 +1246,7 @@ ilo_gpe_init_view_surface_for_texture(const struct ilo_dev *dev,
}
/* do not increment reference count */
- surf->bo = tex->bo;
+ surf->bo = tex->image.bo;
/* assume imported RTs are scanouts */
surf->scanout = ((tex->base.bind & PIPE_BIND_SCANOUT) ||
diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c
index e80ed8bda9c..4ee33523753 100644
--- a/src/gallium/drivers/ilo/ilo_transfer.c
+++ b/src/gallium/drivers/ilo/ilo_transfer.c
@@ -553,9 +553,9 @@ tex_staging_sys_map_bo(struct ilo_texture *tex,
if (prefer_cpu && (tex->image.tiling == GEN6_TILING_NONE ||
!linear_view))
- ptr = intel_bo_map(tex->bo, !for_read_back);
+ ptr = intel_bo_map(tex->image.bo, !for_read_back);
else
- ptr = intel_bo_map_gtt(tex->bo);
+ ptr = intel_bo_map_gtt(tex->image.bo);
return ptr;
}
@@ -563,7 +563,7 @@ tex_staging_sys_map_bo(struct ilo_texture *tex,
static void
tex_staging_sys_unmap_bo(struct ilo_texture *tex)
{
- intel_bo_unmap(tex->bo);
+ intel_bo_unmap(tex->image.bo);
}
static bool