summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i915
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2009-12-02 02:08:26 +0100
committerRoland Scheidegger <sroland@vmware.com>2009-12-02 02:08:26 +0100
commitc78748a5274e58bcbb122923edf81065be9bbe16 (patch)
tree9b22e49cfb1a1edb1a1acfd086245fbd8ac83b2b /src/gallium/drivers/i915
parentdecf6ed810eae473d043a4a399a5a84f1378a725 (diff)
gallium: adapt drivers to interface cleanups
Diffstat (limited to 'src/gallium/drivers/i915')
-rw-r--r--src/gallium/drivers/i915/i915_surface.c21
-rw-r--r--src/gallium/drivers/i915/i915_texture.c125
2 files changed, 64 insertions, 82 deletions
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index ab8331f3e6..24e1024aaa 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -48,17 +48,19 @@ i915_surface_copy(struct pipe_context *pipe,
{
struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
struct i915_texture *src_tex = (struct i915_texture *)src->texture;
+ struct pipe_texture *dpt = &dst_tex->base;
+ struct pipe_texture *spt = &src_tex->base;
assert( dst != src );
- assert( dst_tex->base.block.size == src_tex->base.block.size );
- assert( dst_tex->base.block.width == src_tex->base.block.height );
- assert( dst_tex->base.block.height == src_tex->base.block.height );
- assert( dst_tex->base.block.width == 1 );
- assert( dst_tex->base.block.height == 1 );
+ assert( pf_get_blocksize(dpt->format) == pf_get_blocksize(spt->format) );
+ assert( pf_get_blockwidth(dpt->format) == pf_get_blockwidth(spt->format) );
+ assert( pf_get_blockheight(dpt->format) == pf_get_blockheight(spt->format) );
+ assert( pf_get_blockwidth(dpt->format) == 1 );
+ assert( pf_get_blockheight(dpt->format) == 1 );
i915_copy_blit( i915_context(pipe),
FALSE,
- dst_tex->base.block.size,
+ pf_get_blocksize(dpt->format),
(unsigned short) src_tex->stride, src_tex->buffer, src->offset,
(unsigned short) dst_tex->stride, dst_tex->buffer, dst->offset,
(short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
@@ -72,12 +74,13 @@ i915_surface_fill(struct pipe_context *pipe,
unsigned width, unsigned height, unsigned value)
{
struct i915_texture *tex = (struct i915_texture *)dst->texture;
+ struct pipe_texture *pt = &tex->base;
- assert(tex->base.block.width == 1);
- assert(tex->base.block.height == 1);
+ assert(pf_get_blockwidth(pt->format) == 1);
+ assert(pf_get_blockheight(pt->format) == 1);
i915_fill_blit( i915_context(pipe),
- tex->base.block.size,
+ pf_get_blocksize(pt->format),
(unsigned short) tex->stride,
tex->buffer, dst->offset,
(short) dstx, (short) dsty,
diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c
index c7b86dd4c5..b28b413771 100644
--- a/src/gallium/drivers/i915/i915_texture.c
+++ b/src/gallium/drivers/i915/i915_texture.c
@@ -74,6 +74,9 @@ static const int step_offsets[6][2] = {
{-1, 1}
};
+/* XXX really need twice the size if x is already pot?
+ Otherwise just use util_next_power_of_two?
+*/
static unsigned
power_of_two(unsigned x)
{
@@ -83,13 +86,6 @@ power_of_two(unsigned x)
return value;
}
-static unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
/*
* More advanced helper funcs
*/
@@ -101,13 +97,8 @@ i915_miptree_set_level_info(struct i915_texture *tex,
unsigned nr_images,
unsigned w, unsigned h, unsigned d)
{
- struct pipe_texture *pt = &tex->base;
-
assert(level < PIPE_MAX_TEXTURE_LEVELS);
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h);
-
tex->nr_images[level] = nr_images;
/*
@@ -138,7 +129,7 @@ i915_miptree_set_image_offset(struct i915_texture *tex,
assert(img < tex->nr_images[level]);
- tex->image_offset[level][img] = y * tex->stride + x * tex->base.block.size;
+ tex->image_offset[level][img] = y * tex->stride + x * pf_get_blocksize(tex->base.format);
/*
printf("%s level %d img %d pos %d,%d image_offset %x\n",
@@ -160,28 +151,28 @@ i915_scanout_layout(struct i915_texture *tex)
{
struct pipe_texture *pt = &tex->base;
- if (pt->last_level > 0 || pt->block.size != 4)
+ if (pt->last_level > 0 || pf_get_blocksize(pt->format) != 4)
return FALSE;
i915_miptree_set_level_info(tex, 0, 1,
- tex->base.width0,
- tex->base.height0,
+ pt->width0,
+ pt->height0,
1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- if (tex->base.width0 >= 240) {
- tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
- tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+ if (pt->width0 >= 240) {
+ tex->stride = power_of_two(pf_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(pf_get_nblocksy(pt->format, pt->height0), 8);
tex->hw_tiled = INTEL_TILE_X;
- } else if (tex->base.width0 == 64 && tex->base.height0 == 64) {
- tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
- tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+ } else if (pt->width0 == 64 && pt->height0 == 64) {
+ tex->stride = power_of_two(pf_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(pf_get_nblocksy(pt->format, pt->height0), 8);
} else {
return FALSE;
}
debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
- tex->base.width0, tex->base.height0, pt->block.size,
+ pt->width0, pt->height0, pf_get_blocksize(pt->format),
tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
return TRUE;
@@ -195,25 +186,25 @@ i915_display_target_layout(struct i915_texture *tex)
{
struct pipe_texture *pt = &tex->base;
- if (pt->last_level > 0 || pt->block.size != 4)
+ if (pt->last_level > 0 || pf_get_blocksize(pt->format) != 4)
return FALSE;
/* fallback to normal textures for small textures */
- if (tex->base.width0 < 240)
+ if (pt->width0 < 240)
return FALSE;
i915_miptree_set_level_info(tex, 0, 1,
- tex->base.width0,
- tex->base.height0,
+ pt->width0,
+ pt->height0,
1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
- tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
+ tex->stride = power_of_two(pf_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(pf_get_nblocksy(pt->format, pt->height0), 8);
tex->hw_tiled = INTEL_TILE_X;
debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
- tex->base.width0, tex->base.height0, pt->block.size,
+ pt->width0, pt->height0, pf_get_blocksize(pt->format),
tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
return TRUE;
@@ -226,34 +217,32 @@ i915_miptree_layout_2d(struct i915_texture *tex)
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
- unsigned nblocksx = pt->nblocksx[0];
- unsigned nblocksy = pt->nblocksy[0];
+ unsigned nblocksy = pf_get_nblocksy(pt->format, pt->width0);
/* used for scanouts that need special layouts */
- if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
+ if (pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
if (i915_scanout_layout(tex))
return;
/* for shared buffers we use some very like scanout */
- if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+ if (pt->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
if (i915_display_target_layout(tex))
return;
- tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+ tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 1, width, height, 1);
i915_miptree_set_image_offset(tex, level, 0, 0, tex->total_nblocksy);
- nblocksy = round_up(MAX2(2, nblocksy), 2);
+ nblocksy = align(MAX2(2, nblocksy), 2);
tex->total_nblocksy += nblocksy;
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksx = pf_get_nblocksx(&pt->block, width);
- nblocksy = pf_get_nblocksy(&pt->block, height);
+ nblocksy = pf_get_nblocksy(pt->format, height);
}
}
@@ -266,13 +255,12 @@ i915_miptree_layout_3d(struct i915_texture *tex)
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned depth = pt->depth0;
- unsigned nblocksx = pt->nblocksx[0];
- unsigned nblocksy = pt->nblocksy[0];
+ unsigned nblocksy = pf_get_nblocksy(pt->format, pt->height0);
unsigned stack_nblocksy = 0;
/* Calculate the size of a single slice.
*/
- tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+ tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
/* XXX: hardware expects/requires 9 levels at minimum.
*/
@@ -283,8 +271,7 @@ i915_miptree_layout_3d(struct i915_texture *tex)
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksx = pf_get_nblocksx(&pt->block, width);
- nblocksy = pf_get_nblocksy(&pt->block, height);
+ nblocksy = pf_get_nblocksy(pt->format, height);
}
/* Fixup depth image_offsets:
@@ -309,14 +296,14 @@ i915_miptree_layout_cube(struct i915_texture *tex)
{
struct pipe_texture *pt = &tex->base;
unsigned width = pt->width0, height = pt->height0;
- const unsigned nblocks = pt->nblocksx[0];
+ const unsigned nblocks = pf_get_nblocksx(pt->format, pt->width0);
unsigned level;
unsigned face;
assert(width == height); /* cubemap images are square */
/* double pitch for cube layouts */
- tex->stride = round_up(nblocks * pt->block.size * 2, 4);
+ tex->stride = align(nblocks * pf_get_blocksize(pt->format) * 2, 4);
tex->total_nblocksy = nblocks * 4;
for (level = 0; level <= pt->last_level; level++) {
@@ -379,8 +366,8 @@ i945_miptree_layout_2d(struct i915_texture *tex)
unsigned y = 0;
unsigned width = pt->width0;
unsigned height = pt->height0;
- unsigned nblocksx = pt->nblocksx[0];
- unsigned nblocksy = pt->nblocksy[0];
+ unsigned nblocksx = pf_get_nblocksx(pt->format, pt->width0);
+ unsigned nblocksy = pf_get_nblocksy(pt->format, pt->height0);
/* used for scanouts that need special layouts */
if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
@@ -392,7 +379,7 @@ i945_miptree_layout_2d(struct i915_texture *tex)
if (i915_display_target_layout(tex))
return;
- tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+ tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
/* May need to adjust pitch to accomodate the placement of
* the 2nd mipmap level. This occurs when the alignment
@@ -401,11 +388,11 @@ i945_miptree_layout_2d(struct i915_texture *tex)
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align(pf_get_nblocksx(&pt->block, u_minify(width, 1)), align_x)
- + pf_get_nblocksx(&pt->block, u_minify(width, 2));
+ = align(pf_get_nblocksx(pt->format, u_minify(width, 1)), align_x)
+ + pf_get_nblocksx(pt->format, u_minify(width, 2));
if (mip1_nblocksx > nblocksx)
- tex->stride = mip1_nblocksx * pt->block.size;
+ tex->stride = mip1_nblocksx * pf_get_blocksize(pt->format);
}
/* Pitch must be a whole number of dwords
@@ -435,8 +422,8 @@ i945_miptree_layout_2d(struct i915_texture *tex)
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksx = pf_get_nblocksx(&pt->block, width);
- nblocksy = pf_get_nblocksy(&pt->block, height);
+ nblocksx = pf_get_nblocksx(pt->format, width);
+ nblocksy = pf_get_nblocksy(pt->format, height);
}
}
@@ -447,17 +434,16 @@ i945_miptree_layout_3d(struct i915_texture *tex)
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned depth = pt->depth0;
- unsigned nblocksx = pt->nblocksx[0];
- unsigned nblocksy = pt->nblocksy[0];
+ unsigned nblocksy = pf_get_nblocksy(pt->format, pt->width0);
unsigned pack_x_pitch, pack_x_nr;
unsigned pack_y_pitch;
unsigned level;
- tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4);
+ tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
tex->total_nblocksy = 0;
- pack_y_pitch = MAX2(pt->nblocksy[0], 2);
- pack_x_pitch = tex->stride / pt->block.size;
+ pack_y_pitch = MAX2(nblocksy, 2);
+ pack_x_pitch = tex->stride / pf_get_blocksize(pt->format);
pack_x_nr = 1;
for (level = 0; level <= pt->last_level; level++) {
@@ -482,7 +468,7 @@ i945_miptree_layout_3d(struct i915_texture *tex)
if (pack_x_pitch > 4) {
pack_x_pitch >>= 1;
pack_x_nr <<= 1;
- assert(pack_x_pitch * pack_x_nr * pt->block.size <= tex->stride);
+ assert(pack_x_pitch * pack_x_nr * pf_get_blocksize(pt->format) <= tex->stride);
}
if (pack_y_pitch > 2) {
@@ -492,8 +478,7 @@ i945_miptree_layout_3d(struct i915_texture *tex)
width = u_minify(width, 1);
height = u_minify(height, 1);
depth = u_minify(depth, 1);
- nblocksx = pf_get_nblocksx(&pt->block, width);
- nblocksy = pf_get_nblocksy(&pt->block, height);
+ nblocksy = pf_get_nblocksy(pt->format, height);
}
}
@@ -503,7 +488,7 @@ i945_miptree_layout_cube(struct i915_texture *tex)
struct pipe_texture *pt = &tex->base;
unsigned level;
- const unsigned nblocks = pt->nblocksx[0];
+ const unsigned nblocks = pf_get_nblocksx(pt->format, pt->width0);
unsigned face;
unsigned width = pt->width0;
unsigned height = pt->height0;
@@ -523,9 +508,9 @@ i945_miptree_layout_cube(struct i915_texture *tex)
* or the final row of 4x4, 2x2 and 1x1 faces below this.
*/
if (nblocks > 32)
- tex->stride = round_up(nblocks * pt->block.size * 2, 4);
+ tex->stride = align(nblocks * pf_get_blocksize(pt->format) * 2, 4);
else
- tex->stride = 14 * 8 * pt->block.size;
+ tex->stride = 14 * 8 * pf_get_blocksize(pt->format);
tex->total_nblocksy = nblocks * 4;
@@ -645,9 +630,6 @@ i915_texture_create(struct pipe_screen *screen,
pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
- tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width0);
- tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height0);
-
if (is->is_i945) {
if (!i945_miptree_layout(tex))
goto fail;
@@ -829,14 +811,10 @@ i915_get_tex_transfer(struct pipe_screen *screen,
trans = CALLOC_STRUCT(i915_transfer);
if (trans) {
pipe_texture_reference(&trans->base.texture, texture);
- trans->base.format = trans->base.format;
trans->base.x = x;
trans->base.y = y;
trans->base.width = w;
trans->base.height = h;
- trans->base.block = texture->block;
- trans->base.nblocksx = texture->nblocksx[level];
- trans->base.nblocksy = texture->nblocksy[level];
trans->base.stride = tex->stride;
trans->offset = offset;
trans->base.usage = usage;
@@ -852,6 +830,7 @@ i915_transfer_map(struct pipe_screen *screen,
struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
char *map;
boolean write = FALSE;
+ enum pipe_format format = tex->base.format;
if (transfer->usage & PIPE_TRANSFER_WRITE)
write = TRUE;
@@ -861,8 +840,8 @@ i915_transfer_map(struct pipe_screen *screen,
return NULL;
return map + i915_transfer(transfer)->offset +
- transfer->y / transfer->block.height * transfer->stride +
- transfer->x / transfer->block.width * transfer->block.size;
+ transfer->y / pf_get_blockheight(format) * transfer->stride +
+ transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
}
static void