Now, pass in a template object and return a new object.
}
-void
-cell_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
+struct pipe_texture *
+cell_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
{
- struct cell_texture *spt = REALLOC(*pt, sizeof(struct pipe_texture),
- sizeof(struct cell_texture));
+ struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
+ if (!spt)
+ return NULL;
- if (spt) {
- memset(&spt->base + 1, 0,
- sizeof(struct cell_texture) - sizeof(struct pipe_texture));
+ spt->base = *templat;
- cell_texture_layout(spt);
+ cell_texture_layout(spt);
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
+ spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
- if (!spt->buffer) {
- FREE(spt);
- spt = NULL;
- }
+ if (!spt->buffer) {
+ FREE(spt);
+ return NULL;
}
- *pt = &spt->base;
+ return &spt->base;
}
+
void
cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
-extern void
-cell_texture_create(struct pipe_context *pipe, struct pipe_texture **pt);
+extern struct pipe_texture *
+cell_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat);
extern void
cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
return TRUE;
}
-void
-i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
+
+struct pipe_texture *
+i915_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat)
{
- struct i915_texture *tex = REALLOC(*pt, sizeof(struct pipe_texture),
- sizeof(struct i915_texture));
+ struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
if (tex) {
struct i915_context *i915 = i915_context(pipe);
- memset(&tex->base + 1, 0,
- sizeof(struct i915_texture) - sizeof(struct pipe_texture));
+ tex->base = *templat;
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex))
if (!tex->buffer) {
FREE(tex);
- tex = NULL;
+ return NULL;
}
}
- *pt = &tex->base;
+ return &tex->base;
}
+
void
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
struct pipe_texture;
-extern void
-i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt);
+struct pipe_texture *
+i915_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat);
extern void
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
return TRUE;
}
-void
-brw_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
+
+struct pipe_texture *
+brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
{
- struct brw_texture *tex = REALLOC(*pt, sizeof(struct pipe_texture),
- sizeof(struct brw_texture));
+ struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
- memset(&tex->base + 1, 0,
- sizeof(struct brw_texture) - sizeof(struct pipe_texture));
+ tex->base = *templat;
if (brw_miptree_layout(pipe, tex))
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
if (!tex->buffer) {
FREE(tex);
- tex = NULL;
+ return NULL;
}
}
- *pt = &tex->base;
+ return &tex->base;
}
void
struct pipe_context;
struct pipe_texture;
-extern void
-brw_texture_create(struct pipe_context *pipe, struct pipe_texture **pt);
+extern struct pipe_texture *
+brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat);
extern void
brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
/*
* Texture functions
*/
- void (*texture_create)(struct pipe_context *pipe,
- struct pipe_texture **pt);
+ struct pipe_texture * (*texture_create)(struct pipe_context *pipe,
+ const struct pipe_texture *templat);
void (*texture_release)(struct pipe_context *pipe,
struct pipe_texture **pt);
}
-void
-softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
+struct pipe_texture *
+softpipe_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat)
{
- struct softpipe_texture *spt = REALLOC(*pt, sizeof(struct pipe_texture),
- sizeof(struct softpipe_texture));
-
- if (spt) {
- memset(&spt->base + 1, 0,
- sizeof(struct softpipe_texture) - sizeof(struct pipe_texture));
+ struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
+ if (!spt)
+ return NULL;
- softpipe_texture_layout(spt);
+ spt->base = *templat;
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
+ softpipe_texture_layout(spt);
- if (!spt->buffer) {
- FREE(spt);
- spt = NULL;
- }
+ spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
+ if (!spt->buffer) {
+ FREE(spt);
+ return NULL;
}
- *pt = &spt->base;
+ return &spt->base;
}
+
void
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
-extern void
-softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt);
+extern struct pipe_texture *
+softpipe_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat);
extern void
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
GLuint depth0,
GLuint compress_byte)
{
- struct pipe_texture *pt = CALLOC_STRUCT(pipe_texture);
+ struct pipe_texture pt;
assert(target <= PIPE_TEXTURE_CUBE);
_mesa_lookup_enum_by_nr(target),
_mesa_lookup_enum_by_nr(format), first_level, last_level);
- if (!pt)
- return NULL;
-
assert(format);
- pt->target = target;
- pt->format = format;
- pt->first_level = first_level;
- pt->last_level = last_level;
- pt->width[0] = width0;
- pt->height[0] = height0;
- pt->depth[0] = depth0;
- pt->compressed = compress_byte ? 1 : 0;
- pt->cpp = pt->compressed ? compress_byte : st_sizeof_format(format);
- pt->refcount = 1;
-
- st->pipe->texture_create(st->pipe, &pt);
-
- return pt;
+ pt.target = target;
+ pt.format = format;
+ pt.first_level = first_level;
+ pt.last_level = last_level;
+ pt.width[0] = width0;
+ pt.height[0] = height0;
+ 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);
}