diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/drm/intel/dri/Makefile | 1 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_api.c | 30 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_api.h | 7 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_context.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.c | 34 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.h | 20 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/xorg/Makefile | 42 | ||||
-rw-r--r-- | src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 43 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 11 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 13 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_drm.c | 72 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_drm.h | 19 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_r300.c | 2 |
13 files changed, 205 insertions, 91 deletions
diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile index de39e759d8..5e212b62a4 100644 --- a/src/gallium/winsys/drm/intel/dri/Makefile +++ b/src/gallium/winsys/drm/intel/dri/Makefile @@ -8,6 +8,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a 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 a74be13bf7..dd5f814da3 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c @@ -1,21 +1,37 @@ #include "intel_be_api.h" #include "i915simple/i915_winsys.h" +#include "identity/id_drm.h" +#include "trace/tr_drm.h" -#ifdef DEBUG -#include "trace/trace_drm.h" +static void destroy(struct drm_api *api) +{ -struct drm_api hooks = -#else -struct drm_api drm_api_hooks = -#endif +} + +struct drm_api intel_be_drm_api = { /* intel_be_context.c */ .create_context = intel_be_create_context, /* intel_be_device.c */ .create_screen = intel_be_create_screen, - .buffer_from_texture = i915_get_texture_buffer, + .buffer_from_texture = intel_be_get_texture_buffer, .buffer_from_handle = intel_be_buffer_from_handle, .handle_from_buffer = intel_be_handle_from_buffer, .global_handle_from_buffer = intel_be_global_handle_from_buffer, + .destroy = destroy, }; + +struct drm_api * +drm_api_create() +{ +#ifdef DEBUG +#if 0 + return identity_drm_create(&intel_be_drm_api); +#else + return trace_drm_create(&intel_be_drm_api); +#endif +#else + return &intel_be_drm_api; +#endif +} diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.h b/src/gallium/winsys/drm/intel/gem/intel_be_api.h index 1c622f3b97..f286b62eb8 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h @@ -8,8 +8,11 @@ #include "intel_be_device.h" -struct pipe_screen *intel_be_create_screen(int drmFD, +extern struct drm_api intel_be_drm_api; + +struct pipe_screen *intel_be_create_screen(struct drm_api *api, int drmFD, struct drm_create_screen_arg *arg); -struct pipe_context *intel_be_create_context(struct pipe_screen *screen); +struct pipe_context *intel_be_create_context(struct drm_api *api, + struct pipe_screen *screen); #endif diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.c b/src/gallium/winsys/drm/intel/gem/intel_be_context.c index fe0b138fbe..db84f9af51 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_context.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.c @@ -97,7 +97,7 @@ intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *de } struct pipe_context * -intel_be_create_context(struct pipe_screen *screen) +intel_be_create_context(struct drm_api *api, struct pipe_screen *screen) { struct intel_be_context *intel; struct pipe_context *pipe; 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 907ac86637..e3630f5d12 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -142,8 +142,27 @@ err: return NULL; } +boolean +intel_be_get_texture_buffer(struct drm_api *api, + struct pipe_texture *texture, + struct pipe_buffer **buffer, + unsigned *stride) +{ + struct intel_be_device *dev; + + if (!texture) + return FALSE; + + dev = intel_be_device(texture->screen->winsys); + if (dev->softpipe) + return softpipe_get_texture_buffer(texture, buffer, stride); + else + return i915_get_texture_buffer(texture, buffer, stride); +} + struct pipe_buffer * -intel_be_buffer_from_handle(struct pipe_screen *screen, +intel_be_buffer_from_handle(struct drm_api *api, + struct pipe_screen *screen, const char* name, unsigned handle) { struct intel_be_device *dev = intel_be_device(screen->winsys); @@ -174,7 +193,8 @@ err: } boolean -intel_be_handle_from_buffer(struct pipe_screen *screen, +intel_be_handle_from_buffer(struct drm_api *api, + struct pipe_screen *screen, struct pipe_buffer *buffer, unsigned *handle) { @@ -186,7 +206,8 @@ intel_be_handle_from_buffer(struct pipe_screen *screen, } boolean -intel_be_global_handle_from_buffer(struct pipe_screen *screen, +intel_be_global_handle_from_buffer(struct drm_api *api, + struct pipe_screen *screen, struct pipe_buffer *buffer, unsigned *handle) { @@ -296,6 +317,7 @@ intel_be_get_device_id(unsigned int *device_id) { char path[512]; FILE *file; + void *shutup_gcc; /* * FIXME: Fix this up to use a drm ioctl or whatever. @@ -307,13 +329,14 @@ intel_be_get_device_id(unsigned int *device_id) return; } - fgets(path, sizeof(path), file); + shutup_gcc = fgets(path, sizeof(path), file); sscanf(path, "%x", device_id); fclose(file); } struct pipe_screen * -intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg) +intel_be_create_screen(struct drm_api *api, int drmFD, + struct drm_create_screen_arg *arg) { struct intel_be_device *dev; struct pipe_screen *screen; @@ -339,7 +362,6 @@ intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg) if (dev->softpipe) { screen = softpipe_create_screen(&dev->base); - drm_api_hooks.buffer_from_texture = softpipe_get_texture_buffer; } else screen = i915_create_screen(&dev->base, deviceID); diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.h b/src/gallium/winsys/drm/intel/gem/intel_be_device.h index b32637ece2..56d95bd7fe 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h @@ -8,6 +8,8 @@ #include "drm.h" #include "intel_bufmgr.h" +struct drm_api; + /* * Device */ @@ -50,13 +52,23 @@ struct intel_be_buffer { unsigned flink; }; +/* + * Wrapper for driver get_texture_buffer functions. + */ +boolean +intel_be_get_texture_buffer(struct drm_api *api, + struct pipe_texture *texture, + struct pipe_buffer **buffer, + unsigned *stride); + /** * Create a be buffer from a drm bo handle. * * Takes a reference. */ struct pipe_buffer * -intel_be_buffer_from_handle(struct pipe_screen *screen, +intel_be_buffer_from_handle(struct drm_api *api, + struct pipe_screen *screen, const char* name, unsigned handle); /** @@ -65,7 +77,8 @@ intel_be_buffer_from_handle(struct pipe_screen *screen, * If buffer is destroyed handle may become invalid. */ boolean -intel_be_handle_from_buffer(struct pipe_screen *screen, +intel_be_handle_from_buffer(struct drm_api *api, + struct pipe_screen *screen, struct pipe_buffer *buffer, unsigned *handle); @@ -75,7 +88,8 @@ intel_be_handle_from_buffer(struct pipe_screen *screen, * If buffer is destroyed handle may become invalid. */ boolean -intel_be_global_handle_from_buffer(struct pipe_screen *screen, +intel_be_global_handle_from_buffer(struct drm_api *api, + struct pipe_screen *screen, struct pipe_buffer *buffer, unsigned *handle); diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile index d9aa5d54e1..d51cca8d21 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/winsys/drm/intel/xorg/Makefile @@ -1,36 +1,38 @@ TARGET = modesetting_drv.so CFILES = $(wildcard ./*.c) OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) -GALLIUMDIR = ../../../.. TOP = ../../../../../.. -include ${TOP}/configs/current +include $(TOP)/configs/current -CFLAGS = -DHAVE_CONFIG_H \ - -g -Wall -Wimplicit-function-declaration -fPIC \ - $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \ - -I../gem \ - -I${GALLIUMDIR}/include \ - -I${GALLIUMDIR}/drivers \ - -I${GALLIUMDIR}/auxiliary \ - -I${TOP}/src/mesa \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main +INCLUDES = \ + $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ + -I../gem \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/mesa \ + -I$(TOP)/include \ + -I$(TOP)/src/egl/main LIBS = \ - $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \ - $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ + $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(GALLIUM_AUXILIARIES) +DRIVER_DEFINES = \ + -DHAVE_CONFIG_H + + ############################################# all default: $(TARGET) -$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS) +$(TARGET): $(OBJECTS) Makefile $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a $(LIBS) $(TOP)/bin/mklib -noprefix -o $@ \ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel @@ -41,4 +43,14 @@ install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + +############################################## + + +.c.o: + $(CC) -c $(CFLAGS) $(INCLUDES) $(DRIVER_DEFINES) $< -o $@ + + +############################################## + .PHONY = all clean install diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 395b21ec7a..3167ccfdc1 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -12,7 +12,7 @@ #include "nouveau/nouveau_screen.h" static struct pipe_surface * -dri_surface_from_handle(struct pipe_screen *screen, +dri_surface_from_handle(struct drm_api *api, struct pipe_screen *screen, unsigned handle, enum pipe_format format, unsigned width, @@ -24,7 +24,7 @@ dri_surface_from_handle(struct pipe_screen *screen, struct pipe_texture templat; struct pipe_buffer *buf = NULL; - buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle); + buf = api->buffer_from_handle(api, screen, "front buffer", handle); if (!buf) return NULL; @@ -70,7 +70,8 @@ static struct dri1_api nouveau_dri1_api = { }; static struct pipe_screen * -nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) +nouveau_drm_create_screen(struct drm_api *api, int fd, + struct drm_create_screen_arg *arg) { struct dri1_create_screen_arg *dri1 = (void *)arg; struct nouveau_winsys *nvws; @@ -134,13 +135,12 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) else format = PIPE_FORMAT_A8R8G8B8_UNORM; - nvws->front = dri_surface_from_handle(nvws->pscreen, - nvdri->front_offset, - format, - nvdri->width, - nvdri->height, - nvdri->front_pitch * - (nvdri->bpp / 8)); + nvws->front = dri_surface_from_handle(api, nvws->pscreen, + nvdri->front_offset, + format, nvdri->width, + nvdri->height, + nvdri->front_pitch * + (nvdri->bpp / 8)); if (!nvws->front) { debug_printf("%s: error referencing front buffer\n", __func__); @@ -155,7 +155,7 @@ nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) } static struct pipe_context * -nouveau_drm_create_context(struct pipe_screen *pscreen) +nouveau_drm_create_context(struct drm_api *api, struct pipe_screen *pscreen) { struct nouveau_winsys *nvws = nouveau_winsys_screen(pscreen); struct pipe_context *(*init)(struct pipe_screen *, unsigned); @@ -206,15 +206,15 @@ nouveau_drm_create_context(struct pipe_screen *pscreen) } static boolean -nouveau_drm_pb_from_pt(struct pipe_texture *pt, struct pipe_buffer **ppb, - unsigned *stride) +nouveau_drm_pb_from_pt(struct drm_api *api, struct pipe_texture *pt, + struct pipe_buffer **ppb, unsigned *stride) { return false; } static struct pipe_buffer * -nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name, - unsigned handle) +nouveau_drm_pb_from_handle(struct drm_api *api, struct pipe_screen *pscreen, + const char *name, unsigned handle) { struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct pipe_buffer *pb; @@ -242,8 +242,8 @@ nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name, } static boolean -nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, - unsigned *handle) +nouveau_drm_handle_from_pb(struct drm_api *api, struct pipe_screen *pscreen, + struct pipe_buffer *pb, unsigned *handle) { struct nouveau_bo *bo = nouveau_bo(pb); @@ -255,8 +255,8 @@ nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, } static boolean -nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb, - unsigned *handle) +nouveau_drm_name_from_pb(struct drm_api *api, struct pipe_screen *pscreen, + struct pipe_buffer *pb, unsigned *handle) { struct nouveau_bo *bo = nouveau_bo(pb); @@ -275,3 +275,8 @@ struct drm_api drm_api_hooks = { .global_handle_from_buffer = nouveau_drm_name_from_pb, }; +struct drm_api * +drm_api_create() { + return &drm_api_hooks; +} + diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 0d0fdc5bd8..684a487f24 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -1,8 +1,8 @@ -/* +/* * Copyright © 2008 Jérôme Glisse * 2009 Corbin Simpson * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,14 +10,14 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the @@ -141,6 +141,8 @@ static void *radeon_buffer_map(struct pipe_winsys *ws, write = 1; } + radeon_bo_wait(radeon_buffer->bo); + if (radeon_bo_map(radeon_buffer->bo, write)) return NULL; return radeon_buffer->bo->ptr; @@ -198,6 +200,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) return NULL; } + radeon_ws->priv->fd = fd; radeon_ws->priv->bom = radeon_bo_manager_gem_ctor(fd); radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index ca8bbb3c11..8c8b61fa10 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -1,7 +1,7 @@ -/* +/* * Copyright © 2008 Jérôme Glisse * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -9,14 +9,14 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the @@ -48,11 +48,16 @@ struct radeon_pipe_buffer { struct pipe_buffer base; struct radeon_bo *bo; + boolean flinked; + uint32_t flink; }; #define RADEON_MAX_BOS 24 struct radeon_winsys_priv { + /* DRM FD */ + int fd; + /* Radeon BO manager. */ struct radeon_bo_manager* bom; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 5406d2bbea..da2010184a 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -1,7 +1,7 @@ -/* +/* * Copyright © 2009 Corbin Simpson * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -9,14 +9,14 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the @@ -29,13 +29,11 @@ */ #include "radeon_drm.h" - -#ifdef DEBUG -#include "trace/trace_drm.h" -#endif +#include "trace/tr_drm.h" /* Create a pipe_screen. */ -struct pipe_screen* radeon_create_screen(int drmFB, +struct pipe_screen* radeon_create_screen(struct drm_api* api, + int drmFB, struct drm_create_screen_arg *arg) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); @@ -50,7 +48,8 @@ struct pipe_screen* radeon_create_screen(int drmFB, } /* Create a pipe_context. */ -struct pipe_context* radeon_create_context(struct pipe_screen* screen) +struct pipe_context* radeon_create_context(struct drm_api* api, + struct pipe_screen* screen) { if (getenv("RADEON_SOFTPIPE")) { return radeon_create_softpipe(screen->winsys); @@ -59,16 +58,19 @@ struct pipe_context* radeon_create_context(struct pipe_screen* screen) } } -boolean radeon_buffer_from_texture(struct pipe_texture* texture, +boolean radeon_buffer_from_texture(struct drm_api* api, + struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride) { - return FALSE; + /* XXX fix this */ + return r300_get_texture_buffer(texture, buffer, stride); } /* Create a buffer from a handle. */ /* XXX what's up with name? */ -struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, +struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, + struct pipe_screen* screen, const char* name, unsigned handle) { @@ -95,7 +97,8 @@ struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, return &radeon_buffer->base; } -boolean radeon_handle_from_buffer(struct pipe_screen* screen, +boolean radeon_handle_from_buffer(struct drm_api* api, + struct pipe_screen* screen, struct pipe_buffer* buffer, unsigned* handle) { @@ -105,27 +108,50 @@ boolean radeon_handle_from_buffer(struct pipe_screen* screen, return TRUE; } -boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, +boolean radeon_global_handle_from_buffer(struct drm_api* api, + struct pipe_screen* screen, struct pipe_buffer* buffer, unsigned* handle) { - /* XXX WTF is the difference here? global? */ + int retval, fd; + struct drm_gem_flink flink; struct radeon_pipe_buffer* radeon_buffer = (struct radeon_pipe_buffer*)buffer; - *handle = radeon_buffer->bo->handle; + + if (!radeon_buffer->flinked) { + fd = ((struct radeon_winsys*)screen->winsys)->priv->fd; + + flink.handle = radeon_buffer->bo->handle; + + retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); + if (retval) { + debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", + retval); + return FALSE; + } + + radeon_buffer->flink = flink.name; + radeon_buffer->flinked = TRUE; + } + + *handle = radeon_buffer->flink; return TRUE; } -#ifdef DEBUG -struct drm_api hooks = { -#else struct drm_api drm_api_hooks = { -#endif .create_screen = radeon_create_screen, .create_context = radeon_create_context, - /* XXX fix this */ - .buffer_from_texture = r300_get_texture_buffer, + .buffer_from_texture = radeon_buffer_from_texture, .buffer_from_handle = radeon_buffer_from_handle, .handle_from_buffer = radeon_handle_from_buffer, .global_handle_from_buffer = radeon_global_handle_from_buffer, }; + +struct drm_api* drm_api_create() +{ +#ifdef DEBUG + return trace_drm_create(&drm_api_hooks); +#else + return &drm_api_hooks; +#endif +} diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 049f9984db..8560f71db6 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -40,25 +40,32 @@ #include "radeon_r300.h" #include "radeon_winsys_softpipe.h" -struct pipe_screen* radeon_create_screen(int drmFB, +struct pipe_screen* radeon_create_screen(struct drm_api* api, + int drmFB, struct drm_create_screen_arg *arg); -struct pipe_context* radeon_create_context(struct pipe_screen* screen); +struct pipe_context* radeon_create_context(struct drm_api* api, + struct pipe_screen* screen); -boolean radeon_buffer_from_texture(struct pipe_texture* texture, +boolean radeon_buffer_from_texture(struct drm_api* api, + struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); -struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, +struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, + struct pipe_screen* screen, const char* name, unsigned handle); -boolean radeon_handle_from_buffer(struct pipe_screen* screen, +boolean radeon_handle_from_buffer(struct drm_api* api, + struct pipe_screen* screen, struct pipe_buffer* buffer, unsigned* handle); -boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, +boolean radeon_global_handle_from_buffer(struct drm_api* api, + struct pipe_screen* screen, struct pipe_buffer* buffer, unsigned* handle); +void radeon_destroy_drm_api(struct drm_api* api); #endif diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 63aa3179ac..8c5f756ddf 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -39,7 +39,7 @@ static boolean radeon_r300_add_buffer(struct r300_winsys* winsys, if (sc[i].bo == bo) { sc[i].read_domains |= rd; sc[i].write_domain |= wd; - return; + return TRUE; } } |