diff options
Diffstat (limited to 'src/gallium/state_trackers')
56 files changed, 3814 insertions, 1266 deletions
diff --git a/src/gallium/state_trackers/dri2/Makefile b/src/gallium/state_trackers/dri2/Makefile new file mode 100644 index 00000000000..47750e997e9 --- /dev/null +++ b/src/gallium/state_trackers/dri2/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/glx/dri/dri_context.c b/src/gallium/state_trackers/dri2/dri_context.c index 9424e18bee3..92c26ac70fe 100644 --- a/src/gallium/state_trackers/glx/dri/dri_context.c +++ b/src/gallium/state_trackers/dri2/dri_context.c @@ -18,22 +18,29 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ #include "dri_screen.h" -#include "dri_context.h" -#include "dri_winsys.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" @@ -59,33 +66,33 @@ dri_create_context(const __GLcontextModes *visual, ctx->cPriv = cPriv; ctx->sPriv = sPriv; - driParseConfigFiles(&ctx->optionCache, + driParseConfigFiles(&ctx->optionCache, &screen->optionCache, - sPriv->myNum, + sPriv->myNum, "dri"); - - ctx->pipe = screen->pipe_screen->create_context(screen->pipe_screen, - screen->pipe_winsys, - hw_winsys ); + + ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen); + if (ctx->pipe == NULL) goto fail; - ctx->pipe->priv = ctx; /* I guess */ + /* 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 ); + dri_init_extensions(ctx); return GL_TRUE; fail: if (ctx && ctx->st) - st_destroy_context( ctx->st ); + st_destroy_context(ctx->st); if (ctx && ctx->pipe) - ctx->pipe->destroy( ctx->pipe ); + ctx->pipe->destroy(ctx->pipe); FREE(ctx); return FALSE; @@ -97,14 +104,13 @@ dri_destroy_context(__DRIcontextPrivate *cPriv) { struct dri_context *ctx = dri_context(cPriv); struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); - struct pipe_winsys *winsys = screen->winsys; /* 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); + st_flush(ctx->st, 0, NULL); if (screen->dummyContext == ctx) screen->dummyContext = NULL; @@ -143,26 +149,22 @@ dri_make_current(__DRIcontextPrivate *cPriv, */ screen->dummyContext = ctx; - st_make_current( ctx->st, - draw->stfb, - read->stfb ); + st_make_current(ctx->st, + draw->stfb, + read->stfb); + /* used in dri_flush_frontbuffer */ ctx->dPriv = driDrawPriv; - /* Update window sizes if necessary: - */ - if (draw->stamp != driDrawPriv->lastStamp) { - dri_update_window_size( draw ); - } - - if (read->stamp != driReadPriv->lastStamp) { - dri_update_window_size( read ); - } - - } - else { + 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/glx/dri/dri_context.h b/src/gallium/state_trackers/dri2/dri_context.h index 4e6a305abb0..e910472700c 100644 --- a/src/gallium/state_trackers/glx/dri/dri_context.h +++ b/src/gallium/state_trackers/dri2/dri_context.h @@ -1,6 +1,7 @@ /************************************************************************** * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * 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 @@ -17,12 +18,16 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ #ifndef DRI_CONTEXT_H #define DRI_CONTEXT_H @@ -35,22 +40,21 @@ 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; - - boolean locked; - - /** - * Configuration cache - */ - driOptionCache optionCache; }; @@ -60,13 +64,14 @@ dri_context(__DRIcontextPrivate *driContextPriv) return (struct dri_context *) driContextPriv->driverPrivate; } + /*********************************************************************** * dri_context.c */ -void +void dri_destroy_context(__DRIcontextPrivate * driContextPriv); -boolean +boolean dri_unbind_context(__DRIcontextPrivate * driContextPriv); boolean @@ -80,16 +85,12 @@ dri_create_context(const __GLcontextModes * visual, void *sharedContextPrivate); - /*********************************************************************** - * dri_lock.c + * dri_extensions.c */ -void dri_lock_hardware( struct dri_context *context, - struct dri_drawable *drawable ); - -void dri_unlock_hardware( struct dri_context *dri ); -boolean dri_is_locked( struct dri_context *dri ); - - +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 new file mode 100644 index 00000000000..2e3f4099e2a --- /dev/null +++ b/src/gallium/state_trackers/dri2/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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ + +#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/glx/dri/dri_drawable.h b/src/gallium/state_trackers/dri2/dri_drawable.h index 1001bb8c578..185c657b35a 100644 --- a/src/gallium/state_trackers/glx/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri2/dri_drawable.h @@ -18,7 +18,7 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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. @@ -37,12 +37,14 @@ struct st_framebuffer; struct dri_drawable { + /* dri */ __DRIdrawablePrivate *dPriv; - unsigned stamp; + __DRIscreenPrivate *sPriv; - struct pipe_fence *last_swap_fence; - struct pipe_fence *first_swap_fence; + unsigned attachments[8]; + unsigned num_attachments; + /* gallium */ struct st_framebuffer *stfb; }; @@ -57,17 +59,31 @@ dri_drawable(__DRIdrawablePrivate * driDrawPriv) /*********************************************************************** * dri_drawable.c */ - -void +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 +void dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, - int x, int y, + int x, int y, int w, int h); -void -dri_update_window_size(__DRIdrawablePrivate *dPriv); +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/glx/dri/dri_extensions.c b/src/gallium/state_trackers/dri2/dri_extensions.c index 126faf76014..732d1e89b0c 100644 --- a/src/gallium/state_trackers/glx/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri2/dri_extensions.c @@ -18,17 +18,23 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ - - +#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 @@ -53,6 +59,7 @@ 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}, @@ -96,13 +103,17 @@ const struct dri_extension card_extensions[] = { }; - -void -dri_init_extensions( void ) +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 + * capabilities of the pipe_screen. This is actually something * that can/should be done inside st_create_context(). */ - driInitExtensions( ctx->st->ctx, card_extensions, GL_TRUE ); + 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/glx/dri/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c index f7119b949a3..ab5878a4bce 100644 --- a/src/gallium/state_trackers/glx/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri2/dri_screen.c @@ -18,23 +18,29 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ #include "utils.h" #include "vblank.h" #include "xmlpool.h" -#include "dri_context.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" @@ -44,19 +50,15 @@ PUBLIC const char __driConfigOptions[] = 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_FORCE_S3TC_ENABLE(false)*/ DRI_CONF_ALLOW_LARGE_TEXTURES(1) DRI_CONF_SECTION_END DRI_CONF_END; -const uint __driNConfigOptions = 3; - -static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; - -extern const struct dri_extension card_extensions[]; +const uint __driNConfigOptions = 3; -static const __DRIextension *driScreenExtensions[] = { +static const __DRIextension *dri_screen_extensions[] = { &driReadDrawableExtension, &driCopySubBufferExtension.base, &driSwapControlExtension.base, @@ -66,46 +68,40 @@ static const __DRIextension *driScreenExtensions[] = { }; - - -static const char * -dri_get_name( struct pipe_winsys *winsys ) +static void +dri_get_drm_minor(struct dri_screen *screen) { - return "dri"; + /* TODO get the real minor */ + screen->minor = 0; } - static void -dri_destroy_screen(__DRIscreenPrivate * sPriv) +dri_get_device_id(struct dri_screen *screen) { - struct dri_screen *screen = dri_screen(sPriv); - - screen->pipe_screen->destroy( screen->pipe_screen ); - screen->pipe_winsys->destroy( screen->pipe_winsys ); - FREE(screen); - sPriv->private = NULL; -} + 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; + } -/** - * Get information about previous buffer swaps. - */ -static int -dri_get_swap_info(__DRIdrawablePrivate * dPriv, - __DRIswapInfo * sInfo) -{ - if (dPriv == NULL || - dPriv->driverPrivate == NULL || - sInfo == NULL) - return -1; - else - return 0; + 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 pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer) { __DRIconfig **configs; __GLcontextModes *m; @@ -115,17 +111,19 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, 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_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] = depth_bits; - depth_bits_array[2] = depth_bits; + 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 */ @@ -134,9 +132,10 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, msaa_samples_array[0] = 0; depth_buffer_factor = 3; - back_buffer_factor = 1; + back_buffer_factor = 3; + msaa_samples_factor = 1; - num_modes = depth_buffer_factor * back_buffer_factor * 4; + num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; if (pixel_bits == 16) { fb_format = GL_RGB; @@ -148,85 +147,92 @@ dri_fill_in_modes(__DRIscreenPrivate *psp, } configs = driCreateConfigs(fb_format, fb_type, - depth_bits_array, - stencil_bits_array, depth_buffer_factor, + depth_bits_array, + stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1); + msaa_samples_array, msaa_samples_factor); if (configs == NULL) { debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__); return NULL; } - return configs; + 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; +} -/* This is the driver specific part of the createNewScreen entry point. - * - * Returns the __GLcontextModes supported by this driver. + +/** + * NULL stub for old dri loaders */ -static const __DRIconfig **dri_init_screen(__DRIscreenPrivate *sPriv) +const __DRIconfig ** +dri_init_screen(__DRIscreenPrivate *sPriv) { - static const __DRIversion ddx_expected = { 1, 6, 0 }; /* hw query */ - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 5, 0 }; /* hw query */ - struct dri_screen *screen; + return NULL; +} - if (!driCheckDriDdxDrmVersions2("dri", - &sPriv->dri_version, &dri_expected, - &sPriv->ddx_version, &ddx_expected, - &sPriv->drm_version, &drm_expected)) { - return NULL; - } - /* Set up dispatch table to cope with all known extensions: - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); +/** + * 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; + dri_get_drm_minor(screen); + dri_get_device_id(screen); sPriv->private = (void *) screen; + sPriv->extensions = dri_screen_extensions; - /* Search the registered winsys' for one that likes this sPriv. - * This is required in situations where multiple devices speak to - * the same DDX and are built into the same binary. - * - * Note that cases like Intel i915 vs i965 doesn't fall into this - * category because they are built into separate binaries. - * - * Nonetheless, it's healthy to keep that level of detail out of - * this state_tracker. - */ - for (i = 0; - i < dri1_winsys_count && - screen->st_winsys == NULL; - i++) - { - screen->dri_winsys = - dri_winsys[i]->check_dri_privates( sPriv->pDevPriv, - sPriv->pSAREA - /* versions, etc?? */)); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID); + 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, + __driConfigOptions, __driNConfigOptions); - - /* Plug our info back into the __DRIscreenPrivate: - */ - sPriv->private = (void *) screen; - sPriv->extensions = driScreenExtensions; - - return dri_fill_in_modes(sPriv, - dri_priv->cpp * 8, + return dri_fill_in_modes(sPriv, + 4 * 8, 24, 8, 1); @@ -235,21 +241,32 @@ fail: } +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; +} -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = dri_init_screen, - .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, - .DestroyContext = dri_destroy_context, - .CreateBuffer = dri_create_buffer, - .DestroyBuffer = dri_destroy_buffer, - .SwapBuffers = dri_swap_buffers, - .MakeCurrent = dri_make_current, - .UnbindContext = dri_unbind_context, - .GetSwapInfo = dri_get_swap_info, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .CopySubBuffer = dri_copy_sub_buffer, - //.InitScreen2 = dri_init_screen2, +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/glx/dri/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h index 12ed86d22a9..fe2676d0be3 100644 --- a/src/gallium/state_trackers/glx/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri2/dri_screen.h @@ -18,12 +18,16 @@ * 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * 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 <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + */ #ifndef DRI_SCREEN_H #define DRI_SCREEN_H @@ -35,27 +39,8 @@ struct dri_screen { - __DRIScreenPrivate *sPriv; - struct pipe_winsys *pipe_winsys; - struct pipe_screen *pipe_screen; - - struct { - /* Need a pipe_surface pointer to do client-side swapbuffers: - */ - unsigned long buffer_handle; - struct pipe_surface *surface; - struct pipe_texture *texture; - - int pitch; /* row stride, in bytes */ - int width; - int height; - int size; - int cpp; /* for front and back buffers */ - } front; - - int deviceID; - int drmMinor; - + /* dri */ + __DRIscreenPrivate *sPriv; /** * Configuration cache with default values for all contexts @@ -67,8 +52,16 @@ struct dri_screen * which we need a rendering context, but none is currently bound. */ struct dri_context *dummyContext; -}; + /* drm */ + int deviceID; + int fd; + int minor; + + /* gallium */ + struct pipe_winsys *pipe_winsys; + struct pipe_screen *pipe_screen; +}; /** cast wrapper */ @@ -79,5 +72,19 @@ dri_screen(__DRIscreenPrivate *sPriv) } +/*********************************************************************** + * 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/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index c9124b1c90e..692a3c8b76f 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -6,15 +6,15 @@ TOP = ../../../.. include ${TOP}/configs/current -CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \ +CFLAGS := \ -I${GALLIUMDIR}/include \ -I${GALLIUMDIR}/auxiliary \ -I${TOP}/src/mesa/drivers/dri/common \ -I${TOP}/src/mesa \ -I$(TOP)/include \ -I$(TOP)/src/egl/main \ - $(shell pkg-config --cflags pixman-1 xorg-server) \ - ${LIBDRM_CFLAGS} + ${LIBDRM_CFLAGS} \ + ${CFLAGS} ############################################# diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index 8564972b91e..36548fae263 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -115,7 +115,7 @@ drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext _eglInitContext(drv, dpy, &ctx->base, config, attrib_list); - ctx->pipe = drm_api_hocks.create_context(dev->screen); + ctx->pipe = drm_api_hooks.create_context(dev->screen); if (!ctx->pipe) goto err_pipe; diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index 091d437d81b..e6e80b985aa 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -16,11 +16,11 @@ * Util functions */ -static struct drm_mode_modeinfo * +static drmModeModeInfoPtr drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode) { int i; - struct drm_mode_modeinfo *m = NULL; + drmModeModeInfoPtr m = NULL; for (i = 0; i < connector->count_modes; i++) { m = &connector->modes[i]; @@ -132,7 +132,7 @@ drm_create_texture(_EGLDriver *drv, scrn->front.width = w; scrn->front.height = h; scrn->front.pitch = pitch; - scrn->front.handle = drm_api_hocks.handle_from_buffer(dev->winsys, scrn->buffer); + drm_api_hooks.handle_from_buffer(screen, scrn->buffer, &scrn->front.handle); if (0) goto err_handle; @@ -143,7 +143,7 @@ err_handle: err_surf: pipe_texture_reference(&texture, NULL); err_tex: - pipe_buffer_reference(screen, &buf, NULL); + pipe_buffer_reference(&buf, NULL); err_buf: return; } @@ -173,7 +173,7 @@ drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen) pipe_surface_reference(&screen->surface, NULL); pipe_texture_reference(&screen->tex, NULL); - pipe_buffer_reference(dev->screen, &screen->buffer, NULL); + pipe_buffer_reference(&screen->buffer, NULL); screen->shown = 0; } @@ -271,7 +271,6 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, struct drm_device *dev = (struct drm_device *)drv; struct drm_surface *surf = lookup_drm_surface(surface); struct drm_screen *scrn = lookup_drm_screen(dpy, screen); - struct pipe_context *pipe; _EGLMode *mode = _eglLookupMode(dpy, m); int ret; unsigned int i, k; @@ -349,7 +348,7 @@ err_fb: err_bo: pipe_surface_reference(&scrn->surface, NULL); pipe_texture_reference(&scrn->tex, NULL); - pipe_buffer_reference(dev->screen, &scrn->buffer, NULL); + pipe_buffer_reference(&scrn->buffer, NULL); return EGL_FALSE; } @@ -392,7 +391,6 @@ drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) if (surf->screen) { surf->user->pipe->flush(surf->user->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL); surf->user->pipe->surface_copy(surf->user->pipe, - 0, surf->screen->surface, 0, 0, back_surf, diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index dec82c3a002..a22ef381b96 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -92,7 +92,7 @@ drm_update_res(struct drm_device *dev) static void drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector) { - struct drm_mode_modeinfo *m; + drmModeModeInfoPtr m = NULL; int i; for (i = 0; i < connector->count_modes; i++) { @@ -121,7 +121,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) dev->drmFD = fd; drm_get_device_id(dev); - dev->screen = drm_api_hocks.create_screen(dev->drmFD, dev->deviceID); + dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID); if (!dev->screen) goto err_screen; dev->winsys = dev->screen->winsys; diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h index 0b4dd9797d5..908bab5f9bf 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ b/src/gallium/state_trackers/egl/egl_tracker.h @@ -128,7 +128,7 @@ struct drm_screen /*drmModeCrtcPtr crtc;*/ uint32_t crtcID; - struct drm_mode_modeinfo *mode; + drmModeModeInfoPtr mode; }; diff --git a/src/gallium/state_trackers/g3dvl/Makefile b/src/gallium/state_trackers/g3dvl/Makefile index cddfca54fe5..f9f4d6be3c3 100644 --- a/src/gallium/state_trackers/g3dvl/Makefile +++ b/src/gallium/state_trackers/g3dvl/Makefile @@ -3,7 +3,7 @@ OBJECTS = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_shader_build.o vl_r16snorm_mc_buf.o GALLIUMDIR = ../.. -CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \ +CFLAGS += -g -Wall -Werror-implicit-function-declaration -fPIC \ -I${GALLIUMDIR}/include \ -I${GALLIUMDIR}/auxiliary \ -I${GALLIUMDIR}/winsys/g3dvl \ diff --git a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c index 187a13a5605..b61b49a2f8a 100644 --- a/src/gallium/state_trackers/g3dvl/vl_basic_csc.c +++ b/src/gallium/state_trackers/g3dvl/vl_basic_csc.c @@ -237,10 +237,10 @@ static int vlDestroy pipe->delete_fs_state(pipe, basic_csc->fragment_shader); for (i = 0; i < 2; ++i) - pipe_buffer_reference(pipe->screen, &basic_csc->vertex_bufs[i].buffer, NULL); + pipe_buffer_reference(&basic_csc->vertex_bufs[i].buffer, NULL); - pipe_buffer_reference(pipe->screen, &basic_csc->vs_const_buf.buffer, NULL); - pipe_buffer_reference(pipe->screen, &basic_csc->fs_const_buf.buffer, NULL); + pipe_buffer_reference(&basic_csc->vs_const_buf.buffer, NULL); + pipe_buffer_reference(&basic_csc->fs_const_buf.buffer, NULL); FREE(basic_csc); @@ -371,7 +371,7 @@ static int vlCreateVertexShader unsigned int ti; unsigned int i; - assert(context); + assert(csc); pipe = csc->pipe; tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token)); @@ -458,7 +458,7 @@ static int vlCreateFragmentShader unsigned int ti; unsigned int i; - assert(context); + assert(csc); pipe = csc->pipe; tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token)); diff --git a/src/gallium/state_trackers/g3dvl/vl_context.c b/src/gallium/state_trackers/g3dvl/vl_context.c index 65ddb9f01ef..1d8ad0b0469 100644 --- a/src/gallium/state_trackers/g3dvl/vl_context.c +++ b/src/gallium/state_trackers/g3dvl/vl_context.c @@ -41,9 +41,7 @@ static int vlInitCommon(struct vlContext *context) rast.line_stipple_factor = 0; rast.line_stipple_pattern = 0; rast.line_last_pixel = 0; - /* Don't need clipping, but viewport mapping done here */ - rast.bypass_clipping = 0; - rast.bypass_vs = 0; + rast.bypass_vs_clip_and_viewport = 0; rast.origin_lower_left = 0; rast.line_width = 1; rast.point_smooth = 0; diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c index 2176bb86d8a..eb8270ecad3 100644 --- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c +++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c @@ -66,7 +66,7 @@ struct vlR16SnormBufferedMC struct vlVertex2f zero_block[3]; unsigned int num_macroblocks; struct vlMpeg2MacroBlock *macroblocks; - struct pipe_surface *tex_surface[3]; + struct pipe_transfer *tex_transfer[3]; short *texels[3]; struct pipe_context *pipe; @@ -187,7 +187,7 @@ static inline int vlGrabBlocks assert(mc); assert(blocks); - tex_pitch = mc->tex_surface[0]->stride / mc->tex_surface[0]->block.size; + tex_pitch = mc->tex_transfer[0]->stride / mc->tex_transfer[0]->block.size; texels = mc->texels[0] + mbpy * tex_pitch + mbpx; for (y = 0; y < 2; ++y) @@ -235,7 +235,7 @@ static inline int vlGrabBlocks for (tb = 0; tb < 2; ++tb) { - tex_pitch = mc->tex_surface[tb + 1]->stride / mc->tex_surface[tb + 1]->block.size; + tex_pitch = mc->tex_transfer[tb + 1]->stride / mc->tex_transfer[tb + 1]->block.size; texels = mc->texels[tb + 1] + mbpy * tex_pitch + mbpx; if ((coded_block_pattern >> (1 - tb)) & 1) @@ -635,8 +635,8 @@ static int vlFlush for (i = 0; i < 3; ++i) { - pipe_surface_unmap(mc->tex_surface[i]); - pipe_surface_reference(&mc->tex_surface[i], NULL); + pipe->screen->transfer_unmap(pipe->screen, mc->tex_transfer[i]); + pipe->screen->tex_transfer_destroy(mc->tex_transfer[i]); } mc->render_target.cbufs[0] = pipe->screen->get_tex_surface @@ -809,14 +809,16 @@ static int vlRenderMacroBlocksMpeg2R16SnormBuffered for (i = 0; i < 3; ++i) { - mc->tex_surface[i] = mc->pipe->screen->get_tex_surface + mc->tex_transfer[i] = mc->pipe->screen->get_tex_transfer ( mc->pipe->screen, mc->textures.all[i], - 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD + 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, + surface->texture->width[0], + surface->texture->height[0] ); - mc->texels[i] = pipe_surface_map(mc->tex_surface[i], PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD); + mc->texels[i] = mc->pipe->screen->transfer_map(mc->pipe->screen, mc->tex_transfer[i]); } } @@ -854,7 +856,7 @@ static int vlDestroy pipe->delete_sampler_state(pipe, mc->samplers.all[i]); for (i = 0; i < 3; ++i) - pipe_buffer_reference(pipe->screen, &mc->vertex_bufs.all[i].buffer, NULL); + pipe_buffer_reference(&mc->vertex_bufs.all[i].buffer, NULL); /* Textures 3 & 4 are not created directly, no need to release them here */ for (i = 0; i < 3; ++i) @@ -871,8 +873,8 @@ static int vlDestroy pipe->delete_fs_state(pipe, mc->b_fs[i]); } - pipe_buffer_reference(pipe->screen, &mc->vs_const_buf.buffer, NULL); - pipe_buffer_reference(pipe->screen, &mc->fs_const_buf.buffer, NULL); + pipe_buffer_reference(&mc->vs_const_buf.buffer, NULL); + pipe_buffer_reference(&mc->fs_const_buf.buffer, NULL); FREE(mc->macroblocks); FREE(mc); diff --git a/src/gallium/state_trackers/glx/dri/dri_drawable.c b/src/gallium/state_trackers/glx/dri/dri_drawable.c deleted file mode 100644 index b712acda88e..00000000000 --- a/src/gallium/state_trackers/glx/dri/dri_drawable.c +++ /dev/null @@ -1,363 +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 TUNGSTEN GRAPHICS 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. - * - **************************************************************************/ - -#include "dri_screen.h" -#include "dri_context.h" -#include "dri_swapbuffers.h" - -#include "pipe/p_context.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_cb_fbo.h" - - -static void -blit_swapbuffers(__DRIdrawablePrivate *dPriv, - __DRIcontextPrivate *cPriv, - struct pipe_surface *src, - const drm_clip_rect_t *rect) -{ - struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); - struct dri_drawable *fb = dri_drawable(dPriv); - struct dri_context *context = dri_context(cPriv); - - const int nbox = dPriv->numClipRects; - const drm_clip_rect_t *pbox = dPriv->pClipRects; - - struct pipe_surface *dest = fb->front_surface; - const int backWidth = fb->stfb->Base.Width; - const int backHeight = fb->stfb->Base.Height; - int i; - - for (i = 0; i < nbox; i++, pbox++) { - drm_clip_rect_t box; - drm_clip_rect_t sbox; - - if (pbox->x1 > pbox->x2 || - pbox->y1 > pbox->y2 || - (pbox->x2 - pbox->x1) > dest->width || - (pbox->y2 - pbox->y1) > dest->height) - continue; - - box = *pbox; - - if (rect) { - drm_clip_rect_t rrect; - - rrect.x1 = dPriv->x + rect->x1; - rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y; - rrect.x2 = rect->x2 + rrect.x1; - rrect.y2 = rect->y2 + rrect.y1; - if (rrect.x1 > box.x1) - box.x1 = rrect.x1; - if (rrect.y1 > box.y1) - box.y1 = rrect.y1; - if (rrect.x2 < box.x2) - box.x2 = rrect.x2; - if (rrect.y2 < box.y2) - box.y2 = rrect.y2; - - if (box.x1 > box.x2 || box.y1 > box.y2) - continue; - } - - /* restrict blit to size of actually rendered area */ - if (box.x2 - box.x1 > backWidth) - box.x2 = backWidth + box.x1; - if (box.y2 - box.y1 > backHeight) - box.y2 = backHeight + box.y1; - - debug_printf("%s: box %d,%d-%d,%d\n", __FUNCTION__, - box.x1, box.y1, box.x2, box.y2); - - sbox.x1 = box.x1 - dPriv->x; - sbox.y1 = box.y1 - dPriv->y; - - ctx->st->pipe->surface_copy( ctx->st->pipe, - FALSE, - dest, - box.x1, box.y1, - src, - sbox.x1, sbox.y1, - box.x2 - box.x1, - box.y2 - box.y1 ); - } -} - -/** - * Display a colorbuffer surface in an X window. - * Used for SwapBuffers and flushing front buffer rendering. - * - * \param dPriv the window/drawable to display into - * \param surf the surface to display - * \param rect optional subrect of surface to display (may be NULL). - */ -static void -dri_display_surface(__DRIdrawablePrivate *dPriv, - struct pipe_surface *source, - const drm_clip_rect_t *rect) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); - struct dri_context *context = screen->dummy_context; - struct pipe_winsys *winsys = screen->winsys; - - if (!context) - return; - - if (drawable->last_swap_fence) { - winsys->fence_finish( winsys, - drawable->last_swap_fence, - 0 ); - - winsys->fence_reference( winsys, - &drawable->last_swap_fence, - NULL ); - } - - drawable->last_swap_fence = drawable->first_swap_fence; - drawable->first_swap_fence = NULL; - - /* Call lock_hardware to update dPriv cliprects. - */ - dri_lock_hardware(context, drawable); - { - if (dPriv->numClipRects) { - blit_swapbuffers( context, dPriv, source, rect ); - } - } - dri_unlock_hardware(context); - - if (drawble->stamp != drawable->dPriv->lastStamp) { - dri_update_window_size( dpriv ); - } -} - - - -/** - * This will be called a drawable is known to have moved/resized. - */ -void -dri_update_window_size(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - st_resize_framebuffer(drawable->stfb, dPriv->w, dPriv->h); - drawable->stamp = dPriv->lastStamp; -} - - - -void -dri_swap_buffers(__DRIdrawablePrivate * dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *back_surf; - - assert(drawable); - assert(drawable->stfb); - - back_surf = st_get_framebuffer_surface(drawable->stfb, - ST_SURFACE_BACK_LEFT); - if (back_surf) { - st_notify_swapbuffers(drawable->stfb); - dri_display_surface(dPriv, back_surf, NULL); - st_notify_swapbuffers_complete(drawable->stfb); - } -} - - -/** - * Called via glXCopySubBufferMESA() to copy a subrect of the back - * buffer to the front buffer/screen. - */ -void -dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_surface *back_surf; - - assert(drawable); - assert(drawable->stfb); - - back_surf = st_get_framebuffer_surface(drawable->stfb, - ST_SURFACE_BACK_LEFT); - if (back_surf) { - drm_clip_rect_t rect; - rect.x1 = x; - rect.y1 = y; - rect.x2 = w; - rect.y2 = h; - - st_notify_swapbuffers(drawable->stfb); - dri_display_surface(dPriv, back_surf, &rect); - } -} - - - -/* - * The state tracker keeps track of whether the fake frontbuffer has - * been touched by any rendering since the last time we copied its - * contents to the real frontbuffer. Our task is easy: - */ -static void -dri_flush_frontbuffer( struct pipe_winsys *winsys, - struct pipe_surface *surf, - void *context_private) -{ - struct dri_context *dri = (struct dri_context *) context_private; - __DRIdrawablePrivate *dPriv = dri->driDrawable; - - dri_display_surface(dPriv, surf, NULL); -} - - - -/* Need to create a surface which wraps the front surface to support - * client-side swapbuffers. - */ -static void -dri_create_front_surface(struct dri_screen *screen, - struct pipe_winsys *winsys, - unsigned handle) -{ - struct pipe_screen *pipe_screen = screen->pipe_screen; - struct pipe_texture *texture; - struct pipe_texture templat; - struct pipe_surface *surface; - struct pipe_buffer *buffer; - unsigned pitch; - - assert(screen->front.cpp == 4); - -// buffer = dri_buffer_from_handle(screen->winsys, -// "front", handle); - - if (!buffer) - return; - - screen->front.buffer = dri_bo(buffer); - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth[0] = 1; - templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; - templat.width[0] = screen->front.width; - templat.height[0] = screen->front.height; - pf_get_block(templat.format, &templat.block); - pitch = screen->front.pitch; - - texture = pipe_screen->texture_blanket(pipe_screen, - &templat, - &pitch, - buffer); - - /* Unref the buffer we don't need it anyways */ - pipe_buffer_reference(screen, &buffer, NULL); - - surface = pipe_screen->get_tex_surface(pipe_screen, - texture, - 0, - 0, - 0, - PIPE_BUFFER_USAGE_GPU_WRITE); - - screen->front.texture = texture; - screen->front.surface = surface; -} - -/** - * This is called when we need to set up GL rendering to a new X window. - */ -static boolean -dri_create_buffer(__DRIscreenPrivate *sPriv, - __DRIdrawablePrivate *dPriv, - const __GLcontextModes *visual, - boolean isPixmap) -{ - enum pipe_format colorFormat, depthFormat, stencilFormat; - struct dri_drawable *drawable; - - 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. - */ - if (visual->redBits == 5) - colorFormat = PIPE_FORMAT_R5G6B5_UNORM; - else - colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; - - if (visual->depthBits == 16) - depthFormat = PIPE_FORMAT_Z16_UNORM; - else if (visual->depthBits == 24) { - if (visual->stencilBits == 8) - depthFormat = PIPE_FORMAT_S8Z24_UNORM; - else - depthFormat = PIPE_FORMAT_X8Z24_UNORM; - } - - drawable->stfb = st_create_framebuffer(visual, - colorFormat, - depthFormat, - dPriv->w, - dPriv->h, - (void*) drawable); - if (drawable->stfb == NULL) - goto fail; - - dPriv->driverPrivate = (void *) drawable; - return GL_TRUE; - -fail: - FREE(drawable); - return GL_FALSE; -} - -static void -dri_destroy_buffer(__DRIdrawablePrivate *dPriv) -{ - struct dri_drawable *drawable = dri_drawable(dPriv); - - /* No particular need to wait on fences before dereferencing them: - */ - winsys->fence_reference( winsys, &ctx->last_swap_fence, NULL ); - winsys->fence_reference( winsys, &ctx->first_swap_fence, NULL ); - - st_unreference_framebuffer(drawable->stfb); - - FREE(drawable); -} - diff --git a/src/gallium/state_trackers/glx/dri/dri_lock.c b/src/gallium/state_trackers/glx/dri/dri_lock.c deleted file mode 100644 index b272ab55f34..00000000000 --- a/src/gallium/state_trackers/glx/dri/dri_lock.c +++ /dev/null @@ -1,90 +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 TUNGSTEN GRAPHICS 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. - * - **************************************************************************/ - - -#include "pipe/p_thread.h" -#include "dri_context.h" -#include "xf86drm.h" - -pipe_static_mutex( lockMutex ); - -static void -dri_contended_lock(struct dri_context *ctx) -{ - __DRIdrawablePrivate *dPriv = ctx->dPriv; - __DRIcontextPrivate *cPriv = ctx->cPriv; - __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; - - drmGetLock(sPriv->fd, cPriv->hHWContext, 0); - - /* Perform round trip communication with server (including dropping - * and retaking the above lock) to update window dimensions: - */ - if (dPriv) - DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv); -} - - -/* Lock the hardware and validate our state. - */ -void dri_lock_hardware( struct dri_context *ctx ) -{ - __DRIcontextPrivate *cPriv = ctx->cPriv; - __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; - char __ret = 0; - - pipe_mutex_lock(lockMutex); - assert(!ctx->locked); - - DRM_CAS((drmLock *) &sPriv->pSAREA->lock, - cPriv->hHWContext, - (DRM_LOCK_HELD | cPriv->hHWContext), - __ret); - - if (__ret) - dri_contended_lock( ctx ); - - ctx->locked = TRUE; -} - - -/* Unlock the hardware using the global current context - */ -void dri_unlock_hardware( struct dri_context *ctx ) -{ - __DRIcontextPrivate *cPriv = ctx->cPriv; - __DRIscreenPrivate *sPriv = cPriv->driScreenPriv; - - assert(ctx->locked); - ctx->locked = FALSE; - - DRM_UNLOCK(sPriv->fd, - (drmLock *) &sPriv->pSAREA->lock, - cPriv->hHWContext); - - pipe_mutex_unlock(lockMutex); -} diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile index 1b63db1f0ea..6d10b090aa0 100644 --- a/src/gallium/state_trackers/glx/xlib/Makefile +++ b/src/gallium/state_trackers/glx/xlib/Makefile @@ -3,23 +3,15 @@ include $(TOP)/configs/current LIBNAME = xlib - -DRIVER_INCLUDES = \ +LIBRARY_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/auxiliary + -I$(TOP)/src/mesa/main C_SOURCES = \ - glxapi.c \ - fakeglx.c \ - fakeglx_fonts.c \ + glxapi.c \ + fakeglx.c \ + fakeglx_fonts.c \ xm_api.c - include ../../../Makefile.template - -symlinks: - diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index 14cdad69cbe..0dbe3413972 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -5,8 +5,7 @@ Import('*') if env['platform'] == 'linux' \ and 'mesa' in env['statetrackers'] \ - and ('softpipe' or 'i915simple' or 'trace') in env['drivers'] \ - and not env['dri']: + and ('softpipe' or 'i915simple' or 'trace') in env['drivers']: env = env.Clone() @@ -15,6 +14,8 @@ if env['platform'] == 'linux' \ '#/src/mesa/main', ]) + env.Append(CPPDEFINES = ['USE_XSHM']) + st_xlib = env.ConvenienceLibrary( target = 'st_xlib', source = [ 'glxapi.c', diff --git a/src/gallium/state_trackers/glx/xlib/glxapi.c b/src/gallium/state_trackers/glx/xlib/glxapi.c index 1ff04804f15..c2cb34d7cf7 100644 --- a/src/gallium/state_trackers/glx/xlib/glxapi.c +++ b/src/gallium/state_trackers/glx/xlib/glxapi.c @@ -34,13 +34,21 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include "main/glheader.h" #include "glapi/glapi.h" #include "glxapi.h" #include "fakeglx.h" #include "pipe/p_thread.h" +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +#else +# define PUBLIC +# define USED +#endif + + struct display_dispatch { Display *Dpy; struct _glxapi_table *Table; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 33dc044ad55..a3d16516531 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -458,7 +458,7 @@ xmesa_free_buffer(XMesaBuffer buffer) XDestroyImage(buffer->tempImage); /* Unreference. If count = zero we'll really delete the buffer */ - _mesa_unreference_framebuffer(&fb); + _mesa_reference_framebuffer(&fb, NULL); XFreeGC(b->xm_visual->display, b->gc); @@ -763,7 +763,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) c->xm_visual = v; c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */ - + c->xm_read_buffer = NULL; + /* XXX: create once per Xlib Display. */ screen = driver.create_pipe_screen(); @@ -1037,27 +1038,25 @@ PUBLIC GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, XMesaBuffer readBuffer ) { + XMesaContext old_ctx = XMesaGetCurrentContext(); + + if (old_ctx && old_ctx != c) { + XMesaFlush(old_ctx); + old_ctx->xm_buffer = NULL; + old_ctx->xm_read_buffer = NULL; + } + if (c) { if (!drawBuffer || !readBuffer) return GL_FALSE; /* must specify buffers! */ -#if 0 - /* XXX restore this optimization */ - if (&(c->mesa) == _mesa_get_current_context() - && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer - && c->mesa.ReadBuffer == &readBuffer->mesa_buffer - && xmesa_buffer(c->mesa.DrawBuffer)->wasCurrent) { - /* same context and buffer, do nothing */ - return GL_TRUE; - } -#endif + if (c == old_ctx && + c->xm_buffer == drawBuffer && + c->xm_read_buffer == readBuffer) + return GL_TRUE; c->xm_buffer = drawBuffer; - - /* Call this periodically to detect when the user has begun using - * GL rendering from multiple threads. - */ - _glapi_check_multithread(); + c->xm_read_buffer = readBuffer; st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb); @@ -1071,6 +1070,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, else { /* Detach */ st_make_current( NULL, NULL, NULL ); + } return GL_TRUE; } @@ -1143,7 +1143,6 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) return; pipe->surface_copy(pipe, - FALSE, surf_front, x, y, /* dest */ surf_back, x, y, /* src */ width, height); diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 2b8302d1747..bdd434cd364 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -295,6 +295,7 @@ struct xmesa_context { struct st_context *st; XMesaVisual xm_visual; /** pixel format info */ XMesaBuffer xm_buffer; /** current drawbuffer */ + XMesaBuffer xm_read_buffer; /** current readbuffer */ }; diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i index f4c4b36ea7d..79e68de1df8 100644 --- a/src/gallium/state_trackers/python/gallium.i +++ b/src/gallium/state_trackers/python/gallium.i @@ -42,13 +42,15 @@ #include "pipe/p_screen.h" #include "pipe/p_context.h" #include "pipe/p_inlines.h" -#include "util/u_memory.h" -#include "pipe/p_shader_tokens.h" +#include "pipe/p_shader_tokens.h" +#include "pipe/internal/p_winsys_screen.h" #include "cso_cache/cso_context.h" -#include "util/u_draw_quad.h" -#include "util/u_tile.h" -#include "tgsi/tgsi_text.h" -#include "tgsi/tgsi_dump.h" +#include "util/u_draw_quad.h" +#include "util/u_tile.h" +#include "util/u_math.h" +#include "util/u_memory.h" +#include "tgsi/tgsi_text.h" +#include "tgsi/tgsi_dump.h" #include "st_device.h" #include "st_sample.h" @@ -93,7 +95,7 @@ %include "p_compiler.i" -%include "pipe/p_defines.h"; +%include "p_defines.h"; %include "p_format.i" %include "p_device.i" diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 7b8b64b5923..1fdbdf98b26 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -121,7 +121,6 @@ struct st_context { struct pipe_constant_buffer state; memset(&state, 0, sizeof(state)); state.buffer = buffer ? buffer->buffer : NULL; - state.size = buffer->buffer->size; $self->pipe->set_constant_buffer($self->pipe, shader, index, &state); } @@ -161,7 +160,7 @@ struct st_context { struct pipe_vertex_buffer state; memset(&state, 0, sizeof(state)); - state.pitch = pitch; + state.stride = pitch; state.max_index = max_index; state.buffer_offset = buffer_offset; state.buffer = buffer ? buffer->buffer : NULL; @@ -248,7 +247,7 @@ struct st_context { util_draw_vertex_buffer(pipe, vbuf, 0, prim, num_verts, num_attribs); error2: - pipe_buffer_reference(screen, &vbuf, NULL); + pipe_buffer_reference(&vbuf, NULL); error1: ; } @@ -266,13 +265,12 @@ error1: * Surface functions */ - void surface_copy(int do_flip, - struct pipe_surface *dest, + void surface_copy(struct pipe_surface *dest, unsigned destx, unsigned desty, struct pipe_surface *src, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - $self->pipe->surface_copy($self->pipe, do_flip, dest, destx, desty, src, srcx, srcy, width, height); + $self->pipe->surface_copy($self->pipe, dest, destx, desty, src, srcx, srcy, width, height); } void surface_fill(struct pipe_surface *dst, diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i index 7f5760b3b66..110b3d5da43 100644 --- a/src/gallium/state_trackers/python/p_state.i +++ b/src/gallium/state_trackers/python/p_state.i @@ -37,6 +37,7 @@ %ignore winsys; %ignore pipe_vertex_buffer::buffer; +%include "pipe/p_compiler.h"; %include "pipe/p_state.h"; diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index 08ba0ebe4d0..1e64fc8e41f 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -121,6 +121,50 @@ pipe_put_tile_rgba($self, x, y, w, h, rgba); } + %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1)); + void + get_tile_rgba8(unsigned x, unsigned y, unsigned w, unsigned h, char **STRING, int *LENGTH) + { + unsigned surface_usage; + float *rgba; + unsigned char *rgba8; + unsigned i, j, k; + + *LENGTH = 0; + *STRING = NULL; + + if (!$self) + return; + + *LENGTH = h*w*4; + *STRING = (char *) malloc(*LENGTH); + if(!*STRING) + return; + + rgba = malloc(w*4*sizeof(float)); + if(!rgba) + return; + + rgba8 = (unsigned char *) *STRING; + + /* XXX: force mappable surface */ + surface_usage = $self->usage; + $self->usage |= PIPE_BUFFER_USAGE_CPU_READ; + + for(j = 0; j < h; ++j) { + pipe_get_tile_rgba($self, + x, y + j, w, 1, + rgba); + for(i = 0; i < w; ++i) + for(k = 0; k <4; ++k) + rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[i*4 + k]); + } + + $self->usage = surface_usage; + + free(rgba); + } + void get_tile_z(unsigned x, unsigned y, unsigned w, unsigned h, unsigned *z) { pipe_get_tile_z($self, x, y, w, h, z); @@ -181,7 +225,7 @@ struct st_buffer { unsigned __len__(void) { - assert($self->buffer->refcount); + assert(p_atomic_read(&$self->buffer->reference.count) > 0); return $self->buffer->size; } @@ -191,7 +235,7 @@ struct st_buffer { struct pipe_screen *screen = $self->st_dev->screen; const char *map; - assert($self->buffer->refcount); + assert(p_atomic_read(&$self->buffer->reference.count) > 0); *LENGTH = $self->buffer->size; *STRING = (char *) malloc($self->buffer->size); @@ -211,7 +255,7 @@ struct st_buffer { struct pipe_screen *screen = $self->st_dev->screen; char *map; - assert($self->buffer->refcount); + assert(p_atomic_read(&$self->buffer->reference.count) > 0); if(offset > $self->buffer->size) { PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size"); diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index f418f80d7b4..e6999a2211e 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -35,21 +35,19 @@ import model import parser +try: + from struct import unpack_from +except ImportError: + def unpack_from(fmt, buf, offset=0): + size = struct.calcsize(fmt) + return struct.unpack(fmt, buf[offset:offset + size]) + + def make_image(surface): - pixels = gallium.FloatArray(surface.height*surface.width*4) - surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels) + data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) import Image - outimage = Image.new( - mode='RGB', - size=(surface.width, surface.height), - color=(0,0,0)) - outpixels = outimage.load() - for y in range(0, surface.height): - for x in range(0, surface.width): - offset = (y*surface.width + x)*4 - r, g, b, a = [int(pixels[offset + ch]*255) for ch in range(4)] - outpixels[x, y] = r, g, b + outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) return outimage def save_image(filename, surface): @@ -77,6 +75,7 @@ def show_image(surface): root.mainloop() +verbose = 1 class Struct: @@ -297,6 +296,7 @@ class Context(Object): self.zsbuf = None self.vbufs = [] self.velems = [] + self.dirty = False def destroy(self): pass @@ -374,18 +374,23 @@ class Context(Object): _state.ucp = ucp self.real.set_clip(_state) + def dump_constant_buffer(self, buffer): + if verbose < 2: + return + + data = buffer.read() + format = '4f' + index = 0 + for offset in range(0, len(data), struct.calcsize(format)): + x, y, z, w = unpack_from(format, data, offset) + sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w)) + index += 1 + def set_constant_buffer(self, shader, index, state): if state is not None: self.real.set_constant_buffer(shader, index, state.buffer) - if 1: - data = state.buffer.read() - format = '4f' - index = 0 - for offset in range(0, len(data), struct.calcsize(format)): - x, y, z, w = struct.unpack_from(format, data, offset) - sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w)) - index += 1 + self.dump_constant_buffer(state.buffer) def set_framebuffer_state(self, state): _state = gallium.Framebuffer() @@ -436,6 +441,9 @@ class Context(Object): pass def dump_vertices(self, start, count): + if verbose < 2: + return + for index in range(start, start + count): if index >= start + 16: sys.stdout.write('\t...\n') @@ -454,12 +462,15 @@ class Context(Object): }[velem.src_format] data = vbuf.buffer.read() - values = struct.unpack_from(format, data, offset) + values = unpack_from(format, data, offset) sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n') assert len(values) == velem.nr_components sys.stdout.write('\t},\n') def dump_indices(self, ibuf, isize, start, count): + if verbose < 2: + return + format = { 1: 'B', 2: 'H', @@ -477,7 +488,7 @@ class Context(Object): sys.stdout.write('\t...\n') break offset = i*isize - index, = struct.unpack_from(format, data, offset) + index, = unpack_from(format, data, offset) sys.stdout.write('\t\t%u,\n' % index) minindex = min(minindex, index) maxindex = max(maxindex, index) @@ -489,25 +500,35 @@ class Context(Object): self.dump_vertices(start, count) self.real.draw_arrays(mode, start, count) + + self.dirty = True def draw_elements(self, indexBuffer, indexSize, mode, start, count): - minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) - self.dump_vertices(minindex, maxindex - minindex) + if verbose >= 2: + minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) + self.dump_vertices(minindex, maxindex - minindex) self.real.draw_elements(indexBuffer, indexSize, mode, start, count) + + self.dirty = True def draw_range_elements(self, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count): - minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) - minindex = min(minindex, minIndex) - maxindex = min(maxindex, maxIndex) - self.dump_vertices(minindex, maxindex - minindex) + if verbose >= 2: + minindex, maxindex = self.dump_indices(indexBuffer, indexSize, start, count) + minindex = min(minindex, minIndex) + maxindex = min(maxindex, maxIndex) + self.dump_vertices(minindex, maxindex - minindex) self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count) + + self.dirty = True def flush(self, flags): self.real.flush(flags) - if flags & gallium.PIPE_FLUSH_FRAME: - self._update() + if self.dirty: + if flags & gallium.PIPE_FLUSH_FRAME: + self._update() + self.dirty = False return None def clear(self, surface, value): @@ -553,7 +574,8 @@ class Interpreter(parser.TraceDumper): if (call.klass, call.method) in self.ignore_calls: return - parser.TraceDumper.handle_call(self, call) + if verbose >= 1: + parser.TraceDumper.handle_call(self, call) args = [self.interpret_arg(arg) for name, arg in call.args] diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index 193479f7d6c..d3ccb6c2f46 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -31,20 +31,10 @@ from gallium import * def make_image(surface): - pixels = FloatArray(surface.height*surface.width*4) - surface.get_tile_rgba(0, 0, surface.width, surface.height, pixels) + data = surface.get_tile_rgba8(0, 0, surface.width, surface.height) import Image - outimage = Image.new( - mode='RGB', - size=(surface.width, surface.height), - color=(0,0,0)) - outpixels = outimage.load() - for y in range(0, surface.height): - for x in range(0, surface.width): - offset = (y*surface.width + x)*4 - r, g, b, a = [int(pixels[offset + ch]*255) for ch in range(4)] - outpixels[x, y] = r, g, b + outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1) return outimage def save_image(filename, surface): diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 20dd8d269d9..366d4eb19af 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -51,11 +51,20 @@ st_device_really_destroy(struct st_device *st_dev) } +static void +st_device_reference(struct st_device **ptr, struct st_device *st_dev) +{ + struct st_device *old_dev = *ptr; + + if (pipe_reference((struct pipe_reference **)ptr, &st_dev->reference)) + st_device_really_destroy(old_dev); +} + + void st_device_destroy(struct st_device *st_dev) { - if(!--st_dev->refcount) - st_device_really_destroy(st_dev); + st_device_reference(&st_dev, NULL); } @@ -72,7 +81,7 @@ st_device_create_from_st_winsys(const struct st_winsys *st_ws) if(!st_dev) return NULL; - st_dev->refcount = 1; + pipe_reference_init(&st_dev->reference, 1); st_dev->st_ws = st_ws; st_dev->real_screen = st_ws->screen_create(); @@ -124,8 +133,7 @@ st_context_destroy(struct st_context *st_ctx) FREE(st_ctx); - if(!--st_dev->refcount) - st_device_really_destroy(st_dev); + st_device_reference(&st_dev, NULL); } } @@ -139,8 +147,7 @@ st_context_create(struct st_device *st_dev) if(!st_ctx) return NULL; - st_ctx->st_dev = st_dev; - ++st_dev->refcount; + st_device_reference(&st_ctx->st_dev, st_dev); st_ctx->real_pipe = st_dev->st_ws->context_create(st_dev->real_screen); if(!st_ctx->real_pipe) { @@ -185,8 +192,7 @@ st_context_create(struct st_device *st_dev) memset(&rasterizer, 0, sizeof(rasterizer)); rasterizer.front_winding = PIPE_WINDING_CW; rasterizer.cull_mode = PIPE_WINDING_NONE; - rasterizer.bypass_clipping = 1; - /*rasterizer.bypass_vs = 1;*/ + rasterizer.bypass_vs_clip_and_viewport = 1; cso_set_rasterizer(st_ctx->cso, &rasterizer); } @@ -225,7 +231,7 @@ st_context_create(struct st_device *st_dev) { struct pipe_screen *screen = st_dev->screen; struct pipe_texture templat; - struct pipe_surface *surface; + struct pipe_transfer *transfer; unsigned i; memset( &templat, 0, sizeof( templat ) ); @@ -241,17 +247,21 @@ st_context_create(struct st_device *st_dev) st_ctx->default_texture = screen->texture_create( screen, &templat ); if(st_ctx->default_texture) { - surface = screen->get_tex_surface( screen, - st_ctx->default_texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE ); - if(surface) { + transfer = screen->get_tex_transfer(screen, + st_ctx->default_texture, + 0, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, + st_ctx->default_texture->width[0], + st_ctx->default_texture->height[0]); + if (transfer) { uint32_t *map; - map = (uint32_t *) pipe_surface_map(surface, PIPE_BUFFER_USAGE_CPU_WRITE ); + map = (uint32_t *) screen->transfer_map(screen, transfer); if(map) { *map = 0x00000000; - pipe_surface_unmap( surface ); + screen->transfer_unmap(screen, transfer); } - pipe_surface_reference(&surface, NULL); + screen->tex_transfer_destroy(transfer); } } @@ -263,24 +273,19 @@ st_context_create(struct st_device *st_dev) /* vertex shader */ { - struct pipe_shader_state vert_shader; - const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_GENERIC }; const uint semantic_indexes[] = { 0, 0 }; st_ctx->vs = util_make_vertex_passthrough_shader(st_ctx->pipe, 2, semantic_names, - semantic_indexes, - &vert_shader); + semantic_indexes); cso_set_vertex_shader_handle(st_ctx->cso, st_ctx->vs); } /* fragment shader */ { - struct pipe_shader_state frag_shader; - st_ctx->fs = util_make_fragment_passthrough_shader(st_ctx->pipe, - &frag_shader); + st_ctx->fs = util_make_fragment_passthrough_shader(st_ctx->pipe); cso_set_fragment_shader_handle(st_ctx->cso, st_ctx->fs); } @@ -292,8 +297,7 @@ void st_buffer_destroy(struct st_buffer *st_buf) { if(st_buf) { - struct pipe_screen *screen = st_buf->st_dev->screen; - pipe_buffer_reference(screen, &st_buf->buffer, NULL); + pipe_buffer_reference(&st_buf->buffer, NULL); FREE(st_buf); } } diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h index 7cfe6de9f6a..0641aff149f 100644 --- a/src/gallium/state_trackers/python/st_device.h +++ b/src/gallium/state_trackers/python/st_device.h @@ -68,13 +68,13 @@ struct st_context { struct st_device { + /* FIXME: we also need to refcount for textures and surfaces... */ + struct pipe_reference reference; + const struct st_winsys *st_ws; struct pipe_screen *real_screen; struct pipe_screen *screen; - - /* FIXME: we also need to refcount for textures and surfaces... */ - unsigned refcount; }; diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index 7765df3c4a4..c2ffe9fce1d 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -451,6 +451,7 @@ st_sample_dxt_pixel_block(enum pipe_format format, break; default: assert(0); + return; } i = st_random() % n; @@ -524,26 +525,42 @@ st_sample_pixel_block(enum pipe_format format, void st_sample_surface(struct pipe_surface *surface, float *rgba) { - const struct pipe_format_block *block = &surface->block; - unsigned rgba_stride = surface->width*4; + struct pipe_screen *screen = surface->texture->screen; + uint rgba_stride = surface->width * 4; + struct pipe_transfer *transfer; void *raw; - unsigned x, y; - raw = pipe_surface_map(surface, PIPE_BUFFER_USAGE_CPU_READ); - if(!raw) + transfer = screen->get_tex_transfer(screen, + surface->texture, + surface->face, + surface->level, + surface->zslice, + PIPE_TRANSFER_READ, + 0, 0, + surface->width, + surface->height); + if (!transfer) return; - for (y = 0; y < surface->nblocksy; ++y) { - for(x = 0; x < surface->nblocksx; ++x) { - st_sample_pixel_block(surface->format, - block, - (uint8_t*)raw + y*surface->stride + x*block->size, - rgba + y*block->height*rgba_stride + x*block->width*4, - rgba_stride, - MIN2(block->width, surface->width - x*block->width), - MIN2(block->height, surface->height - y*block->height)); - } + raw = screen->transfer_map(screen, transfer); + if (raw) { + const struct pipe_format_block *block = &transfer->block; + uint x, y; + + for (y = 0; y < transfer->nblocksy; ++y) { + for (x = 0; x < transfer->nblocksx; ++x) { + st_sample_pixel_block(surface->format, + block, + (uint8_t *) raw + y * transfer->stride + x * block->size, + rgba + y * block->height * rgba_stride + x * block->width * 4, + rgba_stride, + MIN2(block->width, surface->width - x*block->width), + MIN2(block->height, surface->height - y*block->height)); + } + } + + screen->transfer_unmap(screen, transfer); } - pipe_surface_unmap(surface); + screen->tex_transfer_destroy(transfer); } diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 4d798df99bf..426f347d189 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -124,7 +124,7 @@ st_softpipe_buffer_create(struct pipe_winsys *winsys, { struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer); - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; @@ -149,7 +149,7 @@ st_softpipe_user_buffer_create(struct pipe_winsys *winsys, if(!buffer) return NULL; - buffer->base.refcount = 1; + pipe_reference_init(&buffer->base.reference, 1); buffer->base.size = bytes; buffer->userBuffer = TRUE; buffer->data = ptr; diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index c72f495735d..2141b02d688 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -14,13 +14,10 @@ if env['platform'] in ['windows']: env.Append(CPPDEFINES = [ '_GDI32_', # prevent wgl* being declared __declspec(dllimport) 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - '__GL_EXPORTS', - '_GNU_H_WINDOWS32_DEFINES', + 'WIN32_THREADS', # use Win32 thread API ]) sources = [ - 'stw.c', - 'icd/stw_icd.c', 'wgl/stw_wgl.c', diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 1aa4b8a6e22..faf7f2f4106 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -30,82 +30,17 @@ #include "GL/gl.h" -#include "pipe/p_debug.h" +#include "util/u_debug.h" #include "pipe/p_thread.h" #include "shared/stw_public.h" #include "icd/stw_icd.h" -#include "stw.h" +#define DBG 0 -#define DRV_CONTEXT_MAX 32 +static GLCLTPROCTABLE cpt; +static boolean cpt_initialized = FALSE; -struct stw_icd -{ - pipe_mutex mutex; - - GLCLTPROCTABLE cpt; - boolean cpt_initialized; - - struct { - struct stw_context *ctx; - } ctx_array[DRV_CONTEXT_MAX]; -}; - - -static struct stw_icd *stw_icd = NULL; - - -boolean -stw_icd_init( void ) -{ - static struct stw_icd stw_icd_storage; - - assert(!stw_icd); - - stw_icd = &stw_icd_storage; - memset(stw_icd, 0, sizeof *stw_icd); - - pipe_mutex_init( stw_icd->mutex ); - - return TRUE; -} - -void -stw_icd_cleanup(void) -{ - int i; - - if (!stw_icd) - return; - - pipe_mutex_lock( stw_icd->mutex ); - { - /* Ensure all contexts are destroyed */ - for (i = 0; i < DRV_CONTEXT_MAX; i++) - if (stw_icd->ctx_array[i].ctx) - stw_delete_context( stw_icd->ctx_array[i].ctx ); - } - pipe_mutex_unlock( stw_icd->mutex ); - - pipe_mutex_init( stw_icd->mutex ); - stw_icd = NULL; -} - - -static struct stw_context * -lookup_context( struct stw_icd *icd, - DHGLRC dhglrc ) -{ - if (dhglrc == 0 || - dhglrc >= DRV_CONTEXT_MAX) - return NULL; - - if (icd == NULL) - return NULL; - - return icd->ctx_array[dhglrc - 1].ctx; -} BOOL APIENTRY DrvCopyContext( @@ -113,63 +48,16 @@ DrvCopyContext( DHGLRC dhrcDest, UINT fuMask ) { - BOOL ret = FALSE; - - if (!stw_icd) - return FALSE; - - pipe_mutex_lock( stw_icd->mutex ); - { - struct stw_context *src = lookup_context( stw_icd, dhrcSource ); - struct stw_context *dst = lookup_context( stw_icd, dhrcDest ); - - if (src == NULL || dst == NULL) - goto done; - - ret = stw_copy_context( src, dst, fuMask ); - } -done: - pipe_mutex_unlock( stw_icd->mutex ); - - return ret; + return stw_copy_context(dhrcSource, dhrcDest, fuMask); } + DHGLRC APIENTRY DrvCreateLayerContext( HDC hdc, INT iLayerPlane ) { - DHGLRC handle = 0; - - if (!stw_icd) - return handle; - - pipe_mutex_lock( stw_icd->mutex ); - { - int i; - - for (i = 0; i < DRV_CONTEXT_MAX; i++) { - if (stw_icd->ctx_array[i].ctx == NULL) - break; - } - - /* No slot available, fail: - */ - if (i == DRV_CONTEXT_MAX) - goto done; - - stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane ); - if (stw_icd->ctx_array[i].ctx == NULL) - goto done; - - /* success: - */ - handle = (DHGLRC) i + 1; - } -done: - pipe_mutex_unlock( stw_icd->mutex ); - - return handle; + return stw_create_layer_context( hdc, iLayerPlane ); } DHGLRC APIENTRY @@ -183,30 +71,7 @@ BOOL APIENTRY DrvDeleteContext( DHGLRC dhglrc ) { - BOOL ret = FALSE; - - if (!stw_icd) - return ret; - - pipe_mutex_lock( stw_icd->mutex ); - { - struct stw_context *ctx; - - ctx = lookup_context( stw_icd, dhglrc ); - if (ctx == NULL) - goto done; - - if (stw_delete_context( ctx ) == FALSE) - goto done; - - stw_icd->ctx_array[dhglrc - 1].ctx = NULL; - ret = TRUE; - - } -done: - pipe_mutex_unlock( stw_icd->mutex ); - - return ret; + return stw_delete_context( dhglrc ); } BOOL APIENTRY @@ -217,7 +82,8 @@ DrvDescribeLayerPlane( UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return FALSE; } @@ -233,8 +99,9 @@ DrvDescribePixelFormat( r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd ); - debug_printf( "%s( %p, %d, %u, %p ) = %d\n", - __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r ); + if (DBG) + debug_printf( "%s( %p, %d, %u, %p ) = %d\n", + __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r ); return r; } @@ -247,7 +114,8 @@ DrvGetLayerPaletteEntries( INT cEntries, COLORREF *pcr ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return 0; } @@ -260,7 +128,8 @@ DrvGetProcAddress( r = stw_get_proc_address( lpszProc ); - debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r ); + if (DBG) + debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r ); return r; } @@ -271,7 +140,8 @@ DrvRealizeLayerPalette( INT iLayerPlane, BOOL bRealize ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return FALSE; } @@ -280,32 +150,7 @@ BOOL APIENTRY DrvReleaseContext( DHGLRC dhglrc ) { - BOOL ret = FALSE; - - if (!stw_icd) - return ret; - - pipe_mutex_lock( stw_icd->mutex ); - { - struct stw_context *ctx; - - /* XXX: The expectation is that ctx is the same context which is - * current for this thread. We should check that and return False - * if not the case. - */ - ctx = lookup_context( stw_icd, dhglrc ); - if (ctx == NULL) - goto done; - - if (stw_make_current( NULL, NULL ) == FALSE) - goto done; - - ret = TRUE; - } -done: - pipe_mutex_unlock( stw_icd->mutex ); - - return ret; + return stw_release_context(dhglrc); } void APIENTRY @@ -313,7 +158,8 @@ DrvSetCallbackProcs( INT nProcs, PROC *pProcs ) { - debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs ); + if (DBG) + debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs ); return; } @@ -671,38 +517,21 @@ DrvSetContext( DHGLRC dhglrc, PFN_SETPROCTABLE pfnSetProcTable ) { - PGLCLTPROCTABLE result = NULL; - - if (!stw_icd) - return result; - - pipe_mutex_lock( stw_icd->mutex ); - { - struct stw_context *ctx; - + if (DBG) debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable ); - /* Although WGL allows different dispatch entrypoints per - */ - if (!stw_icd->cpt_initialized) { - init_proc_table( &stw_icd->cpt ); - stw_icd->cpt_initialized = TRUE; - } - - ctx = lookup_context( stw_icd, dhglrc ); - if (ctx == NULL) - goto done; - - if (!stw_make_current( hdc, ctx )) - goto done; - - result = &stw_icd->cpt; + /* Although WGL allows different dispatch entrypoints per + */ + if (!cpt_initialized) { + init_proc_table( &cpt ); + cpt_initialized = TRUE; } -done: - pipe_mutex_unlock( stw_icd->mutex ); - return result; + if (!stw_make_current( hdc, dhglrc )) + return NULL; + + return &cpt; } int APIENTRY @@ -713,7 +542,8 @@ DrvSetLayerPaletteEntries( INT cEntries, CONST COLORREF *pcr ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return 0; } @@ -727,7 +557,8 @@ DrvSetPixelFormat( r = stw_pixelformat_set( hdc, iPixelFormat ); - debug_printf( "%s( %p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" ); + if (DBG) + debug_printf( "%s( %p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" ); return r; } @@ -737,7 +568,8 @@ DrvShareLists( DHGLRC dhglrc1, DHGLRC dhglrc2 ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return FALSE; } @@ -746,7 +578,8 @@ BOOL APIENTRY DrvSwapBuffers( HDC hdc ) { - debug_printf( "%s( %p )\n", __FUNCTION__, hdc ); + if (DBG) + debug_printf( "%s( %p )\n", __FUNCTION__, hdc ); return stw_swap_buffers( hdc ); } @@ -756,7 +589,8 @@ DrvSwapLayerBuffers( HDC hdc, UINT fuPlanes ) { - debug_printf( "%s\n", __FUNCTION__ ); + if (DBG) + debug_printf( "%s\n", __FUNCTION__ ); return FALSE; } @@ -765,7 +599,8 @@ BOOL APIENTRY DrvValidateVersion( ULONG ulVersion ) { - debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion ); + if (DBG) + debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion ); /* TODO: get the expected version from the winsys */ diff --git a/src/gallium/state_trackers/wgl/opengl32.mingw.def b/src/gallium/state_trackers/wgl/opengl32.mingw.def new file mode 100644 index 00000000000..1f03ea3b375 --- /dev/null +++ b/src/gallium/state_trackers/wgl/opengl32.mingw.def @@ -0,0 +1,387 @@ +EXPORTS +; GlmfBeginGlsBlock = GlmfBeginGlsBlock@4 +; GlmfCloseMetaFile = GlmfCloseMetaFile@4 +; GlmfEndGlsBlock = GlmfEndGlsBlock@4 +; GlmfEndPlayback = GlmfEndPlayback@4 +; GlmfInitPlayback = GlmfInitPlayback@12 +; GlmfPlayGlsRecord = GlmfPlayGlsRecord@16 + glAccum = glAccum@8 + glAlphaFunc = glAlphaFunc@8 + glAreTexturesResident = glAreTexturesResident@12 + glArrayElement = glArrayElement@4 + glBegin = glBegin@4 + glBindTexture = glBindTexture@8 + glBitmap = glBitmap@28 + glBlendFunc = glBlendFunc@8 + glCallList = glCallList@4 + glCallLists = glCallLists@12 + glClear = glClear@4 + glClearAccum = glClearAccum@16 + glClearColor = glClearColor@16 + glClearDepth = glClearDepth@8 + glClearIndex = glClearIndex@4 + glClearStencil = glClearStencil@4 + glClipPlane = glClipPlane@8 + glColor3b = glColor3b@12 + glColor3bv = glColor3bv@4 + glColor3d = glColor3d@24 + glColor3dv = glColor3dv@4 + glColor3f = glColor3f@12 + glColor3fv = glColor3fv@4 + glColor3i = glColor3i@12 + glColor3iv = glColor3iv@4 + glColor3s = glColor3s@12 + glColor3sv = glColor3sv@4 + glColor3ub = glColor3ub@12 + glColor3ubv = glColor3ubv@4 + glColor3ui = glColor3ui@12 + glColor3uiv = glColor3uiv@4 + glColor3us = glColor3us@12 + glColor3usv = glColor3usv@4 + glColor4b = glColor4b@16 + glColor4bv = glColor4bv@4 + glColor4d = glColor4d@32 + glColor4dv = glColor4dv@4 + glColor4f = glColor4f@16 + glColor4fv = glColor4fv@4 + glColor4i = glColor4i@16 + glColor4iv = glColor4iv@4 + glColor4s = glColor4s@16 + glColor4sv = glColor4sv@4 + glColor4ub = glColor4ub@16 + glColor4ubv = glColor4ubv@4 + glColor4ui = glColor4ui@16 + glColor4uiv = glColor4uiv@4 + glColor4us = glColor4us@16 + glColor4usv = glColor4usv@4 + glColorMask = glColorMask@16 + glColorMaterial = glColorMaterial@8 + glColorPointer = glColorPointer@16 + glCopyPixels = glCopyPixels@20 + glCopyTexImage1D = glCopyTexImage1D@28 + glCopyTexImage2D = glCopyTexImage2D@32 + glCopyTexSubImage1D = glCopyTexSubImage1D@24 + glCopyTexSubImage2D = glCopyTexSubImage2D@32 + glCullFace = glCullFace@4 +; glDebugEntry = glDebugEntry@8 + glDeleteLists = glDeleteLists@8 + glDeleteTextures = glDeleteTextures@8 + glDepthFunc = glDepthFunc@4 + glDepthMask = glDepthMask@4 + glDepthRange = glDepthRange@16 + glDisable = glDisable@4 + glDisableClientState = glDisableClientState@4 + glDrawArrays = glDrawArrays@12 + glDrawBuffer = glDrawBuffer@4 + glDrawElements = glDrawElements@16 + glDrawPixels = glDrawPixels@20 + glEdgeFlag = glEdgeFlag@4 + glEdgeFlagPointer = glEdgeFlagPointer@8 + glEdgeFlagv = glEdgeFlagv@4 + glEnable = glEnable@4 + glEnableClientState = glEnableClientState@4 + glEnd = glEnd@0 + glEndList = glEndList@0 + glEvalCoord1d = glEvalCoord1d@8 + glEvalCoord1dv = glEvalCoord1dv@4 + glEvalCoord1f = glEvalCoord1f@4 + glEvalCoord1fv = glEvalCoord1fv@4 + glEvalCoord2d = glEvalCoord2d@16 + glEvalCoord2dv = glEvalCoord2dv@4 + glEvalCoord2f = glEvalCoord2f@8 + glEvalCoord2fv = glEvalCoord2fv@4 + glEvalMesh1 = glEvalMesh1@12 + glEvalMesh2 = glEvalMesh2@20 + glEvalPoint1 = glEvalPoint1@4 + glEvalPoint2 = glEvalPoint2@8 + glFeedbackBuffer = glFeedbackBuffer@12 + glFinish = glFinish@0 + glFlush = glFlush@0 + glFogf = glFogf@8 + glFogfv = glFogfv@8 + glFogi = glFogi@8 + glFogiv = glFogiv@8 + glFrontFace = glFrontFace@4 + glFrustum = glFrustum@48 + glGenLists = glGenLists@4 + glGenTextures = glGenTextures@8 + glGetBooleanv = glGetBooleanv@8 + glGetClipPlane = glGetClipPlane@8 + glGetDoublev = glGetDoublev@8 + glGetError = glGetError@0 + glGetFloatv = glGetFloatv@8 + glGetIntegerv = glGetIntegerv@8 + glGetLightfv = glGetLightfv@12 + glGetLightiv = glGetLightiv@12 + glGetMapdv = glGetMapdv@12 + glGetMapfv = glGetMapfv@12 + glGetMapiv = glGetMapiv@12 + glGetMaterialfv = glGetMaterialfv@12 + glGetMaterialiv = glGetMaterialiv@12 + glGetPixelMapfv = glGetPixelMapfv@8 + glGetPixelMapuiv = glGetPixelMapuiv@8 + glGetPixelMapusv = glGetPixelMapusv@8 + glGetPointerv = glGetPointerv@8 + glGetPolygonStipple = glGetPolygonStipple@4 + glGetString = glGetString@4 + glGetTexEnvfv = glGetTexEnvfv@12 + glGetTexEnviv = glGetTexEnviv@12 + glGetTexGendv = glGetTexGendv@12 + glGetTexGenfv = glGetTexGenfv@12 + glGetTexGeniv = glGetTexGeniv@12 + glGetTexImage = glGetTexImage@20 + glGetTexLevelParameterfv = glGetTexLevelParameterfv@16 + glGetTexLevelParameteriv = glGetTexLevelParameteriv@16 + glGetTexParameterfv = glGetTexParameterfv@12 + glGetTexParameteriv = glGetTexParameteriv@12 + glHint = glHint@8 + glIndexMask = glIndexMask@4 + glIndexPointer = glIndexPointer@12 + glIndexd = glIndexd@8 + glIndexdv = glIndexdv@4 + glIndexf = glIndexf@4 + glIndexfv = glIndexfv@4 + glIndexi = glIndexi@4 + glIndexiv = glIndexiv@4 + glIndexs = glIndexs@4 + glIndexsv = glIndexsv@4 + glIndexub = glIndexub@4 + glIndexubv = glIndexubv@4 + glInitNames = glInitNames@0 + glInterleavedArrays = glInterleavedArrays@12 + glIsEnabled = glIsEnabled@4 + glIsList = glIsList@4 + glIsTexture = glIsTexture@4 + glLightModelf = glLightModelf@8 + glLightModelfv = glLightModelfv@8 + glLightModeli = glLightModeli@8 + glLightModeliv = glLightModeliv@8 + glLightf = glLightf@12 + glLightfv = glLightfv@12 + glLighti = glLighti@12 + glLightiv = glLightiv@12 + glLineStipple = glLineStipple@8 + glLineWidth = glLineWidth@4 + glListBase = glListBase@4 + glLoadIdentity = glLoadIdentity@0 + glLoadMatrixd = glLoadMatrixd@4 + glLoadMatrixf = glLoadMatrixf@4 + glLoadName = glLoadName@4 + glLogicOp = glLogicOp@4 + glMap1d = glMap1d@32 + glMap1f = glMap1f@24 + glMap2d = glMap2d@56 + glMap2f = glMap2f@40 + glMapGrid1d = glMapGrid1d@20 + glMapGrid1f = glMapGrid1f@12 + glMapGrid2d = glMapGrid2d@40 + glMapGrid2f = glMapGrid2f@24 + glMaterialf = glMaterialf@12 + glMaterialfv = glMaterialfv@12 + glMateriali = glMateriali@12 + glMaterialiv = glMaterialiv@12 + glMatrixMode = glMatrixMode@4 + glMultMatrixd = glMultMatrixd@4 + glMultMatrixf = glMultMatrixf@4 + glNewList = glNewList@8 + glNormal3b = glNormal3b@12 + glNormal3bv = glNormal3bv@4 + glNormal3d = glNormal3d@24 + glNormal3dv = glNormal3dv@4 + glNormal3f = glNormal3f@12 + glNormal3fv = glNormal3fv@4 + glNormal3i = glNormal3i@12 + glNormal3iv = glNormal3iv@4 + glNormal3s = glNormal3s@12 + glNormal3sv = glNormal3sv@4 + glNormalPointer = glNormalPointer@12 + glOrtho = glOrtho@48 + glPassThrough = glPassThrough@4 + glPixelMapfv = glPixelMapfv@12 + glPixelMapuiv = glPixelMapuiv@12 + glPixelMapusv = glPixelMapusv@12 + glPixelStoref = glPixelStoref@8 + glPixelStorei = glPixelStorei@8 + glPixelTransferf = glPixelTransferf@8 + glPixelTransferi = glPixelTransferi@8 + glPixelZoom = glPixelZoom@8 + glPointSize = glPointSize@4 + glPolygonMode = glPolygonMode@8 + glPolygonOffset = glPolygonOffset@8 + glPolygonStipple = glPolygonStipple@4 + glPopAttrib = glPopAttrib@0 + glPopClientAttrib = glPopClientAttrib@0 + glPopMatrix = glPopMatrix@0 + glPopName = glPopName@0 + glPrioritizeTextures = glPrioritizeTextures@12 + glPushAttrib = glPushAttrib@4 + glPushClientAttrib = glPushClientAttrib@4 + glPushMatrix = glPushMatrix@0 + glPushName = glPushName@4 + glRasterPos2d = glRasterPos2d@16 + glRasterPos2dv = glRasterPos2dv@4 + glRasterPos2f = glRasterPos2f@8 + glRasterPos2fv = glRasterPos2fv@4 + glRasterPos2i = glRasterPos2i@8 + glRasterPos2iv = glRasterPos2iv@4 + glRasterPos2s = glRasterPos2s@8 + glRasterPos2sv = glRasterPos2sv@4 + glRasterPos3d = glRasterPos3d@24 + glRasterPos3dv = glRasterPos3dv@4 + glRasterPos3f = glRasterPos3f@12 + glRasterPos3fv = glRasterPos3fv@4 + glRasterPos3i = glRasterPos3i@12 + glRasterPos3iv = glRasterPos3iv@4 + glRasterPos3s = glRasterPos3s@12 + glRasterPos3sv = glRasterPos3sv@4 + glRasterPos4d = glRasterPos4d@32 + glRasterPos4dv = glRasterPos4dv@4 + glRasterPos4f = glRasterPos4f@16 + glRasterPos4fv = glRasterPos4fv@4 + glRasterPos4i = glRasterPos4i@16 + glRasterPos4iv = glRasterPos4iv@4 + glRasterPos4s = glRasterPos4s@16 + glRasterPos4sv = glRasterPos4sv@4 + glReadBuffer = glReadBuffer@4 + glReadPixels = glReadPixels@28 + glRectd = glRectd@32 + glRectdv = glRectdv@8 + glRectf = glRectf@16 + glRectfv = glRectfv@8 + glRecti = glRecti@16 + glRectiv = glRectiv@8 + glRects = glRects@16 + glRectsv = glRectsv@8 + glRenderMode = glRenderMode@4 + glRotated = glRotated@32 + glRotatef = glRotatef@16 + glScaled = glScaled@24 + glScalef = glScalef@12 + glScissor = glScissor@16 + glSelectBuffer = glSelectBuffer@8 + glShadeModel = glShadeModel@4 + glStencilFunc = glStencilFunc@12 + glStencilMask = glStencilMask@4 + glStencilOp = glStencilOp@12 + glTexCoord1d = glTexCoord1d@8 + glTexCoord1dv = glTexCoord1dv@4 + glTexCoord1f = glTexCoord1f@4 + glTexCoord1fv = glTexCoord1fv@4 + glTexCoord1i = glTexCoord1i@4 + glTexCoord1iv = glTexCoord1iv@4 + glTexCoord1s = glTexCoord1s@4 + glTexCoord1sv = glTexCoord1sv@4 + glTexCoord2d = glTexCoord2d@16 + glTexCoord2dv = glTexCoord2dv@4 + glTexCoord2f = glTexCoord2f@8 + glTexCoord2fv = glTexCoord2fv@4 + glTexCoord2i = glTexCoord2i@8 + glTexCoord2iv = glTexCoord2iv@4 + glTexCoord2s = glTexCoord2s@8 + glTexCoord2sv = glTexCoord2sv@4 + glTexCoord3d = glTexCoord3d@24 + glTexCoord3dv = glTexCoord3dv@4 + glTexCoord3f = glTexCoord3f@12 + glTexCoord3fv = glTexCoord3fv@4 + glTexCoord3i = glTexCoord3i@12 + glTexCoord3iv = glTexCoord3iv@4 + glTexCoord3s = glTexCoord3s@12 + glTexCoord3sv = glTexCoord3sv@4 + glTexCoord4d = glTexCoord4d@32 + glTexCoord4dv = glTexCoord4dv@4 + glTexCoord4f = glTexCoord4f@16 + glTexCoord4fv = glTexCoord4fv@4 + glTexCoord4i = glTexCoord4i@16 + glTexCoord4iv = glTexCoord4iv@4 + glTexCoord4s = glTexCoord4s@16 + glTexCoord4sv = glTexCoord4sv@4 + glTexCoordPointer = glTexCoordPointer@16 + glTexEnvf = glTexEnvf@12 + glTexEnvfv = glTexEnvfv@12 + glTexEnvi = glTexEnvi@12 + glTexEnviv = glTexEnviv@12 + glTexGend = glTexGend@16 + glTexGendv = glTexGendv@12 + glTexGenf = glTexGenf@12 + glTexGenfv = glTexGenfv@12 + glTexGeni = glTexGeni@12 + glTexGeniv = glTexGeniv@12 + glTexImage1D = glTexImage1D@32 + glTexImage2D = glTexImage2D@36 + glTexParameterf = glTexParameterf@12 + glTexParameterfv = glTexParameterfv@12 + glTexParameteri = glTexParameteri@12 + glTexParameteriv = glTexParameteriv@12 + glTexSubImage1D = glTexSubImage1D@28 + glTexSubImage2D = glTexSubImage2D@36 + glTranslated = glTranslated@24 + glTranslatef = glTranslatef@12 + glVertex2d = glVertex2d@16 + glVertex2dv = glVertex2dv@4 + glVertex2f = glVertex2f@8 + glVertex2fv = glVertex2fv@4 + glVertex2i = glVertex2i@8 + glVertex2iv = glVertex2iv@4 + glVertex2s = glVertex2s@8 + glVertex2sv = glVertex2sv@4 + glVertex3d = glVertex3d@24 + glVertex3dv = glVertex3dv@4 + glVertex3f = glVertex3f@12 + glVertex3fv = glVertex3fv@4 + glVertex3i = glVertex3i@12 + glVertex3iv = glVertex3iv@4 + glVertex3s = glVertex3s@12 + glVertex3sv = glVertex3sv@4 + glVertex4d = glVertex4d@32 + glVertex4dv = glVertex4dv@4 + glVertex4f = glVertex4f@16 + glVertex4fv = glVertex4fv@4 + glVertex4i = glVertex4i@16 + glVertex4iv = glVertex4iv@4 + glVertex4s = glVertex4s@16 + glVertex4sv = glVertex4sv@4 + glVertexPointer = glVertexPointer@16 + glViewport = glViewport@16 + wglChoosePixelFormat = wglChoosePixelFormat@8 + wglCopyContext = wglCopyContext@12 + wglCreateContext = wglCreateContext@4 + wglCreateLayerContext = wglCreateLayerContext@8 + wglDeleteContext = wglDeleteContext@4 + wglDescribeLayerPlane = wglDescribeLayerPlane@20 + wglDescribePixelFormat = wglDescribePixelFormat@16 + wglGetCurrentContext = wglGetCurrentContext@0 + wglGetCurrentDC = wglGetCurrentDC@0 +; wglGetDefaultProcAddress = wglGetDefaultProcAddress@4 + wglGetLayerPaletteEntries = wglGetLayerPaletteEntries@20 + wglGetPixelFormat = wglGetPixelFormat@4 + wglGetProcAddress = wglGetProcAddress@4 + wglMakeCurrent = wglMakeCurrent@8 + wglRealizeLayerPalette = wglRealizeLayerPalette@12 + wglSetLayerPaletteEntries = wglSetLayerPaletteEntries@20 + wglSetPixelFormat = wglSetPixelFormat@12 + wglShareLists = wglShareLists@8 + wglSwapBuffers = wglSwapBuffers@4 + wglSwapLayerBuffers = wglSwapLayerBuffers@8 +; wglSwapMultipleBuffers = wglSwapMultipleBuffers@8 + wglUseFontBitmapsA = wglUseFontBitmapsA@16 + wglUseFontBitmapsW = wglUseFontBitmapsW@16 + wglUseFontOutlinesA = wglUseFontOutlinesA@32 + wglUseFontOutlinesW = wglUseFontOutlinesW@32 + DrvCopyContext = DrvCopyContext@12 + DrvCreateContext = DrvCreateContext@4 + DrvCreateLayerContext = DrvCreateLayerContext@8 + DrvDeleteContext = DrvDeleteContext@4 + DrvDescribeLayerPlane = DrvDescribeLayerPlane@20 + DrvDescribePixelFormat = DrvDescribePixelFormat@16 + DrvGetLayerPaletteEntries = DrvGetLayerPaletteEntries@20 + DrvGetProcAddress = DrvGetProcAddress@4 + DrvRealizeLayerPalette = DrvRealizeLayerPalette@12 + DrvReleaseContext = DrvReleaseContext@4 + DrvSetCallbackProcs = DrvSetCallbackProcs@8 + DrvSetContext = DrvSetContext@12 + DrvSetLayerPaletteEntries = DrvSetLayerPaletteEntries@20 + DrvSetPixelFormat = DrvSetPixelFormat@8 + DrvShareLists = DrvShareLists@8 + DrvSwapBuffers = DrvSwapBuffers@4 + DrvSwapLayerBuffers = DrvSwapLayerBuffers@8 + DrvValidateVersion = DrvValidateVersion@4 diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c index 2abf97b5adb..d77daac39cd 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.c +++ b/src/gallium/state_trackers/wgl/shared/stw_context.c @@ -40,26 +40,38 @@ #include "stw_public.h" #include "stw_context.h" -static struct stw_context *ctx_head = NULL; - static HDC current_hdc = NULL; -static struct stw_context *current_hrc = NULL; +static UINT_PTR current_hglrc = 0; BOOL stw_copy_context( - struct stw_context *src, - struct stw_context *dst, + UINT_PTR hglrcSrc, + UINT_PTR hglrcDst, UINT mask ) { - (void) src; - (void) dst; - (void) mask; + struct stw_context *src; + struct stw_context *dst; + BOOL ret = FALSE; + + pipe_mutex_lock( stw_dev->mutex ); + + src = stw_lookup_context( hglrcSrc ); + dst = stw_lookup_context( hglrcDst ); + + if (src && dst) { + /* FIXME */ + (void) src; + (void) dst; + (void) mask; + } - return FALSE; + pipe_mutex_unlock( stw_dev->mutex ); + + return ret; } -struct stw_context * -stw_create_context( +UINT_PTR +stw_create_layer_context( HDC hdc, int iLayerPlane ) { @@ -68,19 +80,23 @@ stw_create_context( struct stw_context *ctx = NULL; GLvisual *visual = NULL; struct pipe_context *pipe = NULL; + UINT_PTR hglrc = 0; + if(!stw_dev) + return 0; + if (iLayerPlane != 0) - return NULL; + return 0; pfi = stw_pixelformat_get( hdc ); if (pfi == 0) - return NULL; + return 0; pf = pixelformat_get_info( pfi - 1 ); ctx = CALLOC_STRUCT( stw_context ); if (ctx == NULL) - return NULL; + return 0; ctx->hdc = hdc; ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL ); @@ -119,10 +135,26 @@ stw_create_context( ctx->st->ctx->DriverCtx = ctx; - ctx->next = ctx_head; - ctx_head = ctx; + pipe_mutex_lock( stw_dev->mutex ); + { + UINT_PTR i; + + for (i = 0; i < STW_CONTEXT_MAX; i++) { + if (stw_dev->ctx_array[i].ctx == NULL) { + /* success: + */ + stw_dev->ctx_array[i].ctx = ctx; + hglrc = i + 1; + break; + } + } + } + pipe_mutex_unlock( stw_dev->mutex ); - return ctx; + /* Success? + */ + if (hglrc != 0) + return hglrc; fail: if (visual) @@ -132,47 +164,83 @@ fail: pipe->destroy( pipe ); FREE( ctx ); - return NULL; + return 0; } - BOOL stw_delete_context( - struct stw_context *hglrc ) + UINT_PTR hglrc ) { - struct stw_context **link = &ctx_head; - struct stw_context *ctx = ctx_head; + struct stw_context *ctx ; + BOOL ret = FALSE; + + if (!stw_dev) + return FALSE; - while (ctx != NULL) { - if (ctx == hglrc) { - GLcontext *glctx = ctx->st->ctx; - GET_CURRENT_CONTEXT( glcurctx ); - struct stw_framebuffer *fb; + pipe_mutex_lock( stw_dev->mutex ); - /* Unbind current if deleting current context. - */ - if (glcurctx == glctx) - st_make_current( NULL, NULL, NULL ); + ctx = stw_lookup_context(hglrc); + if (ctx) { + GLcontext *glctx = ctx->st->ctx; + GET_CURRENT_CONTEXT( glcurctx ); + struct stw_framebuffer *fb; - fb = framebuffer_from_hdc( ctx->hdc ); - if (fb) - framebuffer_destroy( fb ); + /* Unbind current if deleting current context. + */ + if (glcurctx == glctx) + st_make_current( NULL, NULL, NULL ); - if (WindowFromDC( ctx->hdc ) != NULL) - ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc ); + fb = framebuffer_from_hdc( ctx->hdc ); + if (fb) + framebuffer_destroy( fb ); - st_destroy_context( ctx->st ); + if (WindowFromDC( ctx->hdc ) != NULL) + ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc ); - *link = ctx->next; - FREE( ctx ); - return TRUE; - } + st_destroy_context( ctx->st ); - link = &ctx->next; - ctx = ctx->next; + FREE( ctx ); + + stw_dev->ctx_array[hglrc - 1].ctx = NULL; + + ret = TRUE; } - return FALSE; + pipe_mutex_unlock( stw_dev->mutex ); + + return ret; +} + +BOOL +stw_release_context( + UINT_PTR hglrc ) +{ + BOOL ret = FALSE; + + if (!stw_dev) + return ret; + + pipe_mutex_lock( stw_dev->mutex ); + { + struct stw_context *ctx; + + /* XXX: The expectation is that ctx is the same context which is + * current for this thread. We should check that and return False + * if not the case. + */ + ctx = stw_lookup_context( hglrc ); + if (ctx == NULL) + goto done; + + if (stw_make_current( NULL, 0 ) == FALSE) + goto done; + + ret = TRUE; + } +done: + pipe_mutex_unlock( stw_dev->mutex ); + + return ret; } /* Find the width and height of the window named by hdc. @@ -193,10 +261,10 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height ) } } -struct stw_context * +UINT_PTR stw_get_current_context( void ) { - return current_hrc; + return current_hglrc; } HDC @@ -208,35 +276,43 @@ stw_get_current_dc( void ) BOOL stw_make_current( HDC hdc, - struct stw_context *hglrc ) + UINT_PTR hglrc ) { - struct stw_context *ctx = ctx_head; + struct stw_context *ctx; GET_CURRENT_CONTEXT( glcurctx ); struct stw_framebuffer *fb; GLuint width = 0; GLuint height = 0; + struct stw_context *curctx; + + if (!stw_dev) + return FALSE; + + pipe_mutex_lock( stw_dev->mutex ); + ctx = stw_lookup_context( hglrc ); + pipe_mutex_unlock( stw_dev->mutex ); + + if (ctx == NULL) + return FALSE; current_hdc = hdc; - current_hrc = hglrc; + current_hglrc = hglrc; - if (hdc == NULL || hglrc == NULL) { - st_make_current( NULL, NULL, NULL ); - return TRUE; + if (glcurctx != NULL) { + curctx = (struct stw_context *) glcurctx->DriverCtx; + + if (curctx != ctx) + st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); } - while (ctx != NULL) { - if (ctx == hglrc) - break; - ctx = ctx->next; + if (hdc == NULL || hglrc == 0) { + st_make_current( NULL, NULL, NULL ); + return TRUE; } - if (ctx == NULL) - return FALSE; /* Return if already current. */ if (glcurctx != NULL) { - struct stw_context *curctx = (struct stw_context *) glcurctx->DriverCtx; - if (curctx != NULL && curctx == ctx && ctx->hdc == hdc) return TRUE; } @@ -273,20 +349,3 @@ stw_make_current( return TRUE; } - -struct stw_context * -stw_context_from_hdc( - HDC hdc ) -{ - struct stw_context *ctx = ctx_head; - - while (ctx != NULL) { - if (ctx->hdc == hdc) - return ctx; - ctx = ctx->next; - } - return NULL; -} - - - diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h index 89a8f900d81..b2896152724 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_context.h +++ b/src/gallium/state_trackers/wgl/shared/stw_context.h @@ -37,17 +37,6 @@ struct stw_context struct st_context *st; HDC hdc; DWORD color_bits; - struct stw_context *next; }; -struct stw_context * -stw_context_from_hdc(HDC hdc ); - - - - - - - - #endif /* STW_CONTEXT_H */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 6873e813ee3..0dca856d73b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -27,14 +27,19 @@ #include <windows.h> -#include "pipe/p_debug.h" +#include "glapi/glthread.h" +#include "util/u_debug.h" #include "pipe/p_screen.h" #include "shared/stw_device.h" #include "shared/stw_winsys.h" #include "shared/stw_pixelformat.h" #include "shared/stw_public.h" -#include "stw.h" + +#ifdef WIN32_THREADS +extern _glthread_Mutex OneTimeLock; +extern void FreeAllTSD(void); +#endif struct stw_device *stw_dev = NULL; @@ -57,23 +62,35 @@ st_flush_frontbuffer(struct pipe_screen *screen, boolean -stw_shared_init(const struct stw_winsys *stw_winsys) +st_init(const struct stw_winsys *stw_winsys) { static struct stw_device stw_dev_storage; + debug_printf("%s\n", __FUNCTION__); + assert(!stw_dev); stw_dev = &stw_dev_storage; memset(stw_dev, 0, sizeof(*stw_dev)); +#ifdef DEBUG + stw_dev->memdbg_no = debug_memory_begin(); +#endif + stw_dev->stw_winsys = stw_winsys; +#ifdef WIN32_THREADS + _glthread_INIT_MUTEX(OneTimeLock); +#endif + stw_dev->screen = stw_winsys->create_screen(); if(!stw_dev->screen) goto error1; stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer; + pipe_mutex_init( stw_dev->mutex ); + pixelformat_init(); return TRUE; @@ -85,7 +102,51 @@ error1: void -stw_shared_cleanup(void) +st_cleanup(void) { + UINT_PTR i; + + debug_printf("%s\n", __FUNCTION__); + + if (!stw_dev) + return; + + pipe_mutex_lock( stw_dev->mutex ); + { + /* Ensure all contexts are destroyed */ + for (i = 0; i < STW_CONTEXT_MAX; i++) + if (stw_dev->ctx_array[i].ctx) + stw_delete_context( i + 1 ); + } + pipe_mutex_unlock( stw_dev->mutex ); + + pipe_mutex_destroy( stw_dev->mutex ); + + stw_dev->screen->destroy(stw_dev->screen); + +#ifdef WIN32_THREADS + _glthread_DESTROY_MUTEX(OneTimeLock); + FreeAllTSD(); +#endif + +#ifdef DEBUG + debug_memory_end(stw_dev->memdbg_no); +#endif + stw_dev = NULL; } + + +struct stw_context * +stw_lookup_context( UINT_PTR dhglrc ) +{ + if (dhglrc == 0 || + dhglrc >= STW_CONTEXT_MAX) + return NULL; + + if (stw_dev == NULL) + return NULL; + + return stw_dev->ctx_array[dhglrc - 1].ctx; +} + diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h index bc0bce37c6e..80da14b84f4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.h +++ b/src/gallium/state_trackers/wgl/shared/stw_device.h @@ -25,8 +25,15 @@ * **************************************************************************/ -#ifndef ST_DEVICE_H_ -#define ST_DEVICE_H_ +#ifndef STW_DEVICE_H_ +#define STW_DEVICE_H_ + + +#include "pipe/p_compiler.h" +#include "pipe/p_thread.h" + + +#define STW_CONTEXT_MAX 32 struct pipe_screen; @@ -35,10 +42,22 @@ struct stw_device { const struct stw_winsys *stw_winsys; struct pipe_screen *screen; + + pipe_mutex mutex; + + struct { + struct stw_context *ctx; + } ctx_array[STW_CONTEXT_MAX]; + +#ifdef DEBUG + unsigned long memdbg_no; +#endif }; +struct stw_context * +stw_lookup_context( UINT_PTR hglrc ); extern struct stw_device *stw_dev; -#endif /* ST_DEVICE_H_ */ +#endif /* STW_DEVICE_H_ */ diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index c70b31a4881..17c96c411f7 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -79,6 +79,14 @@ window_proc( return CallWindowProc( fb->WndProc, hWnd, uMsg, wParam, lParam ); } +static INLINE boolean +stw_is_supported_depth_stencil(enum pipe_format format) +{ + struct pipe_screen *screen = stw_dev->screen; + return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + /* Create a new framebuffer object which will correspond to the given HDC. */ struct stw_framebuffer * @@ -101,18 +109,43 @@ framebuffer_create( if (visual->depthBits == 0) depthFormat = PIPE_FORMAT_NONE; - else if (visual->depthBits <= 16) + else if (visual->depthBits <= 16 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z16_UNORM)) depthFormat = PIPE_FORMAT_Z16_UNORM; - else if (visual->depthBits <= 24) + else if (visual->depthBits <= 24 && visual->stencilBits != 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_X8Z24_UNORM)) { + depthFormat = PIPE_FORMAT_X8Z24_UNORM; + } + else if (visual->depthBits <= 24 && visual->stencilBits != 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z24X8_UNORM)) { + depthFormat = PIPE_FORMAT_Z24X8_UNORM; + } + else if (visual->depthBits <= 24 && visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_S8Z24_UNORM)) { depthFormat = PIPE_FORMAT_S8Z24_UNORM; - else + } + else if (visual->depthBits <= 24 && visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z24S8_UNORM)) { + depthFormat = PIPE_FORMAT_Z24S8_UNORM; + } + else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_UNORM)) { depthFormat = PIPE_FORMAT_Z32_UNORM; + } + else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_FLOAT)) { + depthFormat = PIPE_FORMAT_Z32_FLOAT; + } + else { + assert(0); + depthFormat = PIPE_FORMAT_NONE; + } - if (visual->stencilBits == 8) { - if (depthFormat == PIPE_FORMAT_S8Z24_UNORM) - stencilFormat = depthFormat; - else - stencilFormat = PIPE_FORMAT_S8_UNORM; + if (depthFormat == PIPE_FORMAT_S8Z24_UNORM || + depthFormat == PIPE_FORMAT_Z24S8_UNORM) { + stencilFormat = depthFormat; + } + else if (visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_S8_UNORM)) { + stencilFormat = PIPE_FORMAT_S8_UNORM; } else { stencilFormat = PIPE_FORMAT_NONE; diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 84b7b287b91..2992a1ac0a1 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -25,7 +25,7 @@ * **************************************************************************/ -#include "pipe/p_debug.h" +#include "util/u_debug.h" #include "stw_pixelformat.h" #include "stw_public.h" @@ -76,6 +76,18 @@ add_standard_pixelformats( pf->flags = flags; pf->color = color24; + pf->alpha = alpha8; + pf->depth = depth16; + pf++; + + pf->flags = flags; + pf->color = color24; + pf->alpha = alpha8; + pf->depth = depth24s8; + pf++; + + pf->flags = flags; + pf->color = color24; pf->alpha = noalpha; pf->depth = depth16; pf++; diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h index 75b504a50f6..39d377c16b5 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_public.h +++ b/src/gallium/state_trackers/wgl/shared/stw_public.h @@ -29,31 +29,24 @@ #define STW_PUBLIC_H #include <windows.h> -#include "pipe/p_compiler.h" -struct stw_winsys; -struct stw_context; - -boolean -st_shared_init(const struct stw_winsys *stw_winsys); - -void -st_shared_cleanup(void); - - -BOOL stw_copy_context( struct stw_context *src, - struct stw_context *dst, +BOOL stw_copy_context( UINT_PTR hglrcSrc, + UINT_PTR hglrcDst, UINT mask ); -struct stw_context *stw_create_context( HDC hdc, int iLayerPlane ); +UINT_PTR stw_create_layer_context( HDC hdc, + int iLayerPlane ); + +BOOL stw_delete_context( UINT_PTR hglrc ); -BOOL stw_delete_context( struct stw_context *ctx ); +BOOL +stw_release_context( UINT_PTR dhglrc ); -struct stw_context *stw_get_current_context( void ); +UINT_PTR stw_get_current_context( void ); HDC stw_get_current_dc( void ); -BOOL stw_make_current( HDC hdc, struct stw_context *ctx ); +BOOL stw_make_current( HDC hdc, UINT_PTR hglrc ); BOOL stw_swap_buffers( HDC hdc ); diff --git a/src/gallium/state_trackers/wgl/shared/stw_quirks.c b/src/gallium/state_trackers/wgl/shared/stw_quirks.c index 0961ce3bb0e..2f7091a52c0 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_quirks.c +++ b/src/gallium/state_trackers/wgl/shared/stw_quirks.c @@ -111,3 +111,6 @@ void gl_dispatch_stub_770(void){} void gl_dispatch_stub_771(void){} void gl_dispatch_stub_772(void){} void gl_dispatch_stub_773(void){} +void gl_dispatch_stub_774(void){} +void gl_dispatch_stub_750(void){} +void gl_dispatch_stub_742(void){} diff --git a/src/gallium/state_trackers/wgl/stw.c b/src/gallium/state_trackers/wgl/stw.c deleted file mode 100644 index 8bccdad2211..00000000000 --- a/src/gallium/state_trackers/wgl/stw.c +++ /dev/null @@ -1,57 +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 TUNGSTEN GRAPHICS 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. - * - **************************************************************************/ - -#include "stw.h" -#include "shared/stw_winsys.h" - -boolean -st_init(const struct stw_winsys *stw_winsys) -{ - if (!stw_shared_init( stw_winsys )) - goto fail; - - if (!stw_icd_init()) - goto fail; - - if (!stw_wgl_init()) - goto fail; - - return TRUE; - -fail: - st_cleanup(); - return FALSE; -} - - -void -st_cleanup(void) -{ - stw_icd_cleanup(); - stw_shared_cleanup(); - stw_wgl_cleanup(); -} diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index f50b79b4e11..e06d2640b47 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -27,25 +27,9 @@ #include <windows.h> -#include "pipe/p_debug.h" +#include "util/u_debug.h" #include "shared/stw_public.h" #include "stw_wgl.h" -#include "stw.h" - -boolean stw_wgl_init( void ) -{ - debug_printf("%s\n", __FUNCTION__); - return TRUE; -} - -void stw_wgl_cleanup( void ) -{ -} - -static INLINE struct stw_context *stw_context( HGLRC hglrc ) -{ - return (struct stw_context *)hglrc; -} WINGDIAPI BOOL APIENTRY @@ -54,8 +38,8 @@ wglCopyContext( HGLRC hglrcDst, UINT mask ) { - return stw_copy_context( stw_context(hglrcSrc), - stw_context(hglrcDst), + return stw_copy_context( (UINT_PTR)hglrcSrc, + (UINT_PTR)hglrcDst, mask ); } @@ -63,7 +47,7 @@ WINGDIAPI HGLRC APIENTRY wglCreateContext( HDC hdc ) { - return (HGLRC) stw_create_context( hdc, 0 ); + return wglCreateLayerContext(hdc, 0); } WINGDIAPI HGLRC APIENTRY @@ -71,21 +55,21 @@ wglCreateLayerContext( HDC hdc, int iLayerPlane ) { - return (HGLRC) stw_create_context( hdc, iLayerPlane ); + return (HGLRC) stw_create_layer_context( hdc, iLayerPlane ); } WINGDIAPI BOOL APIENTRY wglDeleteContext( HGLRC hglrc ) { - return stw_delete_context( stw_context(hglrc) ); + return stw_delete_context( (UINT_PTR)hglrc ); } WINGDIAPI HGLRC APIENTRY wglGetCurrentContext( VOID ) { - return (HGLRC) stw_get_current_context(); + return (HGLRC)stw_get_current_context(); } WINGDIAPI HDC APIENTRY @@ -99,7 +83,7 @@ wglMakeCurrent( HDC hdc, HGLRC hglrc ) { - return stw_make_current( hdc, stw_context(hglrc) ); + return stw_make_current( hdc, (UINT_PTR)hglrc ); } diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.h b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h index b86cc240f28..a98179944aa 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.h +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h @@ -31,7 +31,7 @@ #include <windows.h> -#include "GL/gl.h" +#include <GL/gl.h> /* diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile new file mode 100644 index 00000000000..a00ea3e2a4e --- /dev/null +++ b/src/gallium/state_trackers/xorg/Makefile @@ -0,0 +1,29 @@ +TARGET = libxorgtracker.a +CFILES = $(wildcard ./*.c) +OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) +GALLIUMDIR = ../.. +TOP = ../../../.. + +include $(TOP)/configs/current + +CFLAGS = -DHAVE_CONFIG_H \ + -g -Wall -Wimplicit-function-declaration -fPIC \ + $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \ + -I$(GALLIUMDIR)/include \ + -I$(GALLIUMDIR)/auxiliary \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa \ + -I$(TOP)/include \ + -I$(TOP)/src/egl/main + +############################################# + +.PHONY = all clean + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + ar rcs $(TARGET) $(OBJECTS) + +clean: + rm -rf $(OBJECTS) $(TARGET) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c new file mode 100644 index 00000000000..7304113a659 --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -0,0 +1,314 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + +#include <unistd.h> +#include <string.h> +#include <assert.h> +#include <stdlib.h> +#include <math.h> +#include <stdint.h> + +#include "xorg-server.h" +#include <xf86.h> +#include <xf86i2c.h> +#include <xf86Crtc.h> +#include "xorg_tracker.h" +#include "xf86Modes.h" + +#define DPMS_SERVER +#include <X11/extensions/dpms.h> + +#include "pipe/p_inlines.h" + +struct crtc_private +{ + drmModeCrtcPtr drm_crtc; + + /* hwcursor */ + struct pipe_buffer *cursor_buf; + unsigned cursor_handle; +}; + +static void +crtc_dpms(xf86CrtcPtr crtc, int mode) +{ + //ScrnInfoPtr pScrn = crtc->scrn; + + switch (mode) { + case DPMSModeOn: + case DPMSModeStandby: + case DPMSModeSuspend: + break; + case DPMSModeOff: + break; + } +} + +static Bool +crtc_lock(xf86CrtcPtr crtc) +{ + return FALSE; +} + +static void +crtc_unlock(xf86CrtcPtr crtc) +{ +} + +static void +crtc_prepare(xf86CrtcPtr crtc) +{ +} + +static void +crtc_commit(xf86CrtcPtr crtc) +{ +} + +static Bool +crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, + DisplayModePtr adjusted_mode) +{ + return TRUE; +} + +static void +crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, + DisplayModePtr adjusted_mode, int x, int y) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + modesettingPtr ms = modesettingPTR(crtc->scrn); + xf86OutputPtr output = config->output[config->compat_output]; + drmModeConnectorPtr drm_connector = output->driver_private; + struct crtc_private *crtcp = crtc->driver_private; + drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; + drmModeModeInfo drm_mode; + + drm_mode.clock = mode->Clock; + drm_mode.hdisplay = mode->HDisplay; + drm_mode.hsync_start = mode->HSyncStart; + drm_mode.hsync_end = mode->HSyncEnd; + drm_mode.htotal = mode->HTotal; + drm_mode.vdisplay = mode->VDisplay; + drm_mode.vsync_start = mode->VSyncStart; + drm_mode.vsync_end = mode->VSyncEnd; + drm_mode.vtotal = mode->VTotal; + drm_mode.flags = mode->Flags; + drm_mode.hskew = mode->HSkew; + drm_mode.vscan = mode->VScan; + drm_mode.vrefresh = mode->VRefresh; + if (!mode->name) + xf86SetModeDefaultName(mode); + strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN); + + drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, + &drm_connector->connector_id, 1, &drm_mode); +} + +#if 0 +static void +crtc_load_lut(xf86CrtcPtr crtc) +{ + //ScrnInfoPtr pScrn = crtc->scrn; +} +#endif + +static void +crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, + int size) +{ +} + +static void * +crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) +{ + //ScrnInfoPtr pScrn = crtc->scrn; + + return NULL; +} + +static PixmapPtr +crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) +{ + //ScrnInfoPtr pScrn = crtc->scrn; + + return NULL; +} + +static void +crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) +{ + //ScrnInfoPtr pScrn = crtc->scrn; +} + +static void +crtc_destroy(xf86CrtcPtr crtc) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + if (crtcp->cursor_buf) + pipe_buffer_reference(&crtcp->cursor_buf, NULL); + + drmModeFreeCrtc(crtcp->drm_crtc); + xfree(crtcp); +} + +static void +crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) +{ + unsigned char *ptr; + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + if (!crtcp->cursor_buf) { + crtcp->cursor_buf = pipe_buffer_create(ms->screen, + 0, + PIPE_BUFFER_USAGE_CPU_WRITE | + PIPE_BUFFER_USAGE_GPU_READ, + 64*64*4); + drm_api_hooks.handle_from_buffer(ms->screen, + crtcp->cursor_buf, + &crtcp->cursor_handle); + } + + ptr = pipe_buffer_map(ms->screen, crtcp->cursor_buf, PIPE_BUFFER_USAGE_CPU_WRITE); + + if (ptr) + memcpy(ptr, image, 64 * 64 * 4); + + pipe_buffer_unmap(ms->screen, crtcp->cursor_buf); +} + +static void +crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); +} + +static void +crtc_show_cursor(xf86CrtcPtr crtc) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + if (crtcp->cursor_buf) + drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, + crtcp->cursor_handle, 64, 64); +} + +static void +crtc_hide_cursor(xf86CrtcPtr crtc) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0); +} + +static const xf86CrtcFuncsRec crtc_funcs = { + .dpms = crtc_dpms, + .save = NULL, + .restore = NULL, + .lock = crtc_lock, + .unlock = crtc_unlock, + .mode_fixup = crtc_mode_fixup, + .prepare = crtc_prepare, + .mode_set = crtc_mode_set, + .commit = crtc_commit, + .gamma_set = crtc_gamma_set, + .shadow_create = crtc_shadow_create, + .shadow_allocate = crtc_shadow_allocate, + .shadow_destroy = crtc_shadow_destroy, + .set_cursor_position = crtc_set_cursor_position, + .show_cursor = crtc_show_cursor, + .hide_cursor = crtc_hide_cursor, + .load_cursor_image = NULL, /* lets convert to argb only */ + .set_cursor_colors = NULL, /* using argb only */ + .load_cursor_argb = crtc_load_cursor_argb, + .destroy = crtc_destroy, +}; + +void +cursor_destroy(xf86CrtcPtr crtc) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; + + if (crtcp->cursor_buf) { + pipe_buffer_reference(&crtcp->cursor_buf, NULL); + } +} + +void +crtc_init(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + xf86CrtcPtr crtc; + drmModeResPtr res; + drmModeCrtcPtr drm_crtc = NULL; + struct crtc_private *crtcp; + int c; + + res = drmModeGetResources(ms->fd); + if (res == 0) { + ErrorF("Failed drmModeGetResources %d\n", errno); + return; + } + + for (c = 0; c < res->count_crtcs; c++) { + drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); + if (!drm_crtc) + continue; + + crtc = xf86CrtcCreate(pScrn, &crtc_funcs); + if (crtc == NULL) + goto out; + + crtcp = xcalloc(1, sizeof(struct crtc_private)); + if (!crtcp) { + xf86CrtcDestroy(crtc); + goto out; + } + + crtcp->drm_crtc = drm_crtc; + + crtc->driver_private = crtcp; + + } + + out: + drmModeFreeResources(res); +} + +/* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c new file mode 100644 index 00000000000..d04204e1bfd --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -0,0 +1,212 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "xorg_tracker.h" + +#include "dri2.h" + +#include "pipe/p_state.h" +#include "pipe/p_inlines.h" + +typedef struct { + PixmapPtr pPixmap; + struct pipe_texture *tex; + struct pipe_buffer *buf; +} *BufferPrivatePtr; + +static DRI2BufferPtr +driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count) +{ + struct pipe_texture *depth, *tex; + struct pipe_buffer *buf; + ScreenPtr pScreen = pDraw->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + BufferPrivatePtr privates; + DRI2BufferPtr buffers; + PixmapPtr pPixmap; + unsigned stride, handle; + int i; + + buffers = xcalloc(count, sizeof *buffers); + if (!buffers) + goto fail_buffers; + + privates = xcalloc(count, sizeof *privates); + if (!privates) + goto fail_privates; + + depth = NULL; + for (i = 0; i < count; i++) { + pPixmap = NULL; + tex = NULL; + buf = NULL; + if (attachments[i] == DRI2BufferFrontLeft) { + if (pDraw->type == DRAWABLE_PIXMAP) + pPixmap = (PixmapPtr) pDraw; + else + pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw); + pPixmap->refcnt++; + tex = xorg_exa_get_texture(pPixmap); + } else if (attachments[i] == DRI2BufferStencil) { + pipe_texture_reference(&tex, depth); + } else if (attachments[i] == DRI2BufferDepth) { + struct pipe_texture template; + + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + template.compressed = 0; + template.format = PIPE_FORMAT_S8Z24_UNORM; + pf_get_block(template.format, &template.block); + template.width[0] = pDraw->width; + template.height[0] = pDraw->height; + template.depth[0] = 1; + template.last_level = 0; + template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + tex = ms->screen->texture_create(ms->screen, &template); + } else { + struct pipe_texture template; + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + template.compressed = 0; + template.format = PIPE_FORMAT_A8R8G8B8_UNORM; + pf_get_block(template.format, &template.block); + template.width[0] = pDraw->width; + template.height[0] = pDraw->height; + template.depth[0] = 1; + template.last_level = 0; + template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + tex = ms->screen->texture_create(ms->screen, &template); + } + + drm_api_hooks.buffer_from_texture(tex, &buf, &stride); + drm_api_hooks.global_handle_from_buffer(ms->screen, buf, &handle); + + buffers[i].name = handle; + buffers[i].attachment = attachments[i]; + buffers[i].pitch = stride; + buffers[i].cpp = 4; + buffers[i].driverPrivate = &privates[i]; + buffers[i].flags = 0; /* not tiled */ + privates[i].pPixmap = pPixmap; + privates[i].buf = buf; + privates[i].tex = tex; + } + + return buffers; + +fail_privates: + xfree(buffers); +fail_buffers: + return NULL; +} + +static void +driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count) +{ + ScreenPtr pScreen = pDraw->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + BufferPrivatePtr private; + int i; + + for (i = 0; i < count; i++) { + private = buffers[i].driverPrivate; + + if (private->pPixmap) + (*pScreen->DestroyPixmap)(private->pPixmap); + + pipe_texture_reference(&private->tex, NULL); + pipe_buffer_reference(&private->buf, NULL); + } + + if (buffers) { + xfree(buffers[0].driverPrivate); + xfree(buffers); + } +} + +static void +driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion, + DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer) +{ + ScreenPtr pScreen = pDraw->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + BufferPrivatePtr dst_priv = pDestBuffer->driverPrivate; + BufferPrivatePtr src_priv = pSrcBuffer->driverPrivate; + + struct pipe_surface *dst_surf = + ms->screen->get_tex_surface(ms->screen, dst_priv->tex, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_WRITE); + struct pipe_surface *src_surf = + ms->screen->get_tex_surface(ms->screen, src_priv->tex, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ); + + ms->ctx->surface_copy(ms->ctx, dst_surf, 0, 0, src_surf, + 0, 0, pDraw->width, pDraw->height); + + pipe_surface_reference(&dst_surf, NULL); + pipe_surface_reference(&src_surf, NULL); +} + +Bool +driScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + DRI2InfoRec dri2info; + + dri2info.version = 1; + dri2info.fd = ms->fd; +#if 0 + dri2info.driverName = pScrn->name; +#else + dri2info.driverName = "i915"; /* FIXME */ +#endif + dri2info.deviceName = "/dev/dri/card0"; /* FIXME */ + + dri2info.CreateBuffers = driCreateBuffers; + dri2info.DestroyBuffers = driDestroyBuffers; + dri2info.CopyRegion = driCopyRegion; + + return DRI2ScreenInit(pScreen, &dri2info); +} + +void +driCloseScreen(ScreenPtr pScreen) +{ + DRI2CloseScreen(pScreen); +} + +/* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c new file mode 100644 index 00000000000..8a2711e70cd --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -0,0 +1,695 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + + +#include "xorg-server.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#include "xf86RAC.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86Resources.h" +#include "mipointer.h" +#include "micmap.h" +#include <X11/extensions/randr.h> +#include "fb.h" +#include "edid.h" +#include "xf86i2c.h" +#include "xf86Crtc.h" +#include "miscstruct.h" +#include "dixstruct.h" +#include "xf86xv.h" +#include <X11/extensions/Xv.h> +#ifndef XSERVER_LIBPCIACCESS +#error "libpciaccess needed" +#endif + +#include <pciaccess.h> + +#include "xorg_tracker.h" +#include "xorg_winsys.h" + +static void AdjustFrame(int scrnIndex, int x, int y, int flags); +static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool EnterVT(int scrnIndex, int flags); +static Bool SaveHWState(ScrnInfoPtr pScrn); +static Bool RestoreHWState(ScrnInfoPtr pScrn); + + +static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, + int flags); +static void FreeScreen(int scrnIndex, int flags); +static void LeaveVT(int scrnIndex, int flags); +static Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv); +static Bool PreInit(ScrnInfoPtr pScrn, int flags); + +typedef enum +{ + OPTION_SW_CURSOR, +} modesettingOpts; + +static const OptionInfoRec Options[] = { + {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} +}; + +/* + * Functions that might be needed + */ + +static const char *exaSymbols[] = { + "exaGetVersion", + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + "exaWaitSync", + NULL +}; + +static const char *fbSymbols[] = { + "fbPictureInit", + "fbScreenInit", + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86SetDDCproperties", + NULL +}; + +/* + * Exported Xorg driver functions to winsys + */ + +void +xorg_tracker_loader_ref_sym_lists() +{ + LoaderRefSymLists(exaSymbols, fbSymbols, ddcSymbols, NULL); +} + +const OptionInfoRec * +xorg_tracker_available_options(int chipid, int busid) +{ + return Options; +} + +void +xorg_tracker_set_functions(ScrnInfoPtr scrn) +{ + scrn->PreInit = PreInit; + scrn->ScreenInit = ScreenInit; + scrn->SwitchMode = SwitchMode; + scrn->AdjustFrame = AdjustFrame; + scrn->EnterVT = EnterVT; + scrn->LeaveVT = LeaveVT; + scrn->FreeScreen = FreeScreen; + scrn->ValidMode = ValidMode; +} + +/* + * Static Xorg funtctions + */ + +static Bool +GetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); + + return TRUE; +} + +static void +FreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn) + return; + + if (!pScrn->driverPrivate) + return; + + xfree(pScrn->driverPrivate); + + pScrn->driverPrivate = NULL; +} + +static void +ProbeDDC(ScrnInfoPtr pScrn, int index) +{ + ConfiguredMonitor = NULL; +} + +static Bool +CreateFrontBuffer(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); + + ms->noEvict = TRUE; + pScreen->ModifyPixmapHeader(rootPixmap, + pScrn->virtualX, pScrn->virtualY, + pScrn->depth, pScrn->bitsPerPixel, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, + NULL); + ms->noEvict = FALSE; + + drmModeAddFB(ms->fd, + pScrn->virtualX, + pScrn->virtualY, + pScrn->depth, + pScrn->bitsPerPixel, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, + xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id); + + pScrn->frameX0 = 0; + pScrn->frameY0 = 0; + AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +static Bool +crtc_resize(ScrnInfoPtr pScrn, int width, int height) +{ + modesettingPtr ms = modesettingPTR(pScrn); + //ScreenPtr pScreen = pScrn->pScreen; + //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); + //Bool fbAccessDisabled; + //CARD8 *fbstart; + + if (width == pScrn->virtualX && height == pScrn->virtualY) + return TRUE; + + ErrorF("RESIZING TO %dx%d\n", width, height); + + pScrn->virtualX = width; + pScrn->virtualY = height; + + /* HW dependent - FIXME */ + pScrn->displayWidth = pScrn->virtualX; + + drmModeRmFB(ms->fd, ms->fb_id); + + /* now create new frontbuffer */ + return CreateFrontBuffer(pScrn); +} + +static const xf86CrtcConfigFuncsRec crtc_config_funcs = { + crtc_resize +}; + +static Bool +PreInit(ScrnInfoPtr pScrn, int flags) +{ + xf86CrtcConfigPtr xf86_config; + modesettingPtr ms; + rgb defaultWeight = { 0, 0, 0 }; + EntityInfoPtr pEnt; + EntPtr msEnt = NULL; + char *BusID; + int max_width, max_height; + + if (pScrn->numEntities != 1) + return FALSE; + + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + + if (flags & PROBE_DETECT) { + ProbeDDC(pScrn, pEnt->index); + return TRUE; + } + + /* Allocate driverPrivate */ + if (!GetRec(pScrn)) + return FALSE; + + ms = modesettingPTR(pScrn); + ms->SaveGeneration = -1; + ms->pEnt = pEnt; + + pScrn->displayWidth = 640; /* default it */ + + if (ms->pEnt->location.type != BUS_PCI) + return FALSE; + + ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); + + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + FatalError("Entity"); +#if 0 + msEnt = xf86GetEntityPrivate(pScrn->entityList[0], + modesettingEntityIndex)->ptr; + ms->entityPrivate = msEnt; +#else + (void)msEnt; +#endif + } else + ms->entityPrivate = NULL; + + if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) { + return FALSE; + } + + if (xf86IsEntityShared(pScrn->entityList[0])) { + if (xf86IsPrimInitDone(pScrn->entityList[0])) { + /* do something */ + } else { + xf86SetPrimInitDone(pScrn->entityList[0]); + } + } + + BusID = xalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), + ms->PciInfo->dev, ms->PciInfo->func + ); + + ms->fd = drmOpen(NULL, BusID); + + if (ms->fd < 0) + return FALSE; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + pScrn->progClock = TRUE; + pScrn->rgbBits = 8; + + if (!xf86SetDepthBpp + (pScrn, 0, 0, 0, + PreferConvert24to32 | SupportConvert24to32 | Support32bppFb)) + return FALSE; + + switch (pScrn->depth) { + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by the driver\n", + pScrn->depth); + return FALSE; + } + xf86PrintDepthBpp(pScrn); + + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) + return FALSE; + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + + /* Process the options */ + xf86CollectOptions(pScrn, NULL); + if (!(ms->Options = xalloc(sizeof(Options)))) + return FALSE; + memcpy(ms->Options, Options, sizeof(Options)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options); + + /* Allocate an xf86CrtcConfig */ + xf86CrtcConfigInit(pScrn, &crtc_config_funcs); + xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + + max_width = 8192; + max_height = 8192; + xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height); + + if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { + ms->SWCursor = TRUE; + } + + SaveHWState(pScrn); + + crtc_init(pScrn); + output_init(pScrn); + + if (!xf86InitialConfiguration(pScrn, TRUE)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); + RestoreHWState(pScrn); + return FALSE; + } + + RestoreHWState(pScrn); + + /* + * If the driver can do gamma correction, it should call xf86SetGamma() here. + */ + { + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } + } + + if (pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n"); + return FALSE; + } + + pScrn->currentMode = pScrn->modes; + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + /* Load the required sub modules */ + if (!xf86LoadSubModule(pScrn, "fb")) { + return FALSE; + } + + xf86LoaderReqSymLists(fbSymbols, NULL); + + xf86LoadSubModule(pScrn, "exa"); + +#ifdef DRI2 + xf86LoadSubModule(pScrn, "dri2"); +#endif + + return TRUE; +} + +static Bool +SaveHWState(ScrnInfoPtr pScrn) +{ + /*xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);*/ + + return TRUE; +} + +static Bool +RestoreHWState(ScrnInfoPtr pScrn) +{ + /*xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);*/ + + return TRUE; +} + +static Bool +CreateScreenResources(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + PixmapPtr rootPixmap; + Bool ret; + + ms->noEvict = TRUE; + + pScreen->CreateScreenResources = ms->createScreenResources; + ret = pScreen->CreateScreenResources(pScreen); + pScreen->CreateScreenResources = CreateScreenResources; + + rootPixmap = pScreen->GetScreenPixmap(pScreen); + + if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) + FatalError("Couldn't adjust screen pixmap\n"); + + ms->noEvict = FALSE; + + drmModeAddFB(ms->fd, + pScrn->virtualX, + pScrn->virtualY, + pScrn->depth, + pScrn->bitsPerPixel, + pScrn->displayWidth * pScrn->bitsPerPixel / 8, + xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id); + + AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return ret; +} + +static Bool +ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + VisualPtr visual; + + /* deal with server regeneration */ + if (ms->fd < 0) { + char *BusID; + + BusID = xalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), + ms->PciInfo->dev, ms->PciInfo->func + ); + + ms->fd = drmOpen(NULL, BusID); + + if (ms->fd < 0) + return FALSE; + } + + if (!ms->screen) { + ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id); + + if (!ms->screen) { + FatalError("Could not init pipe_screen\n"); + return FALSE; + } + } + + pScrn->pScreen = pScreen; + + /* HW dependent - FIXME */ + pScrn->displayWidth = pScrn->virtualX; + + miClearVisualTypes(); + + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + if (!miSetPixmapDepths()) + return FALSE; + + pScrn->memPhysBase = 0; + pScrn->fbOffset = 0; + + if (!fbScreenInit(pScreen, NULL, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return FALSE; + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + fbPictureInit(pScreen, NULL, 0); + + ms->createScreenResources = pScreen->CreateScreenResources; + pScreen->CreateScreenResources = CreateScreenResources; + + xf86SetBlackWhitePixels(pScreen); + + ms->exa = xorg_exa_init(pScrn); + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Need to extend HWcursor support to handle mask interleave */ + if (!ms->SWCursor) + xf86_cursors_init(pScreen, 64, 64, + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 | + HARDWARE_CURSOR_ARGB); + + /* Must force it before EnterVT, so we are in control of VT and + * later memory should be bound when allocating, e.g rotate_mem */ + pScrn->vtSema = TRUE; + + pScreen->SaveScreen = xf86SaveScreen; + ms->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = CloseScreen; + + if (!xf86CrtcScreenInit(pScreen)) + return FALSE; + + if (!miCreateDefColormap(pScreen)) + return FALSE; + + xf86DPMSInit(pScreen, xf86DPMSSet, 0); + + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + +#if 1 +#ifdef DRI2 + driScreenInit(pScreen); +#endif +#endif + + return EnterVT(scrnIndex, 1); +} + +static void +AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86OutputPtr output = config->output[config->compat_output]; + xf86CrtcPtr crtc = output->crtc; + + if (crtc && crtc->enabled) { + crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x, + y); + crtc->x = output->initial_x + x; + crtc->y = output->initial_y + y; + } +} + +static void +FreeScreen(int scrnIndex, int flags) +{ + FreeRec(xf86Screens[scrnIndex]); +} + +/* HACK */ +void +cursor_destroy(xf86CrtcPtr crtc); + +static void +LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int o; + + for (o = 0; o < config->num_crtc; o++) { + xf86CrtcPtr crtc = config->crtc[o]; + + cursor_destroy(crtc); + + if (crtc->rotatedPixmap || crtc->rotatedData) { + crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, + crtc->rotatedData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + } + + drmModeRmFB(ms->fd, ms->fb_id); + + RestoreHWState(pScrn); + + pScrn->vtSema = FALSE; +} + +/* + * This gets called when gaining control of the VT, and from ScreenInit(). + */ +static Bool +EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); + + /* + * Only save state once per server generation since that's what most + * drivers do. Could change this to save state at each VT enter. + */ + if (ms->SaveGeneration != serverGeneration) { + ms->SaveGeneration = serverGeneration; + SaveHWState(pScrn); + } + + if (!flags) /* signals startup as we'll do this in CreateScreenResources */ + CreateFrontBuffer(pScrn); + + if (!xf86SetDesiredModes(pScrn)) + return FALSE; + + return TRUE; +} + +static Bool +SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); +} + +static Bool +CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + modesettingPtr ms = modesettingPTR(pScrn); + + if (pScrn->vtSema) { + LeaveVT(scrnIndex, 0); + } +#ifdef DRI2 + driCloseScreen(pScreen); +#endif + + pScreen->CreateScreenResources = ms->createScreenResources; + + if (ms->exa) + xorg_exa_close(pScrn); + + drmClose(ms->fd); + ms->fd = -1; + + pScrn->vtSema = FALSE; + pScreen->CloseScreen = ms->CloseScreen; + return (*pScreen->CloseScreen) (scrnIndex, pScreen); +} + +static ModeStatus +ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + return MODE_OK; +} + +/* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c new file mode 100644 index 00000000000..56c8fdccb28 --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -0,0 +1,528 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + +#include "xf86.h" +#include "xorg_tracker.h" + +#include "pipe/p_format.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "pipe/p_inlines.h" + +struct exa_entity +{ + ExaDriverPtr pExa; + struct pipe_context *ctx; + struct pipe_screen *scrn; +}; + +struct PixmapPriv +{ + int flags; + struct pipe_texture *tex; + unsigned int color; + struct pipe_surface *src_surf; /* for copies */ + + struct pipe_transfer *map_transfer; + unsigned map_count; +}; + +/* + * Helper functions + */ + +static void +exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) +{ + switch (depth) { + case 32: + *format = PIPE_FORMAT_A8R8G8B8_UNORM; + assert(*bbp == 32); + break; + case 24: + *format = PIPE_FORMAT_X8R8G8B8_UNORM; + assert(*bbp == 32); + break; + case 16: + *format = PIPE_FORMAT_R5G6B5_UNORM; + assert(*bbp == 16); + break; + case 15: + *format = PIPE_FORMAT_A1R5G5B5_UNORM; + assert(*bbp == 16); + break; + case 8: + case 4: + case 1: + *format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */ + break; + default: + assert(0); + break; + } +} + +/* + * Static exported EXA functions + */ + +static void +ExaWaitMarker(ScreenPtr pScreen, int marker) +{ +} + +static int +ExaMarkSync(ScreenPtr pScreen) +{ + return 1; +} + +static Bool +ExaPrepareAccess(PixmapPtr pPix, int index) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + struct PixmapPriv *priv; + + priv = exaGetPixmapDriverPrivate(pPix); + + if (!priv) + return FALSE; + + if (!priv->tex) + return FALSE; + + if (priv->map_count++ == 0) + { + priv->map_transfer = + exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, + PIPE_TRANSFER_READ_WRITE, + 0, 0, priv->tex->width[0], priv->tex->height[0]); + + pPix->devPrivate.ptr = + exa->scrn->transfer_map(exa->scrn, priv->map_transfer); + pPix->devKind = priv->map_transfer->stride; + } + + return TRUE; +} + +static void +ExaFinishAccess(PixmapPtr pPix, int index) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + struct PixmapPriv *priv; + priv = exaGetPixmapDriverPrivate(pPix); + + if (!priv) + return; + + if (!priv->map_transfer) + return; + + if (--priv->map_count == 0) { + assert(priv->map_transfer); + exa->scrn->transfer_unmap(exa->scrn, priv->map_transfer); + exa->scrn->tex_transfer_destroy(priv->map_transfer); + priv->map_transfer = NULL; + } +} + +static void +ExaDone(PixmapPtr pPixmap) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); + struct exa_entity *exa = ms->exa; + + if (!priv) + return; + + if (priv->src_surf) + exa->scrn->tex_surface_destroy(priv->src_surf); + priv->src_surf = NULL; +} + +static void +ExaDoneComposite(PixmapPtr pPixmap) +{ + +} + +static Bool +ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); + struct exa_entity *exa = ms->exa; + + if (1) + return FALSE; + + if (pPixmap->drawable.depth < 15) + return FALSE; + + if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask)) + return FALSE; + + if (!priv || !priv->tex) + return FALSE; + + if (alu != GXcopy) + return FALSE; + + if (!exa->ctx || !exa->ctx->surface_fill) + return FALSE; + + priv->color = fg; + + return TRUE; +} + +static void +ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); + struct pipe_surface *surf = + exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0, + priv->color); + + exa->scrn->tex_surface_destroy(surf); +} + +static Bool +ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, + int ydir, int alu, Pixel planeMask) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap); + struct PixmapPriv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); + + if (1) + return FALSE; + + if (alu != GXcopy) + return FALSE; + + if (pSrcPixmap->drawable.depth < 15 || pDstPixmap->drawable.depth < 15) + return FALSE; + + if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) + return FALSE; + + if (!priv || !src_priv) + return FALSE; + + if (!priv->tex || !src_priv->tex) + return FALSE; + + if (!exa->ctx || !exa->ctx->surface_copy) + return FALSE; + + priv->src_surf = + exa->scrn->get_tex_surface(exa->scrn, src_priv->tex, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + return TRUE; +} + +static void +ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, + int width, int height) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap); + struct pipe_surface *surf = + exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + + exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf, + srcX, srcY, width, height); + exa->scrn->tex_surface_destroy(surf); +} + +static Bool +ExaPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +{ + return FALSE; +} + +static void +ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, + int dstX, int dstY, int width, int height) +{ +} + +static Bool +ExaCheckComposite(int op, + PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + return FALSE; +} + +static void * +ExaCreatePixmap(ScreenPtr pScreen, int size, int align) +{ + struct PixmapPriv *priv; + + priv = xcalloc(1, sizeof(struct PixmapPriv)); + if (!priv) + return NULL; + + return priv; +} + +static void +ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv) +{ + struct PixmapPriv *priv = (struct PixmapPriv *)dPriv; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + + if (!priv) + return; + + if (priv->tex) + ms->screen->texture_destroy(priv->tex); + + xfree(priv); +} + +static Bool +ExaPixmapIsOffscreen(PixmapPtr pPixmap) +{ + struct PixmapPriv *priv; + + priv = exaGetPixmapDriverPrivate(pPixmap); + + if (!priv) + return FALSE; + + if (priv->tex) + return TRUE; + + return FALSE; +} + +unsigned +xorg_exa_get_pixmap_handle(PixmapPtr pPixmap) +{ + ScreenPtr pScreen = pPixmap->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct PixmapPriv *priv; + struct pipe_buffer *buffer = NULL; + unsigned handle; + unsigned stride; + + if (!ms->exa) { + FatalError("NO MS->EXA\n"); + return 0; + } + + priv = exaGetPixmapDriverPrivate(pPixmap); + + if (!priv) { + FatalError("NO PIXMAP PRIVATE\n"); + return 0; + } + + drm_api_hooks.buffer_from_texture(priv->tex, &buffer, &stride); + drm_api_hooks.handle_from_buffer(ms->screen, buffer, &handle); + pipe_buffer_reference(&buffer, NULL); + return handle; +} + +static Bool +ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, + int depth, int bitsPerPixel, int devKind, + pointer pPixData) +{ + ScreenPtr pScreen = pPixmap->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + + if (!priv) + return FALSE; + + if (depth <= 0) + depth = pPixmap->drawable.depth; + + if (bitsPerPixel <= 0) + bitsPerPixel = pPixmap->drawable.bitsPerPixel; + + if (width <= 0) + width = pPixmap->drawable.width; + + if (height <= 0) + height = pPixmap->drawable.height; + + if (width <= 0 || height <= 0 || depth <= 0) + return FALSE; + + miModifyPixmapHeader(pPixmap, width, height, depth, + bitsPerPixel, devKind, NULL); + + /* Deal with screen resize */ + if (priv->tex && (priv->tex->width[0] != width || priv->tex->height[0] != height)) { + pipe_texture_reference(&priv->tex, NULL); + } + + if (!priv->tex) { + struct pipe_texture template; + + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + template.compressed = 0; + exa_get_pipe_format(depth, &template.format, &bitsPerPixel); + pf_get_block(template.format, &template.block); + template.width[0] = width; + template.height[0] = height; + template.depth[0] = 1; + template.last_level = 0; + template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + priv->tex = exa->scrn->texture_create(exa->scrn, &template); + } + + return TRUE; +} + +struct pipe_texture * +xorg_exa_get_texture(PixmapPtr pPixmap) +{ + struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap); + struct pipe_texture *tex = NULL; + pipe_texture_reference(&tex, priv->tex); + return tex; +} + +void +xorg_exa_close(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa = ms->exa; + + if (exa->ctx) + exa->ctx->destroy(exa->ctx); + + exaDriverFini(pScrn->pScreen); + xfree(exa); + ms->exa = NULL; +} + +void * +xorg_exa_init(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_entity *exa; + ExaDriverPtr pExa; + + exa = xcalloc(1, sizeof(struct exa_entity)); + if (!exa) + return NULL; + + pExa = exaDriverAlloc(); + if (!pExa) { + goto out_err; + } + + memset(pExa, 0, sizeof(*pExa)); + pExa->exa_major = 2; + pExa->exa_minor = 2; + pExa->memoryBase = 0; + pExa->memorySize = 0; + pExa->offScreenBase = 0; + pExa->pixmapOffsetAlign = 0; + pExa->pixmapPitchAlign = 1; + pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS; + pExa->maxX = 8191; /* FIXME */ + pExa->maxY = 8191; /* FIXME */ + pExa->WaitMarker = ExaWaitMarker; + pExa->MarkSync = ExaMarkSync; + pExa->PrepareSolid = ExaPrepareSolid; + pExa->Solid = ExaSolid; + pExa->DoneSolid = ExaDone; + pExa->PrepareCopy = ExaPrepareCopy; + pExa->Copy = ExaCopy; + pExa->DoneCopy = ExaDone; + pExa->CheckComposite = ExaCheckComposite; + pExa->PrepareComposite = ExaPrepareComposite; + pExa->Composite = ExaComposite; + pExa->DoneComposite = ExaDoneComposite; + pExa->PixmapIsOffscreen = ExaPixmapIsOffscreen; + pExa->PrepareAccess = ExaPrepareAccess; + pExa->FinishAccess = ExaFinishAccess; + pExa->CreatePixmap = ExaCreatePixmap; + pExa->DestroyPixmap = ExaDestroyPixmap; + pExa->ModifyPixmapHeader = ExaModifyPixmapHeader; + + if (!exaDriverInit(pScrn->pScreen, pExa)) { + goto out_err; + } + + exa->scrn = ms->screen; + exa->ctx = drm_api_hooks.create_context(exa->scrn); + /* Share context with DRI */ + ms->ctx = exa->ctx; + + return (void *)exa; + + out_err: + xorg_exa_close(pScrn); + + return NULL; +} + +/* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c new file mode 100644 index 00000000000..950af942f5b --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -0,0 +1,296 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + +#include "xorg-server.h" +#include <xf86.h> +#include <xf86i2c.h> +#include <xf86Crtc.h> +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> + +#define DPMS_SERVER +#include <X11/extensions/dpms.h> + +#include "X11/Xatom.h" + +#include "xorg_tracker.h" + +static char *connector_enum_list[] = { + "Unknown", + "VGA", + "DVI-I", + "DVI-D", + "DVI-A", + "Composite", + "SVIDEO", + "LVDS", + "Component", + "9-pin DIN", + "DisplayPort", + "HDMI Type A", + "HDMI Type B", +}; + +static void +dpms(xf86OutputPtr output, int mode) +{ +} + +static void +save(xf86OutputPtr output) +{ +} + +static void +restore(xf86OutputPtr output) +{ +} + +static int +mode_valid(xf86OutputPtr output, DisplayModePtr pMode) +{ + return MODE_OK; +} + +static Bool +mode_fixup(xf86OutputPtr output, DisplayModePtr mode, + DisplayModePtr adjusted_mode) +{ + return TRUE; +} + +static void +prepare(xf86OutputPtr output) +{ + dpms(output, DPMSModeOff); +} + +static void +mode_set(xf86OutputPtr output, DisplayModePtr mode, + DisplayModePtr adjusted_mode) +{ +} + +static void +commit(xf86OutputPtr output) +{ + dpms(output, DPMSModeOn); + + if (output->scrn->pScreen != NULL) + xf86_reload_cursors(output->scrn->pScreen); +} + +static xf86OutputStatus +detect(xf86OutputPtr output) +{ + drmModeConnectorPtr drm_connector = output->driver_private; + + switch (drm_connector->connection) { + case DRM_MODE_CONNECTED: + return XF86OutputStatusConnected; + case DRM_MODE_DISCONNECTED: + return XF86OutputStatusDisconnected; + default: + return XF86OutputStatusUnknown; + } +} + +static DisplayModePtr +get_modes(xf86OutputPtr output) +{ + drmModeConnectorPtr drm_connector = output->driver_private; + drmModeModeInfoPtr drm_mode = NULL; + DisplayModePtr modes = NULL, mode = NULL; + int i; + + for (i = 0; i < drm_connector->count_modes; i++) { + drm_mode = &drm_connector->modes[i]; + if (drm_mode) { + mode = xcalloc(1, sizeof(DisplayModeRec)); + if (!mode) + continue; + mode->type = 0; + mode->Clock = drm_mode->clock; + mode->HDisplay = drm_mode->hdisplay; + mode->HSyncStart = drm_mode->hsync_start; + mode->HSyncEnd = drm_mode->hsync_end; + mode->HTotal = drm_mode->htotal; + mode->VDisplay = drm_mode->vdisplay; + mode->VSyncStart = drm_mode->vsync_start; + mode->VSyncEnd = drm_mode->vsync_end; + mode->VTotal = drm_mode->vtotal; + mode->Flags = drm_mode->flags; + mode->HSkew = drm_mode->hskew; + mode->VScan = drm_mode->vscan; + mode->VRefresh = xf86ModeVRefresh(mode); + mode->Private = (void *)drm_mode; + xf86SetModeDefaultName(mode); + modes = xf86ModesAdd(modes, mode); + xf86PrintModeline(0, mode); + } + } + + return modes; +} + +static void +destroy(xf86OutputPtr output) +{ + drmModeFreeConnector(output->driver_private); +} + +static void +create_resources(xf86OutputPtr output) +{ +#ifdef RANDR_12_INTERFACE +#endif /* RANDR_12_INTERFACE */ +} + +#ifdef RANDR_12_INTERFACE +static Bool +set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value) +{ + return TRUE; +} +#endif /* RANDR_12_INTERFACE */ + +#ifdef RANDR_13_INTERFACE +static Bool +get_property(xf86OutputPtr output, Atom property) +{ + return TRUE; +} +#endif /* RANDR_13_INTERFACE */ + +#ifdef RANDR_GET_CRTC_INTERFACE +static xf86CrtcPtr +get_crtc(xf86OutputPtr output) +{ + return NULL; +} +#endif + +static const xf86OutputFuncsRec output_funcs = { + .create_resources = create_resources, + .dpms = dpms, + .save = save, + .restore = restore, + .mode_valid = mode_valid, + .mode_fixup = mode_fixup, + .prepare = prepare, + .mode_set = mode_set, + .commit = commit, + .detect = detect, + .get_modes = get_modes, +#ifdef RANDR_12_INTERFACE + .set_property = set_property, +#endif +#ifdef RANDR_13_INTERFACE + .get_property = get_property, +#endif + .destroy = destroy, +#ifdef RANDR_GET_CRTC_INTERFACE + .get_crtc = get_crtc, +#endif +}; + +void +output_init(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + xf86OutputPtr output; + drmModeResPtr res; + drmModeConnectorPtr drm_connector = NULL; + drmModeEncoderPtr drm_encoder = NULL; + char *name; + int c, v, p; + + res = drmModeGetResources(ms->fd); + if (res == 0) { + DRV_ERROR("Failed drmModeGetResources\n"); + return; + } + + for (c = 0; c < res->count_connectors; c++) { + drm_connector = drmModeGetConnector(ms->fd, res->connectors[c]); + if (!drm_connector) + goto out; + +#if 0 + for (p = 0; p < drm_connector->count_props; p++) { + drmModePropertyPtr prop; + + prop = drmModeGetProperty(ms->fd, drm_connector->props[p]); + + name = NULL; + if (prop) { + ErrorF("VALUES %d\n", prop->count_values); + + for (v = 0; v < prop->count_values; v++) + ErrorF("%s %lld\n", prop->name, prop->values[v]); + } + } +#else + (void)p; + (void)v; +#endif + + name = connector_enum_list[drm_connector->connector_type]; + + output = xf86OutputCreate(pScrn, &output_funcs, name); + if (!output) + continue; + + drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]); + if (drm_encoder) { + output->possible_crtcs = drm_encoder->possible_crtcs; + output->possible_clones = drm_encoder->possible_clones; + } else { + output->possible_crtcs = 0; + output->possible_clones = 0; + } + output->driver_private = drm_connector; + output->subpixel_order = SubPixelHorizontalRGB; + output->interlaceAllowed = FALSE; + output->doubleScanAllowed = FALSE; + } + + out: + drmModeFreeResources(res); +} + +/* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h new file mode 100644 index 00000000000..82c3890dfbd --- /dev/null +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -0,0 +1,130 @@ +/* + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * + */ + +#ifndef _XORG_TRACKER_H_ +#define _XORG_TRACKER_H_ + +#include <errno.h> +#include <drm.h> +#include <xf86drm.h> +#include <xf86drmMode.h> +#include "exa.h" + +#include "pipe/p_screen.h" +#include "state_tracker/drm_api.h" + +#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); + +typedef struct +{ + int lastInstance; + int refCount; + ScrnInfoPtr pScrn_1; + ScrnInfoPtr pScrn_2; +} EntRec, *EntPtr; + +typedef struct _modesettingRec +{ + /* drm */ + int fd; + unsigned fb_id; + + /* X */ + EntPtr entityPrivate; + + int Chipset; + EntityInfoPtr pEnt; + struct pci_device *PciInfo; + + Bool noAccel; + Bool SWCursor; + CloseScreenProcPtr CloseScreen; + + /* Broken-out options. */ + OptionInfoPtr Options; + + unsigned int SaveGeneration; + + CreateScreenResourcesProcPtr createScreenResources; + + /* gallium */ + struct pipe_screen *screen; + struct pipe_context *ctx; + + /* exa */ + void *exa; + Bool noEvict; + +} modesettingRec, *modesettingPtr; + +#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) + + +/*********************************************************************** + * xorg_exa.c + */ +struct pipe_texture * +xorg_exa_get_texture(PixmapPtr pPixmap); + +unsigned +xorg_exa_get_pixmap_handle(PixmapPtr pPixmap); + +void * +xorg_exa_init(ScrnInfoPtr pScrn); + +void +xorg_exa_close(ScrnInfoPtr pScrn); + + +/*********************************************************************** + * xorg_dri2.c + */ +Bool +driScreenInit(ScreenPtr pScreen); + +void +driCloseScreen(ScreenPtr pScreen); + + +/*********************************************************************** + * xorg_crtc.c + */ +void +crtc_init(ScrnInfoPtr pScrn); + + +/*********************************************************************** + * xorg_output.c + */ +void +output_init(ScrnInfoPtr pScrn); + + +#endif /* _XORG_TRACKER_H_ */ diff --git a/src/gallium/state_trackers/wgl/stw.h b/src/gallium/state_trackers/xorg/xorg_winsys.h index 450af4ccb6f..d523080e90f 100644 --- a/src/gallium/state_trackers/wgl/stw.h +++ b/src/gallium/state_trackers/xorg/xorg_winsys.h @@ -1,5 +1,4 @@ -/************************************************************************** - * +/* * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * @@ -23,31 +22,30 @@ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - **************************************************************************/ - -#ifndef STW_H -#define STW_H - -#include "pipe/p_compiler.h" - -struct stw_winsys; - -/* Public interface: + * + * Author: Alan Hourihane <[email protected]> + * Author: Jakob Bornecrantz <[email protected]> + * */ -boolean stw_init( const struct stw_winsys *stw_winsys ); -void stw_cleanup( void ); +/* + * File with all the junk needed to personalize the a xorg driver. + */ +#ifndef _XORG_WINSYS_H_ +#define _XORG_WINSYS_H_ -/* Internal functions - */ -boolean stw_shared_init( const struct stw_winsys *stw_winsys ); -boolean stw_icd_init( void ); -boolean stw_wgl_init( void ); +#include "xorg-server.h" +#include "xf86.h" +#include "xf86Resources.h" +#include "pciaccess.h" -void stw_shared_cleanup( void ); -void stw_icd_cleanup( void ); -void stw_wgl_cleanup( void ); +#ifndef XSERVER_LIBPCIACCESS +#error "libpciaccess needed" +#endif +void xorg_tracker_set_functions(ScrnInfoPtr scrn); +const OptionInfoRec * xorg_tracker_available_options(int chipid, int busid); +void xorg_tracker_loader_ref_sym_lists(void); -#endif /* STW_H */ +#endif |