python: Drop st_buffer.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 26 Mar 2009 11:19:15 +0000 (11:19 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 26 Mar 2009 11:19:15 +0000 (11:19 +0000)
It adds nothing, now that pipe_buffer has a pointer to the screen.

src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/p_device.i
src/gallium/state_trackers/python/p_texture.i
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h

index 79e68de1df8d15610a20deb3d164c4afbf2143d6..8b43c1721ef3233d3339f0bd07b713f24aaef9f7 100644 (file)
@@ -72,7 +72,7 @@
 %rename(Context) st_context;
 %rename(Texture) pipe_texture;
 %rename(Surface) pipe_surface;
-%rename(Buffer) st_buffer;
+%rename(Buffer) pipe_buffer;
 
 %rename(BlendColor) pipe_blend_color;
 %rename(Blend) pipe_blend_state;
index 178ab0e24ef34a05afa1171cf966e85f8455dfd6..05f3f222035f9c22b86889ecf5d28eb276b808f1 100644 (file)
@@ -116,11 +116,11 @@ struct st_context {
    }
 
    void set_constant_buffer(unsigned shader, unsigned index,
-                            struct st_buffer *buffer ) 
+                            struct pipe_buffer *buffer ) 
    {
       struct pipe_constant_buffer state;
       memset(&state, 0, sizeof(state));
-      state.buffer = buffer ? buffer->buffer : NULL;
+      state.buffer = buffer;
       $self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
    }
 
@@ -154,7 +154,7 @@ struct st_context {
                           unsigned stride, 
                           unsigned max_index,
                           unsigned buffer_offset,
-                          struct st_buffer *buffer)
+                          struct pipe_buffer *buffer)
    {
       unsigned i;
       struct pipe_vertex_buffer state;
@@ -163,7 +163,7 @@ struct st_context {
       state.stride = stride;
       state.max_index = max_index;
       state.buffer_offset = buffer_offset;
-      state.buffer = buffer ? buffer->buffer : NULL;
+      state.buffer = buffer;
 
       memcpy(&$self->vertex_buffers[index], &state, sizeof(state));
       
@@ -198,22 +198,22 @@ struct st_context {
       $self->pipe->draw_arrays($self->pipe, mode, start, count);
    }
 
-   void draw_elements( struct st_buffer *indexBuffer,
+   void draw_elements( struct pipe_buffer *indexBuffer,
                        unsigned indexSize,
                        unsigned mode, unsigned start, unsigned count) 
    {
       $self->pipe->draw_elements($self->pipe, 
-                                 indexBuffer->buffer
+                                 indexBuffer, 
                                  indexSize, 
                                  mode, start, count);
    }
 
-   void draw_range_elements( struct st_buffer *indexBuffer,
+   void draw_range_elements( struct pipe_buffer *indexBuffer,
                              unsigned indexSize, unsigned minIndex, unsigned maxIndex,
                              unsigned mode, unsigned start, unsigned count)
    {
       $self->pipe->draw_range_elements($self->pipe, 
-                                       indexBuffer->buffer
+                                       indexBuffer, 
                                        indexSize, minIndex, maxIndex,
                                        mode, start, count);
    }
index 84fd2e4349bc46e58773c23669b395d1acfd614f..f16fe5b0ff70182f978dfb2d4fa9f3b9eb43abca 100644 (file)
@@ -122,9 +122,9 @@ struct st_device {
       return $self->screen->texture_create($self->screen, &templat);
    }
    
-   struct st_buffer *
+   struct pipe_buffer *
    buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) {
-      return st_buffer_create($self, alignment, usage, size);
+      return pipe_buffer_create($self->screen, alignment, usage, size);
    }
 
 };
index 4648af691d14e609fa9759e8463fd021c10822d2..63c63db9ebed2d0b9daf53beaa9752abb5638166 100644 (file)
 
 %nodefaultctor pipe_texture;
 %nodefaultctor pipe_surface;
-%nodefaultctor st_buffer;
+%nodefaultctor pipe_buffer;
 
 %nodefaultdtor pipe_texture;
 %nodefaultdtor pipe_surface;
-%nodefaultdtor st_buffer;
+%nodefaultdtor pipe_buffer;
 
 %ignore pipe_texture::screen;
 
 
 };
 
-struct st_buffer {
-};
+/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */ 
+%rename(read) pipe_buffer_read_; 
+%rename(write) pipe_buffer_write_; 
 
-%extend st_buffer {
+%extend pipe_buffer {
    
-   ~st_buffer() {
-      st_buffer_destroy($self);
+   ~pipe_buffer() {
+      struct pipe_buffer *ptr = $self;
+      pipe_buffer_reference(&ptr, NULL);
    }
    
    unsigned __len__(void) 
    {
-      assert(p_atomic_read(&$self->buffer->reference.count) > 0);
-      return $self->buffer->size;
+      assert(p_atomic_read(&$self->reference.count) > 0);
+      return $self->size;
    }
    
    %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
-   void read(char **STRING, int *LENGTH)
+   void read_(char **STRING, int *LENGTH)
    {
-      struct pipe_screen *screen = $self->st_dev->screen;
+      struct pipe_screen *screen = $self->screen;
       
-      assert(p_atomic_read(&$self->buffer->reference.count) > 0);
+      assert(p_atomic_read(&$self->reference.count) > 0);
       
-      *LENGTH = $self->buffer->size;
-      *STRING = (char *) malloc($self->buffer->size);
+      *LENGTH = $self->size;
+      *STRING = (char *) malloc($self->size);
       if(!*STRING)
          return;
       
-      pipe_buffer_read(screen, $self->buffer, 0, $self->buffer->size, STRING);
+      pipe_buffer_read(screen, $self, 0, $self->size, STRING);
    }
    
    %cstring_input_binary(const char *STRING, unsigned LENGTH);
-   void write(const char *STRING, unsigned LENGTH, unsigned offset = 0) 
+   void write_(const char *STRING, unsigned LENGTH, unsigned offset = 0) 
    {
-      struct pipe_screen *screen = $self->st_dev->screen;
+      struct pipe_screen *screen = $self->screen;
       
-      assert(p_atomic_read(&$self->buffer->reference.count) > 0);
+      assert(p_atomic_read(&$self->reference.count) > 0);
       
-      if(offset > $self->buffer->size) {
+      if(offset > $self->size) {
          PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size");
          return;
       }
 
-      if(offset + LENGTH > $self->buffer->size) {
+      if(offset + LENGTH > $self->size) {
          PyErr_SetString(PyExc_ValueError, "data length must fit inside the buffer");
          return;
       }
 
-      pipe_buffer_write(screen, $self->buffer, offset, LENGTH, STRING);
+      pipe_buffer_write(screen, $self, offset, LENGTH, STRING);
    }
 };
index 366d4eb19afd1e1659795539cce402fbc93d1275..b4f8649d3bc5c642e6dd7e7bd70e33a95925f705 100644 (file)
@@ -291,37 +291,3 @@ st_context_create(struct st_device *st_dev)
 
    return st_ctx;
 }
-
-
-void
-st_buffer_destroy(struct st_buffer *st_buf)
-{
-   if(st_buf) {
-      pipe_buffer_reference(&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_screen *screen = st_dev->screen;
-   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 = pipe_buffer_create(screen, alignment, usage, size);
-   if(!st_buf->buffer) {
-      st_buffer_destroy(st_buf);
-      return NULL;
-   }
-   
-   return st_buf;
-}
-
index 0641aff149fd7b5a002f6ebcb2467486cb8ba62a..d1bd8c31f4ff932fbc1de393f707f351f0c9b6ce 100644 (file)
@@ -38,13 +38,6 @@ 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;
    
@@ -78,13 +71,6 @@ 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);