python: Fix after sampler view changes.
authorMichal Krol <michal@vmware.com>
Thu, 25 Feb 2010 13:19:54 +0000 (14:19 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 25 Feb 2010 13:19:54 +0000 (14:19 +0100)
src/gallium/state_trackers/python/gallium.i
src/gallium/state_trackers/python/p_context.i
src/gallium/state_trackers/python/st_device.c
src/gallium/state_trackers/python/st_device.h

index ffb084e358b10b2e7806e2fc01e27f55d23dce40..632d71ccbee73659d5c084f36ea951a32c18f6c1 100644 (file)
@@ -49,6 +49,7 @@
 #include "util/u_format.h"
 #include "util/u_dump.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 #include "cso_cache/cso_context.h"
 #include "tgsi/tgsi_text.h"
 #include "tgsi/tgsi_dump.h"
index 3f36ccb6217a5918b373112af78803d23cb98a8e..85c9598d06974be6aff8f8c0daa239bfb18b80d6 100644 (file)
@@ -169,22 +169,39 @@ struct st_context {
 
    void set_fragment_sampler_texture(unsigned index,
                                      struct pipe_texture *texture) {
+      struct pipe_sampler_view templ;
+
       if(!texture)
          texture = $self->default_texture;
-      pipe_texture_reference(&$self->fragment_sampler_textures[index], texture);
-      $self->pipe->set_fragment_sampler_textures($self->pipe,
-                                                 PIPE_MAX_SAMPLERS,
-                                                 $self->fragment_sampler_textures);
+      pipe_sampler_view_reference(&$self->fragment_sampler_views[index], NULL);
+      u_sampler_view_default_template(&templ,
+                                      texture,
+                                      texture->format);
+      $self->fragment_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe,
+                                                                              texture,
+                                                                              &templ);
+      $self->pipe->set_fragment_sampler_views($self->pipe,
+                                              PIPE_MAX_SAMPLERS,
+                                              $self->fragment_sampler_views);
    }
 
    void set_vertex_sampler_texture(unsigned index,
                                    struct pipe_texture *texture) {
+      struct pipe_sampler_view templ;
+
       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);
+      pipe_sampler_view_reference(&$self->vertex_sampler_views[index], NULL);
+      u_sampler_view_default_template(&templ,
+                                      texture,
+                                      texture->format);
+      $self->vertex_sampler_views[index] = $self->pipe->create_sampler_view($self->pipe,
+                                                                            texture,
+                                                                            &templ);
+      
+      $self->pipe->set_vertex_sampler_views($self->pipe,
+                                            PIPE_MAX_VERTEX_SAMPLERS,
+                                            $self->vertex_sampler_views);
    }
 
    void set_vertex_buffer(unsigned index,
index a3798a5521231d47880b7140431a418a77f2b2ac..d5a14fd795dc283b0f4bae00301f4f174ab5ba7c 100644 (file)
@@ -33,6 +33,7 @@
 #include "cso_cache/cso_context.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_sampler.h"
 #include "util/u_simple_shaders.h"
 #include "trace/tr_screen.h"
 #include "trace/tr_context.h"
@@ -134,9 +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->fragment_sampler_textures[i], NULL);
+         pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], NULL);
       for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
-         pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL);
+         pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], NULL);
       pipe_texture_reference(&st_ctx->default_texture, NULL);
 
       FREE(st_ctx);
@@ -240,6 +241,8 @@ st_context_create(struct st_device *st_dev)
       struct pipe_screen *screen = st_dev->screen;
       struct pipe_texture templat;
       struct pipe_transfer *transfer;
+      struct pipe_sampler_view view_templ;
+      struct pipe_sampler_view *view;
       unsigned i;
 
       memset( &templat, 0, sizeof( templat ) );
@@ -269,14 +272,27 @@ st_context_create(struct st_device *st_dev)
             screen->tex_transfer_destroy(transfer);
          }
       }
-   
+
+      u_sampler_view_default_template(&view_templ,
+                                      st_ctx->default_texture,
+                                      st_ctx->default_texture->format);
+      view = st_ctx->pipe->create_sampler_view(st_ctx->pipe,
+                                               st_ctx->default_texture,
+                                               &view_templ);
+
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
-         pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture);
+         pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], view);
       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->fragment_sampler_textures);
-      cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures);
+         pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], view);
+
+      st_ctx->pipe->set_fragment_sampler_views(st_ctx->pipe,
+                                               PIPE_MAX_SAMPLERS,
+                                               st_ctx->fragment_sampler_views);
+      st_ctx->pipe->set_vertex_sampler_views(st_ctx->pipe,
+                                             PIPE_MAX_VERTEX_SAMPLERS,
+                                             st_ctx->vertex_sampler_views);
+
+      pipe_sampler_view_reference(&view, NULL);
    }
    
    /* vertex shader */
index de9e0215d8e881ae66b24400818333d239db5b36..dee9a8ca7b565f1ec116b528ca37bbfff4649a71 100644 (file)
@@ -59,8 +59,8 @@ struct st_context {
    void *gs;
 
    struct pipe_texture *default_texture;
-   struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
    
    unsigned num_vertex_buffers;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];