summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/cell/ppu/cell_surface.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_context.h6
-rw-r--r--src/gallium/drivers/i915simple/i915_state_emit.c12
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c8
-rw-r--r--src/gallium/drivers/i915simple/i915_surface.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c61
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c2
9 files changed, 79 insertions, 38 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c
index a35db0ef991..18f37919241 100644
--- a/src/gallium/drivers/cell/ppu/cell_surface.c
+++ b/src/gallium/drivers/cell/ppu/cell_surface.c
@@ -60,7 +60,7 @@ cell_surface_data(struct pipe_context *pipe,
static void
cell_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
+ boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
@@ -76,7 +76,7 @@ cell_surface_copy(struct pipe_context *pipe,
width, height,
pipe_surface_map(src),
do_flip ? -src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
+ srcx, do_flip ? height - 1 - srcy : srcy);
pipe_surface_unmap(src);
pipe_surface_unmap(dst);
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index 892a88fd2cc..5d411a66486 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -192,6 +192,8 @@ struct i915_texture {
unsigned depth_pitch; /* per-image on i945? */
unsigned total_height;
+ unsigned tiled;
+
unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
/* Explicitly store the offset of each image for each cube face or
@@ -202,10 +204,6 @@ struct i915_texture {
*/
unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */
- /* Includes image offset tables:
- */
- unsigned level_offset[PIPE_MAX_TEXTURE_LEVELS];
-
/* The data is held here:
*/
struct pipe_buffer *buffer;
diff --git a/src/gallium/drivers/i915simple/i915_state_emit.c b/src/gallium/drivers/i915simple/i915_state_emit.c
index bc801a82f03..19d968fd8b6 100644
--- a/src/gallium/drivers/i915simple/i915_state_emit.c
+++ b/src/gallium/drivers/i915simple/i915_state_emit.c
@@ -213,10 +213,10 @@ i915_emit_hardware_state(struct i915_context *i915 )
if (cbuf_surface) {
unsigned cpitch = (cbuf_surface->pitch * cbuf_surface->cpp);
unsigned ctile = BUF_3D_USE_FENCE;
-#if 0
- if (!((cpitch - 1) & cpitch) && cpitch >= 512)
+ if (cbuf_surface->texture &&
+ ((struct i915_texture*)(cbuf_surface->texture))->tiled) {
ctile = BUF_3D_TILED_SURFACE;
-#endif
+ }
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
@@ -234,10 +234,10 @@ i915_emit_hardware_state(struct i915_context *i915 )
if (depth_surface) {
unsigned zpitch = (depth_surface->pitch * depth_surface->cpp);
unsigned ztile = BUF_3D_USE_FENCE;
-#if 0
- if (!((zpitch - 1) & zpitch) && zpitch >= 512)
+ if (depth_surface->texture &&
+ ((struct i915_texture*)(depth_surface->texture))->tiled) {
ztile = BUF_3D_TILED_SURFACE;
-#endif
+ }
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 24440843f33..379aff38460 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -234,6 +234,7 @@ i915_update_texture(struct i915_context *i915,
const uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
const uint num_levels = pt->last_level;
unsigned max_lod = num_levels * 4;
+ unsigned tiled = MS3_USE_FENCE_REGS;
assert(tex);
assert(width);
@@ -246,12 +247,17 @@ i915_update_texture(struct i915_context *i915,
assert(format);
assert(pitch);
+ if (tex->tiled) {
+ assert(!((pitch - 1) & pitch));
+ tiled = MS3_TILED_SURFACE;
+ }
+
/* MS3 state */
state[0] =
(((height - 1) << MS3_HEIGHT_SHIFT)
| ((width - 1) << MS3_WIDTH_SHIFT)
| format
- | MS3_USE_FENCE_REGS);
+ | tiled);
/*
* XXX When min_filter != mag_filter and there's just one mipmap level,
diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c
index 98367ac0739..cc55a0910ed 100644
--- a/src/gallium/drivers/i915simple/i915_surface.c
+++ b/src/gallium/drivers/i915simple/i915_surface.c
@@ -41,7 +41,7 @@
*/
static void
i915_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
+ boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
@@ -66,7 +66,7 @@ i915_surface_copy(struct pipe_context *pipe,
width, height,
src_map,
do_flip ? -(int) src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
+ srcx, do_flip ? height - 1 - srcy : srcy);
pipe->screen->surface_unmap(pipe->screen, src);
pipe->screen->surface_unmap(pipe->screen, dst);
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 9cd32e39191..b2e490c7db1 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -100,7 +100,7 @@ static void
i915_miptree_set_level_info(struct i915_texture *tex,
unsigned level,
unsigned nr_images,
- unsigned x, unsigned y, unsigned w, unsigned h, unsigned d)
+ unsigned w, unsigned h, unsigned d)
{
struct pipe_texture *pt = &tex->base;
@@ -110,7 +110,6 @@ i915_miptree_set_level_info(struct i915_texture *tex,
pt->height[level] = h;
pt->depth[level] = d;
- tex->level_offset[level] = (x + y * tex->pitch) * pt->cpp;
tex->nr_images[level] = nr_images;
/*
@@ -166,7 +165,7 @@ i915_displaytarget_layout(struct i915_texture *tex)
if (pt->last_level > 0 || pt->cpp != 4)
return 0;
- i915_miptree_set_level_info( tex, 0, 1, 0, 0,
+ i915_miptree_set_level_info( tex, 0, 1,
tex->base.width[0],
tex->base.height[0],
1 );
@@ -175,6 +174,7 @@ i915_displaytarget_layout(struct i915_texture *tex)
if (tex->base.width[0] >= 128) {
tex->pitch = power_of_two(tex->base.width[0] * pt->cpp) / pt->cpp;
tex->total_height = round_up(tex->base.height[0], 8);
+ tex->tiled = 1;
} else {
tex->pitch = round_up(tex->base.width[0], 64 / pt->cpp);
tex->total_height = tex->base.height[0];
@@ -230,7 +230,8 @@ i945_miptree_layout_2d( struct i915_texture *tex )
for (level = 0; level <= pt->last_level; level++) {
unsigned img_height;
- i915_miptree_set_level_info(tex, level, 1, x, y, width, height, 1);
+ i915_miptree_set_level_info(tex, level, 1, width, height, 1);
+ i915_miptree_set_image_offset(tex, level, 0, x, y);
if (pt->compressed)
img_height = MAX2(1, height/4);
@@ -294,7 +295,7 @@ i945_miptree_layout_cube(struct i915_texture *tex)
/* Set all the levels to effectively occupy the whole rectangular region.
*/
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 6, 0, 0, lvlWidth, lvlHeight, 1);
+ i915_miptree_set_level_info(tex, level, 6, lvlWidth, lvlHeight, 1);
lvlWidth /= 2;
lvlHeight /= 2;
}
@@ -380,8 +381,6 @@ i915_miptree_layout(struct i915_texture * tex)
for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 6,
- 0, 0,
- /*OLD: tex->pitch, tex->total_height,*/
lvlWidth, lvlHeight,
1);
lvlWidth /= 2;
@@ -416,7 +415,7 @@ i915_miptree_layout(struct i915_texture * tex)
*/
for (level = 0; level <= MAX2(8, pt->last_level);
level++) {
- i915_miptree_set_level_info(tex, level, depth, 0, tex->total_height,
+ i915_miptree_set_level_info(tex, level, depth,
width, height, depth);
@@ -458,8 +457,9 @@ i915_miptree_layout(struct i915_texture * tex)
for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 1,
- 0, tex->total_height,
width, height, 1);
+ i915_miptree_set_image_offset(tex, level, 0,
+ 0, tex->total_height);
if (pt->compressed)
img_height = MAX2(1, height / 4);
@@ -515,12 +515,11 @@ i945_miptree_layout(struct i915_texture * tex)
unsigned q, j;
i915_miptree_set_level_info(tex, level, nr_images,
- 0, tex->total_height,
width, height, depth);
for (q = 0; q < nr_images;) {
for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) {
- i915_miptree_set_image_offset(tex, level, q, x, y);
+ i915_miptree_set_image_offset(tex, level, q, x, y + tex->total_height);
x += pack_x_pitch;
}
@@ -648,15 +647,14 @@ i915_get_tex_surface(struct pipe_screen *screen,
struct pipe_surface *ps;
unsigned offset; /* in bytes */
- offset = tex->level_offset[level];
-
if (pt->target == PIPE_TEXTURE_CUBE) {
- offset += tex->image_offset[level][face] * pt->cpp;
+ offset = tex->image_offset[level][face] * pt->cpp;
}
else if (pt->target == PIPE_TEXTURE_3D) {
- offset += tex->image_offset[level][zslice] * pt->cpp;
+ offset = tex->image_offset[level][zslice] * pt->cpp;
}
else {
+ offset = tex->image_offset[level][0] * pt->cpp;
assert(face == 0);
assert(zslice == 0);
}
@@ -679,6 +677,38 @@ i915_get_tex_surface(struct pipe_screen *screen,
return ps;
}
+static struct pipe_texture *
+i915_texture_blanket(struct pipe_screen * screen,
+ const struct pipe_texture *base,
+ const unsigned *pitch,
+ struct pipe_buffer *buffer)
+{
+ struct i915_texture *tex;
+ assert(screen);
+
+ /* Only supports one type */
+ if (base->target != PIPE_TEXTURE_2D ||
+ base->last_level != 0 ||
+ base->depth[0] != 1) {
+ return NULL;
+ }
+
+ tex = CALLOC_STRUCT(i915_texture);
+ if (!tex)
+ return NULL;
+
+ tex->base = *base;
+
+ tex->pitch = pitch[0];
+
+ i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
+ i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
+
+ pipe_buffer_reference(screen->winsys, &tex->buffer, buffer);
+
+ return &tex->base;
+}
+
void
i915_init_texture_functions(struct i915_context *i915)
{
@@ -715,5 +745,6 @@ i915_init_screen_texture_functions(struct pipe_screen *screen)
screen->texture_create = i915_texture_create;
screen->texture_release = i915_texture_release;
screen->get_tex_surface = i915_get_tex_surface;
+ screen->texture_blanket = i915_texture_blanket;
screen->tex_surface_release = i915_tex_surface_release;
}
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index 3e3736b2806..3d98a2bf199 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -41,7 +41,7 @@
*/
static void
brw_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
+ boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
@@ -66,7 +66,7 @@ brw_surface_copy(struct pipe_context *pipe,
width, height,
src_map,
do_flip ? -(int) src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
+ srcx, do_flip ? height - 1 - srcy : srcy);
pipe->screen->surface_unmap(pipe->screen, src);
pipe->screen->surface_unmap(pipe->screen, dst);
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index 29a1e92416e..9fd48aeccc5 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -35,12 +35,16 @@
-/* Assumes all values are within bounds -- no checking at this level -
+/**
+ * Copy a rectangular region from one surface to another.
+ * Surfaces must have same bpp.
+ *
+ * Assumes all values are within bounds -- no checking at this level -
* do it higher up if required.
*/
static void
sp_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
+ boolean do_flip,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
struct pipe_surface *src,
@@ -54,9 +58,11 @@ sp_surface_copy(struct pipe_context *pipe,
src,
PIPE_BUFFER_USAGE_CPU_READ );
- assert( dst->cpp == src->cpp );
- assert(src_map && dst_map);
+ assert(dst->cpp == src->cpp);
+ assert(src_map);
+ assert(dst_map);
+ /* If do_flip, invert src_y position and pass negative src stride */
pipe_copy_rect(dst_map,
dst->cpp,
dst->pitch,
@@ -64,7 +70,7 @@ sp_surface_copy(struct pipe_context *pipe,
width, height,
src_map,
do_flip ? -(int) src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
+ srcx, do_flip ? src->height - 1 - srcy : srcy);
pipe->screen->surface_unmap(pipe->screen, src);
pipe->screen->surface_unmap(pipe->screen, dst);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index ef8c5bd6b0c..2ef17a220b4 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -198,7 +198,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->pitch = ps->width;
+ ps->pitch = spt->pitch[level];
ps->offset = spt->level_offset[level];
ps->usage = usage;