gallium: interface cleanups, remove nblocksx/y from pipe_texture and more
This patch removes nblocksx, nblocksy arrays from pipe_texture (can be recalculated if needed). Furthermore, pipe_format_block struct is gone completely (again, contains just derived state). nblocksx, nblocksy, block are also removed from pipe_transfer, together with the format enum (can be obtained from the texture associated with the transfer).
This commit is contained in:
@@ -401,7 +401,6 @@ aaline_create_texture(struct aaline_stage *aaline)
|
|||||||
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
|
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
|
||||||
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
|
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
|
||||||
texTemp.depth0 = 1;
|
texTemp.depth0 = 1;
|
||||||
pf_get_block(texTemp.format, &texTemp.block);
|
|
||||||
|
|
||||||
aaline->texture = screen->texture_create(screen, &texTemp);
|
aaline->texture = screen->texture_create(screen, &texTemp);
|
||||||
if (!aaline->texture)
|
if (!aaline->texture)
|
||||||
|
@@ -430,7 +430,6 @@ pstip_create_texture(struct pstip_stage *pstip)
|
|||||||
texTemp.width0 = 32;
|
texTemp.width0 = 32;
|
||||||
texTemp.height0 = 32;
|
texTemp.height0 = 32;
|
||||||
texTemp.depth0 = 1;
|
texTemp.depth0 = 1;
|
||||||
pf_get_block(texTemp.format, &texTemp.block);
|
|
||||||
|
|
||||||
pstip->texture = screen->texture_create(screen, &texTemp);
|
pstip->texture = screen->texture_create(screen, &texTemp);
|
||||||
if (pstip->texture == NULL)
|
if (pstip->texture == NULL)
|
||||||
|
@@ -357,7 +357,6 @@ util_blit_pixels_writemask(struct blit_state *ctx,
|
|||||||
texTemp.width0 = srcW;
|
texTemp.width0 = srcW;
|
||||||
texTemp.height0 = srcH;
|
texTemp.height0 = srcH;
|
||||||
texTemp.depth0 = 1;
|
texTemp.depth0 = 1;
|
||||||
pf_get_block(src->format, &texTemp.block);
|
|
||||||
|
|
||||||
tex = screen->texture_create(screen, &texTemp);
|
tex = screen->texture_create(screen, &texTemp);
|
||||||
if (!tex)
|
if (!tex)
|
||||||
|
@@ -669,10 +669,10 @@ void debug_dump_surface(const char *prefix,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
debug_dump_image(prefix,
|
debug_dump_image(prefix,
|
||||||
transfer->format,
|
texture->format,
|
||||||
transfer->block.size,
|
pf_get_blocksize(texture->format),
|
||||||
transfer->nblocksx,
|
pf_get_nblocksx(texture->format, transfer->width),
|
||||||
transfer->nblocksy,
|
pf_get_nblocksy(texture->format, transfer->height),
|
||||||
transfer->stride,
|
transfer->stride,
|
||||||
data);
|
data);
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ struct util_format_block
|
|||||||
/** Block height in pixels */
|
/** Block height in pixels */
|
||||||
unsigned height;
|
unsigned height;
|
||||||
|
|
||||||
/** Block size in bytes */
|
/** Block size in bits */
|
||||||
unsigned bits;
|
unsigned bits;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -996,7 +996,7 @@ reduce_2d(enum pipe_format pformat,
|
|||||||
{
|
{
|
||||||
enum dtype datatype;
|
enum dtype datatype;
|
||||||
uint comps;
|
uint comps;
|
||||||
const int bpt = pf_get_size(pformat);
|
const int bpt = pf_get_blocksize(pformat);
|
||||||
const ubyte *srcA, *srcB;
|
const ubyte *srcA, *srcB;
|
||||||
ubyte *dst;
|
ubyte *dst;
|
||||||
int row;
|
int row;
|
||||||
@@ -1035,7 +1035,7 @@ reduce_3d(enum pipe_format pformat,
|
|||||||
int dstWidth, int dstHeight, int dstDepth,
|
int dstWidth, int dstHeight, int dstDepth,
|
||||||
int dstRowStride, ubyte *dstPtr)
|
int dstRowStride, ubyte *dstPtr)
|
||||||
{
|
{
|
||||||
const int bpt = pf_get_size(pformat);
|
const int bpt = pf_get_blocksize(pformat);
|
||||||
const int border = 0;
|
const int border = 0;
|
||||||
int img, row;
|
int img, row;
|
||||||
int bytesPerSrcImage, bytesPerDstImage;
|
int bytesPerSrcImage, bytesPerDstImage;
|
||||||
@@ -1159,8 +1159,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
|
|||||||
const uint zslice = 0;
|
const uint zslice = 0;
|
||||||
uint dstLevel;
|
uint dstLevel;
|
||||||
|
|
||||||
assert(pt->block.width == 1);
|
assert(pf_get_blockwidth(pt->format) == 1);
|
||||||
assert(pt->block.height == 1);
|
assert(pf_get_blockheight(pt->format) == 1);
|
||||||
|
|
||||||
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
||||||
const uint srcLevel = dstLevel - 1;
|
const uint srcLevel = dstLevel - 1;
|
||||||
@@ -1204,8 +1204,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
|
|||||||
struct pipe_screen *screen = pipe->screen;
|
struct pipe_screen *screen = pipe->screen;
|
||||||
uint dstLevel, zslice = 0;
|
uint dstLevel, zslice = 0;
|
||||||
|
|
||||||
assert(pt->block.width == 1);
|
assert(pf_get_blockwidth(pt->format) == 1);
|
||||||
assert(pt->block.height == 1);
|
assert(pf_get_blockheight(pt->format) == 1);
|
||||||
|
|
||||||
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
|
||||||
const uint srcLevel = dstLevel - 1;
|
const uint srcLevel = dstLevel - 1;
|
||||||
|
@@ -82,7 +82,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
|
|||||||
|
|
||||||
void
|
void
|
||||||
pipe_linear_fill_info(struct pipe_tile_info *t,
|
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 tile_width, unsigned tile_height,
|
||||||
unsigned tiles_x, unsigned tiles_y)
|
unsigned tiles_x, unsigned tiles_y)
|
||||||
{
|
{
|
||||||
|
@@ -35,6 +35,19 @@
|
|||||||
|
|
||||||
#include "pipe/p_format.h"
|
#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
|
struct pipe_tile_info
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned size;
|
||||||
@@ -49,10 +62,10 @@ struct pipe_tile_info
|
|||||||
unsigned rows;
|
unsigned rows;
|
||||||
|
|
||||||
/* Describe the tile in pixels */
|
/* Describe the tile in pixels */
|
||||||
struct pipe_format_block tile;
|
struct u_linear_format_block tile;
|
||||||
|
|
||||||
/* Describe each block within the 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,
|
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
|
* @tiles_y number of tiles in y axis
|
||||||
*/
|
*/
|
||||||
void pipe_linear_fill_info(struct pipe_tile_info *t,
|
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 tile_width, unsigned tile_height,
|
||||||
unsigned tiles_x, unsigned tiles_y);
|
unsigned tiles_x, unsigned tiles_y);
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
util_copy_rect(ubyte * dst,
|
util_copy_rect(ubyte * dst,
|
||||||
const struct pipe_format_block *block,
|
enum pipe_format format,
|
||||||
unsigned dst_stride,
|
unsigned dst_stride,
|
||||||
unsigned dst_x,
|
unsigned dst_x,
|
||||||
unsigned dst_y,
|
unsigned dst_y,
|
||||||
@@ -57,27 +57,30 @@ util_copy_rect(ubyte * dst,
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
|
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(blocksize > 0);
|
||||||
assert(block->width > 0);
|
assert(blockwidth > 0);
|
||||||
assert(block->height > 0);
|
assert(blockheight > 0);
|
||||||
assert(src_x >= 0);
|
assert(src_x >= 0);
|
||||||
assert(src_y >= 0);
|
assert(src_y >= 0);
|
||||||
assert(dst_x >= 0);
|
assert(dst_x >= 0);
|
||||||
assert(dst_y >= 0);
|
assert(dst_y >= 0);
|
||||||
|
|
||||||
dst_x /= block->width;
|
dst_x /= blockwidth;
|
||||||
dst_y /= block->height;
|
dst_y /= blockheight;
|
||||||
width = (width + block->width - 1)/block->width;
|
width = (width + blockwidth - 1)/blockwidth;
|
||||||
height = (height + block->height - 1)/block->height;
|
height = (height + blockheight - 1)/blockheight;
|
||||||
src_x /= block->width;
|
src_x /= blockwidth;
|
||||||
src_y /= block->height;
|
src_y /= blockheight;
|
||||||
|
|
||||||
dst += dst_x * block->size;
|
dst += dst_x * blocksize;
|
||||||
src += src_x * block->size;
|
src += src_x * blocksize;
|
||||||
dst += dst_y * dst_stride;
|
dst += dst_y * dst_stride;
|
||||||
src += src_y * src_stride_pos;
|
src += src_y * src_stride_pos;
|
||||||
width *= block->size;
|
width *= blocksize;
|
||||||
|
|
||||||
if (width == dst_stride && width == src_stride)
|
if (width == dst_stride && width == src_stride)
|
||||||
memcpy(dst, src, height * width);
|
memcpy(dst, src, height * width);
|
||||||
@@ -92,7 +95,7 @@ util_copy_rect(ubyte * dst,
|
|||||||
|
|
||||||
void
|
void
|
||||||
util_fill_rect(ubyte * dst,
|
util_fill_rect(ubyte * dst,
|
||||||
const struct pipe_format_block *block,
|
enum pipe_format format,
|
||||||
unsigned dst_stride,
|
unsigned dst_stride,
|
||||||
unsigned dst_x,
|
unsigned dst_x,
|
||||||
unsigned dst_y,
|
unsigned dst_y,
|
||||||
@@ -102,23 +105,26 @@ util_fill_rect(ubyte * dst,
|
|||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
unsigned width_size;
|
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(blocksize > 0);
|
||||||
assert(block->width > 0);
|
assert(blockwidth > 0);
|
||||||
assert(block->height > 0);
|
assert(blockheight > 0);
|
||||||
assert(dst_x >= 0);
|
assert(dst_x >= 0);
|
||||||
assert(dst_y >= 0);
|
assert(dst_y >= 0);
|
||||||
|
|
||||||
dst_x /= block->width;
|
dst_x /= blockwidth;
|
||||||
dst_y /= block->height;
|
dst_y /= blockheight;
|
||||||
width = (width + block->width - 1)/block->width;
|
width = (width + blockwidth - 1)/blockwidth;
|
||||||
height = (height + block->height - 1)/block->height;
|
height = (height + blockheight - 1)/blockheight;
|
||||||
|
|
||||||
dst += dst_x * block->size;
|
dst += dst_x * blocksize;
|
||||||
dst += dst_y * dst_stride;
|
dst += dst_y * dst_stride;
|
||||||
width_size = width * block->size;
|
width_size = width * blocksize;
|
||||||
|
|
||||||
switch (block->size) {
|
switch (blocksize) {
|
||||||
case 1:
|
case 1:
|
||||||
if(dst_stride == width_size)
|
if(dst_stride == width_size)
|
||||||
memset(dst, (ubyte) value, height * 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;
|
struct pipe_transfer *src_trans, *dst_trans;
|
||||||
void *dst_map;
|
void *dst_map;
|
||||||
const void *src_map;
|
const void *src_map;
|
||||||
|
enum pipe_format src_format, dst_format;
|
||||||
|
|
||||||
assert(src->texture && dst->texture);
|
assert(src->texture && dst->texture);
|
||||||
if (!src->texture || !dst->texture)
|
if (!src->texture || !dst->texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
src_format = src->texture->format;
|
||||||
|
dst_format = dst->texture->format;
|
||||||
|
|
||||||
src_trans = screen->get_tex_transfer(screen,
|
src_trans = screen->get_tex_transfer(screen,
|
||||||
src->texture,
|
src->texture,
|
||||||
src->face,
|
src->face,
|
||||||
@@ -192,9 +203,9 @@ util_surface_copy(struct pipe_context *pipe,
|
|||||||
PIPE_TRANSFER_WRITE,
|
PIPE_TRANSFER_WRITE,
|
||||||
dst_x, dst_y, w, h);
|
dst_x, dst_y, w, h);
|
||||||
|
|
||||||
assert(dst_trans->block.size == src_trans->block.size);
|
assert(pf_get_blocksize(dst_format) == pf_get_blocksize(src_format));
|
||||||
assert(dst_trans->block.width == src_trans->block.width);
|
assert(pf_get_blockwidth(dst_format) == pf_get_blockwidth(src_format));
|
||||||
assert(dst_trans->block.height == src_trans->block.height);
|
assert(pf_get_blockheight(dst_format) == pf_get_blockheight(src_format));
|
||||||
|
|
||||||
src_map = pipe->screen->transfer_map(screen, src_trans);
|
src_map = pipe->screen->transfer_map(screen, src_trans);
|
||||||
dst_map = pipe->screen->transfer_map(screen, dst_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 (src_map && dst_map) {
|
||||||
/* If do_flip, invert src_y position and pass negative src stride */
|
/* If do_flip, invert src_y position and pass negative src stride */
|
||||||
util_copy_rect(dst_map,
|
util_copy_rect(dst_map,
|
||||||
&dst_trans->block,
|
dst_format,
|
||||||
dst_trans->stride,
|
dst_trans->stride,
|
||||||
0, 0,
|
0, 0,
|
||||||
w, h,
|
w, h,
|
||||||
@@ -259,11 +270,11 @@ util_surface_fill(struct pipe_context *pipe,
|
|||||||
if (dst_map) {
|
if (dst_map) {
|
||||||
assert(dst_trans->stride > 0);
|
assert(dst_trans->stride > 0);
|
||||||
|
|
||||||
switch (dst_trans->block.size) {
|
switch (pf_get_blocksize(dst_trans->texture->format)) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
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);
|
0, 0, width, height, value);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
@@ -42,13 +42,13 @@ struct pipe_surface;
|
|||||||
|
|
||||||
|
|
||||||
extern void
|
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 dst_stride, unsigned dst_x, unsigned dst_y,
|
||||||
unsigned width, unsigned height, const ubyte * src,
|
unsigned width, unsigned height, const ubyte * src,
|
||||||
int src_stride, unsigned src_x, int src_y);
|
int src_stride, unsigned src_x, int src_y);
|
||||||
|
|
||||||
extern void
|
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 dst_stride, unsigned dst_x, unsigned dst_y,
|
||||||
unsigned width, unsigned height, uint32_t value);
|
unsigned width, unsigned height, uint32_t value);
|
||||||
|
|
||||||
|
@@ -82,7 +82,6 @@ util_create_rgba_surface(struct pipe_screen *screen,
|
|||||||
templ.width0 = width;
|
templ.width0 = width;
|
||||||
templ.height0 = height;
|
templ.height0 = height;
|
||||||
templ.depth0 = 1;
|
templ.depth0 = 1;
|
||||||
pf_get_block(format, &templ.block);
|
|
||||||
templ.tex_usage = usage;
|
templ.tex_usage = usage;
|
||||||
|
|
||||||
*textureOut = screen->texture_create(screen, &templ);
|
*textureOut = screen->texture_create(screen, &templ);
|
||||||
|
@@ -52,7 +52,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
|
|||||||
const void *src;
|
const void *src;
|
||||||
|
|
||||||
if (dst_stride == 0)
|
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))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
return;
|
||||||
@@ -62,7 +62,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt,
|
|||||||
if(!src)
|
if(!src)
|
||||||
return;
|
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);
|
screen->transfer_unmap(screen, pt);
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,10 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
|
|||||||
{
|
{
|
||||||
struct pipe_screen *screen = pt->texture->screen;
|
struct pipe_screen *screen = pt->texture->screen;
|
||||||
void *dst;
|
void *dst;
|
||||||
|
enum pipe_format format = pt->texture->format;
|
||||||
|
|
||||||
if (src_stride == 0)
|
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))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
return;
|
||||||
@@ -90,7 +91,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt,
|
|||||||
if(!dst)
|
if(!dst)
|
||||||
return;
|
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);
|
screen->transfer_unmap(screen, pt);
|
||||||
}
|
}
|
||||||
@@ -1219,21 +1220,22 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
|
|||||||
{
|
{
|
||||||
unsigned dst_stride = w * 4;
|
unsigned dst_stride = w * 4;
|
||||||
void *packed;
|
void *packed;
|
||||||
|
enum pipe_format format = pt->texture->format;
|
||||||
|
|
||||||
if (pipe_clip_tile(x, y, &w, &h, pt))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
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)
|
if (!packed)
|
||||||
return;
|
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);
|
assert((x & 1) == 0);
|
||||||
|
|
||||||
pipe_get_tile_raw(pt, x, y, w, h, packed, 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);
|
FREE(packed);
|
||||||
}
|
}
|
||||||
@@ -1246,16 +1248,17 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
|
|||||||
{
|
{
|
||||||
unsigned src_stride = w * 4;
|
unsigned src_stride = w * 4;
|
||||||
void *packed;
|
void *packed;
|
||||||
|
enum pipe_format format = pt->texture->format;
|
||||||
|
|
||||||
if (pipe_clip_tile(x, y, &w, &h, pt))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
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)
|
if (!packed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (pt->format) {
|
switch (format) {
|
||||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||||
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||||
break;
|
break;
|
||||||
@@ -1322,7 +1325,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
|
|||||||
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
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;
|
ubyte *map;
|
||||||
uint *pDest = z;
|
uint *pDest = z;
|
||||||
uint i, j;
|
uint i, j;
|
||||||
|
enum pipe_format format = pt->texture->format;
|
||||||
|
|
||||||
if (pipe_clip_tile(x, y, &w, &h, pt))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
return;
|
||||||
@@ -1354,7 +1358,7 @@ pipe_get_tile_z(struct pipe_transfer *pt,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pt->format) {
|
switch (format) {
|
||||||
case PIPE_FORMAT_Z32_UNORM:
|
case PIPE_FORMAT_Z32_UNORM:
|
||||||
{
|
{
|
||||||
const uint *ptrc
|
const uint *ptrc
|
||||||
@@ -1428,6 +1432,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
|
|||||||
const uint *ptrc = zSrc;
|
const uint *ptrc = zSrc;
|
||||||
ubyte *map;
|
ubyte *map;
|
||||||
uint i, j;
|
uint i, j;
|
||||||
|
enum pipe_format format = pt->texture->format;
|
||||||
|
|
||||||
if (pipe_clip_tile(x, y, &w, &h, pt))
|
if (pipe_clip_tile(x, y, &w, &h, pt))
|
||||||
return;
|
return;
|
||||||
@@ -1438,7 +1443,7 @@ pipe_put_tile_z(struct pipe_transfer *pt,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pt->format) {
|
switch (format) {
|
||||||
case PIPE_FORMAT_Z32_UNORM:
|
case PIPE_FORMAT_Z32_UNORM:
|
||||||
{
|
{
|
||||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||||
|
@@ -840,7 +840,6 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||||||
template.height0 = r->pot_buffers ?
|
template.height0 = r->pot_buffers ?
|
||||||
util_next_power_of_two(r->picture_height) : r->picture_height;
|
util_next_power_of_two(r->picture_height) : r->picture_height;
|
||||||
template.depth0 = 1;
|
template.depth0 = 1;
|
||||||
pf_get_block(template.format, &template.block);
|
|
||||||
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
|
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
|
||||||
|
|
||||||
r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
|
r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
|
||||||
|
@@ -63,13 +63,11 @@ softpipe_texture_layout(struct pipe_screen *screen,
|
|||||||
pt->depth0 = depth;
|
pt->depth0 = depth;
|
||||||
|
|
||||||
for (level = 0; level <= pt->last_level; level++) {
|
for (level = 0; level <= pt->last_level; level++) {
|
||||||
pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
|
spt->stride[level] = pf_get_stride(pt->format, width);
|
||||||
pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
|
|
||||||
spt->stride[level] = pt->nblocksx[level]*pt->block.size;
|
|
||||||
|
|
||||||
spt->level_offset[level] = buffer_size;
|
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) *
|
((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
|
||||||
spt->stride[level]);
|
spt->stride[level]);
|
||||||
|
|
||||||
@@ -97,9 +95,6 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
|
|||||||
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
|
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
|
||||||
unsigned tex_usage = spt->base.tex_usage;
|
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->buffer = screen->surface_buffer_create( screen,
|
||||||
spt->base.width0,
|
spt->base.width0,
|
||||||
spt->base.height0,
|
spt->base.height0,
|
||||||
@@ -175,8 +170,6 @@ softpipe_texture_blanket(struct pipe_screen * screen,
|
|||||||
spt->base = *base;
|
spt->base = *base;
|
||||||
pipe_reference_init(&spt->base.reference, 1);
|
pipe_reference_init(&spt->base.reference, 1);
|
||||||
spt->base.screen = screen;
|
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];
|
spt->stride[0] = stride[0];
|
||||||
|
|
||||||
pipe_buffer_reference(&spt->buffer, buffer);
|
pipe_buffer_reference(&spt->buffer, buffer);
|
||||||
@@ -244,10 +237,12 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
|
|||||||
ps->zslice = zslice;
|
ps->zslice = zslice;
|
||||||
|
|
||||||
if (pt->target == PIPE_TEXTURE_CUBE) {
|
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) {
|
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 {
|
else {
|
||||||
assert(face == 0);
|
assert(face == 0);
|
||||||
@@ -302,15 +297,12 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
|
|||||||
spt = CALLOC_STRUCT(softpipe_transfer);
|
spt = CALLOC_STRUCT(softpipe_transfer);
|
||||||
if (spt) {
|
if (spt) {
|
||||||
struct pipe_transfer *pt = &spt->base;
|
struct pipe_transfer *pt = &spt->base;
|
||||||
|
int nblocksy = pf_get_nblocksy(texture->format, u_minify(texture->height0, level));
|
||||||
pipe_texture_reference(&pt->texture, texture);
|
pipe_texture_reference(&pt->texture, texture);
|
||||||
pt->format = texture->format;
|
|
||||||
pt->block = texture->block;
|
|
||||||
pt->x = x;
|
pt->x = x;
|
||||||
pt->y = y;
|
pt->y = y;
|
||||||
pt->width = w;
|
pt->width = w;
|
||||||
pt->height = h;
|
pt->height = h;
|
||||||
pt->nblocksx = texture->nblocksx[level];
|
|
||||||
pt->nblocksy = texture->nblocksy[level];
|
|
||||||
pt->stride = sptex->stride[level];
|
pt->stride = sptex->stride[level];
|
||||||
pt->usage = usage;
|
pt->usage = usage;
|
||||||
pt->face = face;
|
pt->face = face;
|
||||||
@@ -320,10 +312,10 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
|
|||||||
spt->offset = sptex->level_offset[level];
|
spt->offset = sptex->level_offset[level];
|
||||||
|
|
||||||
if (texture->target == PIPE_TEXTURE_CUBE) {
|
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) {
|
else if (texture->target == PIPE_TEXTURE_3D) {
|
||||||
spt->offset += zslice * pt->nblocksy * pt->stride;
|
spt->offset += zslice * nblocksy * pt->stride;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(face == 0);
|
assert(face == 0);
|
||||||
@@ -361,9 +353,11 @@ softpipe_transfer_map( struct pipe_screen *screen,
|
|||||||
{
|
{
|
||||||
ubyte *map, *xfer_map;
|
ubyte *map, *xfer_map;
|
||||||
struct softpipe_texture *spt;
|
struct softpipe_texture *spt;
|
||||||
|
enum pipe_format format;
|
||||||
|
|
||||||
assert(transfer->texture);
|
assert(transfer->texture);
|
||||||
spt = softpipe_texture(transfer->texture);
|
spt = softpipe_texture(transfer->texture);
|
||||||
|
format = transfer->texture->format;
|
||||||
|
|
||||||
map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer));
|
map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer));
|
||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
@@ -380,8 +374,8 @@ softpipe_transfer_map( struct pipe_screen *screen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
xfer_map = map + softpipe_transfer(transfer)->offset +
|
xfer_map = map + softpipe_transfer(transfer)->offset +
|
||||||
transfer->y / transfer->block.height * transfer->stride +
|
transfer->y / pf_get_blockheight(format) * transfer->stride +
|
||||||
transfer->x / transfer->block.width * transfer->block.size;
|
transfer->x / pf_get_blockwidth(format) * pf_get_blocksize(format);
|
||||||
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
|
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
|
||||||
return 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.width0 = util_next_power_of_two(width);
|
||||||
template.height0 = util_next_power_of_two(height);
|
template.height0 = util_next_power_of_two(height);
|
||||||
template.depth0 = 1;
|
template.depth0 = 1;
|
||||||
pf_get_block(template.format, &template.block);
|
|
||||||
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
|
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
|
||||||
|
|
||||||
sp_vsfc->tex = screen->texture_create(screen, &template);
|
sp_vsfc->tex = screen->texture_create(screen, &template);
|
||||||
|
@@ -238,7 +238,7 @@ clear_tile(struct softpipe_cached_tile *tile,
|
|||||||
{
|
{
|
||||||
uint i, j;
|
uint i, j;
|
||||||
|
|
||||||
switch (pf_get_size(format)) {
|
switch (pf_get_blocksize(format)) {
|
||||||
case 1:
|
case 1:
|
||||||
memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
|
memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
|
||||||
break;
|
break;
|
||||||
@@ -284,8 +284,9 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
|
|||||||
uint x, y;
|
uint x, y;
|
||||||
uint numCleared = 0;
|
uint numCleared = 0;
|
||||||
|
|
||||||
|
assert(pt->texture);
|
||||||
/* clear the scratch tile to the clear value */
|
/* 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 */
|
/* push the tile to all positions marked as clear */
|
||||||
for (y = 0; y < h; y += TILE_SIZE) {
|
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) {
|
if (addr.value != tile->addr.value) {
|
||||||
|
|
||||||
|
assert(pt->texture);
|
||||||
if (tile->addr.bits.invalid == 0) {
|
if (tile->addr.bits.invalid == 0) {
|
||||||
/* put dirty tile back in framebuffer */
|
/* put dirty tile back in framebuffer */
|
||||||
if (tc->depth_stencil) {
|
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)) {
|
if (is_clear_flag_set(tc->clear_flags, addr)) {
|
||||||
/* don't get tile from framebuffer, just clear it */
|
/* don't get tile from framebuffer, just clear it */
|
||||||
if (tc->depth_stencil) {
|
if (tc->depth_stencil) {
|
||||||
clear_tile(tile, pt->format, tc->clear_val);
|
clear_tile(tile, pt->texture->format, tc->clear_val);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
clear_clear_flag(tc->clear_flags, addr);
|
||||||
}
|
}
|
||||||
|
@@ -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 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)) {
|
switch (pf_layout(format)) {
|
||||||
case PIPE_FORMAT_LAYOUT_RGBAZS:
|
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 );
|
pf_get_component_bits( format, PIPE_FORMAT_COMP_S );
|
||||||
case PIPE_FORMAT_LAYOUT_YCBCR:
|
case PIPE_FORMAT_LAYOUT_YCBCR:
|
||||||
assert( format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV );
|
assert( format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV );
|
||||||
/* return effective bits per pixel */
|
return 32;
|
||||||
return 16;
|
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:
|
default:
|
||||||
assert( 0 );
|
assert( 0 );
|
||||||
return 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);
|
assert(pf_get_blocksizebits(format) % 8 == 0);
|
||||||
return pf_get_bits(format) / 8;
|
return pf_get_blocksizebits(format) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static INLINE uint pf_get_blockwidth( enum pipe_format format )
|
||||||
* 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
|
|
||||||
{
|
{
|
||||||
/** Block size in bytes */
|
switch (pf_layout(format)) {
|
||||||
unsigned size;
|
case PIPE_FORMAT_LAYOUT_YCBCR:
|
||||||
|
return 2;
|
||||||
/** Block width in pixels */
|
case PIPE_FORMAT_LAYOUT_DXT:
|
||||||
unsigned width;
|
return 4;
|
||||||
|
|
||||||
/** Block height in pixels */
|
|
||||||
unsigned height;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
default:
|
default:
|
||||||
block->size = pf_get_size(format);
|
return 1;
|
||||||
block->width = 1;
|
}
|
||||||
block->height = 1;
|
}
|
||||||
break;
|
|
||||||
|
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
|
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
|
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
|
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
|
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
|
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
|
static INLINE boolean
|
||||||
|
@@ -315,14 +315,10 @@ struct pipe_surface
|
|||||||
*/
|
*/
|
||||||
struct pipe_transfer
|
struct pipe_transfer
|
||||||
{
|
{
|
||||||
enum pipe_format format; /**< PIPE_FORMAT_x */
|
|
||||||
unsigned x; /**< x offset from start of texture image */
|
unsigned x; /**< x offset from start of texture image */
|
||||||
unsigned y; /**< y offset from start of texture image */
|
unsigned y; /**< y offset from start of texture image */
|
||||||
unsigned width; /**< logical width in pixels */
|
unsigned width; /**< logical width in pixels */
|
||||||
unsigned height; /**< logical height 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 */
|
unsigned stride; /**< stride in bytes between rows of blocks */
|
||||||
enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */
|
enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */
|
||||||
|
|
||||||
@@ -347,10 +343,6 @@ struct pipe_texture
|
|||||||
unsigned height0;
|
unsigned height0;
|
||||||
unsigned depth0;
|
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 last_level:8; /**< Index of last mipmap level present/defined */
|
||||||
|
|
||||||
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
|
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
|
||||||
|
@@ -701,7 +701,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now pack the stencil (and Z) values in the dest format */
|
/* now pack the stencil (and Z) values in the dest format */
|
||||||
switch (pt->format) {
|
switch (pt->texture->format) {
|
||||||
case PIPE_FORMAT_S8_UNORM:
|
case PIPE_FORMAT_S8_UNORM:
|
||||||
{
|
{
|
||||||
ubyte *dest = stmap + spanY * pt->stride + spanX;
|
ubyte *dest = stmap + spanY * pt->stride + spanX;
|
||||||
@@ -856,8 +856,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||||||
usage, dstx, dsty,
|
usage, dstx, dsty,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
assert(ptDraw->block.width == 1);
|
assert(pf_get_blockwidth(ptDraw->texture->format) == 1);
|
||||||
assert(ptDraw->block.height == 1);
|
assert(pf_get_blockheight(ptDraw->texture->format) == 1);
|
||||||
|
|
||||||
/* map the stencil buffer */
|
/* map the stencil buffer */
|
||||||
drawMap = screen->transfer_map(screen, ptDraw);
|
drawMap = screen->transfer_map(screen, ptDraw);
|
||||||
@@ -878,7 +878,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||||||
dst = drawMap + y * ptDraw->stride;
|
dst = drawMap + y * ptDraw->stride;
|
||||||
src = buffer + i * width;
|
src = buffer + i * width;
|
||||||
|
|
||||||
switch (ptDraw->format) {
|
switch (ptDraw->texture->format) {
|
||||||
case PIPE_FORMAT_S8Z24_UNORM:
|
case PIPE_FORMAT_S8Z24_UNORM:
|
||||||
{
|
{
|
||||||
uint *dst4 = (uint *) dst;
|
uint *dst4 = (uint *) dst;
|
||||||
|
@@ -98,16 +98,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
|||||||
strb->defined = GL_FALSE; /* undefined contents now */
|
strb->defined = GL_FALSE; /* undefined contents now */
|
||||||
|
|
||||||
if(strb->software) {
|
if(strb->software) {
|
||||||
struct pipe_format_block block;
|
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
_mesa_free(strb->data);
|
_mesa_free(strb->data);
|
||||||
|
|
||||||
assert(strb->format != PIPE_FORMAT_NONE);
|
assert(strb->format != PIPE_FORMAT_NONE);
|
||||||
pf_get_block(strb->format, &block);
|
|
||||||
|
|
||||||
strb->stride = pf_get_stride(&block, width);
|
strb->stride = pf_get_stride(strb->format, width);
|
||||||
size = pf_get_2d_size(&block, strb->stride, height);
|
size = pf_get_2d_size(strb->format, strb->stride, height);
|
||||||
|
|
||||||
strb->data = _mesa_malloc(size);
|
strb->data = _mesa_malloc(size);
|
||||||
|
|
||||||
@@ -127,7 +125,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
|||||||
memset(&template, 0, sizeof(template));
|
memset(&template, 0, sizeof(template));
|
||||||
template.target = PIPE_TEXTURE_2D;
|
template.target = PIPE_TEXTURE_2D;
|
||||||
template.format = format;
|
template.format = format;
|
||||||
pf_get_block(format, &template.block);
|
|
||||||
template.width0 = width;
|
template.width0 = width;
|
||||||
template.height0 = height;
|
template.height0 = height;
|
||||||
template.depth0 = 1;
|
template.depth0 = 1;
|
||||||
|
@@ -103,7 +103,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get stencil (and Z) values */
|
/* get stencil (and Z) values */
|
||||||
switch (pt->format) {
|
switch (pt->texture->format) {
|
||||||
case PIPE_FORMAT_S8_UNORM:
|
case PIPE_FORMAT_S8_UNORM:
|
||||||
{
|
{
|
||||||
const ubyte *src = stmap + srcY * pt->stride;
|
const ubyte *src = stmap + srcY * pt->stride;
|
||||||
@@ -431,8 +431,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||||||
const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
|
const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
|
||||||
format, type);
|
format, type);
|
||||||
|
|
||||||
if (trans->format == PIPE_FORMAT_S8Z24_UNORM ||
|
if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM ||
|
||||||
trans->format == PIPE_FORMAT_X8Z24_UNORM) {
|
trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) {
|
||||||
if (format == GL_DEPTH_COMPONENT) {
|
if (format == GL_DEPTH_COMPONENT) {
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
GLuint ztemp[MAX_WIDTH];
|
GLuint ztemp[MAX_WIDTH];
|
||||||
@@ -463,8 +463,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (trans->format == PIPE_FORMAT_Z24S8_UNORM ||
|
else if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM ||
|
||||||
trans->format == PIPE_FORMAT_Z24X8_UNORM) {
|
trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) {
|
||||||
if (format == GL_DEPTH_COMPONENT) {
|
if (format == GL_DEPTH_COMPONENT) {
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
GLuint ztemp[MAX_WIDTH];
|
GLuint ztemp[MAX_WIDTH];
|
||||||
@@ -490,7 +490,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (trans->format == PIPE_FORMAT_Z16_UNORM) {
|
else if (trans->texture->format == PIPE_FORMAT_Z16_UNORM) {
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
GLushort ztemp[MAX_WIDTH];
|
GLushort ztemp[MAX_WIDTH];
|
||||||
GLfloat zfloat[MAX_WIDTH];
|
GLfloat zfloat[MAX_WIDTH];
|
||||||
@@ -505,7 +505,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
|||||||
dst += dstStride;
|
dst += dstStride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (trans->format == PIPE_FORMAT_Z32_UNORM) {
|
else if (trans->texture->format == PIPE_FORMAT_Z32_UNORM) {
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
GLuint ztemp[MAX_WIDTH];
|
GLuint ztemp[MAX_WIDTH];
|
||||||
GLfloat zfloat[MAX_WIDTH];
|
GLfloat zfloat[MAX_WIDTH];
|
||||||
|
@@ -405,7 +405,6 @@ compress_with_blit(GLcontext * ctx,
|
|||||||
memset(&templ, 0, sizeof(templ));
|
memset(&templ, 0, sizeof(templ));
|
||||||
templ.target = PIPE_TEXTURE_2D;
|
templ.target = PIPE_TEXTURE_2D;
|
||||||
templ.format = st_mesa_format_to_pipe_format(mesa_format);
|
templ.format = st_mesa_format_to_pipe_format(mesa_format);
|
||||||
pf_get_block(templ.format, &templ.block);
|
|
||||||
templ.width0 = width;
|
templ.width0 = width;
|
||||||
templ.height0 = height;
|
templ.height0 = height;
|
||||||
templ.depth0 = 1;
|
templ.depth0 = 1;
|
||||||
@@ -833,7 +832,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
/* copy/pack data into user buffer */
|
/* copy/pack data into user buffer */
|
||||||
if (st_equal_formats(stImage->pt->format, format, type)) {
|
if (st_equal_formats(stImage->pt->format, format, type)) {
|
||||||
/* memcpy */
|
/* memcpy */
|
||||||
const uint bytesPerRow = width * pf_get_size(stImage->pt->format);
|
const uint bytesPerRow = width * pf_get_blocksize(stImage->pt->format);
|
||||||
ubyte *map = screen->transfer_map(screen, tex_xfer);
|
ubyte *map = screen->transfer_map(screen, tex_xfer);
|
||||||
GLuint row;
|
GLuint row;
|
||||||
for (row = 0; row < height; row++) {
|
for (row = 0; row < height; row++) {
|
||||||
@@ -915,7 +914,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
|
|||||||
PIPE_TRANSFER_READ, 0, 0,
|
PIPE_TRANSFER_READ, 0, 0,
|
||||||
stImage->base.Width,
|
stImage->base.Width,
|
||||||
stImage->base.Height);
|
stImage->base.Height);
|
||||||
texImage->RowStride = stImage->transfer->stride / stImage->pt->block.size;
|
texImage->RowStride = stImage->transfer->stride / pf_get_blocksize(stImage->pt->format);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Otherwise, the image should actually be stored in
|
/* Otherwise, the image should actually be stored in
|
||||||
@@ -1163,10 +1162,10 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
struct gl_texture_image *texImage)
|
struct gl_texture_image *texImage)
|
||||||
{
|
{
|
||||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||||
struct pipe_format_block block;
|
|
||||||
int srcBlockStride;
|
int srcBlockStride;
|
||||||
int dstBlockStride;
|
int dstBlockStride;
|
||||||
int y;
|
int y;
|
||||||
|
enum pipe_format pformat= stImage->pt->format;
|
||||||
|
|
||||||
if (stImage->pt) {
|
if (stImage->pt) {
|
||||||
unsigned face = _mesa_tex_target_to_face(target);
|
unsigned face = _mesa_tex_target_to_face(target);
|
||||||
@@ -1178,8 +1177,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
xoffset, yoffset,
|
xoffset, yoffset,
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
block = stImage->pt->block;
|
srcBlockStride = pf_get_stride(pformat, width);
|
||||||
srcBlockStride = pf_get_stride(&block, width);
|
|
||||||
dstBlockStride = stImage->transfer->stride;
|
dstBlockStride = stImage->transfer->stride;
|
||||||
} else {
|
} else {
|
||||||
assert(stImage->pt);
|
assert(stImage->pt);
|
||||||
@@ -1193,16 +1191,16 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(xoffset % block.width == 0);
|
assert(xoffset % pf_get_blockwidth(pformat) == 0);
|
||||||
assert(yoffset % block.height == 0);
|
assert(yoffset % pf_get_blockheight(pformat) == 0);
|
||||||
assert(width % block.width == 0);
|
assert(width % pf_get_blockwidth(pformat) == 0);
|
||||||
assert(height % block.height == 0);
|
assert(height % pf_get_blockheight(pformat) == 0);
|
||||||
|
|
||||||
for (y = 0; y < height; y += block.height) {
|
for (y = 0; y < height; y += pf_get_blockheight(pformat)) {
|
||||||
/* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
|
/* 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(&block, y);
|
const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(pformat, y);
|
||||||
char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(&block, y);
|
char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(pformat, y);
|
||||||
memcpy(dst, src, pf_get_stride(&block, width));
|
memcpy(dst, src, pf_get_stride(pformat, width));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stImage->pt) {
|
if (stImage->pt) {
|
||||||
@@ -1692,10 +1690,10 @@ copy_image_data_to_texture(struct st_context *st,
|
|||||||
dstLevel,
|
dstLevel,
|
||||||
stImage->base.Data,
|
stImage->base.Data,
|
||||||
stImage->base.RowStride *
|
stImage->base.RowStride *
|
||||||
stObj->pt->block.size,
|
pf_get_blocksize(stObj->pt->format),
|
||||||
stImage->base.RowStride *
|
stImage->base.RowStride *
|
||||||
stImage->base.Height *
|
stImage->base.Height *
|
||||||
stObj->pt->block.size);
|
pf_get_blocksize(stObj->pt->format));
|
||||||
_mesa_align_free(stImage->base.Data);
|
_mesa_align_free(stImage->base.Data);
|
||||||
stImage->base.Data = NULL;
|
stImage->base.Data = NULL;
|
||||||
}
|
}
|
||||||
@@ -1763,8 +1761,7 @@ st_finalize_texture(GLcontext *ctx,
|
|||||||
stObj->pt->last_level < stObj->lastLevel ||
|
stObj->pt->last_level < stObj->lastLevel ||
|
||||||
stObj->pt->width0 != firstImage->base.Width2 ||
|
stObj->pt->width0 != firstImage->base.Width2 ||
|
||||||
stObj->pt->height0 != firstImage->base.Height2 ||
|
stObj->pt->height0 != firstImage->base.Height2 ||
|
||||||
stObj->pt->depth0 != firstImage->base.Depth2 ||
|
stObj->pt->depth0 != firstImage->base.Depth2)
|
||||||
stObj->pt->block.size != blockSize)
|
|
||||||
{
|
{
|
||||||
pipe_texture_reference(&stObj->pt, NULL);
|
pipe_texture_reference(&stObj->pt, NULL);
|
||||||
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
|
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
|
||||||
|
@@ -146,8 +146,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||||||
srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
|
srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
|
||||||
dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
|
dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
|
||||||
|
|
||||||
srcStride = srcTrans->stride / srcTrans->block.size;
|
srcStride = srcTrans->stride / pf_get_blocksize(srcTrans->texture->format);
|
||||||
dstStride = dstTrans->stride / dstTrans->block.size;
|
dstStride = dstTrans->stride / pf_get_blocksize(dstTrans->texture->format);
|
||||||
|
|
||||||
_mesa_generate_mipmap_level(target, datatype, comps,
|
_mesa_generate_mipmap_level(target, datatype, comps,
|
||||||
0 /*border*/,
|
0 /*border*/,
|
||||||
|
@@ -104,7 +104,6 @@ st_texture_create(struct st_context *st,
|
|||||||
pt.width0 = width0;
|
pt.width0 = width0;
|
||||||
pt.height0 = height0;
|
pt.height0 = height0;
|
||||||
pt.depth0 = depth0;
|
pt.depth0 = depth0;
|
||||||
pf_get_block(format, &pt.block);
|
|
||||||
pt.tex_usage = usage;
|
pt.tex_usage = usage;
|
||||||
|
|
||||||
newtex = screen->texture_create(screen, &pt);
|
newtex = screen->texture_create(screen, &pt);
|
||||||
@@ -242,8 +241,9 @@ st_surface_data(struct pipe_context *pipe,
|
|||||||
struct pipe_screen *screen = pipe->screen;
|
struct pipe_screen *screen = pipe->screen;
|
||||||
void *map = screen->transfer_map(screen, dst);
|
void *map = screen->transfer_map(screen, dst);
|
||||||
|
|
||||||
|
assert(dst->texture);
|
||||||
util_copy_rect(map,
|
util_copy_rect(map,
|
||||||
&dst->block,
|
dst->texture->format,
|
||||||
dst->stride,
|
dst->stride,
|
||||||
dstx, dsty,
|
dstx, dsty,
|
||||||
width, height,
|
width, height,
|
||||||
|
Reference in New Issue
Block a user