python: Update python state tracker and samples for recent interface changes.
authorJosé Fonseca <jfonseca@vmware.com>
Sat, 26 Dec 2009 01:14:59 +0000 (01:14 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Sat, 26 Dec 2009 01:14:59 +0000 (01:14 +0000)
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/retrace/interpreter.py
src/gallium/state_trackers/python/samples/tri.py
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h
src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py
src/gallium/state_trackers/python/tests/texture_render.py
src/gallium/state_trackers/python/tests/texture_sample.py

index 3c35e6f74558797d99cb5c79e719c0313c090765..84ce1a41e6d98207f4bef6f16f80770ef3dea918 100644 (file)
@@ -52,11 +52,16 @@ struct st_context {
       cso_set_blend($self->cso, state);
    }
    
-   void set_sampler( unsigned index, const struct pipe_sampler_state *state ) {
+   void set_fragment_sampler( unsigned index, const struct pipe_sampler_state *state ) {
       cso_single_sampler($self->cso, index, state);
       cso_single_sampler_done($self->cso);
    }
 
+   void set_vertex_sampler( unsigned index, const struct pipe_sampler_state *state ) {
+      cso_single_vertex_sampler($self->cso, index, state);
+      cso_single_vertex_sampler_done($self->cso);
+   }
+
    void set_rasterizer( const struct pipe_rasterizer_state *state ) {
       cso_set_rasterizer($self->cso, state);
    }
@@ -161,14 +166,24 @@ struct st_context {
       cso_set_viewport($self->cso, state);
    }
 
-   void set_sampler_texture(unsigned index,
-                            struct pipe_texture *texture) {
+   void set_fragment_sampler_texture(unsigned index,
+                                     struct pipe_texture *texture) {
       if(!texture)
          texture = $self->default_texture;
-      pipe_texture_reference(&$self->sampler_textures[index], texture);
-      $self->pipe->set_fragment_sampler_textures($self->pipe, 
+      pipe_texture_reference(&$self->fragment_sampler_textures[index], texture);
+      $self->pipe->set_fragment_sampler_textures($self->pipe,
                                                  PIPE_MAX_SAMPLERS,
-                                                 $self->sampler_textures);
+                                                 $self->fragment_sampler_textures);
+   }
+
+   void set_vertex_sampler_texture(unsigned index,
+                                   struct pipe_texture *texture) {
+      if(!texture)
+         texture = $self->default_texture;
+      pipe_texture_reference(&$self->vertex_sampler_textures[index], texture);
+      $self->pipe->set_vertex_sampler_textures($self->pipe,
+                                               PIPE_MAX_VERTEX_SAMPLERS,
+                                               $self->vertex_sampler_textures);
    }
 
    void set_vertex_buffer(unsigned index,
index 110b3d0ec11a0a05c98090995b2700ce74fa7399..2487af6bd13a3f03025dc63725192d0492aaaf96 100755 (executable)
@@ -278,9 +278,9 @@ class Screen(Object):
     def texture_create(self, templat):
         return self.real.texture_create(
             format = templat.format,
-            width = templat.width0,
-            height = templat.height0,
-            depth = templat.depth0,
+            width = templat.width,
+            height = templat.height,
+            depth = templat.depth,
             last_level = templat.last_level,
             target = templat.target,
             tex_usage = templat.tex_usage,
@@ -387,9 +387,13 @@ class Context(Object):
     def delete_sampler_state(self, state):
         pass
 
+    def bind_vertex_sampler_states(self, num_states, states):
+        for i in range(num_states):
+            self.real.set_vertex_sampler(i, states[i])
+        
     def bind_fragment_sampler_states(self, num_states, states):
         for i in range(num_states):
-            self.real.set_sampler(i, states[i])
+            self.real.set_fragment_sampler(i, states[i])
         
     def create_rasterizer_state(self, state):
         return state
@@ -487,7 +491,11 @@ class Context(Object):
 
     def set_fragment_sampler_textures(self, num_textures, textures):
         for i in range(num_textures):
-            self.real.set_sampler_texture(i, textures[i])
+            self.real.set_fragment_sampler_texture(i, textures[i])
+
+    def set_vertex_sampler_textures(self, num_textures, textures):
+        for i in range(num_textures):
+            self.real.set_vertex_sampler_texture(i, textures[i])
 
     def set_vertex_buffers(self, num_buffers, buffers):
         self.vbufs = buffers[0:num_buffers]
index 87acf60366d8ba19cf0a94d6b778b8ce554a7bf6..af80426dc6cdc90965fe11bcfba68d18aad33ef6 100644 (file)
@@ -118,7 +118,7 @@ def test(dev):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
index 10c7ecbd78fb5556c02fc4b0fb958499f2ab274b..d144af2447d1d8c0955f9b8acd5ba0ee1d723694 100644 (file)
@@ -135,7 +135,9 @@ st_context_destroy(struct st_context *st_ctx)
          st_ctx->pipe->destroy(st_ctx->pipe);
       
       for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
-         pipe_texture_reference(&st_ctx->sampler_textures[i], NULL);
+         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], NULL);
+      for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL);
       pipe_texture_reference(&st_ctx->default_texture, NULL);
 
       FREE(st_ctx);
@@ -276,9 +278,12 @@ st_context_create(struct st_device *st_dev)
       }
    
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
-         pipe_texture_reference(&st_ctx->sampler_textures[i], st_ctx->default_texture);
+         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture);
+      for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
+         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], st_ctx->default_texture);
       
-      cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->sampler_textures);
+      cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->fragment_sampler_textures);
+      cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures);
    }
    
    /* vertex shader */
index 2a7a323985f925dd5ca11aa61dddab6aaccd6902..f786e1341189ac1b32c15eb26658b0fe6eb6879d 100644 (file)
@@ -60,7 +60,8 @@ struct st_context {
    void *gs;
 
    struct pipe_texture *default_texture;
-   struct pipe_texture *sampler_textures[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS];
+   struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS];
    
    unsigned num_vertex_buffers;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
index 35673b3ec922f5909f86fa8ab3cdfda0abaaa9fc..eed6cdd1e6460be4771991ee5463d7d95a949bed 100644 (file)
@@ -96,7 +96,7 @@ def test(dev, name):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
index 5be1ca80f301503a0f40abda430cfd5485096b92..41bebd0604a423029f033c06b7ca2c29d4d25213 100644 (file)
@@ -96,7 +96,7 @@ def test(dev, name):
     sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
     sampler.normalized_coords = 1
-    ctx.set_sampler(0, sampler)
+    ctx.set_fragment_sampler(0, sampler)
 
     # scissor
     scissor = Scissor()
index 8a2db9dbcffb192c611229565788140c76dcb909..79287f2caceaa115907cd1b9d7a588ea71d13598 100755 (executable)
@@ -144,8 +144,8 @@ class TextureTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
-        ctx.set_sampler_texture(0, src_texture)
+        ctx.set_fragment_sampler(0, sampler)
+        ctx.set_fragment_sampler_texture(0, src_texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(
index 92a6c4dfb9fe020093869731dba7fcd87ff6da57..520961c8051ef9e98f002c9312827dbfe1bab747 100755 (executable)
@@ -169,7 +169,7 @@ class TextureColorSampleTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
+        ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
         texture = dev.texture_create(
@@ -189,7 +189,7 @@ class TextureColorSampleTest(TestCase):
             zslice = zslice,
         ).sample_rgba(expected_rgba)
         
-        ctx.set_sampler_texture(0, texture)
+        ctx.set_fragment_sampler_texture(0, texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(
@@ -359,7 +359,7 @@ class TextureDepthSampleTest(TestCase):
         sampler.normalized_coords = 1
         sampler.min_lod = 0
         sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
-        ctx.set_sampler(0, sampler)
+        ctx.set_fragment_sampler(0, sampler)
     
         #  texture 
         texture = dev.texture_create(
@@ -379,7 +379,7 @@ class TextureDepthSampleTest(TestCase):
             zslice = zslice,
         ).sample_rgba(expected_rgba)
         
-        ctx.set_sampler_texture(0, texture)
+        ctx.set_fragment_sampler_texture(0, texture)
 
         #  framebuffer 
         cbuf_tex = dev.texture_create(