From eb63e8cc75f7ac0f4b8b89ceecc030b61789ea8c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 18 Apr 2009 21:22:32 +0100 Subject: softpipe: Remove softpipe_winsys. Not used by softpipe anyway. --- .../drm/radeon/core/radeon_winsys_softpipe.c | 31 +--------------------- 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c index 33f9ac15ab..3c0d6f11aa 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c @@ -31,42 +31,13 @@ #include "radeon_winsys_softpipe.h" -struct radeon_softpipe_winsys { - struct softpipe_winsys sp_winsys; - struct radeon_context *radeon_context; -}; - -/** - * Return list of surface formats supported by this driver. - */ -static boolean radeon_is_format_supported(struct softpipe_winsys *sws, - uint format) -{ - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - return TRUE; - default: - break; - } - return FALSE; -} - struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys) { - struct softpipe_winsys *sp_winsys; struct pipe_screen *pipe_screen; pipe_screen = softpipe_create_screen(winsys); - sp_winsys = CALLOC_STRUCT(softpipe_winsys); - if (sp_winsys == NULL) { - return NULL; - } - - sp_winsys->is_format_supported = radeon_is_format_supported; return softpipe_create(pipe_screen, winsys, - sp_winsys); + NULL); } -- cgit v1.2.3 From dc1153ce83041a397b1d1815db4133ce8c53eaa1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 18 Apr 2009 23:14:42 +0100 Subject: softpipe: Simplify softpipe_create's prototype. --- src/gallium/drivers/softpipe/sp_context.c | 6 ++---- src/gallium/drivers/softpipe/sp_winsys.h | 4 +--- src/gallium/state_trackers/python/st_softpipe_winsys.c | 2 +- src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c | 4 +--- src/gallium/winsys/egl_xlib/egl_xlib.c | 2 +- src/gallium/winsys/g3dvl/xsp_winsys.c | 2 +- src/gallium/winsys/gdi/gdi_softpipe_winsys.c | 2 +- src/gallium/winsys/xlib/xlib_softpipe.c | 2 +- 8 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 2c6a0b53b0..62e8d99cfd 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -137,9 +137,7 @@ softpipe_is_buffer_referenced( struct pipe_context *pipe, } struct pipe_context * -softpipe_create( struct pipe_screen *screen, - struct pipe_winsys *pipe_winsys, - void *unused ) +softpipe_create( struct pipe_screen *screen ) { struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context); uint i; @@ -154,7 +152,7 @@ softpipe_create( struct pipe_screen *screen, softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE ); - softpipe->pipe.winsys = pipe_winsys; + softpipe->pipe.winsys = screen->winsys; softpipe->pipe.screen = screen; softpipe->pipe.destroy = softpipe_destroy; diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h index 44720b7960..cf91e7782b 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.h +++ b/src/gallium/drivers/softpipe/sp_winsys.h @@ -45,9 +45,7 @@ struct pipe_winsys; struct pipe_context; -struct pipe_context *softpipe_create( struct pipe_screen *, - struct pipe_winsys *, - void *unused ); +struct pipe_context *softpipe_create( struct pipe_screen * ); struct pipe_screen * diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 41cdeaa6fd..f0a4826a00 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -260,7 +260,7 @@ st_softpipe_screen_create(void) static struct pipe_context * st_softpipe_context_create(struct pipe_screen *screen) { - return softpipe_create(screen, screen->winsys, NULL); + return softpipe_create(screen); } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c index 3c0d6f11aa..f038bfa40e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c @@ -37,7 +37,5 @@ struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys) pipe_screen = softpipe_create_screen(winsys); - return softpipe_create(pipe_screen, - winsys, - NULL); + return softpipe_create(pipe_screen); } diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index 68fe64a52e..b52f427e4a 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -359,7 +359,7 @@ xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, /* fall-through */ case EGL_OPENGL_API: /* create a softpipe context */ - ctx->pipe = softpipe_create(xdrv->screen, xdrv->winsys, NULL); + ctx->pipe = softpipe_create(xdrv->screen); /* Now do xlib / state tracker inits here */ _eglConfigToContextModesRec(conf, &visual); ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx); diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c index 5b9fdb5c1f..698c2856a4 100644 --- a/src/gallium/winsys/g3dvl/xsp_winsys.c +++ b/src/gallium/winsys/g3dvl/xsp_winsys.c @@ -261,7 +261,7 @@ struct pipe_context* create_pipe_context(Display *display, int screen) } sp_screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys); - sp_pipe = softpipe_create(sp_screen, (struct pipe_winsys*)xsp_winsys, NULL); + sp_pipe = softpipe_create(sp_screen); xsp_context = calloc(1, sizeof(struct xsp_context)); xsp_context->display = display; diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c index df7e43d56b..33826524d7 100644 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c @@ -263,7 +263,7 @@ gdi_softpipe_screen_create(void) static struct pipe_context * gdi_softpipe_context_create(struct pipe_screen *screen) { - return softpipe_create(screen, screen->winsys, NULL); + return softpipe_create(screen); } diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 762ebd9847..44b8464518 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -482,7 +482,7 @@ xlib_create_softpipe_context( struct pipe_screen *screen, { struct pipe_context *pipe; - pipe = softpipe_create(screen, screen->winsys, NULL); + pipe = softpipe_create(screen); if (pipe == NULL) goto fail; -- cgit v1.2.3 From 638261b3530106b70819c2fe0c3cd613c0d85777 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:23:11 +0200 Subject: gallium: Update the drm_api. Make it possible to pass state-tracker-specific data to the init_screen function, and even open the door for device-specific state-tracker screen initialization. Signed-off-by: Thomas Hellstrom --- src/gallium/include/state_tracker/drm_api.h | 19 +++++++++++- src/gallium/state_trackers/dri2/dri_screen.c | 35 +--------------------- src/gallium/state_trackers/dri2/dri_screen.h | 2 -- src/gallium/state_trackers/egl/egl_tracker.c | 2 +- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- src/gallium/winsys/drm/intel/gem/intel_be_api.h | 3 +- src/gallium/winsys/drm/intel/gem/intel_be_device.c | 35 +++++++++++++++++++++- .../winsys/drm/nouveau/dri/nouveau_screen.c | 2 +- .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 2 +- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 3 +- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 3 +- 11 files changed, 63 insertions(+), 45 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 435435da29..5790b2f6c7 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -10,13 +10,30 @@ struct pipe_buffer; struct pipe_context; struct pipe_texture; +enum drm_create_screen_mode { + DRM_CREATE_NORMAL = 0, + DRM_CREATE_DRI1, + DRM_CREATE_DRIVER = 1024, + DRM_CREATE_MAX +}; + +/** + * Modes other than DRM_CREATE_NORMAL derive from this struct. + */ +/*@{*/ +struct drm_create_screen_arg { + enum drm_create_screen_mode mode; +}; +/*@}*/ + struct drm_api { /** * Special buffer functions */ /*@{*/ - struct pipe_screen* (*create_screen)(int drmFB, int pciID); + struct pipe_screen* (*create_screen)(int drm_fd, + struct drm_create_screen_arg *arg); struct pipe_context* (*create_context)(struct pipe_screen *screen); /*@}*/ diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c index ab5878a4bc..ab33003f51 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.c +++ b/src/gallium/state_trackers/dri2/dri_screen.c @@ -67,37 +67,6 @@ static const __DRIextension *dri_screen_extensions[] = { NULL }; - -static void -dri_get_drm_minor(struct dri_screen *screen) -{ - /* TODO get the real minor */ - screen->minor = 0; -} - - -static void -dri_get_device_id(struct dri_screen *screen) -{ - char path[512]; - FILE *file; - - /* - * There must be a better way to get the deviceID. - * XXX this only works on Linux. - */ - snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", screen->minor); - file = fopen(path, "r"); - if (!file) { - return; - } - - fgets(path, sizeof(path), file); - sscanf(path, "%x", &screen->deviceID); - fclose(file); -} - - static const __DRIconfig ** dri_fill_in_modes(__DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, @@ -212,13 +181,11 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; - dri_get_drm_minor(screen); - dri_get_device_id(screen); sPriv->private = (void *) screen; sPriv->extensions = dri_screen_extensions; - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); goto fail; diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h index fe2676d0be..3751ec6121 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.h +++ b/src/gallium/state_trackers/dri2/dri_screen.h @@ -54,9 +54,7 @@ struct dri_screen struct dri_context *dummyContext; /* drm */ - int deviceID; int fd; - int minor; /* gallium */ struct pipe_winsys *pipe_winsys; diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index abdf84544f..8e62008461 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -146,7 +146,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) dev->drmFD = fd; drm_get_device_id(dev); - dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID); + dev->screen = drm_api_hooks.create_screen(dev->drmFD, NULL); if (!dev->screen) goto err_screen; dev->winsys = dev->screen->winsys; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 8a2711e70c..45e831f0c2 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -476,7 +476,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } if (!ms->screen) { - ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id); + ms->screen = drm_api_hooks.create_screen(ms->fd, NULL); if (!ms->screen) { FatalError("Could not init pipe_screen\n"); 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 73e458d4ba..1c622f3b97 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h @@ -8,7 +8,8 @@ #include "intel_be_device.h" -struct pipe_screen *intel_be_create_screen(int drmFD, int pciID); +struct pipe_screen *intel_be_create_screen(int drmFD, + struct drm_create_screen_arg *arg); struct pipe_context *intel_be_create_context(struct pipe_screen *screen); #endif 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 c866c2a2f1..907ac86637 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -14,6 +14,7 @@ #include "softpipe/sp_winsys.h" #include "intel_be_api.h" +#include /* * Buffer @@ -290,11 +291,42 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id) return true; } +static void +intel_be_get_device_id(unsigned int *device_id) +{ + char path[512]; + FILE *file; + + /* + * FIXME: Fix this up to use a drm ioctl or whatever. + */ + + snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device"); + file = fopen(path, "r"); + if (!file) { + return; + } + + fgets(path, sizeof(path), file); + sscanf(path, "%x", device_id); + fclose(file); +} + struct pipe_screen * -intel_be_create_screen(int drmFD, int deviceID) +intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg) { struct intel_be_device *dev; struct pipe_screen *screen; + unsigned int deviceID; + + if (arg != NULL) { + switch(arg->mode) { + case DRM_CREATE_NORMAL: + break; + default: + return NULL; + } + } /* Allocate the private area */ dev = malloc(sizeof(*dev)); @@ -302,6 +334,7 @@ intel_be_create_screen(int drmFD, int deviceID) return NULL; memset(dev, 0, sizeof(*dev)); + intel_be_get_device_id(&deviceID); intel_be_init_device(dev, drmFD, deviceID); if (dev->softpipe) { diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c index 0b45b1ff1f..4e9b76a909 100644 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c +++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c @@ -267,7 +267,7 @@ nouveau_screen_create(__DRIscreenPrivate *psp) nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0); - nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, 0); + nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, NULL); if (!nv_screen->pscreen) { FREE(nv_screen); return NULL; 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 c0127e803f..a558fda140 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -8,7 +8,7 @@ #include "nouveau_bo.h" static struct pipe_screen * -nouveau_drm_create_screen(int fd, int pciid) +nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct pipe_winsys *ws; struct nouveau_winsys *nvws; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 3446654e28..1f89d1b1d1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -31,7 +31,8 @@ #include "radeon_drm.h" /* Create a pipe_screen. */ -struct pipe_screen* radeon_create_screen(int drmFB, int pciID) +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg ) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index ca2d98ed1a..049f9984db 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -40,7 +40,8 @@ #include "radeon_r300.h" #include "radeon_winsys_softpipe.h" -struct pipe_screen* radeon_create_screen(int drmFB, int pciID); +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg); struct pipe_context* radeon_create_context(struct pipe_screen* screen); -- cgit v1.2.3 From 2e5acd24b0421f3824fbe441f4a7062c1f081109 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:32:59 +0200 Subject: gallium: Move the dri2 state tracker since we're about to extend it to dri1. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/Makefile | 28 ++ src/gallium/state_trackers/dri/dri_context.c | 170 ++++++++++++ src/gallium/state_trackers/dri/dri_context.h | 96 +++++++ src/gallium/state_trackers/dri/dri_drawable.c | 325 +++++++++++++++++++++++ src/gallium/state_trackers/dri/dri_drawable.h | 89 +++++++ src/gallium/state_trackers/dri/dri_extensions.c | 119 +++++++++ src/gallium/state_trackers/dri/dri_screen.c | 239 +++++++++++++++++ src/gallium/state_trackers/dri/dri_screen.h | 88 ++++++ src/gallium/state_trackers/dri2/Makefile | 28 -- src/gallium/state_trackers/dri2/dri_context.c | 170 ------------ src/gallium/state_trackers/dri2/dri_context.h | 96 ------- src/gallium/state_trackers/dri2/dri_drawable.c | 325 ----------------------- src/gallium/state_trackers/dri2/dri_drawable.h | 89 ------- src/gallium/state_trackers/dri2/dri_extensions.c | 119 --------- src/gallium/state_trackers/dri2/dri_screen.c | 239 ----------------- src/gallium/state_trackers/dri2/dri_screen.h | 88 ------ src/gallium/winsys/drm/intel/dri2/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri2/Makefile | 2 +- src/gallium/winsys/drm/radeon/dri2/Makefile | 2 +- 19 files changed, 1157 insertions(+), 1157 deletions(-) create mode 100644 src/gallium/state_trackers/dri/Makefile create mode 100644 src/gallium/state_trackers/dri/dri_context.c create mode 100644 src/gallium/state_trackers/dri/dri_context.h create mode 100644 src/gallium/state_trackers/dri/dri_drawable.c create mode 100644 src/gallium/state_trackers/dri/dri_drawable.h create mode 100644 src/gallium/state_trackers/dri/dri_extensions.c create mode 100644 src/gallium/state_trackers/dri/dri_screen.c create mode 100644 src/gallium/state_trackers/dri/dri_screen.h delete mode 100644 src/gallium/state_trackers/dri2/Makefile delete mode 100644 src/gallium/state_trackers/dri2/dri_context.c delete mode 100644 src/gallium/state_trackers/dri2/dri_context.h delete mode 100644 src/gallium/state_trackers/dri2/dri_drawable.c delete mode 100644 src/gallium/state_trackers/dri2/dri_drawable.h delete mode 100644 src/gallium/state_trackers/dri2/dri_extensions.c delete mode 100644 src/gallium/state_trackers/dri2/dri_screen.c delete mode 100644 src/gallium/state_trackers/dri2/dri_screen.h (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile new file mode 100644 index 0000000000..47750e997e --- /dev/null +++ b/src/gallium/state_trackers/dri/Makefile @@ -0,0 +1,28 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = dri2drm + +LIBRARY_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa/main \ + $(shell pkg-config --cflags-only-I libdrm) + + +C_SOURCES = \ + dri_context.c \ + dri_screen.c \ + dri_drawable.c \ + dri_extensions.c + +# $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/vblank.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ + $(TOP)/src/mesa/drivers/common/driverfuncs.c \ + $(TOP)/src/mesa/drivers/dri/common/texmem.c \ + $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c + +include ../../Makefile.template diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c new file mode 100644 index 0000000000..92c26ac70f --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -0,0 +1,170 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" + +#include "dri_drawable.h" + + +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "pipe/p_context.h" + +#include "dri_context.h" + +#include "util/u_memory.h" + + +GLboolean +dri_create_context(const __GLcontextModes *visual, + __DRIcontextPrivate *cPriv, + void *sharedContextPrivate) +{ + __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; + struct dri_screen *screen = dri_screen(sPriv); + struct dri_context *ctx = NULL; + struct st_context *st_share = NULL; + + if (sharedContextPrivate) { + st_share = ((struct dri_context *) sharedContextPrivate)->st; + } + + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto fail; + + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; + ctx->sPriv = sPriv; + + driParseConfigFiles(&ctx->optionCache, + &screen->optionCache, + sPriv->myNum, + "dri"); + + ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); + + if (ctx->pipe == NULL) + goto fail; + + /* used in dri_flush_frontbuffer */ + ctx->pipe->priv = ctx; + + ctx->st = st_create_context(ctx->pipe, visual, st_share); + if (ctx->st == NULL) + goto fail; + + dri_init_extensions(ctx); + + return GL_TRUE; + +fail: + if (ctx && ctx->st) + st_destroy_context(ctx->st); + + if (ctx && ctx->pipe) + ctx->pipe->destroy(ctx->pipe); + + FREE(ctx); + return FALSE; +} + + +void +dri_destroy_context(__DRIcontextPrivate *cPriv) +{ + struct dri_context *ctx = dri_context(cPriv); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + + /* No particular reason to wait for command completion before + * destroying a context, but it is probably worthwhile flushing it + * to avoid having to add code elsewhere to cope with flushing a + * partially destroyed context. + */ + st_flush(ctx->st, 0, NULL); + + if (screen->dummyContext == ctx) + screen->dummyContext = NULL; + + /* Also frees ctx->pipe? + */ + st_destroy_context(ctx->st); + + FREE(ctx); +} + + +GLboolean +dri_unbind_context(__DRIcontextPrivate *cPriv) +{ + struct dri_context *ctx = dri_context(cPriv); + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + /* XXX make_current(NULL)? */ + return GL_TRUE; +} + + +GLboolean +dri_make_current(__DRIcontextPrivate *cPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); + struct dri_drawable *draw = dri_drawable(driDrawPriv); + struct dri_drawable *read = dri_drawable(driReadPriv); + + /* This is for situations in which we need a rendering context but + * there may not be any currently bound. + */ + screen->dummyContext = ctx; + + st_make_current(ctx->st, + draw->stfb, + read->stfb); + + /* used in dri_flush_frontbuffer */ + ctx->dPriv = driDrawPriv; + + if (driDrawPriv) + dri_get_buffers(driDrawPriv); + if (driDrawPriv != driReadPriv && driReadPriv) + dri_get_buffers(driReadPriv); + } else { + st_make_current(NULL, NULL, NULL); + } + + return GL_TRUE; +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h new file mode 100644 index 0000000000..e910472700 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_context.h @@ -0,0 +1,96 @@ +/************************************************************************** + * + * Copyright (C) 2009 VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_CONTEXT_H +#define DRI_CONTEXT_H + +#include "pipe/p_compiler.h" +#include "drm.h" +#include "dri_util.h" + + +struct pipe_context; +struct pipe_fence; +struct st_context; +struct dri_drawable; + + +struct dri_context +{ + /* dri */ + __DRIscreenPrivate *sPriv; + __DRIcontextPrivate *cPriv; + __DRIdrawablePrivate *dPriv; + + driOptionCache optionCache; + + /* gallium */ + struct st_context *st; + struct pipe_context *pipe; +}; + + +static INLINE struct dri_context * +dri_context(__DRIcontextPrivate *driContextPriv) +{ + return (struct dri_context *) driContextPriv->driverPrivate; +} + + +/*********************************************************************** + * dri_context.c + */ +void +dri_destroy_context(__DRIcontextPrivate * driContextPriv); + +boolean +dri_unbind_context(__DRIcontextPrivate * driContextPriv); + +boolean +dri_make_current(__DRIcontextPrivate * driContextPriv, + __DRIdrawablePrivate * driDrawPriv, + __DRIdrawablePrivate * driReadPriv); + +boolean +dri_create_context(const __GLcontextModes * visual, + __DRIcontextPrivate * driContextPriv, + void *sharedContextPrivate); + + +/*********************************************************************** + * dri_extensions.c + */ +void +dri_init_extensions(struct dri_context *ctx); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c new file mode 100644 index 0000000000..2e3f4099e2 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -0,0 +1,325 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "pipe/p_inlines.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_cb_fbo.h" + +#include "util/u_memory.h" + + +static void +dri_copy_to_front(__DRIdrawablePrivate *dPriv, + struct pipe_surface *from, + int x, int y, unsigned w, unsigned h) +{ + /* TODO send a message to the Xserver to copy to the real front buffer */ +} + + +static struct pipe_surface * +dri_surface_from_handle(struct pipe_screen *screen, + unsigned handle, + enum pipe_format format, + unsigned width, + unsigned height, + unsigned pitch) +{ + struct pipe_surface *surface = NULL; + struct pipe_texture *texture = NULL; + struct pipe_texture templat; + struct pipe_buffer *buf = NULL; + + buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle); + if (!buf) + return NULL; + + memset(&templat, 0, sizeof(templat)); + templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; + templat.target = PIPE_TEXTURE_2D; + templat.last_level = 0; + templat.depth[0] = 1; + templat.format = format; + templat.width[0] = width; + templat.height[0] = height; + pf_get_block(templat.format, &templat.block); + + texture = screen->texture_blanket(screen, + &templat, + &pitch, + buf); + + /* we don't need the buffer from this point on */ + pipe_buffer_reference(&buf, NULL); + + if (!texture) + return NULL; + + surface = screen->get_tex_surface(screen, texture, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + /* we don't need the texture from this point on */ + pipe_texture_reference(&texture, NULL); + return surface; +} + + +/** + * This will be called a drawable is known to have been resized. + */ +void +dri_get_buffers(__DRIdrawablePrivate *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + struct pipe_surface *surface = NULL; + struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + __DRIbuffer *buffers = NULL; + __DRIscreen *dri_screen = drawable->sPriv; + __DRIdrawable *dri_drawable = drawable->dPriv; + boolean have_depth = FALSE; + int i, count; + + buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable, + &dri_drawable->w, + &dri_drawable->h, + drawable->attachments, + drawable->num_attachments, + &count, + dri_drawable->loaderPrivate); + + if (buffers == NULL) { + return; + } + + /* set one cliprect to cover the whole dri_drawable */ + dri_drawable->x = 0; + dri_drawable->y = 0; + dri_drawable->backX = 0; + dri_drawable->backY = 0; + dri_drawable->numClipRects = 1; + dri_drawable->pClipRects[0].x1 = 0; + dri_drawable->pClipRects[0].y1 = 0; + dri_drawable->pClipRects[0].x2 = dri_drawable->w; + dri_drawable->pClipRects[0].y2 = dri_drawable->h; + dri_drawable->numBackClipRects = 1; + dri_drawable->pBackClipRects[0].x1 = 0; + dri_drawable->pBackClipRects[0].y1 = 0; + dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; + dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; + + for (i = 0; i < count; i++) { + enum pipe_format format = 0; + int index = 0; + + switch (buffers[i].attachment) { + case __DRI_BUFFER_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_FAKE_FRONT_LEFT: + index = ST_SURFACE_FRONT_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_BACK_LEFT: + index = ST_SURFACE_BACK_LEFT; + format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case __DRI_BUFFER_DEPTH: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_STENCIL: + index = ST_SURFACE_DEPTH; + format = PIPE_FORMAT_Z24S8_UNORM; + break; + case __DRI_BUFFER_ACCUM: + default: + assert(0); + } + assert(buffers[i].cpp == 4); + + if (index == ST_SURFACE_DEPTH) { + if (have_depth) + continue; + else + have_depth = TRUE; + } + + surface = dri_surface_from_handle(screen, + buffers[i].name, + format, + dri_drawable->w, + dri_drawable->h, + buffers[i].pitch); + + st_set_framebuffer_surface(drawable->stfb, index, surface); + pipe_surface_reference(&surface, NULL); + } + /* this needed, or else the state tracker fails to pick the new buffers */ + st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); +} + + +void +dri_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private) +{ + struct dri_context *ctx = (struct dri_context *)context_private; + dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height); +} + + +void +dri_swap_buffers(__DRIdrawablePrivate * dPriv) +{ + /* not needed for dri2 */ + assert(0); +} + + +void +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) +{ + /* not needed for dri2 */ + assert(0); +} + + +/** + * This is called when we need to set up GL rendering to a new X window. + */ +boolean +dri_create_buffer(__DRIscreenPrivate *sPriv, + __DRIdrawablePrivate *dPriv, + const __GLcontextModes *visual, + boolean isPixmap) +{ + enum pipe_format colorFormat, depthFormat, stencilFormat; + struct dri_screen *screen = sPriv->private; + struct dri_drawable *drawable = NULL; + struct pipe_screen *pscreen = screen->pipe_screen; + int i; + + if (isPixmap) + goto fail; /* not implemented */ + + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto fail; + + /* XXX: todo: use the pipe_screen queries to figure out which + * render targets are supportable. + */ + assert(visual->redBits == 8); + assert(visual->depthBits == 24 || visual->depthBits == 0); + assert(visual->stencilBits == 8 || visual->stencilBits == 0); + + colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + + if (visual->depthBits) { + if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + depthFormat = PIPE_FORMAT_Z24S8_UNORM; + else + depthFormat = PIPE_FORMAT_S8Z24_UNORM; + } else + depthFormat = PIPE_FORMAT_NONE; + + if (visual->stencilBits) { + if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) + stencilFormat = PIPE_FORMAT_Z24S8_UNORM; + else + stencilFormat = PIPE_FORMAT_S8Z24_UNORM; + } else + stencilFormat = PIPE_FORMAT_NONE; + + drawable->stfb = st_create_framebuffer(visual, + colorFormat, + depthFormat, + stencilFormat, + dPriv->w, + dPriv->h, + (void*) drawable); + if (drawable->stfb == NULL) + goto fail; + + drawable->sPriv = sPriv; + drawable->dPriv = dPriv; + dPriv->driverPrivate = (void *) drawable; + + /* setup dri2 buffers information */ + i = 0; + drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; +#if 0 + /* TODO incase of double buffer visual, delay fake creation */ + drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; +#endif + if (visual->doubleBufferMode) + drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; + if (visual->depthBits) + drawable->attachments[i++] = __DRI_BUFFER_DEPTH; + if (visual->stencilBits) + drawable->attachments[i++] = __DRI_BUFFER_STENCIL; + drawable->num_attachments = i; + + return GL_TRUE; +fail: + FREE(drawable); + return GL_FALSE; +} + + +void +dri_destroy_buffer(__DRIdrawablePrivate *dPriv) +{ + struct dri_drawable *drawable = dri_drawable(dPriv); + + st_unreference_framebuffer(drawable->stfb); + + FREE(drawable); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h new file mode 100644 index 0000000000..185c657b35 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -0,0 +1,89 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef DRI_DRAWABLE_H +#define DRI_DRAWABLE_H + +#include "pipe/p_compiler.h" + +struct pipe_surface; +struct pipe_fence; +struct st_framebuffer; + + +struct dri_drawable +{ + /* dri */ + __DRIdrawablePrivate *dPriv; + __DRIscreenPrivate *sPriv; + + unsigned attachments[8]; + unsigned num_attachments; + + /* gallium */ + struct st_framebuffer *stfb; +}; + + +static INLINE struct dri_drawable * +dri_drawable(__DRIdrawablePrivate * driDrawPriv) +{ + return (struct dri_drawable *) driDrawPriv->driverPrivate; +} + + +/*********************************************************************** + * dri_drawable.c + */ +boolean +dri_create_buffer(__DRIscreenPrivate *sPriv, + __DRIdrawablePrivate *dPriv, + const __GLcontextModes *visual, + boolean isPixmap); + +void +dri_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, + void *context_private); + +void +dri_swap_buffers(__DRIdrawablePrivate * dPriv); + +void +dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, + int x, int y, + int w, int h); + +void +dri_get_buffers(__DRIdrawablePrivate * dPriv); + +void +dri_destroy_buffer(__DRIdrawablePrivate *dPriv); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c new file mode 100644 index 0000000000..732d1e89b0 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -0,0 +1,119 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "dri_screen.h" +#include "dri_context.h" +#include "state_tracker/st_context.h" + +#define need_GL_ARB_multisample +#define need_GL_ARB_occlusion_query +#define need_GL_ARB_point_parameters +#define need_GL_ARB_texture_compression +#define need_GL_ARB_vertex_buffer_object +#define need_GL_ARB_vertex_program +#define need_GL_ARB_window_pos +#define need_GL_EXT_blend_color +#define need_GL_EXT_blend_equation_separate +#define need_GL_EXT_blend_func_separate +#define need_GL_EXT_blend_minmax +#define need_GL_EXT_cull_vertex +#define need_GL_EXT_fog_coord +#define need_GL_EXT_framebuffer_object +#define need_GL_EXT_multi_draw_arrays +#define need_GL_EXT_secondary_color +#define need_GL_NV_vertex_program +#include "extension_helper.h" + + +/** + * Extension strings exported by the driver. + */ +const struct dri_extension card_extensions[] = { + {"GL_ARB_multisample", GL_ARB_multisample_functions}, + {"GL_ARB_multitexture", NULL}, + {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, + {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, + {"GL_ARB_texture_border_clamp", NULL}, + {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, + {"GL_ARB_texture_cube_map", NULL}, + {"GL_ARB_texture_env_add", NULL}, + {"GL_ARB_texture_env_combine", NULL}, + {"GL_ARB_texture_env_dot3", NULL}, + {"GL_ARB_texture_mirrored_repeat", NULL}, + {"GL_ARB_texture_rectangle", NULL}, + {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, + {"GL_ARB_pixel_buffer_object", NULL}, + {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, + {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, + {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, + {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, + {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, + {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, + {"GL_EXT_blend_subtract", NULL}, + {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, + {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, + {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, + {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, + {"GL_EXT_packed_depth_stencil", NULL}, + {"GL_EXT_pixel_buffer_object", NULL}, + {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, + {"GL_EXT_stencil_wrap", NULL}, + {"GL_EXT_texture_edge_clamp", NULL}, + {"GL_EXT_texture_env_combine", NULL}, + {"GL_EXT_texture_env_dot3", NULL}, + {"GL_EXT_texture_filter_anisotropic", NULL}, + {"GL_EXT_texture_lod_bias", NULL}, + {"GL_3DFX_texture_compression_FXT1", NULL}, + {"GL_APPLE_client_storage", NULL}, + {"GL_MESA_pack_invert", NULL}, + {"GL_MESA_ycbcr_texture", NULL}, + {"GL_NV_blend_square", NULL}, + {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, + {"GL_NV_vertex_program1_1", NULL}, + {"GL_SGIS_generate_mipmap", NULL }, + {NULL, NULL} +}; + + +void +dri_init_extensions(struct dri_context *ctx) +{ + /* The card_extensions list should be pruned according to the + * capabilities of the pipe_screen. This is actually something + * that can/should be done inside st_create_context(). + */ + if (ctx) + driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); + else + driInitExtensions(NULL, card_extensions, GL_FALSE); +} + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c new file mode 100644 index 0000000000..ab33003f51 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -0,0 +1,239 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#include "utils.h" +#include "vblank.h" +#include "xmlpool.h" + +#include "dri_screen.h" +#include "dri_context.h" +#include "dri_drawable.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "pipe/p_inlines.h" +#include "state_tracker/drm_api.h" +#include "state_tracker/st_public.h" +#include "state_tracker/st_cb_fbo.h" + + +PUBLIC const char __driConfigOptions[] = + DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) + DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY + /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/ + DRI_CONF_ALLOW_LARGE_TEXTURES(1) + DRI_CONF_SECTION_END DRI_CONF_END; + + +const uint __driNConfigOptions = 3; + + +static const __DRIextension *dri_screen_extensions[] = { + &driReadDrawableExtension, + &driCopySubBufferExtension.base, + &driSwapControlExtension.base, + &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, + NULL +}; + +static const __DRIconfig ** +dri_fill_in_modes(__DRIscreenPrivate *psp, + unsigned pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer) +{ + __DRIconfig **configs; + __GLcontextModes *m; + unsigned num_modes; + uint8_t depth_bits_array[3]; + uint8_t stencil_bits_array[3]; + uint8_t msaa_samples_array[1]; + unsigned depth_buffer_factor; + unsigned back_buffer_factor; + unsigned msaa_samples_factor; + GLenum fb_format; + GLenum fb_type; + int i; + + static const GLenum back_buffer_modes[] = { + GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML + }; + + /* TODO probe the hardware of what is supports */ + depth_bits_array[0] = 0; + depth_bits_array[1] = 24; + depth_bits_array[2] = 24; + + stencil_bits_array[0] = 0; /* no depth or stencil */ + stencil_bits_array[1] = 0; /* z24x8 */ + stencil_bits_array[2] = 8; /* z24s8 */ + + msaa_samples_array[0] = 0; + + depth_buffer_factor = 3; + back_buffer_factor = 3; + msaa_samples_factor = 1; + + num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; + + if (pixel_bits == 16) { + fb_format = GL_RGB; + fb_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + fb_format = GL_BGRA; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + } + + configs = driCreateConfigs(fb_format, fb_type, + depth_bits_array, + stencil_bits_array, depth_buffer_factor, + back_buffer_modes, back_buffer_factor, + msaa_samples_array, msaa_samples_factor); + if (configs == NULL) { + debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); + return NULL; + } + + for (i = 0; configs[i]; i++) { + m = &configs[i]->modes; + if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { + m->visualRating = GLX_SLOW_CONFIG; + } + } + + return (const const __DRIconfig **) configs; +} + + +/** + * Get information about previous buffer swaps. + */ +int +dri_get_swap_info(__DRIdrawablePrivate * dPriv, + __DRIswapInfo * sInfo) +{ + if (dPriv == NULL || + dPriv->driverPrivate == NULL || + sInfo == NULL) + return -1; + else + return 0; +} + + +/** + * NULL stub for old dri loaders + */ +const __DRIconfig ** +dri_init_screen(__DRIscreenPrivate *sPriv) +{ + return NULL; +} + + +/** + * This is the driver specific part of the createNewScreen entry point. + * + * Returns the __GLcontextModes supported by this driver. + */ +const __DRIconfig ** +dri_init_screen2(__DRIscreenPrivate *sPriv) +{ + struct dri_screen *screen; + + /* Set up dispatch table to cope with all known extensions */ + dri_init_extensions(NULL); + + screen = CALLOC_STRUCT(dri_screen); + if (!screen) + goto fail; + + screen->sPriv = sPriv; + screen->fd = sPriv->fd; + sPriv->private = (void *) screen; + sPriv->extensions = dri_screen_extensions; + + + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); + if (!screen->pipe_screen) { + debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); + goto fail; + } + + /* We need to hook in here */ + screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; + + driParseOptionInfo(&screen->optionCache, + __driConfigOptions, + __driNConfigOptions); + + return dri_fill_in_modes(sPriv, + 4 * 8, + 24, + 8, + 1); +fail: + return NULL; +} + + +void +dri_destroy_screen(__DRIscreenPrivate * sPriv) +{ + struct dri_screen *screen = dri_screen(sPriv); + + screen->pipe_screen->destroy(screen->pipe_screen); + FREE(screen); + sPriv->private = NULL; +} + + +PUBLIC const struct __DriverAPIRec driDriverAPI = { + .InitScreen = dri_init_screen, /* not supported but exported */ + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .SwapBuffers = dri_swap_buffers, /* not supported but exported */ + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, + .GetSwapInfo = dri_get_swap_info, + .GetDrawableMSC = driDrawableGetMSC32, + .WaitForMSC = driWaitForMSC32, + .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */ + .InitScreen2 = dri_init_screen2, +}; + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h new file mode 100644 index 0000000000..3751ec6121 --- /dev/null +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -0,0 +1,88 @@ +/************************************************************************** + * + * Copyright 2009, VMware, Inc. + * 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 + * without limitation the rights to use, copy, modify, merge, publish, + * 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 above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +/* + * Author: Keith Whitwell + * Author: Jakob Bornecrantz + */ + +#ifndef DRI_SCREEN_H +#define DRI_SCREEN_H + +#include "dri_util.h" +#include "xmlconfig.h" + +#include "pipe/p_compiler.h" + +struct dri_screen +{ + /* dri */ + __DRIscreenPrivate *sPriv; + + /** + * Configuration cache with default values for all contexts + */ + driOptionCache optionCache; + + /** + * Temporary(?) context to use for SwapBuffers or other situations in + * which we need a rendering context, but none is currently bound. + */ + struct dri_context *dummyContext; + + /* drm */ + int fd; + + /* gallium */ + struct pipe_winsys *pipe_winsys; + struct pipe_screen *pipe_screen; +}; + + +/** cast wrapper */ +static INLINE struct dri_screen * +dri_screen(__DRIscreenPrivate *sPriv) +{ + return (struct dri_screen *) sPriv->private; +} + + +/*********************************************************************** + * dri_screen.c + */ +const __DRIconfig ** +dri_init_screen2(__DRIscreenPrivate *sPriv); + +void +dri_destroy_screen(__DRIscreenPrivate * sPriv); + +int +dri_get_swap_info(__DRIdrawablePrivate * dPriv, + __DRIswapInfo * sInfo); + +#endif + +/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/Makefile b/src/gallium/state_trackers/dri2/Makefile deleted file mode 100644 index 47750e997e..0000000000 --- a/src/gallium/state_trackers/dri2/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = dri2drm - -LIBRARY_INCLUDES = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa/main \ - $(shell pkg-config --cflags-only-I libdrm) - - -C_SOURCES = \ - dri_context.c \ - dri_screen.c \ - dri_drawable.c \ - dri_extensions.c - -# $(TOP)/src/mesa/drivers/dri/common/utils.c \ - $(TOP)/src/mesa/drivers/dri/common/vblank.c \ - $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ - $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c \ - $(TOP)/src/mesa/drivers/common/driverfuncs.c \ - $(TOP)/src/mesa/drivers/dri/common/texmem.c \ - $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c - -include ../../Makefile.template diff --git a/src/gallium/state_trackers/dri2/dri_context.c b/src/gallium/state_trackers/dri2/dri_context.c deleted file mode 100644 index 92c26ac70f..0000000000 --- a/src/gallium/state_trackers/dri2/dri_context.c +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" - -#include "dri_drawable.h" - - -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" -#include "pipe/p_context.h" - -#include "dri_context.h" - -#include "util/u_memory.h" - - -GLboolean -dri_create_context(const __GLcontextModes *visual, - __DRIcontextPrivate *cPriv, - void *sharedContextPrivate) -{ - __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; - struct dri_screen *screen = dri_screen(sPriv); - struct dri_context *ctx = NULL; - struct st_context *st_share = NULL; - - if (sharedContextPrivate) { - st_share = ((struct dri_context *) sharedContextPrivate)->st; - } - - ctx = CALLOC_STRUCT(dri_context); - if (ctx == NULL) - goto fail; - - cPriv->driverPrivate = ctx; - ctx->cPriv = cPriv; - ctx->sPriv = sPriv; - - driParseConfigFiles(&ctx->optionCache, - &screen->optionCache, - sPriv->myNum, - "dri"); - - ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); - - if (ctx->pipe == NULL) - goto fail; - - /* used in dri_flush_frontbuffer */ - ctx->pipe->priv = ctx; - - ctx->st = st_create_context(ctx->pipe, visual, st_share); - if (ctx->st == NULL) - goto fail; - - dri_init_extensions(ctx); - - return GL_TRUE; - -fail: - if (ctx && ctx->st) - st_destroy_context(ctx->st); - - if (ctx && ctx->pipe) - ctx->pipe->destroy(ctx->pipe); - - FREE(ctx); - return FALSE; -} - - -void -dri_destroy_context(__DRIcontextPrivate *cPriv) -{ - struct dri_context *ctx = dri_context(cPriv); - struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); - - /* No particular reason to wait for command completion before - * destroying a context, but it is probably worthwhile flushing it - * to avoid having to add code elsewhere to cope with flushing a - * partially destroyed context. - */ - st_flush(ctx->st, 0, NULL); - - if (screen->dummyContext == ctx) - screen->dummyContext = NULL; - - /* Also frees ctx->pipe? - */ - st_destroy_context(ctx->st); - - FREE(ctx); -} - - -GLboolean -dri_unbind_context(__DRIcontextPrivate *cPriv) -{ - struct dri_context *ctx = dri_context(cPriv); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* XXX make_current(NULL)? */ - return GL_TRUE; -} - - -GLboolean -dri_make_current(__DRIcontextPrivate *cPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - if (cPriv) { - struct dri_context *ctx = dri_context(cPriv); - struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); - struct dri_drawable *draw = dri_drawable(driDrawPriv); - struct dri_drawable *read = dri_drawable(driReadPriv); - - /* This is for situations in which we need a rendering context but - * there may not be any currently bound. - */ - screen->dummyContext = ctx; - - st_make_current(ctx->st, - draw->stfb, - read->stfb); - - /* used in dri_flush_frontbuffer */ - ctx->dPriv = driDrawPriv; - - if (driDrawPriv) - dri_get_buffers(driDrawPriv); - if (driDrawPriv != driReadPriv && driReadPriv) - dri_get_buffers(driReadPriv); - } else { - st_make_current(NULL, NULL, NULL); - } - - return GL_TRUE; -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_context.h b/src/gallium/state_trackers/dri2/dri_context.h deleted file mode 100644 index e910472700..0000000000 --- a/src/gallium/state_trackers/dri2/dri_context.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** - * - * Copyright (C) 2009 VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_CONTEXT_H -#define DRI_CONTEXT_H - -#include "pipe/p_compiler.h" -#include "drm.h" -#include "dri_util.h" - - -struct pipe_context; -struct pipe_fence; -struct st_context; -struct dri_drawable; - - -struct dri_context -{ - /* dri */ - __DRIscreenPrivate *sPriv; - __DRIcontextPrivate *cPriv; - __DRIdrawablePrivate *dPriv; - - driOptionCache optionCache; - - /* gallium */ - struct st_context *st; - struct pipe_context *pipe; -}; - - -static INLINE struct dri_context * -dri_context(__DRIcontextPrivate *driContextPriv) -{ - return (struct dri_context *) driContextPriv->driverPrivate; -} - - -/*********************************************************************** - * dri_context.c - */ -void -dri_destroy_context(__DRIcontextPrivate * driContextPriv); - -boolean -dri_unbind_context(__DRIcontextPrivate * driContextPriv); - -boolean -dri_make_current(__DRIcontextPrivate * driContextPriv, - __DRIdrawablePrivate * driDrawPriv, - __DRIdrawablePrivate * driReadPriv); - -boolean -dri_create_context(const __GLcontextModes * visual, - __DRIcontextPrivate * driContextPriv, - void *sharedContextPrivate); - - -/*********************************************************************** - * dri_extensions.c - */ -void -dri_init_extensions(struct dri_context *ctx); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_drawable.c b/src/gallium/state_trackers/dri2/dri_drawable.c deleted file mode 100644 index 2e3f4099e2..0000000000 --- a/src/gallium/state_trackers/dri2/dri_drawable.c +++ /dev/null @@ -1,325 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_inlines.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_cb_fbo.h" - -#include "util/u_memory.h" - - -static void -dri_copy_to_front(__DRIdrawablePrivate *dPriv, - struct pipe_surface *from, - int x, int y, unsigned w, unsigned h) -{ - /* TODO send a message to the Xserver to copy to the real front buffer */ -} - - -static struct pipe_surface * -dri_surface_from_handle(struct pipe_screen *screen, - unsigned handle, - enum pipe_format format, - unsigned width, - unsigned height, - unsigned pitch) -{ - struct pipe_surface *surface = NULL; - struct pipe_texture *texture = NULL; - struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - - buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle); - if (!buf) - return NULL; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth[0] = 1; - templat.format = format; - templat.width[0] = width; - templat.height[0] = height; - pf_get_block(templat.format, &templat.block); - - texture = screen->texture_blanket(screen, - &templat, - &pitch, - buf); - - /* we don't need the buffer from this point on */ - pipe_buffer_reference(&buf, NULL); - - if (!texture) - return NULL; - - surface = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - - /* we don't need the texture from this point on */ - pipe_texture_reference(&texture, NULL); - return surface; -} - - -/** - * This will be called a drawable is known to have been resized. - */ -void -dri_get_buffers(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *surface = NULL; - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; - __DRIbuffer *buffers = NULL; - __DRIscreen *dri_screen = drawable->sPriv; - __DRIdrawable *dri_drawable = drawable->dPriv; - boolean have_depth = FALSE; - int i, count; - - buffers = (*dri_screen->dri2.loader->getBuffers)(dri_drawable, - &dri_drawable->w, - &dri_drawable->h, - drawable->attachments, - drawable->num_attachments, - &count, - dri_drawable->loaderPrivate); - - if (buffers == NULL) { - return; - } - - /* set one cliprect to cover the whole dri_drawable */ - dri_drawable->x = 0; - dri_drawable->y = 0; - dri_drawable->backX = 0; - dri_drawable->backY = 0; - dri_drawable->numClipRects = 1; - dri_drawable->pClipRects[0].x1 = 0; - dri_drawable->pClipRects[0].y1 = 0; - dri_drawable->pClipRects[0].x2 = dri_drawable->w; - dri_drawable->pClipRects[0].y2 = dri_drawable->h; - dri_drawable->numBackClipRects = 1; - dri_drawable->pBackClipRects[0].x1 = 0; - dri_drawable->pBackClipRects[0].y1 = 0; - dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; - dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; - - for (i = 0; i < count; i++) { - enum pipe_format format = 0; - int index = 0; - - switch (buffers[i].attachment) { - case __DRI_BUFFER_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_FAKE_FRONT_LEFT: - index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_BACK_LEFT: - index = ST_SURFACE_BACK_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case __DRI_BUFFER_DEPTH: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_STENCIL: - index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; - break; - case __DRI_BUFFER_ACCUM: - default: - assert(0); - } - assert(buffers[i].cpp == 4); - - if (index == ST_SURFACE_DEPTH) { - if (have_depth) - continue; - else - have_depth = TRUE; - } - - surface = dri_surface_from_handle(screen, - buffers[i].name, - format, - dri_drawable->w, - dri_drawable->h, - buffers[i].pitch); - - st_set_framebuffer_surface(drawable->stfb, index, surface); - pipe_surface_reference(&surface, NULL); - } - /* this needed, or else the state tracker fails to pick the new buffers */ - st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h); -} - - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private) -{ - struct dri_context *ctx = (struct dri_context *)context_private; - dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height); -} - - -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv) -{ - /* not needed for dri2 */ - assert(0); -} - - -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) -{ - /* not needed for dri2 */ - assert(0); -} - - -/** - * This is called when we need to set up GL rendering to a new X window. - */ -boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap) -{ - enum pipe_format colorFormat, depthFormat, stencilFormat; - struct dri_screen *screen = sPriv->private; - struct dri_drawable *drawable = NULL; - struct pipe_screen *pscreen = screen->pipe_screen; - int i; - - if (isPixmap) - goto fail; /* not implemented */ - - drawable = CALLOC_STRUCT(dri_drawable); - if (drawable == NULL) - goto fail; - - /* XXX: todo: use the pipe_screen queries to figure out which - * render targets are supportable. - */ - assert(visual->redBits == 8); - assert(visual->depthBits == 24 || visual->depthBits == 0); - assert(visual->stencilBits == 8 || visual->stencilBits == 0); - - colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; - - if (visual->depthBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - depthFormat = PIPE_FORMAT_Z24S8_UNORM; - else - depthFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - depthFormat = PIPE_FORMAT_NONE; - - if (visual->stencilBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - stencilFormat = PIPE_FORMAT_Z24S8_UNORM; - else - stencilFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - stencilFormat = PIPE_FORMAT_NONE; - - drawable->stfb = st_create_framebuffer(visual, - colorFormat, - depthFormat, - stencilFormat, - dPriv->w, - dPriv->h, - (void*) drawable); - if (drawable->stfb == NULL) - goto fail; - - drawable->sPriv = sPriv; - drawable->dPriv = dPriv; - dPriv->driverPrivate = (void *) drawable; - - /* setup dri2 buffers information */ - i = 0; - drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; -#if 0 - /* TODO incase of double buffer visual, delay fake creation */ - drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; -#endif - if (visual->doubleBufferMode) - drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; - if (visual->depthBits) - drawable->attachments[i++] = __DRI_BUFFER_DEPTH; - if (visual->stencilBits) - drawable->attachments[i++] = __DRI_BUFFER_STENCIL; - drawable->num_attachments = i; - - return GL_TRUE; -fail: - FREE(drawable); - return GL_FALSE; -} - - -void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - - st_unreference_framebuffer(drawable->stfb); - - FREE(drawable); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_drawable.h b/src/gallium/state_trackers/dri2/dri_drawable.h deleted file mode 100644 index 185c657b35..0000000000 --- a/src/gallium/state_trackers/dri2/dri_drawable.h +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef DRI_DRAWABLE_H -#define DRI_DRAWABLE_H - -#include "pipe/p_compiler.h" - -struct pipe_surface; -struct pipe_fence; -struct st_framebuffer; - - -struct dri_drawable -{ - /* dri */ - __DRIdrawablePrivate *dPriv; - __DRIscreenPrivate *sPriv; - - unsigned attachments[8]; - unsigned num_attachments; - - /* gallium */ - struct st_framebuffer *stfb; -}; - - -static INLINE struct dri_drawable * -dri_drawable(__DRIdrawablePrivate * driDrawPriv) -{ - return (struct dri_drawable *) driDrawPriv->driverPrivate; -} - - -/*********************************************************************** - * dri_drawable.c - */ -boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap); - -void -dri_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private); - -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv); - -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, - int x, int y, - int w, int h); - -void -dri_get_buffers(__DRIdrawablePrivate * dPriv); - -void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_extensions.c b/src/gallium/state_trackers/dri2/dri_extensions.c deleted file mode 100644 index 732d1e89b0..0000000000 --- a/src/gallium/state_trackers/dri2/dri_extensions.c +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "dri_screen.h" -#include "dri_context.h" -#include "state_tracker/st_context.h" - -#define need_GL_ARB_multisample -#define need_GL_ARB_occlusion_query -#define need_GL_ARB_point_parameters -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_buffer_object -#define need_GL_ARB_vertex_program -#define need_GL_ARB_window_pos -#define need_GL_EXT_blend_color -#define need_GL_EXT_blend_equation_separate -#define need_GL_EXT_blend_func_separate -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_cull_vertex -#define need_GL_EXT_fog_coord -#define need_GL_EXT_framebuffer_object -#define need_GL_EXT_multi_draw_arrays -#define need_GL_EXT_secondary_color -#define need_GL_NV_vertex_program -#include "extension_helper.h" - - -/** - * Extension strings exported by the driver. - */ -const struct dri_extension card_extensions[] = { - {"GL_ARB_multisample", GL_ARB_multisample_functions}, - {"GL_ARB_multitexture", NULL}, - {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, - {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, - {"GL_ARB_texture_border_clamp", NULL}, - {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, - {"GL_ARB_texture_cube_map", NULL}, - {"GL_ARB_texture_env_add", NULL}, - {"GL_ARB_texture_env_combine", NULL}, - {"GL_ARB_texture_env_dot3", NULL}, - {"GL_ARB_texture_mirrored_repeat", NULL}, - {"GL_ARB_texture_rectangle", NULL}, - {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, - {"GL_ARB_pixel_buffer_object", NULL}, - {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, - {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, - {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, - {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, - {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, - {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, - {"GL_EXT_blend_subtract", NULL}, - {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, - {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, - {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, - {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, - {"GL_EXT_packed_depth_stencil", NULL}, - {"GL_EXT_pixel_buffer_object", NULL}, - {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, - {"GL_EXT_stencil_wrap", NULL}, - {"GL_EXT_texture_edge_clamp", NULL}, - {"GL_EXT_texture_env_combine", NULL}, - {"GL_EXT_texture_env_dot3", NULL}, - {"GL_EXT_texture_filter_anisotropic", NULL}, - {"GL_EXT_texture_lod_bias", NULL}, - {"GL_3DFX_texture_compression_FXT1", NULL}, - {"GL_APPLE_client_storage", NULL}, - {"GL_MESA_pack_invert", NULL}, - {"GL_MESA_ycbcr_texture", NULL}, - {"GL_NV_blend_square", NULL}, - {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, - {"GL_NV_vertex_program1_1", NULL}, - {"GL_SGIS_generate_mipmap", NULL }, - {NULL, NULL} -}; - - -void -dri_init_extensions(struct dri_context *ctx) -{ - /* The card_extensions list should be pruned according to the - * capabilities of the pipe_screen. This is actually something - * that can/should be done inside st_create_context(). - */ - if (ctx) - driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); - else - driInitExtensions(NULL, card_extensions, GL_FALSE); -} - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c deleted file mode 100644 index ab33003f51..0000000000 --- a/src/gallium/state_trackers/dri2/dri_screen.c +++ /dev/null @@ -1,239 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#include "utils.h" -#include "vblank.h" -#include "xmlpool.h" - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_drawable.h" - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_inlines.h" -#include "state_tracker/drm_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_cb_fbo.h" - - -PUBLIC const char __driConfigOptions[] = - DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) - DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0) - DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY - /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/ - DRI_CONF_ALLOW_LARGE_TEXTURES(1) - DRI_CONF_SECTION_END DRI_CONF_END; - - -const uint __driNConfigOptions = 3; - - -static const __DRIextension *dri_screen_extensions[] = { - &driReadDrawableExtension, - &driCopySubBufferExtension.base, - &driSwapControlExtension.base, - &driFrameTrackingExtension.base, - &driMediaStreamCounterExtension.base, - NULL -}; - -static const __DRIconfig ** -dri_fill_in_modes(__DRIscreenPrivate *psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) -{ - __DRIconfig **configs; - __GLcontextModes *m; - unsigned num_modes; - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; - uint8_t msaa_samples_array[1]; - unsigned depth_buffer_factor; - unsigned back_buffer_factor; - unsigned msaa_samples_factor; - GLenum fb_format; - GLenum fb_type; - int i; - - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML - }; - - /* TODO probe the hardware of what is supports */ - depth_bits_array[0] = 0; - depth_bits_array[1] = 24; - depth_bits_array[2] = 24; - - stencil_bits_array[0] = 0; /* no depth or stencil */ - stencil_bits_array[1] = 0; /* z24x8 */ - stencil_bits_array[2] = 8; /* z24s8 */ - - msaa_samples_array[0] = 0; - - depth_buffer_factor = 3; - back_buffer_factor = 3; - msaa_samples_factor = 1; - - num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } - else { - fb_format = GL_BGRA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, - stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - msaa_samples_array, msaa_samples_factor); - if (configs == NULL) { - debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); - return NULL; - } - - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - - return (const const __DRIconfig **) configs; -} - - -/** - * Get information about previous buffer swaps. - */ -int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo) -{ - if (dPriv == NULL || - dPriv->driverPrivate == NULL || - sInfo == NULL) - return -1; - else - return 0; -} - - -/** - * NULL stub for old dri loaders - */ -const __DRIconfig ** -dri_init_screen(__DRIscreenPrivate *sPriv) -{ - return NULL; -} - - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * Returns the __GLcontextModes supported by this driver. - */ -const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv) -{ - struct dri_screen *screen; - - /* Set up dispatch table to cope with all known extensions */ - dri_init_extensions(NULL); - - screen = CALLOC_STRUCT(dri_screen); - if (!screen) - goto fail; - - screen->sPriv = sPriv; - screen->fd = sPriv->fd; - sPriv->private = (void *) screen; - sPriv->extensions = dri_screen_extensions; - - - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); - if (!screen->pipe_screen) { - debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); - goto fail; - } - - /* We need to hook in here */ - screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; - - driParseOptionInfo(&screen->optionCache, - __driConfigOptions, - __driNConfigOptions); - - return dri_fill_in_modes(sPriv, - 4 * 8, - 24, - 8, - 1); -fail: - return NULL; -} - - -void -dri_destroy_screen(__DRIscreenPrivate * sPriv) -{ - struct dri_screen *screen = dri_screen(sPriv); - - screen->pipe_screen->destroy(screen->pipe_screen); - FREE(screen); - sPriv->private = NULL; -} - - -PUBLIC const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, /* not supported but exported */ - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, /* not supported but exported */ - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .GetSwapInfo = dri_get_swap_info, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */ - .InitScreen2 = dri_init_screen2, -}; - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h deleted file mode 100644 index 3751ec6121..0000000000 --- a/src/gallium/state_trackers/dri2/dri_screen.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** - * - * Copyright 2009, VMware, Inc. - * 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 - * without limitation the rights to use, copy, modify, merge, publish, - * 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * 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 VMWARE 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 USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ -/* - * Author: Keith Whitwell - * Author: Jakob Bornecrantz - */ - -#ifndef DRI_SCREEN_H -#define DRI_SCREEN_H - -#include "dri_util.h" -#include "xmlconfig.h" - -#include "pipe/p_compiler.h" - -struct dri_screen -{ - /* dri */ - __DRIscreenPrivate *sPriv; - - /** - * Configuration cache with default values for all contexts - */ - driOptionCache optionCache; - - /** - * Temporary(?) context to use for SwapBuffers or other situations in - * which we need a rendering context, but none is currently bound. - */ - struct dri_context *dummyContext; - - /* drm */ - int fd; - - /* gallium */ - struct pipe_winsys *pipe_winsys; - struct pipe_screen *pipe_screen; -}; - - -/** cast wrapper */ -static INLINE struct dri_screen * -dri_screen(__DRIscreenPrivate *sPriv) -{ - return (struct dri_screen *) sPriv->private; -} - - -/*********************************************************************** - * dri_screen.c - */ -const __DRIconfig ** -dri_init_screen2(__DRIscreenPrivate *sPriv); - -void -dri_destroy_screen(__DRIscreenPrivate * sPriv); - -int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo); - -#endif - -/* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile index e7c57afc34..286ef08d5b 100644 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ b/src/gallium/winsys/drm/intel/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile index 728870d2e1..5e5efbcb11 100644 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri2.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nv04/libnv04.a \ $(TOP)/src/gallium/drivers/nv10/libnv10.a \ diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile index f471c44349..58a87dae18 100644 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ b/src/gallium/winsys/drm/radeon/dri2/Makefile @@ -7,7 +7,7 @@ LIBNAME = radeon_dri.so MINIGLX_SOURCES = PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -- cgit v1.2.3 From 05af5a7f593ac6451cff9e6923d4a969d5358bcb Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 28 Apr 2009 11:58:27 +0200 Subject: gallium: Rename the dri state tracker lib to libdridrm.a --- src/gallium/state_trackers/dri/Makefile | 2 +- src/gallium/winsys/drm/intel/dri2/Makefile | 2 +- src/gallium/winsys/drm/nouveau/dri2/Makefile | 2 +- src/gallium/winsys/drm/radeon/dri2/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/state_trackers/dri/Makefile b/src/gallium/state_trackers/dri/Makefile index 47750e997e..ef8f19709a 100644 --- a/src/gallium/state_trackers/dri/Makefile +++ b/src/gallium/state_trackers/dri/Makefile @@ -1,7 +1,7 @@ TOP = ../../../.. include $(TOP)/configs/current -LIBNAME = dri2drm +LIBNAME = dridrm LIBRARY_INCLUDES = \ -I$(TOP)/include \ diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile index 286ef08d5b..125e79e0ed 100644 --- a/src/gallium/winsys/drm/intel/dri2/Makefile +++ b/src/gallium/winsys/drm/intel/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile index 5e5efbcb11..377a80d518 100644 --- a/src/gallium/winsys/drm/nouveau/dri2/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile @@ -4,7 +4,7 @@ include $(TOP)/configs/current LIBNAME = nouveau_dri2.so PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ $(TOP)/src/gallium/drivers/nv04/libnv04.a \ $(TOP)/src/gallium/drivers/nv10/libnv10.a \ diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile index 58a87dae18..c218ee9d01 100644 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ b/src/gallium/winsys/drm/radeon/dri2/Makefile @@ -7,7 +7,7 @@ LIBNAME = radeon_dri.so MINIGLX_SOURCES = PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdri2drm.a \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -- cgit v1.2.3 From 1ae877d95adbc19cb0a8d4fe07f46ac4d46c8147 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 03:28:37 -0700 Subject: radeon: Use PCI_MATCH_ANY for xorg driver. Might as well. --- src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c index 6f77fbe5de..36824251f0 100644 --- a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c +++ b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c @@ -38,20 +38,17 @@ static Bool radeon_xorg_pci_probe(DriverPtr driver, intptr_t match_data); static const struct pci_id_match radeon_xorg_device_match[] = { - {0x1002, 0x5E4D, 0xffff, 0xffff, 0, 0, 0}, - {0x1002, 0x7249, 0xffff, 0xffff, 0, 0, 0}, + {0x1002, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, {0, 0, 0}, }; static SymTabRec radeon_xorg_chipsets[] = { - {0x5E4D, "Radeon RV410 PCIE (X700)"}, - {0x7249, "Radeon R580 PCIE (X1900 XT)"}, + {PCI_MATCH_ANY, "ATI/AMD Radeon Graphics Chipset"}, {-1, NULL} }; static PciChipsets radeon_xorg_pci_devices[] = { - {0x5E4D, 0x5E4D, RES_SHARED_VGA}, - {0x7249, 0x7249, RES_SHARED_VGA}, + {PCI_MATCH_ANY, PCI_MATCH_ANY, RES_SHARED_VGA}, {-1, -1, RES_UNDEFINED} }; -- cgit v1.2.3 From 81ded8092a4068ec289e6c7207078f076bfee5fd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 03:28:57 -0700 Subject: radeon-r300: Fix a bit of breakage. Not really sure why reordering the ioctls makes them work again. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 19 +++++++++--------- src/gallium/winsys/drm/radeon/dri/Makefile | 25 ++++++++++++++++++++++++ src/gallium/winsys/drm/radeon/dri/SConscript | 14 +++++++++++++ src/gallium/winsys/drm/radeon/dri2/Makefile | 25 ------------------------ src/gallium/winsys/drm/radeon/dri2/SConscript | 14 ------------- 5 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 src/gallium/winsys/drm/radeon/dri/Makefile create mode 100644 src/gallium/winsys/drm/radeon/dri/SConscript delete mode 100644 src/gallium/winsys/drm/radeon/dri2/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/dri2/SConscript (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 293b6c2d38..3302d623bf 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -53,32 +53,31 @@ static void radeon_r300_flush_cs(struct radeon_cs* cs) static void do_ioctls(struct r300_winsys* winsys, int fd) { drm_radeon_getparam_t gp; - uint32_t target; + int target; int retval; /* XXX is this cast safe? */ gp.value = (int*)⌖ - /* First, get PCI ID */ - gp.param = RADEON_PARAM_DEVICE_ID; + /* First, get the number of pixel pipes */ + gp.param = RADEON_PARAM_NUM_GB_PIPES; retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); if (retval) { - fprintf(stderr, "%s: Failed to get PCI ID, error number %d", + fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n", __FUNCTION__, retval); exit(1); } - winsys->pci_id = target; + winsys->gb_pipes = target; - /* Then, get the number of pixel pipes */ - gp.param = RADEON_PARAM_NUM_GB_PIPES; + /* Then, get PCI ID */ + gp.param = RADEON_PARAM_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); if (retval) { - fprintf(stderr, "%s: Failed to get GB pipe count, error number %d", + fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n", __FUNCTION__, retval); exit(1); } - winsys->gb_pipes = target; - + winsys->pci_id = target; } struct r300_winsys* diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile new file mode 100644 index 0000000000..c218ee9d01 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -0,0 +1,25 @@ + +TOP = ../../../../../.. +include $(TOP)/configs/current + +LIBNAME = radeon_dri.so + +MINIGLX_SOURCES = + +PIPE_DRIVERS = \ + $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/r300/libr300.a + +C_SOURCES = \ + $(COMMON_GALLIUM_SOURCES) \ + $(DRIVER_SOURCES) + +ASM_SOURCES = + +include ../../Makefile.template + +DRI_LIB_DEPS += -ldrm_radeon + +symlinks: diff --git a/src/gallium/winsys/drm/radeon/dri/SConscript b/src/gallium/winsys/drm/radeon/dri/SConscript new file mode 100644 index 0000000000..f2cdee97d9 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/dri/SConscript @@ -0,0 +1,14 @@ +Import('*') + +env = drienv.Clone() + +drivers = [ + softpipe, + r300 +] + +env.SharedLibrary( + target ='radeon_dri.so', + source = COMMON_GALLIUM_SOURCES, + LIBS = drivers + mesa + auxiliaries + env['LIBS'], +) diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile deleted file mode 100644 index c218ee9d01..0000000000 --- a/src/gallium/winsys/drm/radeon/dri2/Makefile +++ /dev/null @@ -1,25 +0,0 @@ - -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = radeon_dri.so - -MINIGLX_SOURCES = - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../../Makefile.template - -DRI_LIB_DEPS += -ldrm_radeon - -symlinks: diff --git a/src/gallium/winsys/drm/radeon/dri2/SConscript b/src/gallium/winsys/drm/radeon/dri2/SConscript deleted file mode 100644 index f2cdee97d9..0000000000 --- a/src/gallium/winsys/drm/radeon/dri2/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -Import('*') - -env = drienv.Clone() - -drivers = [ - softpipe, - r300 -] - -env.SharedLibrary( - target ='radeon_dri.so', - source = COMMON_GALLIUM_SOURCES, - LIBS = drivers + mesa + auxiliaries + env['LIBS'], -) -- cgit v1.2.3 From 1f43cc1d841d3be04433224842f89ff03ba28a02 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 28 Apr 2009 04:37:56 -0700 Subject: radeon: Fix cast and comment. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 3302d623bf..adbf23ab51 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -56,8 +56,7 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) int target; int retval; - /* XXX is this cast safe? */ - gp.value = (int*)⌖ + gp.value = ⌖ /* First, get the number of pixel pipes */ gp.param = RADEON_PARAM_NUM_GB_PIPES; -- cgit v1.2.3 From d7f4ac9f34a72efe53a1a140557f1822afbadf16 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 05:03:56 -0700 Subject: r300-gallium, radeon-winsys: Reorganize r300_winsys header, break ABI. Make things more consistent, prepare for more function hooks. --- src/gallium/drivers/r300/r300_cs.h | 18 ++++---- src/gallium/drivers/r300/r300_winsys.h | 46 ++++++++++---------- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 53 +++++++++++++++++------- 3 files changed, 70 insertions(+), 47 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 5d9799dd72..82a3942248 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -49,27 +49,27 @@ #define CS_LOCALS(context) \ struct r300_winsys* cs_winsys = context->winsys; \ - struct radeon_cs* cs = cs_winsys->cs; \ int cs_count = 0; #define CHECK_CS(size) \ - cs_winsys->check_cs(cs, (size)) + cs_winsys->check_cs(cs_winsys, (size)) #define BEGIN_CS(size) do { \ CHECK_CS(size); \ debug_printf("r300: BEGIN_CS, count %d, in %s (%s:%d)\n", \ size, __FUNCTION__, __FILE__, __LINE__); \ - cs_winsys->begin_cs(cs, (size), __FILE__, __FUNCTION__, __LINE__); \ + cs_winsys->begin_cs(cs_winsys, (size), \ + __FILE__, __FUNCTION__, __LINE__); \ cs_count = size; \ } while (0) #define OUT_CS(value) do { \ - cs_winsys->write_cs_dword(cs, (value)); \ + cs_winsys->write_cs_dword(cs_winsys, (value)); \ cs_count--; \ } while (0) #define OUT_CS_32F(value) do { \ - cs_winsys->write_cs_dword(cs, fui(value)); \ + cs_winsys->write_cs_dword(cs_winsys, fui(value)); \ cs_count--; \ } while (0) @@ -97,7 +97,7 @@ bo, offset); \ assert(bo); \ OUT_CS(offset); \ - cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \ + cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ cs_count -= 2; \ } while (0) @@ -106,13 +106,13 @@ __LINE__); \ if (cs_count != 0) \ debug_printf("r300: Warning: cs_count off by %d\n", cs_count); \ - cs_winsys->end_cs(cs, __FILE__, __FUNCTION__, __LINE__); \ + cs_winsys->end_cs(cs_winsys, __FILE__, __FUNCTION__, __LINE__); \ } while (0) #define FLUSH_CS do { \ debug_printf("r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, __FILE__, \ __LINE__); \ - cs_winsys->flush_cs(cs); \ + cs_winsys->flush_cs(cs_winsys); \ } while (0) #define RADEON_ONE_REG_WR (1 << 15) @@ -138,7 +138,7 @@ assert(bo); \ OUT_CS(offset); \ OUT_CS(count); \ - cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \ + cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ cs_count -= 2; \ } while (0) diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index baa95282c3..393ba07012 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -35,8 +35,6 @@ extern "C" { #include "pipe/p_state.h" #include "pipe/internal/p_winsys_screen.h" -struct radeon_cs; - struct r300_winsys { /* Parent class */ struct pipe_winsys base; @@ -44,45 +42,45 @@ struct r300_winsys { /* Opaque Radeon-specific winsys object. */ void* radeon_winsys; + /* CS object. This is very much like Intel's batchbuffer. + * Fill it full of dwords and relocs and then submit. + * Repeat as needed. */ + struct radeon_cs* cs; + /* PCI ID */ uint32_t pci_id; /* GB pipe count */ uint32_t gb_pipes; - /* CS object. This is very much like Intel's batchbuffer. - * Fill it full of dwords and relocs and then submit. - * Repeat as needed. */ - struct radeon_cs* cs; - /* Check to see if there's room for commands. */ - boolean (*check_cs)(struct radeon_cs* cs, int size); + boolean (*check_cs)(struct r300_winsys* winsys, int size); /* Start a command emit. */ - void (*begin_cs)(struct radeon_cs* cs, - int size, - const char* file, - const char* function, - int line); + void (*begin_cs)(struct r300_winsys* winsys, + int size, + const char* file, + const char* function, + int line); /* Write a dword to the command buffer. */ - void (*write_cs_dword)(struct radeon_cs* cs, uint32_t dword); + void (*write_cs_dword)(struct r300_winsys* winsys, uint32_t dword); /* Write a relocated dword to the command buffer. */ - void (*write_cs_reloc)(struct radeon_cs* cs, - struct pipe_buffer* bo, - uint32_t rd, - uint32_t wd, - uint32_t flags); + void (*write_cs_reloc)(struct r300_winsys* winsys, + struct pipe_buffer* bo, + uint32_t rd, + uint32_t wd, + uint32_t flags); /* Finish a command emit. */ - void (*end_cs)(struct radeon_cs* cs, - const char* file, - const char* function, - int line); + void (*end_cs)(struct r300_winsys* winsys, + const char* file, + const char* function, + int line); /* Flush the CS. */ - void (*flush_cs)(struct radeon_cs* cs); + void (*flush_cs)(struct r300_winsys* winsys); }; struct pipe_context* r300_create_context(struct pipe_screen* screen, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index adbf23ab51..929e4842cc 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,31 +22,56 @@ #include "radeon_r300.h" -static boolean radeon_r300_check_cs(struct radeon_cs* cs, int size) +static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size) { /* XXX check size here, lazy ass! */ + /* XXX also validate buffers */ return TRUE; } -static void radeon_r300_write_cs_reloc(struct radeon_cs* cs, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd, - uint32_t flags) +static void radeon_r300_begin_cs(struct r300_winsys* winsys, + int size, + const char* file, + const char* function, + int line) { - radeon_cs_write_reloc(cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + radeon_cs_begin(winsys->cs, size, file, function, line); } -static void radeon_r300_flush_cs(struct radeon_cs* cs) +static void radeon_r300_write_cs_dword(struct r300_winsys* winsys, + uint32_t dword) +{ + radeon_cs_write_dword(winsys->cs, dword); +} + +static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd, + uint32_t flags) +{ + radeon_cs_write_reloc(winsys->cs, + ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); +} + +static void radeon_r300_end_cs(struct r300_winsys* winsys, + const char* file, + const char* function, + int line) +{ + radeon_cs_end(winsys->cs, file, function, line); +} + +static void radeon_r300_flush_cs(struct r300_winsys* winsys) { int retval = 0; - retval = radeon_cs_emit(cs); + retval = radeon_cs_emit(winsys->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); - radeon_cs_print(cs, stderr); + radeon_cs_print(winsys->cs, stderr); } - radeon_cs_erase(cs); + radeon_cs_erase(winsys->cs); } /* Helper function to do the ioctls needed for setup and init. */ @@ -96,10 +121,10 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); winsys->check_cs = radeon_r300_check_cs; - winsys->begin_cs = radeon_cs_begin; - winsys->write_cs_dword = radeon_cs_write_dword; + winsys->begin_cs = radeon_r300_begin_cs; + winsys->write_cs_dword = radeon_r300_write_cs_dword; winsys->write_cs_reloc = radeon_r300_write_cs_reloc; - winsys->end_cs = radeon_cs_end; + winsys->end_cs = radeon_r300_end_cs; winsys->flush_cs = radeon_r300_flush_cs; memcpy(winsys, old_winsys, sizeof(struct radeon_winsys)); -- cgit v1.2.3 From c11ad489e7432f3ed2fcaf5b15b8fe3538ae6d30 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 05:54:53 -0700 Subject: r300-gallium, radeon-winsys: Space accounting. It is no longer optional in current libdrm, so it was time to actually start counting our BOs. --- src/gallium/drivers/r300/r300_emit.c | 10 +++- src/gallium/drivers/r300/r300_surface.c | 7 +++ src/gallium/drivers/r300/r300_winsys.h | 16 +++++ src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 12 +++- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 18 +++++- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 4 +- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 68 ++++++++++++++++++++++ 7 files changed, 126 insertions(+), 9 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 74d63ffe41..01bac5f759 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -424,13 +424,21 @@ void r300_emit_dirty_state(struct r300_context* r300) int i; int dirty_tex = 0; - if (!(r300->dirty_state) && !(r300->dirty_hw)) { + if (!(r300->dirty_hw)) { return; } r300_update_derived_state(r300); /* XXX check size */ + struct r300_texture* fb_tex = + (struct r300_texture*)r300->framebuffer_state.cbufs[0]; + r300->winsys->add_buffer(r300->winsys, fb_tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + /* XXX */ + r300->context.flush(&r300->context, 0, NULL); + } if (r300->dirty_state & R300_NEW_BLEND) { r300_emit_blend_state(r300, r300->blend_state); diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 79bed03253..4dd5b8af99 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -34,6 +34,13 @@ static void r300_surface_setup(struct pipe_context* pipe, unsigned pixpitch = tex->stride / tex->tex.block.size; CS_LOCALS(r300); + /* Make sure our target BO is okay. */ + r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM); + if (r300->winsys->validate(r300->winsys)) { + r300->context.flush(&r300->context, 0, NULL); + } + r300_emit_blend_state(r300, &blend_clear_state); r300_emit_blend_color_state(r300, &blend_color_clear_state); r300_emit_dsa_state(r300, &dsa_clear_state); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 393ba07012..761aedebfc 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -53,6 +53,22 @@ struct r300_winsys { /* GB pipe count */ uint32_t gb_pipes; + /* GART size. */ + uint32_t gart_size; + + /* VRAM size. */ + uint32_t vram_size; + + /* Add a pipe_buffer to the list of buffer objects to validate. */ + void (*add_buffer)(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd); + + /* Revalidate all currently setup pipe_buffers. + * Returns TRUE if a flush is required. */ + boolean (*validate)(struct r300_winsys* winsys); + /* Check to see if there's room for commands. */ boolean (*check_cs)(struct r300_winsys* winsys, int size); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 611ee68da6..6313eb219e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -68,8 +68,8 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, domain |= RADEON_GEM_DOMAIN_GTT; } - radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment, - domain, 0); + radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, + alignment, domain, 0); if (radeon_buffer->bo == NULL) { FREE(radeon_buffer); } @@ -169,8 +169,14 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) return NULL; } + radeon_ws->priv = CALLOC_STRUCT(radeon_winsys_priv); + if (radeon_ws->priv == NULL) { + FREE(radeon_ws); + return NULL; + } + bom = radeon_bo_manager_gem_ctor(fd); - radeon_ws->bom = bom; + radeon_ws->priv->bom = bom; 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 163422f296..73fa362aca 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -41,6 +41,7 @@ #include "util/u_memory.h" #include "radeon_bo.h" +#include "radeon_cs.h" #include "radeon_drm.h" @@ -49,13 +50,24 @@ struct radeon_pipe_buffer { struct radeon_bo *bo; }; +#define RADEON_MAX_BOS 24 + +struct radeon_winsys_priv { + /* Radeon BO manager. */ + struct radeon_bo_manager* bom; + + /* Radeon BO space checker. */ + struct radeon_cs_space_check sc[RADEON_MAX_BOS]; + /* Current BO count. */ + unsigned bo_count; +}; + 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; + /* This corresponds to void* radeon_winsys in r300_winsys. */ + struct radeon_winsys_priv* priv; }; struct radeon_winsys* radeon_pipe_winsys(int fb); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 1f89d1b1d1..428d3f65a1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -32,7 +32,7 @@ /* Create a pipe_screen. */ struct pipe_screen* radeon_create_screen(int drmFB, - struct drm_create_screen_arg *arg ) + struct drm_create_screen_arg *arg) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); @@ -69,7 +69,7 @@ struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen, unsigned handle) { struct radeon_bo_manager* bom = - ((struct radeon_winsys*)screen->winsys)->bom; + ((struct radeon_winsys*)screen->winsys)->priv->bom; struct radeon_pipe_buffer* radeon_buffer; struct radeon_bo* bo = NULL; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 929e4842cc..b172107432 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,6 +22,54 @@ #include "radeon_r300.h" +static void radeon_r300_add_buffer(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd) +{ + int i; + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + struct radeon_cs_space_check* sc = priv->sc; + struct radeon_bo* bo = ((struct radeon_pipe_buffer*)pbuffer)->bo; + + /* Check to see if this BO is already in line for validation; + * find a slot for it otherwise. */ + for (i = 0; i < RADEON_MAX_BOS; i++) { + if (sc[i].bo == bo) { + return; + } else if (sc[i].bo == NULL) { + sc[i].bo = bo; + sc[i].read_domains = rd; + sc[i].write_domain = wd; + priv->bo_count = i + 1; + return; + } + } + + assert(FALSE && "Oh God too many BOs!"); +} + +static boolean radeon_r300_validate(struct r300_winsys* winsys) +{ + int retval; + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + struct radeon_cs_space_check* sc = priv->sc; + + retval = radeon_cs_space_check(winsys->cs, sc, priv->bo_count); + + if (retval == RADEON_CS_SPACE_OP_TO_BIG) { + /* XXX we need to failover here */ + } else if (retval == RADEON_CS_SPACE_FLUSH) { + /* We must flush before more rendering can commence. */ + return TRUE; + } + + /* Things are fine, we can proceed as normal. */ + return FALSE; +} + static boolean radeon_r300_check_cs(struct r300_winsys* winsys, int size) { /* XXX check size here, lazy ass! */ @@ -77,6 +125,7 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(struct r300_winsys* winsys, int fd) { + struct drm_radeon_gem_info info; drm_radeon_getparam_t gp; int target; int retval; @@ -102,6 +151,18 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) exit(1); } winsys->pci_id = target; + + /* Finally, retrieve MM info */ + retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO, + &info, sizeof(info)); + if (retval) { + fprintf(stderr, "%s: Failed to get MM info, error number %d\n", + __FUNCTION__, retval); + exit(1); + } + winsys->gart_size = info.gart_size; + /* XXX */ + winsys->vram_size = info.vram_visible; } struct r300_winsys* @@ -119,6 +180,13 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) csm = radeon_cs_manager_gem_ctor(fd); winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); + radeon_cs_set_limit(winsys->cs, + RADEON_GEM_DOMAIN_GTT, winsys->gart_size); + radeon_cs_set_limit(winsys->cs, + RADEON_GEM_DOMAIN_VRAM, winsys->vram_size); + + winsys->add_buffer = radeon_r300_add_buffer; + winsys->validate = radeon_r300_validate; winsys->check_cs = radeon_r300_check_cs; winsys->begin_cs = radeon_r300_begin_cs; -- cgit v1.2.3 From 5b15cc312f16c6147e1f8f3d25c6ed34076aa3a1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 06:01:52 -0700 Subject: r300-gallium, radeon-winsys: Hide radeon_cs from r300 pipe. --- src/gallium/drivers/r300/r300_winsys.h | 5 --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 3 +- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 6 ++++ src/gallium/winsys/drm/radeon/core/radeon_r300.c | 42 +++++++++++++++------- 4 files changed, 36 insertions(+), 20 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 761aedebfc..a833bb0399 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -42,11 +42,6 @@ struct r300_winsys { /* Opaque Radeon-specific winsys object. */ void* radeon_winsys; - /* CS object. This is very much like Intel's batchbuffer. - * Fill it full of dwords and relocs and then submit. - * Repeat as needed. */ - struct radeon_cs* cs; - /* PCI ID */ uint32_t pci_id; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 6313eb219e..a15487352b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -175,8 +175,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) return NULL; } - bom = radeon_bo_manager_gem_ctor(fd); - radeon_ws->priv->bom = bom; + 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 73fa362aca..ca8bbb3c11 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -60,6 +60,12 @@ struct radeon_winsys_priv { struct radeon_cs_space_check sc[RADEON_MAX_BOS]; /* Current BO count. */ unsigned bo_count; + + /* Radeon CS manager. */ + struct radeon_cs_manager* csm; + + /* Current CS. */ + struct radeon_cs* cs; }; struct radeon_winsys { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index b172107432..ac6cca36bf 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -57,7 +57,7 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) (struct radeon_winsys_priv*)winsys->radeon_winsys; struct radeon_cs_space_check* sc = priv->sc; - retval = radeon_cs_space_check(winsys->cs, sc, priv->bo_count); + retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { /* XXX we need to failover here */ @@ -83,13 +83,19 @@ static void radeon_r300_begin_cs(struct r300_winsys* winsys, const char* function, int line) { - radeon_cs_begin(winsys->cs, size, file, function, line); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_begin(priv->cs, size, file, function, line); } static void radeon_r300_write_cs_dword(struct r300_winsys* winsys, uint32_t dword) { - radeon_cs_write_dword(winsys->cs, dword); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_write_dword(priv->cs, dword); } static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, @@ -98,7 +104,10 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, uint32_t wd, uint32_t flags) { - radeon_cs_write_reloc(winsys->cs, + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_write_reloc(priv->cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); } @@ -107,19 +116,24 @@ static void radeon_r300_end_cs(struct r300_winsys* winsys, const char* function, int line) { - radeon_cs_end(winsys->cs, file, function, line); + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_end(priv->cs, file, function, line); } static void radeon_r300_flush_cs(struct r300_winsys* winsys) { + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; int retval = 0; - retval = radeon_cs_emit(winsys->cs); + retval = radeon_cs_emit(priv->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); - radeon_cs_print(winsys->cs, stderr); + radeon_cs_print(priv->cs, stderr); } - radeon_cs_erase(winsys->cs); + radeon_cs_erase(priv->cs); } /* Helper function to do the ioctls needed for setup and init. */ @@ -169,20 +183,22 @@ struct r300_winsys* radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) { struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys); - struct radeon_cs_manager* csm; + struct radeon_winsys_priv* priv; if (winsys == NULL) { return NULL; } + priv = old_winsys->priv; + do_ioctls(winsys, fd); - csm = radeon_cs_manager_gem_ctor(fd); + priv->csm = radeon_cs_manager_gem_ctor(fd); - winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4); - radeon_cs_set_limit(winsys->cs, + priv->cs = radeon_cs_create(priv->csm, 1024 * 64 / 4); + radeon_cs_set_limit(priv->cs, RADEON_GEM_DOMAIN_GTT, winsys->gart_size); - radeon_cs_set_limit(winsys->cs, + radeon_cs_set_limit(priv->cs, RADEON_GEM_DOMAIN_VRAM, winsys->vram_size); winsys->add_buffer = radeon_r300_add_buffer; -- cgit v1.2.3 From 2953b180044df602fbbf5882715774a779ff2123 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 1 May 2009 07:29:14 -0700 Subject: radeon: Don't even bother with things too big to fit into our card. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index ac6cca36bf..da233203d7 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -60,7 +60,9 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { - /* XXX we need to failover here */ + /* We might as well HCF, since this is not going to fit in the card, + * period. */ + exit(1); } else if (retval == RADEON_CS_SPACE_FLUSH) { /* We must flush before more rendering can commence. */ return TRUE; -- cgit v1.2.3 From cd59933d9f70c6acea63013f1b773b545026bf81 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 16:50:42 -0700 Subject: r300-gallium, radeon: A couple cleanups. Trying to track down goddamn bugs. :C --- src/gallium/drivers/r300/r300_context.c | 4 ---- src/gallium/drivers/r300/r300_state.c | 3 +++ src/gallium/drivers/r300/r300_texture.c | 1 + src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +++++++- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 6bdf544a05..a4e89c37d1 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -34,10 +34,6 @@ static boolean r300_draw_range_elements(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); int i; - if (r300->dirty_state) { - r300_emit_dirty_state(r300); - } - for (i = 0; i < r300->vertex_buffer_count; i++) { void* buf = pipe_buffer_map(pipe->screen, r300->vertex_buffers[i].buffer, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 184a23c9e6..0143e228c4 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -562,14 +562,17 @@ static void r300_set_viewport_state(struct pipe_context* pipe, r300->viewport_state->vte_control = R300_VTX_W0_FMT; if (state->scale[0] != 1.0f) { + assert(state->scale[0] != 0.0f); r300->viewport_state->xscale = state->scale[0]; r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA; } if (state->scale[1] != 1.0f) { + assert(state->scale[1] != 0.0f); r300->viewport_state->yscale = state->scale[1]; r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA; } if (state->scale[2] != 1.0f) { + assert(state->scale[2] != 0.0f); r300->viewport_state->zscale = state->scale[2]; r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA; } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index fe91f4e184..6c9d3b7412 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -187,6 +187,7 @@ static struct pipe_texture* tex->stride); pipe_buffer_reference(&tex->buffer, buffer); + debug_printf("%p is the buffer\n", tex->buffer); return (struct pipe_texture*)tex; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index da233203d7..5dcce20cd5 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -62,6 +62,7 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) if (retval == RADEON_CS_SPACE_OP_TO_BIG) { /* We might as well HCF, since this is not going to fit in the card, * period. */ + /* XXX just drop it on the floor instead */ exit(1); } else if (retval == RADEON_CS_SPACE_FLUSH) { /* We must flush before more rendering can commence. */ @@ -128,14 +129,19 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) { struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; - int retval = 0; + struct radeon_cs_space_check* sc = priv->sc; + int retval = 1; + /* Emit the CS. */ retval = radeon_cs_emit(priv->cs); if (retval) { debug_printf("radeon: Bad CS, dumping...\n"); radeon_cs_print(priv->cs, stderr); } radeon_cs_erase(priv->cs); + + /* Clean out BOs. */ + memset(sc, 0, sizeof(struct radeon_cs_space_check) * RADEON_MAX_BOS); } /* Helper function to do the ioctls needed for setup and init. */ -- cgit v1.2.3 From bed917641cfde06b9ff609760ba20b498a65cefa Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 17:09:32 -0700 Subject: radeon-gallium: Shut up Valgrind. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 5dcce20cd5..556f1d9b87 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -147,9 +147,9 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(struct r300_winsys* winsys, int fd) { - struct drm_radeon_gem_info info; - drm_radeon_getparam_t gp; - int target; + struct drm_radeon_gem_info info = {0}; + drm_radeon_getparam_t gp = {0}; + int target = 0; int retval; gp.value = ⌖ -- cgit v1.2.3 From 1b26c2bbaefe3608b96d9351c0f2eac80274891c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 8 May 2009 19:40:38 -0700 Subject: r300-gallium, radeon: BO handling fixes, some useful asserts. --- src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index ab17af799b..38b1682415 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -459,7 +459,7 @@ void r300_emit_dirty_state(struct r300_context* r300) /* Color buffers... */ for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]; - //assert(tex && tex->buffer && "cbuf is marked, but NULL!"); + assert(tex && tex->buffer && "cbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM); @@ -467,7 +467,7 @@ void r300_emit_dirty_state(struct r300_context* r300) /* ...depth buffer... */ if (r300->framebuffer_state.zsbuf) { tex = (struct r300_texture*)r300->framebuffer_state.zsbuf; - //assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); + assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); if (!tex->buffer) return; r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 556f1d9b87..cbe1652302 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -37,6 +37,8 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, * find a slot for it otherwise. */ for (i = 0; i < RADEON_MAX_BOS; i++) { if (sc[i].bo == bo) { + sc[i].read_domains |= rd; + sc[i].write_domain |= wd; return; } else if (sc[i].bo == NULL) { sc[i].bo = bo; @@ -52,11 +54,15 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, static boolean radeon_r300_validate(struct r300_winsys* winsys) { - int retval; + int retval, i; struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; struct radeon_cs_space_check* sc = priv->sc; + debug_printf("Validation count: %d\n", priv->bo_count); + for (i = 0; i < priv->bo_count; i++) { + debug_printf("BO %d: %p rd: %d wd: %d\n", i, sc[i].bo, sc[i].read_domains, sc[i].write_domain); + } retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { -- cgit v1.2.3 From 53c2cc8fefa07723fc456d94eda292e201c41dae Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 9 May 2009 00:43:05 -0700 Subject: radeon-gallium: Clean up some of the BO counting logic. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index cbe1652302..be70ead68d 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -35,21 +35,19 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, /* Check to see if this BO is already in line for validation; * find a slot for it otherwise. */ - for (i = 0; i < RADEON_MAX_BOS; i++) { + assert(priv->bo_count <= RADEON_MAX_BOS); + for (i = 0; i < priv->bo_count; i++) { if (sc[i].bo == bo) { sc[i].read_domains |= rd; sc[i].write_domain |= wd; return; - } else if (sc[i].bo == NULL) { - sc[i].bo = bo; - sc[i].read_domains = rd; - sc[i].write_domain = wd; - priv->bo_count = i + 1; - return; } } - assert(FALSE && "Oh God too many BOs!"); + sc[priv->bo_count].bo = bo; + sc[priv->bo_count].read_domains = rd; + sc[priv->bo_count].write_domain = wd; + priv->bo_count++; } static boolean radeon_r300_validate(struct r300_winsys* winsys) @@ -148,6 +146,7 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Clean out BOs. */ memset(sc, 0, sizeof(struct radeon_cs_space_check) * RADEON_MAX_BOS); + priv->bo_count = 0; } /* Helper function to do the ioctls needed for setup and init. */ -- cgit v1.2.3 From 2e22bd8460ebbb2dd85417d8e5e670fa651d0da9 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 11 May 2009 09:04:15 -0700 Subject: radeon-gallium: Support new info ioctls in addition to classic getparams. This makes non-hybrid kernels like newttm from drm-next-radeon work while avoiding breakage with Fedora/Ubuntu/etc. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 42 +++++++++++++++++------- src/gallium/winsys/drm/radeon/core/radeon_r300.h | 11 +++++++ 2 files changed, 41 insertions(+), 12 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index be70ead68d..56b0d00842 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -152,44 +152,62 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(struct r300_winsys* winsys, int fd) { - struct drm_radeon_gem_info info = {0}; + struct drm_radeon_gem_info gem_info = {0}; drm_radeon_getparam_t gp = {0}; + struct drm_radeon_info info = {0}; int target = 0; int retval; + info.value = ⌖ gp.value = ⌖ /* First, get the number of pixel pipes */ - gp.param = RADEON_PARAM_NUM_GB_PIPES; - retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); + info.request = RADEON_INFO_NUM_GB_PIPES; + retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { - fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n", + fprintf(stderr, "%s: New ioctl for GB pipe count failed " + "(error number %d), trying classic ioctl...\n", __FUNCTION__, retval); - exit(1); + gp.param = RADEON_PARAM_NUM_GB_PIPES; + retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, + sizeof(gp)); + if (retval) { + fprintf(stderr, "%s: Failed to get GB pipe count, " + "error number %d\n", __FUNCTION__, retval); + exit(1); + } } winsys->gb_pipes = target; /* Then, get PCI ID */ - gp.param = RADEON_PARAM_DEVICE_ID; - retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); + info.request = RADEON_INFO_DEVICE_ID; + retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { - fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n", + fprintf(stderr, "%s: New ioctl for PCI ID failed " + "(error number %d), trying classic ioctl...\n", __FUNCTION__, retval); - exit(1); + gp.param = RADEON_PARAM_DEVICE_ID; + retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, + sizeof(gp)); + if (retval) { + fprintf(stderr, "%s: Failed to get PCI ID, " + "error number %d\n", __FUNCTION__, retval); + exit(1); + } } winsys->pci_id = target; /* Finally, retrieve MM info */ retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO, - &info, sizeof(info)); + &gem_info, sizeof(gem_info)); if (retval) { fprintf(stderr, "%s: Failed to get MM info, error number %d\n", __FUNCTION__, retval); exit(1); } - winsys->gart_size = info.gart_size; + winsys->gart_size = gem_info.gart_size; /* XXX */ - winsys->vram_size = info.vram_visible; + winsys->vram_size = gem_info.vram_visible; } struct r300_winsys* diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index 5c373cd084..98586746cd 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -31,5 +31,16 @@ #include "radeon_buffer.h" +/* protect us from bonghits */ +#ifndef RADEON_INFO_NUM_GB_PIPES +#define RADEON_INFO_NUM_GB_PIPES 0 +#endif +#ifndef RADEON_INFO_DEVICE_ID +#define RADEON_INFO_DEVICE_ID 0 +#endif +#ifndef DRM_RADEON_INFO +#define DRM_RADEON_INFO 0x1 +#endif + struct r300_winsys* radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys); -- cgit v1.2.3 From f38a02212fef426dd3f86e5d0f52126e4132a003 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 11 May 2009 09:55:28 -0700 Subject: radeon-gallium: Forgot a typedef. --- src/gallium/winsys/drm/radeon/core/radeon_r300.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index 98586746cd..19c7ed2626 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -40,6 +40,11 @@ #endif #ifndef DRM_RADEON_INFO #define DRM_RADEON_INFO 0x1 +struct drm_radeon_info { + uint32_t request; + uint32_t pad; + uint64_t value; +}; #endif struct r300_winsys* -- cgit v1.2.3 From 5e39a8c4503596a019dc7c3ed4e24ee4117b1fca Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 16 May 2009 09:58:54 -0700 Subject: Create common trace_drm code, add to radeon_winsys. --- src/gallium/auxiliary/trace/trace_drm.h | 165 ++++++++++++++++++++++++ src/gallium/winsys/drm/radeon/core/radeon_drm.c | 8 ++ src/gallium/winsys/drm/radeon/dri/Makefile | 1 + src/gallium/winsys/drm/radeon/egl/Makefile | 1 + 4 files changed, 175 insertions(+) create mode 100644 src/gallium/auxiliary/trace/trace_drm.h (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/auxiliary/trace/trace_drm.h b/src/gallium/auxiliary/trace/trace_drm.h new file mode 100644 index 0000000000..892bd9860c --- /dev/null +++ b/src/gallium/auxiliary/trace/trace_drm.h @@ -0,0 +1,165 @@ +/* + * Copyright 2009 Jakob Bornecrantz + * Corbin Simpson + * + * 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 without limitation + * on the rights to use, copy, modify, merge, publish, 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 above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * 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 AUTHOR(S) AND/OR THEIR 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 + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef TRACE_DRM_H +#define TRACE_DRM_H + +#include "state_tracker/drm_api.h" + +#include "trace/tr_buffer.h" +#include "trace/tr_context.h" +#include "trace/tr_screen.h" +#include "trace/tr_texture.h" + +struct drm_api hooks; + +static struct pipe_screen * +trace_drm_create_screen(int fd, struct drm_create_screen_arg *arg) +{ + struct pipe_screen *screen; + + if (arg && arg->mode != DRM_CREATE_NORMAL) + return NULL; + + screen = hooks.create_screen(fd, arg); + + return trace_screen_create(screen); +}; + +static struct pipe_context * +trace_drm_create_context(struct pipe_screen *_screen) +{ + struct pipe_screen *screen; + struct pipe_context *pipe; + + if (trace_enabled()) + screen = trace_screen(_screen)->screen; + else + screen = _screen; + + pipe = hooks.create_context(screen); + + if (trace_enabled()) + pipe = trace_context_create(_screen, pipe); + + return pipe; +}; + +static boolean +trace_drm_buffer_from_texture(struct pipe_texture *_texture, + struct pipe_buffer **_buffer, + unsigned *stride) +{ + struct pipe_texture *texture; + struct pipe_buffer *buffer = NULL; + boolean result; + + if (trace_enabled()) + texture = trace_texture(_texture)->texture; + else + texture = _texture; + + result = hooks.buffer_from_texture(texture, &buffer, stride); + + if (result && _buffer) + buffer = trace_buffer_create(trace_screen(texture->screen), buffer); + + if (_buffer) + *_buffer = buffer; + else + pipe_buffer_reference(&buffer, NULL); + + return result; +} + +static struct pipe_buffer * +trace_drm_buffer_from_handle(struct pipe_screen *_screen, + const char *name, + unsigned handle) +{ + struct pipe_screen *screen; + struct pipe_buffer *result; + + if (trace_enabled()) + screen = trace_screen(_screen)->screen; + else + screen = _screen; + + result = hooks.buffer_from_handle(screen, name, handle); + + if (trace_enabled()) + result = trace_buffer_create(trace_screen(_screen), result); + + return result; +} + +static boolean +trace_drm_handle_from_buffer(struct pipe_screen *_screen, + struct pipe_buffer *_buffer, + unsigned *handle) +{ + struct pipe_screen *screen; + struct pipe_buffer *buffer; + + if (trace_enabled()) { + screen = trace_screen(_screen)->screen; + buffer = trace_buffer(_buffer)->buffer; + } else { + screen = _screen; + buffer = _buffer; + } + + return hooks.handle_from_buffer(screen, buffer, handle); +} + +static boolean +trace_drm_global_handle_from_buffer(struct pipe_screen *_screen, + struct pipe_buffer *_buffer, + unsigned *handle) +{ + struct pipe_screen *screen; + struct pipe_buffer *buffer; + + if (trace_enabled()) { + screen = trace_screen(_screen)->screen; + buffer = trace_buffer(_buffer)->buffer; + } else { + screen = _screen; + buffer = _buffer; + } + + return hooks.global_handle_from_buffer(screen, buffer, handle); +} + +struct drm_api drm_api_hooks = +{ + .create_screen = trace_drm_create_screen, + .create_context = trace_drm_create_context, + + .buffer_from_texture = trace_drm_buffer_from_texture, + .buffer_from_handle = trace_drm_buffer_from_handle, + .handle_from_buffer = trace_drm_handle_from_buffer, + .global_handle_from_buffer = trace_drm_global_handle_from_buffer, +}; + +#endif /* TRACE_DRM_H */ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 428d3f65a1..5406d2bbea 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -30,6 +30,10 @@ #include "radeon_drm.h" +#ifdef DEBUG +#include "trace/trace_drm.h" +#endif + /* Create a pipe_screen. */ struct pipe_screen* radeon_create_screen(int drmFB, struct drm_create_screen_arg *arg) @@ -112,7 +116,11 @@ boolean radeon_global_handle_from_buffer(struct pipe_screen* screen, 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 */ diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile index c218ee9d01..a9889444de 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -10,6 +10,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a C_SOURCES = \ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index d989b3aa93..6a1448d1b9 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -8,6 +8,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a DRIVER_SOURCES = -- cgit v1.2.3 From 6a40d1e9d96f8e8c57bc3bbd6f567cacd4471f59 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 17 May 2009 17:03:15 -0700 Subject: r300-gallium, radeon-gallium: Nuke gb_pipes from orbit. See the previous commit for an explanation. This is just all the support code for GB_TILE_CONFIG. --- src/gallium/drivers/r300/r300_chipset.c | 1 - src/gallium/drivers/r300/r300_chipset.h | 2 -- src/gallium/drivers/r300/r300_screen.c | 1 - src/gallium/drivers/r300/r300_state_inlines.h | 19 ------------------- src/gallium/drivers/r300/r300_winsys.h | 3 --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 22 ++-------------------- src/gallium/winsys/drm/radeon/core/radeon_r300.h | 3 --- 7 files changed, 2 insertions(+), 49 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index db09f27bfa..758f706c51 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -34,7 +34,6 @@ void r300_parse_chipset(struct r300_capabilities* caps) caps->is_r500 = FALSE; caps->num_vert_fpus = 4; - /* Note: These are not ordered by PCI ID. I leave that task to GCC, * which will perform the ordering while collating jump tables. Instead, * I've tried to group them according to capabilities and age. */ diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h index 21eebeae60..5b2e1f0568 100644 --- a/src/gallium/drivers/r300/r300_chipset.h +++ b/src/gallium/drivers/r300/r300_chipset.h @@ -34,8 +34,6 @@ struct r300_capabilities { int family; /* The number of vertex floating-point units */ int num_vert_fpus; - /* The number of fragment pipes */ - int num_frag_pipes; /* Whether or not TCL is physically present */ boolean has_tcl; /* Whether or not this is an RV515 or newer; R500s have many differences diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 6fe724cc92..04d6db81b0 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -346,7 +346,6 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys) return NULL; caps->pci_id = r300_winsys->pci_id; - caps->num_frag_pipes = r300_winsys->gb_pipes; r300_parse_chipset(caps); diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 91b93fc367..22c8e199ae 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -353,25 +353,6 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format) /* Non-CSO state. (For now.) */ -static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) -{ - switch (pipe_count) { - case 1: - return R300_GB_TILE_PIPE_COUNT_RV300; - break; - case 2: - return R300_GB_TILE_PIPE_COUNT_R300; - break; - case 3: - return R300_GB_TILE_PIPE_COUNT_R420_3P; - break; - case 4: - return R300_GB_TILE_PIPE_COUNT_R420; - break; - } - return 0; -} - static INLINE uint32_t translate_vertex_data_type(int type) { switch (type) { case EMIT_1F: diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index a833bb0399..a5ced8041c 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -45,9 +45,6 @@ struct r300_winsys { /* PCI ID */ uint32_t pci_id; - /* GB pipe count */ - uint32_t gb_pipes; - /* GART size. */ uint32_t gart_size; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 56b0d00842..d257e01693 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -161,25 +161,7 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) info.value = ⌖ gp.value = ⌖ - /* First, get the number of pixel pipes */ - info.request = RADEON_INFO_NUM_GB_PIPES; - retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); - if (retval) { - fprintf(stderr, "%s: New ioctl for GB pipe count failed " - "(error number %d), trying classic ioctl...\n", - __FUNCTION__, retval); - gp.param = RADEON_PARAM_NUM_GB_PIPES; - retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, - sizeof(gp)); - if (retval) { - fprintf(stderr, "%s: Failed to get GB pipe count, " - "error number %d\n", __FUNCTION__, retval); - exit(1); - } - } - winsys->gb_pipes = target; - - /* Then, get PCI ID */ + /* First, get PCI ID */ info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { @@ -197,7 +179,7 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) } winsys->pci_id = target; - /* Finally, retrieve MM info */ + /* Then, retrieve MM info */ retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO, &gem_info, sizeof(gem_info)); if (retval) { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index 19c7ed2626..a2e0e58248 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -32,9 +32,6 @@ #include "radeon_buffer.h" /* protect us from bonghits */ -#ifndef RADEON_INFO_NUM_GB_PIPES -#define RADEON_INFO_NUM_GB_PIPES 0 -#endif #ifndef RADEON_INFO_DEVICE_ID #define RADEON_INFO_DEVICE_ID 0 #endif -- cgit v1.2.3 From 026f4c97dc4cf29c93461857afa76b07086ede42 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 May 2009 09:47:37 -0700 Subject: radeon-gallium: Remove BO validation debug. It appears that that area of code "just works" much like classic Mesa's version, so might as well not waste scrollback on it. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index d257e01693..65366e242c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -57,10 +57,6 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) (struct radeon_winsys_priv*)winsys->radeon_winsys; struct radeon_cs_space_check* sc = priv->sc; - debug_printf("Validation count: %d\n", priv->bo_count); - for (i = 0; i < priv->bo_count; i++) { - debug_printf("BO %d: %p rd: %d wd: %d\n", i, sc[i].bo, sc[i].read_domains, sc[i].write_domain); - } retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count); if (retval == RADEON_CS_SPACE_OP_TO_BIG) { -- cgit v1.2.3 From 4550423211063010a2fa482037d8233bb80e3773 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 07:18:08 -0700 Subject: radeon-gallium: Don't permit reading and writing a BO in one CS. This fixes some silent problems in current libdrm_radeon. surface_copy still locks up hard. --- src/gallium/drivers/r300/r300_cs.h | 5 +++-- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 82a3942248..2abf04d27e 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -93,8 +93,9 @@ } while (0) #define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \ - debug_printf("r300: writing relocation for buffer %p, offset %d\n", \ - bo, offset); \ + debug_printf("r300: writing relocation for buffer %p, offset %d, " \ + "domains (%d, %d, %d)\n", \ + bo, offset, rd, wd, flags); \ assert(bo); \ OUT_CS(offset); \ cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 65366e242c..995bf6aa22 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -69,6 +69,16 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys) return TRUE; } + /* XXX should probably be its own function */ + for (i = 0; i < priv->bo_count; i++) { + if (sc[i].read_domains && sc[i].write_domain) { + /* Cute, cute. We need to flush first. */ + debug_printf("radeon: BO %p can't be read and written; " + "requesting flush.\n", sc[i].bo); + return TRUE; + } + } + /* Things are fine, we can proceed as normal. */ return FALSE; } @@ -109,9 +119,15 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, { struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; + int retval = 0; - radeon_cs_write_reloc(priv->cs, + retval = radeon_cs_write_reloc(priv->cs, ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + + if (retval) { + debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", + pbuffer, rd, wd, flags); + } } static void radeon_r300_end_cs(struct r300_winsys* winsys, -- cgit v1.2.3 From 0ba7f762339cbc8be31fe98421b0c9b44c7402fa Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 May 2009 13:21:17 -0700 Subject: radeon-gallium: Add surface_buffer_create callback. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index a15487352b..0d0fdc5bd8 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -93,6 +93,29 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws, return &radeon_buffer->base; } +static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws, + unsigned width, + unsigned height, + enum pipe_format format, + unsigned usage, + unsigned *stride) +{ + struct pipe_format_block block; + unsigned nblocksx, nblocksy, size; + + pf_get_block(format, &block); + + nblocksx = pf_get_nblocksx(&block, width); + nblocksy = pf_get_nblocksy(&block, height); + + /* Radeons enjoy things in multiples of 32. */ + /* XXX this can be 32 when POT */ + *stride = (nblocksx * block.size + 63) & ~63; + size = *stride * nblocksy; + + return radeon_buffer_create(ws, 64, usage, size); +} + static void radeon_buffer_del(struct pipe_buffer *buffer) { struct radeon_pipe_buffer *radeon_buffer = @@ -180,10 +203,11 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer; radeon_ws->base.buffer_create = radeon_buffer_create; - radeon_ws->base.buffer_destroy = radeon_buffer_del; radeon_ws->base.user_buffer_create = radeon_buffer_user_create; + radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create; radeon_ws->base.buffer_map = radeon_buffer_map; radeon_ws->base.buffer_unmap = radeon_buffer_unmap; + radeon_ws->base.buffer_destroy = radeon_buffer_del; radeon_ws->base.fence_reference = radeon_fence_reference; radeon_ws->base.fence_signalled = radeon_fence_signalled; -- cgit v1.2.3 From b70fcd620d69850c6e19213d84ae4584e77ab689 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 May 2009 07:46:34 -0700 Subject: r300-gallium, radeon-gallium: Make add_buffer indicate when a flush is needed. On a side note, why is RADEON_MAX_BOS 24? Should ask airlied about that. --- src/gallium/drivers/r300/r300_emit.c | 28 +++++++++++++++++------- src/gallium/drivers/r300/r300_surface.c | 21 +++++++++++++----- src/gallium/drivers/r300/r300_winsys.h | 8 +++---- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 16 +++++++++----- 4 files changed, 50 insertions(+), 23 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 5e4b179505..caeb73a8ed 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -467,27 +467,39 @@ validate: for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture; assert(tex && tex->buffer && "cbuf is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } /* ...depth buffer... */ if (r300->framebuffer_state.zsbuf) { tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture; assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } /* ...textures... */ for (i = 0; i < r300->texture_count; i++) { tex = r300->textures[i]; assert(tex && tex->buffer && "texture is marked, but NULL!"); - r300->winsys->add_buffer(r300->winsys, tex->buffer, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } /* ...and vertex buffer. */ if (r300->vbo) { - r300->winsys->add_buffer(r300->winsys, r300->vbo, - RADEON_GEM_DOMAIN_GTT, 0); + if (!r300->winsys->add_buffer(r300->winsys, r300->vbo, + RADEON_GEM_DOMAIN_GTT, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } } else { debug_printf("No VBO while emitting dirty state!\n"); } diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 7711e8f569..c9e2dff14e 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -120,8 +120,11 @@ fallback: /* Make sure our target BO is okay. */ validate: - r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } if (r300->winsys->validate(r300->winsys)) { r300->context.flush(&r300->context, 0, NULL); if (invalid) { @@ -242,10 +245,16 @@ fallback: /* Add our target BOs to the list. */ validate: - r300->winsys->add_buffer(r300->winsys, srctex->buffer, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); - r300->winsys->add_buffer(r300->winsys, desttex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM); + if (!r300->winsys->add_buffer(r300->winsys, srctex->buffer, + RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } + if (!r300->winsys->add_buffer(r300->winsys, desttex->buffer, + 0, RADEON_GEM_DOMAIN_VRAM)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } if (r300->winsys->validate(r300->winsys)) { r300->context.flush(&r300->context, 0, NULL); if (invalid) { diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index a5ced8041c..d2893c3b9d 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -52,10 +52,10 @@ struct r300_winsys { uint32_t vram_size; /* Add a pipe_buffer to the list of buffer objects to validate. */ - void (*add_buffer)(struct r300_winsys* winsys, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd); + boolean (*add_buffer)(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd); /* Revalidate all currently setup pipe_buffers. * Returns TRUE if a flush is required. */ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 995bf6aa22..63aa3179ac 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,10 +22,10 @@ #include "radeon_r300.h" -static void radeon_r300_add_buffer(struct r300_winsys* winsys, - struct pipe_buffer* pbuffer, - uint32_t rd, - uint32_t wd) +static boolean radeon_r300_add_buffer(struct r300_winsys* winsys, + struct pipe_buffer* pbuffer, + uint32_t rd, + uint32_t wd) { int i; struct radeon_winsys_priv* priv = @@ -35,7 +35,6 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, /* Check to see if this BO is already in line for validation; * find a slot for it otherwise. */ - assert(priv->bo_count <= RADEON_MAX_BOS); for (i = 0; i < priv->bo_count; i++) { if (sc[i].bo == bo) { sc[i].read_domains |= rd; @@ -44,10 +43,17 @@ static void radeon_r300_add_buffer(struct r300_winsys* winsys, } } + if (priv->bo_count >= RADEON_MAX_BOS) { + /* Dohoho. Not falling for that one again. Request a flush. */ + return FALSE; + } + sc[priv->bo_count].bo = bo; sc[priv->bo_count].read_domains = rd; sc[priv->bo_count].write_domain = wd; priv->bo_count++; + + return TRUE; } static boolean radeon_r300_validate(struct r300_winsys* winsys) -- cgit v1.2.3 From bc302b2a33ceffe454bcf443daa0ac1edc118e9b Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 22 May 2009 09:39:02 -0700 Subject: Use separate $(MINSTALL) for installing libraries The special feature of bin/minstall to copy symlinks is only ever needed when installing libraries which may have .so symlinks. All the headers and directories can use a normal install program. These two modes are separated as $(INSTALL) and $(MINSTALL) to allow the user (or autoconf) to override installing normal files as they please. An autoconf check for the install program has been added and will be used in preference to minstall when available. Fixes bug 16053. --- configs/autoconf.in | 1 + configs/default | 5 ++++- configure.ac | 5 +++++ src/egl/drivers/dri/Makefile | 2 +- src/egl/drivers/glx/Makefile | 2 +- src/egl/drivers/xdri/Makefile | 2 +- src/egl/main/Makefile | 2 +- src/gallium/winsys/drm/Makefile.template | 2 +- src/gallium/winsys/drm/intel/xorg/Makefile | 2 +- src/gallium/winsys/drm/radeon/xorg/Makefile | 2 +- src/gallium/winsys/egl_xlib/Makefile | 2 +- src/gallium/winsys/xlib/Makefile | 2 +- src/glu/Makefile | 2 +- src/glut/fbdev/Makefile | 2 +- src/glut/glx/Makefile | 2 +- src/glut/mini/Makefile | 2 +- src/glw/Makefile | 2 +- src/mesa/Makefile | 4 ++-- src/mesa/drivers/dri/Makefile.template | 2 +- 19 files changed, 27 insertions(+), 18 deletions(-) (limited to 'src/gallium/winsys/drm/radeon') diff --git a/configs/autoconf.in b/configs/autoconf.in index b61d7f33f0..77422e3fe5 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -31,6 +31,7 @@ SHELL = @SHELL@ MKLIB_OPTIONS = @MKLIB_OPTIONS@ MKDEP = @MKDEP@ MKDEP_OPTIONS = @MKDEP_OPTIONS@ +INSTALL = @INSTALL@ # Python and flags (generally only needed by the developers) PYTHON2 = python diff --git a/configs/default b/configs/default index d2ea3b2487..dc28be37dd 100644 --- a/configs/default +++ b/configs/default @@ -36,7 +36,10 @@ MKLIB_OPTIONS = MKDEP = makedepend MKDEP_OPTIONS = -fdepend MAKE = make -INSTALL = $(SHELL) $(TOP)/bin/minstall + +# Use MINSTALL for installing libraries, INSTALL for everything else +MINSTALL = $(SHELL) $(TOP)/bin/minstall +INSTALL = $(MINSTALL) # Tools for regenerating glapi (generally only needed by the developers) PYTHON2 = python diff --git a/configure.ac b/configure.ac index 24aa13a7ca..772fb29973 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,11 @@ AC_CHECK_PROGS([MAKE], [gmake make]) AC_PATH_PROG([MKDEP], [makedepend]) AC_PATH_PROG([SED], [sed]) +dnl Our fallback install-sh is a symlink to minstall. Use the existing +dnl configuration in that case. +AC_PROG_INSTALL +test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)' + dnl We need a POSIX shell for parts of the build. Assume we have one dnl in most cases. case "$host_os" in diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index 4041d5c906..567edfae97 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -50,7 +50,7 @@ $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR) clean: -rm -f *.o diff --git a/src/egl/drivers/glx/Makefile b/src/egl/drivers/glx/Makefile index 5f041a268f..20ef0352ad 100644 --- a/src/egl/drivers/glx/Makefile +++ b/src/egl/drivers/glx/Makefile @@ -58,7 +58,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) clean: rm -f *.o diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile index eb83867b71..8a14027fc7 100644 --- a/src/egl/drivers/xdri/Makefile +++ b/src/egl/drivers/xdri/Makefile @@ -54,7 +54,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) clean: rm -f *.o diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 8cfa25ca16..cddba9f088 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -66,7 +66,7 @@ $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS) install: default $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR) clean: -rm -f *.o *.so* diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 9f92cb4207..985e5a861f 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -118,7 +118,7 @@ clean: install: $(LIBNAME) $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) include depend diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile index b1b6b9362b..d9aa5d54e1 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/winsys/drm/intel/xorg/Makefile @@ -39,6 +39,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile index 6ffd4a3a54..0241625f69 100644 --- a/src/gallium/winsys/drm/radeon/xorg/Makefile +++ b/src/gallium/winsys/drm/radeon/xorg/Makefile @@ -37,6 +37,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 8646ee3b52..a33a50ec22 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -74,7 +74,7 @@ depend: $(ALL_SOURCES) install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) @if [ -e $(TOP)/$(LIB_DIR) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 04309e67ee..522f6dc5ae 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -90,7 +90,7 @@ install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/glu/Makefile b/src/glu/Makefile index 5c26ead1bb..b268265976 100644 --- a/src/glu/Makefile +++ b/src/glu/Makefile @@ -30,7 +30,7 @@ glu.pc: glu.pc.in install: glu.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig clean: diff --git a/src/glut/fbdev/Makefile b/src/glut/fbdev/Makefile index 199d8c390a..c150ea88dc 100644 --- a/src/glut/fbdev/Makefile +++ b/src/glut/fbdev/Makefile @@ -72,7 +72,7 @@ install: $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) # Run 'make -f Makefile.solo dep' to update the dependencies if you change # what's included by any source file. diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 1b072906c7..6889cd4b40 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -117,7 +117,7 @@ install: glut.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/glut/mini/Makefile b/src/glut/mini/Makefile index 0e42436133..b82a758d2c 100644 --- a/src/glut/mini/Makefile +++ b/src/glut/mini/Makefile @@ -91,7 +91,7 @@ install: glut.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/glw/Makefile b/src/glw/Makefile index d88d773313..1fb3d3c320 100644 --- a/src/glw/Makefile +++ b/src/glw/Makefile @@ -43,7 +43,7 @@ install: glw.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig clean: diff --git a/src/mesa/Makefile b/src/mesa/Makefile index bb18bee8ea..8300b30144 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -129,14 +129,14 @@ install-headers: install-libgl: default gl.pc install-headers $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig install-osmesa: default osmesa.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 5c01d233c1..bd38e3be47 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -92,7 +92,7 @@ clean: install: $(LIBNAME) $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) -include depend -- cgit v1.2.3