g3dvl: Shared drm winsys bits.

This commit is contained in:
Younes Manton 2009-11-05 23:58:29 -05:00
parent dcccbfd14e
commit 8ebc795ec4
18 changed files with 60 additions and 456 deletions

View file

@ -2,7 +2,7 @@
TOP = ../../..
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_DIRS)
SUBDIRS = $(GALLIUM_WINSYS_DIRS) g3dvl
default install clean:
@for dir in $(SUBDIRS) ; do \

View file

@ -1,7 +1,8 @@
# src/gallium/winsys/Makefile
TOP = ../../../..
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_DIRS)
SUBDIRS = $(GALLIUM_STATE_TRACKERS_DIRS) $(GALLIUM_WINSYS_DIRS)
default install clean:
@for dir in $(SUBDIRS) ; do \

View file

@ -0,0 +1,14 @@
TOP = ../../../../..
include $(TOP)/configs/current
LIBNAME = vldri
LIBRARY_INCLUDES = -I$(TOP)/src/gallium/winsys/g3dvl \
$(shell pkg-config libdrm --cflags-only-I)
C_SOURCES = \
driclient.c \
XF86dri.c \
dri_winsys.c
include ../../../Makefile.template

View file

@ -0,0 +1,12 @@
# src/gallium/winsys/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS)
default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done

View file

@ -1,34 +1,9 @@
# This makefile produces a libXvMCg3dvl.so which is
# based on DRM/DRI
TOP = ../../../../..
include $(TOP)/configs/current
XVMC_MAJOR = 1
XVMC_MINOR = 0
XVMC_LIB = XvMCg3dvl
XVMC_LIB_NAME = lib$(XVMC_LIB).so
XVMC_LIB_DEPS = $(EXTRA_LIB_PATH) -lXvMC -lXv -lX11 -lm
SOURCES = drm_nouveau_winsys.c
DRIVER_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) \
-I$(TOP)/src/gallium/winsys/drm/nouveau \
-I$(TOP)/src/driclient/include
DRIVER_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
PIPE_DRIVERS = \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
$(TOP)/src/gallium/drivers/nv04/libnv04.a \
$(TOP)/src/gallium/drivers/nv10/libnv10.a \
$(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
$(TOP)/src/gallium/drivers/nouveau/libnouveau.a
DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
###############################################################
INCLUDES = $(DRIVER_INCLUDES) \
@ -36,7 +11,7 @@ INCLUDES = $(DRIVER_INCLUDES) \
-I$(TOP)/src/gallium/auxiliary \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/gallium/winsys/g3dvl \
-I$(TOP)/src/driclient/include
-I$(TOP)/src/gallium/winsys/g3dvl/dri
DEFINES += $(DRIVER_DEFINES) \
-DGALLIUM_SOFTPIPE \
@ -44,11 +19,10 @@ DEFINES += $(DRIVER_DEFINES) \
# XXX: Hack, if we include libxvmctracker.a in LIBS none of the symbols are
# pulled in by the linker because xsp_winsys.c doesn't refer to them
OBJECTS = $(SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
OBJECTS = $(C_SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
LIBS = $(PIPE_DRIVERS) \
$(TOP)/src/driclient/lib/libdriclient.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
LIBS = $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
$(PIPE_DRIVERS) \
$(TOP)/src/gallium/auxiliary/vl/libvl.a \
$(TOP)/src/gallium/auxiliary/draw/libdraw.a \
$(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \
@ -75,7 +49,7 @@ $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME): $(OBJECTS) $(LIBS) Makefile
$(MKLIB) -o $(XVMC_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
-install $(TOP)/$(LIB_DIR)/gallium -id $(INSTALL_LIB_DIR)/lib$(XVMC_LIB).1.dylib \
$(XVMC_LIB_DEPS) $(DRI_LIB_DEPS) $(OBJECTS) $(LIBS)
$(XVMC_LIB_DEPS) $(DRIVER_LIB_DEPS) $(OBJECTS) $(LIBS)
depend: $(SOURCES) Makefile
$(RM) depend

View file

@ -0,0 +1,26 @@
# This makefile produces a libXvMCg3dvl.so which is
# based on DRM/DRI
TOP = ../../../../../..
include $(TOP)/configs/current
C_SOURCES =
DRIVER_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I) \
-I$(TOP)/src/gallium/winsys/drm/nouveau \
DRIVER_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
PIPE_DRIVERS = \
$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
$(TOP)/src/gallium/drivers/nv04/libnv04.a \
$(TOP)/src/gallium/drivers/nv10/libnv10.a \
$(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a \
$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
DRIVER_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
include ../Makefile.template

View file

@ -1,172 +0,0 @@
#include "nouveau_context_vl.h"
#include <pipe/p_defines.h>
#include <pipe/p_context.h>
#include <pipe/p_screen.h>
#include <util/u_memory.h>
#include <common/nouveau_dri.h>
#include <common/nouveau_local.h>
#include <common/nouveau_winsys_pipe.h>
#include "nouveau_screen_vl.h"
/*
#ifdef DEBUG
static const struct dri_debug_control debug_control[] = {
{ "bo", DEBUG_BO },
{ NULL, 0 }
};
int __nouveau_debug = 0;
#endif
*/
int
nouveau_context_create(dri_context_t *dri_context)
{
dri_screen_t *dri_screen;
struct nouveau_screen_vl *nv_screen;
struct nouveau_context_vl *nv;
assert (dri_context);
dri_screen = dri_context->dri_screen;
nv_screen = dri_screen->private;
nv = CALLOC_STRUCT(nouveau_context_vl);
if (!nv)
return 1;
if (nouveau_context_init(&nv_screen->base, dri_context->drm_context,
(drmLock*)&dri_screen->sarea->lock, NULL, &nv->base))
{
FREE(nv);
return 1;
}
dri_context->private = (void*)nv;
nv->dri_context = dri_context;
nv->nv_screen = nv_screen;
/*
driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
nv->dri_screen->myNum, "nouveau");
#ifdef DEBUG
__nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
debug_control);
#endif
*/
nv->base.nvc->pctx[nv->base.pctx_id]->priv = nv;
return 0;
}
void
nouveau_context_destroy(dri_context_t *dri_context)
{
struct nouveau_context_vl *nv = dri_context->private;
assert(dri_context);
nouveau_context_cleanup(&nv->base);
FREE(nv);
}
int
nouveau_context_bind(struct nouveau_context_vl *nv, dri_drawable_t *dri_drawable)
{
assert(nv);
assert(dri_drawable);
if (nv->dri_drawable != dri_drawable)
{
nv->dri_drawable = dri_drawable;
dri_drawable->private = nv;
}
return 0;
}
int
nouveau_context_unbind(struct nouveau_context_vl *nv)
{
assert(nv);
nv->dri_drawable = NULL;
return 0;
}
/* Show starts here */
int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
{
struct nouveau_context_vl *nv;
dri_drawable_t *dri_drawable;
assert(pipe);
nv = pipe->priv;
driCreateDrawable(nv->nv_screen->dri_screen, drawable, &dri_drawable);
nouveau_context_bind(nv, dri_drawable);
return 0;
}
int unbind_pipe_drawable(struct pipe_context *pipe)
{
assert (pipe);
nouveau_context_unbind(pipe->priv);
return 0;
}
struct pipe_context* create_pipe_context(Display *display, int screen)
{
dri_screen_t *dri_screen;
dri_framebuffer_t dri_framebuf;
dri_context_t *dri_context;
struct nouveau_context_vl *nv;
assert(display);
driCreateScreen(display, screen, &dri_screen, &dri_framebuf);
driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context);
nouveau_screen_create(dri_screen, &dri_framebuf);
nouveau_context_create(dri_context);
nv = dri_context->private;
return nv->base.nvc->pctx[nv->base.pctx_id];
}
int destroy_pipe_context(struct pipe_context *pipe)
{
struct pipe_screen *screen;
struct pipe_winsys *winsys;
struct nouveau_context_vl *nv;
dri_screen_t *dri_screen;
dri_context_t *dri_context;
assert(pipe);
screen = pipe->screen;
winsys = pipe->winsys;
nv = pipe->priv;
dri_context = nv->dri_context;
dri_screen = dri_context->dri_screen;
pipe->destroy(pipe);
screen->destroy(screen);
FREE(winsys);
nouveau_context_destroy(dri_context);
nouveau_screen_destroy(dri_screen);
driDestroyContext(dri_context);
driDestroyScreen(dri_screen);
return 0;
}

View file

@ -1,39 +0,0 @@
#ifndef __NOUVEAU_CONTEXT_VL_H__
#define __NOUVEAU_CONTEXT_VL_H__
#include <driclient.h>
#include <nouveau/nouveau_winsys.h>
#include <common/nouveau_context.h>
/*#include "xmlconfig.h"*/
struct nouveau_context_vl {
struct nouveau_context base;
struct nouveau_screen_vl *nv_screen;
dri_context_t *dri_context;
dri_drawable_t *dri_drawable;
unsigned int last_stamp;
/*driOptionCache dri_option_cache;*/
drm_context_t drm_context;
drmLock drm_lock;
};
extern int nouveau_context_create(dri_context_t *);
extern void nouveau_context_destroy(dri_context_t *);
extern int nouveau_context_bind(struct nouveau_context_vl *, dri_drawable_t *);
extern int nouveau_context_unbind(struct nouveau_context_vl *);
#ifdef DEBUG
extern int __nouveau_debug;
#define DEBUG_BO (1 << 0)
#define DBG(flag, ...) do { \
if (__nouveau_debug & (DEBUG_##flag)) \
NOUVEAU_ERR(__VA_ARGS__); \
} while(0)
#else
#define DBG(flag, ...)
#endif
#endif

View file

@ -1,88 +0,0 @@
#include "nouveau_screen_vl.h"
#include <util/u_memory.h>
#include <nouveau_drm.h>
#include <common/nouveau_dri.h>
#include <common/nouveau_local.h>
#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
#error nouveau_drm.h version does not match expected version
#endif
/*
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 0;
*/
int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_version_t *ddx)
{
static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
static const dri_version_t dri_expected = {4, 0, 0};
static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
assert(dri);
assert(drm);
assert(ddx);
if (dri->major != dri_expected.major || dri->minor < dri_expected.minor)
{
NOUVEAU_ERR("Unexpected DRI version.\n");
return 1;
}
if (drm->major != drm_expected.major || drm->minor < drm_expected.minor)
{
NOUVEAU_ERR("Unexpected DRM version.\n");
return 1;
}
if (ddx->major != ddx_expected.major || ddx->minor < ddx_expected.minor)
{
NOUVEAU_ERR("Unexpected DDX version.\n");
return 1;
}
return 0;
}
int
nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf)
{
struct nouveau_dri *nv_dri = dri_framebuf->private;
struct nouveau_screen_vl *nv_screen;
assert(dri_screen);
assert(dri_framebuf);
if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx))
return 1;
nv_screen = CALLOC_STRUCT(nouveau_screen_vl);
if (!nv_screen)
return 1;
if (nouveau_screen_init(nv_dri, dri_screen->fd, &nv_screen->base))
{
FREE(nv_screen);
return 1;
}
/*
driParseOptionInfo(&nv_screen->option_cache,
__driConfigOptions, __driNConfigOptions);
*/
nv_screen->dri_screen = dri_screen;
dri_screen->private = (void*)nv_screen;
return 0;
}
void
nouveau_screen_destroy(dri_screen_t *dri_screen)
{
struct nouveau_screen_vl *nv_screen = dri_screen->private;
nouveau_screen_cleanup(&nv_screen->base);
FREE(nv_screen);
}

View file

@ -1,20 +0,0 @@
#ifndef __NOUVEAU_SCREEN_VL_H__
#define __NOUVEAU_SCREEN_VL_H__
#include <driclient.h>
#include <common/nouveau_screen.h>
/* TODO: Investigate using DRI options for interesting things */
/*#include "xmlconfig.h"*/
struct nouveau_screen_vl
{
struct nouveau_screen base;
dri_screen_t *dri_screen;
/*driOptionCache option_cache;*/
};
int nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf);
void nouveau_screen_destroy(dri_screen_t *dri_screen);
#endif

View file

@ -1,94 +0,0 @@
#include <driclient.h>
#include <common/nouveau_local.h>
#include <common/nouveau_screen.h>
#include "nouveau_context_vl.h"
#include "nouveau_swapbuffers.h"
void
nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
const drm_clip_rect_t *rect)
{
struct nouveau_context_vl *nv = dri_drawable->private;
struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
drm_clip_rect_t *pbox;
int nbox, i;
LOCK_HARDWARE(&nv->base);
if (!dri_drawable->num_cliprects) {
UNLOCK_HARDWARE(&nv->base);
return;
}
pbox = dri_drawable->cliprects;
nbox = dri_drawable->num_cliprects;
for (i = 0; i < nbox; i++, pbox++) {
int sx, sy, dx, dy, w, h;
sx = pbox->x1 - dri_drawable->x;
sy = pbox->y1 - dri_drawable->y;
dx = pbox->x1;
dy = pbox->y1;
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
pipe->surface_copy(pipe, nv->base.frontbuffer,
dx, dy, surf, sx, sy, w, h);
}
FIRE_RING(nv->base.nvc->channel);
UNLOCK_HARDWARE(&nv->base);
}
void
nouveau_copy_sub_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf, int x, int y, int w, int h)
{
if (surf) {
drm_clip_rect_t rect;
rect.x1 = x;
rect.y1 = y;
rect.x2 = x + w;
rect.y2 = y + h;
nouveau_copy_buffer(dri_drawable, surf, &rect);
}
}
void
nouveau_swap_buffers(dri_drawable_t *dri_drawable, struct pipe_surface *surf)
{
if (surf)
nouveau_copy_buffer(dri_drawable, surf, NULL);
}
void
nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
void *context_private)
{
struct nouveau_context_vl *nv;
dri_drawable_t *dri_drawable;
assert(pws);
assert(surf);
assert(context_private);
nv = context_private;
dri_drawable = nv->dri_drawable;
nouveau_copy_buffer(dri_drawable, surf, NULL);
}
void
nouveau_contended_lock(struct nouveau_context *nv)
{
struct nouveau_context_vl *nv_vl = (struct nouveau_context_vl*)nv;
dri_drawable_t *dri_drawable = nv_vl->dri_drawable;
dri_screen_t *dri_screen = nv_vl->dri_context->dri_screen;
/* If the window moved, may need to set a new cliprect now.
*
* NOTE: This releases and regains the hw lock, so all state
* checking must be done *after* this call:
*/
if (dri_drawable)
DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable);
}

View file

@ -1,10 +0,0 @@
#ifndef __NOUVEAU_SWAPBUFFERS_H__
#define __NOUVEAU_SWAPBUFFERS_H__
extern void nouveau_copy_buffer(dri_drawable_t *, struct pipe_surface *,
const drm_clip_rect_t *);
extern void nouveau_copy_sub_buffer(dri_drawable_t *, struct pipe_surface *,
int x, int y, int w, int h);
extern void nouveau_swap_buffers(dri_drawable_t *, struct pipe_surface *);
#endif