This fixes at least one instance of dereferencing an invalid texture pointer.tags/mesa_20090313
@@ -88,6 +88,7 @@ cell_texture_create(struct pipe_context *pipe, | |||
return NULL; | |||
spt->base = *templat; | |||
spt->base.refcount = 1; | |||
cell_texture_layout(spt); | |||
@@ -32,6 +32,7 @@ | |||
#include "draw/draw_context.h" | |||
#include "pipe/p_winsys.h" | |||
#include "pipe/p_util.h" | |||
#include "pipe/p_inlines.h" | |||
#include "i915_context.h" | |||
#include "i915_reg.h" | |||
@@ -505,7 +506,9 @@ static void i915_set_sampler_texture(struct pipe_context *pipe, | |||
{ | |||
struct i915_context *i915 = i915_context(pipe); | |||
i915->texture[sampler] = (struct i915_texture*)texture; /* ptr, not struct */ | |||
pipe_texture_reference(pipe, | |||
(struct pipe_texture **) &i915->texture[sampler], | |||
texture); | |||
i915->dirty |= I915_NEW_TEXTURE; | |||
} |
@@ -488,6 +488,7 @@ i915_texture_create(struct pipe_context *pipe, | |||
struct i915_context *i915 = i915_context(pipe); | |||
tex->base = *templat; | |||
tex->base.refcount = 1; | |||
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) : | |||
i915_miptree_layout(pipe, tex)) |
@@ -327,7 +327,9 @@ static void brw_set_sampler_texture(struct pipe_context *pipe, | |||
{ | |||
struct brw_context *brw = brw_context(pipe); | |||
brw->attribs.Texture[unit] = (struct brw_texture*)texture; /* ptr, not struct */ | |||
pipe_reference_texture(pipe, | |||
(struct pipe_texture **) &brw->attribs.Texture[unit], | |||
texture); | |||
brw->state.dirty.brw |= BRW_NEW_TEXTURE; | |||
} |
@@ -308,6 +308,7 @@ brw_texture_create(struct pipe_context *pipe, | |||
if (tex) { | |||
tex->base = *templat; | |||
tex->base.refcount = 1; | |||
if (brw_miptree_layout(pipe, tex)) | |||
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, |
@@ -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]; |
@@ -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 */ |
@@ -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); | |||
@@ -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]); | |||
} | |||
} |
@@ -76,7 +76,7 @@ st_texture_create(struct st_context *st, | |||
GLuint depth0, | |||
GLuint compress_byte) | |||
{ | |||
struct pipe_texture pt; | |||
struct pipe_texture pt, *newtex; | |||
assert(target <= PIPE_TEXTURE_CUBE); | |||
@@ -95,9 +95,12 @@ st_texture_create(struct st_context *st, | |||
pt.depth[0] = depth0; | |||
pt.compressed = compress_byte ? 1 : 0; | |||
pt.cpp = pt.compressed ? compress_byte : st_sizeof_format(format); | |||
pt.refcount = 1; | |||
return st->pipe->texture_create(st->pipe, &pt); | |||
newtex = st->pipe->texture_create(st->pipe, &pt); | |||
assert(!newtex || newtex->refcount == 1); | |||
return newtex; | |||
} | |||