st/python: Fix regressions.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:04:16 +0000 (15:04 +0900)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:32:23 +0000 (15:32 +0900)
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/p_device.i
src/gallium/state_trackers/python/p_texture.i

index 882219f4bc5f95509d9f27dafaaae5ae13da0ea8..13c8d1a95e99f97055739ef1aac9ed4bdf975090 100644 (file)
@@ -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;
+   }
+
 };
index 18d5efcffb1278d3a8f8534377b6d32b46ad368a..959c13f54d9fae53de33c5ee6fe74defb2f4f582 100644 (file)
@@ -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);
    }
-
 };
index 1208976905da33f3aa190b7851b0a084e57f8d04..ae506944c4513010e297b61c1581671952db5dcf 100644 (file)
       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