summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/dri2
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/dri2')
-rw-r--r--src/gallium/state_trackers/dri2/dri_context.c6
-rw-r--r--src/gallium/state_trackers/dri2/dri_drawable.c74
-rw-r--r--src/gallium/state_trackers/dri2/dri_drawable.h5
-rw-r--r--src/gallium/state_trackers/dri2/dri_screen.c21
4 files changed, 61 insertions, 45 deletions
diff --git a/src/gallium/state_trackers/dri2/dri_context.c b/src/gallium/state_trackers/dri2/dri_context.c
index a8a94be176..92c26ac70f 100644
--- a/src/gallium/state_trackers/dri2/dri_context.c
+++ b/src/gallium/state_trackers/dri2/dri_context.c
@@ -71,12 +71,13 @@ dri_create_context(const __GLcontextModes *visual,
sPriv->myNum,
"dri");
- ctx->pipe = drm_api_hocks.create_context(screen->pipe_screen);
+ 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)
@@ -152,6 +153,7 @@ dri_make_current(__DRIcontextPrivate *cPriv,
draw->stfb,
read->stfb);
+ /* used in dri_flush_frontbuffer */
ctx->dPriv = driDrawPriv;
if (driDrawPriv)
diff --git a/src/gallium/state_trackers/dri2/dri_drawable.c b/src/gallium/state_trackers/dri2/dri_drawable.c
index 120d45bc03..aa86411190 100644
--- a/src/gallium/state_trackers/dri2/dri_drawable.c
+++ b/src/gallium/state_trackers/dri2/dri_drawable.c
@@ -44,6 +44,15 @@
#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,
@@ -57,7 +66,7 @@ dri_surface_from_handle(struct pipe_screen *screen,
struct pipe_texture templat;
struct pipe_buffer *buf = NULL;
- buf = drm_api_hocks.buffer_from_handle(screen, "dri2 buffer", handle);
+ buf = drm_api_hooks.buffer_from_handle(screen, "dri2 buffer", handle);
if (!buf)
return NULL;
@@ -77,7 +86,7 @@ dri_surface_from_handle(struct pipe_screen *screen,
buf);
/* we don't need the buffer from this point on */
- pipe_buffer_reference(screen, &buf, NULL);
+ pipe_buffer_reference(&buf, NULL);
if (!texture)
return NULL;
@@ -144,6 +153,10 @@ dri_get_buffers(__DRIdrawablePrivate *dPriv)
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;
@@ -185,50 +198,28 @@ dri_get_buffers(__DRIdrawablePrivate *dPriv)
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)
{
- struct dri_drawable *drawable = dri_drawable(dPriv);
- struct pipe_surface *back_surf;
-
- assert(drawable);
- assert(drawable->stfb);
-
- st_get_framebuffer_surface(drawable->stfb,
- ST_SURFACE_BACK_LEFT,
- &back_surf);
- if (back_surf) {
- st_notify_swapbuffers(drawable->stfb);
- /* TODO do stuff here */
- st_notify_swapbuffers_complete(drawable->stfb);
- }
+ /* not needed for dri2 */
+ assert(0);
}
-/**
- * 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);
-
- st_get_framebuffer_surface(drawable->stfb,
- ST_SURFACE_BACK_LEFT,
- &back_surf);
- if (back_surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = w;
- rect.y2 = h;
-
- /* do stuff here */
- }
+ /* not needed for dri2 */
+ assert(0);
}
@@ -288,7 +279,12 @@ dri_create_buffer(__DRIscreenPrivate *sPriv,
/* setup dri2 buffers information */
i = 0;
drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
- drawable->attachments[i++] = __DRI_BUFFER_BACK_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)
diff --git a/src/gallium/state_trackers/dri2/dri_drawable.h b/src/gallium/state_trackers/dri2/dri_drawable.h
index d40d09c9b5..185c657b35 100644
--- a/src/gallium/state_trackers/dri2/dri_drawable.h
+++ b/src/gallium/state_trackers/dri2/dri_drawable.h
@@ -66,6 +66,11 @@ dri_create_buffer(__DRIscreenPrivate *sPriv,
boolean isPixmap);
void
+dri_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf,
+ void *context_private);
+
+void
dri_swap_buffers(__DRIdrawablePrivate * dPriv);
void
diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c
index 1fef538294..ab5878a4bc 100644
--- a/src/gallium/state_trackers/dri2/dri_screen.c
+++ b/src/gallium/state_trackers/dri2/dri_screen.c
@@ -184,6 +184,16 @@ dri_get_swap_info(__DRIdrawablePrivate * dPriv,
/**
+ * NULL stub for old dri loaders
+ */
+const __DRIconfig **
+dri_init_screen(__DRIscreenPrivate *sPriv)
+{
+ return NULL;
+}
+
+
+/**
* This is the driver specific part of the createNewScreen entry point.
*
* Returns the __GLcontextModes supported by this driver.
@@ -208,12 +218,15 @@ dri_init_screen2(__DRIscreenPrivate *sPriv)
sPriv->extensions = dri_screen_extensions;
- screen->pipe_screen = drm_api_hocks.create_screen(screen->fd, screen->deviceID);
+ 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,
__driNConfigOptions);
@@ -240,19 +253,19 @@ dri_destroy_screen(__DRIscreenPrivate * sPriv)
PUBLIC const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = NULL,
+ .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,
+ .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,
+ .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */
.InitScreen2 = dri_init_screen2,
};