diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-03-04 15:23:35 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-03-04 15:23:35 +0000 |
commit | 5b04939b16eb6e13858b070315dee1d0fc09d94f (patch) | |
tree | 0f8739ea6fa7219eaebbb9ff090f86713ef820e0 /src/gallium/winsys | |
parent | cfd5298f240612ef69ae321aebbc425710a8d731 (diff) | |
parent | f9ce417aaf14c00e72e92307b910de5dbed1bb6d (diff) |
Merge commit 'origin/master' into gallium-map-range
Diffstat (limited to 'src/gallium/winsys')
22 files changed, 232 insertions, 118 deletions
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.c b/src/gallium/winsys/drm/intel/gem/intel_be_api.c index 3f71c25441..f4ef7c2d88 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c @@ -2,7 +2,7 @@ #include "intel_be_api.h" #include "i915simple/i915_winsys.h" -struct drm_api drm_api_hocks = +struct drm_api drm_api_hooks = { /* intel_be_context.c */ .create_context = intel_be_create_context, diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c index 0137433785..d5e63c3bae 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c @@ -114,10 +114,10 @@ intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch, if (fence) { if (*fence) - intel_be_fence_unreference(*fence); + intel_be_fence_reference(fence, NULL); (*fence) = CALLOC_STRUCT(intel_be_fence); - (*fence)->refcount = 1; + pipe_reference_init(&(*fence)->reference, 1); (*fence)->bo = NULL; } } diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index 2e191a6d12..de13fb39c7 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -51,8 +51,7 @@ intel_be_buffer_unmap(struct pipe_winsys *winsys, } static void -intel_be_buffer_destroy(struct pipe_winsys *winsys, - struct pipe_buffer *buf) +intel_be_buffer_destroy(struct pipe_buffer *buf) { drm_intel_bo_unreference(intel_bo(buf)); free(buf); @@ -72,7 +71,7 @@ intel_be_buffer_create(struct pipe_winsys *winsys, if (!buffer) return NULL; - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -115,7 +114,7 @@ intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned byte if (!buffer) return NULL; - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = 0; buffer->base.usage = 0; buffer->base.size = bytes; @@ -155,7 +154,7 @@ intel_be_buffer_from_handle(struct pipe_screen *screen, if (!buffer->bo) goto err; - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = buffer->bo->align; buffer->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE | @@ -215,15 +214,7 @@ intel_be_fence_refunref(struct pipe_winsys *sws, struct intel_be_fence **p = (struct intel_be_fence **)ptr; struct intel_be_fence *f = (struct intel_be_fence *)fence; - assert(p); - - if (f) - intel_be_fence_reference(f); - - if (*p) - intel_be_fence_unreference(*p); - - *p = f; + intel_be_fence_reference(p, f); } static int diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h index 0fe18f66f8..a8abb01a9e 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h @@ -15,23 +15,19 @@ */ struct intel_be_fence { - uint32_t refcount; + struct pipe_reference reference; drm_intel_bo *bo; }; static INLINE void -intel_be_fence_reference(struct intel_be_fence *f) +intel_be_fence_reference(struct intel_be_fence **ptr, struct intel_be_fence *f) { - f->refcount++; -} + struct intel_be_fence *old_fence = *ptr; -static INLINE void -intel_be_fence_unreference(struct intel_be_fence *f) -{ - if (!--f->refcount) { - if (f->bo) - drm_intel_bo_unreference(f->bo); - free(f); + if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) { + if (old_fence->bo) + drm_intel_bo_unreference(old_fence->bo); + free(old_fence); } } diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c b/src/gallium/winsys/drm/nouveau/common/nouveau_context.c index d6ae0827cd..25c98456ac 100644 --- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c +++ b/src/gallium/winsys/drm/nouveau/common/nouveau_context.c @@ -109,8 +109,7 @@ nouveau_context_init(struct nouveau_screen *nv_screen, nv_screen->nvc = nvc; } - nvc->refcount++; - nv->nvc = nvc; + pipe_reference((struct pipe_reference**)&nv->nvc, &nvc->reference); /* Find a free slot for a pipe context, allocate a new one if needed */ nv->pctx_id = -1; @@ -159,7 +158,7 @@ nouveau_context_init(struct nouveau_screen *nv_screen, enum pipe_format format; fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer)); - fb_buf->base.refcount = 1; + pipe_reference_init(&fb_buf->base.reference, 1); fb_buf->base.usage = PIPE_BUFFER_USAGE_PIXEL; nouveau_bo_fake(dev, nv_screen->front_offset, NOUVEAU_BO_VRAM, @@ -195,7 +194,7 @@ nouveau_context_cleanup(struct nouveau_context *nv) if (nv->pctx_id >= 0) { nvc->pctx[nv->pctx_id] = NULL; - if (--nvc->refcount <= 0) { + if (pipe_reference((struct pipe_reference**)&nv->nvc, NULL)) { nouveau_channel_context_destroy(nvc); nv->nv_screen->nvc = NULL; } diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h b/src/gallium/winsys/drm/nouveau/common/nouveau_context.h index 02d2745680..ba8fc3ad2d 100644 --- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h +++ b/src/gallium/winsys/drm/nouveau/common/nouveau_context.h @@ -13,8 +13,8 @@ #include "nouveau_local.h" struct nouveau_channel_context { + struct pipe_reference reference; struct pipe_screen *pscreen; - int refcount; unsigned cur_pctx; unsigned nr_pctx; diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c index 54c7dd46b1..24bbd4516f 100644 --- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c +++ b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c @@ -67,7 +67,7 @@ nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment, nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); if (!nvbuf) return NULL; - nvbuf->base.refcount = 1; + pipe_reference_init(&nvbuf->base.reference, 1); nvbuf->base.alignment = alignment; nvbuf->base.usage = usage; nvbuf->base.size = size; @@ -92,7 +92,7 @@ nouveau_pipe_bo_user_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer); if (!nvbuf) return NULL; - nvbuf->base.refcount = 1; + pipe_reference_init(&nvbuf->base.reference, 1); nvbuf->base.size = bytes; if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) { @@ -104,7 +104,7 @@ nouveau_pipe_bo_user_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) } static void -nouveau_pipe_bo_del(struct pipe_winsys *ws, struct pipe_buffer *buf) +nouveau_pipe_bo_del(struct pipe_buffer *buf) { struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf); diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile index 784686ffb6..8721f2cb5d 100644 --- a/src/gallium/winsys/drm/radeon/Makefile +++ b/src/gallium/winsys/drm/radeon/Makefile @@ -7,15 +7,14 @@ LIBNAME = radeon_dri.so MINIGLX_SOURCES = PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/r300/libr300.a DRIVER_SOURCES = \ radeon_buffer.c \ - radeon_context.c \ radeon_drm.c \ radeon_r300.c \ - radeon_screen.c \ radeon_winsys_softpipe.c C_SOURCES = \ diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.c b/src/gallium/winsys/drm/radeon/radeon_buffer.c index 918d2f98e2..b3582e3314 100644 --- a/src/gallium/winsys/drm/radeon/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/radeon_buffer.c @@ -1,5 +1,6 @@ /* * Copyright © 2008 Jérôme Glisse + * 2009 Corbin Simpson * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining @@ -26,10 +27,14 @@ /* * Authors: * Jérôme Glisse <glisse@freedesktop.org> + * Corbin Simpson <MostAwesomeDude@gmail.com> */ #include <stdio.h> -#include "dri_util.h" + #include "state_tracker/st_public.h" + +#include "util/u_memory.h" + #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "radeon_buffer.h" @@ -38,25 +43,27 @@ #include "radeon_bo.h" #include "radeon_drm.h" + static const char *radeon_get_name(struct pipe_winsys *ws) { - return "RADEON/DRI2"; + return "Radeon/GEM+KMS"; } static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, - unsigned alignment, - unsigned usage, - unsigned size) + unsigned alignment, + unsigned usage, + unsigned size) { - struct radeon_pipe_winsys *radeon_ws = (struct radeon_pipe_winsys *)ws; + struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws; struct radeon_pipe_buffer *radeon_buffer; uint32_t domain; - radeon_buffer = calloc(1, sizeof(*radeon_buffer)); + radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); if (radeon_buffer == NULL) { return NULL; } - radeon_buffer->base.refcount = 1; + + pipe_reference_init(&radeon_buffer->base.reference, 1); radeon_buffer->base.alignment = alignment; radeon_buffer->base.usage = usage; radeon_buffer->base.size = size; @@ -69,21 +76,21 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, if (usage & PIPE_BUFFER_USAGE_VERTEX) { domain |= RADEON_GEM_DOMAIN_GTT; } - if (usage & PIPE_BUFFER_USAGE_INDEX) { domain |= RADEON_GEM_DOMAIN_GTT; } - radeon_buffer->bo = radeon_bo_open(radeon_ws->radeon_screen->bom, 0, - size, alignment, domain, 0); + + radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment, + domain, 0); if (radeon_buffer->bo == NULL) { - free(radeon_buffer); + FREE(radeon_buffer); } return &radeon_buffer->base; } static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, - void *ptr, - unsigned bytes) + void *ptr, + unsigned bytes) { struct radeon_pipe_buffer *radeon_buffer; @@ -97,7 +104,7 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, return &radeon_buffer->base; } -static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer) +static void radeon_buffer_del(struct pipe_buffer *buffer) { struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; @@ -106,21 +113,20 @@ static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer } static void *radeon_buffer_map(struct pipe_winsys *ws, - struct pipe_buffer *buffer, - unsigned flags) + struct pipe_buffer *buffer, + unsigned flags) { struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; int write = 0; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { - /* Remove this when radeon_bo_map supports DONTBLOCK - */ + /* XXX Remove this when radeon_bo_map supports DONTBLOCK */ return NULL; } - if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) { write = 1; } + if (radeon_bo_map(radeon_buffer->bo, write)) return NULL; return radeon_buffer->bo->ptr; @@ -134,59 +140,58 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, struct pipe_buffer *buff } static void radeon_fence_reference(struct pipe_winsys *ws, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *pfence) + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *pfence) { } static int radeon_fence_signalled(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, - unsigned flag) + struct pipe_fence_handle *pfence, + unsigned flag) { return 1; } static int radeon_fence_finish(struct pipe_winsys *ws, - struct pipe_fence_handle *pfence, - unsigned flag) + struct pipe_fence_handle *pfence, + unsigned flag) { return 0; } static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys, - struct pipe_surface *pipe_surface, - void *context_private) + struct pipe_surface *pipe_surface, + void *context_private) { /* TODO: call dri2CopyRegion */ } -struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen) +struct pipe_winsys *radeon_pipe_winsys() { - struct radeon_pipe_winsys *radeon_ws; + struct pipe_winsys *radeon_ws; - radeon_ws = calloc(1, sizeof(struct radeon_pipe_winsys)); + radeon_ws = CALLOC_STRUCT(pipe_winsys); if (radeon_ws == NULL) { return NULL; } - radeon_ws->radeon_screen = radeon_screen; - radeon_ws->winsys.flush_frontbuffer = radeon_flush_frontbuffer; + radeon_ws->flush_frontbuffer = radeon_flush_frontbuffer; - radeon_ws->winsys.buffer_create = radeon_buffer_create; - radeon_ws->winsys.buffer_destroy = radeon_buffer_del; - radeon_ws->winsys.user_buffer_create = radeon_buffer_user_create; - radeon_ws->winsys.buffer_map = radeon_buffer_map; - radeon_ws->winsys.buffer_unmap = radeon_buffer_unmap; + radeon_ws->buffer_create = radeon_buffer_create; + radeon_ws->buffer_destroy = radeon_buffer_del; + radeon_ws->user_buffer_create = radeon_buffer_user_create; + radeon_ws->buffer_map = radeon_buffer_map; + radeon_ws->buffer_unmap = radeon_buffer_unmap; - radeon_ws->winsys.fence_reference = radeon_fence_reference; - radeon_ws->winsys.fence_signalled = radeon_fence_signalled; - radeon_ws->winsys.fence_finish = radeon_fence_finish; + radeon_ws->fence_reference = radeon_fence_reference; + radeon_ws->fence_signalled = radeon_fence_signalled; + radeon_ws->fence_finish = radeon_fence_finish; - radeon_ws->winsys.get_name = radeon_get_name; + radeon_ws->get_name = radeon_get_name; - return &radeon_ws->winsys; + return radeon_ws; } - +#if 0 static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeon_screen, uint32_t handle) { @@ -202,7 +207,7 @@ static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeo radeon_bo_unref(bo); return NULL; } - radeon_buffer->base.refcount = 1; + pipe_reference_init(&radeon_buffer->base.reference, 1); radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; radeon_buffer->bo = bo; return &radeon_buffer->base; @@ -237,9 +242,10 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb); if (pt == NULL) { - pipe_buffer_reference(pipe_screen, &pb, NULL); + pipe_buffer_reference(&pb, NULL); } ps = pipe_screen->get_tex_surface(pipe_screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); return ps; } +#endif diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.h b/src/gallium/winsys/drm/radeon/radeon_buffer.h index c626c20229..e062308f44 100644 --- a/src/gallium/winsys/drm/radeon/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/radeon_buffer.h @@ -40,12 +40,15 @@ struct radeon_pipe_buffer { struct radeon_bo *bo; }; -struct radeon_pipe_winsys { - struct pipe_winsys winsys; - struct radeon_screen *radeon_screen; +struct radeon_winsys { + /* Parent class. */ + struct pipe_winsys base; + + /* Radeon BO manager. This corresponds to void* radeon_winsys in r300_winsys. */ + struct radeon_bo_manager* bom; }; -struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen); +struct pipe_winsys *radeon_pipe_winsys(); struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context, uint32_t handle, enum pipe_format format, diff --git a/src/gallium/winsys/drm/radeon/radeon_drm.c b/src/gallium/winsys/drm/radeon/radeon_drm.c index 839b0bf0bd..016634c8fd 100644 --- a/src/gallium/winsys/drm/radeon/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/radeon_drm.c @@ -27,4 +27,97 @@ * Authors: * Corbin Simpson <MostAwesomeDude@gmail.com> */ + #include "radeon_drm.h" + +/* Create a pipe_screen. */ +struct pipe_screen* radeon_create_screen(int drmFB, int pciID) +{ + struct radeon_context* radeon = CALLOC_STRUCT(radeon_context); + struct pipe_winsys* winsys = radeon_pipe_winsys(radeon); + + if (getenv("RADEON_SOFTPIPE")) { + return softpipe_create_screen(winsys); + } else { + struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys); + FREE(winsys); + return r300_create_screen(r300); + } +} + +/* Create a pipe_context. */ +struct pipe_context* radeon_create_context(struct pipe_screen* screen) +{ + if (getenv("RADEON_SOFTPIPE")) { + return radeon_create_softpipe(screen->winsys); + } else { + return r300_create_context(screen, screen->winsys); + } +} + +boolean radeon_buffer_from_texture(struct pipe_texture* texture, + struct pipe_buffer** buffer, + unsigned* stride) +{ + return FALSE; +} + +/* Create a buffer from a handle. */ +/* XXX what's up with name? */ +struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, + const char* name, + unsigned handle) +{ + struct radeon_bo_manager* bom = + ((struct radeon_winsys*)screen->winsys)->bom; + struct radeon_pipe_buffer* radeon_buffer; + struct radeon_bo* bo = NULL; + + bo = radeon_bo_open(bom, handle, 0, 0, 0, 0); + if (bo == NULL) { + return NULL; + } + + radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); + if (radeon_buffer == NULL) { + radeon_bo_unref(bo); + return NULL; + } + + pipe_reference_init(&radeon_buffer->base.reference, 1); + radeon_buffer->base.screen = screen; + radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; + radeon_buffer->bo = bo; + return &radeon_buffer->base; +} + +boolean radeon_handle_from_buffer(struct pipe_screen* screen, + struct pipe_buffer* buffer, + unsigned* handle) +{ + struct radeon_pipe_buffer* radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + *handle = radeon_buffer->bo->handle; + return TRUE; +} + +boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, + struct pipe_buffer* buffer, + unsigned* handle) +{ + /* XXX WTF is the difference here? global? */ + struct radeon_pipe_buffer* radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + *handle = radeon_buffer->bo->handle; + return TRUE; +} + +struct drm_api drm_api_hooks = { + .create_screen = radeon_create_screen, + .create_context = radeon_create_context, + /* XXX fix this */ + .buffer_from_texture = r300_get_texture_buffer, + .buffer_from_handle = radeon_buffer_from_handle, + .handle_from_buffer = radeon_handle_from_buffer, + .global_handle_from_buffer = radeon_global_handle_from_buffer, +}; diff --git a/src/gallium/winsys/drm/radeon/radeon_drm.h b/src/gallium/winsys/drm/radeon/radeon_drm.h index 8ccbc81895..e434106cb5 100644 --- a/src/gallium/winsys/drm/radeon/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/radeon_drm.h @@ -30,6 +30,36 @@ #ifndef RADEON_DRM_H #define RADEON_DRM_H +#include "pipe/p_screen.h" + +#include "util/u_memory.h" + #include "state_tracker/drm_api.h" +#include "radeon_buffer.h" +#include "radeon_context.h" +#include "radeon_r300.h" +#include "radeon_screen.h" +#include "radeon_winsys_softpipe.h" + +struct pipe_screen* radeon_create_screen(int drmFB, int pciID); + +struct pipe_context* radeon_create_context(struct pipe_screen* screen); + +boolean radeon_buffer_from_texture(struct pipe_texture* texture, + struct pipe_buffer** buffer, + unsigned* stride); + +struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, + const char* name, + unsigned handle); + +boolean radeon_handle_from_buffer(struct pipe_screen* screen, + struct pipe_buffer* buffer, + unsigned* handle); + +boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, + struct pipe_buffer* buffer, + unsigned* handle); + #endif diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.c b/src/gallium/winsys/drm/radeon/radeon_r300.c index 8fe2375e34..e9b96b1ee9 100644 --- a/src/gallium/winsys/drm/radeon/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/radeon_r300.c @@ -75,14 +75,16 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) } -struct r300_winsys* radeon_create_r300_winsys(int fd) +struct r300_winsys* radeon_create_r300_winsys(int fd, struct pipe_winsys* old_winsys) { - struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys)); + struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys); do_ioctls(winsys, fd); + struct radeon_bo_manager* bom = radeon_bo_manager_gem_ctor(fd); struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd); + winsys->radeon_winsys = bom; winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); winsys->check_cs = radeon_r300_check_cs; @@ -92,5 +94,7 @@ struct r300_winsys* radeon_create_r300_winsys(int fd) winsys->end_cs = radeon_cs_end; winsys->flush_cs = radeon_r300_flush_cs; + winsys->base = *old_winsys; + return winsys; } diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.h b/src/gallium/winsys/drm/radeon/radeon_r300.h index 8ed95a3a9b..432b7b1833 100644 --- a/src/gallium/winsys/drm/radeon/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/radeon_r300.h @@ -31,4 +31,4 @@ #include "radeon_buffer.h" -struct r300_winsys* radeon_create_r300_winsys(int fd); +struct r300_winsys* radeon_create_r300_winsys(int fd, struct pipe_winsys* old_winsys); diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c index 8402e1fa5a..75e975f5e2 100644 --- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c +++ b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c @@ -29,7 +29,6 @@ * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com> */ #include <stdio.h> -#include "imports.h" #include "pipe/p_defines.h" #include "pipe/p_format.h" #include "softpipe/sp_winsys.h" @@ -57,21 +56,19 @@ static boolean radeon_is_format_supported(struct softpipe_winsys *sws, uint form return FALSE; } -struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context) +struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys) { struct radeon_softpipe_winsys *radeon_sp_ws; struct pipe_screen *pipe_screen; - pipe_screen = softpipe_create_screen(radeon_context->pipe_winsys); + pipe_screen = softpipe_create_screen(winsys); radeon_sp_ws = CALLOC_STRUCT(radeon_softpipe_winsys); if (radeon_sp_ws == NULL) { return NULL; } - radeon_context->pipe_screen = pipe_screen; - radeon_sp_ws->radeon_context = radeon_context; radeon_sp_ws->sp_winsys.is_format_supported = radeon_is_format_supported; return softpipe_create(pipe_screen, - radeon_context->pipe_winsys, + winsys, &radeon_sp_ws->sp_winsys); } diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h index 519eab769c..093693eddf 100644 --- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h +++ b/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h @@ -32,6 +32,6 @@ #include "radeon_context.h" -struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context); +struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys); #endif diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c index 739bfa1c1a..aa1bfa8e88 100644 --- a/src/gallium/winsys/egl_xlib/sw_winsys.c +++ b/src/gallium/winsys/egl_xlib/sw_winsys.c @@ -99,7 +99,7 @@ buffer_create(struct pipe_winsys *pws, if (!buffer) return NULL; - buffer->Base.refcount = 1; + pipe_reference_init(&buffer->Base.reference, 1); buffer->Base.alignment = alignment; buffer->Base.usage = usage; buffer->Base.size = size; @@ -121,7 +121,7 @@ user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) if (!buffer) return NULL; - buffer->Base.refcount = 1; + pipe_reference_init(&buffer->Base.reference, 1); buffer->Base.size = bytes; buffer->UserBuffer = TRUE; buffer->Data = ptr; @@ -148,7 +148,7 @@ buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) static void -buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buf) +buffer_destroy(struct pipe_buffer *buf) { struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c index c4623e82f9..5b9fdb5c1f 100644 --- a/src/gallium/winsys/g3dvl/xsp_winsys.c +++ b/src/gallium/winsys/g3dvl/xsp_winsys.c @@ -39,7 +39,7 @@ static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned a assert(pws); buffer = calloc(1, sizeof(struct xsp_buffer)); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -55,7 +55,7 @@ static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void assert(pws); buffer = calloc(1, sizeof(struct xsp_buffer)); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.size = size; buffer->is_user_buffer = TRUE; buffer->data = data; diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c index 2d961f7087..440666d835 100644 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c @@ -87,8 +87,7 @@ gdi_softpipe_buffer_unmap(struct pipe_winsys *winsys, static void -gdi_softpipe_buffer_destroy(struct pipe_winsys *winsys, - struct pipe_buffer *buf) +gdi_softpipe_buffer_destroy(struct pipe_buffer *buf) { struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf); @@ -118,7 +117,7 @@ gdi_softpipe_buffer_create(struct pipe_winsys *winsys, { struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -143,7 +142,7 @@ gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys, if(!buffer) return NULL; - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.size = bytes; buffer->userBuffer = TRUE; buffer->data = ptr; diff --git a/src/gallium/winsys/xlib/xlib_brw_screen.c b/src/gallium/winsys/xlib/xlib_brw_screen.c index 8e1bfab2f5..fe8dfff767 100644 --- a/src/gallium/winsys/xlib/xlib_brw_screen.c +++ b/src/gallium/winsys/xlib/xlib_brw_screen.c @@ -37,7 +37,6 @@ //#include "state_trackers/xlib/xmesaP.h" #include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" #include "i965simple/brw_winsys.h" @@ -57,10 +56,10 @@ buffer_from_surface(struct pipe_surface *surface) } struct aub_buffer { + struct pipe_reference reference; char *data; unsigned offset; unsigned size; - unsigned refcount; unsigned map_count; boolean dump_on_unmap; }; @@ -144,8 +143,7 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys, static void -aub_buffer_destroy(struct pipe_winsys *winsys, - struct pipe_buffer *buf) +aub_buffer_destroy(struct pipe_buffer *buf) { free(buf); } @@ -189,7 +187,7 @@ aub_buffer_create(struct pipe_winsys *winsys, struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys); struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); - sbo->refcount = 1; + pipe_reference_init(&sbo->reference, 1); /* Could reuse buffers that are not referenced in current * batchbuffer. Can't do that atm, so always reallocate: diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c index 40bcdfe42a..a5dbdf30f6 100644 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ b/src/gallium/winsys/xlib/xlib_cell.c @@ -243,7 +243,7 @@ xm_buffer_create(struct pipe_winsys *pws, { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -267,7 +267,7 @@ static struct pipe_buffer * xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.size = bytes; buffer->userBuffer = TRUE; buffer->data = ptr; diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 71f12b2b47..762ebd9847 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -207,8 +207,7 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) } static void -xm_buffer_destroy(struct pipe_winsys *pws, - struct pipe_buffer *buf) +xm_buffer_destroy(struct pipe_buffer *buf) { struct xm_buffer *oldBuf = xm_buffer(buf); @@ -338,7 +337,7 @@ xm_buffer_create(struct pipe_winsys *pws, } #endif - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -359,7 +358,7 @@ static struct pipe_buffer * xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.size = bytes; buffer->userBuffer = TRUE; buffer->data = ptr; |