python: Bindings fixes.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Wed, 13 Aug 2008 11:31:53 +0000 (12:31 +0100)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 14 Aug 2008 10:01:42 +0000 (11:01 +0100)
src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/p_state.i
src/gallium/state_trackers/python/st_device.h

index 8d7a49cee7da91c0b8ee3060b15f37486a2401dd..641b19e9406e9fc69373d893177218f532085351 100644 (file)
@@ -55,6 +55,8 @@
 
 %}
 
+%include "typemaps.i"
+
 %include "carrays.i"
 %array_class(unsigned char, ByteArray);
 %array_class(int, IntArray);
index 521a2dee075c0769c310519425f413e2e5c20d6e..a23c805852dc9e87b56d97277b7924db7a9f3d45 100644 (file)
@@ -110,7 +110,7 @@ struct st_context {
    {
       struct pipe_constant_buffer state;
       memset(&state, 0, sizeof(state));
-      state.buffer = buffer->buffer;
+      state.buffer = buffer ? buffer->buffer : NULL;
       state.size = buffer->buffer->size;
       $self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
    }
@@ -154,23 +154,31 @@ struct st_context {
       state.pitch = pitch;
       state.max_index = max_index;
       state.buffer_offset = buffer_offset;
-      state.buffer = buffer->buffer;
+      state.buffer = buffer ? buffer->buffer : NULL;
 
       memcpy(&$self->vertex_buffers[index], &state, sizeof(state));
       
       for(i = 0; i < PIPE_MAX_ATTRIBS; ++i)
          if(self->vertex_buffers[i].buffer)
-            num_vertex_buffers = i + 1;
+            $self->num_vertex_buffers = i + 1;
       
       $self->pipe->set_vertex_buffers($self->pipe, 
-                                      num_vertex_buffers, 
+                                      $self->num_vertex_buffers, 
                                       $self->vertex_buffers);
    }
 
    void set_vertex_element(unsigned index,
-                           const struct pipe_vertex_element *element) {
+                           const struct pipe_vertex_element *element) 
+   {
       memcpy(&$self->vertex_elements[index], element, sizeof(*element));
-      $self->pipe->set_vertex_elements($self->pipe, PIPE_MAX_ATTRIBS, $self->vertex_elements);
+   }
+
+   void set_vertex_elements(unsigned num) 
+   {
+      $self->num_vertex_elements = num;
+      $self->pipe->set_vertex_elements($self->pipe, 
+                                       $self->num_vertex_elements, 
+                                       $self->vertex_elements);
    }
 
    /*
@@ -183,8 +191,12 @@ struct st_context {
 
    void draw_elements( struct st_buffer *indexBuffer,
                        unsigned indexSize,
-                       unsigned mode, unsigned start, unsigned count) {
-      $self->pipe->draw_elements($self->pipe, indexBuffer->buffer, indexSize, mode, start, count);
+                       unsigned mode, unsigned start, unsigned count) 
+   {
+      $self->pipe->draw_elements($self->pipe, 
+                                 indexBuffer->buffer, 
+                                 indexSize, 
+                                 mode, start, count);
    }
 
    void draw_vertices(unsigned prim,
@@ -222,9 +234,9 @@ error1:
    }
    
    void
-   flush(void) {
+   flush(unsigned flags = 0) {
       struct pipe_fence_handle *fence = NULL; 
-      $self->pipe->flush($self->pipe, PIPE_FLUSH_RENDER_CACHE, &fence);
+      $self->pipe->flush($self->pipe, flags | PIPE_FLUSH_RENDER_CACHE, &fence);
       /* TODO: allow asynchronous operation */ 
       $self->pipe->winsys->fence_finish( $self->pipe->winsys, fence, 0 );
       $self->pipe->winsys->fence_reference( $self->pipe->winsys, &fence, NULL );
index 9834229b4b590422fe17549ad4b680ec4b704940..7f5760b3b66da4a10f104fca0a3b943f094f0f7e 100644 (file)
 
 %module gallium;
 
+%ignore winsys;
+%ignore pipe_vertex_buffer::buffer;
+
 %include "pipe/p_state.h";
 
 
+%array_class(struct pipe_stencil_state, StencilArray);
+
+
 %extend pipe_framebuffer_state {
    
    pipe_framebuffer_state(void) {
index 5b7adbe1a0be7931cf7e255483c3bee71bed95a9..644c263b53d0f1aaed89ac5b6f9bb3e4e60c3002 100644 (file)
@@ -57,7 +57,11 @@ struct st_context {
 
    struct pipe_texture *default_texture;
    struct pipe_texture *sampler_textures[PIPE_MAX_SAMPLERS];
+   
+   unsigned num_vertex_buffers;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
+   
+   unsigned num_vertex_elements;
    struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS];
 };