llvmpipe: Fix after sampler view changes.
authormichal <michal@transistor.(none)>
Thu, 10 Dec 2009 08:23:15 +0000 (09:23 +0100)
committermichal <michal@transistor.(none)>
Thu, 10 Dec 2009 08:23:15 +0000 (09:23 +0100)
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c

index 9120226de0c108a8dbfa9f12589bc1cb4c2d20ab..0e385f843d14eda63877704c34816fab940904bb 100644 (file)
@@ -68,11 +68,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
    pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_texture_reference(&llvmpipe->texture[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_texture_reference(&llvmpipe->vertex_textures[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], NULL);
    }
 
    for (i = 0; i < Elements(llvmpipe->constants); i++) {
@@ -152,8 +152,10 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
    llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state;
    llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple;
    llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state;
-   llvmpipe->pipe.set_fragment_sampler_textures = llvmpipe_set_sampler_textures;
-   llvmpipe->pipe.set_vertex_sampler_textures = llvmpipe_set_vertex_sampler_textures;
+   llvmpipe->pipe.set_fragment_sampler_views = llvmpipe_set_fragment_sampler_views;
+   llvmpipe->pipe.set_vertex_sampler_views = llvmpipe_set_vertex_sampler_views;
+   llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view;
+   llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy;
    llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state;
 
    llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers;
index 955c7eb8e0e97c0ce4e0289a00e14296a8615a67..1b98e3033dbd011a67df240c5c442da1b19b56e1 100644 (file)
@@ -67,16 +67,16 @@ struct llvmpipe_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
-   struct pipe_texture *vertex_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];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
 
    unsigned num_samplers;
-   unsigned num_textures;
+   unsigned num_fragment_sampler_views;
    unsigned num_vertex_samplers;
-   unsigned num_vertex_textures;
+   unsigned num_vertex_sampler_views;
    unsigned num_vertex_elements;
    unsigned num_vertex_buffers;
 
index cb873667a20a88fb0ae8a40c23764481f4a3dc03..7d52765970ce3304187172b39661ed5d318c6d8a 100644 (file)
@@ -453,11 +453,12 @@ lp_setup_set_vertex_info( struct setup_context *setup,
 
 
 /**
- * Called during state validation when LP_NEW_TEXTURE is set.
+ * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
  */
 void
-lp_setup_set_sampler_textures( struct setup_context *setup,
-                               unsigned num, struct pipe_texture **texture)
+lp_setup_set_fragment_sampler_views(struct setup_context *setup,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views)
 {
    unsigned i;
 
@@ -466,9 +467,10 @@ lp_setup_set_sampler_textures( struct setup_context *setup,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      if(tex) {
+      if(view) {
+         struct pipe_texture *tex = view->texture;
          struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
          struct lp_jit_texture *jit_tex;
          jit_tex = &setup->fs.current.jit_context.textures[i];
index 0e155a7dc313bdef5ae7d32e5c2a5e2d2d549374..5a5d3531f9558b3689ceae7e66e7c4dcd6867b21 100644 (file)
@@ -120,8 +120,9 @@ lp_setup_set_scissor( struct setup_context *setup,
                       const struct pipe_scissor_state *scissor );
 
 void
-lp_setup_set_sampler_textures( struct setup_context *setup,
-                               unsigned num, struct pipe_texture **texture);
+lp_setup_set_fragment_sampler_views(struct setup_context *setup,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views);
 
 unsigned
 lp_setup_is_texture_referenced( const struct setup_context *setup,
index 9beba32271f5022f805d45fc3176b5b5c1d65260..8a2a08b0759653acd915ee5430f2b1009c6288e2 100644 (file)
@@ -50,7 +50,7 @@
 #define LP_NEW_DEPTH_STENCIL_ALPHA 0x100
 #define LP_NEW_CONSTANTS     0x200
 #define LP_NEW_SAMPLER       0x400
-#define LP_NEW_TEXTURE       0x800
+#define LP_NEW_SAMPLER_VIEW  0x800
 #define LP_NEW_VERTEX        0x1000
 #define LP_NEW_VS            0x2000
 #define LP_NEW_QUERY         0x4000
@@ -182,14 +182,23 @@ void llvmpipe_set_polygon_stipple( struct pipe_context *,
 void llvmpipe_set_scissor_state( struct pipe_context *,
                                  const struct pipe_scissor_state * );
 
-void llvmpipe_set_sampler_textures( struct pipe_context *,
-                                    unsigned num,
-                                    struct pipe_texture ** );
+void llvmpipe_set_fragment_sampler_views(struct pipe_context *,
+                                         unsigned num,
+                                         struct pipe_sampler_view **);
 
 void
-llvmpipe_set_vertex_sampler_textures(struct pipe_context *,
-                                     unsigned num_textures,
-                                     struct pipe_texture **);
+llvmpipe_set_vertex_sampler_views(struct pipe_context *,
+                                  unsigned num,
+                                  struct pipe_sampler_view **);
+
+struct pipe_sampler_view *
+llvmpipe_create_sampler_view(struct pipe_context *pipe,
+                            struct pipe_texture *texture,
+                            const struct pipe_sampler_view *templ);
+
+void
+llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view);
 
 void llvmpipe_set_viewport_state( struct pipe_context *,
                                   const struct pipe_viewport_state * );
index bdd906e1a73922c9291bb2cd6d354b2e04d0bb17..9c91ce9238fcec109f397ed0e411a372da88ed52 100644 (file)
@@ -150,7 +150,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
     */
    if (llvmpipe->tex_timestamp != lp_screen->timestamp) {
       llvmpipe->tex_timestamp = lp_screen->timestamp;
-      llvmpipe->dirty |= LP_NEW_TEXTURE;
+      llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
    }
       
    if (llvmpipe->dirty & (LP_NEW_RASTERIZER |
@@ -164,7 +164,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
                           LP_NEW_DEPTH_STENCIL_ALPHA |
                           LP_NEW_RASTERIZER |
                           LP_NEW_SAMPLER |
-                          LP_NEW_TEXTURE))
+                          LP_NEW_SAMPLER_VIEW))
       llvmpipe_update_fs( llvmpipe );
 
    if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
@@ -182,10 +182,10 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
       lp_setup_set_fs_constants(llvmpipe->setup, 
                                 llvmpipe->constants[PIPE_SHADER_FRAGMENT]);
 
-   if (llvmpipe->dirty & LP_NEW_TEXTURE)
-      lp_setup_set_sampler_textures(llvmpipe->setup, 
-                                    llvmpipe->num_textures,
-                                    llvmpipe->texture);
+   if (llvmpipe->dirty & LP_NEW_SAMPLER_VIEW)
+      lp_setup_set_fragment_sampler_views(llvmpipe->setup, 
+                                          llvmpipe->num_fragment_sampler_views,
+                                          llvmpipe->fragment_sampler_views);
 
    llvmpipe->dirty = 0;
 }
index 90dae3f91018f27b3cf1849cc33e4123a415c4e5..2e018df05c08b061f4c5b4a9dbc00705160ee30e 100644 (file)
@@ -1084,7 +1084,7 @@ make_variant_key(struct llvmpipe_context *lp,
 
    for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
       if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i))
-         lp_sampler_static_state(&key->sampler[i], lp->texture[i], lp->sampler[i]);
+         lp_sampler_static_state(&key->sampler[i], lp->fragment_sampler_views[i]->texture, lp->sampler[i]);
 }
 
 
index b30a0757768fe78f8ad23d95e8b5971a43a56df5..2df86a081484e5d0563b5678a9c93eba5b29e70e 100644 (file)
@@ -105,8 +105,9 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
 
 
 void
-llvmpipe_set_sampler_textures(struct pipe_context *pipe,
-                              unsigned num, struct pipe_texture **texture)
+llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
+                                    unsigned num,
+                                    struct pipe_sampler_view **views)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    uint i;
@@ -114,51 +115,77 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == llvmpipe->num_textures &&
-       !memcmp(llvmpipe->texture, texture, num * sizeof(struct pipe_texture *)))
+   if (num == llvmpipe->num_fragment_sampler_views &&
+       !memcmp(llvmpipe->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num ? texture[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&llvmpipe->texture[i], tex);
+      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], view);
    }
 
-   llvmpipe->num_textures = num;
+   llvmpipe->num_fragment_sampler_views = num;
 
-   llvmpipe->dirty |= LP_NEW_TEXTURE;
+   llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
 }
 
 
 void
-llvmpipe_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                     unsigned num_textures,
-                                     struct pipe_texture **textures)
+llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
+                                  unsigned num,
+                                  struct pipe_sampler_view **views)
 {
    struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    uint i;
 
-   assert(num_textures <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num_textures == llvmpipe->num_vertex_textures &&
-       !memcmp(llvmpipe->vertex_textures, textures, num_textures * sizeof(struct pipe_texture *))) {
+   if (num == llvmpipe->num_vertex_sampler_views &&
+       !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      struct pipe_texture *tex = i < num_textures ? textures[i] : NULL;
+      struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_texture_reference(&llvmpipe->vertex_textures[i], tex);
+      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view);
    }
 
-   llvmpipe->num_vertex_textures = num_textures;
+   llvmpipe->num_vertex_sampler_views = num;
 
-   llvmpipe->dirty |= LP_NEW_TEXTURE;
+   llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
+}
+
+
+struct pipe_sampler_view *
+llvmpipe_create_sampler_view(struct pipe_context *pipe,
+                            struct pipe_texture *texture,
+                            const struct pipe_sampler_view *templ)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   *view = *templ;
+   view->reference.count = 1;
+   view->texture = NULL;
+   pipe_texture_reference(&view->texture, texture);
+   view->context = pipe;
+
+   return view;
+}
+
+
+void
+llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
+                              struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
 }