nv30: Fix after sampler view changes.
authorMichal Krol <michal@vmware.com>
Thu, 25 Feb 2010 13:40:56 +0000 (14:40 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 25 Feb 2010 13:40:56 +0000 (14:40 +0100)
Did not test build.

src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_state.c

index ca3d6aca7faf6138c9f7db50b65371a3eb5e0bd6..04813526f4070f81ce8aca18e11e4ae4368090f9 100644 (file)
@@ -138,6 +138,7 @@ struct nv30_context {
        unsigned idxbuf_format;
        struct nv30_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
        struct nv30_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
+       struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
        unsigned nr_samplers;
        unsigned nr_textures;
        unsigned dirty_samplers;
index d911c80707404656a07a15090912432f03159a13..1d484ecb77f0ebc75750fd1a4ee621232e6de02f 100644 (file)
@@ -272,19 +272,22 @@ nv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 }
 
 static void
-nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
-                        struct pipe_texture **miptree)
+nv30_set_fragment_sampler_views(struct pipe_context *pipe,
+                               unsigned nr,
+                               struct pipe_sampler_view **views)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
        unsigned unit;
 
        for (unit = 0; unit < nr; unit++) {
+               pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], views[unit]);
                pipe_texture_reference((struct pipe_texture **)
-                                      &nv30->tex_miptree[unit], miptree[unit]);
+                                      &nv30->tex_miptree[unit], views[unit]->texture);
                nv30->dirty_samplers |= (1 << unit);
        }
 
        for (unit = nr; unit < nv30->nr_textures; unit++) {
+               pipe_sampler_view_reference(&nv30->fragment_sampler_views[unit], NULL);
                pipe_texture_reference((struct pipe_texture **)
                                       &nv30->tex_miptree[unit], NULL);
                nv30->dirty_samplers |= (1 << unit);
@@ -294,6 +297,31 @@ nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
        nv30->dirty |= NV30_NEW_SAMPLER;
 }
 
+static struct pipe_sampler_view *
+nv30_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;
+}
+
+
+static void
+nv30_sampler_view_destroy(struct pipe_context *pipe,
+                         struct pipe_sampler_view *view)
+{
+       pipe_texture_reference(&view->texture, NULL);
+       FREE(view);
+}
+
 static void *
 nv30_rasterizer_state_create(struct pipe_context *pipe,
                             const struct pipe_rasterizer_state *cso)
@@ -692,7 +720,9 @@ nv30_init_state_functions(struct nv30_context *nv30)
        nv30->pipe.create_sampler_state = nv30_sampler_state_create;
        nv30->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind;
        nv30->pipe.delete_sampler_state = nv30_sampler_state_delete;
-       nv30->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture;
+       nv30->pipe.set_fragment_sampler_views = nv30_set_fragment_sampler_view;
+       nv30->pipe.create_sampler_view = nv30_create_sampler_view;
+       nv30->pipe.sampler_view_destroy = nv30_sampler_view_destroy;
 
        nv30->pipe.create_rasterizer_state = nv30_rasterizer_state_create;
        nv30->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind;