diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-03-30 16:02:21 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-03-30 17:19:10 +0100 |
commit | 28de69d6819eab289a400482d15797b662e4d633 (patch) | |
tree | 7e55515a03d72ae68872bfd373d3607a5ebc0edc /src/gallium/state_trackers/python/p_texture.i | |
parent | 68342f9036d3c94ee50c4cbe5c7b36439eeb6825 (diff) |
python: Set the surface GPU access flags.
Make python surface just a dumb (texture, face, level, zslice) tuple.
Diffstat (limited to 'src/gallium/state_trackers/python/p_texture.i')
-rw-r--r-- | src/gallium/state_trackers/python/p_texture.i | 84 |
1 files changed, 70 insertions, 14 deletions
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index fee9fb0bf8..543a0cf33f 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -34,18 +34,19 @@ %nodefaultctor pipe_texture; -%nodefaultctor pipe_surface; +%nodefaultctor st_surface; %nodefaultctor pipe_buffer; %nodefaultdtor pipe_texture; -%nodefaultdtor pipe_surface; +%nodefaultdtor st_surface; %nodefaultdtor pipe_buffer; %ignore pipe_texture::screen; -%ignore pipe_surface::winsys; -%immutable pipe_surface::texture; -%immutable pipe_surface::buffer; +%immutable st_surface::texture; +%immutable st_surface::face; +%immutable st_surface::level; +%immutable st_surface::zslice; %newobject pipe_texture::get_surface; @@ -78,22 +79,57 @@ } /** Get a surface which is a "view" into a texture */ - struct pipe_surface * - get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0 ) + struct st_surface * + get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0) { - const usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE; - struct pipe_screen *screen = $self->screen; - return screen->get_tex_surface(screen, $self, face, level, zslice, usage); + struct st_surface *surface; + + if(face >= ($self->target == PIPE_TEXTURE_CUBE ? 6 : 1)) + SWIG_exception(SWIG_ValueError, "face out of bounds"); + if(level > $self->last_level) + SWIG_exception(SWIG_ValueError, "level out of bounds"); + if(zslice >= $self->depth[level]) + SWIG_exception(SWIG_ValueError, "zslice out of bounds"); + + surface = CALLOC_STRUCT(st_surface); + if(!surface) + return NULL; + + pipe_texture_reference(&surface->texture, $self); + surface->face = face; + surface->level = level; + surface->zslice = zslice; + + return surface; + + fail: + return NULL; } }; +struct st_surface +{ + %immutable; + + struct pipe_texture *texture; + unsigned face; + unsigned level; + unsigned zslice; + +}; -%extend pipe_surface { +%extend st_surface { + + %immutable; - ~pipe_surface() { - struct pipe_surface *ptr = $self; - pipe_surface_reference(&ptr, NULL); + unsigned format; + unsigned width; + unsigned height; + + ~st_surface() { + pipe_texture_reference(&$self->texture, NULL); + FREE($self); } void @@ -309,6 +345,26 @@ }; +%{ + static enum pipe_format + st_surface_format_get(struct st_surface *surface) + { + return surface->texture->format; + } + + static unsigned + st_surface_width_get(struct st_surface *surface) + { + return surface->texture->width[surface->level]; + } + + static unsigned + st_surface_height_get(struct st_surface *surface) + { + return surface->texture->height[surface->level]; + } +%} + /* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ %rename(read) pipe_buffer_read_; %rename(write) pipe_buffer_write_; |