fakedri_drv.c revision c87658ecc964db0626e2662f01e563fe1c6b4cb3
af062818b47340eef15700d2f0211576ba3506eevboxsync * VBox OpenGL DRI driver functions
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2009-2012 Oracle Corporation
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync#if defined(BSD)
af062818b47340eef15700d2f0211576ba3506eevboxsync/** X server message type definitions. */
af062818b47340eef15700d2f0211576ba3506eevboxsynctypedef enum {
af062818b47340eef15700d2f0211576ba3506eevboxsync X_CMDLINE, /* Value was given on the command line */
} MessageType;
#define VBOX_NO_MESA_PATCH_REPORTS
#ifdef RT_ARCH_AMD64
# ifdef BSD
# ifdef BSD
#ifdef DEBUG_DRI_CALLS
#ifndef PAGESIZE
#ifdef RT_ARCH_AMD64
#ifdef RT_ARCH_AMD64
typedef struct _FAKEDRI_PatchNode
const char* psFuncName;
void *pGLTable;
if (!vbox_glapi_table)
#include "fakedri_glfuncsList.h"
#include "fakedri_glxfuncsList.h"
void *alPatch;
int rv;
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#if defined(BSD)
for (i = 0; i < count; i++) {
int rv;
void *alPatch;
void *pMesaEntry;
void *shift;
int ignore_size=false;
#ifndef VBOX_NO_MESA_PATCH_REPORTS
if (!pMesaEntry)
int rv;
# ifndef VBOX_NO_MESA_PATCH_REPORTS
crDebug("VBox Entry: %p, start: %p(%s:%s), size: %li", pStart, dlip1.dli_saddr, dlip1.dli_fname, dlip1.dli_sname, sym1->st_size);
#ifndef VBOX_NO_MESA_PATCH_REPORTS
crDebug("Mesa Entry: %p, start: %p(%s:%s), size: %li", pMesaEntry, dlip.dli_saddr, dlip.dli_fname, dlip.dli_sname, sym->st_size);
#ifndef VBOX_OGL_GLX_USE_CSTUBS
#ifdef RT_ARCH_AMD64
/*@todo we don't really know the size of targeted static function, but it's long enough in practice. We will also patch same place twice, but it's ok.*/
ignore_size = true;
#ifdef RT_ARCH_AMD64
# ifndef VBOX_NO_MESA_PATCH_REPORTS
# ifndef VBOX_NO_MESA_PATCH_REPORTS
if (!pNode)
#ifndef VBOX_NO_MESA_PATCH_REPORTS
#ifdef RT_ARCH_AMD64
if (pNode)
# ifndef VBOX_NO_MESA_PATCH_REPORTS
#ifdef RT_ARCH_AMD64
vboxRepatchMesaExports(void)
while (pPatchNode)
# ifndef VBOX_NO_MESA_PATCH_REPORTS
while (pFreeNode)
if (!pFreeNode)
# ifndef VBOX_NO_MESA_PATCH_REPORTS
# ifndef VBOX_NO_MESA_PATCH_REPORTS
crDebug("Adding jmp from mesa %s+%#lx to vbox %s", pFreeNode->psFuncName, pFreeNode->pDstStart-pFreeNode->pSrcStart,
while (pList)
#ifdef VBOX_OGL_GLX_USE_CSTUBS
# define GLXAPI_ENTRY(Func) vboxPatchMesaExport("glX"#Func, &vbox_glX##Func, &vbox_glX##Func##_EndProc);
#include "fakedri_glxfuncsList.h"
#ifdef RT_ARCH_AMD64
bool vbox_load_sw_dri()
void *handle;
int len, i;
/*code from Mesa-7.2/src/glx/x11/dri_common.c:driOpenDriver*/
if (!libPaths)
next++;
if (handle) break;
if (!gppSwDriExternsion)
for (i = 0; gppSwDriExternsion[i]; i++)
#ifdef _X_ATTRIBUTE_PRINTF
if (pxf86Msg)
/* we're failing to proxy software dri driver calls for certain xservers, so just make sure we're unloaded for now */
if (!stubInit())
/* Load swrast_dri.so to proxy dri related calls there. */
if (!vbox_load_sw_dri())
* 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.
/* Mesa's dispatch table is different across library versions, have to modify mesa's table using offset info functions*/
* app call glxFoo->(mesa asm dispatch stub patched with vbox_glXFoo:jmp glxim[Foo's index])->VBOXGLXTAG(glxFoo)
/* Now patch functions exported by libGL.so */
static __DRIscreen *
void *loaderPrivate)
(void) fd;
(void) sarea_handle;
static const __DRIextension **
unsigned int attrib,
unsigned int *value)
static __DRIdrawable *
unsigned int drawable_id,
unsigned int head,
void *loaderPrivate)
(void) drawable_id;
(void) head;
static __DRIcontext *
void *loaderPrivate)
unsigned long mask)
static __DRIscreen *
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;