This fixes at least one instance of dereferencing an invalid texture pointer.
return NULL;
spt->base = *templat;
+ spt->base.refcount = 1;
cell_texture_layout(spt);
#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"
{
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;
}
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))
{
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;
}
if (tex) {
tex->base = *templat;
+ tex->base.refcount = 1;
if (brw_miptree_layout(pipe, tex))
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
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];
/* 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 */
*/
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
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);
return NULL;
spt->base = *templat;
+ spt->base.refcount = 1;
softpipe_texture_layout(spt);
return NULL;
}
+ assert(spt->base.refcount == 1);
+
return &spt->base;
}
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]);
}
}
GLuint depth0,
GLuint compress_byte)
{
- struct pipe_texture pt;
+ struct pipe_texture pt, *newtex;
assert(target <= PIPE_TEXTURE_CUBE);
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;
}