r300screen->screen.resource_create = r300_resource_create;
r300screen->screen.resource_from_handle = r300_texture_from_handle;
r300screen->screen.resource_get_handle = r300_resource_get_handle;
- r300screen->screen.resource_destroy = u_resource_destroy_vtbl;
+ r300screen->screen.resource_destroy = r300_resource_destroy;
}
*start = index_offset / index_size;
}
-static void r300_buffer_destroy(struct pipe_screen *screen,
- struct pipe_resource *buf)
+void r300_resource_destroy(struct pipe_screen *screen,
+ struct pipe_resource *buf)
{
- struct r300_resource *rbuf = r300_resource(buf);
-
- align_free(rbuf->malloced_buffer);
-
- if (rbuf->buf)
- pb_reference(&rbuf->buf, NULL);
-
- FREE(rbuf);
+ if (buf->target == PIPE_BUFFER) {
+ struct r300_resource *rbuf = r300_resource(buf);
+
+ align_free(rbuf->malloced_buffer);
+
+ if (rbuf->buf)
+ pb_reference(&rbuf->buf, NULL);
+
+ FREE(rbuf);
+ } else {
+ struct r300_screen *rscreen = r300_screen(screen);
+ struct r300_resource* tex = (struct r300_resource*)buf;
+
+ if (tex->tex.cmask_dwords) {
+ mtx_lock(&rscreen->cmask_mutex);
+ if (buf == rscreen->cmask_resource) {
+ rscreen->cmask_resource = NULL;
+ }
+ mtx_unlock(&rscreen->cmask_mutex);
+ }
+ pb_reference(&tex->buf, NULL);
+ FREE(tex);
+ }
}
static void *
static const struct u_resource_vtbl r300_buffer_vtbl =
{
- r300_buffer_destroy, /* resource_destroy */
+ NULL, /* resource_destroy */
r300_buffer_transfer_map, /* transfer_map */
r300_buffer_transfer_unmap, /* transfer_unmap */
};
unsigned index_size, unsigned *start,
unsigned count, const uint8_t *ptr);
+void r300_resource_destroy(struct pipe_screen *screen,
+ struct pipe_resource *buf);
+
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ);
}
}
-static void r300_texture_destroy(struct pipe_screen *screen,
- struct pipe_resource* texture)
-{
- struct r300_screen *rscreen = r300_screen(screen);
- struct r300_resource* tex = (struct r300_resource*)texture;
-
- if (tex->tex.cmask_dwords) {
- mtx_lock(&rscreen->cmask_mutex);
- if (texture == rscreen->cmask_resource) {
- rscreen->cmask_resource = NULL;
- }
- mtx_unlock(&rscreen->cmask_mutex);
- }
- pb_reference(&tex->buf, NULL);
- FREE(tex);
-}
-
bool r300_resource_get_handle(struct pipe_screen* screen,
struct pipe_context *ctx,
struct pipe_resource *texture,
static const struct u_resource_vtbl r300_texture_vtbl =
{
- r300_texture_destroy, /* resource_destroy */
+ NULL, /* resource_destroy */
r300_texture_transfer_map, /* transfer_map */
r300_texture_transfer_unmap, /* transfer_unmap */
};