summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-03-06 01:36:01 +0800
committerChia-I Wu <[email protected]>2015-03-06 02:25:03 +0800
commit70ef171e91582f60a010a4f0ea9f7ff5ba971ab4 (patch)
tree1c4a9ff952bc9be2de630b7d65d0faa7343f27b8 /src/gallium/drivers/ilo
parent0ac706535a07d003b9a40f8bad5445dd50f6c35b (diff)
ilo: add intel_bo_set_tiling()
Make intel_winsys_alloc_bo() always allocate a linear bo, and add intel_bo_set_tiling() to set the tiling. Document the purpose of tiling.
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r--src/gallium/drivers/ilo/ilo_builder.c2
-rw-r--r--src/gallium/drivers/ilo/ilo_draw.c2
-rw-r--r--src/gallium/drivers/ilo/ilo_render.c2
-rw-r--r--src/gallium/drivers/ilo/ilo_resource.c33
-rw-r--r--src/gallium/drivers/ilo/intel_winsys.h40
5 files changed, 38 insertions, 41 deletions
diff --git a/src/gallium/drivers/ilo/ilo_builder.c b/src/gallium/drivers/ilo/ilo_builder.c
index 92a129030e9..52c4b218435 100644
--- a/src/gallium/drivers/ilo/ilo_builder.c
+++ b/src/gallium/drivers/ilo/ilo_builder.c
@@ -139,7 +139,7 @@ alloc_writer_bo(struct intel_winsys *winsys,
[ILO_BUILDER_WRITER_INSTRUCTION] = "instruction",
};
- return intel_winsys_alloc_buffer(winsys, writer_names[which], size, true);
+ return intel_winsys_alloc_bo(winsys, writer_names[which], size, true);
}
static void *
diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c
index 9d1c419dd2a..02e5225f4cd 100644
--- a/src/gallium/drivers/ilo/ilo_draw.c
+++ b/src/gallium/drivers/ilo/ilo_draw.c
@@ -183,7 +183,7 @@ ilo_init_draw_query(struct ilo_context *ilo, struct ilo_query *q)
q->stride <<= q->in_pairs;
bo_size = (q->stride > 4096) ? q->stride : 4096;
- q->bo = intel_winsys_alloc_buffer(ilo->winsys, "query", bo_size, false);
+ q->bo = intel_winsys_alloc_bo(ilo->winsys, "query", bo_size, false);
if (!q->bo)
return false;
diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c
index c1ed2c37a3e..c5492562de0 100644
--- a/src/gallium/drivers/ilo/ilo_render.c
+++ b/src/gallium/drivers/ilo/ilo_render.c
@@ -113,7 +113,7 @@ ilo_render_create(struct ilo_builder *builder)
render->dev = builder->dev;
render->builder = builder;
- render->workaround_bo = intel_winsys_alloc_buffer(builder->winsys,
+ render->workaround_bo = intel_winsys_alloc_bo(builder->winsys,
"PIPE_CONTROL workaround", 4096, false);
if (!render->workaround_bo) {
ilo_warn("failed to allocate PIPE_CONTROL workaround bo\n");
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c
index 6dfc5801687..9f4ee4012c1 100644
--- a/src/gallium/drivers/ilo/ilo_resource.c
+++ b/src/gallium/drivers/ilo/ilo_resource.c
@@ -185,16 +185,24 @@ tex_create_bo(struct ilo_texture *tex)
struct ilo_screen *is = ilo_screen(tex->base.screen);
const char *name = resource_get_bo_name(&tex->base);
const bool cpu_init = resource_get_cpu_init(&tex->base);
- enum intel_tiling_mode tiling;
+ struct intel_bo *bo;
- /* no native support */
- if (tex->layout.tiling == GEN8_TILING_W)
- tiling = INTEL_TILING_NONE;
- else
- tiling = surface_to_winsys_tiling(tex->layout.tiling);
+ bo = intel_winsys_alloc_bo(is->winsys, name,
+ tex->layout.bo_stride * tex->layout.bo_height, cpu_init);
+
+ /* set the tiling for transfer and export */
+ if (bo && (tex->layout.tiling == GEN6_TILING_X ||
+ tex->layout.tiling == GEN6_TILING_Y)) {
+ const enum intel_tiling_mode tiling =
+ surface_to_winsys_tiling(tex->layout.tiling);
+
+ if (intel_bo_set_tiling(bo, tiling, tex->layout.bo_stride)) {
+ intel_bo_unreference(bo);
+ bo = NULL;
+ }
+ }
- tex->bo = intel_winsys_alloc_bo(is->winsys, name, tiling,
- tex->layout.bo_stride, tex->layout.bo_height, cpu_init);
+ tex->bo = bo;
return (tex->bo != NULL);
}
@@ -230,7 +238,7 @@ tex_create_hiz(struct ilo_texture *tex)
struct ilo_screen *is = ilo_screen(tex->base.screen);
unsigned lv;
- tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "hiz texture",
+ tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "hiz texture",
tex->layout.aux_stride * tex->layout.aux_height, false);
if (!tex->aux_bo)
return false;
@@ -259,7 +267,7 @@ tex_create_mcs(struct ilo_texture *tex)
assert(tex->layout.aux_enables == (1 << (tex->base.last_level + 1)) - 1);
- tex->aux_bo = intel_winsys_alloc_buffer(is->winsys, "mcs texture",
+ tex->aux_bo = intel_winsys_alloc_bo(is->winsys, "mcs texture",
tex->layout.aux_stride * tex->layout.aux_height, false);
if (!tex->aux_bo)
return false;
@@ -383,7 +391,7 @@ tex_get_handle(struct ilo_texture *tex, struct winsys_handle *handle)
enum intel_tiling_mode tiling;
int err;
- /* no native support */
+ /* must match what tex_create_bo() sets */
if (tex->layout.tiling == GEN8_TILING_W)
tiling = INTEL_TILING_NONE;
else
@@ -402,8 +410,7 @@ buf_create_bo(struct ilo_buffer *buf)
const char *name = resource_get_bo_name(&buf->base);
const bool cpu_init = resource_get_cpu_init(&buf->base);
- buf->bo = intel_winsys_alloc_buffer(is->winsys, name,
- buf->bo_size, cpu_init);
+ buf->bo = intel_winsys_alloc_bo(is->winsys, name, buf->bo_size, cpu_init);
return (buf->bo != NULL);
}
diff --git a/src/gallium/drivers/ilo/intel_winsys.h b/src/gallium/drivers/ilo/intel_winsys.h
index 5a199e2e819..77eb030efad 100644
--- a/src/gallium/drivers/ilo/intel_winsys.h
+++ b/src/gallium/drivers/ilo/intel_winsys.h
@@ -126,43 +126,24 @@ intel_winsys_get_reset_stats(struct intel_winsys *winsys,
* Allocate a buffer object.
*
* \param name Informative description of the bo.
- * \param tiling Tiling mode.
- * \param pitch Pitch of the bo.
- * \param height Height of the bo.
+ * \param size Size of the bo.
* \param cpu_init Will be initialized by CPU.
*/
struct intel_bo *
intel_winsys_alloc_bo(struct intel_winsys *winsys,
const char *name,
- enum intel_tiling_mode tiling,
- unsigned long pitch,
- unsigned long height,
+ unsigned long size,
bool cpu_init);
/**
- * Allocate a linear buffer object.
- */
-static inline struct intel_bo *
-intel_winsys_alloc_buffer(struct intel_winsys *winsys,
- const char *name,
- unsigned long size,
- bool cpu_init)
-{
- return intel_winsys_alloc_bo(winsys, name,
- INTEL_TILING_NONE, size, 1, cpu_init);
-}
-
-/**
- * Create a bo from a user memory pointer. Both \p userptr and (\p pitch * \p
- * height) must be page aligned.
+ * Create a bo from a user memory pointer. Both \p userptr and \p size must
+ * be page aligned.
*/
struct intel_bo *
intel_winsys_import_userptr(struct intel_winsys *winsys,
const char *name,
void *userptr,
- enum intel_tiling_mode tiling,
- unsigned long pitch,
- unsigned long height,
+ unsigned long size,
unsigned long flags);
/**
@@ -177,7 +158,8 @@ intel_winsys_import_handle(struct intel_winsys *winsys,
unsigned long *pitch);
/**
- * Export \p bo as a winsys handle for inter-process sharing.
+ * Export \p bo as a winsys handle for inter-process sharing. \p tiling and
+ * \p pitch must match those set by \p intel_bo_set_tiling().
*/
int
intel_winsys_export_handle(struct intel_winsys *winsys,
@@ -234,6 +216,14 @@ void
intel_bo_unreference(struct intel_bo *bo);
/**
+ * Set the tiling of \p bo. The info is used by GTT mapping and bo export.
+ */
+int
+intel_bo_set_tiling(struct intel_bo *bo,
+ enum intel_tiling_mode tiling,
+ unsigned long pitch);
+
+/**
* Map \p bo for CPU access. Recursive mapping is allowed.
*
* map() maps the backing store into CPU address space, cached. It will block