summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/python/gallium.i37
-rw-r--r--src/gallium/state_trackers/python/st_device.c33
-rw-r--r--src/gallium/state_trackers/python/st_device.h14
3 files changed, 76 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 284ecb827d..8f731ca905 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -65,8 +65,7 @@
%rename(Context) st_context;
%rename(Texture) pipe_texture;
%rename(Surface) pipe_surface;
-
-%rename(Buffer) pipe_buffer;
+%rename(Buffer) st_buffer;
%rename(BlendColor) pipe_blend_color;
%rename(Blend) pipe_blend_state;
@@ -88,13 +87,13 @@
%nodefaultctor st_context;
%nodefaultctor pipe_texture;
%nodefaultctor pipe_surface;
-%nodefaultctor pipe_buffer;
+%nodefaultctor st_buffer;
%nodefaultdtor st_device;
%nodefaultdtor st_context;
%nodefaultdtor pipe_texture;
%nodefaultdtor pipe_surface;
-%nodefaultdtor pipe_buffer;
+%nodefaultdtor st_buffer;
%ignore pipe_texture::screen;
@@ -114,6 +113,9 @@ struct st_device {
struct st_context {
};
+struct st_buffer {
+};
+
%newobject st_device::texture_create;
%newobject st_device::context_create;
@@ -197,9 +199,9 @@ struct st_context {
return $self->screen->texture_create($self->screen, &templat);
}
- struct pipe_buffer *
+ struct st_buffer *
buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) {
- return $self->screen->winsys->buffer_create($self->screen->winsys, alignment, usage, size);
+ return st_buffer_create($self, alignment, usage, size);
}
};
@@ -323,10 +325,10 @@ struct st_context {
$self->pipe->draw_arrays($self->pipe, mode, start, count);
}
- void draw_elements( struct pipe_buffer *indexBuffer,
+ void draw_elements( struct st_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count) {
- $self->pipe->draw_elements($self->pipe, indexBuffer, indexSize, mode, start, count);
+ $self->pipe->draw_elements($self->pipe, indexBuffer->buffer, indexSize, mode, start, count);
}
void draw_vertices(unsigned prim,
@@ -522,6 +524,25 @@ error1:
};
+%extend st_buffer {
+
+ ~st_buffer() {
+ st_buffer_destroy($self);
+ }
+
+ void write( const char *STRING, unsigned LENGTH, unsigned offset = 0) {
+ struct pipe_winsys *winsys = $self->st_dev->screen->winsys;
+ char *map;
+
+ map = winsys->buffer_map(winsys, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ if(!map) {
+ memcpy(map + offset, STRING, LENGTH);
+ winsys->buffer_unmap(winsys, $self->buffer);
+ }
+ }
+};
+
+
%extend pipe_framebuffer_state {
pipe_framebuffer_state(void) {
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index 2e53a83eea..fbd56712e0 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -266,3 +266,36 @@ st_context_create(struct st_device *st_dev)
return st_ctx;
}
+
+
+void
+st_buffer_destroy(struct st_buffer *st_buf)
+{
+ if(st_buf) {
+ struct pipe_winsys *winsys = st_buf->st_dev->screen->winsys;
+ pipe_buffer_reference(winsys, &st_buf->buffer, NULL);
+ FREE(st_buf);
+ }
+}
+
+
+struct st_buffer *
+st_buffer_create(struct st_device *st_dev,
+ unsigned alignment, unsigned usage, unsigned size)
+{
+ struct pipe_winsys *winsys = st_dev->screen->winsys;
+ struct st_buffer *st_buf;
+
+ st_buf = CALLOC_STRUCT(st_buffer);
+ if(!st_buf)
+ return NULL;
+
+ st_buf->st_dev = st_dev;
+
+ st_buf->buffer = winsys->buffer_create(winsys, alignment, usage, size);
+ if(!st_buf->buffer)
+ st_buffer_destroy(st_buf);
+
+ return st_buf;
+}
+
diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h
index 2d95c2da73..5b7adbe1a0 100644
--- a/src/gallium/state_trackers/python/st_device.h
+++ b/src/gallium/state_trackers/python/st_device.h
@@ -38,6 +38,13 @@ struct pipe_context;
struct st_winsys;
+struct st_buffer {
+ struct st_device *st_dev;
+
+ struct pipe_buffer *buffer;
+};
+
+
struct st_context {
struct st_device *st_dev;
@@ -65,6 +72,13 @@ struct st_device {
};
+struct st_buffer *
+st_buffer_create(struct st_device *st_dev,
+ unsigned alignment, unsigned usage, unsigned size);
+
+void
+st_buffer_destroy(struct st_buffer *st_buf);
+
struct st_context *
st_context_create(struct st_device *st_dev);