Browse Source

gallium: replace some ordinary assignments with pipe_reference_texture()

This fixes at least one instance of dereferencing an invalid texture pointer.
tags/mesa_20090313
Brian 17 years ago
parent
commit
25ea1901b4

+ 1
- 0
src/gallium/drivers/cell/ppu/cell_texture.c View File

return NULL; return NULL;


spt->base = *templat; spt->base = *templat;
spt->base.refcount = 1;


cell_texture_layout(spt); cell_texture_layout(spt);



+ 4
- 1
src/gallium/drivers/i915simple/i915_state.c View File

#include "draw/draw_context.h" #include "draw/draw_context.h"
#include "pipe/p_winsys.h" #include "pipe/p_winsys.h"
#include "pipe/p_util.h" #include "pipe/p_util.h"
#include "pipe/p_inlines.h"


#include "i915_context.h" #include "i915_context.h"
#include "i915_reg.h" #include "i915_reg.h"
{ {
struct i915_context *i915 = i915_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; i915->dirty |= I915_NEW_TEXTURE;
} }

+ 1
- 0
src/gallium/drivers/i915simple/i915_texture.c View File

struct i915_context *i915 = i915_context(pipe); struct i915_context *i915 = i915_context(pipe);


tex->base = *templat; tex->base = *templat;
tex->base.refcount = 1;


if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) : if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex)) i915_miptree_layout(pipe, tex))

+ 3
- 1
src/gallium/drivers/i965simple/brw_state.c View File

{ {
struct brw_context *brw = brw_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; brw->state.dirty.brw |= BRW_NEW_TEXTURE;
} }

+ 1
- 0
src/gallium/drivers/i965simple/brw_tex_layout.c View File



if (tex) { if (tex) {
tex->base = *templat; tex->base = *templat;
tex->base.refcount = 1;


if (brw_miptree_layout(pipe, tex)) if (brw_miptree_layout(pipe, tex))
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,

+ 1
- 1
src/gallium/drivers/softpipe/sp_context.h View File

struct pipe_framebuffer_state framebuffer; struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple; struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor; 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_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];

+ 1
- 1
src/gallium/drivers/softpipe/sp_quad_fs.c View File

/* set TGSI sampler state that varies */ /* set TGSI sampler state that varies */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
qss->samplers[i].state = softpipe->sampler[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 */ /* find output slots for depth, color */

+ 2
- 1
src/gallium/drivers/softpipe/sp_state_sampler.c View File

*/ */


#include "pipe/p_util.h" #include "pipe/p_util.h"
#include "pipe/p_inlines.h"


#include "draw/draw_context.h" #include "draw/draw_context.h"


draw_flush(softpipe->draw); draw_flush(softpipe->draw);


assert(unit < PIPE_MAX_SAMPLERS); 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); sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);



+ 4
- 1
src/gallium/drivers/softpipe/sp_texture.c View File

return NULL; return NULL;


spt->base = *templat; spt->base = *templat;
spt->base.refcount = 1;


softpipe_texture_layout(spt); softpipe_texture_layout(spt);


return NULL; return NULL;
} }


assert(spt->base.refcount == 1);

return &spt->base; return &spt->base;
} }


struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
uint unit; uint unit;
for (unit = 0; unit < PIPE_MAX_SAMPLERS; 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]); sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
} }
} }

+ 6
- 3
src/mesa/state_tracker/st_texture.c View File

GLuint depth0, GLuint depth0,
GLuint compress_byte) GLuint compress_byte)
{ {
struct pipe_texture pt;
struct pipe_texture pt, *newtex;


assert(target <= PIPE_TEXTURE_CUBE); assert(target <= PIPE_TEXTURE_CUBE);


pt.depth[0] = depth0; pt.depth[0] = depth0;
pt.compressed = compress_byte ? 1 : 0; pt.compressed = compress_byte ? 1 : 0;
pt.cpp = pt.compressed ? compress_byte : st_sizeof_format(format); 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;
} }





Loading…
Cancel
Save