Mesa (gallium-sampler-view): nv40: Fix after sampler view changes.

Michał Król michal at kemper.freedesktop.org
Thu Feb 25 13:56:30 UTC 2010


Module: Mesa
Branch: gallium-sampler-view
Commit: 512d3e691e43b663932fcf22a8c333c79033cb8b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=512d3e691e43b663932fcf22a8c333c79033cb8b

Author: Michal Krol <michal at vmware.com>
Date:   Thu Feb 25 14:46:31 2010 +0100

nv40: Fix after sampler view changes.

Did not test build.

---

 src/gallium/drivers/nv40/nv40_context.h |    1 +
 src/gallium/drivers/nv40/nv40_state.c   |   38 +++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index 4861924..3d41042 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -153,6 +153,7 @@ struct nv40_context {
 	unsigned idxbuf_format;
 	struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
 	struct nv40_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;
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 4f28675..dbb52bf 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -282,19 +282,22 @@ nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
 }
 
 static void
-nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
-			 struct pipe_texture **miptree)
+nv40_set_fragment_sampler_views(struct pipe_context *pipe,
+				unsigned nr,
+				struct pipe_sampler_view **views)
 {
 	struct nv40_context *nv40 = nv40_context(pipe);
 	unsigned unit;
 
 	for (unit = 0; unit < nr; unit++) {
+		pipe_sampler_view_reference(&nv40->fragment_sampler_views[unit], views[unit]);
 		pipe_texture_reference((struct pipe_texture **)
-				       &nv40->tex_miptree[unit], miptree[unit]);
+				       &nv40->tex_miptree[unit], views[unit]->texture);
 		nv40->dirty_samplers |= (1 << unit);
 	}
 
 	for (unit = nr; unit < nv40->nr_textures; unit++) {
+		pipe_sampler_view_reference(&nv40->fragment_sampler_views[unit], NULL);
 		pipe_texture_reference((struct pipe_texture **)
 				       &nv40->tex_miptree[unit], NULL);
 		nv40->dirty_samplers |= (1 << unit);
@@ -304,6 +307,31 @@ nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
 	nv40->dirty |= NV40_NEW_SAMPLER;
 }
 
+static struct pipe_sampler_view *
+nv40_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
+nv40_sampler_view_destroy(struct pipe_context *pipe,
+			  struct pipe_sampler_view *view)
+{
+	pipe_texture_reference(&view->texture, NULL);
+	FREE(view);
+}
+
 static void *
 nv40_rasterizer_state_create(struct pipe_context *pipe,
 			     const struct pipe_rasterizer_state *cso)
@@ -707,7 +735,9 @@ nv40_init_state_functions(struct nv40_context *nv40)
 	nv40->pipe.create_sampler_state = nv40_sampler_state_create;
 	nv40->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
 	nv40->pipe.delete_sampler_state = nv40_sampler_state_delete;
-	nv40->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture;
+	nv40->pipe.set_fragment_sampler_views = nv40_set_fragment_sampler_views;
+	nv40->pipe.create_sampler_view = nv40_create_sampler_view;
+	nv40->pipe.sampler_view_destroy = nv40_sampler_view_destroy;
 
 	nv40->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
 	nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;




More information about the mesa-commit mailing list