/** * Create new pipe_resource given the template information. */ static struct pipe_resource * softpipe_resource_create(struct pipe_screen *screen, const struct pipe_resource *templat) { struct softpipe_resource *spr = CALLOC_STRUCT(softpipe_resource); if (!spr) return NULL; assert(templat->format != PIPE_FORMAT_NONE); spr->base = *templat; pipe_reference_init(&spr->base.reference, 1); spr->base.screen = screen; spr->pot = (util_is_power_of_two(templat->width0) && util_is_power_of_two(templat->height0) && util_is_power_of_two(templat->depth0)); if (spr->base.bind & (PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) { if (!softpipe_displaytarget_layout(screen, spr)) goto fail; } else { if (!softpipe_resource_layout(screen, spr)) goto fail; } return &spr->base; fail: FREE(spr); return NULL; }
static struct pipe_texture * softpipe_texture_create(struct pipe_screen *screen, const struct pipe_texture *templat) { struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture); if (!spt) return NULL; spt->base = *templat; spt->base.refcount = 1; spt->base.screen = screen; if (spt->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { if (!softpipe_displaytarget_layout(screen, spt)) goto fail; } else { if (!softpipe_texture_layout(screen, spt)) goto fail; } assert(spt->base.refcount == 1); return &spt->base; fail: FREE(spt); return NULL; }