HGLRC WINAPI wglCreateLayerContext_prox( HDC hdc, int layerPlane ) { CR_DDI_PROLOGUE(); stubInit(); crWarning( "wglCreateLayerContext: unsupported" ); return 0; }
DECLEXPORT(HGLRC) WINAPI VBoxCreateContext( HDC hdc, struct VBOXUHGSMI *pHgsmi ) { char dpyName[MAX_DPY_NAME]; ContextInfo *context; CR_DDI_PROLOGUE(); stubInit(); CRASSERT(stub.contextTable); sprintf(dpyName, "%d", hdc); #ifndef VBOX_CROGL_USE_VBITS_SUPERSET if (stub.haveNativeOpenGL) desiredVisual |= ComputeVisBits( hdc ); #endif context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , pHgsmi #else , NULL #endif ); if (!context) return 0; return (HGLRC) context->id; }
HGLRC APIENTRY DrvCreateContext(HDC hdc) { char dpyName[MAX_DPY_NAME]; ContextInfo *context; CR_DDI_PROLOGUE(); crDebug( "DrvCreateContext(0x%x) called.", hdc); stubInit(); CRASSERT(stub.contextTable); sprintf(dpyName, "%d", hdc); #ifndef VBOX_CROGL_USE_VBITS_SUPERSET if (stub.haveNativeOpenGL) desiredVisual |= ComputeVisBits( hdc ); #endif context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) , NULL #endif ); if (!context) return 0; return (HGLRC) context->id; }
GLint APIENTRY crGetCurrentWindow( void ) { stubInit(); if (stub.currentContext && stub.currentContext->currentDrawable) return stub.currentContext->currentDrawable->spuWindow; else return -1; }
GLint APIENTRY crGetCurrentContext( void ) { stubInit(); if (stub.currentContext) return (GLint) stub.currentContext->id; else return 0; }
/** * Returns -1 on error */ GLint APIENTRY crCreateContext( const char *dpyName, GLint visBits ) { ContextInfo *context; stubInit(); /* XXX in Chromium 1.5 and earlier, the last parameter was UNDECIDED. * That didn't seem right so it was changed to CHROMIUM. (Brian) */ context = stubNewContext(dpyName, visBits, CHROMIUM, 0); return context ? (int) context->id : -1; }
GLint APIENTRY crGetCurrentWindow( void ) { ContextInfo *context; stubInit(); context = stubGetCurrentContext(); if (context && context->currentDrawable) return context->currentDrawable->spuWindow; else return -1; }
GLint APIENTRY crGetCurrentContext( void ) { ContextInfo *context; stubInit(); context = stubGetCurrentContext(); if (context) return (GLint) context->id; else return 0; }
BOOL APIENTRY DrvValidateVersion(DWORD version) { CR_DDI_PROLOGUE(); if (stubInit()) { crDebug("DrvValidateVersion %x -> TRUE\n", version); return TRUE; } crDebug("DrvValidateVersion %x -> FALSE, going to use system default opengl32.dll\n", version); return FALSE; }
void __attribute__ ((constructor)) vbox_install_into_mesa(void) { { #ifdef _X_ATTRIBUTE_PRINTF void (*pxf86Msg)(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3); #else void (*pxf86Msg)(MessageType type, const char *format, ...) _printf_attribute(2,3); #endif pxf86Msg = dlsym(RTLD_DEFAULT, "xf86Msg"); if (pxf86Msg) { pxf86Msg(X_INFO, "Next line is added to allow vboxvideo_drv.so to appear as whitelisted driver\n"); pxf86Msg(X_INFO, "The file referenced, is *NOT* loaded\n"); pxf86Msg(X_INFO, "Loading %s/ati_drv.so\n", DRI_XORG_DRV_DIR); /* 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; } } if (!stubInit()) { crDebug("vboxdriInitScreen: stubInit failed"); 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. */ /* Mesa's dispatch table is different across library versions, have to modify mesa's table using offset info functions*/ vboxPatchMesaGLAPITable(); /* 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 */ vboxFillGLXAPITable(&glxim); /* Now patch functions exported by libGL.so */ vboxPatchMesaExports(); }
HGLRC WINAPI wglCreateContext_prox( HDC hdc ) { char dpyName[MAX_DPY_NAME]; ContextInfo *context; stubInit(); CRASSERT(stub.contextTable); sprintf(dpyName, "%d", hdc); if (stub.haveNativeOpenGL) desiredVisual |= ComputeVisBits( hdc ); context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0); if (!context) return 0; return (HGLRC) context->id; }
int WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd ) { DWORD okayFlags; stubInit(); /* * NOTE!!! * Here we're telling the renderspu not to use the GDI * equivalent's of ChoosePixelFormat/DescribePixelFormat etc * There are subtle differences in the use of these calls. */ crSetenv("CR_WGL_DO_NOT_USE_GDI", "yes"); if ( pfd->nSize != sizeof(*pfd) || pfd->nVersion != 1 ) { crError( "wglChoosePixelFormat: bad pfd\n" ); return 0; } okayFlags = ( PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DOUBLEBUFFER_DONTCARE | PFD_SWAP_EXCHANGE | PFD_SWAP_COPY | PFD_STEREO | PFD_STEREO_DONTCARE | PFD_DEPTH_DONTCARE ); if ( pfd->dwFlags & ~okayFlags ) { crWarning( "wglChoosePixelFormat: only support flags=0x%x, but you gave me flags=0x%x", okayFlags, pfd->dwFlags ); return 0; } if ( pfd->iPixelType != PFD_TYPE_RGBA ) { crError( "wglChoosePixelFormat: only support RGBA\n" ); } if ( pfd->cColorBits > 32 || pfd->cRedBits > 8 || pfd->cGreenBits > 8 || pfd->cBlueBits > 8 || pfd->cAlphaBits > 8 ) { crWarning( "wglChoosePixelFormat: too much color precision requested\n" ); } if ( pfd->dwFlags & PFD_DOUBLEBUFFER ) desiredVisual |= CR_DOUBLE_BIT; if ( pfd->dwFlags & PFD_STEREO ) desiredVisual |= CR_STEREO_BIT; if ( pfd->cColorBits > 8) desiredVisual |= CR_RGB_BIT; if ( pfd->cAccumBits > 0 || pfd->cAccumRedBits > 0 || pfd->cAccumGreenBits > 0 || pfd->cAccumBlueBits > 0 || pfd->cAccumAlphaBits > 0 ) { crWarning( "wglChoosePixelFormat: asked for accumulation buffer, ignoring\n" ); } if ( pfd->cAccumBits > 0 ) desiredVisual |= CR_ACCUM_BIT; if ( pfd->cDepthBits > 32 ) { crError( "wglChoosePixelFormat; asked for too many depth bits\n" ); } if ( pfd->cDepthBits > 0 ) desiredVisual |= CR_DEPTH_BIT; if ( pfd->cStencilBits > 8 ) { crError( "wglChoosePixelFormat: asked for too many stencil bits\n" ); } if ( pfd->cStencilBits > 0 ) desiredVisual |= CR_STENCIL_BIT; if ( pfd->cAuxBuffers > 0 ) { crError( "wglChoosePixelFormat: asked for aux buffers\n" ); } if ( pfd->iLayerType != PFD_MAIN_PLANE ) { crError( "wglChoosePixelFormat: asked for a strange layer\n" ); } return 1; }
int WINAPI wglChoosePixelFormat_prox( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd ) { DWORD okayFlags; CR_DDI_PROLOGUE(); stubInit(); /* * NOTE!!! * Here we're telling the renderspu not to use the GDI * equivalent's of ChoosePixelFormat/DescribePixelFormat etc * There are subtle differences in the use of these calls. */ crSetenv("CR_WGL_DO_NOT_USE_GDI", "yes"); if ( pfd->nSize != sizeof(*pfd) || pfd->nVersion != 1 ) { crError( "wglChoosePixelFormat: bad pfd\n" ); return 0; } okayFlags = ( PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DOUBLEBUFFER_DONTCARE | PFD_SWAP_EXCHANGE | PFD_SWAP_COPY | /* @todo: this is disabled due to VSG Open Inventor interop issues * it does not make any sense actually since reporting this * as well as choosing a pixel format with this cap would not do anything * since ICD stuff has its own pixelformat state var */ // PFD_STEREO | PFD_STEREO_DONTCARE | PFD_DEPTH_DONTCARE ); if ( pfd->dwFlags & ~okayFlags ) { crWarning( "wglChoosePixelFormat: only support flags=0x%x, but you gave me flags=0x%x", okayFlags, pfd->dwFlags ); return 0; } if ( pfd->iPixelType != PFD_TYPE_RGBA ) { crError( "wglChoosePixelFormat: only support RGBA\n" ); } if ( pfd->cColorBits > 32 || pfd->cRedBits > 8 || pfd->cGreenBits > 8 || pfd->cBlueBits > 8 || pfd->cAlphaBits > 8 ) { crWarning( "wglChoosePixelFormat: too much color precision requested\n" ); } if ( pfd->dwFlags & PFD_DOUBLEBUFFER ) desiredVisual |= CR_DOUBLE_BIT; if ( pfd->dwFlags & PFD_STEREO ) desiredVisual |= CR_STEREO_BIT; if ( pfd->cColorBits > 8) desiredVisual |= CR_RGB_BIT; if ( pfd->cAccumBits > 0 || pfd->cAccumRedBits > 0 || pfd->cAccumGreenBits > 0 || pfd->cAccumBlueBits > 0 || pfd->cAccumAlphaBits > 0 ) { crWarning( "wglChoosePixelFormat: asked for accumulation buffer, ignoring\n" ); } /* @todo: although this is not needed by VSG Open Inventor interop, * still it does not make any sense actually since reporting this * as well as choosing a pixel format with this cap would not do anything * since ICD stuff has its own pixelformat state var */ // if ( pfd->cAccumBits > 0 ) // desiredVisual |= CR_ACCUM_BIT; if ( pfd->cDepthBits > 32 ) { crError( "wglChoosePixelFormat; asked for too many depth bits\n" ); } if ( pfd->cDepthBits > 0 ) desiredVisual |= CR_DEPTH_BIT; if ( pfd->cStencilBits > 8 ) { crError( "wglChoosePixelFormat: asked for too many stencil bits\n" ); } if ( pfd->cStencilBits > 0 ) desiredVisual |= CR_STENCIL_BIT; if ( pfd->cAuxBuffers > 0 ) { crError( "wglChoosePixelFormat: asked for aux buffers\n" ); } if ( pfd->iLayerType != PFD_MAIN_PLANE ) { crError( "wglChoosePixelFormat: asked for a strange layer\n" ); } return 1; }
BOOL WINAPI wglChoosePixelFormatEXT_prox (HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats) { int *pi; int wants_rgb = 0; CR_DDI_PROLOGUE(); stubInit(); /* TODO : Need to check pfAttributes too ! */ for ( pi = (int *)piAttributes; *pi != 0; pi++ ) { switch ( *pi ) { case WGL_COLOR_BITS_EXT: if (pi[1] > 8) wants_rgb = 1; pi++; break; case WGL_RED_BITS_EXT: case WGL_GREEN_BITS_EXT: case WGL_BLUE_BITS_EXT: if (pi[1] > 3) wants_rgb = 1; pi++; break; case WGL_ACCUM_ALPHA_BITS_EXT: case WGL_ALPHA_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_ALPHA_BIT; pi++; break; case WGL_DOUBLE_BUFFER_EXT: if (pi[1] > 0) desiredVisual |= CR_DOUBLE_BIT; pi++; break; case WGL_STEREO_EXT: if (pi[1] > 0) { /* @todo: this is disabled due to VSG Open Inventor interop issues * it does not make any sense actually since reporting this * as well as choosing a pixel format with this cap would not do anything * since ICD stuff has its own pixelformat state var */ crWarning("WGL_STEREO_EXT not supporteed!"); return 0; // desiredVisual |= CR_STEREO_BIT; } pi++; break; case WGL_DEPTH_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_DEPTH_BIT; pi++; break; case WGL_STENCIL_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_STENCIL_BIT; pi++; break; case WGL_ACCUM_RED_BITS_EXT: case WGL_ACCUM_GREEN_BITS_EXT: case WGL_ACCUM_BLUE_BITS_EXT: if (pi[1] > 0) { /* @todo: although this is not needed by VSG Open Inventor interop, * still it does not make any sense actually since reporting this * as well as choosing a pixel format with this cap would not do anything * since ICD stuff has its own pixelformat state var */ crWarning("WGL_ACCUM_XXX not supporteed!"); return 0; // desiredVisual |= CR_ACCUM_BIT; } pi++; break; case WGL_SAMPLE_BUFFERS_EXT: case WGL_SAMPLES_EXT: if (pi[1] > 0) { /* @todo: this is disabled due to VSG Open Inventor interop issues * it does not make any sense actually since reporting this * as well as choosing a pixel format with this cap would not do anything * since ICD stuff has its own pixelformat state var */ crWarning("WGL_SAMPLE_BUFFERS_EXT & WGL_SAMPLES_EXT not supporteed!"); return 0; // desiredVisual |= CR_MULTISAMPLE_BIT; } pi++; break; case WGL_SUPPORT_OPENGL_ARB: case WGL_DRAW_TO_WINDOW_ARB: case WGL_ACCELERATION_ARB: pi++; break; case WGL_PIXEL_TYPE_ARB: if(pi[1]!=WGL_TYPE_RGBA_ARB) { crWarning("WGL_PIXEL_TYPE 0x%x not supported!", pi[1]); return 0; } pi++; break; default: crWarning( "wglChoosePixelFormatEXT: bad pi=0x%x", *pi ); return 0; } } if (nNumFormats) *nNumFormats = 1; if (nMaxFormats>0 && piFormats) { piFormats[0] = 1; } return 1; }
XVisualInfo * glXChooseVisual( Display *dpy, int screen, int *attribList ) { XVisualInfo *vis; int *attrib; int visBits = 0; stubInit(); for (attrib = attribList; *attrib != None; attrib++) { switch (*attrib) { case GLX_USE_GL: /* ignored, this is mandatory */ break; case GLX_BUFFER_SIZE: /* this is for color-index visuals, which we don't support */ attrib++; break; case GLX_LEVEL: if (attrib[1] > 0) visBits |= CR_OVERLAY_BIT; attrib++; break; case GLX_RGBA: visBits |= CR_RGB_BIT; break; case GLX_DOUBLEBUFFER: visBits |= CR_DOUBLE_BIT; break; case GLX_STEREO: visBits |= CR_STEREO_BIT; /* crWarning( "glXChooseVisual: stereo unsupported" ); return NULL; */ break; case GLX_AUX_BUFFERS: { int aux_buffers = attrib[1]; if (aux_buffers != 0) { crWarning("glXChooseVisual: aux_buffers=%d unsupported", aux_buffers); return NULL; } } attrib++; break; case GLX_RED_SIZE: case GLX_GREEN_SIZE: case GLX_BLUE_SIZE: if (attrib[1] > 0) visBits |= CR_RGB_BIT; attrib++; break; case GLX_ALPHA_SIZE: if (attrib[1] > 0) visBits |= CR_ALPHA_BIT; attrib++; break; case GLX_DEPTH_SIZE: if (attrib[1] > 0) visBits |= CR_DEPTH_BIT; attrib++; break; case GLX_STENCIL_SIZE: if (attrib[1] > 0) visBits |= CR_STENCIL_BIT; attrib++; break; case GLX_ACCUM_RED_SIZE: case GLX_ACCUM_GREEN_SIZE: case GLX_ACCUM_BLUE_SIZE: case GLX_ACCUM_ALPHA_SIZE: if (attrib[1] > 0) visBits |= CR_ACCUM_BIT; attrib++; break; case GLX_SAMPLE_BUFFERS_SGIS: /* aka GLX_SAMPLES_ARB */ if (attrib[1] > 0) visBits |= CR_MULTISAMPLE_BIT; attrib++; break; case GLX_SAMPLES_SGIS: /* aka GLX_SAMPLES_ARB */ /* just ignore value for now, we'll try to get 4 samples/pixel */ if (attrib[1] > 4) return NULL; visBits |= CR_MULTISAMPLE_BIT; attrib++; break; #ifdef GLX_VERSION_1_3 case GLX_X_VISUAL_TYPE: case GLX_TRANSPARENT_TYPE_EXT: case GLX_TRANSPARENT_INDEX_VALUE_EXT: case GLX_TRANSPARENT_RED_VALUE_EXT: case GLX_TRANSPARENT_GREEN_VALUE_EXT: case GLX_TRANSPARENT_BLUE_VALUE_EXT: case GLX_TRANSPARENT_ALPHA_VALUE_EXT: /* ignore */ crWarning("glXChooseVisual: ignoring attribute 0x%x", *attrib); attrib++; break; #endif default: crWarning( "glXChooseVisual: bad attrib=0x%x", *attrib ); return NULL; } } if ((visBits & CR_RGB_BIT) == 0 && (visBits & CR_OVERLAY_BIT) == 0) { /* normal layer, color index mode not supported */ crWarning( "glXChooseVisual: didn't request RGB visual?" ); return NULL; } vis = crChooseVisual(&stub.wsInterface, dpy, screen, GL_FALSE, visBits); if (!vis && (visBits & CR_STEREO_BIT)) { /* try non-stereo */ visBits &= ~CR_STEREO_BIT; vis = crChooseVisual(&stub.wsInterface, dpy, screen, GL_FALSE, visBits); } if (vis) { AddVisualInfo(dpy, screen, vis->visual->visualid, visBits); } return vis; }
/** * Returns -1 on error */ GLint APIENTRY crWindowCreate( const char *dpyName, GLint visBits ) { stubInit(); return stubNewWindow( dpyName, visBits ); }
BOOL WINAPI wglChoosePixelFormatEXT_prox(HDC hdc, const int *piAttributes, const FLOAT *pfAttributes, UINT nMaxFormats, int *piFormats, UINT *nNumFormats) { int *pi; int wants_rgb = 0; stubInit(); /* TODO : Need to check pfAttributes too ! */ for ( pi = (int *)piAttributes; *pi != 0; pi++ ) { switch ( *pi ) { case WGL_COLOR_BITS_EXT: if (pi[1] > 8) wants_rgb = 1; pi++; break; case WGL_RED_BITS_EXT: case WGL_GREEN_BITS_EXT: case WGL_BLUE_BITS_EXT: if (pi[1] > 3) wants_rgb = 1; pi++; break; case WGL_ACCUM_ALPHA_BITS_EXT: case WGL_ALPHA_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_ALPHA_BIT; pi++; break; case WGL_DOUBLE_BUFFER_EXT: if (pi[1] > 0) desiredVisual |= CR_DOUBLE_BIT; pi++; break; case WGL_STEREO_EXT: if (pi[1] > 0) desiredVisual |= CR_STEREO_BIT; pi++; break; case WGL_DEPTH_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_DEPTH_BIT; pi++; break; case WGL_STENCIL_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_STENCIL_BIT; pi++; break; case WGL_ACCUM_RED_BITS_EXT: case WGL_ACCUM_GREEN_BITS_EXT: case WGL_ACCUM_BLUE_BITS_EXT: if (pi[1] > 0) desiredVisual |= CR_ACCUM_BIT; pi++; break; case WGL_SAMPLE_BUFFERS_EXT: case WGL_SAMPLES_EXT: if (pi[1] > 0) desiredVisual |= CR_MULTISAMPLE_BIT; pi++; break; default: crWarning( "wglChoosePixelFormatEXT: bad pi=0x%x", *pi ); return 0; } } return 1; }