summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-20 15:09:27 -0700
committerBrian <[email protected]>2008-02-20 15:09:44 -0700
commit25ea1901b44107a5bc5351487e18d52d75df8ffd (patch)
tree6b5255f7342a5fccabdbe0d3c845a0fbb12693af /src/gallium/drivers/softpipe
parentfce61f341faf6a2e1a8497ab963985ddbffa8b0a (diff)
gallium: replace some ordinary assignments with pipe_reference_texture()
This fixes at least one instance of dereferencing an invalid texture pointer.
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c5
4 files changed, 8 insertions, 4 deletions
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index b70d4fea85a..a50cee76486 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -68,7 +68,7 @@ struct softpipe_context {
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct softpipe_texture *texture[PIPE_MAX_SAMPLERS];
+ struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index cf1b1eff75c..2f40e09d5c2 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -142,7 +142,7 @@ static void shade_begin(struct quad_stage *qs)
/* set TGSI sampler state that varies */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
qss->samplers[i].state = softpipe->sampler[i];
- qss->samplers[i].texture = &softpipe->texture[i]->base;
+ qss->samplers[i].texture = softpipe->texture[i];
}
/* find output slots for depth, color */
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 9246915e19e..18669a1c6ef 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -30,6 +30,7 @@
*/
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
@@ -82,7 +83,7 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
draw_flush(softpipe->draw);
assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
+ pipe_texture_reference(pipe, &softpipe->texture[unit], texture);
sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 295704c05f8..6ba0f09e0a1 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -89,6 +89,7 @@ softpipe_texture_create(struct pipe_context *pipe,
return NULL;
spt->base = *templat;
+ spt->base.refcount = 1;
softpipe_texture_layout(spt);
@@ -100,6 +101,8 @@ softpipe_texture_create(struct pipe_context *pipe,
return NULL;
}
+ assert(spt->base.refcount == 1);
+
return &spt->base;
}
@@ -136,7 +139,7 @@ softpipe_texture_update(struct pipe_context *pipe,
struct softpipe_context *softpipe = softpipe_context(pipe);
uint unit;
for (unit = 0; unit < PIPE_MAX_SAMPLERS; unit++) {
- if (softpipe->texture[unit] == softpipe_texture(texture)) {
+ if (softpipe->texture[unit] == texture) {
sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
}
}