summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2009-12-04 00:35:14 +0100
committerRoland Scheidegger <sroland@vmware.com>2009-12-04 00:35:14 +0100
commit9c6a9363ef96c00dd0ad63e340b32479e43fea45 (patch)
treec1752752623301c7bc63d25173c396794b74922d /src/gallium
parentcc8a537c57a62a196106b592e510e4c93bd1826e (diff)
parent94b5c28a98850f42fbcdab9ceda1450279e1e6fd (diff)
Merge branch 'gallium-noblocks'
Conflicts: src/gallium/state_trackers/xorg/xorg_exa.c
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c1
-rw-r--r--src/gallium/auxiliary/util/u_blit.c1
-rw-r--r--src/gallium/auxiliary/util/u_debug.c8
-rw-r--r--src/gallium/auxiliary/util/u_format.h2
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c12
-rw-r--r--src/gallium/auxiliary/util/u_linear.c2
-rw-r--r--src/gallium/auxiliary/util/u_linear.h19
-rw-r--r--src/gallium/auxiliary/util/u_rect.c71
-rw-r--r--src/gallium/auxiliary/util/u_rect.h4
-rw-r--r--src/gallium/auxiliary/util/u_surface.c1
-rw-r--r--src/gallium/auxiliary/util/u_tile.c29
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c5
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c30
-rw-r--r--src/gallium/drivers/i915/i915_surface.c21
-rw-r--r--src/gallium/drivers/i915/i915_texture.c125
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tex_cache.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c48
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tile_cache.c6
-rw-r--r--src/gallium/drivers/nv04/nv04_miptree.c13
-rw-r--r--src/gallium/drivers/nv04/nv04_surface_2d.c12
-rw-r--r--src/gallium/drivers/nv04/nv04_transfer.c9
-rw-r--r--src/gallium/drivers/nv10/nv10_miptree.c11
-rw-r--r--src/gallium/drivers/nv10/nv10_transfer.c9
-rw-r--r--src/gallium/drivers/nv20/nv20_miptree.c10
-rw-r--r--src/gallium/drivers/nv20/nv20_transfer.c9
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c11
-rw-r--r--src/gallium/drivers/nv30/nv30_transfer.c9
-rw-r--r--src/gallium/drivers/nv40/nv40_miptree.c11
-rw-r--r--src/gallium/drivers/nv40/nv40_transfer.c9
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c10
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c48
-rw-r--r--src/gallium/drivers/r300/r300_emit.c12
-rw-r--r--src/gallium/drivers/r300/r300_screen.c9
-rw-r--r--src/gallium/drivers/r300/r300_texture.c12
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c33
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c10
-rw-r--r--src/gallium/drivers/svga/svga_screen_texture.c37
-rw-r--r--src/gallium/drivers/svga/svga_state_vs.c2
-rw-r--r--src/gallium/drivers/trace/tr_dump_state.c24
-rw-r--r--src/gallium/drivers/trace/tr_dump_state.h3
-rw-r--r--src/gallium/drivers/trace/tr_rbug.c13
-rw-r--r--src/gallium/drivers/trace/tr_screen.c3
-rw-r--r--src/gallium/include/pipe/p_format.h123
-rw-r--r--src/gallium/include/pipe/p_state.h8
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c1
-rw-r--r--src/gallium/state_trackers/egl/egl_surface.c1
-rw-r--r--src/gallium/state_trackers/python/gallium.i1
-rw-r--r--src/gallium/state_trackers/python/p_device.i1
-rw-r--r--src/gallium/state_trackers/python/p_format.i8
-rw-r--r--src/gallium/state_trackers/python/p_texture.i32
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py3
-rw-r--r--src/gallium/state_trackers/python/st_device.c3
-rw-r--r--src/gallium/state_trackers/python/st_sample.c35
-rw-r--r--src/gallium/state_trackers/python/st_sample.h1
-rw-r--r--src/gallium/state_trackers/python/st_softpipe_winsys.c19
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/surface_copy.py7
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/texture_transfer.py5
-rw-r--r--src/gallium/state_trackers/vega/api_filters.c1
-rw-r--r--src/gallium/state_trackers/vega/image.c1
-rw-r--r--src/gallium/state_trackers/vega/mask.c1
-rw-r--r--src/gallium/state_trackers/vega/paint.c1
-rw-r--r--src/gallium/state_trackers/vega/renderer.c1
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c3
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c6
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c1
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c3
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.c17
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.c19
-rw-r--r--src/gallium/winsys/g3dvl/xlib/xsp_winsys.c9
-rw-r--r--src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c17
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c23
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c20
-rw-r--r--src/gallium/winsys/xlib/xlib_llvmpipe.c15
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c15
79 files changed, 435 insertions, 688 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 8ccd527b3a..23d8b609e1 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -402,7 +402,6 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
- pf_get_block(texTemp.format, &texTemp.block);
aaline->texture = screen->texture_create(screen, &texTemp);
if (!aaline->texture)
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index a500edd7fe..bcb860da2e 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -431,7 +431,6 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.width0 = 32;
texTemp.height0 = 32;
texTemp.depth0 = 1;
- pf_get_block(texTemp.format, &texTemp.block);
pstip->texture = screen->texture_create(screen, &texTemp);
if (pstip->texture == NULL)
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 5372df5735..abe1de3302 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -357,7 +357,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- pf_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 96d400c839..40633574b0 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -669,10 +669,10 @@ void debug_dump_surface(const char *prefix,
goto error;
debug_dump_image(prefix,
- transfer->format,
- transfer->block.size,
- transfer->nblocksx,
- transfer->nblocksy,
+ texture->format,
+ pf_get_blocksize(texture->format),
+ pf_get_nblocksx(texture->format, transfer->width),
+ pf_get_nblocksy(texture->format, transfer->height),
transfer->stride,
data);
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 7b5b7fcda5..6740683a61 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -50,7 +50,7 @@ struct util_format_block
/** Block height in pixels */
unsigned height;
- /** Block size in bytes */
+ /** Block size in bits */
unsigned bits;
};
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index f67f1e458d..83263d9fe6 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -996,7 +996,7 @@ reduce_2d(enum pipe_format pformat,
{
enum dtype datatype;
uint comps;
- const int bpt = pf_get_size(pformat);
+ const int bpt = pf_get_blocksize(pformat);
const ubyte *srcA, *srcB;
ubyte *dst;
int row;
@@ -1035,7 +1035,7 @@ reduce_3d(enum pipe_format pformat,
int dstWidth, int dstHeight, int dstDepth,
int dstRowStride, ubyte *dstPtr)
{
- const int bpt = pf_get_size(pformat);
+ const int bpt = pf_get_blocksize(pformat);
const int border = 0;
int img, row;
int bytesPerSrcImage, bytesPerDstImage;
@@ -1159,8 +1159,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
const uint zslice = 0;
uint dstLevel;
- assert(pt->block.width == 1);
- assert(pt->block.height == 1);
+ assert(pf_get_blockwidth(pt->format) == 1);
+ assert(pf_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
@@ -1204,8 +1204,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
- assert(pt->block.width == 1);
- assert(pt->block.height == 1);
+ assert(pf_get_blockwidth(pt->format) == 1);
+ assert(pf_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c
index a1dce3f5cf..f1aef21677 100644
--- a/src/gallium/auxiliary/util/u_linear.c
+++ b/src/gallium/auxiliary/util/u_linear.c
@@ -82,7 +82,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
void
pipe_linear_fill_info(struct pipe_tile_info *t,
- const struct pipe_format_block *block,
+ const struct u_linear_format_block *block,
unsigned tile_width, unsigned tile_height,
unsigned tiles_x, unsigned tiles_y)
{
diff --git a/src/gallium/auxiliary/util/u_linear.h b/src/gallium/auxiliary/util/u_linear.h
index b74308ffa3..42c40b2aa7 100644
--- a/src/gallium/auxiliary/util/u_linear.h
+++ b/src/gallium/auxiliary/util/u_linear.h
@@ -35,6 +35,19 @@
#include "pipe/p_format.h"
+struct u_linear_format_block
+{
+ /** Block size in bytes */
+ unsigned size;
+
+ /** Block width in pixels */
+ unsigned width;
+
+ /** Block height in pixels */
+ unsigned height;
+};
+
+
struct pipe_tile_info
{
unsigned size;
@@ -49,10 +62,10 @@ struct pipe_tile_info
unsigned rows;
/* Describe the tile in pixels */
- struct pipe_format_block tile;
+ struct u_linear_format_block tile;
/* Describe each block within the tile */
- struct pipe_format_block block;
+ struct u_linear_format_block block;
};
void pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
@@ -71,7 +84,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
* @tiles_y number of tiles in y axis
*/
void pipe_linear_fill_info(struct pipe_tile_info *t,
- const struct pipe_format_block *block,
+ const struct u_linear_format_block *block,
unsigned tile_width, unsigned tile_height,
unsigned tiles_x, unsigned tiles_y);
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
index 9866b6fc8a..72725b59d2 100644
--- a/src/gallium/auxiliary/util/u_rect.c
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -44,7 +44,7 @@
*/
void
util_copy_rect(ubyte * dst,
- const struct pipe_format_block *block,
+ enum pipe_format format,
unsigned dst_stride,
unsigned dst_x,
unsigned dst_y,
@@ -57,27 +57,30 @@ util_copy_rect(ubyte * dst,
{
unsigned i;
int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
+ int blocksize = pf_get_blocksize(format);
+ int blockwidth = pf_get_blockwidth(format);
+ int blockheight = pf_get_blockheight(format);
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
assert(src_x >= 0);
assert(src_y >= 0);
assert(dst_x >= 0);
assert(dst_y >= 0);
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
- src_x /= block->width;
- src_y /= block->height;
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+ src_x /= blockwidth;
+ src_y /= blockheight;
- dst += dst_x * block->size;
- src += src_x * block->size;
+ dst += dst_x * blocksize;
+ src += src_x * blocksize;
dst += dst_y * dst_stride;
src += src_y * src_stride_pos;
- width *= block->size;
+ width *= blocksize;
if (width == dst_stride && width == src_stride)
memcpy(dst, src, height * width);
@@ -92,7 +95,7 @@ util_copy_rect(ubyte * dst,
void
util_fill_rect(ubyte * dst,
- const struct pipe_format_block *block,
+ enum pipe_format format,
unsigned dst_stride,
unsigned dst_x,
unsigned dst_y,
@@ -102,23 +105,26 @@ util_fill_rect(ubyte * dst,
{
unsigned i, j;
unsigned width_size;
+ int blocksize = pf_get_blocksize(format);
+ int blockwidth = pf_get_blockwidth(format);
+ int blockheight = pf_get_blockheight(format);
- assert(block->size > 0);
- assert(block->width > 0);
- assert(block->height > 0);
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
assert(dst_x >= 0);
assert(dst_y >= 0);
- dst_x /= block->width;
- dst_y /= block->height;
- width = (width + block->width - 1)/block->width;
- height = (height + block->height - 1)/block->height;
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
- dst += dst_x * block->size;
+ dst += dst_x * blocksize;
dst += dst_y * dst_stride;
- width_size = width * block->size;
+ width_size = width * blocksize;
- switch (block->size) {
+ switch (blocksize) {
case 1:
if(dst_stride == width_size)
memset(dst, (ubyte) value, height * width_size);
@@ -172,10 +178,15 @@ util_surface_copy(struct pipe_context *pipe,
struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
+ enum pipe_format src_format, dst_format;
assert(src->texture && dst->texture);
if (!src->texture || !dst->texture)
return;
+
+ src_format = src->texture->format;
+ dst_format = dst->texture->format;
+
src_trans = screen->get_tex_transfer(screen,
src->texture,
src->face,
@@ -192,9 +203,9 @@ util_surface_copy(struct pipe_context *pipe,
PIPE_TRANSFER_WRITE,
dst_x, dst_y, w, h);
- assert(dst_trans->block.size == src_trans->block.size);
- assert(dst_trans->block.width == src_trans->block.width);
- assert(dst_trans->block.height == src_trans->block.height);
+ assert(pf_get_blocksize(dst_format) == pf_get_blocksize(src_format));
+ assert(pf_get_blockwidth(dst_format) == pf_get_blockwidth(src_format));
+ assert(pf_get_blockheight(dst_format) == pf_get_blockheight(src_format));
src_map = pipe->screen->transfer_map(screen, src_trans);
dst_map = pipe->screen->transfer_map(screen, dst_trans);
@@ -205,7 +216,7 @@ util_surface_copy(struct pipe_context *pipe,
if (src_map && dst_map) {
/* If do_flip, invert src_y position and pass negative src stride */
util_copy_rect(dst_map,
- &dst_trans->block,
+ dst_format,
dst_trans->stride,
0, 0,
w, h,
@@ -259,11 +270,11 @@ util_surface_fill(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (dst_trans->block.size) {
+ switch (pf_get_blocksize(dst_trans->texture->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, &dst_trans->block, dst_trans->stride,
+ util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
0, 0, width, height, value);
break;
case 8:
diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h
index daa50834d3..5e444ffae2 100644
--- a/src/gallium/auxiliary/util/u_rect.h
+++ b/src/gallium/auxiliary/util/u_rect.h
@@ -42,13 +42,13 @@ struct pipe_surface;
extern void
-util_copy_rect(ubyte * dst, const struct pipe_format_block *block,
+util_copy_rect(ubyte * dst, enum pipe_format format,
unsigned dst_stride, unsigned dst_x, unsigned dst_y,
unsigned width, unsigned height, const ubyte * src,
int src_stride, unsigned src_x, int src_y);
extern void
-util_fill_rect(ubyte * dst, const struct pipe_format_block *block,
+util_fill_rect(ubyte * dst, enum pipe_format format,
unsigned dst_stride, unsigned dst_x, unsigned dst_y,
unsigned width, unsigned height, uint32_t value);
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index de8c266db8..f828908f0b 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -82,7 +82,6 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- pf_get_block(format, &templ.block);
templ.tex_usage = usage;
*textureOut = screen->texture_create(screen, &templ);
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 8a22f584be..4f34f8a1a6 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -52,7 +52,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
const void *src;
if (dst_stride == 0)
- dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+ dst_stride = pf_get_stride(pt->texture->format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -62,7 +62,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
if(!src)
return;
- util_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
+ util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
screen->transfer_unmap(screen, pt);
}
@@ -78,9 +78,10 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
{
struct pipe_screen *screen = pt->texture->screen;
void *dst;
+ enum pipe_format format = pt->texture->format;
if (src_stride == 0)
- src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size;
+ src_stride = pf_get_stride(format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -90,7 +91,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
if(!dst)
return;
- util_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0);
+ util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0);
screen->transfer_unmap(screen, pt);
}
@@ -1219,21 +1220,22 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
{
unsigned dst_stride = w * 4;
void *packed;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+ packed = MALLOC(pf_get_nblocks(format, w, h) * pf_get_blocksize(format));
if (!packed)
return;
- if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV)
+ if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV)
assert((x & 1) == 0);
pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
- pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride);
+ pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
FREE(packed);
}
@@ -1246,16 +1248,17 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
{
unsigned src_stride = w * 4;
void *packed;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size);
+ packed = MALLOC(pf_get_nblocks(format, w, h) * pf_get_blocksize(format));
if (!packed)
return;
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
@@ -1322,7 +1325,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
break;
default:
- debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(pt->format));
+ debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
}
pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
@@ -1344,6 +1347,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
ubyte *map;
uint *pDest = z;
uint i, j;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -1354,7 +1358,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
return;
}
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
const uint *ptrc
@@ -1428,6 +1432,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
+ enum pipe_format format = pt->texture->format;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
@@ -1438,7 +1443,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
return;
}
- switch (pt->format) {
+ switch (format) {
case PIPE_FORMAT_Z32_UNORM:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 85fe2efd2b..4952e9c9f8 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -834,7 +834,6 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
template.height0 = r->pot_buffers ?
util_next_power_of_two(r->picture_height) : r->picture_height;
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
@@ -1444,7 +1443,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
assert(r);
assert(blocks);
- tex_pitch = r->tex_transfer[0]->stride / r->tex_transfer[0]->block.size;
+ tex_pitch = r->tex_transfer[0]->stride / pf_get_blocksize(r->tex_transfer[0]->texture->format);
texels = r->texels[0] + mbpy * tex_pitch + mbpx;
for (y = 0; y < 2; ++y) {
@@ -1483,7 +1482,7 @@ grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
mbpy /= 2;
for (tb = 0; tb < 2; ++tb) {
- tex_pitch = r->tex_transfer[tb + 1]->stride / r->tex_transfer[tb + 1]->block.size;
+ tex_pitch = r->tex_transfer[tb + 1]->stride / pf_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
if ((cbp >> (1 - tb)) & 1) {
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index e6b8a87045..77a57aef14 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -65,14 +65,11 @@ cell_texture_layout(struct cell_texture *ct)
w_tile = align(width, TILE_SIZE);
h_tile = align(height, TILE_SIZE);
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w_tile);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h_tile);
-
- ct->stride[level] = pt->nblocksx[level] * pt->block.size;
+ ct->stride[level] = pf_get_stride(pt->format, w_tile);
ct->level_offset[level] = ct->buffer_size;
- size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+ size = ct->stride[level] * pf_get_nblocksy(pt->format, h_tile);
if (pt->target == PIPE_TEXTURE_CUBE)
size *= 6;
else
@@ -283,10 +280,12 @@ cell_get_tex_surface(struct pipe_screen *screen,
ps->zslice = zslice;
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset += face * pt->nblocksy[level] * ct->stride[level];
+ unsigned h_tile = align(ps->height, TILE_SIZE);
+ ps->offset += face * pf_get_nblocksy(ps->format, h_tile) * ct->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset += zslice * pt->nblocksy[level] * ct->stride[level];
+ unsigned h_tile = align(ps->height, TILE_SIZE);
+ ps->offset += zslice * pf_get_nblocksy(ps->format, h_tile) * ct->stride[level];
}
else {
assert(face == 0);
@@ -327,14 +326,10 @@ cell_get_tex_transfer(struct pipe_screen *screen,
if (ctrans) {
struct pipe_transfer *pt = &ctrans->base;
pipe_texture_reference(&pt->texture, texture);
- pt->format = texture->format;
- pt->block = texture->block;
pt->x = x;
pt->y = y;
pt->width = w;
pt->height = h;
- pt->nblocksx = texture->nblocksx[level];
- pt->nblocksy = texture->nblocksy[level];
pt->stride = ct->stride[level];
pt->usage = usage;
pt->face = face;
@@ -344,10 +339,12 @@ cell_get_tex_transfer(struct pipe_screen *screen,
ctrans->offset = ct->level_offset[level];
if (texture->target == PIPE_TEXTURE_CUBE) {
- ctrans->offset += face * pt->nblocksy * pt->stride;
+ unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
+ ctrans->offset += face * pf_get_nblocksy(texture->format, h_tile) * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
- ctrans->offset += zslice * pt->nblocksy * pt->stride;
+ unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
+ ctrans->offset += zslice * pf_get_nblocksy(texture->format, h_tile) * pt->stride;
}
else {
assert(face == 0);
@@ -400,7 +397,8 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
* Create a buffer of ordinary memory for the linear texture.
* This is the memory that the user will read/write.
*/
- size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+ size = pf_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
+ pf_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));
ctrans->map = align_malloc(size, 16);
if (!ctrans->map)
@@ -408,7 +406,7 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
if (transfer->usage & PIPE_TRANSFER_READ) {
/* need to untwiddle the texture to make a linear version */
- const uint bpp = pf_get_size(ct->base.format);
+ const uint bpp = pf_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = (uint *) (ct->mapped + ctrans->offset);
uint *dst = ctrans->map;
@@ -451,7 +449,7 @@ cell_transfer_unmap(struct pipe_screen *screen,
/* The user wrote new texture data into the mapped buffer.
* We need to convert the new linear data into the twiddled/tiled format.
*/
- const uint bpp = pf_get_size(ct->base.format);
+ const uint bpp = pf_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = ctrans->map;
uint *dst = (uint *) (ct->mapped + ctrans->offset);
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
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index ffcbc9a379..b4aabd4d7c 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -166,7 +166,7 @@ shade_quads(struct llvmpipe_context *llvmpipe,
assert((y % 2) == 0);
depth = llvmpipe->zsbuf_map +
y*llvmpipe->zsbuf_transfer->stride +
- 2*x*llvmpipe->zsbuf_transfer->block.size;
+ 2*x*pf_get_blocksize(llvmpipe->zsbuf_transfer->texture->format);
}
else
depth = NULL;
diff --git a/src/gallium/drivers/llvmpipe/lp_tex_cache.c b/src/gallium/drivers/llvmpipe/lp_tex_cache.c
index c7c4143bc6..5dbc597d2c 100644
--- a/src/gallium/drivers/llvmpipe/lp_tex_cache.c
+++ b/src/gallium/drivers/llvmpipe/lp_tex_cache.c
@@ -291,7 +291,7 @@ lp_find_cached_tex_tile(struct llvmpipe_tex_tile_cache *tc,
assert(0);
}
- util_format_read_4ub(tc->tex_trans->format,
+ util_format_read_4ub(tc->tex_trans->texture->format,
(uint8_t *)tile->color, sizeof tile->color[0],
tc->tex_trans_map, tc->tex_trans->stride,
x, y, w, h);
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 65d62fd072..f099f903bd 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -48,7 +48,6 @@
/* Simple, maximally packed layout.
*/
-
/* Conventional allocation path for non-display textures:
*/
static boolean
@@ -63,20 +62,15 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
unsigned buffer_size = 0;
- pf_get_block(lpt->base.format, &lpt->base.block);
-
for (level = 0; level <= pt->last_level; level++) {
unsigned nblocksx, nblocksy;
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
-
/* Allocate storage for whole quads. This is particularly important
* for depth surfaces, which are currently stored in a swizzled format. */
- nblocksx = pf_get_nblocksx(&pt->block, align(width, 2));
- nblocksy = pf_get_nblocksy(&pt->block, align(height, 2));
+ nblocksx = pf_get_nblocksx(pt->format, align(width, 2));
+ nblocksy = pf_get_nblocksy(pt->format, align(height, 2));
- lpt->stride[level] = align(nblocksx*pt->block.size, 16);
+ lpt->stride[level] = align(nblocksx * pf_get_blocksize(pt->format), 16);
lpt->level_offset[level] = buffer_size;
@@ -100,10 +94,6 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
{
struct llvmpipe_winsys *winsys = screen->winsys;
- pf_get_block(lpt->base.format, &lpt->base.block);
- lpt->base.nblocksx[0] = pf_get_nblocksx(&lpt->base.block, lpt->base.width0);
- lpt->base.nblocksy[0] = pf_get_nblocksy(&lpt->base.block, lpt->base.height0);
-
lpt->dt = winsys->displaytarget_create(winsys,
lpt->base.format,
lpt->base.width0,
@@ -180,8 +170,6 @@ llvmpipe_texture_blanket(struct pipe_screen * screen,
lpt->base = *base;
pipe_reference_init(&lpt->base.reference, 1);
lpt->base.screen = screen;
- lpt->base.nblocksx[0] = pf_get_nblocksx(&lpt->base.block, lpt->base.width0);
- lpt->base.nblocksy[0] = pf_get_nblocksy(&lpt->base.block, lpt->base.height0);
lpt->stride[0] = stride[0];
pipe_buffer_reference(&lpt->buffer, buffer);
@@ -255,11 +243,17 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
ps->level = level;
ps->zslice = zslice;
+ /* XXX shouldn't that rather be
+ tex_height = align(ps->height, 2);
+ to account for alignment done in llvmpipe_texture_layout ?
+ */
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset += face * pt->nblocksy[level] * lpt->stride[level];
+ unsigned tex_height = ps->height;
+ ps->offset += face * pf_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset += zslice * pt->nblocksy[level] * lpt->stride[level];
+ unsigned tex_height = ps->height;
+ ps->offset += zslice * pf_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
}
else {
assert(face == 0);
@@ -300,14 +294,10 @@ llvmpipe_get_tex_transfer(struct pipe_screen *screen,
if (lpt) {
struct pipe_transfer *pt = &lpt->base;
pipe_texture_reference(&pt->texture, texture);
- pt->format = texture->format;
- pt->block = texture->block;
pt->x = x;
pt->y = y;
pt->width = w;
pt->height = h;
- pt->nblocksx = texture->nblocksx[level];
- pt->nblocksy = texture->nblocksy[level];
pt->stride = lptex->stride[level];
pt->usage = usage;
pt->face = face;
@@ -316,11 +306,17 @@ llvmpipe_get_tex_transfer(struct pipe_screen *screen,
lpt->offset = lptex->level_offset[level];
+ /* XXX shouldn't that rather be
+ tex_height = align(u_minify(texture->height0, level), 2)
+ to account for alignment done in llvmpipe_texture_layout ?
+ */
if (texture->target == PIPE_TEXTURE_CUBE) {
- lpt->offset += face * pt->nblocksy * pt->stride;
+ unsigned tex_height = u_minify(texture->height0, level);
+ lpt->offset += face * pf_get_nblocksy(texture->format, tex_height) * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
- lpt->offset += zslice * pt->nblocksy * pt->stride;
+ unsigned tex_height = u_minify(texture->height0, level);
+ lpt->offset += zslice * pf_get_nblocksy(texture->format, tex_height) * pt->stride;
}
else {
assert(face == 0);
@@ -352,9 +348,11 @@ llvmpipe_transfer_map( struct pipe_screen *_screen,
struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
ubyte *map, *xfer_map;
struct llvmpipe_texture *lpt;
+ enum pipe_format format;
assert(transfer->texture);
lpt = llvmpipe_texture(transfer->texture);
+ format = lpt->base.format;
if(lpt->dt) {
struct llvmpipe_winsys *winsys = screen->winsys;
@@ -379,8 +377,8 @@ llvmpipe_transfer_map( struct pipe_screen *_screen,
}
xfer_map = map + llvmpipe_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);
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
return xfer_map;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_cache.c b/src/gallium/drivers/llvmpipe/lp_tile_cache.c
index ec3e002d62..50891c4227 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_cache.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_cache.c
@@ -252,13 +252,13 @@ lp_flush_tile_cache(struct llvmpipe_tile_cache *tc)
case LP_TILE_STATUS_CLEAR:
/* Actually clear the tiles which were flagged as being in a
* clear state. */
- util_fill_rect(tc->transfer_map, &pt->block, pt->stride,
+ util_fill_rect(tc->transfer_map, pt->texture->format, pt->stride,
x, y, w, h,
tc->clear_val);
break;
case LP_TILE_STATUS_DEFINED:
- lp_tile_write_4ub(pt->format,
+ lp_tile_write_4ub(pt->texture->format,
tile->color,
tc->transfer_map, pt->stride,
x, y, w, h);
@@ -306,7 +306,7 @@ lp_get_cached_tile(struct llvmpipe_tile_cache *tc,
y &= ~(TILE_SIZE - 1);
if (!pipe_clip_tile(x, y, &w, &h, tc->transfer))
- lp_tile_read_4ub(pt->format,
+ lp_tile_read_4ub(pt->texture->format,
tile->color,
tc->transfer_map, tc->transfer->stride,
x, y, w, h);
diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c
index 4fd72c82e6..eeab6dfa30 100644
--- a/src/gallium/drivers/nv04/nv04_miptree.c
+++ b/src/gallium/drivers/nv04/nv04_miptree.c
@@ -10,28 +10,21 @@ static void
nv04_miptree_layout(struct nv04_miptree *nv04mt)
{
struct pipe_texture *pt = &nv04mt->base;
- uint width = pt->width0, height = pt->height0;
uint offset = 0;
int nr_faces, l;
nr_faces = 1;
for (l = 0; l <= pt->last_level; l++) {
-
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
nv04mt->level[l].pitch = pt->width0;
nv04mt->level[l].pitch = (nv04mt->level[l].pitch + 63) & ~63;
-
- width = u_minify(width, 1);
- height = u_minify(height, 1);
}
for (l = 0; l <= pt->last_level; l++) {
-
nv04mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
+ /* XXX guess was obviously missing */
+ nv04mt->level[l].image_offset[0] = offset;
offset += nv04mt->level[l].pitch * u_minify(pt->height0, l);
}
@@ -128,7 +121,7 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns->base.zslice = zslice;
ns->pitch = nv04mt->level[level].pitch;
- ns->base.offset = nv04mt->level[level].image_offset;
+ ns->base.offset = nv04mt->level[level].image_offset[0];
return &ns->base;
}
diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c
index 8be134b83d..932893eef5 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.c
+++ b/src/gallium/drivers/nv04/nv04_surface_2d.c
@@ -155,10 +155,10 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
sub_w = MIN2(sub_w, w - x);
/* Must be 64-byte aligned */
- assert(!((dst->offset + nv04_swizzle_bits(dx+x, dy+y) * dst->texture->block.size) & 63));
+ assert(!((dst->offset + nv04_swizzle_bits(dx+x, dy+y) * pf_get_blocksize(dst->texture->format)) & 63));
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
- OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(dx+x, dy+y) * dst->texture->block.size,
+ OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(dx+x, dy+y) * pf_get_blocksize(dst->texture->format),
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
@@ -177,7 +177,7 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
OUT_RING (chan, src_pitch |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
- OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * src->texture->block.size,
+ OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * pf_get_blocksize(src->texture->format),
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
}
@@ -198,9 +198,9 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
unsigned dst_offset = dst->offset + dy * dst_pitch +
- dx * dst->texture->block.size;
+ dx * pf_get_blocksize(dst->texture->format);
unsigned src_offset = src->offset + sy * src_pitch +
- sx * src->texture->block.size;
+ sx * pf_get_blocksize(src->texture->format);
WAIT_RING (chan, 3 + ((h / 2047) + 1) * 9);
BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
@@ -219,7 +219,7 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
OUT_RING (chan, src_pitch);
OUT_RING (chan, dst_pitch);
- OUT_RING (chan, w * src->texture->block.size);
+ OUT_RING (chan, w * pf_get_blocksize(src->texture->format));
OUT_RING (chan, count);
OUT_RING (chan, 0x0101);
OUT_RING (chan, 0);
diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c
index e6456429f4..e8ff686b4a 100644
--- a/src/gallium/drivers/nv04/nv04_transfer.c
+++ b/src/gallium/drivers/nv04/nv04_transfer.c
@@ -24,9 +24,6 @@ nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->width0 = u_minify(pt->width0, level);
template->height0 = u_minify(pt->height0, level);
template->depth0 = 1;
- template->block = pt->block;
- template->nblocksx[0] = pt->nblocksx[level];
- template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->nr_samples = pt->nr_samples;
@@ -49,14 +46,10 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
tx->base.x = x;
tx->base.y = y;
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
tx->base.stride = mt->level[level].pitch;
tx->base.usage = usage;
tx->base.face = face;
@@ -158,7 +151,7 @@ nv04_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * ptx->block.size;
+ ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
}
static void
diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c
index b2a6c59b74..439beeccc3 100644
--- a/src/gallium/drivers/nv10/nv10_miptree.c
+++ b/src/gallium/drivers/nv10/nv10_miptree.c
@@ -11,7 +11,7 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
{
struct pipe_texture *pt = &nv10mt->base;
boolean swizzled = FALSE;
- uint width = pt->width0, height = pt->height0;
+ uint width = pt->width0;
uint offset = 0;
int nr_faces, l, f;
@@ -22,21 +22,16 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
}
for (l = 0; l <= pt->last_level; l++) {
-
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
if (swizzled)
- nv10mt->level[l].pitch = pt->nblocksx[l] * pt->block.size;
+ nv10mt->level[l].pitch = pf_get_stride(pt->format, width);
else
- nv10mt->level[l].pitch = pt->nblocksx[0] * pt->block.size;
+ nv10mt->level[l].pitch = pf_get_stride(pt->format, pt->width0);
nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
nv10mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
width = u_minify(width, 1);
- height = u_minify(height, 1);
}
diff --git a/src/gallium/drivers/nv10/nv10_transfer.c b/src/gallium/drivers/nv10/nv10_transfer.c
index ec54297ab0..9e44d37367 100644
--- a/src/gallium/drivers/nv10/nv10_transfer.c
+++ b/src/gallium/drivers/nv10/nv10_transfer.c
@@ -24,9 +24,6 @@ nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->width0 = u_minify(pt->width0, level);
template->height0 = u_minify(pt->height0, level);
template->depth0 = 1;
- template->block = pt->block;
- template->nblocksx[0] = pt->nblocksx[level];
- template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->nr_samples = pt->nr_samples;
@@ -49,14 +46,10 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
tx->base.x = x;
tx->base.y = y;
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
tx->base.stride = mt->level[level].pitch;
tx->base.usage = usage;
tx->base.face = face;
@@ -158,7 +151,7 @@ nv10_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * ptx->block.size;
+ ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
}
static void
diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c
index 554e28e47d..2bde9fb75b 100644
--- a/src/gallium/drivers/nv20/nv20_miptree.c
+++ b/src/gallium/drivers/nv20/nv20_miptree.c
@@ -10,7 +10,7 @@ static void
nv20_miptree_layout(struct nv20_miptree *nv20mt)
{
struct pipe_texture *pt = &nv20mt->base;
- uint width = pt->width0, height = pt->height0;
+ uint width = pt->width0;
uint offset = 0;
int nr_faces, l, f;
uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -26,19 +26,15 @@ nv20_miptree_layout(struct nv20_miptree *nv20mt)
}
for (l = 0; l <= pt->last_level; l++) {
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- nv20mt->level[l].pitch = align(pt->width0 * pt->block.size, 64);
+ nv20mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
else
- nv20mt->level[l].pitch = u_minify(pt->width0, l) * pt->block.size;
+ nv20mt->level[l].pitch = pf_get_stride(pt->format, width);
nv20mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
width = u_minify(width, 1);
- height = u_minify(height, 1);
}
for (f = 0; f < nr_faces; f++) {
diff --git a/src/gallium/drivers/nv20/nv20_transfer.c b/src/gallium/drivers/nv20/nv20_transfer.c
index 87b5c14a3c..f2e0a34db9 100644
--- a/src/gallium/drivers/nv20/nv20_transfer.c
+++ b/src/gallium/drivers/nv20/nv20_transfer.c
@@ -24,9 +24,6 @@ nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->width0 = u_minify(pt->width0, level);
template->height0 = u_minify(pt->height0, level);
template->depth0 = 1;
- template->block = pt->block;
- template->nblocksx[0] = pt->nblocksx[level];
- template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->nr_samples = pt->nr_samples;
@@ -49,14 +46,10 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
tx->base.x = x;
tx->base.y = y;
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
tx->base.stride = mt->level[level].pitch;
tx->base.usage = usage;
tx->base.face = face;
@@ -158,7 +151,7 @@ nv20_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * ptx->block.size;
+ ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
}
static void
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index b4c306d127..9e50a7cf6b 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -9,7 +9,7 @@ static void
nv30_miptree_layout(struct nv30_miptree *nv30mt)
{
struct pipe_texture *pt = &nv30mt->base;
- uint width = pt->width0, height = pt->height0, depth = pt->depth0;
+ uint width = pt->width0;
uint offset = 0;
int nr_faces, l, f;
uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -28,20 +28,15 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
}
for (l = 0; l <= pt->last_level; l++) {
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- nv30mt->level[l].pitch = align(pt->width0 * pt->block.size, 64);
+ nv30mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
else
- nv30mt->level[l].pitch = u_minify(pt->width0, l) * pt->block.size;
+ nv30mt->level[l].pitch = pf_get_stride(pt->format, width);
nv30mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
width = u_minify(width, 1);
- height = u_minify(height, 1);
- depth = u_minify(depth, 1);
}
for (f = 0; f < nr_faces; f++) {
diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
index 5e429b4d85..c8c3bd1f17 100644
--- a/src/gallium/drivers/nv30/nv30_transfer.c
+++ b/src/gallium/drivers/nv30/nv30_transfer.c
@@ -24,9 +24,6 @@ nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->width0 = u_minify(pt->width0, level);
template->height0 = u_minify(pt->height0, level);
template->depth0 = 1;
- template->block = pt->block;
- template->nblocksx[0] = pt->nblocksx[level];
- template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->nr_samples = pt->nr_samples;
@@ -49,14 +46,10 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
tx->base.x = x;
tx->base.y = y;
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
tx->base.stride = mt->level[level].pitch;
tx->base.usage = usage;
tx->base.face = face;
@@ -158,7 +151,7 @@ nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * ptx->block.size;
+ ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
}
static void
diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index f73bedff6d..8779c5572b 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -9,7 +9,7 @@ static void
nv40_miptree_layout(struct nv40_miptree *mt)
{
struct pipe_texture *pt = &mt->base;
- uint width = pt->width0, height = pt->height0, depth = pt->depth0;
+ uint width = pt->width0;
uint offset = 0;
int nr_faces, l, f;
uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
@@ -28,20 +28,15 @@ nv40_miptree_layout(struct nv40_miptree *mt)
}
for (l = 0; l <= pt->last_level; l++) {
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
-
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- mt->level[l].pitch = align(pt->width0 * pt->block.size, 64);
+ mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
else
- mt->level[l].pitch = u_minify(pt->width0, l) * pt->block.size;
+ mt->level[l].pitch = pf_get_stride(pt->format, width);
mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
width = u_minify(width, 1);
- height = u_minify(height, 1);
- depth = u_minify(depth, 1);
}
for (f = 0; f < nr_faces; f++) {
diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
index 36e253c96f..1ee5cf39e0 100644
--- a/src/gallium/drivers/nv40/nv40_transfer.c
+++ b/src/gallium/drivers/nv40/nv40_transfer.c
@@ -24,9 +24,6 @@ nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->width0 = u_minify(pt->width0, level);
template->height0 = u_minify(pt->height0, level);
template->depth0 = 1;
- template->block = pt->block;
- template->nblocksx[0] = pt->nblocksx[level];
- template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->nr_samples = pt->nr_samples;
@@ -49,14 +46,10 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
tx->base.x = x;
tx->base.y = y;
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
tx->base.stride = mt->level[level].pitch;
tx->base.usage = usage;
tx->base.face = face;
@@ -158,7 +151,7 @@ nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * ptx->block.size;
+ ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
}
static void
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index 3d58746793..40ee665999 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -91,13 +91,11 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
for (l = 0; l <= pt->last_level; l++) {
struct nv50_miptree_level *lvl = &mt->level[l];
-
- pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
+ unsigned nblocksy = pf_get_nblocksy(pt->format, height);
lvl->image_offset = CALLOC(mt->image_nr, sizeof(int));
- lvl->pitch = align(pt->nblocksx[l] * pt->block.size, 64);
- lvl->tile_mode = get_tile_mode(pt->nblocksy[l], depth);
+ lvl->pitch = align(pf_get_stride(pt->format, width), 64);
+ lvl->tile_mode = get_tile_mode(nblocksy, depth);
width = u_minify(width, 1);
height = u_minify(height, 1);
@@ -118,7 +116,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
unsigned tile_d = get_tile_depth(lvl->tile_mode);
size = lvl->pitch;
- size *= align(pt->nblocksy[l], tile_h);
+ size *= align(pf_get_nblocksy(pt->format, u_minify(pt->height0, l)), tile_h);
size *= align(u_minify(pt->depth0, l), tile_d);
lvl->image_offset[i] = mt->total_size;
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index 39d65279fc..4705f96f57 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -16,6 +16,8 @@ struct nv50_transfer {
int level_depth;
int level_x;
int level_y;
+ unsigned nblocksx;
+ unsigned nblocksy;
};
static void
@@ -151,20 +153,11 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- tx->base.format = pt->format;
+ tx->nblocksx = pf_get_nblocksx(pt->format, u_minify(pt->width0, level));
+ tx->nblocksy = pf_get_nblocksy(pt->format, u_minify(pt->height0, level));
tx->base.width = w;
tx->base.height = h;
- tx->base.block = pt->block;
- if (!pt->nblocksx[level]) {
- tx->base.nblocksx = pf_get_nblocksx(&pt->block,
- u_minify(pt->width0, level));
- tx->base.nblocksy = pf_get_nblocksy(&pt->block,
- u_minify(pt->height0, level));
- } else {
- tx->base.nblocksx = pt->nblocksx[level];
- tx->base.nblocksy = pt->nblocksy[level];
- }
- tx->base.stride = tx->base.nblocksx * pt->block.size;
+ tx->base.stride = tx->nblocksx * pf_get_blocksize(pt->format);
tx->base.usage = usage;
tx->level_pitch = lvl->pitch;
@@ -173,10 +166,10 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
tx->level_depth = u_minify(mt->base.base.depth0, level);
tx->level_offset = lvl->image_offset[image];
tx->level_tiling = lvl->tile_mode;
- tx->level_x = pf_get_nblocksx(&tx->base.block, x);
- tx->level_y = pf_get_nblocksy(&tx->base.block, y);
+ tx->level_x = pf_get_nblocksx(pt->format, x);
+ tx->level_y = pf_get_nblocksy(pt->format, y);
ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
- tx->base.nblocksy * tx->base.stride, &tx->bo);
+ tx->nblocksy * tx->base.stride, &tx->bo);
if (ret) {
FREE(tx);
return NULL;
@@ -185,22 +178,22 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (pt->target == PIPE_TEXTURE_3D)
tx->level_offset += get_zslice_offset(lvl->tile_mode, zslice,
lvl->pitch,
- tx->base.nblocksy);
+ tx->nblocksy);
if (usage & PIPE_TRANSFER_READ) {
- nx = pf_get_nblocksx(&tx->base.block, tx->base.width);
- ny = pf_get_nblocksy(&tx->base.block, tx->base.height);
+ nx = pf_get_nblocksx(pt->format, tx->base.width);
+ ny = pf_get_nblocksy(pt->format, tx->base.height);
nv50_transfer_rect_m2mf(pscreen, mt->base.bo, tx->level_offset,
tx->level_pitch, tx->level_tiling,
x, y,
- tx->base.nblocksx, tx->base.nblocksy,
+ tx->nblocksx, tx->nblocksy,
tx->level_depth,
tx->bo, 0,
tx->base.stride, tx->bo->tile_mode,
0, 0,
- tx->base.nblocksx, tx->base.nblocksy, 1,
- tx->base.block.size, nx, ny,
+ tx->nblocksx, tx->nblocksy, 1,
+ pf_get_blocksize(pt->format), nx, ny,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
NOUVEAU_BO_GART);
}
@@ -213,23 +206,24 @@ nv50_transfer_del(struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
struct nv50_miptree *mt = nv50_miptree(ptx->texture);
+ struct pipe_texture *pt = ptx->texture;
- unsigned nx = pf_get_nblocksx(&tx->base.block, tx->base.width);
- unsigned ny = pf_get_nblocksy(&tx->base.block, tx->base.height);
+ unsigned nx = pf_get_nblocksx(pt->format, tx->base.width);
+ unsigned ny = pf_get_nblocksy(pt->format, tx->base.height);
if (ptx->usage & PIPE_TRANSFER_WRITE) {
- struct pipe_screen *pscreen = ptx->texture->screen;
+ struct pipe_screen *pscreen = pt->screen;
nv50_transfer_rect_m2mf(pscreen, tx->bo, 0,
tx->base.stride, tx->bo->tile_mode,
0, 0,
- tx->base.nblocksx, tx->base.nblocksy, 1,
+ tx->nblocksx, tx->nblocksy, 1,
mt->base.bo, tx->level_offset,
tx->level_pitch, tx->level_tiling,
tx->level_x, tx->level_y,
- tx->base.nblocksx, tx->base.nblocksy,
+ tx->nblocksx, tx->nblocksy,
tx->level_depth,
- tx->base.block.size, nx, ny,
+ pf_get_blocksize(pt->format), nx, ny,
NOUVEAU_BO_GART, NOUVEAU_BO_VRAM |
NOUVEAU_BO_GART);
}
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 98a39390bf..a479842f9e 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -631,10 +631,10 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset)
for (i = 0; i < aos_count - 1; i += 2) {
int buf_num1 = velem[i].vertex_buffer_index;
int buf_num2 = velem[i+1].vertex_buffer_index;
- assert(vbuf[buf_num1].stride % 4 == 0 && pf_get_size(velem[i].src_format) % 4 == 0);
- assert(vbuf[buf_num2].stride % 4 == 0 && pf_get_size(velem[i+1].src_format) % 4 == 0);
- OUT_CS((pf_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num1].stride << 6) |
- (pf_get_size(velem[i+1].src_format) << 14) | (vbuf[buf_num2].stride << 22));
+ assert(vbuf[buf_num1].stride % 4 == 0 && pf_get_blocksize(velem[i].src_format) % 4 == 0);
+ assert(vbuf[buf_num2].stride % 4 == 0 && pf_get_blocksize(velem[i+1].src_format) % 4 == 0);
+ OUT_CS((pf_get_blocksize(velem[i].src_format) >> 2) | (vbuf[buf_num1].stride << 6) |
+ (pf_get_blocksize(velem[i+1].src_format) << 14) | (vbuf[buf_num2].stride << 22));
OUT_CS(vbuf[buf_num1].buffer_offset + velem[i].src_offset +
offset * vbuf[buf_num1].stride);
OUT_CS(vbuf[buf_num2].buffer_offset + velem[i+1].src_offset +
@@ -642,8 +642,8 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset)
}
if (aos_count & 1) {
int buf_num = velem[i].vertex_buffer_index;
- assert(vbuf[buf_num].stride % 4 == 0 && pf_get_size(velem[i].src_format) % 4 == 0);
- OUT_CS((pf_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num].stride << 6));
+ assert(vbuf[buf_num].stride % 4 == 0 && pf_get_blocksize(velem[i].src_format) % 4 == 0);
+ OUT_CS((pf_get_blocksize(velem[i].src_format) >> 2) | (vbuf[buf_num].stride << 6));
OUT_CS(vbuf[buf_num].buffer_offset + velem[i].src_offset +
offset * vbuf[buf_num].stride);
}
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 2e7b1423e6..c0d9797020 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -312,14 +312,10 @@ r300_get_tex_transfer(struct pipe_screen *screen,
trans = CALLOC_STRUCT(r300_transfer);
if (trans) {
pipe_texture_reference(&trans->transfer.texture, texture);
- trans->transfer.format = texture->format;
trans->transfer.x = x;
trans->transfer.y = y;
trans->transfer.width = w;
trans->transfer.height = h;
- trans->transfer.block = texture->block;
- trans->transfer.nblocksx = texture->nblocksx[level];
- trans->transfer.nblocksy = texture->nblocksy[level];
trans->transfer.stride = r300_texture_get_stride(tex, level);
trans->transfer.usage = usage;
@@ -345,6 +341,7 @@ static void* r300_transfer_map(struct pipe_screen* screen,
{
struct r300_texture* tex = (struct r300_texture*)transfer->texture;
char* map;
+ enum pipe_format format = tex->tex.format;
map = pipe_buffer_map(screen, tex->buffer,
pipe_transfer_buffer_flags(transfer));
@@ -354,8 +351,8 @@ static void* r300_transfer_map(struct pipe_screen* screen,
}
return map + r300_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 r300_transfer_unmap(struct pipe_screen* screen,
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 093a21ebe2..63fc6a235a 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -105,7 +105,7 @@ unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level)
return 0;
}
- return align(pf_get_stride(&tex->tex.block, u_minify(tex->tex.width0, level)), 32);
+ return align(pf_get_stride(tex->tex.format, u_minify(tex->tex.width0, level)), 32);
}
static void r300_setup_miptree(struct r300_texture* tex)
@@ -115,11 +115,10 @@ static void r300_setup_miptree(struct r300_texture* tex)
int i;
for (i = 0; i <= base->last_level; i++) {
- base->nblocksx[i] = pf_get_nblocksx(&base->block, u_minify(base->width0, i));
- base->nblocksy[i] = pf_get_nblocksy(&base->block, u_minify(base->height0, i));
+ unsigned nblocksy = pf_get_nblocksy(base->format, u_minify(base->height0, i));
stride = r300_texture_get_stride(tex, i);
- layer_size = stride * base->nblocksy[i];
+ layer_size = stride * nblocksy;
if (base->target == PIPE_TEXTURE_CUBE)
size = layer_size * 6;
@@ -129,7 +128,7 @@ static void r300_setup_miptree(struct r300_texture* tex)
tex->offset[i] = align(tex->size, 32);
tex->size = tex->offset[i] + size;
tex->layer_size[i] = layer_size;
- tex->pitch[i] = stride / base->block.size;
+ tex->pitch[i] = stride / pf_get_blocksize(base->format);
debug_printf("r300: Texture miptree: Level %d "
"(%dx%dx%d px, pitch %d bytes)\n",
@@ -245,7 +244,7 @@ static struct pipe_texture*
tex->tex.screen = screen;
tex->stride_override = *stride;
- tex->pitch[0] = *stride / base->block.size;
+ tex->pitch[0] = *stride / pf_get_blocksize(base->format);
r300_setup_flags(tex);
r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500);
@@ -283,7 +282,6 @@ r300_video_surface_create(struct pipe_screen *screen,
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER |
PIPE_TEXTURE_USAGE_RENDER_TARGET;
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index ac5f61e46f..bd653216c0 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -63,13 +63,11 @@ softpipe_texture_layout(struct pipe_screen *screen,
pt->depth0 = depth;
for (level = 0; level <= pt->last_level; level++) {
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
- spt->stride[level] = pt->nblocksx[level]*pt->block.size;
+ spt->stride[level] = pf_get_stride(pt->format, width);
spt->level_offset[level] = buffer_size;
- buffer_size += (pt->nblocksy[level] *
+ buffer_size += (pf_get_nblocksy(pt->format, u_minify(height, level)) *
((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
spt->stride[level]);
@@ -97,9 +95,6 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
unsigned tex_usage = spt->base.tex_usage;
- spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width0);
- spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height0);
-
spt->buffer = screen->surface_buffer_create( screen,
spt->base.width0,
spt->base.height0,
@@ -175,8 +170,6 @@ softpipe_texture_blanket(struct pipe_screen * screen,
spt->base = *base;
pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
- spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width0);
- spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height0);
spt->stride[0] = stride[0];
pipe_buffer_reference(&spt->buffer, buffer);
@@ -244,10 +237,12 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps->zslice = zslice;
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset += face * pt->nblocksy[level] * spt->stride[level];
+ ps->offset += face * pf_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+ spt->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset += zslice * pt->nblocksy[level] * spt->stride[level];
+ ps->offset += zslice * pf_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+ spt->stride[level];
}
else {
assert(face == 0);
@@ -302,15 +297,12 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
spt = CALLOC_STRUCT(softpipe_transfer);
if (spt) {
struct pipe_transfer *pt = &spt->base;
+ int nblocksy = pf_get_nblocksy(texture->format, u_minify(texture->height0, level));
pipe_texture_reference(&pt->texture, texture);
- pt->format = texture->format;
- pt->block = texture->block;
pt->x = x;
pt->y = y;
pt->width = w;
pt->height = h;
- pt->nblocksx = texture->nblocksx[level];
- pt->nblocksy = texture->nblocksy[level];
pt->stride = sptex->stride[level];
pt->usage = usage;
pt->face = face;
@@ -320,10 +312,10 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
spt->offset = sptex->level_offset[level];
if (texture->target == PIPE_TEXTURE_CUBE) {
- spt->offset += face * pt->nblocksy * pt->stride;
+ spt->offset += face * nblocksy * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
- spt->offset += zslice * pt->nblocksy * pt->stride;
+ spt->offset += zslice * nblocksy * pt->stride;
}
else {
assert(face == 0);
@@ -361,9 +353,11 @@ softpipe_transfer_map( struct pipe_screen *screen,
{
ubyte *map, *xfer_map;
struct softpipe_texture *spt;
+ enum pipe_format format;
assert(transfer->texture);
spt = softpipe_texture(transfer->texture);
+ format = transfer->texture->format;
map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer));
if (map == NULL)
@@ -380,8 +374,8 @@ softpipe_transfer_map( struct pipe_screen *screen,
}
xfer_map = map + softpipe_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);
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
return xfer_map;
}
@@ -438,7 +432,6 @@ softpipe_video_surface_create(struct pipe_screen *screen,
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
sp_vsfc->tex = screen->texture_create(screen, &template);
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 65872cecc4..04f61d16c4 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -238,7 +238,7 @@ clear_tile(struct softpipe_cached_tile *tile,
{
uint i, j;
- switch (pf_get_size(format)) {
+ switch (pf_get_blocksize(format)) {
case 1:
memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
break;
@@ -284,8 +284,9 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
uint x, y;
uint numCleared = 0;
+ assert(pt->texture);
/* clear the scratch tile to the clear value */
- clear_tile(&tc->tile, pt->format, tc->clear_val);
+ clear_tile(&tc->tile, pt->texture->format, tc->clear_val);
/* push the tile to all positions marked as clear */
for (y = 0; y < h; y += TILE_SIZE) {
@@ -372,6 +373,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (addr.value != tile->addr.value) {
+ assert(pt->texture);
if (tile->addr.bits.invalid == 0) {
/* put dirty tile back in framebuffer */
if (tc->depth_stencil) {
@@ -395,10 +397,10 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (is_clear_flag_set(tc->clear_flags, addr)) {
/* don't get tile from framebuffer, just clear it */
if (tc->depth_stencil) {
- clear_tile(tile, pt->format, tc->clear_val);
+ clear_tile(tile, pt->texture->format, tc->clear_val);
}
else {
- clear_tile_rgba(tile, pt->format, tc->clear_color);
+ clear_tile_rgba(tile, pt->texture->format, tc->clear_color);
}
clear_clear_flag(tc->clear_flags, addr);
}
diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
index 6e10d65a20..3e2cb1a16d 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.c
+++ b/src/gallium/drivers/svga/svga_screen_texture.c
@@ -158,7 +158,8 @@ svga_transfer_dma_band(struct svga_transfer *st,
st->base.x + st->base.width,
y + h,
st->base.zslice + 1,
- texture->base.block.size*8/(texture->base.block.width*texture->base.block.height));
+ pf_get_blocksize(texture->base.format)*8/
+ (pf_get_blockwidth(texture->base.format)*pf_get_blockheight(texture->base.format)));
box.x = st->base.x;
box.y = y;
@@ -208,7 +209,8 @@ svga_transfer_dma(struct svga_transfer *st,
}
else {
unsigned y, h, srcy;
- h = st->hw_nblocksy * st->base.block.height;
+ unsigned blockheight = pf_get_blockheight(st->base.texture->format);
+ h = st->hw_nblocksy * blockheight;
srcy = 0;
for(y = 0; y < st->base.height; y += h) {
unsigned offset, length;
@@ -218,11 +220,11 @@ svga_transfer_dma(struct svga_transfer *st,
h = st->base.height - y;
/* Transfer band must be aligned to pixel block boundaries */
- assert(y % st->base.block.height == 0);
- assert(h % st->base.block.height == 0);
+ assert(y % blockheight == 0);
+ assert(h % blockheight == 0);
- offset = y * st->base.stride / st->base.block.height;
- length = h * st->base.stride / st->base.block.height;
+ offset = y * st->base.stride / blockheight;
+ length = h * st->base.stride / blockheight;
sw = (uint8_t *)st->swbuf + offset;
@@ -285,8 +287,6 @@ svga_texture_create(struct pipe_screen *screen,
height = templat->height0;
depth = templat->depth0;
for(level = 0; level <= templat->last_level; ++level) {
- tex->base.nblocksx[level] = pf_get_nblocksx(&tex->base.block, width);
- tex->base.nblocksy[level] = pf_get_nblocksy(&tex->base.block, height);
width = u_minify(width, 1);
height = u_minify(height, 1);
depth = u_minify(depth, 1);
@@ -770,6 +770,8 @@ svga_get_tex_transfer(struct pipe_screen *screen,
struct svga_screen *ss = svga_screen(screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st;
+ unsigned nblocksx = pf_get_nblocksx(texture->format, w);
+ unsigned nblocksy = pf_get_nblocksy(texture->format, h);
/* We can't map texture storage directly */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
@@ -779,21 +781,17 @@ svga_get_tex_transfer(struct pipe_screen *screen,
if (!st)
return NULL;
- st->base.format = texture->format;
- st->base.block = texture->block;
st->base.x = x;
st->base.y = y;
st->base.width = w;
st->base.height = h;
- st->base.nblocksx = pf_get_nblocksx(&texture->block, w);
- st->base.nblocksy = pf_get_nblocksy(&texture->block, h);
- st->base.stride = st->base.nblocksx*st->base.block.size;
+ st->base.stride = nblocksx*pf_get_blocksize(texture->format);
st->base.usage = usage;
st->base.face = face;
st->base.level = level;
st->base.zslice = zslice;
- st->hw_nblocksy = st->base.nblocksy;
+ st->hw_nblocksy = nblocksy;
st->hwbuf = svga_winsys_buffer_create(ss,
1,
@@ -809,15 +807,15 @@ svga_get_tex_transfer(struct pipe_screen *screen,
if(!st->hwbuf)
goto no_hwbuf;
- if(st->hw_nblocksy < st->base.nblocksy) {
+ if(st->hw_nblocksy < nblocksy) {
/* We couldn't allocate a hardware buffer big enough for the transfer,
* so allocate regular malloc memory instead */
debug_printf("%s: failed to allocate %u KB of DMA, splitting into %u x %u KB DMA transfers\n",
__FUNCTION__,
- (st->base.nblocksy*st->base.stride + 1023)/1024,
- (st->base.nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy,
+ (nblocksy*st->base.stride + 1023)/1024,
+ (nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy,
(st->hw_nblocksy*st->base.stride + 1023)/1024);
- st->swbuf = MALLOC(st->base.nblocksy*st->base.stride);
+ st->swbuf = MALLOC(nblocksy*st->base.stride);
if(!st->swbuf)
goto no_swbuf;
}
@@ -1069,8 +1067,7 @@ svga_screen_buffer_from_texture(struct pipe_texture *texture,
svga_translate_format(texture->format),
stex->handle);
- *stride = pf_get_nblocksx(&texture->block, texture->width0) *
- texture->block.size;
+ *stride = pf_get_stride(texture->format, texture->width0);
return *buffer != NULL;
}
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index a947745732..f1b0daf9f6 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -210,7 +210,7 @@ static int update_zero_stride( struct svga_context *svga,
mapped_buffer = pipe_buffer_map_range(svga->pipe.screen,
vbuffer->buffer,
vel->src_offset,
- pf_get_size(vel->src_format),
+ pf_get_blocksize(vel->src_format),
PIPE_BUFFER_USAGE_CPU_READ);
translate->set_buffer(translate, vel->vertex_buffer_index,
mapped_buffer,
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index 6d58209294..0102cc1876 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -43,19 +43,6 @@ void trace_dump_format(enum pipe_format format)
}
-void trace_dump_block(const struct pipe_format_block *block)
-{
- if (!trace_dumping_enabled_locked())
- return;
-
- trace_dump_struct_begin("pipe_format_block");
- trace_dump_member(uint, block, size);
- trace_dump_member(uint, block, width);
- trace_dump_member(uint, block, height);
- trace_dump_struct_end();
-}
-
-
static void trace_dump_reference(const struct pipe_reference *reference)
{
if (!trace_dumping_enabled_locked())
@@ -94,10 +81,6 @@ void trace_dump_template(const struct pipe_texture *templat)
trace_dump_uint(templat->depth0);
trace_dump_member_end();
- trace_dump_member_begin("block");
- trace_dump_block(&templat->block);
- trace_dump_member_end();
-
trace_dump_member(uint, templat, last_level);
trace_dump_member(uint, templat, tex_usage);
@@ -483,16 +466,9 @@ void trace_dump_transfer(const struct pipe_transfer *state)
trace_dump_struct_begin("pipe_transfer");
- trace_dump_member(format, state, format);
trace_dump_member(uint, state, width);
trace_dump_member(uint, state, height);
- trace_dump_member_begin("block");
- trace_dump_block(&state->block);
- trace_dump_member_end();
-
- trace_dump_member(uint, state, nblocksx);
- trace_dump_member(uint, state, nblocksy);
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, usage);
diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h
index 05b821adb6..07ad6fbb20 100644
--- a/src/gallium/drivers/trace/tr_dump_state.h
+++ b/src/gallium/drivers/trace/tr_dump_state.h
@@ -35,11 +35,8 @@
void trace_dump_format(enum pipe_format format);
-void trace_dump_block(const struct pipe_format_block *block);
-
void trace_dump_template(const struct pipe_texture *templat);
-
void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
void trace_dump_poly_stipple(const struct pipe_poly_stipple *state);
diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c
index b59458c0e3..af1d7f3224 100644
--- a/src/gallium/drivers/trace/tr_rbug.c
+++ b/src/gallium/drivers/trace/tr_rbug.c
@@ -203,7 +203,9 @@ trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
&t->width0, 1,
&t->height0, 1,
&t->depth0, 1,
- t->block.width, t->block.height, t->block.size,
+ pf_get_blockwidth(t->format),
+ pf_get_blockheight(t->format),
+ pf_get_blocksize(t->format),
t->last_level,
t->nr_samples,
t->tex_usage,
@@ -251,9 +253,12 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
map = screen->transfer_map(screen, t);
rbug_send_texture_read_reply(tr_rbug->con, serial,
- t->format,
- t->block.width, t->block.height, t->block.size,
- (uint8_t*)map, t->stride * t->nblocksy,
+ t->texture->format,
+ pf_get_blockwidth(t->texture->format),
+ pf_get_blockheight(t->texture->format),
+ pf_get_blocksize(t->texture->format),
+ (uint8_t*)map,
+ t->stride * pf_get_nblocksy(t->texture->format, t->height),
t->stride,
NULL);
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 7da9bd3866..f69f7da000 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -35,6 +35,7 @@
#include "tr_screen.h"
#include "pipe/p_inlines.h"
+#include "pipe/p_format.h"
static boolean trace = FALSE;
@@ -424,7 +425,7 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen,
struct pipe_transfer *transfer = tr_trans->transfer;
if(tr_trans->map) {
- size_t size = transfer->nblocksy * transfer->stride;
+ size_t size = pf_get_nblocksy(transfer->texture->format, transfer->width) * transfer->stride;
trace_dump_call_begin("pipe_screen", "transfer_write");
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index af23080920..e6bba777d3 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -422,10 +422,11 @@ static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
return size << (pf_mixed_scale8( format ) * 3);
}
+
/**
- * Return total bits needed for the pixel format.
+ * Return total bits needed for the pixel format per block.
*/
-static INLINE uint pf_get_bits( enum pipe_format format )
+static INLINE uint pf_get_blocksizebits( enum pipe_format format )
{
switch (pf_layout(format)) {
case PIPE_FORMAT_LAYOUT_RGBAZS:
@@ -441,8 +442,24 @@ static INLINE uint pf_get_bits( enum pipe_format format )
pf_get_component_bits( format, PIPE_FORMAT_COMP_S );
case PIPE_FORMAT_LAYOUT_YCBCR:
assert( format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV );
- /* return effective bits per pixel */
- return 16;
+ return 32;
+ case PIPE_FORMAT_LAYOUT_DXT:
+ switch(format) {
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT1_RGB:
+ case PIPE_FORMAT_DXT1_SRGBA:
+ case PIPE_FORMAT_DXT1_SRGB:
+ return 64;
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
+ case PIPE_FORMAT_DXT3_SRGBA:
+ case PIPE_FORMAT_DXT5_SRGBA:
+ return 128;
+ default:
+ assert( 0 );
+ return 0;
+ }
+
default:
assert( 0 );
return 0;
@@ -450,102 +467,66 @@ static INLINE uint pf_get_bits( enum pipe_format format )
}
/**
- * Return bytes per pixel for the given format.
+ * Return bytes per element for the given format.
*/
-static INLINE uint pf_get_size( enum pipe_format format )
+static INLINE uint pf_get_blocksize( enum pipe_format format )
{
- assert(pf_get_bits(format) % 8 == 0);
- return pf_get_bits(format) / 8;
+ assert(pf_get_blocksizebits(format) % 8 == 0);
+ return pf_get_blocksizebits(format) / 8;
}
-/**
- * Describe accurately the pixel format.
- *
- * The chars-per-pixel concept falls apart with compressed and yuv images, where
- * more than one pixel are coded in a single data block. This structure
- * describes that block.
- *
- * Simple pixel formats are effectively a 1x1xcpp block.
- */
-struct pipe_format_block
+static INLINE uint pf_get_blockwidth( enum pipe_format format )
{
- /** Block size in bytes */
- unsigned size;
-
- /** Block width in pixels */
- unsigned width;
-
- /** Block height in pixels */
- unsigned height;
-};
+ switch (pf_layout(format)) {
+ case PIPE_FORMAT_LAYOUT_YCBCR:
+ return 2;
+ case PIPE_FORMAT_LAYOUT_DXT:
+ return 4;
+ default:
+ return 1;
+ }
+}
-/**
- * Describe pixel format's block.
- *
- * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx
- */
-static INLINE void
-pf_get_block(enum pipe_format format, struct pipe_format_block *block)
+static INLINE uint pf_get_blockheight( enum pipe_format format )
{
- switch(format) {
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_SRGBA:
- case PIPE_FORMAT_DXT1_SRGB:
- block->size = 8;
- block->width = 4;
- block->height = 4;
- break;
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- case PIPE_FORMAT_DXT3_SRGBA:
- case PIPE_FORMAT_DXT5_SRGBA:
- block->size = 16;
- block->width = 4;
- block->height = 4;
- break;
- case PIPE_FORMAT_YCBCR:
- case PIPE_FORMAT_YCBCR_REV:
- block->size = 4; /* 2*cpp */
- block->width = 2;
- block->height = 1;
- break;
+ switch (pf_layout(format)) {
+ case PIPE_FORMAT_LAYOUT_DXT:
+ return 4;
default:
- block->size = pf_get_size(format);
- block->width = 1;
- block->height = 1;
- break;
+ return 1;
}
}
static INLINE unsigned
-pf_get_nblocksx(const struct pipe_format_block *block, unsigned x)
+pf_get_nblocksx(enum pipe_format format, unsigned x)
{
- return (x + block->width - 1)/block->width;
+ unsigned blockwidth = pf_get_blockwidth(format);
+ return (x + blockwidth - 1) / blockwidth;
}
static INLINE unsigned
-pf_get_nblocksy(const struct pipe_format_block *block, unsigned y)
+pf_get_nblocksy(enum pipe_format format, unsigned y)
{
- return (y + block->height - 1)/block->height;
+ unsigned blockheight = pf_get_blockheight(format);
+ return (y + blockheight - 1) / blockheight;
}
static INLINE unsigned
-pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned height)
+pf_get_nblocks(enum pipe_format format, unsigned width, unsigned height)
{
- return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height);
+ return pf_get_nblocksx(format, width) * pf_get_nblocksy(format, height);
}
static INLINE size_t
-pf_get_stride(const struct pipe_format_block *block, unsigned width)
+pf_get_stride(enum pipe_format format, unsigned width)
{
- return pf_get_nblocksx(block, width)*block->size;
+ return pf_get_nblocksx(format, width) * pf_get_blocksize(format);
}
static INLINE size_t
-pf_get_2d_size(const struct pipe_format_block *block, size_t stride, unsigned height)
+pf_get_2d_size(enum pipe_format format, size_t stride, unsigned height)
{
- return pf_get_nblocksy(block, height)*stride;
+ return pf_get_nblocksy(format, height) * stride;
}
static INLINE boolean
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 6de7af6a81..cbd5bfa469 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -316,14 +316,10 @@ struct pipe_surface
*/
struct pipe_transfer
{
- enum pipe_format format; /**< PIPE_FORMAT_x */
unsigned x; /**< x offset from start of texture image */
unsigned y; /**< y offset from start of texture image */
unsigned width; /**< logical width in pixels */
unsigned height; /**< logical height in pixels */
- struct pipe_format_block block;
- unsigned nblocksx; /**< allocated width in blocks */
- unsigned nblocksy; /**< allocated height in blocks */
unsigned stride; /**< stride in bytes between rows of blocks */
enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */
@@ -348,10 +344,6 @@ struct pipe_texture
unsigned height0;
unsigned depth0;
- struct pipe_format_block block;
- unsigned nblocksx[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated width in blocks */
- unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated height in blocks */
-
unsigned last_level:8; /**< Index of last mipmap level present/defined */
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 45a6059ea8..099cf1e064 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -66,7 +66,6 @@ dri_surface_from_handle(struct drm_api *api,
templat.format = format;
templat.width0 = width;
templat.height0 = height;
- pf_get_block(templat.format, &templat.block);
texture = api->texture_from_shared_handle(api, screen, &templat,
"dri2 buffer", pitch, handle);
diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c
index ddd9b04cd4..737bdfdd34 100644
--- a/src/gallium/state_trackers/egl/egl_surface.c
+++ b/src/gallium/state_trackers/egl/egl_surface.c
@@ -118,7 +118,6 @@ drm_create_texture(_EGLDisplay *dpy,
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.width0 = w;
templat.height0 = h;
- pf_get_block(templat.format, &templat.block);
texture = screen->texture_create(dev->screen,
&templat);
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 3f79cc1a3d..8e323f4896 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -80,7 +80,6 @@
%rename(Stencil) pipe_stencil_state;
%rename(Alpha) pipe_alpha_state;
%rename(DepthStencilAlpha) pipe_depth_stencil_alpha_state;
-%rename(FormatBlock) pipe_format_block;
%rename(Framebuffer) pipe_framebuffer_state;
%rename(PolyStipple) pipe_poly_stipple;
%rename(Rasterizer) pipe_rasterizer_state;
diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i
index a83bcc71a1..2dc995adb0 100644
--- a/src/gallium/state_trackers/python/p_device.i
+++ b/src/gallium/state_trackers/python/p_device.i
@@ -112,7 +112,6 @@ struct st_device {
struct pipe_texture templat;
memset(&templat, 0, sizeof(templat));
templat.format = format;
- pf_get_block(templat.format, &templat.block);
templat.width0 = width;
templat.height0 = height;
templat.depth0 = depth;
diff --git a/src/gallium/state_trackers/python/p_format.i b/src/gallium/state_trackers/python/p_format.i
index 26fb12b387..68df009331 100644
--- a/src/gallium/state_trackers/python/p_format.i
+++ b/src/gallium/state_trackers/python/p_format.i
@@ -152,11 +152,3 @@ enum pipe_format {
PIPE_FORMAT_DXT5_SRGBA,
};
-
-struct pipe_format_block
-{
- unsigned size;
- unsigned width;
- unsigned height;
-};
-
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index 5416b872f5..1de7f86a3c 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -69,15 +69,7 @@
unsigned get_depth(unsigned level=0) {
return u_minify($self->depth0, level);
}
-
- unsigned get_nblocksx(unsigned level=0) {
- return $self->nblocksx[level];
- }
-
- unsigned get_nblocksy(unsigned level=0) {
- return $self->nblocksy[level];
- }
-
+
/** Get a surface which is a "view" into a texture */
struct st_surface *
get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0)
@@ -126,8 +118,6 @@ struct st_surface
unsigned format;
unsigned width;
unsigned height;
- unsigned nblocksx;
- unsigned nblocksy;
~st_surface() {
pipe_texture_reference(&$self->texture, NULL);
@@ -142,8 +132,8 @@ struct st_surface
struct pipe_transfer *transfer;
unsigned stride;
- stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
- *LENGTH = pf_get_nblocksy(&texture->block, h) * stride;
+ stride = pf_get_stride(texture->format, w);
+ *LENGTH = pf_get_nblocksy(texture->format, h) * stride;
*STRING = (char *) malloc(*LENGTH);
if(!*STRING)
return;
@@ -169,9 +159,9 @@ struct st_surface
struct pipe_transfer *transfer;
if(stride == 0)
- stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
+ stride = pf_get_stride(texture->format, w);
- if(LENGTH < pf_get_nblocksy(&texture->block, h) * stride)
+ if(LENGTH < pf_get_nblocksy(texture->format, h) * stride)
SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
transfer = screen->get_tex_transfer(screen,
@@ -383,18 +373,6 @@ struct st_surface
{
return u_minify(surface->texture->height0, surface->level);
}
-
- static unsigned
- st_surface_nblocksx_get(struct st_surface *surface)
- {
- return surface->texture->nblocksx[surface->level];
- }
-
- static unsigned
- st_surface_nblocksy_get(struct st_surface *surface)
- {
- return surface->texture->nblocksy[surface->level];
- }
%}
/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
index 5f826b1c4c..b32eafe23f 100755
--- a/src/gallium/state_trackers/python/retrace/interpreter.py
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -99,7 +99,6 @@ struct_factories = {
"pipe_stencil_state": gallium.Stencil,
"pipe_alpha_state": gallium.Alpha,
"pipe_depth_stencil_alpha_state": gallium.DepthStencilAlpha,
- "pipe_format_block": gallium.FormatBlock,
#"pipe_framebuffer_state": gallium.Framebuffer,
"pipe_poly_stipple": gallium.PolyStipple,
"pipe_rasterizer_state": gallium.Rasterizer,
@@ -307,7 +306,7 @@ class Screen(Object):
def surface_write(self, surface, data, stride, size):
if surface is None:
return
- assert surface.nblocksy * stride == size
+# assert surface.nblocksy * stride == size
surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index a791113aba..2966b24cdc 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -249,9 +249,6 @@ st_context_create(struct st_device *st_dev)
memset( &templat, 0, sizeof( templat ) );
templat.target = PIPE_TEXTURE_2D;
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- templat.block.size = 4;
- templat.block.width = 1;
- templat.block.height = 1;
templat.width0 = 1;
templat.height0 = 1;
templat.depth0 = 1;
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index 6fee90afda..97ca2afc54 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -423,7 +423,6 @@ dxt5_rgba_data[] = {
static INLINE void
st_sample_dxt_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
uint8_t *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
@@ -462,21 +461,21 @@ st_sample_dxt_pixel_block(enum pipe_format format,
for(ch = 0; ch < 4; ++ch)
rgba[y*rgba_stride + x*4 + ch] = (float)(data[i].rgba[y*4*4 + x*4 + ch])/255.0f;
- memcpy(raw, data[i].raw, block->size);
+ memcpy(raw, data[i].raw, pf_get_blocksize(format));
}
static INLINE void
st_sample_generic_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
uint8_t *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
{
unsigned i;
unsigned x, y, ch;
+ int blocksize = pf_get_blocksize(format);
- for(i = 0; i < block->size; ++i)
+ for(i = 0; i < blocksize; ++i)
raw[i] = (uint8_t)st_random();
@@ -503,7 +502,6 @@ st_sample_generic_pixel_block(enum pipe_format format,
*/
void
st_sample_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
void *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
@@ -513,11 +511,11 @@ st_sample_pixel_block(enum pipe_format format,
case PIPE_FORMAT_DXT1_RGBA:
case PIPE_FORMAT_DXT3_RGBA:
case PIPE_FORMAT_DXT5_RGBA:
- st_sample_dxt_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+ st_sample_dxt_pixel_block(format, raw, rgba, rgba_stride, w, h);
break;
default:
- st_sample_generic_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+ st_sample_generic_pixel_block(format, raw, rgba, rgba_stride, w, h);
break;
}
}
@@ -548,18 +546,23 @@ st_sample_surface(struct st_surface *surface, float *rgba)
raw = screen->transfer_map(screen, transfer);
if (raw) {
- const struct pipe_format_block *block = &texture->block;
+ enum pipe_format format = texture->format;
uint x, y;
+ int nblocksx = pf_get_nblocksx(format, width);
+ int nblocksy = pf_get_nblocksy(format, height);
+ int blockwidth = pf_get_blockwidth(format);
+ int blockheight = pf_get_blockheight(format);
+ int blocksize = pf_get_blocksize(format);
- for (y = 0; y < transfer->nblocksy; ++y) {
- for (x = 0; x < transfer->nblocksx; ++x) {
- st_sample_pixel_block(texture->format,
- block,
- (uint8_t *) raw + y * transfer->stride + x * block->size,
- rgba + y * block->height * rgba_stride + x * block->width * 4,
+
+ for (y = 0; y < nblocksy; ++y) {
+ for (x = 0; x < nblocksx; ++x) {
+ st_sample_pixel_block(format,
+ (uint8_t *) raw + y * transfer->stride + x * blocksize,
+ rgba + y * blockheight * rgba_stride + x * blockwidth * 4,
rgba_stride,
- MIN2(block->width, width - x*block->width),
- MIN2(block->height, height - y*block->height));
+ MIN2(blockwidth, width - x*blockwidth),
+ MIN2(blockheight, height - y*blockheight));
}
}
diff --git a/src/gallium/state_trackers/python/st_sample.h b/src/gallium/state_trackers/python/st_sample.h
index 0a27083549..888114d302 100644
--- a/src/gallium/state_trackers/python/st_sample.h
+++ b/src/gallium/state_trackers/python/st_sample.h
@@ -35,7 +35,6 @@
void
st_sample_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
void *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h);
diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c
index f0abd12e3d..43c61af1ff 100644
--- a/src/gallium/state_trackers/python/st_softpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c
@@ -157,16 +157,6 @@ st_softpipe_user_buffer_create(struct pipe_winsys *winsys,
}
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
static struct pipe_buffer *
st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
@@ -176,13 +166,10 @@ st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
diff --git a/src/gallium/state_trackers/python/tests/surface_copy.py b/src/gallium/state_trackers/python/tests/surface_copy.py
index 3ceecbbd3a..df5babb78a 100755
--- a/src/gallium/state_trackers/python/tests/surface_copy.py
+++ b/src/gallium/state_trackers/python/tests/surface_copy.py
@@ -98,9 +98,10 @@ class TextureTest(TestCase):
y = 0
w = dst_surface.width
h = dst_surface.height
-
- stride = dst_surface.nblocksx * dst_texture.block.size
- size = dst_surface.nblocksy * stride
+
+ # ???
+ stride = pf_get_stride(texture->format, w)
+ size = pf_get_nblocksy(texture->format) * stride
src_raw = os.urandom(size)
src_surface.put_tile_raw(0, 0, w, h, src_raw, stride)
diff --git a/src/gallium/state_trackers/python/tests/texture_transfer.py b/src/gallium/state_trackers/python/tests/texture_transfer.py
index e65b425adf..35daca9e49 100755
--- a/src/gallium/state_trackers/python/tests/texture_transfer.py
+++ b/src/gallium/state_trackers/python/tests/texture_transfer.py
@@ -86,8 +86,9 @@ class TextureTest(TestCase):
surface = texture.get_surface(face, level, zslice)
- stride = surface.nblocksx * texture.block.size
- size = surface.nblocksy * stride
+ # ???
+ stride = pf_get_stride(texture->format, w)
+ size = pf_get_nblocksy(texture->format) * stride
in_raw = os.urandom(size)
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index faf396d087..eb135c1ff4 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -71,7 +71,6 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
templ.width0 = color_data_len;
templ.height0 = 1;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c
index 4684a5727d..172311851e 100644
--- a/src/gallium/state_trackers/vega/image.c
+++ b/src/gallium/state_trackers/vega/image.c
@@ -270,7 +270,6 @@ struct vg_image * image_create(VGImageFormat format,
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
pt.format = pformat;
- pf_get_block(pformat, &pt.block);
pt.last_level = 0;
pt.width0 = width;
pt.height0 = height;
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index b84103fdba..868c28239a 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -491,7 +491,6 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
pt.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &pt.block);
pt.last_level = 0;
pt.width0 = width;
pt.height0 = height;
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index e8ca7d9e89..785c982943 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -154,7 +154,6 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
templ.width0 = 1024;
templ.height0 = 1;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index 9085ed1bfe..c85dae0282 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -448,7 +448,6 @@ void renderer_copy_surface(struct renderer *ctx,
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- pf_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index d28463dd1b..ed18dd6075 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -50,7 +50,6 @@ create_texture(struct pipe_context *pipe, enum pipe_format format,
}
templ.target = PIPE_TEXTURE_2D;
- pf_get_block(templ.format, &templ.block);
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 9e8c14d741..03bc6e37c9 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -200,7 +200,6 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.width0 = 64;
templat.height0 = 64;
- pf_get_block(templat.format, &templat.block);
crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
&templat);
@@ -216,7 +215,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
PIPE_TRANSFER_WRITE,
0, 0, 64, 64);
ptr = ms->screen->transfer_map(ms->screen, transfer);
- util_copy_rect(ptr, &crtcp->cursor_tex->block,
+ util_copy_rect(ptr, crtcp->cursor_tex->format,
transfer->stride, 0, 0,
64, 64, (void*)image, 64 * 4, 0, 0);
ms->screen->transfer_unmap(ms->screen, transfer);
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 2394f004d2..bdd6a8b205 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -108,7 +108,6 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
else
template.format = ms->ds_depth_bits_last ?
PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
- pf_get_block(template.format, &template.block);
template.width0 = pDraw->width;
template.height0 = pDraw->height;
template.depth0 = 1;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index aa46cd45f1..55b87aefa1 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -202,7 +202,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
x, y, w, h, dst_pitch);
#endif
- util_copy_rect((unsigned char*)dst, &priv->tex->block, dst_pitch, 0, 0,
+ util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0,
w, h, exa->scrn->transfer_map(exa->scrn, transfer),
transfer->stride, 0, 0);
@@ -242,7 +242,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
#endif
util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer),
- &priv->tex->block, transfer->stride, 0, 0, w, h,
+ priv->tex->format, transfer->stride, 0, 0, w, h,
(unsigned char*)src, src_pitch, 0, 0);
exa->scrn->transfer_unmap(exa->scrn, transfer);
@@ -899,7 +899,6 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
- pf_get_block(template.format, &template.block);
if (ROUND_UP_TEXTURES && priv->flags == 0) {
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
@@ -985,7 +984,6 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy);
- pf_get_block(template.format, &template.block);
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index f777395100..248d658ac2 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -512,7 +512,6 @@ renderer_clone_texture(struct xorg_renderer *r,
templ.width0 = src->width0;
templ.height0 = src->height0;
templ.depth0 = 1;
- pf_get_block(format, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
pt = screen->texture_create(screen, &templ);
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index b8eca8c817..c965e4b9b5 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -170,7 +170,6 @@ create_component_texture(struct pipe_context *pipe,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_L8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
index d497861324..8d95826c9a 100644
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -28,7 +28,6 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
tmpl.format = format;
tmpl.width0 = width;
tmpl.height0 = height;
- pf_get_block(tmpl.format, &tmpl.block);
pt = api->texture_from_shared_handle(api, pscreen, &tmpl,
"front buffer", pitch, handle);
@@ -247,7 +246,7 @@ nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen,
return false;
*handle = mt->bo->handle;
- *stride = mt->base.nblocksx[0] * mt->base.block.size;
+ *stride = pf_get_stride(mt->base.format, mt->base.width0);
return true;
}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index 74afffc9cf..65f7babff2 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -113,17 +113,13 @@ static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
unsigned tex_usage,
unsigned *stride)
{
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy, size;
-
- pf_get_block(format, &block);
-
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
-
/* Radeons enjoy things in multiples of 32. */
/* XXX this can be 32 when POT */
- *stride = (nblocksx * block.size + 63) & ~63;
+ const unsigned alignment = 64;
+ unsigned nblocksy, size;
+
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
size = *stride * nblocksy;
return radeon_buffer_create(ws, 64, usage, size);
@@ -321,9 +317,6 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co
tmpl.height0 = h;
tmpl.depth0 = 1;
tmpl.format = format;
- pf_get_block(tmpl.format, &tmpl.block);
- tmpl.nblocksx[0] = pf_get_nblocksx(&tmpl.block, w);
- tmpl.nblocksy[0] = pf_get_nblocksy(&tmpl.block, h);
pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb);
if (pt == NULL) {
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c
index 79ff2cc985..d5644c161f 100644
--- a/src/gallium/winsys/egl_xlib/sw_winsys.c
+++ b/src/gallium/winsys/egl_xlib/sw_winsys.c
@@ -71,16 +71,6 @@ sw_pipe_buffer(struct pipe_buffer *b)
}
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
static const char *
get_name(struct pipe_winsys *pws)
{
@@ -170,13 +160,10 @@ surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
index 08067aad64..b8c8502d7b 100644
--- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
@@ -138,13 +138,10 @@ static struct pipe_buffer* xsp_surface_buffer_create
)
{
const unsigned int ALIGNMENT = 1;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = align(nblocksx * block.size, ALIGNMENT);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), ALIGNMENT);
return pws->buffer_create(pws, ALIGNMENT, usage,
*stride * nblocksy);
diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
index e8bc0f55ac..81c46c0a96 100644
--- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
@@ -49,7 +49,6 @@
struct gdi_llvmpipe_displaytarget
{
enum pipe_format format;
- struct pipe_format_block block;
unsigned width;
unsigned height;
unsigned stride;
@@ -118,16 +117,6 @@ gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys,
}
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
static struct llvmpipe_displaytarget *
gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
enum pipe_format format,
@@ -147,10 +136,10 @@ gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
gdt->width = width;
gdt->height = height;
- bpp = pf_get_bits(format);
- cpp = pf_get_size(format);
+ bpp = pf_get_blocksizebits(format);
+ cpp = pf_get_blocksize(format);
- gdt->stride = round_up(width * cpp, alignment);
+ gdt->stride = align(width * cpp, alignment);
gdt->size = gdt->stride * height;
gdt->data = align_malloc(gdt->size, alignment);
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index 5e0ccf32f4..173fa5b6fe 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -151,16 +151,6 @@ gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys,
}
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
static struct pipe_buffer *
gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
@@ -170,13 +160,10 @@ gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
@@ -283,10 +270,10 @@ gdi_softpipe_present(struct pipe_screen *screen,
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_size(surface->format);
+ bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_blocksize(surface->format);
bmi.bmiHeader.biHeight= -(long)surface->height;
bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
+ bmi.bmiHeader.biBitCount = pf_get_blocksizebits(surface->format);
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter = 0;
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 5f8dc2ab24..b078de23b7 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -277,15 +277,6 @@ xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
static struct pipe_buffer *
xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
@@ -295,18 +286,15 @@ xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
/* XXX a bit of a hack */
- *stride * round_up(nblocksy, TILE_SIZE));
+ *stride * align(nblocksy, TILE_SIZE));
}
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
index 3dd15e099b..41f3e248e8 100644
--- a/src/gallium/winsys/xlib/xlib_llvmpipe.c
+++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c
@@ -58,7 +58,6 @@
struct xm_displaytarget
{
enum pipe_format format;
- struct pipe_format_block block;
unsigned width;
unsigned height;
unsigned stride;
@@ -262,10 +261,10 @@ xm_llvmpipe_display(struct xmesa_buffer *xm_buffer,
{
if (xm_dt->tempImage == NULL)
{
- assert(xm_dt->block.width == 1);
- assert(xm_dt->block.height == 1);
+ assert(pf_get_blockwidth(xm_dt->format) == 1);
+ assert(pf_get_blockheight(xm_dt->format) == 1);
alloc_shm_ximage(xm_dt, xm_buffer,
- xm_dt->stride / xm_dt->block.size,
+ xm_dt->stride / pf_get_blocksize(xm_dt->format),
xm_dt->height);
}
@@ -321,7 +320,7 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys,
unsigned *stride)
{
struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget);
- unsigned nblocksx, nblocksy, size;
+ unsigned nblocksy, size;
xm_dt = CALLOC_STRUCT(xm_displaytarget);
if(!xm_dt)
@@ -331,10 +330,8 @@ xm_displaytarget_create(struct llvmpipe_winsys *winsys,
xm_dt->width = width;
xm_dt->height = height;
- pf_get_block(format, &xm_dt->block);
- nblocksx = pf_get_nblocksx(&xm_dt->block, width);
- nblocksy = pf_get_nblocksy(&xm_dt->block, height);
- xm_dt->stride = align(nblocksx * xm_dt->block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ xm_dt->stride = align(pf_get_stride(format, width), alignment);
size = xm_dt->stride * nblocksy;
#ifdef USE_XSHM
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index 260b39e2a0..69a5dcc2b7 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -254,10 +254,10 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
{
if (xm_buf->tempImage == NULL)
{
- assert(surf->texture->block.width == 1);
- assert(surf->texture->block.height == 1);
+ assert(pf_get_blockwidth(surf->texture->format) == 1);
+ assert(pf_get_blockheight(surf->texture->format) == 1);
alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
- surf->texture->block.size, surf->height);
+ pf_get_blocksize(surf->texture->format), surf->height);
}
ximage = xm_buf->tempImage;
@@ -360,13 +360,10 @@ xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy, size;
+ unsigned nblocksy, size;
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = align(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
size = *stride * nblocksy;
#ifdef USE_XSHM