summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/python
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-17 22:37:15 +0100
committerMichal Krol <michal@vmware.com>2009-12-17 22:37:15 +0100
commit16c6dce013f089d072256652f012b3b604781bfd (patch)
tree077623708990a855f9be2dfeb3925f727e6207e7 /src/gallium/state_trackers/python
parent440fc5bf788201a265892ff2e12bf102e63a2896 (diff)
parent294bd53d4b6b15a6890599c46f14b205a3c738bf (diff)
Merge branch 'master' into pipe-format-simplify
Conflicts: src/gallium/auxiliary/draw/draw_pipe_aaline.c src/gallium/auxiliary/draw/draw_pipe_pstipple.c src/gallium/auxiliary/util/u_blit.c src/gallium/auxiliary/util/u_gen_mipmap.c src/gallium/auxiliary/util/u_surface.c src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c src/gallium/drivers/cell/ppu/cell_texture.c src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/r300/r300_emit.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/softpipe/sp_texture.c src/gallium/drivers/softpipe/sp_tile_cache.c src/gallium/drivers/svga/svga_state_vs.c src/gallium/include/pipe/p_format.h src/gallium/state_trackers/dri/dri_drawable.c src/gallium/state_trackers/egl/egl_surface.c src/gallium/state_trackers/python/p_device.i src/gallium/state_trackers/python/st_softpipe_winsys.c src/gallium/state_trackers/vega/api_filters.c src/gallium/state_trackers/vega/image.c src/gallium/state_trackers/vega/mask.c src/gallium/state_trackers/vega/paint.c src/gallium/state_trackers/vega/renderer.c src/gallium/state_trackers/vega/vg_tracker.c src/gallium/state_trackers/xorg/xorg_crtc.c src/gallium/state_trackers/xorg/xorg_dri2.c src/gallium/state_trackers/xorg/xorg_exa.c src/gallium/state_trackers/xorg/xorg_renderer.c src/gallium/state_trackers/xorg/xorg_xv.c src/gallium/state_trackers/xorg/xvmc/surface.c src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c src/gallium/winsys/drm/radeon/core/radeon_buffer.c src/gallium/winsys/egl_xlib/sw_winsys.c src/gallium/winsys/g3dvl/xlib/xsp_winsys.c src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c src/gallium/winsys/gdi/gdi_softpipe_winsys.c src/gallium/winsys/xlib/xlib_cell.c src/gallium/winsys/xlib/xlib_llvmpipe.c src/gallium/winsys/xlib/xlib_softpipe.c src/mesa/state_tracker/st_cb_fbo.c src/mesa/state_tracker/st_cb_texture.c src/mesa/state_tracker/st_texture.c
Diffstat (limited to 'src/gallium/state_trackers/python')
-rw-r--r--src/gallium/state_trackers/python/gallium.i1
-rw-r--r--src/gallium/state_trackers/python/p_device.i3
-rw-r--r--src/gallium/state_trackers/python/p_format.i8
-rw-r--r--src/gallium/state_trackers/python/p_texture.i32
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py3
-rw-r--r--src/gallium/state_trackers/python/st_device.c6
-rw-r--r--src/gallium/state_trackers/python/st_sample.c35
-rw-r--r--src/gallium/state_trackers/python/st_sample.h1
-rw-r--r--src/gallium/state_trackers/python/st_softpipe_winsys.c19
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/surface_copy.py7
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/texture_transfer.py5
11 files changed, 40 insertions, 80 deletions
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 3f79cc1a3d..8e323f4896 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -80,7 +80,6 @@
%rename(Stencil) pipe_stencil_state;
%rename(Alpha) pipe_alpha_state;
%rename(DepthStencilAlpha) pipe_depth_stencil_alpha_state;
-%rename(FormatBlock) pipe_format_block;
%rename(Framebuffer) pipe_framebuffer_state;
%rename(PolyStipple) pipe_poly_stipple;
%rename(Rasterizer) pipe_rasterizer_state;
diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i
index bfe3f051fc..fb793d5cbd 100644
--- a/src/gallium/state_trackers/python/p_device.i
+++ b/src/gallium/state_trackers/python/p_device.i
@@ -112,7 +112,10 @@ struct st_device {
struct pipe_texture templat;
memset(&templat, 0, sizeof(templat));
templat.format = format;
+<<<<<<< HEAD
util_format_get_block(templat.format, &templat.block);
+=======
+>>>>>>> master
templat.width0 = width;
templat.height0 = height;
templat.depth0 = depth;
diff --git a/src/gallium/state_trackers/python/p_format.i b/src/gallium/state_trackers/python/p_format.i
index 26fb12b387..68df009331 100644
--- a/src/gallium/state_trackers/python/p_format.i
+++ b/src/gallium/state_trackers/python/p_format.i
@@ -152,11 +152,3 @@ enum pipe_format {
PIPE_FORMAT_DXT5_SRGBA,
};
-
-struct pipe_format_block
-{
- unsigned size;
- unsigned width;
- unsigned height;
-};
-
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index 5416b872f5..1de7f86a3c 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -69,15 +69,7 @@
unsigned get_depth(unsigned level=0) {
return u_minify($self->depth0, level);
}
-
- unsigned get_nblocksx(unsigned level=0) {
- return $self->nblocksx[level];
- }
-
- unsigned get_nblocksy(unsigned level=0) {
- return $self->nblocksy[level];
- }
-
+
/** Get a surface which is a "view" into a texture */
struct st_surface *
get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0)
@@ -126,8 +118,6 @@ struct st_surface
unsigned format;
unsigned width;
unsigned height;
- unsigned nblocksx;
- unsigned nblocksy;
~st_surface() {
pipe_texture_reference(&$self->texture, NULL);
@@ -142,8 +132,8 @@ struct st_surface
struct pipe_transfer *transfer;
unsigned stride;
- stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
- *LENGTH = pf_get_nblocksy(&texture->block, h) * stride;
+ stride = pf_get_stride(texture->format, w);
+ *LENGTH = pf_get_nblocksy(texture->format, h) * stride;
*STRING = (char *) malloc(*LENGTH);
if(!*STRING)
return;
@@ -169,9 +159,9 @@ struct st_surface
struct pipe_transfer *transfer;
if(stride == 0)
- stride = pf_get_nblocksx(&texture->block, w) * texture->block.size;
+ stride = pf_get_stride(texture->format, w);
- if(LENGTH < pf_get_nblocksy(&texture->block, h) * stride)
+ if(LENGTH < pf_get_nblocksy(texture->format, h) * stride)
SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
transfer = screen->get_tex_transfer(screen,
@@ -383,18 +373,6 @@ struct st_surface
{
return u_minify(surface->texture->height0, surface->level);
}
-
- static unsigned
- st_surface_nblocksx_get(struct st_surface *surface)
- {
- return surface->texture->nblocksx[surface->level];
- }
-
- static unsigned
- st_surface_nblocksy_get(struct st_surface *surface)
- {
- return surface->texture->nblocksy[surface->level];
- }
%}
/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
index 5f826b1c4c..b32eafe23f 100755
--- a/src/gallium/state_trackers/python/retrace/interpreter.py
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -99,7 +99,6 @@ struct_factories = {
"pipe_stencil_state": gallium.Stencil,
"pipe_alpha_state": gallium.Alpha,
"pipe_depth_stencil_alpha_state": gallium.DepthStencilAlpha,
- "pipe_format_block": gallium.FormatBlock,
#"pipe_framebuffer_state": gallium.Framebuffer,
"pipe_poly_stipple": gallium.PolyStipple,
"pipe_rasterizer_state": gallium.Rasterizer,
@@ -307,7 +306,7 @@ class Screen(Object):
def surface_write(self, surface, data, stride, size):
if surface is None:
return
- assert surface.nblocksy * stride == size
+# assert surface.nblocksy * stride == size
surface.put_tile_raw(0, 0, surface.width, surface.height, data, stride)
def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index a791113aba..10c7ecbd78 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -62,8 +62,9 @@ st_device_reference(struct st_device **ptr, struct st_device *st_dev)
{
struct st_device *old_dev = *ptr;
- if (pipe_reference((struct pipe_reference **)ptr, &st_dev->reference))
+ if (pipe_reference(&(*ptr)->reference, &st_dev->reference))
st_device_really_destroy(old_dev);
+ *ptr = st_dev;
}
@@ -249,9 +250,6 @@ st_context_create(struct st_device *st_dev)
memset( &templat, 0, sizeof( templat ) );
templat.target = PIPE_TEXTURE_2D;
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- templat.block.size = 4;
- templat.block.width = 1;
- templat.block.height = 1;
templat.width0 = 1;
templat.height0 = 1;
templat.depth0 = 1;
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index 6fee90afda..97ca2afc54 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -423,7 +423,6 @@ dxt5_rgba_data[] = {
static INLINE void
st_sample_dxt_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
uint8_t *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
@@ -462,21 +461,21 @@ st_sample_dxt_pixel_block(enum pipe_format format,
for(ch = 0; ch < 4; ++ch)
rgba[y*rgba_stride + x*4 + ch] = (float)(data[i].rgba[y*4*4 + x*4 + ch])/255.0f;
- memcpy(raw, data[i].raw, block->size);
+ memcpy(raw, data[i].raw, pf_get_blocksize(format));
}
static INLINE void
st_sample_generic_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
uint8_t *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
{
unsigned i;
unsigned x, y, ch;
+ int blocksize = pf_get_blocksize(format);
- for(i = 0; i < block->size; ++i)
+ for(i = 0; i < blocksize; ++i)
raw[i] = (uint8_t)st_random();
@@ -503,7 +502,6 @@ st_sample_generic_pixel_block(enum pipe_format format,
*/
void
st_sample_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
void *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h)
@@ -513,11 +511,11 @@ st_sample_pixel_block(enum pipe_format format,
case PIPE_FORMAT_DXT1_RGBA:
case PIPE_FORMAT_DXT3_RGBA:
case PIPE_FORMAT_DXT5_RGBA:
- st_sample_dxt_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+ st_sample_dxt_pixel_block(format, raw, rgba, rgba_stride, w, h);
break;
default:
- st_sample_generic_pixel_block(format, block, raw, rgba, rgba_stride, w, h);
+ st_sample_generic_pixel_block(format, raw, rgba, rgba_stride, w, h);
break;
}
}
@@ -548,18 +546,23 @@ st_sample_surface(struct st_surface *surface, float *rgba)
raw = screen->transfer_map(screen, transfer);
if (raw) {
- const struct pipe_format_block *block = &texture->block;
+ enum pipe_format format = texture->format;
uint x, y;
+ int nblocksx = pf_get_nblocksx(format, width);
+ int nblocksy = pf_get_nblocksy(format, height);
+ int blockwidth = pf_get_blockwidth(format);
+ int blockheight = pf_get_blockheight(format);
+ int blocksize = pf_get_blocksize(format);
- for (y = 0; y < transfer->nblocksy; ++y) {
- for (x = 0; x < transfer->nblocksx; ++x) {
- st_sample_pixel_block(texture->format,
- block,
- (uint8_t *) raw + y * transfer->stride + x * block->size,
- rgba + y * block->height * rgba_stride + x * block->width * 4,
+
+ for (y = 0; y < nblocksy; ++y) {
+ for (x = 0; x < nblocksx; ++x) {
+ st_sample_pixel_block(format,
+ (uint8_t *) raw + y * transfer->stride + x * blocksize,
+ rgba + y * blockheight * rgba_stride + x * blockwidth * 4,
rgba_stride,
- MIN2(block->width, width - x*block->width),
- MIN2(block->height, height - y*block->height));
+ MIN2(blockwidth, width - x*blockwidth),
+ MIN2(blockheight, height - y*blockheight));
}
}
diff --git a/src/gallium/state_trackers/python/st_sample.h b/src/gallium/state_trackers/python/st_sample.h
index 0a27083549..888114d302 100644
--- a/src/gallium/state_trackers/python/st_sample.h
+++ b/src/gallium/state_trackers/python/st_sample.h
@@ -35,7 +35,6 @@
void
st_sample_pixel_block(enum pipe_format format,
- const struct pipe_format_block *block,
void *raw,
float *rgba, unsigned rgba_stride,
unsigned w, unsigned h);
diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c
index 010a5ded66..b8535a4217 100644
--- a/src/gallium/state_trackers/python/st_softpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c
@@ -158,16 +158,6 @@ st_softpipe_user_buffer_create(struct pipe_winsys *winsys,
}
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-
static struct pipe_buffer *
st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
@@ -177,13 +167,10 @@ st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned *stride)
{
const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
+ unsigned nblocksy;
- util_format_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
+ nblocksy = pf_get_nblocksy(format, height);
+ *stride = align(pf_get_stride(format, width), alignment);
return winsys->buffer_create(winsys, alignment,
usage,
diff --git a/src/gallium/state_trackers/python/tests/surface_copy.py b/src/gallium/state_trackers/python/tests/surface_copy.py
index 3ceecbbd3a..df5babb78a 100755
--- a/src/gallium/state_trackers/python/tests/surface_copy.py
+++ b/src/gallium/state_trackers/python/tests/surface_copy.py
@@ -98,9 +98,10 @@ class TextureTest(TestCase):
y = 0
w = dst_surface.width
h = dst_surface.height
-
- stride = dst_surface.nblocksx * dst_texture.block.size
- size = dst_surface.nblocksy * stride
+
+ # ???
+ stride = pf_get_stride(texture->format, w)
+ size = pf_get_nblocksy(texture->format) * stride
src_raw = os.urandom(size)
src_surface.put_tile_raw(0, 0, w, h, src_raw, stride)
diff --git a/src/gallium/state_trackers/python/tests/texture_transfer.py b/src/gallium/state_trackers/python/tests/texture_transfer.py
index e65b425adf..35daca9e49 100755
--- a/src/gallium/state_trackers/python/tests/texture_transfer.py
+++ b/src/gallium/state_trackers/python/tests/texture_transfer.py
@@ -86,8 +86,9 @@ class TextureTest(TestCase):
surface = texture.get_surface(face, level, zslice)
- stride = surface.nblocksx * texture.block.size
- size = surface.nblocksy * stride
+ # ???
+ stride = pf_get_stride(texture->format, w)
+ size = pf_get_nblocksy(texture->format) * stride
in_raw = os.urandom(size)