We want to work with ilo_image instead of ilo_texture in core.
#define ILO_IMAGE_H
#include "genhw/genhw.h"
+#include "intel_winsys.h"
#include "ilo_core.h"
#include "ilo_dev.h"
unsigned aux_layer_height;
unsigned aux_stride;
unsigned aux_height;
+
+ struct intel_bo *bo;
+ struct intel_bo *aux_bo;
};
void
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.
*/
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;
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;
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;
}
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
{
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) ?
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;
}
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);
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;
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);
}
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;
};
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 *
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 */
}
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);
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:
}
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);
}
/* 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) ||
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;
}
static void
tex_staging_sys_unmap_bo(struct ilo_texture *tex)
{
- intel_bo_unmap(tex->bo);
+ intel_bo_unmap(tex->image.bo);
}
static bool