#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_debug.h"
#include "util/u_network.h"
unsigned src_stride, enum pipe_format src_format,
uint8_t *data, unsigned src_size)
{
- struct pipe_format_block src_block;
-
enum pipe_format dst_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
- struct pipe_format_block dst_block;
unsigned dst_stride;
unsigned dst_size;
float *rgba;
char filename[512];
{
- pf_get_block(src_format, &src_block);
- assert(src_stride >= pf_get_stride(&src_block, width));
- assert(src_size >= pf_get_2d_size(&src_block, src_stride, width));
+ assert(src_stride >= util_format_get_stride(src_format, width));
}
{
- pf_get_block(dst_format, &dst_block);
- dst_stride = pf_get_stride(&dst_block, width);
- dst_size = pf_get_2d_size(&dst_block, dst_stride, width);
+ dst_stride = util_format_get_stride(dst_format, width);
+ dst_size = util_format_get_2d_size(dst_format, dst_stride, width);
rgba = MALLOC(dst_size);
}
if (!dst->texture || !src->texture)
return;
- is_depth = pf_get_component_bits(src->format, PIPE_FORMAT_COMP_Z) != 0;
- is_stencil = pf_get_component_bits(src->format, PIPE_FORMAT_COMP_S) != 0;
+ is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
+ is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
PIPE_TEXTURE_USAGE_RENDER_TARGET;
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_string.h"
#include "util/u_stream.h"
debug_dump_image(prefix,
texture->format,
- pf_get_blocksize(texture->format),
- pf_get_nblocksx(texture->format, transfer->width),
- pf_get_nblocksy(texture->format, transfer->height),
+ util_format_get_blocksize(texture->format),
+ util_format_get_nblocksx(texture->format, transfer->width),
+ util_format_get_nblocksy(texture->format, transfer->height),
transfer->stride,
data);
* Return total bits needed for the pixel format.
*/
static INLINE uint
-util_format_get_bits(enum pipe_format format)
+util_format_get_blocksizebits(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
* Return bytes per pixel for the given format.
*/
static INLINE uint
-util_format_get_size(enum pipe_format format)
+util_format_get_blocksize(enum pipe_format format)
{
- uint bits = util_format_get_bits(format);
+ uint bits = util_format_get_blocksizebits(format);
assert(bits % 8 == 0);
return bits / 8;
}
+static INLINE uint
+util_format_get_blockwidth(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 1;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_YUV:
+ return 2;
+ case UTIL_FORMAT_LAYOUT_DXT:
+ return 4;
+ default:
+ return 1;
+ }
+}
+
+static INLINE uint
+util_format_get_blockheight(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 1;
+ }
+
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_DXT:
+ return 4;
+ default:
+ return 1;
+ }
+}
+
+static INLINE unsigned
+util_format_get_nblocksx(enum pipe_format format,
+ unsigned x)
+{
+ unsigned blockwidth = util_format_get_blockwidth(format);
+ return (x + blockwidth - 1) / blockwidth;
+}
+
+static INLINE unsigned
+util_format_get_nblocksy(enum pipe_format format,
+ unsigned y)
+{
+ unsigned blockheight = util_format_get_blockheight(format);
+ return (y + blockheight - 1) / blockheight;
+}
+
+static INLINE unsigned
+util_format_get_nblocks(enum pipe_format format,
+ unsigned width,
+ unsigned height)
+{
+ return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
+}
+
+static INLINE size_t
+util_format_get_stride(enum pipe_format format,
+ unsigned width)
+{
+ return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
+}
+
+static INLINE size_t
+util_format_get_2d_size(enum pipe_format format,
+ size_t stride,
+ unsigned height)
+{
+ return util_format_get_nblocksy(format, height) * stride;
+}
+
static INLINE uint
util_format_get_component_bits(enum pipe_format format,
enum util_format_colorspace colorspace,
{
enum dtype datatype;
uint comps;
- const int bpt = util_format_get_size(pformat);
+ const int bpt = util_format_get_blocksize(pformat);
const ubyte *srcA, *srcB;
ubyte *dst;
int row;
int dstWidth, int dstHeight, int dstDepth,
int dstRowStride, ubyte *dstPtr)
{
- const int bpt = util_format_get_size(pformat);
+ const int bpt = util_format_get_blocksize(pformat);
const int border = 0;
int img, row;
int bytesPerSrcImage, bytesPerDstImage;
const uint zslice = 0;
uint dstLevel;
- assert(pf_get_blockwidth(pt->format) == 1);
- assert(pf_get_blockheight(pt->format) == 1);
+ assert(util_format_get_blockwidth(pt->format) == 1);
+ assert(util_format_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
- assert(pf_get_blockwidth(pt->format) == 1);
- assert(pf_get_blockheight(pt->format) == 1);
+ assert(util_format_get_blockwidth(pt->format) == 1);
+ assert(util_format_get_blockheight(pt->format) == 1);
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
{
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);
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
assert(blocksize > 0);
assert(blockwidth > 0);
{
unsigned i, j;
unsigned width_size;
- int blocksize = pf_get_blocksize(format);
- int blockwidth = pf_get_blockwidth(format);
- int blockheight = pf_get_blockheight(format);
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
assert(blocksize > 0);
assert(blockwidth > 0);
PIPE_TRANSFER_WRITE,
dst_x, dst_y, w, h);
- 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));
+ assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
+ assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
+ assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
src_map = pipe->screen->transfer_map(screen, src_trans);
dst_map = pipe->screen->transfer_map(screen, dst_trans);
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (pf_get_blocksize(dst_trans->texture->format)) {
+ switch (util_format_get_blocksize(dst_trans->texture->format)) {
case 1:
case 2:
case 4:
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
const void *src;
if (dst_stride == 0)
- dst_stride = pf_get_stride(pt->texture->format, w);
+ dst_stride = util_format_get_stride(pt->texture->format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
enum pipe_format format = pt->texture->format;
if (src_stride == 0)
- src_stride = pf_get_stride(format, w);
+ src_stride = util_format_get_stride(format, w);
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(format, w, h) * pf_get_blocksize(format));
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
if (!packed)
return;
if (pipe_clip_tile(x, y, &w, &h, pt))
return;
- packed = MALLOC(pf_get_nblocks(format, w, h) * pf_get_blocksize(format));
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
if (!packed)
return;
assert(r);
assert(blocks);
- tex_pitch = r->tex_transfer[0]->stride / pf_get_blocksize(r->tex_transfer[0]->texture->format);
+ tex_pitch = r->tex_transfer[0]->stride / util_format_get_blocksize(r->tex_transfer[0]->texture->format);
texels = r->texels[0] + mbpy * tex_pitch + mbpx;
for (y = 0; y < 2; ++y) {
mbpy /= 2;
for (tb = 0; tb < 2; ++tb) {
- tex_pitch = r->tex_transfer[tb + 1]->stride / pf_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
+ tex_pitch = r->tex_transfer[tb + 1]->stride / util_format_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
if ((cbp >> (1 - tb)) & 1) {
w_tile = align(width, TILE_SIZE);
h_tile = align(height, TILE_SIZE);
- ct->stride[level] = pf_get_stride(pt->format, w_tile);
+ ct->stride[level] = util_format_get_stride(pt->format, w_tile);
ct->level_offset[level] = ct->buffer_size;
- size = ct->stride[level] * pf_get_nblocksy(pt->format, h_tile);
+ size = ct->stride[level] * util_format_get_nblocksy(pt->format, h_tile);
if (pt->target == PIPE_TEXTURE_CUBE)
size *= 6;
else
if (pt->target == PIPE_TEXTURE_CUBE) {
unsigned h_tile = align(ps->height, TILE_SIZE);
- ps->offset += face * pf_get_nblocksy(ps->format, h_tile) * ct->stride[level];
+ ps->offset += face * util_format_get_nblocksy(ps->format, h_tile) * ct->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
unsigned h_tile = align(ps->height, TILE_SIZE);
- ps->offset += zslice * pf_get_nblocksy(ps->format, h_tile) * ct->stride[level];
+ ps->offset += zslice * util_format_get_nblocksy(ps->format, h_tile) * ct->stride[level];
}
else {
assert(face == 0);
if (texture->target == PIPE_TEXTURE_CUBE) {
unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
- ctrans->offset += face * pf_get_nblocksy(texture->format, h_tile) * pt->stride;
+ ctrans->offset += face * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
- ctrans->offset += zslice * pf_get_nblocksy(texture->format, h_tile) * pt->stride;
+ ctrans->offset += zslice * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
}
else {
assert(face == 0);
* Create a buffer of ordinary memory for the linear texture.
* This is the memory that the user will read/write.
*/
- size = pf_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
- pf_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));
+ size = util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
+ util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));
ctrans->map = align_malloc(size, 16);
if (!ctrans->map)
if (transfer->usage & PIPE_TRANSFER_READ) {
/* need to untwiddle the texture to make a linear version */
- const uint bpp = util_format_get_size(ct->base.format);
+ const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = (uint *) (ct->mapped + ctrans->offset);
uint *dst = ctrans->map;
/* 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 = util_format_get_size(ct->base.format);
+ const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = ctrans->map;
uint *dst = (uint *) (ct->mapped + ctrans->offset);
#include "pipe/p_inlines.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_format.h"
#include "util/u_tile.h"
#include "util/u_rect.h"
struct pipe_texture *spt = &src_tex->base;
assert( dst != src );
- 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 );
+ assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
+ assert( util_format_get_blockwidth(dpt->format) == util_format_get_blockwidth(spt->format) );
+ assert( util_format_get_blockheight(dpt->format) == util_format_get_blockheight(spt->format) );
+ assert( util_format_get_blockwidth(dpt->format) == 1 );
+ assert( util_format_get_blockheight(dpt->format) == 1 );
i915_copy_blit( i915_context(pipe),
FALSE,
- pf_get_blocksize(dpt->format),
+ util_format_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 );
struct i915_texture *tex = (struct i915_texture *)dst->texture;
struct pipe_texture *pt = &tex->base;
- assert(pf_get_blockwidth(pt->format) == 1);
- assert(pf_get_blockheight(pt->format) == 1);
+ assert(util_format_get_blockwidth(pt->format) == 1);
+ assert(util_format_get_blockheight(pt->format) == 1);
i915_fill_blit( i915_context(pipe),
- pf_get_blocksize(pt->format),
+ util_format_get_blocksize(pt->format),
(unsigned short) tex->stride,
tex->buffer, dst->offset,
(short) dstx, (short) dsty,
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
assert(img < tex->nr_images[level]);
- tex->image_offset[level][img] = y * tex->stride + x * pf_get_blocksize(tex->base.format);
+ tex->image_offset[level][img] = y * tex->stride + x * util_format_get_blocksize(tex->base.format);
/*
printf("%s level %d img %d pos %d,%d image_offset %x\n",
{
struct pipe_texture *pt = &tex->base;
- if (pt->last_level > 0 || pf_get_blocksize(pt->format) != 4)
+ if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
return FALSE;
i915_miptree_set_level_info(tex, 0, 1,
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
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->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
tex->hw_tiled = INTEL_TILE_X;
} 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);
+ tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
} else {
return FALSE;
}
debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
- pt->width0, pt->height0, pf_get_blocksize(pt->format),
+ pt->width0, pt->height0, util_format_get_blocksize(pt->format),
tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
return TRUE;
{
struct pipe_texture *pt = &tex->base;
- if (pt->last_level > 0 || pf_get_blocksize(pt->format) != 4)
+ if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
return FALSE;
/* fallback to normal textures for small textures */
1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- 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->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
+ tex->total_nblocksy = align(util_format_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__,
- pt->width0, pt->height0, pf_get_blocksize(pt->format),
+ pt->width0, pt->height0, util_format_get_blocksize(pt->format),
tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
return TRUE;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
- unsigned nblocksy = pf_get_nblocksy(pt->format, pt->width0);
+ unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
/* used for scanouts that need special layouts */
if (pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
if (i915_display_target_layout(tex))
return;
- tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
+ tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksy = pf_get_nblocksy(pt->format, height);
+ nblocksy = util_format_get_nblocksy(pt->format, height);
}
}
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned depth = pt->depth0;
- unsigned nblocksy = pf_get_nblocksy(pt->format, pt->height0);
+ unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
unsigned stack_nblocksy = 0;
/* Calculate the size of a single slice.
*/
- tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
+ tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
/* XXX: hardware expects/requires 9 levels at minimum.
*/
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksy = pf_get_nblocksy(pt->format, height);
+ nblocksy = util_format_get_nblocksy(pt->format, height);
}
/* Fixup depth image_offsets:
{
struct pipe_texture *pt = &tex->base;
unsigned width = pt->width0, height = pt->height0;
- const unsigned nblocks = pf_get_nblocksx(pt->format, pt->width0);
+ const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
unsigned level;
unsigned face;
assert(width == height); /* cubemap images are square */
/* double pitch for cube layouts */
- tex->stride = align(nblocks * pf_get_blocksize(pt->format) * 2, 4);
+ tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4);
tex->total_nblocksy = nblocks * 4;
for (level = 0; level <= pt->last_level; level++) {
unsigned y = 0;
unsigned width = pt->width0;
unsigned height = pt->height0;
- unsigned nblocksx = pf_get_nblocksx(pt->format, pt->width0);
- unsigned nblocksy = pf_get_nblocksy(pt->format, pt->height0);
+ unsigned nblocksx = util_format_get_nblocksx(pt->format, pt->width0);
+ unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
/* used for scanouts that need special layouts */
if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
if (i915_display_target_layout(tex))
return;
- tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
+ tex->stride = align(util_format_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
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align(pf_get_nblocksx(pt->format, u_minify(width, 1)), align_x)
- + pf_get_nblocksx(pt->format, u_minify(width, 2));
+ = align(util_format_get_nblocksx(pt->format, u_minify(width, 1)), align_x)
+ + util_format_get_nblocksx(pt->format, u_minify(width, 2));
if (mip1_nblocksx > nblocksx)
- tex->stride = mip1_nblocksx * pf_get_blocksize(pt->format);
+ tex->stride = mip1_nblocksx * util_format_get_blocksize(pt->format);
}
/* Pitch must be a whole number of dwords
width = u_minify(width, 1);
height = u_minify(height, 1);
- nblocksx = pf_get_nblocksx(pt->format, width);
- nblocksy = pf_get_nblocksy(pt->format, height);
+ nblocksx = util_format_get_nblocksx(pt->format, width);
+ nblocksy = util_format_get_nblocksy(pt->format, height);
}
}
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned depth = pt->depth0;
- unsigned nblocksy = pf_get_nblocksy(pt->format, pt->width0);
+ unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
unsigned pack_x_pitch, pack_x_nr;
unsigned pack_y_pitch;
unsigned level;
- tex->stride = align(pf_get_stride(pt->format, pt->width0), 4);
+ tex->stride = align(util_format_get_stride(pt->format, pt->width0), 4);
tex->total_nblocksy = 0;
pack_y_pitch = MAX2(nblocksy, 2);
- pack_x_pitch = tex->stride / pf_get_blocksize(pt->format);
+ pack_x_pitch = tex->stride / util_format_get_blocksize(pt->format);
pack_x_nr = 1;
for (level = 0; level <= pt->last_level; level++) {
if (pack_x_pitch > 4) {
pack_x_pitch >>= 1;
pack_x_nr <<= 1;
- assert(pack_x_pitch * pack_x_nr * pf_get_blocksize(pt->format) <= tex->stride);
+ assert(pack_x_pitch * pack_x_nr * util_format_get_blocksize(pt->format) <= tex->stride);
}
if (pack_y_pitch > 2) {
width = u_minify(width, 1);
height = u_minify(height, 1);
depth = u_minify(depth, 1);
- nblocksy = pf_get_nblocksy(pt->format, height);
+ nblocksy = util_format_get_nblocksy(pt->format, height);
}
}
struct pipe_texture *pt = &tex->base;
unsigned level;
- const unsigned nblocks = pf_get_nblocksx(pt->format, pt->width0);
+ const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
unsigned face;
unsigned width = pt->width0;
unsigned height = pt->height0;
* or the final row of 4x4, 2x2 and 1x1 faces below this.
*/
if (nblocks > 32)
- tex->stride = align(nblocks * pf_get_blocksize(pt->format) * 2, 4);
+ tex->stride = align(nblocks * util_format_get_blocksize(pt->format) * 2, 4);
else
- tex->stride = 14 * 8 * pf_get_blocksize(pt->format);
+ tex->stride = 14 * 8 * util_format_get_blocksize(pt->format);
tex->total_nblocksy = nblocks * 4;
return NULL;
return map + i915_transfer(transfer)->offset +
- transfer->y / pf_get_blockheight(format) * transfer->stride +
- transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
+ transfer->y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
static void
#include "draw/draw_vertex.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_thread.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "lp_bld_debug.h"
assert((y % 2) == 0);
depth = llvmpipe->zsbuf_map +
y*llvmpipe->zsbuf_transfer->stride +
- 2*x*pf_get_blocksize(llvmpipe->zsbuf_transfer->texture->format);
+ 2*x*util_format_get_blocksize(llvmpipe->zsbuf_transfer->texture->format);
}
else
depth = NULL;
/* 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->format, align(width, 2));
- nblocksy = pf_get_nblocksy(pt->format, align(height, 2));
+ nblocksx = util_format_get_nblocksx(pt->format, align(width, 2));
+ nblocksy = util_format_get_nblocksy(pt->format, align(height, 2));
- lpt->stride[level] = align(nblocksx * pf_get_blocksize(pt->format), 16);
+ lpt->stride[level] = align(nblocksx * util_format_get_blocksize(pt->format), 16);
lpt->level_offset[level] = buffer_size;
*/
if (pt->target == PIPE_TEXTURE_CUBE) {
unsigned tex_height = ps->height;
- ps->offset += face * pf_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
+ ps->offset += face * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
unsigned tex_height = ps->height;
- ps->offset += zslice * pf_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
+ ps->offset += zslice * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
}
else {
assert(face == 0);
*/
if (texture->target == PIPE_TEXTURE_CUBE) {
unsigned tex_height = u_minify(texture->height0, level);
- lpt->offset += face * pf_get_nblocksy(texture->format, tex_height) * pt->stride;
+ lpt->offset += face * util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
unsigned tex_height = u_minify(texture->height0, level);
- lpt->offset += zslice * pf_get_nblocksy(texture->format, tex_height) * pt->stride;
+ lpt->offset += zslice * util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
}
else {
assert(face == 0);
}
xfer_map = map + llvmpipe_transfer(transfer)->offset +
- transfer->y / pf_get_blockheight(format) * transfer->stride +
- transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
+ transfer->y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
return xfer_map;
}
#include "pipe/p_context.h"
#include "pipe/p_format.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
sub_w = MIN2(sub_w, w - x);
/* Must be 64-byte aligned */
- assert(!((dst->offset + nv04_swizzle_bits(dx+x, dy+y) * pf_get_blocksize(dst->texture->format)) & 63));
+ assert(!((dst->offset + nv04_swizzle_bits(dx+x, dy+y) * util_format_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) * pf_get_blocksize(dst->texture->format),
+ OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(dx+x, dy+y) * util_format_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);
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) * pf_get_blocksize(src->texture->format),
+ OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
}
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 * pf_get_blocksize(dst->texture->format);
+ dx * util_format_get_blocksize(dst->texture->format);
unsigned src_offset = src->offset + sy * src_pitch +
- sx * pf_get_blocksize(src->texture->format);
+ sx * util_format_get_blocksize(src->texture->format);
MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2);
BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
OUT_RING (chan, src_pitch);
OUT_RING (chan, dst_pitch);
- OUT_RING (chan, w * pf_get_blocksize(src->texture->format));
+ OUT_RING (chan, w * util_format_get_blocksize(src->texture->format));
OUT_RING (chan, count);
OUT_RING (chan, 0x0101);
OUT_RING (chan, 0);
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <nouveau/nouveau_winsys.h>
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
+ ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
}
static void
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "nv10_context.h"
for (l = 0; l <= pt->last_level; l++) {
if (swizzled)
- nv10mt->level[l].pitch = pf_get_stride(pt->format, width);
+ nv10mt->level[l].pitch = util_format_get_stride(pt->format, width);
else
- nv10mt->level[l].pitch = pf_get_stride(pt->format, pt->width0);
+ nv10mt->level[l].pitch = util_format_get_stride(pt->format, pt->width0);
nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
nv10mt->level[l].image_offset =
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <nouveau/nouveau_winsys.h>
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
+ ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
}
static void
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "nv20_context.h"
for (l = 0; l <= pt->last_level; l++) {
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- nv20mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
+ nv20mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
else
- nv20mt->level[l].pitch = pf_get_stride(pt->format, width);
+ nv20mt->level[l].pitch = util_format_get_stride(pt->format, width);
nv20mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <nouveau/nouveau_winsys.h>
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
+ ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
}
static void
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "nv30_context.h"
for (l = 0; l <= pt->last_level; l++) {
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- nv30mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
+ nv30mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
else
- nv30mt->level[l].pitch = pf_get_stride(pt->format, width);
+ nv30mt->level[l].pitch = util_format_get_stride(pt->format, width);
nv30mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <nouveau/nouveau_winsys.h>
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
+ ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
}
static void
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "nv40_context.h"
for (l = 0; l <= pt->last_level; l++) {
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
- mt->level[l].pitch = align(pf_get_stride(pt->format, pt->width0), 64);
+ mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
else
- mt->level[l].pitch = pf_get_stride(pt->format, width);
+ mt->level[l].pitch = util_format_get_stride(pt->format, width);
mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
#include <pipe/p_state.h>
#include <pipe/p_defines.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <nouveau/nouveau_winsys.h>
pipe_transfer_buffer_flags(ptx));
return map + ns->base.offset +
- ptx->y * ns->pitch + ptx->x * pf_get_blocksize(ptx->texture->format);
+ ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
}
static void
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "nv50_context.h"
for (l = 0; l <= pt->last_level; l++) {
struct nv50_miptree_level *lvl = &mt->level[l];
- unsigned nblocksy = pf_get_nblocksy(pt->format, height);
+ unsigned nblocksy = util_format_get_nblocksy(pt->format, height);
lvl->image_offset = CALLOC(mt->image_nr, sizeof(int));
- lvl->pitch = align(pf_get_stride(pt->format, width), 64);
+ lvl->pitch = align(util_format_get_stride(pt->format, width), 64);
lvl->tile_mode = get_tile_mode(nblocksy, depth);
width = u_minify(width, 1);
unsigned tile_d = get_tile_depth(lvl->tile_mode);
size = lvl->pitch;
- size *= align(pf_get_nblocksy(pt->format, u_minify(pt->height0, l)), tile_h);
+ size *= align(util_format_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;
ps->offset = lvl->image_offset[img];
if (pt->target == PIPE_TEXTURE_3D) {
- unsigned nb_h = pf_get_nblocksy(pt->format, ps->height);
+ unsigned nb_h = util_format_get_nblocksy(pt->format, ps->height);
ps->offset += get_zslice_offset(lvl->tile_mode, zslice,
lvl->pitch, nb_h);
}
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "nv50_context.h"
return NULL;
pipe_texture_reference(&tx->base.texture, pt);
- 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->nblocksx = util_format_get_nblocksx(pt->format, u_minify(pt->width0, level));
+ tx->nblocksy = util_format_get_nblocksy(pt->format, u_minify(pt->height0, level));
tx->base.width = w;
tx->base.height = h;
- tx->base.stride = tx->nblocksx * pf_get_blocksize(pt->format);
+ tx->base.stride = tx->nblocksx * util_format_get_blocksize(pt->format);
tx->base.usage = usage;
tx->level_pitch = lvl->pitch;
tx->level_offset = lvl->image_offset[image];
tx->level_tiling = lvl->tile_mode;
tx->level_z = zslice;
- tx->level_x = pf_get_nblocksx(pt->format, x);
- tx->level_y = pf_get_nblocksy(pt->format, y);
+ tx->level_x = util_format_get_nblocksx(pt->format, x);
+ tx->level_y = util_format_get_nblocksy(pt->format, y);
ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
tx->nblocksy * tx->base.stride, &tx->bo);
if (ret) {
}
if (usage & PIPE_TRANSFER_READ) {
- nx = pf_get_nblocksx(pt->format, tx->base.width);
- ny = pf_get_nblocksy(pt->format, tx->base.height);
+ nx = util_format_get_nblocksx(pt->format, tx->base.width);
+ ny = util_format_get_nblocksy(pt->format, tx->base.height);
nv50_transfer_rect_m2mf(pscreen, mt->base.bo, tx->level_offset,
tx->level_pitch, tx->level_tiling,
tx->base.stride, tx->bo->tile_mode,
0, 0, 0,
tx->nblocksx, tx->nblocksy, 1,
- pf_get_blocksize(pt->format), nx, ny,
+ util_format_get_blocksize(pt->format), nx, ny,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
NOUVEAU_BO_GART);
}
struct nv50_miptree *mt = nv50_miptree(ptx->texture);
struct pipe_texture *pt = ptx->texture;
- unsigned nx = pf_get_nblocksx(pt->format, tx->base.width);
- unsigned ny = pf_get_nblocksy(pt->format, tx->base.height);
+ unsigned nx = util_format_get_nblocksx(pt->format, tx->base.width);
+ unsigned ny = util_format_get_nblocksy(pt->format, tx->base.height);
if (ptx->usage & PIPE_TRANSFER_WRITE) {
struct pipe_screen *pscreen = pt->screen;
tx->level_x, tx->level_y, tx->level_z,
tx->nblocksx, tx->nblocksy,
tx->level_depth,
- pf_get_blocksize(pt->format), nx, ny,
+ util_format_get_blocksize(pt->format), nx, ny,
NOUVEAU_BO_GART, NOUVEAU_BO_VRAM |
NOUVEAU_BO_GART);
}
/* Check if formats and strides are aligned to the size of DWORD. */
for (i = 0; i < r300->vertex_element_count; i++) {
if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 ||
- pf_get_blocksize(velem[i].src_format) % 4 != 0) {
+ util_format_get_blocksize(velem[i].src_format) % 4 != 0) {
return FALSE;
}
}
for (i = 0; i < aos_count - 1; i += 2) {
vb1 = &vbuf[velem[i].vertex_buffer_index];
vb2 = &vbuf[velem[i+1].vertex_buffer_index];
- size1 = util_format_get_size(velem[i].src_format);
- size2 = util_format_get_size(velem[i+1].src_format);
+ size1 = util_format_get_blocksize(velem[i].src_format);
+ size2 = util_format_get_blocksize(velem[i+1].src_format);
OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride) |
R300_VBPNTR_SIZE1(size2) | R300_VBPNTR_STRIDE1(vb2->stride));
if (aos_count & 1) {
vb1 = &vbuf[velem[i].vertex_buffer_index];
- size1 = util_format_get_size(velem[i].src_format);
+ size1 = util_format_get_blocksize(velem[i].src_format);
OUT_CS(R300_VBPNTR_SIZE0(size1) | R300_VBPNTR_STRIDE0(vb1->stride));
OUT_CS(vb1->buffer_offset + velem[i].src_offset + offset * vb1->stride);
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_simple_screen.h"
}
return map + r300_transfer(transfer)->offset +
- transfer->y / pf_get_blockheight(format) * transfer->stride +
- transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
+ transfer->y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
static void r300_transfer_unmap(struct pipe_screen* screen,
return 0;
}
- return align(pf_get_stride(tex->tex.format, u_minify(tex->tex.width0, level)), 32);
+ return align(util_format_get_stride(tex->tex.format, u_minify(tex->tex.width0, level)), 32);
}
static void r300_setup_miptree(struct r300_texture* tex)
int i;
for (i = 0; i <= base->last_level; i++) {
- unsigned nblocksy = pf_get_nblocksy(base->format, u_minify(base->height0, i));
+ unsigned nblocksy = util_format_get_nblocksy(base->format, u_minify(base->height0, i));
stride = r300_texture_get_stride(tex, i);
layer_size = stride * nblocksy;
tex->offset[i] = align(tex->size, 32);
tex->size = tex->offset[i] + size;
tex->layer_size[i] = layer_size;
- tex->pitch[i] = stride / pf_get_blocksize(base->format);
+ tex->pitch[i] = stride / util_format_get_blocksize(base->format);
debug_printf("r300: Texture miptree: Level %d "
"(%dx%dx%d px, pitch %d bytes)\n",
tex->tex.screen = screen;
tex->stride_override = *stride;
- tex->pitch[0] = *stride / pf_get_blocksize(base->format);
+ tex->pitch[0] = *stride / util_format_get_blocksize(base->format);
r300_setup_flags(tex);
r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500);
pt->depth0 = depth;
for (level = 0; level <= pt->last_level; level++) {
- spt->stride[level] = pf_get_stride(pt->format, width);
+ spt->stride[level] = util_format_get_stride(pt->format, width);
spt->level_offset[level] = buffer_size;
- buffer_size += (pf_get_nblocksy(pt->format, height) *
+ buffer_size += (util_format_get_nblocksy(pt->format, height) *
((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
spt->stride[level]);
ps->zslice = zslice;
if (pt->target == PIPE_TEXTURE_CUBE) {
- ps->offset += face * pf_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+ ps->offset += face * util_format_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
spt->stride[level];
}
else if (pt->target == PIPE_TEXTURE_3D) {
- ps->offset += zslice * pf_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
+ ps->offset += zslice * util_format_get_nblocksy(pt->format, u_minify(pt->height0, level)) *
spt->stride[level];
}
else {
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));
+ int nblocksy = util_format_get_nblocksy(texture->format, u_minify(texture->height0, level));
pipe_texture_reference(&pt->texture, texture);
pt->x = x;
pt->y = y;
}
xfer_map = map + softpipe_transfer(transfer)->offset +
- transfer->y / pf_get_blockheight(format) * transfer->stride +
- transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
+ transfer->y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
return xfer_map;
}
{
uint i, j;
- switch (util_format_get_size(format)) {
+ switch (util_format_get_blocksize(format)) {
case 1:
memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
break;
st->base.x + st->base.width,
y + h,
st->base.zslice + 1,
- pf_get_blocksize(texture->base.format)*8/
- (pf_get_blockwidth(texture->base.format)*pf_get_blockheight(texture->base.format)));
+ util_format_get_blocksize(texture->base.format)*8/
+ (util_format_get_blockwidth(texture->base.format)*util_format_get_blockheight(texture->base.format)));
box.x = st->base.x;
box.y = y;
}
else {
unsigned y, h, srcy;
- unsigned blockheight = pf_get_blockheight(st->base.texture->format);
+ unsigned blockheight = util_format_get_blockheight(st->base.texture->format);
h = st->hw_nblocksy * blockheight;
srcy = 0;
for(y = 0; y < st->base.height; y += h) {
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);
+ unsigned nblocksx = util_format_get_nblocksx(texture->format, w);
+ unsigned nblocksy = util_format_get_nblocksy(texture->format, h);
/* We can't map texture storage directly */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
st->base.y = y;
st->base.width = w;
st->base.height = h;
- st->base.stride = nblocksx*pf_get_blocksize(texture->format);
+ st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
st->base.usage = usage;
st->base.face = face;
st->base.level = level;
svga_translate_format(texture->format),
stex->handle);
- *stride = pf_get_stride(texture->format, texture->width0);
+ *stride = util_format_get_stride(texture->format, texture->width0);
return *buffer != NULL;
}
mapped_buffer = pipe_buffer_map_range(svga->pipe.screen,
vbuffer->buffer,
vel->src_offset,
- util_format_get_size(vel->src_format),
+ util_format_get_blocksize(vel->src_format),
PIPE_BUFFER_USAGE_CPU_READ);
translate->set_buffer(translate, vel->vertex_buffer_index,
mapped_buffer,
**************************************************************************/
+#include "util/u_format.h"
#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
&t->width0, 1,
&t->height0, 1,
&t->depth0, 1,
- pf_get_blockwidth(t->format),
- pf_get_blockheight(t->format),
- pf_get_blocksize(t->format),
+ util_format_get_blockwidth(t->format),
+ util_format_get_blockheight(t->format),
+ util_format_get_blocksize(t->format),
t->last_level,
t->nr_samples,
t->tex_usage,
rbug_send_texture_read_reply(tr_rbug->con, serial,
t->texture->format,
- pf_get_blockwidth(t->texture->format),
- pf_get_blockheight(t->texture->format),
- pf_get_blocksize(t->texture->format),
+ util_format_get_blockwidth(t->texture->format),
+ util_format_get_blockheight(t->texture->format),
+ util_format_get_blocksize(t->texture->format),
(uint8_t*)map,
- t->stride * pf_get_nblocksy(t->texture->format, t->height),
+ t->stride * util_format_get_nblocksy(t->texture->format, t->height),
t->stride,
NULL);
*
**************************************************************************/
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
struct pipe_transfer *transfer = tr_trans->transfer;
if(tr_trans->map) {
- size_t size = pf_get_nblocksy(transfer->texture->format, transfer->width) * transfer->stride;
+ size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->width) * transfer->stride;
trace_dump_call_begin("pipe_screen", "transfer_write");
*/
extern const char *pf_name( enum pipe_format format );
-/**
- * Return bits for a particular component.
- * \param comp component index, starting at 0
- */
-static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
-{
- uint size;
-
- if (pf_swizzle_x(format) == comp) {
- size = pf_size_x(format);
- }
- else if (pf_swizzle_y(format) == comp) {
- size = pf_size_y(format);
- }
- else if (pf_swizzle_z(format) == comp) {
- size = pf_size_z(format);
- }
- else if (pf_swizzle_w(format) == comp) {
- size = pf_size_w(format);
- }
- else {
- size = 0;
- }
- if (pf_layout( format ) == PIPE_FORMAT_LAYOUT_RGBAZS)
- return size << pf_exp2( format );
- return size << (pf_mixed_scale8( format ) * 3);
-}
-
-
-/**
- * Return total bits needed for the pixel format per block.
- */
-static INLINE uint pf_get_blocksizebits( enum pipe_format format )
-{
- switch (pf_layout(format)) {
- case PIPE_FORMAT_LAYOUT_RGBAZS:
- case PIPE_FORMAT_LAYOUT_MIXED:
- return
- pf_get_component_bits( format, PIPE_FORMAT_COMP_0 ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_1 ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_R ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_G ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_B ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
- 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 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;
- }
-}
-
-/**
- * Return bytes per element for the given format.
- */
-static INLINE uint pf_get_blocksize( enum pipe_format format )
-{
- assert(pf_get_blocksizebits(format) % 8 == 0);
- return pf_get_blocksizebits(format) / 8;
-}
-
-static INLINE uint pf_get_blockwidth( enum pipe_format format )
-{
- switch (pf_layout(format)) {
- case PIPE_FORMAT_LAYOUT_YCBCR:
- return 2;
- case PIPE_FORMAT_LAYOUT_DXT:
- return 4;
- default:
- return 1;
- }
-}
-
-static INLINE uint pf_get_blockheight( enum pipe_format format )
-{
- switch (pf_layout(format)) {
- case PIPE_FORMAT_LAYOUT_DXT:
- return 4;
- default:
- return 1;
- }
-}
-
-static INLINE unsigned
-pf_get_nblocksx(enum pipe_format format, unsigned x)
-{
- unsigned blockwidth = pf_get_blockwidth(format);
- return (x + blockwidth - 1) / blockwidth;
-}
-
-static INLINE unsigned
-pf_get_nblocksy(enum pipe_format format, unsigned y)
-{
- unsigned blockheight = pf_get_blockheight(format);
- return (y + blockheight - 1) / blockheight;
-}
-
-static INLINE unsigned
-pf_get_nblocks(enum pipe_format format, unsigned width, unsigned height)
-{
- return pf_get_nblocksx(format, width) * pf_get_nblocksy(format, height);
-}
-
-static INLINE size_t
-pf_get_stride(enum pipe_format format, unsigned width)
-{
- return pf_get_nblocksx(format, width) * pf_get_blocksize(format);
-}
-
-static INLINE size_t
-pf_get_2d_size(enum pipe_format format, size_t stride, unsigned height)
-{
- return pf_get_nblocksy(format, height) * stride;
-}
enum pipe_video_chroma_format
{
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_tile.h"
#include "util/u_math.h"
#include "util/u_memory.h"
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, pf_get_blocksize(format));
+ memcpy(raw, data[i].raw, util_format_get_blocksize(format));
}
{
unsigned i;
unsigned x, y, ch;
- int blocksize = pf_get_blocksize(format);
+ int blocksize = util_format_get_blocksize(format);
for(i = 0; i < blocksize; ++i)
raw[i] = (uint8_t)st_random();
if (raw) {
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);
+ int nblocksx = util_format_get_nblocksx(format, width);
+ int nblocksy = util_format_get_nblocksy(format, height);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
+ int blocksize = util_format_get_blocksize(format);
for (y = 0; y < nblocksy; ++y) {
const unsigned alignment = 64;
unsigned nblocksy;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
return false;
*handle = mt->bo->handle;
- *stride = pf_get_stride(mt->base.format, mt->base.width0);
+ *stride = util_format_get_stride(mt->base.format, mt->base.width0);
return true;
}
#include "radeon_bo_gem.h"
#include "softpipe/sp_texture.h"
#include "r300_context.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include <X11/Xutil.h>
const unsigned alignment = 64;
unsigned nblocksy, size;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
size = *stride * nblocksy;
return radeon_buffer_create(ws, 64, usage, size);
const unsigned alignment = 64;
unsigned nblocksy;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
const unsigned int ALIGNMENT = 1;
unsigned nblocksy;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), ALIGNMENT);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), ALIGNMENT);
return pws->buffer_create(pws, ALIGNMENT, usage,
*stride * nblocksy);
gdt->width = width;
gdt->height = height;
- bpp = util_format_get_bits(format);
- cpp = util_format_get_size(format);
+ bpp = util_format_get_blocksizebits(format);
+ cpp = util_format_get_blocksize(format);
gdt->stride = align(width * cpp, alignment);
gdt->size = gdt->stride * height;
const unsigned alignment = 64;
unsigned nblocksy;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_size(surface->format);
+ bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_blocksize(surface->format);
bmi.bmiHeader.biHeight= -(long)surface->height;
bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = util_format_get_bits(surface->format);
+ bmi.bmiHeader.biBitCount = util_format_get_blocksizebits(surface->format);
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter = 0;
const unsigned alignment = 64;
unsigned nblocksy;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
{
if (xm_dt->tempImage == NULL)
{
- assert(pf_get_blockwidth(xm_dt->format) == 1);
- assert(pf_get_blockheight(xm_dt->format) == 1);
+ assert(util_format_get_blockwidth(xm_dt->format) == 1);
+ assert(util_format_get_blockheight(xm_dt->format) == 1);
alloc_shm_ximage(xm_dt, xm_buffer,
- xm_dt->stride / pf_get_blocksize(xm_dt->format),
+ xm_dt->stride / util_format_get_blocksize(xm_dt->format),
xm_dt->height);
}
xm_dt->width = width;
xm_dt->height = height;
- nblocksy = pf_get_nblocksy(format, height);
- xm_dt->stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ xm_dt->stride = align(util_format_get_stride(format, width), alignment);
size = xm_dt->stride * nblocksy;
#ifdef USE_XSHM
{
if (xm_buf->tempImage == NULL)
{
- assert(pf_get_blockwidth(surf->texture->format) == 1);
- assert(pf_get_blockheight(surf->texture->format) == 1);
+ assert(util_format_get_blockwidth(surf->texture->format) == 1);
+ assert(util_format_get_blockheight(surf->texture->format) == 1);
alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
- pf_get_blocksize(surf->texture->format), surf->height);
+ util_format_get_blocksize(surf->texture->format), surf->height);
}
ximage = xm_buf->tempImage;
const unsigned alignment = 64;
unsigned nblocksy, size;
- nblocksy = pf_get_nblocksy(format, height);
- *stride = align(pf_get_stride(format, width), alignment);
+ nblocksy = util_format_get_nblocksy(format, height);
+ *stride = align(util_format_get_stride(format, width), alignment);
size = *stride * nblocksy;
#ifdef USE_XSHM
usage, dstx, dsty,
width, height);
- assert(pf_get_blockwidth(ptDraw->texture->format) == 1);
- assert(pf_get_blockheight(ptDraw->texture->format) == 1);
+ assert(util_format_get_blockwidth(ptDraw->texture->format) == 1);
+ assert(util_format_get_blockheight(ptDraw->texture->format) == 1);
/* map the stencil buffer */
drawMap = screen->transfer_map(screen, ptDraw);
assert(strb->format != PIPE_FORMAT_NONE);
- strb->stride = pf_get_stride(strb->format, width);
- size = pf_get_2d_size(strb->format, strb->stride, height);
+ strb->stride = util_format_get_stride(strb->format, width);
+ size = util_format_get_2d_size(strb->format, strb->stride, height);
strb->data = _mesa_malloc(size);
/* copy/pack data into user buffer */
if (st_equal_formats(stImage->pt->format, format, type)) {
/* memcpy */
- const uint bytesPerRow = width * util_format_get_size(stImage->pt->format);
+ const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
ubyte *map = screen->transfer_map(screen, tex_xfer);
GLuint row;
for (row = 0; row < height; row++) {
PIPE_TRANSFER_READ, 0, 0,
stImage->base.Width,
stImage->base.Height);
- texImage->RowStride = stImage->transfer->stride / pf_get_blocksize(stImage->pt->format);
+ texImage->RowStride = stImage->transfer->stride / util_format_get_blocksize(stImage->pt->format);
}
else {
/* Otherwise, the image should actually be stored in
xoffset, yoffset,
width, height);
- srcBlockStride = pf_get_stride(pformat, width);
+ srcBlockStride = util_format_get_stride(pformat, width);
dstBlockStride = stImage->transfer->stride;
} else {
assert(stImage->pt);
return;
}
- assert(xoffset % pf_get_blockwidth(pformat) == 0);
- assert(yoffset % pf_get_blockheight(pformat) == 0);
- assert(width % pf_get_blockwidth(pformat) == 0);
- assert(height % pf_get_blockheight(pformat) == 0);
+ assert(xoffset % util_format_get_blockwidth(pformat) == 0);
+ assert(yoffset % util_format_get_blockheight(pformat) == 0);
+ assert(width % util_format_get_blockwidth(pformat) == 0);
+ assert(height % util_format_get_blockheight(pformat) == 0);
- for (y = 0; y < height; y += pf_get_blockheight(pformat)) {
+ for (y = 0; y < height; y += util_format_get_blockheight(pformat)) {
/* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
- const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(pformat, y);
- char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(pformat, y);
- memcpy(dst, src, pf_get_stride(pformat, width));
+ const char *src = (const char*)data + srcBlockStride * util_format_get_nblocksy(pformat, y);
+ char *dst = (char*)texImage->Data + dstBlockStride * util_format_get_nblocksy(pformat, y);
+ memcpy(dst, src, util_format_get_stride(pformat, width));
}
if (stImage->pt) {
dstLevel,
stImage->base.Data,
stImage->base.RowStride *
- pf_get_blocksize(stObj->pt->format),
+ util_format_get_blocksize(stObj->pt->format),
stImage->base.RowStride *
stImage->base.Height *
- pf_get_blocksize(stObj->pt->format));
+ util_format_get_blocksize(stObj->pt->format));
_mesa_align_free(stImage->base.Data);
stImage->base.Data = NULL;
}
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_gen_mipmap.h"
#include "util/u_math.h"
srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
- srcStride = srcTrans->stride / pf_get_blocksize(srcTrans->texture->format);
- dstStride = dstTrans->stride / pf_get_blocksize(dstTrans->texture->format);
+ srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format);
+ dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format);
_mesa_generate_mipmap_level(target, datatype, comps,
0 /*border*/,