summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/Makefile (renamed from src/gallium/state_trackers/dri2/Makefile)2
-rw-r--r--src/gallium/state_trackers/dri/SConscript23
-rw-r--r--src/gallium/state_trackers/dri/dri_context.c (renamed from src/gallium/state_trackers/dri2/dri_context.c)121
-rw-r--r--src/gallium/state_trackers/dri/dri_context.h (renamed from src/gallium/state_trackers/dri2/dri_context.h)59
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c595
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.h (renamed from src/gallium/state_trackers/dri2/dri_drawable.h)41
-rw-r--r--src/gallium/state_trackers/dri/dri_extensions.c (renamed from src/gallium/state_trackers/dri2/dri_extensions.c)7
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c (renamed from src/gallium/state_trackers/dri2/dri_screen.c)224
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.h (renamed from src/gallium/state_trackers/dri2/dri_screen.h)20
-rw-r--r--src/gallium/state_trackers/dri2/dri_drawable.c325
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/fakeglx.c13
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c21
-rw-r--r--src/gallium/state_trackers/wgl/SConscript2
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.c707
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c121
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h1
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c (renamed from src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c)20
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c12
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c3
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c16
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_public.h5
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.c39
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.h2
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.c12
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c3
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c16
28 files changed, 1450 insertions, 964 deletions
diff --git a/src/gallium/state_trackers/dri2/Makefile b/src/gallium/state_trackers/dri/Makefile
index 47750e997e..ef8f19709a 100644
--- a/src/gallium/state_trackers/dri2/Makefile
+++ b/src/gallium/state_trackers/dri/Makefile
@@ -1,7 +1,7 @@
TOP = ../../../..
include $(TOP)/configs/current
-LIBNAME = dri2drm
+LIBNAME = dridrm
LIBRARY_INCLUDES = \
-I$(TOP)/include \
diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript
new file mode 100644
index 0000000000..ce2c273597
--- /dev/null
+++ b/src/gallium/state_trackers/dri/SConscript
@@ -0,0 +1,23 @@
+#######################################################################
+# SConscript for dri state_tracker
+
+Import('*')
+
+if env['dri']:
+
+ env = env.Clone()
+
+ env.Append(CPPPATH = [
+ '#/src/mesa',
+ '#/src/mesa/drivers/dri/common',
+ ])
+
+ st_dri = env.ConvenienceLibrary(
+ target = 'st_dri',
+ source = [ 'dri_context.c',
+ 'dri_drawable.c',
+ 'dri_extensions.c',
+ 'dri_screen.c',
+ ]
+ )
+ Export('st_dri')
diff --git a/src/gallium/state_trackers/dri2/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index 92c26ac70f..45eaec4ed3 100644
--- a/src/gallium/state_trackers/dri2/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -32,9 +32,8 @@
#include "dri_screen.h"
#include "dri_drawable.h"
-
-
#include "state_tracker/drm_api.h"
+#include "state_tracker/dri1_api.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "pipe/p_context.h"
@@ -43,11 +42,9 @@
#include "util/u_memory.h"
-
GLboolean
-dri_create_context(const __GLcontextModes *visual,
- __DRIcontextPrivate *cPriv,
- void *sharedContextPrivate)
+dri_create_context(const __GLcontextModes * visual,
+ __DRIcontextPrivate * cPriv, void *sharedContextPrivate)
{
__DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
@@ -55,7 +52,7 @@ dri_create_context(const __GLcontextModes *visual,
struct st_context *st_share = NULL;
if (sharedContextPrivate) {
- st_share = ((struct dri_context *) sharedContextPrivate)->st;
+ st_share = ((struct dri_context *)sharedContextPrivate)->st;
}
ctx = CALLOC_STRUCT(dri_context);
@@ -65,11 +62,12 @@ dri_create_context(const __GLcontextModes *visual,
cPriv->driverPrivate = ctx;
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
+ ctx->lock = screen->drmLock;
+ ctx->d_stamp = -1;
+ ctx->r_stamp = -1;
driParseConfigFiles(&ctx->optionCache,
- &screen->optionCache,
- sPriv->myNum,
- "dri");
+ &screen->optionCache, sPriv->myNum, "dri");
ctx->pipe = drm_api_hooks.create_context(screen->pipe_screen);
@@ -87,7 +85,7 @@ dri_create_context(const __GLcontextModes *visual,
return GL_TRUE;
-fail:
+ fail:
if (ctx && ctx->st)
st_destroy_context(ctx->st);
@@ -98,9 +96,8 @@ fail:
return FALSE;
}
-
void
-dri_destroy_context(__DRIcontextPrivate *cPriv)
+dri_destroy_context(__DRIcontextPrivate * cPriv)
{
struct dri_context *ctx = dri_context(cPriv);
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
@@ -122,44 +119,64 @@ dri_destroy_context(__DRIcontextPrivate *cPriv)
FREE(ctx);
}
-
GLboolean
-dri_unbind_context(__DRIcontextPrivate *cPriv)
+dri_unbind_context(__DRIcontextPrivate * cPriv)
{
- struct dri_context *ctx = dri_context(cPriv);
- st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- /* XXX make_current(NULL)? */
+ if (cPriv) {
+ struct dri_context *ctx = dri_context(cPriv);
+
+ if (--ctx->bind_count == 0) {
+ if (ctx->st && ctx->st == st_get_current()) {
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_make_current(NULL, NULL, NULL);
+ }
+ }
+ }
+
return GL_TRUE;
}
-
GLboolean
-dri_make_current(__DRIcontextPrivate *cPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv)
+dri_make_current(__DRIcontextPrivate * cPriv,
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv)
{
if (cPriv) {
struct dri_context *ctx = dri_context(cPriv);
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
struct dri_drawable *draw = dri_drawable(driDrawPriv);
struct dri_drawable *read = dri_drawable(driReadPriv);
+ struct st_context *old_st = st_get_current();
+
+ if (old_st && old_st != ctx->st)
+ st_flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ ++ctx->bind_count;
/* This is for situations in which we need a rendering context but
* there may not be any currently bound.
*/
screen->dummyContext = ctx;
- st_make_current(ctx->st,
- draw->stfb,
- read->stfb);
-
- /* used in dri_flush_frontbuffer */
- ctx->dPriv = driDrawPriv;
-
- if (driDrawPriv)
- dri_get_buffers(driDrawPriv);
- if (driDrawPriv != driReadPriv && driReadPriv)
- dri_get_buffers(driReadPriv);
+ if (ctx->dPriv != driDrawPriv) {
+ ctx->dPriv = driDrawPriv;
+ ctx->d_stamp = driDrawPriv->lastStamp - 1;
+ }
+ if (ctx->rPriv != driReadPriv) {
+ ctx->rPriv = driReadPriv;
+ ctx->r_stamp = driReadPriv->lastStamp - 1;
+ }
+
+ st_make_current(ctx->st, draw->stfb, read->stfb);
+
+ if (__dri1_api_hooks) {
+ dri1_update_drawables(ctx, draw, read);
+ } else {
+ if (driDrawPriv)
+ dri_get_buffers(driDrawPriv);
+ if (driDrawPriv != driReadPriv && driReadPriv)
+ dri_get_buffers(driReadPriv);
+ }
} else {
st_make_current(NULL, NULL, NULL);
}
@@ -167,4 +184,42 @@ dri_make_current(__DRIcontextPrivate *cPriv,
return GL_TRUE;
}
+static void
+st_dri_lock(struct pipe_context *pipe)
+{
+ dri_lock((struct dri_context *)pipe->priv);
+}
+
+static void
+st_dri_unlock(struct pipe_context *pipe)
+{
+ dri_unlock((struct dri_context *)pipe->priv);
+}
+
+static boolean
+st_dri_is_locked(struct pipe_context *pipe)
+{
+ return ((struct dri_context *)pipe->priv)->isLocked;
+}
+
+static boolean
+st_dri_lost_lock(struct pipe_context *pipe)
+{
+ return ((struct dri_context *)pipe->priv)->wsLostLock;
+}
+
+static void
+st_dri_clear_lost_lock(struct pipe_context *pipe)
+{
+ ((struct dri_context *)pipe->priv)->wsLostLock = FALSE;
+}
+
+struct dri1_api_lock_funcs dri1_lf = {
+ .lock = st_dri_lock,
+ .unlock = st_dri_unlock,
+ .is_locked = st_dri_is_locked,
+ .is_lock_lost = st_dri_lost_lock,
+ .clear_lost_lock = st_dri_clear_lost_lock
+};
+
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri2/dri_context.h b/src/gallium/state_trackers/dri/dri_context.h
index e910472700..4650178734 100644
--- a/src/gallium/state_trackers/dri2/dri_context.h
+++ b/src/gallium/state_trackers/dri/dri_context.h
@@ -36,60 +36,87 @@
#include "drm.h"
#include "dri_util.h"
-
struct pipe_context;
struct pipe_fence;
struct st_context;
struct dri_drawable;
-
struct dri_context
{
/* dri */
__DRIscreenPrivate *sPriv;
__DRIcontextPrivate *cPriv;
__DRIdrawablePrivate *dPriv;
+ __DRIdrawablePrivate *rPriv;
driOptionCache optionCache;
+ unsigned int d_stamp;
+ unsigned int r_stamp;
+
+ drmLock *lock;
+ boolean isLocked;
+ boolean stLostLock;
+ boolean wsLostLock;
+
+ unsigned int bind_count;
+
/* gallium */
struct st_context *st;
struct pipe_context *pipe;
};
-
static INLINE struct dri_context *
-dri_context(__DRIcontextPrivate *driContextPriv)
+dri_context(__DRIcontextPrivate * driContextPriv)
+{
+ return (struct dri_context *)driContextPriv->driverPrivate;
+}
+
+static INLINE void
+dri_lock(struct dri_context *ctx)
{
- return (struct dri_context *) driContextPriv->driverPrivate;
+ drm_context_t hw_context = ctx->cPriv->hHWContext;
+ char ret = 0;
+
+ DRM_CAS(ctx->lock, hw_context, DRM_LOCK_HELD | hw_context, ret);
+ if (ret) {
+ drmGetLock(ctx->sPriv->fd, hw_context, 0);
+ ctx->stLostLock = TRUE;
+ ctx->wsLostLock = TRUE;
+ }
+ ctx->isLocked = TRUE;
}
+static INLINE void
+dri_unlock(struct dri_context *ctx)
+{
+ ctx->isLocked = FALSE;
+ DRM_UNLOCK(ctx->sPriv->fd, ctx->lock, ctx->cPriv->hHWContext);
+}
/***********************************************************************
* dri_context.c
*/
-void
-dri_destroy_context(__DRIcontextPrivate * driContextPriv);
+extern struct dri1_api_lock_funcs dri1_lf;
-boolean
-dri_unbind_context(__DRIcontextPrivate * driContextPriv);
+void dri_destroy_context(__DRIcontextPrivate * driContextPriv);
+
+boolean dri_unbind_context(__DRIcontextPrivate * driContextPriv);
boolean
dri_make_current(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv);
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv);
boolean
dri_create_context(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate);
-
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate);
/***********************************************************************
* dri_extensions.c
*/
-void
-dri_init_extensions(struct dri_context *ctx);
+void dri_init_extensions(struct dri_context *ctx);
#endif
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
new file mode 100644
index 0000000000..15a2088df5
--- /dev/null
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -0,0 +1,595 @@
+/**************************************************************************
+ *
+ * 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 <keithw@vmware.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ */
+
+#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/dri1_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);
+}
+
+/**
+ * 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;
+
+ drawable->desired_fences = 2;
+
+ return GL_TRUE;
+ fail:
+ FREE(drawable);
+ return GL_FALSE;
+}
+
+static struct pipe_fence_handle *
+dri_swap_fences_pop_front(struct dri_drawable *draw)
+{
+ struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+ struct pipe_fence_handle *fence = NULL;
+
+ if (draw->cur_fences >= draw->desired_fences) {
+ screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
+ screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
+ --draw->cur_fences;
+ draw->tail &= DRI_SWAP_FENCES_MASK;
+ }
+ return fence;
+}
+
+static void
+dri_swap_fences_push_back(struct dri_drawable *draw,
+ struct pipe_fence_handle *fence)
+{
+ struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+
+ if (!fence)
+ return;
+
+ if (draw->cur_fences < DRI_SWAP_FENCES_MAX) {
+ draw->cur_fences++;
+ screen->fence_reference(screen, &draw->swap_fences[draw->head++],
+ fence);
+ draw->head &= DRI_SWAP_FENCES_MASK;
+ }
+}
+
+void
+dri_destroy_buffer(__DRIdrawablePrivate * dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_fence_handle *fence;
+ struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
+
+ st_unreference_framebuffer(drawable->stfb);
+ drawable->desired_fences = 0;
+ while (drawable->cur_fences) {
+ fence = dri_swap_fences_pop_front(drawable);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+
+ FREE(drawable);
+}
+
+static void
+dri1_update_drawables_locked(struct dri_context *ctx,
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv)
+{
+ if (ctx->stLostLock) {
+ ctx->stLostLock = FALSE;
+ if (driDrawPriv == driReadPriv)
+ DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv);
+ else
+ DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv,
+ driReadPriv);
+ }
+}
+
+/**
+ * This ensures all contexts which bind to a drawable pick up the
+ * drawable change and signal new buffer state.
+ * Calling st_resize_framebuffer for each context may seem like overkill,
+ * but no new buffers will actually be allocated if the dimensions don't
+ * change.
+ */
+
+static void
+dri1_propagate_drawable_change(struct dri_context *ctx)
+{
+ __DRIdrawablePrivate *dPriv = ctx->dPriv;
+ __DRIdrawablePrivate *rPriv = ctx->rPriv;
+ boolean flushed = FALSE;
+
+ if (dPriv && ctx->d_stamp != dPriv->lastStamp) {
+
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ flushed = TRUE;
+ ctx->d_stamp = dPriv->lastStamp;
+ st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h);
+
+ }
+
+ if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) {
+
+ if (!flushed)
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ ctx->r_stamp = rPriv->lastStamp;
+ st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h);
+
+ } else if (rPriv && dPriv == rPriv) {
+
+ ctx->r_stamp = ctx->d_stamp;
+
+ }
+}
+
+void
+dri1_update_drawables(struct dri_context *ctx,
+ struct dri_drawable *draw, struct dri_drawable *read)
+{
+ dri_lock(ctx);
+ dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv);
+ dri_unlock(ctx);
+
+ dri1_propagate_drawable_change(ctx);
+}
+
+static INLINE boolean
+dri1_intersect_src_bbox(struct drm_clip_rect *dst,
+ int dst_x,
+ int dst_y,
+ const struct drm_clip_rect *src,
+ const struct drm_clip_rect *bbox)
+{
+ int xy1;
+ int xy2;
+
+ xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
+ (int)bbox->x1 + dst_x;
+ xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
+ (int)bbox->x2 + dst_x;
+ if (xy1 >= xy2 || xy1 < 0)
+ return FALSE;
+
+ dst->x1 = xy1;
+ dst->x2 = xy2;
+
+ xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
+ (int)bbox->y1 + dst_y;
+ xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
+ (int)bbox->y2 + dst_y;
+ if (xy1 >= xy2 || xy1 < 0)
+ return FALSE;
+
+ dst->y1 = xy1;
+ dst->y2 = xy2;
+ return TRUE;
+}
+
+static void
+dri1_swap_copy(struct dri_context *ctx,
+ struct pipe_surface *dst,
+ struct pipe_surface *src,
+ __DRIdrawablePrivate * dPriv, const struct drm_clip_rect *bbox)
+{
+ struct pipe_context *pipe = ctx->pipe;
+ struct drm_clip_rect clip;
+ struct drm_clip_rect *cur;
+ int i;
+
+ cur = dPriv->pClipRects;
+
+ for (i = 0; i < dPriv->numClipRects; ++i) {
+ if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
+ pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
+ src,
+ (int)clip.x1 - dPriv->x,
+ (int)clip.y1 - dPriv->y,
+ clip.x2 - clip.x1, clip.y2 - clip.y1);
+ }
+}
+
+static void
+dri1_copy_to_front(struct dri_context *ctx,
+ struct pipe_surface *surf,
+ __DRIdrawablePrivate * dPriv,
+ const struct drm_clip_rect *sub_box,
+ struct pipe_fence_handle **fence)
+{
+ struct pipe_context *pipe = ctx->pipe;
+ boolean save_lost_lock;
+ uint cur_w;
+ uint cur_h;
+ struct drm_clip_rect bbox;
+ boolean visible = TRUE;
+
+ *fence = NULL;
+
+ dri_lock(ctx);
+ save_lost_lock = ctx->stLostLock;
+ dri1_update_drawables_locked(ctx, dPriv, dPriv);
+ st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h);
+
+ bbox.x1 = 0;
+ bbox.x2 = cur_w;
+ bbox.y1 = 0;
+ bbox.y2 = cur_h;
+
+ if (sub_box)
+ visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box);
+
+ if (visible && __dri1_api_hooks->present_locked) {
+
+ __dri1_api_hooks->present_locked(pipe,
+ surf,
+ dPriv->pClipRects,
+ dPriv->numClipRects,
+ dPriv->x, dPriv->y, &bbox, fence);
+
+ } else if (visible && __dri1_api_hooks->front_srf_locked) {
+
+ struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe);
+
+ if (front)
+ dri1_swap_copy(ctx, front, surf, dPriv, &bbox);
+
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence);
+ }
+
+ ctx->stLostLock = save_lost_lock;
+
+ /**
+ * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
+ */
+
+ if (!sub_box)
+ dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv);
+
+ dri_unlock(ctx);
+ dri1_propagate_drawable_change(ctx);
+}
+
+void
+dri1_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf, void *context_private)
+{
+ struct dri_context *ctx = (struct dri_context *)context_private;
+ struct pipe_fence_handle *dummy_fence;
+
+ dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence);
+ screen->fence_reference(screen, &dummy_fence, NULL);
+
+ /**
+ * FIXME: Do we need swap throttling here?
+ */
+}
+
+void
+dri_swap_buffers(__DRIdrawablePrivate * dPriv)
+{
+ struct dri_context *ctx;
+ struct pipe_surface *back_surf;
+ struct dri_drawable *draw = dri_drawable(dPriv);
+ struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+ struct pipe_fence_handle *fence;
+ struct st_context *st = st_get_current();
+
+ assert(__dri1_api_hooks != NULL);
+
+ if (!st)
+ return; /* For now */
+
+ ctx = (struct dri_context *)st->pipe->priv;
+
+ st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
+ if (back_surf) {
+ st_notify_swapbuffers(draw->stfb);
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ fence = dri_swap_fences_pop_front(draw);
+ if (fence) {
+ (void)screen->fence_finish(screen, fence, 0);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+ dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence);
+ dri_swap_fences_push_back(draw, fence);
+ screen->fence_reference(screen, &fence, NULL);
+ }
+}
+
+void
+dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
+{
+ struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen;
+ struct drm_clip_rect sub_bbox;
+ struct dri_context *ctx;
+ struct pipe_surface *back_surf;
+ struct dri_drawable *draw = dri_drawable(dPriv);
+ struct pipe_fence_handle *dummy_fence;
+ struct st_context *st = st_get_current();
+
+ assert(__dri1_api_hooks != NULL);
+
+ if (!st)
+ return;
+
+ ctx = (struct dri_context *)st->pipe->priv;
+
+ sub_bbox.x1 = x;
+ sub_bbox.x2 = x + w;
+ sub_bbox.y1 = y;
+ sub_bbox.y2 = y + h;
+
+ st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
+ if (back_surf) {
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence);
+ screen->fence_reference(screen, &dummy_fence, NULL);
+ }
+}
+
+/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri2/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h
index 185c657b35..78a66624aa 100644
--- a/src/gallium/state_trackers/dri2/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/dri_drawable.h
@@ -31,9 +31,11 @@
#include "pipe/p_compiler.h"
struct pipe_surface;
-struct pipe_fence;
+struct pipe_fence_handle;
struct st_framebuffer;
+#define DRI_SWAP_FENCES_MAX 8
+#define DRI_SWAP_FENCES_MASK 7
struct dri_drawable
{
@@ -46,44 +48,47 @@ struct dri_drawable
/* gallium */
struct st_framebuffer *stfb;
+ struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
+ unsigned int head;
+ unsigned int tail;
+ unsigned int desired_fences;
+ unsigned int cur_fences;
};
-
static INLINE struct dri_drawable *
dri_drawable(__DRIdrawablePrivate * driDrawPriv)
{
- return (struct dri_drawable *) driDrawPriv->driverPrivate;
+ return (struct dri_drawable *)driDrawPriv->driverPrivate;
}
-
/***********************************************************************
* dri_drawable.c
*/
boolean
-dri_create_buffer(__DRIscreenPrivate *sPriv,
- __DRIdrawablePrivate *dPriv,
- const __GLcontextModes *visual,
- boolean isPixmap);
+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);
+ struct pipe_surface *surf, void *context_private);
-void
-dri_swap_buffers(__DRIdrawablePrivate * dPriv);
+void dri_swap_buffers(__DRIdrawablePrivate * dPriv);
void
-dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv,
- int x, int y,
- int w, int h);
+dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h);
-void
-dri_get_buffers(__DRIdrawablePrivate * dPriv);
+void dri_get_buffers(__DRIdrawablePrivate * dPriv);
+
+void dri_destroy_buffer(__DRIdrawablePrivate * dPriv);
void
-dri_destroy_buffer(__DRIdrawablePrivate *dPriv);
+dri1_update_drawables(struct dri_context *ctx,
+ struct dri_drawable *draw, struct dri_drawable *read);
+void
+dri1_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf, void *context_private);
#endif
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri2/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c
index 732d1e89b0..0c59d42d5c 100644
--- a/src/gallium/state_trackers/dri2/dri_extensions.c
+++ b/src/gallium/state_trackers/dri/dri_extensions.c
@@ -52,7 +52,6 @@
#define need_GL_NV_vertex_program
#include "extension_helper.h"
-
/**
* Extension strings exported by the driver.
*/
@@ -74,7 +73,8 @@ const struct dri_extension card_extensions[] = {
{"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
{"GL_ARB_window_pos", GL_ARB_window_pos_functions},
{"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
+ {"GL_EXT_blend_equation_separate",
+ GL_EXT_blend_equation_separate_functions},
{"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
{"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
{"GL_EXT_blend_subtract", NULL},
@@ -98,11 +98,10 @@ const struct dri_extension card_extensions[] = {
{"GL_NV_blend_square", NULL},
{"GL_NV_vertex_program", GL_NV_vertex_program_functions},
{"GL_NV_vertex_program1_1", NULL},
- {"GL_SGIS_generate_mipmap", NULL },
+ {"GL_SGIS_generate_mipmap", NULL},
{NULL, NULL}
};
-
void
dri_init_extensions(struct dri_context *ctx)
{
diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index ab5878a4bc..d3392ee690 100644
--- a/src/gallium/state_trackers/dri2/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -40,68 +40,38 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
+#include "pipe/p_format.h"
#include "state_tracker/drm_api.h"
+#include "state_tracker/dri1_api.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_cb_fbo.h"
-
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
- DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
- DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
- /*DRI_CONF_FORCE_S3TC_ENABLE(false)*/
- DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+ /*DRI_CONF_FORCE_S3TC_ENABLE(false) */
+ DRI_CONF_ALLOW_LARGE_TEXTURES(1)
DRI_CONF_SECTION_END DRI_CONF_END;
+ const uint __driNConfigOptions = 3;
-const uint __driNConfigOptions = 3;
-
-
-static const __DRIextension *dri_screen_extensions[] = {
- &driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
- NULL
-};
-
-
-static void
-dri_get_drm_minor(struct dri_screen *screen)
-{
- /* TODO get the real minor */
- screen->minor = 0;
-}
-
-
-static void
-dri_get_device_id(struct dri_screen *screen)
-{
- char path[512];
- FILE *file;
-
- /*
- * There must be a better way to get the deviceID.
- * XXX this only works on Linux.
- */
- snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", screen->minor);
- file = fopen(path, "r");
- if (!file) {
- return;
- }
-
- fgets(path, sizeof(path), file);
- sscanf(path, "%x", &screen->deviceID);
- fclose(file);
-}
+ static const __DRIextension *dri_screen_extensions[] = {
+ &driReadDrawableExtension,
+ &driCopySubBufferExtension.base,
+ &driSwapControlExtension.base,
+ &driFrameTrackingExtension.base,
+ &driMediaStreamCounterExtension.base,
+ NULL
+ };
+struct dri1_api *__dri1_api_hooks = NULL;
static const __DRIconfig **
-dri_fill_in_modes(__DRIscreenPrivate *psp,
- unsigned pixel_bits, unsigned depth_bits,
- unsigned stencil_bits, GLboolean have_back_buffer)
+dri_fill_in_modes(__DRIscreenPrivate * psp,
+ unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer)
{
__DRIconfig **configs;
__GLcontextModes *m;
@@ -125,9 +95,9 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
depth_bits_array[1] = 24;
depth_bits_array[2] = 24;
- stencil_bits_array[0] = 0; /* no depth or stencil */
- stencil_bits_array[1] = 0; /* z24x8 */
- stencil_bits_array[2] = 8; /* z24s8 */
+ stencil_bits_array[0] = 0; /* no depth or stencil */
+ stencil_bits_array[1] = 0; /* z24x8 */
+ stencil_bits_array[2] = 8; /* z24s8 */
msaa_samples_array[0] = 0;
@@ -135,22 +105,22 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
back_buffer_factor = 3;
msaa_samples_factor = 1;
- num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
+ num_modes =
+ depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
if (pixel_bits == 16) {
fb_format = GL_RGB;
fb_type = GL_UNSIGNED_SHORT_5_6_5;
- }
- else {
+ } else {
fb_format = GL_BGRA;
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
configs = driCreateConfigs(fb_format, fb_type,
depth_bits_array,
- stencil_bits_array, depth_buffer_factor,
- back_buffer_modes, back_buffer_factor,
- msaa_samples_array, msaa_samples_factor);
+ stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ msaa_samples_array, msaa_samples_factor);
if (configs == NULL) {
debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
return NULL;
@@ -159,49 +129,99 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
for (i = 0; configs[i]; i++) {
m = &configs[i]->modes;
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
- m->visualRating = GLX_SLOW_CONFIG;
+ m->visualRating = GLX_SLOW_CONFIG;
}
}
- return (const const __DRIconfig **) configs;
+ return (const const __DRIconfig **)configs;
}
-
/**
* Get information about previous buffer swaps.
*/
-int
-dri_get_swap_info(__DRIdrawablePrivate * dPriv,
- __DRIswapInfo * sInfo)
+static int
+dri_get_swap_info(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
{
- if (dPriv == NULL ||
- dPriv->driverPrivate == NULL ||
- sInfo == NULL)
+ if (dPriv == NULL || dPriv->driverPrivate == NULL || sInfo == NULL)
return -1;
else
return 0;
}
+static INLINE void
+dri_copy_version(struct dri1_api_version *dst,
+ const struct __DRIversionRec *src)
+{
+ dst->major = src->major;
+ dst->minor = src->minor;
+ dst->patch_level = src->patch;
+}
-/**
- * NULL stub for old dri loaders
- */
-const __DRIconfig **
-dri_init_screen(__DRIscreenPrivate *sPriv)
+static const __DRIconfig **
+dri_init_screen(__DRIscreenPrivate * sPriv)
{
+ struct dri_screen *screen;
+ const __DRIconfig **configs;
+ struct dri1_create_screen_arg arg;
+
+ dri_init_extensions(NULL);
+
+ screen = CALLOC_STRUCT(dri_screen);
+ if (!screen)
+ return NULL;
+
+ screen->sPriv = sPriv;
+ screen->fd = sPriv->fd;
+ screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
+
+ sPriv->private = (void *)screen;
+ sPriv->extensions = dri_screen_extensions;
+
+ arg.base.mode = DRM_CREATE_DRI1;
+ arg.lf = &dri1_lf;
+ arg.ddx_info = sPriv->pDevPriv;
+ arg.ddx_info_size = sPriv->devPrivSize;
+ arg.sarea = sPriv->pSAREA;
+ dri_copy_version(&arg.ddx_version, &sPriv->ddx_version);
+ dri_copy_version(&arg.dri_version, &sPriv->dri_version);
+ dri_copy_version(&arg.drm_version, &sPriv->drm_version);
+ arg.api = NULL;
+
+ screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg.base);
+
+ if (!screen->pipe_screen || !arg.api) {
+ debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
+ goto out_no_screen;
+ }
+
+ __dri1_api_hooks = arg.api;
+
+ screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer;
+ driParseOptionInfo(&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ configs = dri_fill_in_modes(sPriv, sPriv->fbBPP, 24, 8, 1);
+ if (!configs)
+ goto out_no_configs;
+
+ return configs;
+ out_no_configs:
+ screen->pipe_screen->destroy(screen->pipe_screen);
+ out_no_screen:
+ FREE(screen);
return NULL;
}
-
/**
* This is the driver specific part of the createNewScreen entry point.
*
* Returns the __GLcontextModes supported by this driver.
*/
-const __DRIconfig **
-dri_init_screen2(__DRIscreenPrivate *sPriv)
+static const __DRIconfig **
+dri_init_screen2(__DRIscreenPrivate * sPriv)
{
struct dri_screen *screen;
+ struct drm_create_screen_arg arg;
/* Set up dispatch table to cope with all known extensions */
dri_init_extensions(NULL);
@@ -212,13 +232,11 @@ dri_init_screen2(__DRIscreenPrivate *sPriv)
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
- dri_get_drm_minor(screen);
- dri_get_device_id(screen);
- sPriv->private = (void *) screen;
+ sPriv->private = (void *)screen;
sPriv->extensions = dri_screen_extensions;
+ arg.mode = DRM_CREATE_NORMAL;
-
- screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID);
+ screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg);
if (!screen->pipe_screen) {
debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
goto fail;
@@ -228,20 +246,14 @@ dri_init_screen2(__DRIscreenPrivate *sPriv)
screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer;
driParseOptionInfo(&screen->optionCache,
- __driConfigOptions,
- __driNConfigOptions);
-
- return dri_fill_in_modes(sPriv,
- 4 * 8,
- 24,
- 8,
- 1);
-fail:
+ __driConfigOptions, __driNConfigOptions);
+
+ return dri_fill_in_modes(sPriv, 4 * 8, 24, 8, 1);
+ fail:
return NULL;
}
-
-void
+static void
dri_destroy_screen(__DRIscreenPrivate * sPriv)
{
struct dri_screen *screen = dri_screen(sPriv);
@@ -251,22 +263,22 @@ dri_destroy_screen(__DRIscreenPrivate * sPriv)
sPriv->private = NULL;
}
-
PUBLIC const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = dri_init_screen, /* not supported but exported */
- .DestroyScreen = dri_destroy_screen,
- .CreateContext = dri_create_context,
- .DestroyContext = dri_destroy_context,
- .CreateBuffer = dri_create_buffer,
- .DestroyBuffer = dri_destroy_buffer,
- .SwapBuffers = dri_swap_buffers, /* not supported but exported */
- .MakeCurrent = dri_make_current,
- .UnbindContext = dri_unbind_context,
- .GetSwapInfo = dri_get_swap_info,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */
- .InitScreen2 = dri_init_screen2,
+ .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,
+ .InitScreen = dri_init_screen,
+ .InitScreen2 = dri_init_screen2,
};
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
index fe2676d0be..100d9e50e0 100644
--- a/src/gallium/state_trackers/dri2/dri_screen.h
+++ b/src/gallium/state_trackers/dri/dri_screen.h
@@ -37,6 +37,8 @@
#include "pipe/p_compiler.h"
+#include "state_tracker/dri1_api.h"
+
struct dri_screen
{
/* dri */
@@ -54,36 +56,26 @@ struct dri_screen
struct dri_context *dummyContext;
/* drm */
- int deviceID;
int fd;
- int minor;
+ drmLock *drmLock;
/* gallium */
struct pipe_winsys *pipe_winsys;
struct pipe_screen *pipe_screen;
};
-
/** cast wrapper */
static INLINE struct dri_screen *
-dri_screen(__DRIscreenPrivate *sPriv)
+dri_screen(__DRIscreenPrivate * sPriv)
{
- return (struct dri_screen *) sPriv->private;
+ return (struct dri_screen *)sPriv->private;
}
-
/***********************************************************************
* dri_screen.c
*/
-const __DRIconfig **
-dri_init_screen2(__DRIscreenPrivate *sPriv);
-
-void
-dri_destroy_screen(__DRIscreenPrivate * sPriv);
-int
-dri_get_swap_info(__DRIdrawablePrivate * dPriv,
- __DRIswapInfo * sInfo);
+extern struct dri1_api *__dri1_api_hooks;
#endif
diff --git a/src/gallium/state_trackers/dri2/dri_drawable.c b/src/gallium/state_trackers/dri2/dri_drawable.c
deleted file mode 100644
index 2e3f4099e2..0000000000
--- a/src/gallium/state_trackers/dri2/dri_drawable.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009, VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-/*
- * Author: Keith Whitwell <keithw@vmware.com>
- * Author: Jakob Bornecrantz <wallbraker@gmail.com>
- */
-
-#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/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c
index abdf84544f..8e62008461 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.c
+++ b/src/gallium/state_trackers/egl/egl_tracker.c
@@ -146,7 +146,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
dev->drmFD = fd;
drm_get_device_id(dev);
- dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID);
+ dev->screen = drm_api_hooks.create_screen(dev->drmFD, NULL);
if (!dev->screen)
goto err_screen;
dev->winsys = dev->screen->winsys;
diff --git a/src/gallium/state_trackers/glx/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c
index 65e7048188..85e7ecfb9e 100644
--- a/src/gallium/state_trackers/glx/xlib/fakeglx.c
+++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c
@@ -97,6 +97,9 @@ struct fake_glx_context {
+#define DEFAULT_DIRECT GL_TRUE
+
+
/**********************************************************************/
/*** GLX Visual Code ***/
/**********************************************************************/
@@ -1059,7 +1062,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
return NULL;
}
- glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
glxCtx->glxContext.currentDpy = dpy;
glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
@@ -1296,9 +1299,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
static Bool
Fake_glXIsDirect( Display *dpy, GLXContext ctx )
{
- (void) dpy;
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
(void) ctx;
- return False;
+ return glxCtx->glxContext.isDirect;
}
@@ -2055,7 +2058,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
return NULL;
}
- glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
glxCtx->glxContext.currentDpy = dpy;
glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
@@ -2277,7 +2280,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re
return NULL;
}
- glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
glxCtx->glxContext.currentDpy = dpy;
glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index a3d1651653..79c2230588 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -1100,26 +1100,19 @@ XMesaContext XMesaGetCurrentContext( void )
-
-
-
-/*
- * Copy the back buffer to the front buffer. If there's no back buffer
- * this is a no-op.
+/**
+ * Swap front and back color buffers and have winsys display front buffer.
+ * If there's no front color buffer no swap actually occurs.
*/
PUBLIC
void XMesaSwapBuffers( XMesaBuffer b )
{
- struct pipe_surface *surf;
+ struct pipe_surface *frontLeftSurf;
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers(b->stfb);
+ st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
- st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf);
- if (surf) {
- driver.display_surface(b, surf);
+ if (frontLeftSurf) {
+ driver.display_surface(b, frontLeftSurf);
}
xmesa_check_and_update_buffer_size(NULL, b);
diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript
index 61fd8bfc0c..5bbcc7175f 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -26,7 +26,7 @@ if env['platform'] in ['windows']:
'shared/stw_device.c',
'shared/stw_framebuffer.c',
'shared/stw_pixelformat.c',
- 'shared/stw_arbextensionsstring.c',
+ 'shared/stw_extensionsstring.c',
'shared/stw_getprocaddress.c',
'shared/stw_arbpixelformat.c',
'shared/stw_tls.c',
diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c
index faf7f2f410..62af765211 100644
--- a/src/gallium/state_trackers/wgl/icd/stw_icd.c
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c
@@ -38,9 +38,6 @@
#define DBG 0
-static GLCLTPROCTABLE cpt;
-static boolean cpt_initialized = FALSE;
-
BOOL APIENTRY
DrvCopyContext(
@@ -165,351 +162,352 @@ DrvSetCallbackProcs(
}
-static void init_proc_table( GLCLTPROCTABLE *cpt )
-{
- GLDISPATCHTABLE *disp = &cpt->glDispatchTable;
-
- memset( cpt, 0, sizeof *cpt );
- cpt->cEntries = OPENGL_VERSION_110_ENTRIES;
-
-#define GPA_GL( NAME ) disp->NAME = gl##NAME
- GPA_GL( NewList );
- GPA_GL( EndList );
- GPA_GL( CallList );
- GPA_GL( CallLists );
- GPA_GL( DeleteLists );
- GPA_GL( GenLists );
- GPA_GL( ListBase );
- GPA_GL( Begin );
- GPA_GL( Bitmap );
- GPA_GL( Color3b );
- GPA_GL( Color3bv );
- GPA_GL( Color3d );
- GPA_GL( Color3dv );
- GPA_GL( Color3f );
- GPA_GL( Color3fv );
- GPA_GL( Color3i );
- GPA_GL( Color3iv );
- GPA_GL( Color3s );
- GPA_GL( Color3sv );
- GPA_GL( Color3ub );
- GPA_GL( Color3ubv );
- GPA_GL( Color3ui );
- GPA_GL( Color3uiv );
- GPA_GL( Color3us );
- GPA_GL( Color3usv );
- GPA_GL( Color4b );
- GPA_GL( Color4bv );
- GPA_GL( Color4d );
- GPA_GL( Color4dv );
- GPA_GL( Color4f );
- GPA_GL( Color4fv );
- GPA_GL( Color4i );
- GPA_GL( Color4iv );
- GPA_GL( Color4s );
- GPA_GL( Color4sv );
- GPA_GL( Color4ub );
- GPA_GL( Color4ubv );
- GPA_GL( Color4ui );
- GPA_GL( Color4uiv );
- GPA_GL( Color4us );
- GPA_GL( Color4usv );
- GPA_GL( EdgeFlag );
- GPA_GL( EdgeFlagv );
- GPA_GL( End );
- GPA_GL( Indexd );
- GPA_GL( Indexdv );
- GPA_GL( Indexf );
- GPA_GL( Indexfv );
- GPA_GL( Indexi );
- GPA_GL( Indexiv );
- GPA_GL( Indexs );
- GPA_GL( Indexsv );
- GPA_GL( Normal3b );
- GPA_GL( Normal3bv );
- GPA_GL( Normal3d );
- GPA_GL( Normal3dv );
- GPA_GL( Normal3f );
- GPA_GL( Normal3fv );
- GPA_GL( Normal3i );
- GPA_GL( Normal3iv );
- GPA_GL( Normal3s );
- GPA_GL( Normal3sv );
- GPA_GL( RasterPos2d );
- GPA_GL( RasterPos2dv );
- GPA_GL( RasterPos2f );
- GPA_GL( RasterPos2fv );
- GPA_GL( RasterPos2i );
- GPA_GL( RasterPos2iv );
- GPA_GL( RasterPos2s );
- GPA_GL( RasterPos2sv );
- GPA_GL( RasterPos3d );
- GPA_GL( RasterPos3dv );
- GPA_GL( RasterPos3f );
- GPA_GL( RasterPos3fv );
- GPA_GL( RasterPos3i );
- GPA_GL( RasterPos3iv );
- GPA_GL( RasterPos3s );
- GPA_GL( RasterPos3sv );
- GPA_GL( RasterPos4d );
- GPA_GL( RasterPos4dv );
- GPA_GL( RasterPos4f );
- GPA_GL( RasterPos4fv );
- GPA_GL( RasterPos4i );
- GPA_GL( RasterPos4iv );
- GPA_GL( RasterPos4s );
- GPA_GL( RasterPos4sv );
- GPA_GL( Rectd );
- GPA_GL( Rectdv );
- GPA_GL( Rectf );
- GPA_GL( Rectfv );
- GPA_GL( Recti );
- GPA_GL( Rectiv );
- GPA_GL( Rects );
- GPA_GL( Rectsv );
- GPA_GL( TexCoord1d );
- GPA_GL( TexCoord1dv );
- GPA_GL( TexCoord1f );
- GPA_GL( TexCoord1fv );
- GPA_GL( TexCoord1i );
- GPA_GL( TexCoord1iv );
- GPA_GL( TexCoord1s );
- GPA_GL( TexCoord1sv );
- GPA_GL( TexCoord2d );
- GPA_GL( TexCoord2dv );
- GPA_GL( TexCoord2f );
- GPA_GL( TexCoord2fv );
- GPA_GL( TexCoord2i );
- GPA_GL( TexCoord2iv );
- GPA_GL( TexCoord2s );
- GPA_GL( TexCoord2sv );
- GPA_GL( TexCoord3d );
- GPA_GL( TexCoord3dv );
- GPA_GL( TexCoord3f );
- GPA_GL( TexCoord3fv );
- GPA_GL( TexCoord3i );
- GPA_GL( TexCoord3iv );
- GPA_GL( TexCoord3s );
- GPA_GL( TexCoord3sv );
- GPA_GL( TexCoord4d );
- GPA_GL( TexCoord4dv );
- GPA_GL( TexCoord4f );
- GPA_GL( TexCoord4fv );
- GPA_GL( TexCoord4i );
- GPA_GL( TexCoord4iv );
- GPA_GL( TexCoord4s );
- GPA_GL( TexCoord4sv );
- GPA_GL( Vertex2d );
- GPA_GL( Vertex2dv );
- GPA_GL( Vertex2f );
- GPA_GL( Vertex2fv );
- GPA_GL( Vertex2i );
- GPA_GL( Vertex2iv );
- GPA_GL( Vertex2s );
- GPA_GL( Vertex2sv );
- GPA_GL( Vertex3d );
- GPA_GL( Vertex3dv );
- GPA_GL( Vertex3f );
- GPA_GL( Vertex3fv );
- GPA_GL( Vertex3i );
- GPA_GL( Vertex3iv );
- GPA_GL( Vertex3s );
- GPA_GL( Vertex3sv );
- GPA_GL( Vertex4d );
- GPA_GL( Vertex4dv );
- GPA_GL( Vertex4f );
- GPA_GL( Vertex4fv );
- GPA_GL( Vertex4i );
- GPA_GL( Vertex4iv );
- GPA_GL( Vertex4s );
- GPA_GL( Vertex4sv );
- GPA_GL( ClipPlane );
- GPA_GL( ColorMaterial );
- GPA_GL( CullFace );
- GPA_GL( Fogf );
- GPA_GL( Fogfv );
- GPA_GL( Fogi );
- GPA_GL( Fogiv );
- GPA_GL( FrontFace );
- GPA_GL( Hint );
- GPA_GL( Lightf );
- GPA_GL( Lightfv );
- GPA_GL( Lighti );
- GPA_GL( Lightiv );
- GPA_GL( LightModelf );
- GPA_GL( LightModelfv );
- GPA_GL( LightModeli );
- GPA_GL( LightModeliv );
- GPA_GL( LineStipple );
- GPA_GL( LineWidth );
- GPA_GL( Materialf );
- GPA_GL( Materialfv );
- GPA_GL( Materiali );
- GPA_GL( Materialiv );
- GPA_GL( PointSize );
- GPA_GL( PolygonMode );
- GPA_GL( PolygonStipple );
- GPA_GL( Scissor );
- GPA_GL( ShadeModel );
- GPA_GL( TexParameterf );
- GPA_GL( TexParameterfv );
- GPA_GL( TexParameteri );
- GPA_GL( TexParameteriv );
- GPA_GL( TexImage1D );
- GPA_GL( TexImage2D );
- GPA_GL( TexEnvf );
- GPA_GL( TexEnvfv );
- GPA_GL( TexEnvi );
- GPA_GL( TexEnviv );
- GPA_GL( TexGend );
- GPA_GL( TexGendv );
- GPA_GL( TexGenf );
- GPA_GL( TexGenfv );
- GPA_GL( TexGeni );
- GPA_GL( TexGeniv );
- GPA_GL( FeedbackBuffer );
- GPA_GL( SelectBuffer );
- GPA_GL( RenderMode );
- GPA_GL( InitNames );
- GPA_GL( LoadName );
- GPA_GL( PassThrough );
- GPA_GL( PopName );
- GPA_GL( PushName );
- GPA_GL( DrawBuffer );
- GPA_GL( Clear );
- GPA_GL( ClearAccum );
- GPA_GL( ClearIndex );
- GPA_GL( ClearColor );
- GPA_GL( ClearStencil );
- GPA_GL( ClearDepth );
- GPA_GL( StencilMask );
- GPA_GL( ColorMask );
- GPA_GL( DepthMask );
- GPA_GL( IndexMask );
- GPA_GL( Accum );
- GPA_GL( Disable );
- GPA_GL( Enable );
- GPA_GL( Finish );
- GPA_GL( Flush );
- GPA_GL( PopAttrib );
- GPA_GL( PushAttrib );
- GPA_GL( Map1d );
- GPA_GL( Map1f );
- GPA_GL( Map2d );
- GPA_GL( Map2f );
- GPA_GL( MapGrid1d );
- GPA_GL( MapGrid1f );
- GPA_GL( MapGrid2d );
- GPA_GL( MapGrid2f );
- GPA_GL( EvalCoord1d );
- GPA_GL( EvalCoord1dv );
- GPA_GL( EvalCoord1f );
- GPA_GL( EvalCoord1fv );
- GPA_GL( EvalCoord2d );
- GPA_GL( EvalCoord2dv );
- GPA_GL( EvalCoord2f );
- GPA_GL( EvalCoord2fv );
- GPA_GL( EvalMesh1 );
- GPA_GL( EvalPoint1 );
- GPA_GL( EvalMesh2 );
- GPA_GL( EvalPoint2 );
- GPA_GL( AlphaFunc );
- GPA_GL( BlendFunc );
- GPA_GL( LogicOp );
- GPA_GL( StencilFunc );
- GPA_GL( StencilOp );
- GPA_GL( DepthFunc );
- GPA_GL( PixelZoom );
- GPA_GL( PixelTransferf );
- GPA_GL( PixelTransferi );
- GPA_GL( PixelStoref );
- GPA_GL( PixelStorei );
- GPA_GL( PixelMapfv );
- GPA_GL( PixelMapuiv );
- GPA_GL( PixelMapusv );
- GPA_GL( ReadBuffer );
- GPA_GL( CopyPixels );
- GPA_GL( ReadPixels );
- GPA_GL( DrawPixels );
- GPA_GL( GetBooleanv );
- GPA_GL( GetClipPlane );
- GPA_GL( GetDoublev );
- GPA_GL( GetError );
- GPA_GL( GetFloatv );
- GPA_GL( GetIntegerv );
- GPA_GL( GetLightfv );
- GPA_GL( GetLightiv );
- GPA_GL( GetMapdv );
- GPA_GL( GetMapfv );
- GPA_GL( GetMapiv );
- GPA_GL( GetMaterialfv );
- GPA_GL( GetMaterialiv );
- GPA_GL( GetPixelMapfv );
- GPA_GL( GetPixelMapuiv );
- GPA_GL( GetPixelMapusv );
- GPA_GL( GetPolygonStipple );
- GPA_GL( GetString );
- GPA_GL( GetTexEnvfv );
- GPA_GL( GetTexEnviv );
- GPA_GL( GetTexGendv );
- GPA_GL( GetTexGenfv );
- GPA_GL( GetTexGeniv );
- GPA_GL( GetTexImage );
- GPA_GL( GetTexParameterfv );
- GPA_GL( GetTexParameteriv );
- GPA_GL( GetTexLevelParameterfv );
- GPA_GL( GetTexLevelParameteriv );
- GPA_GL( IsEnabled );
- GPA_GL( IsList );
- GPA_GL( DepthRange );
- GPA_GL( Frustum );
- GPA_GL( LoadIdentity );
- GPA_GL( LoadMatrixf );
- GPA_GL( LoadMatrixd );
- GPA_GL( MatrixMode );
- GPA_GL( MultMatrixf );
- GPA_GL( MultMatrixd );
- GPA_GL( Ortho );
- GPA_GL( PopMatrix );
- GPA_GL( PushMatrix );
- GPA_GL( Rotated );
- GPA_GL( Rotatef );
- GPA_GL( Scaled );
- GPA_GL( Scalef );
- GPA_GL( Translated );
- GPA_GL( Translatef );
- GPA_GL( Viewport );
- GPA_GL( ArrayElement );
- GPA_GL( BindTexture );
- GPA_GL( ColorPointer );
- GPA_GL( DisableClientState );
- GPA_GL( DrawArrays );
- GPA_GL( DrawElements );
- GPA_GL( EdgeFlagPointer );
- GPA_GL( EnableClientState );
- GPA_GL( IndexPointer );
- GPA_GL( Indexub );
- GPA_GL( Indexubv );
- GPA_GL( InterleavedArrays );
- GPA_GL( NormalPointer );
- GPA_GL( PolygonOffset );
- GPA_GL( TexCoordPointer );
- GPA_GL( VertexPointer );
- GPA_GL( AreTexturesResident );
- GPA_GL( CopyTexImage1D );
- GPA_GL( CopyTexImage2D );
- GPA_GL( CopyTexSubImage1D );
- GPA_GL( CopyTexSubImage2D );
- GPA_GL( DeleteTextures );
- GPA_GL( GenTextures );
- GPA_GL( GetPointerv );
- GPA_GL( IsTexture );
- GPA_GL( PrioritizeTextures );
- GPA_GL( TexSubImage1D );
- GPA_GL( TexSubImage2D );
- GPA_GL( PopClientAttrib );
- GPA_GL( PushClientAttrib );
-}
+/**
+ * Although WGL allows different dispatch entrypoints per context
+ */
+static const GLCLTPROCTABLE cpt =
+{
+ OPENGL_VERSION_110_ENTRIES,
+ {
+ &glNewList,
+ &glEndList,
+ &glCallList,
+ &glCallLists,
+ &glDeleteLists,
+ &glGenLists,
+ &glListBase,
+ &glBegin,
+ &glBitmap,
+ &glColor3b,
+ &glColor3bv,
+ &glColor3d,
+ &glColor3dv,
+ &glColor3f,
+ &glColor3fv,
+ &glColor3i,
+ &glColor3iv,
+ &glColor3s,
+ &glColor3sv,
+ &glColor3ub,
+ &glColor3ubv,
+ &glColor3ui,
+ &glColor3uiv,
+ &glColor3us,
+ &glColor3usv,
+ &glColor4b,
+ &glColor4bv,
+ &glColor4d,
+ &glColor4dv,
+ &glColor4f,
+ &glColor4fv,
+ &glColor4i,
+ &glColor4iv,
+ &glColor4s,
+ &glColor4sv,
+ &glColor4ub,
+ &glColor4ubv,
+ &glColor4ui,
+ &glColor4uiv,
+ &glColor4us,
+ &glColor4usv,
+ &glEdgeFlag,
+ &glEdgeFlagv,
+ &glEnd,
+ &glIndexd,
+ &glIndexdv,
+ &glIndexf,
+ &glIndexfv,
+ &glIndexi,
+ &glIndexiv,
+ &glIndexs,
+ &glIndexsv,
+ &glNormal3b,
+ &glNormal3bv,
+ &glNormal3d,
+ &glNormal3dv,
+ &glNormal3f,
+ &glNormal3fv,
+ &glNormal3i,
+ &glNormal3iv,
+ &glNormal3s,
+ &glNormal3sv,
+ &glRasterPos2d,
+ &glRasterPos2dv,
+ &glRasterPos2f,
+ &glRasterPos2fv,
+ &glRasterPos2i,
+ &glRasterPos2iv,
+ &glRasterPos2s,
+ &glRasterPos2sv,
+ &glRasterPos3d,
+ &glRasterPos3dv,
+ &glRasterPos3f,
+ &glRasterPos3fv,
+ &glRasterPos3i,
+ &glRasterPos3iv,
+ &glRasterPos3s,
+ &glRasterPos3sv,
+ &glRasterPos4d,
+ &glRasterPos4dv,
+ &glRasterPos4f,
+ &glRasterPos4fv,
+ &glRasterPos4i,
+ &glRasterPos4iv,
+ &glRasterPos4s,
+ &glRasterPos4sv,
+ &glRectd,
+ &glRectdv,
+ &glRectf,
+ &glRectfv,
+ &glRecti,
+ &glRectiv,
+ &glRects,
+ &glRectsv,
+ &glTexCoord1d,
+ &glTexCoord1dv,
+ &glTexCoord1f,
+ &glTexCoord1fv,
+ &glTexCoord1i,
+ &glTexCoord1iv,
+ &glTexCoord1s,
+ &glTexCoord1sv,
+ &glTexCoord2d,
+ &glTexCoord2dv,
+ &glTexCoord2f,
+ &glTexCoord2fv,
+ &glTexCoord2i,
+ &glTexCoord2iv,
+ &glTexCoord2s,
+ &glTexCoord2sv,
+ &glTexCoord3d,
+ &glTexCoord3dv,
+ &glTexCoord3f,
+ &glTexCoord3fv,
+ &glTexCoord3i,
+ &glTexCoord3iv,
+ &glTexCoord3s,
+ &glTexCoord3sv,
+ &glTexCoord4d,
+ &glTexCoord4dv,
+ &glTexCoord4f,
+ &glTexCoord4fv,
+ &glTexCoord4i,
+ &glTexCoord4iv,
+ &glTexCoord4s,
+ &glTexCoord4sv,
+ &glVertex2d,
+ &glVertex2dv,
+ &glVertex2f,
+ &glVertex2fv,
+ &glVertex2i,
+ &glVertex2iv,
+ &glVertex2s,
+ &glVertex2sv,
+ &glVertex3d,
+ &glVertex3dv,
+ &glVertex3f,
+ &glVertex3fv,
+ &glVertex3i,
+ &glVertex3iv,
+ &glVertex3s,
+ &glVertex3sv,
+ &glVertex4d,
+ &glVertex4dv,
+ &glVertex4f,
+ &glVertex4fv,
+ &glVertex4i,
+ &glVertex4iv,
+ &glVertex4s,
+ &glVertex4sv,
+ &glClipPlane,
+ &glColorMaterial,
+ &glCullFace,
+ &glFogf,
+ &glFogfv,
+ &glFogi,
+ &glFogiv,
+ &glFrontFace,
+ &glHint,
+ &glLightf,
+ &glLightfv,
+ &glLighti,
+ &glLightiv,
+ &glLightModelf,
+ &glLightModelfv,
+ &glLightModeli,
+ &glLightModeliv,
+ &glLineStipple,
+ &glLineWidth,
+ &glMaterialf,
+ &glMaterialfv,
+ &glMateriali,
+ &glMaterialiv,
+ &glPointSize,
+ &glPolygonMode,
+ &glPolygonStipple,
+ &glScissor,
+ &glShadeModel,
+ &glTexParameterf,
+ &glTexParameterfv,
+ &glTexParameteri,
+ &glTexParameteriv,
+ &glTexImage1D,
+ &glTexImage2D,
+ &glTexEnvf,
+ &glTexEnvfv,
+ &glTexEnvi,
+ &glTexEnviv,
+ &glTexGend,
+ &glTexGendv,
+ &glTexGenf,
+ &glTexGenfv,
+ &glTexGeni,
+ &glTexGeniv,
+ &glFeedbackBuffer,
+ &glSelectBuffer,
+ &glRenderMode,
+ &glInitNames,
+ &glLoadName,
+ &glPassThrough,
+ &glPopName,
+ &glPushName,
+ &glDrawBuffer,
+ &glClear,
+ &glClearAccum,
+ &glClearIndex,
+ &glClearColor,
+ &glClearStencil,
+ &glClearDepth,
+ &glStencilMask,
+ &glColorMask,
+ &glDepthMask,
+ &glIndexMask,
+ &glAccum,
+ &glDisable,
+ &glEnable,
+ &glFinish,
+ &glFlush,
+ &glPopAttrib,
+ &glPushAttrib,
+ &glMap1d,
+ &glMap1f,
+ &glMap2d,
+ &glMap2f,
+ &glMapGrid1d,
+ &glMapGrid1f,
+ &glMapGrid2d,
+ &glMapGrid2f,
+ &glEvalCoord1d,
+ &glEvalCoord1dv,
+ &glEvalCoord1f,
+ &glEvalCoord1fv,
+ &glEvalCoord2d,
+ &glEvalCoord2dv,
+ &glEvalCoord2f,
+ &glEvalCoord2fv,
+ &glEvalMesh1,
+ &glEvalPoint1,
+ &glEvalMesh2,
+ &glEvalPoint2,
+ &glAlphaFunc,
+ &glBlendFunc,
+ &glLogicOp,
+ &glStencilFunc,
+ &glStencilOp,
+ &glDepthFunc,
+ &glPixelZoom,
+ &glPixelTransferf,
+ &glPixelTransferi,
+ &glPixelStoref,
+ &glPixelStorei,
+ &glPixelMapfv,
+ &glPixelMapuiv,
+ &glPixelMapusv,
+ &glReadBuffer,
+ &glCopyPixels,
+ &glReadPixels,
+ &glDrawPixels,
+ &glGetBooleanv,
+ &glGetClipPlane,
+ &glGetDoublev,
+ &glGetError,
+ &glGetFloatv,
+ &glGetIntegerv,
+ &glGetLightfv,
+ &glGetLightiv,
+ &glGetMapdv,
+ &glGetMapfv,
+ &glGetMapiv,
+ &glGetMaterialfv,
+ &glGetMaterialiv,
+ &glGetPixelMapfv,
+ &glGetPixelMapuiv,
+ &glGetPixelMapusv,
+ &glGetPolygonStipple,
+ &glGetString,
+ &glGetTexEnvfv,
+ &glGetTexEnviv,
+ &glGetTexGendv,
+ &glGetTexGenfv,
+ &glGetTexGeniv,
+ &glGetTexImage,
+ &glGetTexParameterfv,
+ &glGetTexParameteriv,
+ &glGetTexLevelParameterfv,
+ &glGetTexLevelParameteriv,
+ &glIsEnabled,
+ &glIsList,
+ &glDepthRange,
+ &glFrustum,
+ &glLoadIdentity,
+ &glLoadMatrixf,
+ &glLoadMatrixd,
+ &glMatrixMode,
+ &glMultMatrixf,
+ &glMultMatrixd,
+ &glOrtho,
+ &glPopMatrix,
+ &glPushMatrix,
+ &glRotated,
+ &glRotatef,
+ &glScaled,
+ &glScalef,
+ &glTranslated,
+ &glTranslatef,
+ &glViewport,
+ &glArrayElement,
+ &glBindTexture,
+ &glColorPointer,
+ &glDisableClientState,
+ &glDrawArrays,
+ &glDrawElements,
+ &glEdgeFlagPointer,
+ &glEnableClientState,
+ &glIndexPointer,
+ &glIndexub,
+ &glIndexubv,
+ &glInterleavedArrays,
+ &glNormalPointer,
+ &glPolygonOffset,
+ &glTexCoordPointer,
+ &glVertexPointer,
+ &glAreTexturesResident,
+ &glCopyTexImage1D,
+ &glCopyTexImage2D,
+ &glCopyTexSubImage1D,
+ &glCopyTexSubImage2D,
+ &glDeleteTextures,
+ &glGenTextures,
+ &glGetPointerv,
+ &glIsTexture,
+ &glPrioritizeTextures,
+ &glTexSubImage1D,
+ &glTexSubImage2D,
+ &glPopClientAttrib,
+ &glPushClientAttrib
+ }
+};
+
PGLCLTPROCTABLE APIENTRY
DrvSetContext(
@@ -521,17 +519,10 @@ DrvSetContext(
debug_printf( "%s( 0x%p, %u, 0x%p )\n",
__FUNCTION__, hdc, dhglrc, pfnSetProcTable );
- /* Although WGL allows different dispatch entrypoints per
- */
- if (!cpt_initialized) {
- init_proc_table( &cpt );
- cpt_initialized = TRUE;
- }
-
if (!stw_make_current( hdc, dhglrc ))
return NULL;
- return &cpt;
+ return (GLCLTPROCTABLE *)&cpt;
}
int APIENTRY
@@ -571,7 +562,7 @@ DrvShareLists(
if (DBG)
debug_printf( "%s\n", __FUNCTION__ );
- return FALSE;
+ return stw_share_lists(dhglrc1, dhglrc2);
}
BOOL APIENTRY
@@ -592,7 +583,7 @@ DrvSwapLayerBuffers(
if (DBG)
debug_printf( "%s\n", __FUNCTION__ );
- return FALSE;
+ return stw_swap_layer_buffers( hdc, fuPlanes );
}
BOOL APIENTRY
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index f3c7af93f5..dd97e48b14 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -64,6 +64,7 @@ stw_copy_context(
if (src && dst) {
/* FIXME */
+ assert(0);
(void) src;
(void) dst;
(void) mask;
@@ -74,6 +75,30 @@ stw_copy_context(
return ret;
}
+BOOL
+stw_share_lists(
+ UINT_PTR hglrc1,
+ UINT_PTR hglrc2 )
+{
+ struct stw_context *ctx1;
+ struct stw_context *ctx2;
+ BOOL ret = FALSE;
+
+ pipe_mutex_lock( stw_dev->mutex );
+
+ ctx1 = stw_lookup_context_locked( hglrc1 );
+ ctx2 = stw_lookup_context_locked( hglrc2 );
+
+ if (ctx1 && ctx2 &&
+ ctx1->pfi == ctx2->pfi) {
+ ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
+ }
+
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return ret;
+}
+
UINT_PTR
stw_create_layer_context(
HDC hdc,
@@ -85,7 +110,6 @@ stw_create_layer_context(
GLvisual *visual = NULL;
struct pipe_screen *screen = NULL;
struct pipe_context *pipe = NULL;
- UINT_PTR hglrc = 0;
if(!stw_dev)
return 0;
@@ -101,7 +125,7 @@ stw_create_layer_context(
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
- return 0;
+ goto no_ctx;
ctx->hdc = hdc;
ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL );
@@ -125,7 +149,7 @@ stw_create_layer_context(
pf->pfd.cAccumAlphaBits,
pf->numSamples );
if (visual == NULL)
- goto fail;
+ goto no_visual;
screen = stw_dev->screen;
@@ -137,7 +161,7 @@ stw_create_layer_context(
pipe = stw_dev->stw_winsys->create_context( screen );
if (pipe == NULL)
- goto fail;
+ goto no_pipe;
#ifdef DEBUG
/* Wrap context */
@@ -150,28 +174,29 @@ stw_create_layer_context(
ctx->st = st_create_context( pipe, visual, NULL );
if (ctx->st == NULL)
- goto fail;
+ goto no_st_ctx;
ctx->st->ctx->DriverCtx = ctx;
ctx->pfi = pf;
pipe_mutex_lock( stw_dev->mutex );
- hglrc = handle_table_add(stw_dev->ctx_table, ctx);
+ ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
pipe_mutex_unlock( stw_dev->mutex );
-
- /* Success?
- */
- if (hglrc != 0)
- return hglrc;
-
-fail:
- if (visual)
- _mesa_destroy_visual( visual );
-
- if (pipe)
- pipe->destroy( pipe );
-
+ if (!ctx->hglrc)
+ goto no_hglrc;
+
+ return ctx->hglrc;
+
+no_hglrc:
+ st_destroy_context(ctx->st);
+ goto no_pipe; /* st_context_destroy already destroys pipe */
+no_st_ctx:
+ pipe->destroy( pipe );
+no_pipe:
+ _mesa_destroy_visual( visual );
+no_visual:
FREE( ctx );
+no_ctx:
return 0;
}
@@ -253,31 +278,64 @@ stw_release_context(
/* Find the width and height of the window named by hdc.
*/
static void
-stw_get_window_size( HDC hdc, GLuint *width, GLuint *height )
+stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight )
{
- if (WindowFromDC( hdc )) {
- RECT rect;
+ GLuint width, height;
+ HWND hwnd;
- GetClientRect( WindowFromDC( hdc ), &rect );
- *width = rect.right - rect.left;
- *height = rect.bottom - rect.top;
+ hwnd = WindowFromDC( hdc );
+ if (hwnd) {
+ RECT rect;
+ GetClientRect( hwnd, &rect );
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
}
else {
- *width = GetDeviceCaps( hdc, HORZRES );
- *height = GetDeviceCaps( hdc, VERTRES );
+ width = GetDeviceCaps( hdc, HORZRES );
+ height = GetDeviceCaps( hdc, VERTRES );
}
+
+ if(width < 1)
+ width = 1;
+ if(height < 1)
+ height = 1;
+
+ *pwidth = width;
+ *pheight = height;
}
UINT_PTR
stw_get_current_context( void )
{
- return stw_tls_get_data()->currentGLRC;
+ GET_CURRENT_CONTEXT( glcurctx );
+ struct stw_context *ctx;
+
+ if(!glcurctx)
+ return 0;
+
+ ctx = (struct stw_context *)glcurctx->DriverCtx;
+ assert(ctx);
+ if(!ctx)
+ return 0;
+
+ return ctx->hglrc;
}
HDC
stw_get_current_dc( void )
{
- return stw_tls_get_data()->currentDC;
+ GET_CURRENT_CONTEXT( glcurctx );
+ struct stw_context *ctx;
+
+ if(!glcurctx)
+ return NULL;
+
+ ctx = (struct stw_context *)glcurctx->DriverCtx;
+ assert(ctx);
+ if(!ctx)
+ return NULL;
+
+ return ctx->hdc;
}
BOOL
@@ -290,7 +348,7 @@ stw_make_current(
struct stw_framebuffer *fb;
GLuint width = 0;
GLuint height = 0;
- struct stw_context *curctx;
+ struct stw_context *curctx = NULL;
if (!stw_dev)
return FALSE;
@@ -299,9 +357,6 @@ stw_make_current(
ctx = stw_lookup_context_locked( hglrc );
pipe_mutex_unlock( stw_dev->mutex );
- stw_tls_get_data()->currentDC = hdc;
- stw_tls_get_data()->currentGLRC = hglrc;
-
if (glcurctx != NULL) {
curctx = (struct stw_context *) glcurctx->DriverCtx;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
index bc3b1dc880..e276737e85 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.h
@@ -36,6 +36,7 @@ struct stw_pixelformat_info;
struct stw_context
{
struct st_context *st;
+ UINT_PTR hglrc;
HDC hdc;
DWORD color_bits;
const struct stw_pixelformat_info *pfi;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c b/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c
index cd9fe93eee..2660c591f9 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c
@@ -1,5 +1,6 @@
/**************************************************************************
*
+ * Copyright 2009 VMware, Inc.
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
@@ -33,14 +34,25 @@
#include <GL/wglext.h>
+static const char *stw_extension_string =
+ "WGL_ARB_extensions_string "
+ "WGL_ARB_multisample "
+ "WGL_ARB_pixel_format "
+ "WGL_EXT_extensions_string";
+
+
WINGDIAPI const char * APIENTRY
wglGetExtensionsStringARB(
HDC hdc )
{
(void) hdc;
- return
- "WGL_ARB_extensions_string "
- "WGL_ARB_multisample "
- "WGL_ARB_pixel_format";
+ return stw_extension_string;
+}
+
+
+WINGDIAPI const char * APIENTRY
+wglGetExtensionsStringEXT( void )
+{
+ return stw_extension_string;
}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index 4348b8f326..f66f429542 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -237,6 +237,18 @@ stw_swap_buffers(
}
+BOOL
+stw_swap_layer_buffers(
+ HDC hdc,
+ UINT fuPlanes )
+{
+ if(fuPlanes & WGL_SWAP_MAIN_PLANE)
+ return stw_swap_buffers(hdc);
+
+ return FALSE;
+}
+
+
boolean
stw_framebuffer_init_thread(void)
{
diff --git a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
index aa43120955..4070cbd5c0 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
@@ -53,6 +53,9 @@ static const struct stw_extension_entry stw_extension_entries[] = {
STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
+ /* WGL_EXT_extensions_string */
+ STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
+
{ NULL, NULL }
};
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
index 9e642cbdd4..b81d2b59a4 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
@@ -119,6 +119,7 @@ stw_pixelformat_add(
struct stw_device *stw_dev,
const struct stw_pf_color_info *color,
const struct stw_pf_depth_info *depth,
+ unsigned accum,
boolean doublebuffer,
unsigned samples )
{
@@ -158,7 +159,7 @@ stw_pixelformat_add(
pfi->pfd.iPixelType = PFD_TYPE_RGBA;
- pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue;
+ pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha;
pfi->pfd.cRedBits = color->bits.red;
pfi->pfd.cRedShift = color->shift.red;
pfi->pfd.cGreenBits = color->bits.green;
@@ -167,11 +168,11 @@ stw_pixelformat_add(
pfi->pfd.cBlueShift = color->shift.blue;
pfi->pfd.cAlphaBits = color->bits.alpha;
pfi->pfd.cAlphaShift = color->shift.alpha;
- pfi->pfd.cAccumBits = 0;
- pfi->pfd.cAccumRedBits = 0;
- pfi->pfd.cAccumGreenBits = 0;
- pfi->pfd.cAccumBlueBits = 0;
- pfi->pfd.cAccumAlphaBits = 0;
+ pfi->pfd.cAccumBits = 4*accum;
+ pfi->pfd.cAccumRedBits = accum;
+ pfi->pfd.cAccumGreenBits = accum;
+ pfi->pfd.cAccumBlueBits = accum;
+ pfi->pfd.cAccumAlphaBits = accum;
pfi->pfd.cDepthBits = depth->bits.depth;
pfi->pfd.cStencilBits = depth->bits.stencil;
pfi->pfd.cAuxBuffers = 0;
@@ -228,7 +229,8 @@ stw_pixelformat_init( void )
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
continue;
- stw_pixelformat_add( stw_dev, color, depth, doublebuffer, samples );
+ stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
+ stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples );
}
}
}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h
index 39d377c16b..7fe9cfb356 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_public.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_public.h
@@ -37,6 +37,8 @@ BOOL stw_copy_context( UINT_PTR hglrcSrc,
UINT_PTR stw_create_layer_context( HDC hdc,
int iLayerPlane );
+BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 );
+
BOOL stw_delete_context( UINT_PTR hglrc );
BOOL
@@ -50,6 +52,9 @@ BOOL stw_make_current( HDC hdc, UINT_PTR hglrc );
BOOL stw_swap_buffers( HDC hdc );
+BOOL
+stw_swap_layer_buffers( HDC hdc, UINT fuPlanes );
+
PROC stw_get_proc_address( LPCSTR lpszProc );
int stw_pixelformat_describe( HDC hdc,
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c
index e72bafb880..95863ca9cf 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_tls.c
@@ -44,6 +44,20 @@ stw_tls_init(void)
return TRUE;
}
+static INLINE struct stw_tls_data *
+stw_tls_data_create()
+{
+ struct stw_tls_data *data;
+
+ data = CALLOC_STRUCT(stw_tls_data);
+ if (!data)
+ return NULL;
+
+ data->currentPixelFormat = 0;
+
+ return data;
+}
+
boolean
stw_tls_init_thread(void)
{
@@ -53,14 +67,9 @@ stw_tls_init_thread(void)
return FALSE;
}
- data = MALLOC(sizeof(*data));
- if (!data) {
+ data = stw_tls_data_create();
+ if(!data)
return FALSE;
- }
-
- data->currentPixelFormat = 0;
- data->currentDC = NULL;
- data->currentGLRC = 0;
TlsSetValue(tlsIndex, data);
@@ -93,9 +102,23 @@ stw_tls_cleanup(void)
struct stw_tls_data *
stw_tls_get_data(void)
{
+ struct stw_tls_data *data;
+
if (tlsIndex == TLS_OUT_OF_INDEXES) {
return NULL;
}
+
+ data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
+ if(!data) {
+ /* DllMain is called with DLL_THREAD_ATTACH only by threads created after
+ * the DLL is loaded by the process */
+
+ data = stw_tls_data_create();
+ if(!data)
+ return NULL;
+
+ TlsSetValue(tlsIndex, data);
+ }
- return (struct stw_tls_data *) TlsGetValue(tlsIndex);
+ return data;
}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h
index f5a6bdf4b1..6cfb0899f2 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h
@@ -33,8 +33,6 @@
struct stw_tls_data
{
uint currentPixelFormat;
- HDC currentDC;
- UINT_PTR currentGLRC;
HHOOK hCallWndProcHook;
};
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
index e06d2640b4..a131292f7a 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
@@ -100,10 +100,7 @@ wglSwapLayerBuffers(
HDC hdc,
UINT fuPlanes )
{
- (void) hdc;
- (void) fuPlanes;
-
- return FALSE;
+ return stw_swap_layer_buffers( hdc, fuPlanes );
}
WINGDIAPI PROC APIENTRY
@@ -189,12 +186,7 @@ wglShareLists(
HGLRC hglrc1,
HGLRC hglrc2 )
{
- (void) hglrc1;
- (void) hglrc2;
-
- assert( 0 );
-
- return FALSE;
+ return stw_share_lists( (UINT_PTR)hglrc1, (UINT_PTR)hglrc2);;
}
WINGDIAPI BOOL APIENTRY
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index d04204e1bf..401bd39dac 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -28,6 +28,7 @@
*
*/
+#include "xorg-server.h"
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -85,7 +86,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
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;
@@ -98,7 +98,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
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;
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 8a2711e70c..45e831f0c2 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -476,7 +476,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
if (!ms->screen) {
- ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id);
+ ms->screen = drm_api_hooks.create_screen(ms->fd, NULL);
if (!ms->screen) {
FatalError("Could not init pipe_screen\n");
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index 56c8fdccb2..7913174354 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -28,6 +28,7 @@
*
*/
+#include "xorg-server.h"
#include "xf86.h"
#include "xorg_tracker.h"
@@ -36,6 +37,8 @@
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_rect.h"
+
struct exa_entity
{
ExaDriverPtr pExa;
@@ -425,7 +428,6 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
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;
@@ -436,6 +438,18 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
priv->tex = exa->scrn->texture_create(exa->scrn, &template);
}
+ if (pPixData) {
+ struct pipe_transfer *transfer =
+ exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0,
+ PIPE_TRANSFER_WRITE,
+ 0, 0, width, height);
+ pipe_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer),
+ &priv->tex->block, transfer->stride, 0, 0,
+ width, height, pPixData, pPixmap->devKind, 0, 0);
+ exa->scrn->transfer_unmap(exa->scrn, transfer);
+ exa->scrn->tex_transfer_destroy(transfer);
+ }
+
return TRUE;
}