Mesa (master): st/python: Fix regressions.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Mon Apr 12 06:32:48 UTC 2010


Module: Mesa
Branch: master
Commit: c48f21ea7cb9634c1865514f069b8c0993cb5daf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c48f21ea7cb9634c1865514f069b8c0993cb5daf

Author: José Fonseca <jfonseca at vmware.com>
Date:   Mon Apr 12 15:04:16 2010 +0900

st/python: Fix regressions.

---

 src/gallium/state_trackers/python/p_context.i |  109 +++++++++++++++++++++++++
 src/gallium/state_trackers/python/p_device.i  |   17 ++--
 src/gallium/state_trackers/python/p_texture.i |   39 ---------
 3 files changed, 117 insertions(+), 48 deletions(-)

diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 882219f..13c8d1a 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -127,6 +127,45 @@ struct st_context {
       $self->gs = gs;
    }
 
+   struct pipe_sampler_view *
+   create_sampler_view(struct pipe_resource *texture,
+                       enum pipe_format format = PIPE_FORMAT_NONE,
+                       unsigned first_level = 0,
+                       unsigned last_level = ~0,
+                       unsigned swizzle_r = 0,
+                       unsigned swizzle_g = 1,
+                       unsigned swizzle_b = 2,
+                       unsigned swizzle_a = 3)
+   {
+      struct pipe_context *pipe = $self->pipe;
+      struct pipe_sampler_view templat;
+
+      memset(&templat, 0, sizeof templat);
+      if (format == PIPE_FORMAT_NONE) {
+         templat.format = texture->format;
+      } else {
+         templat.format = format;
+      }
+      templat.last_level = MIN2(last_level, texture->last_level);
+      templat.first_level = first_level;
+      templat.last_level = last_level;
+      templat.swizzle_r = swizzle_r;
+      templat.swizzle_g = swizzle_g;
+      templat.swizzle_b = swizzle_b;
+      templat.swizzle_a = swizzle_a;
+
+      return pipe->create_sampler_view(pipe, texture, &templat);
+   }
+
+   void
+   sampler_view_destroy(struct pipe_context *ctx,
+                        struct pipe_sampler_view *view)
+   {
+      struct pipe_context *pipe = $self->pipe;
+
+      pipe->sampler_view_destroy(pipe, view);
+   }
+
    /*
     * Parameter-like state (or properties)
     */
@@ -167,6 +206,26 @@ struct st_context {
       cso_set_viewport($self->cso, state);
    }
 
+   void set_fragment_sampler_view(unsigned index,
+                                  struct pipe_sampler_view *view)
+   {
+      pipe_sampler_view_reference(&$self->fragment_sampler_views[index], view);
+
+      $self->pipe->set_fragment_sampler_views($self->pipe,
+                                              PIPE_MAX_SAMPLERS,
+                                              $self->fragment_sampler_views);
+   }
+
+   void set_vertex_sampler_view(unsigned index,
+                                struct pipe_sampler_view *view)
+   {
+      pipe_sampler_view_reference(&$self->vertex_sampler_views[index], view);
+
+      $self->pipe->set_vertex_sampler_views($self->pipe,
+                                            PIPE_MAX_VERTEX_SAMPLERS,
+                                            $self->vertex_sampler_views);
+   }
+
    void set_fragment_sampler_texture(unsigned index,
                                      struct pipe_resource *texture) {
       struct pipe_sampler_view templ;
@@ -643,4 +702,54 @@ error1:
       return n;
    }
 
+   %cstring_input_binary(const char *STRING, unsigned LENGTH);
+   void
+   transfer_inline_write(struct pipe_resource *resource,
+                         struct pipe_subresource *sr,
+                         unsigned usage,
+                         const struct pipe_box *box,
+                         const char *STRING, unsigned LENGTH,
+                         unsigned stride,
+                         unsigned slice_stride)
+   {
+      struct pipe_context *pipe = $self->pipe;
+
+      pipe->transfer_inline_write(pipe, resource, *sr, usage, box, STRING, stride, slice_stride);
+   }
+
+   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+   void buffer_read(struct pipe_resource *buffer,
+                    char **STRING, int *LENGTH)
+   {
+      struct pipe_context *pipe = $self->pipe;
+
+      assert(buffer->target == PIPE_BUFFER);
+
+      *LENGTH = buffer->width0;
+      *STRING = (char *) malloc(buffer->width0);
+      if(!*STRING)
+         return;
+
+      pipe_buffer_read(pipe, buffer, 0, buffer->width0, *STRING);
+   }
+
+   void buffer_write(struct pipe_resource *buffer,
+                     const char *STRING, unsigned LENGTH, unsigned offset = 0)
+   {
+      struct pipe_context *pipe = $self->pipe;
+
+      assert(buffer->target == PIPE_BUFFER);
+
+      if(offset > buffer->width0)
+         SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
+
+      if(offset + LENGTH > buffer->width0)
+         SWIG_exception(SWIG_ValueError, "data length must fit inside the buffer");
+
+      pipe_buffer_write(pipe, buffer, offset, LENGTH, STRING);
+
+fail:
+      return;
+   }
+
 };
diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i
index 18d5efc..959c13f 100644
--- a/src/gallium/state_trackers/python/p_device.i
+++ b/src/gallium/state_trackers/python/p_device.i
@@ -81,20 +81,20 @@ struct st_device {
    /**
     * Check if the given pipe_format is supported as a texture or
     * drawing surface.
-    * \param tex_usage bitmask of PIPE_BIND flags
+    * \param bind bitmask of PIPE_BIND flags
     */
    int is_format_supported( enum pipe_format format, 
                             enum pipe_texture_target target,
-                            unsigned tex_usage, 
+                            unsigned bind, 
                             unsigned geom_flags ) {
       /* We can't really display surfaces with the python statetracker so mask
        * out that usage */
-      tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
+      bind &= ~PIPE_BIND_DISPLAY_TARGET;
 
       return $self->screen->is_format_supported( $self->screen, 
                                                  format, 
                                                  target, 
-                                                 tex_usage, 
+                                                 bind, 
                                                  geom_flags );
    }
 
@@ -104,20 +104,20 @@ struct st_device {
    }
 
    struct pipe_resource * 
-   texture_create(
+   resource_create(
          enum pipe_format format,
          unsigned width,
          unsigned height,
          unsigned depth = 1,
          unsigned last_level = 0,
          enum pipe_texture_target target = PIPE_TEXTURE_2D,
-         unsigned tex_usage = 0
+         unsigned bind = 0
       ) {
       struct pipe_resource templat;
 
       /* We can't really display surfaces with the python statetracker so mask
        * out that usage */
-      tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
+      bind &= ~PIPE_BIND_DISPLAY_TARGET;
 
       memset(&templat, 0, sizeof(templat));
       templat.format = format;
@@ -126,7 +126,7 @@ struct st_device {
       templat.depth0 = depth;
       templat.last_level = last_level;
       templat.target = target;
-      templat.bind = tex_usage;
+      templat.bind = bind;
 
       return $self->screen->resource_create($self->screen, &templat);
    }
@@ -135,5 +135,4 @@ struct st_device {
    buffer_create(unsigned size, unsigned bind = 0) {
       return pipe_buffer_create($self->screen, bind, size);
    }
-
 };
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index 1208976..ae50694 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -106,45 +106,6 @@
       return $self->width0;
    }
 
-   %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
-   void read_(char **STRING, int *LENGTH)
-   {
-      struct pipe_screen *screen = $self->screen;
-      /* XXX need context here not screen */
-
-      assert($self->target == PIPE_BUFFER);
-      assert(p_atomic_read(&$self->reference.count) > 0);
-
-      *LENGTH = $self->width0;
-      *STRING = (char *) malloc($self->width0);
-      if(!*STRING)
-         return;
-
-      pipe_buffer_read(screen, $self, 0, $self->width0, *STRING);
-   }
-
-   %cstring_input_binary(const char *STRING, unsigned LENGTH);
-   void write_(const char *STRING, unsigned LENGTH, unsigned offset = 0) 
-   {
-      struct pipe_screen *screen = $self->screen;
-      /* XXX need context here not screen */
-
-      assert($self->target == PIPE_BUFFER);
-      assert(p_atomic_read(&$self->reference.count) > 0);
-
-      if(offset > $self->width0)
-         SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
-
-      if(offset + LENGTH > $self->width0)
-         SWIG_exception(SWIG_ValueError, "data length must fit inside the buffer");
-
-      pipe_buffer_write(screen, $self, offset, LENGTH, STRING);
-
-fail:
-      return;
-   }
-
-
 };
 
 struct st_surface




More information about the mesa-commit mailing list