summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/xorg
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/xorg')
-rw-r--r--src/gallium/state_trackers/xorg/Makefile37
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c27
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.h22
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c8
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c81
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c38
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c156
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.h29
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h15
9 files changed, 296 insertions, 117 deletions
diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile
index a00ea3e2a4..27a1990724 100644
--- a/src/gallium/state_trackers/xorg/Makefile
+++ b/src/gallium/state_trackers/xorg/Makefile
@@ -1,29 +1,18 @@
-TARGET = libxorgtracker.a
-CFILES = $(wildcard ./*.c)
-OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES))
-GALLIUMDIR = ../..
-TOP = ../../../..
-
+TOP = ../../../..
include $(TOP)/configs/current
-CFLAGS = -DHAVE_CONFIG_H \
- -g -Wall -Wimplicit-function-declaration -fPIC \
- $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \
- -I$(GALLIUMDIR)/include \
- -I$(GALLIUMDIR)/auxiliary \
- -I$(TOP)/src/mesa/drivers/dri/common \
- -I$(TOP)/src/mesa \
- -I$(TOP)/include \
- -I$(TOP)/src/egl/main
-
-#############################################
-
-.PHONY = all clean
+LIBNAME = xorgtracker
-all: $(TARGET)
+LIBRARY_INCLUDES = \
+ -DHAVE_CONFIG_H \
+ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
+ -I$(TOP)/src/gallium/include \
+ -I$(TOP)/src/gallium/auxiliary \
+ -I$(TOP)/include \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -I$(TOP)/src/mesa/main
-$(TARGET): $(OBJECTS)
- ar rcs $(TARGET) $(OBJECTS)
+C_SOURCES = $(wildcard ./*.c)
-clean:
- rm -rf $(OBJECTS) $(TARGET)
+include ../../Makefile.template
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
new file mode 100644
index 0000000000..255ae91f09
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -0,0 +1,27 @@
+#include "xorg_composite.h"
+
+
+boolean xorg_composite_accelerated(int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ return FALSE;
+}
+
+boolean xorg_composite_bind_state(struct exa_context *exa,
+ int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ return FALSE;
+}
+
+void xorg_composite(struct exa_context *exa,
+ struct exa_pixmap_priv *dst,
+ int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int width, int height)
+{
+}
+
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.h b/src/gallium/state_trackers/xorg/xorg_composite.h
new file mode 100644
index 0000000000..a52e0e6dff
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_composite.h
@@ -0,0 +1,22 @@
+#ifndef XORG_COMPOSITE_H
+#define XORG_COMPOSITE_H
+
+#include "xorg_exa.h"
+
+boolean xorg_composite_accelerated(int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+
+boolean xorg_composite_bind_state(struct exa_context *exa,
+ int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+
+void xorg_composite(struct exa_context *exa,
+ struct exa_pixmap_priv *dst,
+ int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int width, int height);
+
+#endif
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 7304113a65..2235961b03 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -171,7 +171,6 @@ crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
static void
crtc_destroy(xf86CrtcPtr crtc)
{
- modesettingPtr ms = modesettingPTR(crtc->scrn);
struct crtc_private *crtcp = crtc->driver_private;
if (crtcp->cursor_buf)
@@ -194,9 +193,10 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
PIPE_BUFFER_USAGE_CPU_WRITE |
PIPE_BUFFER_USAGE_GPU_READ,
64*64*4);
- drm_api_hooks.handle_from_buffer(ms->screen,
- crtcp->cursor_buf,
- &crtcp->cursor_handle);
+ ms->api->handle_from_buffer(ms->api,
+ ms->screen,
+ crtcp->cursor_buf,
+ &crtcp->cursor_handle);
}
ptr = pipe_buffer_map(ms->screen, crtcp->cursor_buf, PIPE_BUFFER_USAGE_CPU_WRITE);
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 401bd39dac..3fbab4dc51 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -39,10 +39,13 @@
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_rect.h"
+
typedef struct {
PixmapPtr pPixmap;
struct pipe_texture *tex;
struct pipe_buffer *buf;
+ struct pipe_fence_handle *fence;
} *BufferPrivatePtr;
static DRI2BufferPtr
@@ -83,7 +86,6 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
pipe_texture_reference(&tex, depth);
} else if (attachments[i] == DRI2BufferDepth) {
struct pipe_texture template;
-
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
template.format = PIPE_FORMAT_S8Z24_UNORM;
@@ -92,24 +94,22 @@ driCreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
template.height[0] = pDraw->height;
template.depth[0] = 1;
template.last_level = 0;
- template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
tex = ms->screen->texture_create(ms->screen, &template);
+ depth = tex;
} else {
- struct pipe_texture template;
- memset(&template, 0, sizeof(template));
- template.target = PIPE_TEXTURE_2D;
- template.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- pf_get_block(template.format, &template.block);
- template.width[0] = pDraw->width;
- template.height[0] = pDraw->height;
- template.depth[0] = 1;
- template.last_level = 0;
- template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
- tex = ms->screen->texture_create(ms->screen, &template);
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, pDraw->width,
+ pDraw->height,
+ pDraw->depth,
+ 0);
+ tex = xorg_exa_get_texture(pPixmap);
}
- drm_api_hooks.buffer_from_texture(tex, &buf, &stride);
- drm_api_hooks.global_handle_from_buffer(ms->screen, buf, &handle);
+ if (!tex)
+ FatalError("NO TEXTURE IN DRI2\n");
+
+ ms->api->buffer_from_texture(ms->api, tex, &buf, &stride);
+ ms->api->global_handle_from_buffer(ms->api, ms->screen, buf, &handle);
buffers[i].name = handle;
buffers[i].attachment = attachments[i];
@@ -138,15 +138,17 @@ driDestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
modesettingPtr ms = modesettingPTR(pScrn);
BufferPrivatePtr private;
int i;
+ (void)ms;
for (i = 0; i < count; i++) {
private = buffers[i].driverPrivate;
- if (private->pPixmap)
- (*pScreen->DestroyPixmap)(private->pPixmap);
-
pipe_texture_reference(&private->tex, NULL);
pipe_buffer_reference(&private->buf, NULL);
+ ms->screen->fence_reference(ms->screen, &private->fence, NULL);
+
+ if (private->pPixmap)
+ (*pScreen->DestroyPixmap)(private->pPixmap);
}
if (buffers) {
@@ -164,19 +166,42 @@ driCopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
modesettingPtr ms = modesettingPTR(pScrn);
BufferPrivatePtr dst_priv = pDestBuffer->driverPrivate;
BufferPrivatePtr src_priv = pSrcBuffer->driverPrivate;
+ PixmapPtr src_pixmap;
+ PixmapPtr dst_pixmap;
+ GCPtr gc;
+ RegionPtr copy_clip;
+
+ src_pixmap = src_priv->pPixmap;
+ dst_pixmap = dst_priv->pPixmap;
+ if (pSrcBuffer->attachment == DRI2BufferFrontLeft)
+ src_pixmap = (PixmapPtr)pDraw;
+ if (pDestBuffer->attachment == DRI2BufferFrontLeft)
+ dst_pixmap = (PixmapPtr)pDraw;
+ gc = GetScratchGC(pDraw->depth, pScreen);
+ copy_clip = REGION_CREATE(pScreen, NULL, 0);
+ REGION_COPY(pScreen, copy_clip, pRegion);
+ (*gc->funcs->ChangeClip) (gc, CT_REGION, copy_clip, 0);
+ ValidateGC(&dst_pixmap->drawable, gc);
+
+ /* If this is a full buffer swap, throttle on the previous one */
+ if (dst_priv->fence && REGION_NUM_RECTS(pRegion) == 1) {
+ BoxPtr extents = REGION_EXTENTS(pScreen, pRegion);
+
+ if (extents->x1 == 0 && extents->y1 == 0 &&
+ extents->x2 == pDraw->width && extents->y2 == pDraw->height) {
+ ms->screen->fence_finish(ms->screen, dst_priv->fence, 0);
+ ms->screen->fence_reference(ms->screen, &dst_priv->fence, NULL);
+ }
+ }
- struct pipe_surface *dst_surf =
- ms->screen->get_tex_surface(ms->screen, dst_priv->tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
- struct pipe_surface *src_surf =
- ms->screen->get_tex_surface(ms->screen, src_priv->tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ);
+ (*gc->ops->CopyArea)(&src_pixmap->drawable, &dst_pixmap->drawable, gc,
+ 0, 0, pDraw->width, pDraw->height, 0, 0);
- ms->ctx->surface_copy(ms->ctx, dst_surf, 0, 0, src_surf,
- 0, 0, pDraw->width, pDraw->height);
+ FreeScratchGC(gc);
- pipe_surface_reference(&dst_surf, NULL);
- pipe_surface_reference(&src_surf, NULL);
+ ms->ctx->flush(ms->ctx, PIPE_FLUSH_SWAPBUFFERS,
+ pDestBuffer->attachment == DRI2BufferFrontLeft ?
+ &dst_priv->fence : NULL);
}
Bool
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 45e831f0c2..53d1a33095 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -179,8 +179,10 @@ CreateFrontBuffer(ScrnInfoPtr pScrn)
modesettingPtr ms = modesettingPTR(pScrn);
ScreenPtr pScreen = pScrn->pScreen;
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+ unsigned handle, stride;
ms->noEvict = TRUE;
+ xorg_exa_set_displayed_usage(rootPixmap);
pScreen->ModifyPixmapHeader(rootPixmap,
pScrn->virtualX, pScrn->virtualY,
pScrn->depth, pScrn->bitsPerPixel,
@@ -188,13 +190,16 @@ CreateFrontBuffer(ScrnInfoPtr pScrn)
NULL);
ms->noEvict = FALSE;
+ handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
+
drmModeAddFB(ms->fd,
pScrn->virtualX,
pScrn->virtualY,
pScrn->depth,
pScrn->bitsPerPixel,
- pScrn->displayWidth * pScrn->bitsPerPixel / 8,
- xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id);
+ stride,
+ handle,
+ &ms->fb_id);
pScrn->frameX0 = 0;
pScrn->frameY0 = 0;
@@ -300,6 +305,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
ms->PciInfo->dev, ms->PciInfo->func
);
+ ms->api = drm_api_create();
ms->fd = drmOpen(NULL, BusID);
if (ms->fd < 0)
@@ -425,6 +431,7 @@ CreateScreenResources(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
PixmapPtr rootPixmap;
Bool ret;
+ unsigned handle, stride;
ms->noEvict = TRUE;
@@ -434,18 +441,22 @@ CreateScreenResources(ScreenPtr pScreen)
rootPixmap = pScreen->GetScreenPixmap(pScreen);
+ xorg_exa_set_displayed_usage(rootPixmap);
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
FatalError("Couldn't adjust screen pixmap\n");
ms->noEvict = FALSE;
+ handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride);
+
drmModeAddFB(ms->fd,
pScrn->virtualX,
pScrn->virtualY,
pScrn->depth,
pScrn->bitsPerPixel,
- pScrn->displayWidth * pScrn->bitsPerPixel / 8,
- xorg_exa_get_pixmap_handle(rootPixmap), &ms->fb_id);
+ stride,
+ handle,
+ &ms->fb_id);
AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
@@ -476,7 +487,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
if (!ms->screen) {
- ms->screen = drm_api_hooks.create_screen(ms->fd, NULL);
+ ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);
if (!ms->screen) {
FatalError("Could not init pipe_screen\n");
@@ -622,6 +633,10 @@ LeaveVT(int scrnIndex, int flags)
RestoreHWState(pScrn);
+ if (drmDropMaster(ms->fd))
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "drmDropMaster failed: %s\n", strerror(errno));
+
pScrn->vtSema = FALSE;
}
@@ -634,6 +649,17 @@ EnterVT(int scrnIndex, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
modesettingPtr ms = modesettingPTR(pScrn);
+ if (drmSetMaster(ms->fd)) {
+ if (errno == EINVAL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "drmSetMaster failed: 2.6.29 or newer kernel required for "
+ "multi-server DRI\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "drmSetMaster failed: %s\n", strerror(errno));
+ }
+ }
+
/*
* Only save state once per server generation since that's what most
* drivers do. Could change this to save state at each VT enter.
@@ -678,6 +704,8 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen)
if (ms->exa)
xorg_exa_close(pScrn);
+ ms->api->destroy(ms->api);
+ ms->api = NULL;
drmClose(ms->fd);
ms->fd = -1;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index 7913174354..f2dac73e90 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -28,9 +28,14 @@
*
*/
-#include "xorg-server.h"
-#include "xf86.h"
+#include "xorg_exa.h"
#include "xorg_tracker.h"
+#include "xorg_composite.h"
+
+#include <xorg-server.h>
+#include <xf86.h>
+#include <picturestr.h>
+#include <picture.h>
#include "pipe/p_format.h"
#include "pipe/p_context.h"
@@ -39,24 +44,6 @@
#include "util/u_rect.h"
-struct exa_entity
-{
- ExaDriverPtr pExa;
- struct pipe_context *ctx;
- struct pipe_screen *scrn;
-};
-
-struct PixmapPriv
-{
- int flags;
- struct pipe_texture *tex;
- unsigned int color;
- struct pipe_surface *src_surf; /* for copies */
-
- struct pipe_transfer *map_transfer;
- unsigned map_count;
-};
-
/*
* Helper functions
*/
@@ -113,8 +100,8 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
ScreenPtr pScreen = pPix->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
- struct PixmapPriv *priv;
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv;
priv = exaGetPixmapDriverPrivate(pPix);
@@ -145,8 +132,8 @@ ExaFinishAccess(PixmapPtr pPix, int index)
ScreenPtr pScreen = pPix->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
- struct PixmapPriv *priv;
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv;
priv = exaGetPixmapDriverPrivate(pPix);
if (!priv)
@@ -168,8 +155,8 @@ ExaDone(PixmapPtr pPixmap)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
- struct exa_entity *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_context *exa = ms->exa;
if (!priv)
return;
@@ -190,8 +177,8 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
- struct exa_entity *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_context *exa = ms->exa;
if (1)
return FALSE;
@@ -221,8 +208,8 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
struct pipe_surface *surf =
exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ |
@@ -240,9 +227,9 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
{
ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
- struct PixmapPriv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
+ struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
if (1)
return FALSE;
@@ -279,8 +266,8 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
{
ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
struct pipe_surface *surf =
exa->scrn->get_tex_surface(exa->scrn, priv->tex, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ |
@@ -296,13 +283,25 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
PicturePtr pMaskPicture, PicturePtr pDstPicture,
PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
- return FALSE;
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_context *exa = ms->exa;
+
+ return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
+ pDstPicture);
}
static void
ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
int dstX, int dstY, int width, int height)
{
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_context *exa = ms->exa;
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
+
+ xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
+ dstX, dstY, width, height);
}
static Bool
@@ -310,15 +309,18 @@ ExaCheckComposite(int op,
PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
- return FALSE;
+ return xorg_composite_accelerated(op,
+ pSrcPicture,
+ pMaskPicture,
+ pDstPicture);
}
static void *
ExaCreatePixmap(ScreenPtr pScreen, int size, int align)
{
- struct PixmapPriv *priv;
+ struct exa_pixmap_priv *priv;
- priv = xcalloc(1, sizeof(struct PixmapPriv));
+ priv = xcalloc(1, sizeof(struct exa_pixmap_priv));
if (!priv)
return NULL;
@@ -328,7 +330,7 @@ ExaCreatePixmap(ScreenPtr pScreen, int size, int align)
static void
ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
{
- struct PixmapPriv *priv = (struct PixmapPriv *)dPriv;
+ struct exa_pixmap_priv *priv = (struct exa_pixmap_priv *)dPriv;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
@@ -344,7 +346,7 @@ ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
static Bool
ExaPixmapIsOffscreen(PixmapPtr pPixmap)
{
- struct PixmapPriv *priv;
+ struct exa_pixmap_priv *priv;
priv = exaGetPixmapDriverPrivate(pPixmap);
@@ -357,13 +359,53 @@ ExaPixmapIsOffscreen(PixmapPtr pPixmap)
return FALSE;
}
+int
+xorg_exa_set_displayed_usage(PixmapPtr pPixmap)
+{
+ struct exa_pixmap_priv *priv;
+ priv = exaGetPixmapDriverPrivate(pPixmap);
+
+ if (!priv) {
+ FatalError("NO PIXMAP PRIVATE\n");
+ return 0;
+ }
+
+ if (priv->flags & ~PIPE_TEXTURE_USAGE_PRIMARY) {
+ FatalError("BAD FLAGS\n");
+ return 0;
+ }
+ priv->flags = PIPE_TEXTURE_USAGE_PRIMARY;
+
+ return 0;
+}
+
+int
+xorg_exa_set_shared_usage(PixmapPtr pPixmap)
+{
+ struct exa_pixmap_priv *priv;
+ priv = exaGetPixmapDriverPrivate(pPixmap);
+
+ if (!priv) {
+ FatalError("NO PIXMAP PRIVATE\n");
+ return 0;
+ }
+
+ if (priv->flags & ~PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+ FatalError("BAD FLAGS\n");
+ return 0;
+ }
+ priv->flags = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+
+ return 0;
+}
+
unsigned
-xorg_exa_get_pixmap_handle(PixmapPtr pPixmap)
+xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride_out)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
- struct PixmapPriv *priv;
+ struct exa_pixmap_priv *priv;
struct pipe_buffer *buffer = NULL;
unsigned handle;
unsigned stride;
@@ -380,9 +422,12 @@ xorg_exa_get_pixmap_handle(PixmapPtr pPixmap)
return 0;
}
- drm_api_hooks.buffer_from_texture(priv->tex, &buffer, &stride);
- drm_api_hooks.handle_from_buffer(ms->screen, buffer, &handle);
+ ms->api->buffer_from_texture(ms->api, priv->tex, &buffer, &stride);
+ ms->api->handle_from_buffer(ms->api, ms->screen, buffer, &handle);
pipe_buffer_reference(&buffer, NULL);
+ if (stride_out)
+ *stride_out = stride;
+
return handle;
}
@@ -393,9 +438,9 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
+ struct exa_context *exa = ms->exa;
if (!priv)
return FALSE;
@@ -419,7 +464,9 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
bitsPerPixel, devKind, NULL);
/* Deal with screen resize */
- if (priv->tex && (priv->tex->width[0] != width || priv->tex->height[0] != height)) {
+ if (priv->tex && (priv->tex->width[0] != width ||
+ priv->tex->height[0] != height ||
+ priv->tex_flags != priv->flags)) {
pipe_texture_reference(&priv->tex, NULL);
}
@@ -434,7 +481,8 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
template.height[0] = height;
template.depth[0] = 1;
template.last_level = 0;
- template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags;
+ priv->tex_flags = priv->flags;
priv->tex = exa->scrn->texture_create(exa->scrn, &template);
}
@@ -456,7 +504,7 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
struct pipe_texture *
xorg_exa_get_texture(PixmapPtr pPixmap)
{
- struct PixmapPriv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
struct pipe_texture *tex = NULL;
pipe_texture_reference(&tex, priv->tex);
return tex;
@@ -466,7 +514,7 @@ void
xorg_exa_close(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa = ms->exa;
+ struct exa_context *exa = ms->exa;
if (exa->ctx)
exa->ctx->destroy(exa->ctx);
@@ -480,10 +528,10 @@ void *
xorg_exa_init(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- struct exa_entity *exa;
+ struct exa_context *exa;
ExaDriverPtr pExa;
- exa = xcalloc(1, sizeof(struct exa_entity));
+ exa = xcalloc(1, sizeof(struct exa_context));
if (!exa)
return NULL;
@@ -527,7 +575,7 @@ xorg_exa_init(ScrnInfoPtr pScrn)
}
exa->scrn = ms->screen;
- exa->ctx = drm_api_hooks.create_context(exa->scrn);
+ exa->ctx = ms->api->create_context(ms->api, exa->scrn);
/* Share context with DRI */
ms->ctx = exa->ctx;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h
new file mode 100644
index 0000000000..f0508eb2d5
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_exa.h
@@ -0,0 +1,29 @@
+#ifndef XORG_EXA_H
+#define XORG_EXA_H
+
+#include "xorg_tracker.h"
+
+struct exa_context
+{
+ ExaDriverPtr pExa;
+ struct pipe_context *ctx;
+ struct pipe_screen *scrn;
+};
+
+
+struct exa_pixmap_priv
+{
+ int flags;
+ int tex_flags;
+
+ struct pipe_texture *tex;
+ unsigned int color;
+ struct pipe_surface *src_surf; /* for copies */
+
+ struct pipe_transfer *map_transfer;
+ unsigned map_count;
+};
+
+
+
+#endif
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index 82c3890dfb..910782dbc4 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -31,11 +31,15 @@
#ifndef _XORG_TRACKER_H_
#define _XORG_TRACKER_H_
+#include <stddef.h>
+#include <stdint.h>
#include <errno.h>
#include <drm.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include "exa.h"
+#include <xorg-server.h>
+#include <xf86.h>
+#include <exa.h>
#include "pipe/p_screen.h"
#include "state_tracker/drm_api.h"
@@ -75,6 +79,7 @@ typedef struct _modesettingRec
CreateScreenResourcesProcPtr createScreenResources;
/* gallium */
+ struct drm_api *api;
struct pipe_screen *screen;
struct pipe_context *ctx;
@@ -94,7 +99,13 @@ struct pipe_texture *
xorg_exa_get_texture(PixmapPtr pPixmap);
unsigned
-xorg_exa_get_pixmap_handle(PixmapPtr pPixmap);
+xorg_exa_get_pixmap_handle(PixmapPtr pPixmap, unsigned *stride);
+
+int
+xorg_exa_set_displayed_usage(PixmapPtr pPixmap);
+
+int
+xorg_exa_set_shared_usage(PixmapPtr pPixmap);
void *
xorg_exa_init(ScrnInfoPtr pScrn);