i965: Fix after sampler view changes.
authormichal <michal@transistor.(none)>
Thu, 10 Dec 2009 07:05:45 +0000 (08:05 +0100)
committermichal <michal@transistor.(none)>
Thu, 10 Dec 2009 07:05:45 +0000 (08:05 +0100)
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/i965/brw_pipe_sampler.c
src/gallium/drivers/i965/brw_wm.c
src/gallium/drivers/i965/brw_wm_sampler_state.c
src/gallium/drivers/i965/brw_wm_surface_state.c

index 12cfa7b049c2276de81f82f807ad42be0fb9bfc0..8816714a7aad5a607d07acb26cab1ec3e3315363 100644 (file)
@@ -550,11 +550,11 @@ struct brw_context
       const struct brw_sampler *sampler[PIPE_MAX_SAMPLERS];
       unsigned num_samplers;
 
-      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+      struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
       struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
       struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
       unsigned num_vertex_elements;
-      unsigned num_textures;
+      unsigned num_fragment_sampler_views;
       unsigned num_vertex_buffers;
 
       struct pipe_scissor_state scissor;
index c7c0e2ae95ea3f916ee551d703ae37d560c5ab6f..fe1d18ae7736dce33c7219bdfc5f129e218d7bb0 100644 (file)
@@ -183,26 +183,26 @@ static void brw_delete_sampler_state(struct pipe_context *pipe,
    FREE(cso);
 }
 
-static void brw_set_sampler_textures(struct pipe_context *pipe,
-                                    unsigned num,
-                                    struct pipe_texture **texture)
+static void brw_set_fragment_sampler_views(struct pipe_context *pipe,
+                                           unsigned num,
+                                           struct pipe_sampler_view **views)
 {
    struct brw_context *brw = brw_context(pipe);
    int i;
 
    for (i = 0; i < num; i++)
-      pipe_texture_reference(&brw->curr.texture[i], texture[i]);
+      pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], views[i]);
 
-   for (i = num; i < brw->curr.num_textures; i++)
-      pipe_texture_reference(&brw->curr.texture[i], NULL);
+   for (i = num; i < brw->curr.num_fragment_sampler_views; i++)
+      pipe_sampler_view_reference(&brw->curr.fragment_sampler_views[i], NULL);
 
-   brw->curr.num_textures = num;
+   brw->curr.num_fragment_sampler_views = num;
    brw->state.dirty.mesa |= PIPE_NEW_BOUND_TEXTURES;
 }
 
-static void brw_set_vertex_sampler_textures(struct pipe_context *pipe,
-                                            unsigned num,
-                                            struct pipe_texture **texture)
+static void brw_set_vertex_sampler_views(struct pipe_context *pipe,
+                                         unsigned num,
+                                         struct pipe_sampler_view **views)
 {
 }
 
@@ -212,17 +212,46 @@ static void brw_bind_vertex_sampler_state(struct pipe_context *pipe,
 }
 
 
+static struct pipe_sampler_view *
+brw_create_sampler_view(struct pipe_context *pipe,
+                        struct pipe_texture *texture,
+                        const struct pipe_sampler_view *templ)
+{
+   struct brw_context *brw = brw_context(pipe);
+   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;
+}
+
+
+static void
+brw_sampler_view_destroy(struct pipe_context *pipe,
+                         struct pipe_sampler_view *view)
+{
+   pipe_texture_reference(&view->texture, NULL);
+   FREE(view);
+}
+
+
 void brw_pipe_sampler_init( struct brw_context *brw )
 {
    brw->base.create_sampler_state = brw_create_sampler_state;
    brw->base.delete_sampler_state = brw_delete_sampler_state;
 
-   brw->base.set_fragment_sampler_textures = brw_set_sampler_textures;
+   brw->base.set_fragment_sampler_views = brw_set_fragment_sampler_views;
    brw->base.bind_fragment_sampler_states = brw_bind_sampler_state;
 
-   brw->base.set_vertex_sampler_textures = brw_set_vertex_sampler_textures;
+   brw->base.set_vertex_sampler_views = brw_set_vertex_sampler_views;
    brw->base.bind_vertex_sampler_states = brw_bind_vertex_sampler_state;
 
+   brw->base.create_sampler_view = brw_create_sampler_view;
+   brw->base.sampler_view_destroy = brw_sampler_view_destroy;
 }
 void brw_pipe_sampler_cleanup( struct brw_context *brw )
 {
index 5164c90ed60cf6261d41dd25a7a52d9df8dfc401..3724adc040e360402fb900e5be2c7370768c9e05 100644 (file)
@@ -251,8 +251,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
 
 
    /* PIPE_NEW_BOUND_TEXTURES */
-   for (i = 0; i < brw->curr.num_textures; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+   for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) {
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
         
       if (tex->base.format == PIPE_FORMAT_YCBCR)
         key->yuvtex_mask |= 1 << i;
index a8bc31c9ceffca33d422f5adf5d57af9fb89bd99..a4bfa61ab306d994e881fb019133056798faba6d 100644 (file)
@@ -78,11 +78,11 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 
    memset(key, 0, sizeof(*key));
 
-   key->sampler_count = MIN2(brw->curr.num_textures,
+   key->sampler_count = MIN2(brw->curr.num_fragment_sampler_views,
                            brw->curr.num_samplers);
 
    for (i = 0; i < key->sampler_count; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
       const struct brw_sampler *sampler = brw->curr.sampler[i];
       struct brw_sampler_state *entry = &key->sampler[i];
 
@@ -122,12 +122,12 @@ static enum pipe_error
 brw_wm_sampler_update_default_colors(struct brw_context *brw)
 {
    enum pipe_error ret;
-   int nr = MIN2(brw->curr.num_textures,
+   int nr = MIN2(brw->curr.num_fragment_sampler_views,
                 brw->curr.num_samplers);
    int i;
 
    for (i = 0; i < nr; i++) {
-      const struct brw_texture *tex = brw_texture(brw->curr.texture[i]);
+      const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
       const struct brw_sampler *sampler = brw->curr.sampler[i];
       const float *bc;
 
index b01a7f194b7e8d8c5ff11e525e8e60b09127983b..2368ae3f808947cdd2d3f77a291a218551e9e082 100644 (file)
@@ -242,9 +242,9 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw )
 
    /* PIPE_NEW_TEXTURE 
     */
-   for (i = 0; i < brw->curr.num_textures; i++) {
+   for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) {
       ret = brw_update_texture_surface(brw, 
-                                       brw_texture(brw->curr.texture[i]),
+                                       brw_texture(brw->curr.fragment_sampler_views[i]->texture),
                                        &brw->wm.surf_bo[BTI_TEXTURE(i)]);
       if (ret)
          return ret;
@@ -261,7 +261,7 @@ static enum pipe_error prepare_wm_surfaces(struct brw_context *brw )
       bo_reference(&brw->wm.surf_bo[BTI_FRAGMENT_CONSTANTS], NULL);      
 
    /* XXX: no pipe_max_textures define?? */
-   for (i = brw->curr.num_textures; i < PIPE_MAX_SAMPLERS; i++)
+   for (i = brw->curr.num_fragment_sampler_views; i < PIPE_MAX_SAMPLERS; i++)
       bo_reference(&brw->wm.surf_bo[BTI_TEXTURE(i)], NULL);
 
    if (brw->wm.nr_surfaces != nr_surfaces) {