summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c24
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c11
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c8
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c6
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c17
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c4
-rw-r--r--src/mesa/state_tracker/st_texture.c26
8 files changed, 55 insertions, 45 deletions
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 8098d75e18..809a906ba3 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -66,15 +66,17 @@ acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
uint x, uint y, uint w, uint h, float *p)
{
const enum pipe_format f = acc_ps->format;
- const int cpp = acc_ps->cpp;
+ const struct pipe_format_block b = acc_ps->block;
acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_ps->cpp = 8;
+ acc_ps->block.size = 8;
+ acc_ps->block.width = 1;
+ acc_ps->block.height = 1;
pipe_get_tile_rgba(pipe, acc_ps, x, y, w, h, p);
acc_ps->format = f;
- acc_ps->cpp = cpp;
+ acc_ps->block = b;
}
@@ -88,15 +90,17 @@ acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
uint x, uint y, uint w, uint h, const float *p)
{
enum pipe_format f = acc_ps->format;
- const int cpp = acc_ps->cpp;
+ const struct pipe_format_block b = acc_ps->block;
acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_ps->cpp = 8;
+ acc_ps->block.size = 8;
+ acc_ps->block.width = 1;
+ acc_ps->block.height = 1;
pipe_put_tile_rgba(pipe, acc_ps, x, y, w, h, p);
acc_ps->format = f;
- acc_ps->cpp = cpp;
+ acc_ps->block = b;
}
@@ -111,7 +115,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
const GLint ypos = ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - xpos;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
- GLvoid *map;
+ GLubyte *map;
acc_ps = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
@@ -128,8 +132,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
int i, j;
for (i = 0; i < height; i++) {
- GLshort *dst = ((GLshort *) map
- + ((ypos + i) * acc_ps->pitch + xpos) * 4);
+ GLshort *dst = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8);
for (j = 0; j < width; j++) {
dst[0] = r;
dst[1] = g;
@@ -168,8 +171,7 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
{
int i, j;
for (i = 0; i < height; i++) {
- GLshort *acc = ((GLshort *) map
- + ((ypos + i) * acc_ps->pitch + xpos) * 4);
+ GLshort *acc = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8);
for (j = 0; j < width * 4; j++) {
float val = SHORT_TO_FLOAT(acc[j]) * scale + bias;
acc[j] = FLOAT_TO_SHORT(val);
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 6fa3cbd533..f3bc3b8584 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -341,9 +341,9 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
/* Put image into texture surface */
- memset(dest, 0xff, height * surface->pitch);
+ memset(dest, 0xff, height * surface->stride);
unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap,
- dest, surface->pitch);
+ dest, surface->stride);
_mesa_unmap_bitmap_pbo(ctx, unpack);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index d8f1d2367c..a7781f3ab2 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -382,7 +382,7 @@ make_texture(struct st_context *st,
mformat, /* gl_texture_format */
dest, /* dest */
0, 0, 0, /* dstX/Y/Zoffset */
- surface->pitch * cpp, /* dstRowStride, bytes */
+ surface->stride, /* dstRowStride, bytes */
&dstImageOffsets, /* dstImageOffsets */
width, height, 1, /* size */
format, type, /* src format/type */
@@ -786,13 +786,13 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
switch (ps->format) {
case PIPE_FORMAT_S8_UNORM:
{
- ubyte *dest = stmap + spanY * ps->pitch + spanX;
+ ubyte *dest = stmap + spanY * ps->stride + spanX;
memcpy(dest, values, spanWidth);
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
{
- uint *dest = (uint *) stmap + spanY * ps->pitch + spanX;
+ uint *dest = (uint *) (stmap + spanY * ps->stride + spanX*4);
GLint k;
for (k = 0; k < spanWidth; k++) {
uint p = dest[k];
@@ -903,6 +903,9 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
psDraw = screen->get_tex_surface(screen, rbDraw->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(psDraw->block.width == 1);
+ assert(psDraw->block.height == 1);
+
/* map the stencil buffer */
drawMap = screen->surface_map(screen, psDraw, PIPE_BUFFER_USAGE_CPU_WRITE);
@@ -919,7 +922,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
y = ctx->DrawBuffer->Height - y - 1;
}
- dst = drawMap + (y * psDraw->pitch + dstx) * psDraw->cpp;
+ dst = drawMap + y * psDraw->stride + dstx * psDraw->block.size;
src = buffer + i * width;
switch (psDraw->format) {
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index db25ddd615..1067caf9b3 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -113,7 +113,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
template.target = PIPE_TEXTURE_2D;
template.compressed = 0;
- template.cpp = pf_get_size(template.format);
+ pf_get_block(template.format, &template.block);
template.width[0] = width;
template.height[0] = height;
template.depth[0] = 1;
@@ -171,10 +171,12 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
assert(strb->surface->buffer);
assert(strb->surface->format);
- assert(strb->surface->cpp);
+ assert(strb->surface->block.size);
+ assert(strb->surface->block.width);
+ assert(strb->surface->block.height);
assert(strb->surface->width == width);
assert(strb->surface->height == height);
- assert(strb->surface->pitch);
+ assert(strb->surface->stride);
return strb->surface != NULL;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index c5193631a7..09d9c29e44 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -94,13 +94,13 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
switch (ps->format) {
case PIPE_FORMAT_S8_UNORM:
{
- const ubyte *src = stmap + srcY * ps->pitch + x;
+ const ubyte *src = stmap + srcY * ps->stride + x;
memcpy(values, src, width);
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
{
- const uint *src = (uint *) stmap + srcY * ps->pitch + x;
+ const uint *src = (uint *) (stmap + srcY * ps->stride + x*4);
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] >> 24;
@@ -109,7 +109,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
break;
case PIPE_FORMAT_Z24S8_UNORM:
{
- const uint *src = (uint *) stmap + srcY * ps->pitch + x;
+ const uint *src = (uint *) (stmap + srcY * ps->stride + x*4);
GLint k;
for (k = 0; k < width; k++) {
values[k] = src[k] & 0xff;
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 7d52d1da1b..b9aa513d72 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -658,7 +658,7 @@ st_TexImage(GLcontext * ctx,
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
if (stImage->surface)
- dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
+ dstRowStride = stImage->surface->stride;
}
else {
/* Allocate regular memory and store the image there temporarily. */
@@ -820,7 +820,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
*/
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
PIPE_BUFFER_USAGE_CPU_READ);
- texImage->RowStride = stImage->surface->pitch;
+ texImage->RowStride = stImage->surface->stride / stImage->pt->block.size;
}
else {
/* Otherwise, the image should actually be stored in
@@ -925,7 +925,7 @@ st_TexSubimage(GLcontext * ctx,
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
PIPE_BUFFER_USAGE_CPU_WRITE);
if (stImage->surface)
- dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
+ dstRowStride = stImage->surface->stride;
}
if (!texImage->Data) {
@@ -1425,9 +1425,11 @@ copy_image_data_to_texture(struct st_context *st,
stImage->face,
dstLevel,
stImage->base.Data,
- stImage->base.RowStride,
+ stImage->base.RowStride *
+ stObj->pt->block.size,
stImage->base.RowStride *
- stImage->base.Height);
+ stImage->base.Height *
+ stObj->pt->block.size);
_mesa_align_free(stImage->base.Data);
stImage->base.Data = NULL;
}
@@ -1477,6 +1479,7 @@ st_finalize_texture(GLcontext *ctx,
pipe_texture_reference(&stObj->pt, firstImage->pt);
}
+ /* FIXME: determine format block instead of cpp */
if (firstImage->base.IsCompressed) {
comp_byte = compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
cpp = comp_byte;
@@ -1497,7 +1500,9 @@ st_finalize_texture(GLcontext *ctx,
stObj->pt->width[0] != firstImage->base.Width2 ||
stObj->pt->height[0] != firstImage->base.Height2 ||
stObj->pt->depth[0] != firstImage->base.Depth2 ||
- stObj->pt->cpp != cpp ||
+ stObj->pt->block.size != cpp ||
+ stObj->pt->block.width != 1 ||
+ stObj->pt->block.height != 1 ||
stObj->pt->compressed != firstImage->base.IsCompressed) {
pipe_texture_release(&stObj->pt);
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 851f17c3b4..2fc00df429 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -137,10 +137,10 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
_mesa_generate_mipmap_level(target, datatype, comps,
0 /*border*/,
pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],
- srcSurf->pitch * srcSurf->cpp, /* stride in bytes */
+ srcSurf->stride, /* stride in bytes */
srcData,
pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],
- dstSurf->pitch * dstSurf->cpp, /* stride in bytes */
+ dstSurf->stride, /* stride in bytes */
dstData);
pipe_buffer_unmap(pipe, srcSurf->buffer);
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 9553b34e31..8222826e7a 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -98,7 +98,7 @@ st_texture_create(struct st_context *st,
pt.height[0] = height0;
pt.depth[0] = depth0;
pt.compressed = compress_byte ? 1 : 0;
- pt.cpp = pt.compressed ? compress_byte : st_sizeof_format(format);
+ pf_get_block(format, &pt.block);
pt.tex_usage = usage;
newtex = screen->texture_create(screen, &pt);
@@ -231,16 +231,19 @@ static void
st_surface_data(struct pipe_context *pipe,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
- const void *src, unsigned src_pitch,
+ const void *src, unsigned src_stride,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
struct pipe_screen *screen = pipe->screen;
void *map = screen->surface_map(screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE);
pipe_copy_rect(map,
- dst->cpp,
- dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+ &dst->block,
+ dst->stride,
+ dstx, dsty,
+ width, height,
+ src, src_stride,
+ srcx, srcy);
screen->surface_unmap(screen, dst);
}
@@ -254,34 +257,29 @@ st_texture_image_data(struct pipe_context *pipe,
GLuint face,
GLuint level,
void *src,
- GLuint src_row_pitch, GLuint src_image_pitch)
+ GLuint src_row_stride, GLuint src_image_stride)
{
struct pipe_screen *screen = pipe->screen;
GLuint depth = dst->depth[level];
GLuint i;
- GLuint height = 0;
const GLubyte *srcUB = src;
struct pipe_surface *dst_surface;
DBG("%s\n", __FUNCTION__);
for (i = 0; i < depth; i++) {
- height = dst->height[level];
- if(dst->compressed)
- height /= 4;
-
dst_surface = screen->get_tex_surface(screen, dst, face, level, i,
PIPE_BUFFER_USAGE_CPU_WRITE);
st_surface_data(pipe, dst_surface,
0, 0, /* dstx, dsty */
srcUB,
- src_row_pitch,
+ src_row_stride,
0, 0, /* source x, y */
- dst->width[level], height); /* width, height */
+ dst->width[level], dst->height[level]); /* width, height */
screen->tex_surface_release(screen, &dst_surface);
- srcUB += src_image_pitch * dst->cpp;
+ srcUB += src_image_stride;
}
}