fakedri_drv.c revision 9c9e05854c60412d1f606c125e035317ee956db7
/* $Id$ */
/** @file
* VBox OpenGL DRI driver functions
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#define _GNU_SOURCE 1
#include "cr_error.h"
#include "cr_gl.h"
#include "cr_mem.h"
#include "stub.h"
#include "fakedri_drv.h"
#include "dri_glx.h"
#include <dlfcn.h>
#include <elf.h>
#include <unistd.h>
#include "xf86.h"
#define VBOX_NO_MESA_PATCH_REPORTS
//#define DEBUG_DRI_CALLS
//@todo this could be different...
#ifdef RT_ARCH_AMD64
#else
# define DRI_DEFAULT_DRIVER_DIR "/usr/lib/dri"
#endif
#ifdef DEBUG_DRI_CALLS
#else
#endif
} else { \
}
} else { \
return 0; \
}
#ifndef PAGESIZE
#define PAGESIZE 4096
#endif
#ifdef RT_ARCH_AMD64
# define DRI_ELFSYM Elf64_Sym
#else
# define DRI_ELFSYM Elf32_Sym
#endif
static struct _glapi_table vbox_glapi_table;
extern const __DRIextension * __driDriverExtensions[];
static void
{
#include "fakedri_glfuncsList.h"
};
static void
{
#include "fakedri_glxfuncsList.h"
}
static void
{
DRI_ELFSYM* sym=0;
int rv;
void *alPatch;
void *pMesaEntry;
char patch[5];
void *shift;
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#endif
if (!pMesaEntry)
{
return;
}
{
return;
}
{
DRI_ELFSYM* sym1=0;
int rv;
{
return;
}
crDebug("VBox Entry: %p, start: %p(%s:%s), size: %i", pStart, dlip1.dli_saddr, dlip1.dli_fname, dlip1.dli_sname, sym1->st_size);
}
#endif
#ifndef VBOX_NO_MESA_PATCH_REPORTS
crDebug("Mesa Entry: %p, start: %p(%s:%s), size: %i", pMesaEntry, dlip.dli_saddr, dlip.dli_fname, dlip.dli_sname, sym->st_size);
#endif
#ifndef VBOX_OGL_GLX_USE_CSTUBS
#endif
{
{
return;
}
# ifndef VBOX_NO_MESA_PATCH_REPORTS
# endif
{
#ifdef RT_ARCH_AMD64
#else
#endif
{
return;
}
}
patch[0] = 0xE9;
# ifndef VBOX_NO_MESA_PATCH_REPORTS
# endif
}
/* Get aligned start adress we're going to patch*/
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#endif
/* Get write access to mesa functions */
if (RT_FAILURE(rv))
{
}
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#endif
/*@todo Restore the protection, probably have to check what was it before us...*/
if (RT_FAILURE(rv))
{
}
}
#ifdef VBOX_OGL_GLX_USE_CSTUBS
static void
#else
static void
# define GLXAPI_ENTRY(Func) vboxPatchMesaExport("glX"#Func, &vbox_glX##Func, &vbox_glX##Func##_EndProc);
#endif
{
crDebug("Patching mesa glx entries");
#include "fakedri_glxfuncsList.h"
}
bool vbox_load_sw_dri()
{
char realDriverName[200];
void *handle;
int len, i;
/*code from Mesa-7.2/src/glx/x11/dri_common.c:driOpenDriver*/
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
if (!libPaths)
}
{
{
}
else
{
next++;
}
if (handle) break;
}
/*end code*/
if (!gppSwDriExternsion)
{
return false;
}
for (i = 0; gppSwDriExternsion[i]; i++)
{
}
return gpSwDriCoreExternsion && gpSwDriSwrastExtension;
}
{
if (!stubInit())
{
crDebug("vboxdriInitScreen: stubInit failed");
return;
}
{
if (pxf86Msg)
{
/* we're failing to proxy software dri driver calls for certain xservers, so just make sure we're unloaded for now */
__driDriverExtensions[0] = NULL;
return;
}
}
/* Load swrast_dri.so to proxy dri related calls there. */
if (!vbox_load_sw_dri())
{
crDebug("vboxdriInitScreen: vbox_load_sw_dri failed...going to fail badly");
return;
}
/* Handle gl api.
* In the end application call would look like this:
* app call glFoo->(mesa asm dispatch stub)->cr_glFoo(vbox asm dispatch stub)->SPU Foo function(packspuFoo or alike)
* Note, we don't need to install extension functions via _glapi_add_dispatch, because we'd override glXGetProcAddress.
*/
/* We don't support all mesa's functions. Initialize our table to mesa dispatch first*/
/* Now install our assembly dispatch entries into table */
/* Install our dispatch table into mesa */
/* Handle glx api.
* In the end application call would look like this:
* app call glxFoo->(mesa asm dispatch stub patched with vbox_glXFoo:jmp glxim[Foo's index])->VBOXGLXTAG(glxFoo)
*/
/* Fill structure used by our assembly stubs */
/* Now patch functions exported by libGL.so */
}
/*
* @todo we're missing first glx related call from the client application.
* Luckily, this doesn't add much problems, except for some cases.
*/
/* __DRIcoreExtension */
static __DRIscreen *
void *loaderPrivate)
{
(void) fd;
(void) sarea_handle;
}
static void
{
}
static const __DRIextension **
{
}
static int
unsigned int attrib,
unsigned int *value)
{
}
static int
{
}
static __DRIdrawable *
const __DRIconfig *config,
unsigned int drawable_id,
unsigned int head,
void *loaderPrivate)
{
(void) drawable_id;
(void) head;
}
static void
{
}
static void
{
}
static __DRIcontext *
const __DRIconfig *config,
void *loaderPrivate)
{
}
static int
unsigned long mask)
{
}
static void
{
}
static int
{
}
static int
{
}
/* __DRIlegacyExtension */
static __DRIscreen *
const __DRIversion *ddx_version,
const __DRIversion *dri_version,
const __DRIversion *drm_version,
const __DRIframebuffer *frame_buffer,
const __DRIextension **extensions,
const __DRIconfig ***driver_modes,
void *loaderPrivate)
{
(void) ddx_version;
(void) dri_version;
(void) frame_buffer;
(void) pSAREA;
(void) fd;
}
static __DRIdrawable *
{
(void) hwDrawable;
(void) renderType;
(void) attrs;
(void) data;
}
static __DRIcontext *
{
(void) render_type;
(void) hwContext;
}
static const __DRIlegacyExtension vboxdriLegacyExtension = {
};
static const __DRIcoreExtension vboxdriCoreExtension = {
{ __DRI_CORE, __DRI_CORE_VERSION },
vboxdriCreateNewScreen, /* driCreateNewScreen */
vboxdriCreateNewDrawable, /* driCreateNewDrawable */
};
/* This structure is used by dri_util from mesa, don't rename it! */
};