#include "r300_screen.h"
#include "r300_screen_buffer.h"
-static void r300_update_num_contexts(struct r300_screen *r300screen,
- int diff)
-{
- pipe_mutex_lock(r300screen->num_contexts_mutex);
- if (diff > 0) {
- r300screen->num_contexts++;
-
- if (r300screen->num_contexts > 1)
- util_slab_set_thread_safety(&r300screen->pool_buffers,
- UTIL_SLAB_MULTITHREADED);
- } else {
- r300screen->num_contexts--;
-
- if (r300screen->num_contexts <= 1)
- util_slab_set_thread_safety(&r300screen->pool_buffers,
- UTIL_SLAB_SINGLETHREADED);
- }
- pipe_mutex_unlock(r300screen->num_contexts_mutex);
-}
-
static void r300_release_referenced_objects(struct r300_context *r300)
{
struct pipe_framebuffer_state *fb =
/* XXX: No way to tell if this was initialized or not? */
util_slab_destroy(&r300->pool_transfers);
- r300_update_num_contexts(r300->screen, -1);
-
/* Free the structs allocated in r300_setup_atoms() */
if (r300->aa_state.state) {
FREE(r300->aa_state.state);
if (!r300)
return NULL;
- r300_update_num_contexts(r300screen, 1);
-
r300->rws = rws;
r300->screen = r300screen;
struct r300_screen* r300screen = r300_screen(pscreen);
struct radeon_winsys *rws = radeon_winsys(pscreen);
- util_slab_destroy(&r300screen->pool_buffers);
- pipe_mutex_destroy(r300screen->num_contexts_mutex);
-
if (rws)
rws->destroy(rws);
if (r300screen->info.drm_minor < 8)
r300screen->caps.has_us_format = FALSE;
- pipe_mutex_init(r300screen->num_contexts_mutex);
-
- util_slab_create(&r300screen->pool_buffers,
- sizeof(struct r300_resource), 64,
- UTIL_SLAB_SINGLETHREADED);
-
r300screen->rws = rws;
r300screen->screen.destroy = r300_destroy_screen;
r300screen->screen.get_name = r300_get_name;
struct radeon_info info;
struct r300_capabilities caps;
- /* Memory pools. */
- struct util_slab_mempool pool_buffers;
-
/** Combination of DBG_xxx flags */
unsigned debug;
-
- /* The number of created contexts to know whether we have multiple
- * contexts or not. */
- int num_contexts;
- pipe_mutex num_contexts_mutex;
};
static void r300_buffer_destroy(struct pipe_screen *screen,
struct pipe_resource *buf)
{
- struct r300_screen *r300screen = r300_screen(screen);
struct r300_resource *rbuf = r300_resource(buf);
if (rbuf->constant_buffer)
if (rbuf->buf)
pb_reference(&rbuf->buf, NULL);
- util_slab_free(&r300screen->pool_buffers, rbuf);
+ FREE(rbuf);
}
static struct pipe_transfer*
struct r300_resource *rbuf;
unsigned alignment = 16;
- rbuf = util_slab_alloc(&r300screen->pool_buffers);
+ rbuf = MALLOC_STRUCT(r300_resource);
rbuf->b.b = *templ;
rbuf->b.vtbl = &r300_buffer_vtbl;
rbuf->b.b.width0, alignment,
rbuf->b.b.bind, rbuf->domain);
if (!rbuf->buf) {
- util_slab_free(&r300screen->pool_buffers, rbuf);
+ FREE(rbuf);
return NULL;
}