Changeset 53275 in vbox for trunk/src/VBox
- Timestamp:
- Nov 9, 2014 8:48:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r53206 r53275 1 /* $Id$ */ 1 2 /** @file 2 3 * DevVMWare - VMWare SVGA device … … 4 5 5 6 /* 6 * Copyright (C) 2013 Oracle Corporation7 * Copyright (C) 2013-2014 Oracle Corporation 7 8 * 8 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 44 45 #include "vmsvga/svga3d_reg.h" 45 46 #include "vmsvga/svga3d_shaderdefs.h" 47 46 48 #ifdef RT_OS_WINDOWS 47 #include <GL/gl.h> 48 #include "vmsvga_glext/wglext.h" 49 #elif RT_OS_DARWIN 50 #include <OpenGL/OpenGL.h> 51 #include <OpenGL/gl3.h> 52 #include <OpenGL/gl3ext.h> 53 #define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED 54 #include <OpenGL/gl.h> 55 #include <OpenGL/glext.h> 56 #include "DevVGA-SVGA3d-cocoa.h" 49 # include <GL/gl.h> 50 # include "vmsvga_glext/wglext.h" 51 52 #elif defined(RT_OS_DARWIN) 53 # include <OpenGL/OpenGL.h> 54 # include <OpenGL/gl3.h> 55 # include <OpenGL/gl3ext.h> 56 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED 57 # include <OpenGL/gl.h> 58 # include <OpenGL/glext.h> 59 # include "DevVGA-SVGA3d-cocoa.h" 57 60 /* work around conflicting definition of GLhandleARB in VMware's glext.h */ 58 61 //#define GL_ARB_shader_objects … … 61 64 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); 62 65 typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); 63 # define GL_RGBA_S3TC 0x83A264 # define GL_ALPHA8_EXT 0x803c65 # define GL_LUMINANCE8_EXT 0x804066 # define GL_LUMINANCE16_EXT 0x804267 # define GL_LUMINANCE4_ALPHA4_EXT 0x804368 # define GL_LUMINANCE8_ALPHA8_EXT 0x804569 # define GL_INT_2_10_10_10_REV 0x8D9F66 # define GL_RGBA_S3TC 0x83A2 67 # define GL_ALPHA8_EXT 0x803c 68 # define GL_LUMINANCE8_EXT 0x8040 69 # define GL_LUMINANCE16_EXT 0x8042 70 # define GL_LUMINANCE4_ALPHA4_EXT 0x8043 71 # define GL_LUMINANCE8_ALPHA8_EXT 0x8045 72 # define GL_INT_2_10_10_10_REV 0x8D9F 70 73 #else 71 # include <X11/Xlib.h>72 # include <X11/Xatom.h>73 # include <GL/gl.h>74 # include <GL/glx.h>75 # include <GL/glext.h>74 # include <X11/Xlib.h> 75 # include <X11/Xatom.h> 76 # include <GL/gl.h> 77 # include <GL/glx.h> 78 # include <GL/glext.h> 76 79 //HACK FOR NOW 77 80 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); … … 87 90 #ifdef RT_OS_WINDOWS 88 91 #define OGLGETPROCADDRESS wglGetProcAddress 89 #elif RT_OS_DARWIN92 #elif defined(RT_OS_DARWIN) 90 93 #include <dlfcn.h> 91 94 void *MyNSGLGetProcAddress(const char *name) 92 95 { 93 static void * image = NULL;94 if ( image == NULL)95 image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);96 return ( image ? dlsym(image, name) : NULL);96 static void *s_image = NULL; 97 if (s_image == NULL) 98 s_image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); 99 return (s_image ? dlsym(s_image, name) : NULL); 97 100 } 98 101 # define OGLGETPROCADDRESS MyNSGLGetProcAddress … … 115 118 *******************************************************************************/ 116 119 #define VMSVGA3D_CLEAR_CURRENT_CONTEXT(pState) \ 117 pState->idActiveContext = OPENGL_INVALID_ID;120 do { (pState)->idActiveContext = OPENGL_INVALID_ID; } while (0) 118 121 119 122 #ifdef RT_OS_WINDOWS 120 123 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \ 121 if ( pState->idActiveContext != pContext->id)\124 if ((pState)->idActiveContext != pContext->id) \ 122 125 { \ 123 BOOL makecurret = wglMakeCurrent( pContext->hdc, pContext->hglrc); \126 BOOL makecurret = wglMakeCurrent((pContext)->hdc, (pContext)->hglrc); \ 124 127 Assert(makecurret == TRUE); \ 125 pState->idActiveContext = pContext->id;\126 } 127 128 #elif RT_OS_DARWIN128 pState->idActiveContext = (pContext)->id; \ 129 } else do { } while (0) 130 131 #elif defined(RT_OS_DARWIN) 129 132 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \ 130 if ( pState->idActiveContext != pContext->id)\133 if ((pState)->idActiveContext != (pContext)->id) \ 131 134 { \ 132 vmsvga3dCocoaViewMakeCurrentContext( pContext->cocoaView, pContext->cocoaContext); \133 pState->idActiveContext = pContext->id;\134 } 135 vmsvga3dCocoaViewMakeCurrentContext((pContext)->cocoaView, (pContext)->cocoaContext); \ 136 (pState)->idActiveContext = (pContext)->id; \ 137 } else do { } while (0) 135 138 #else 136 139 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \ 137 if ( pState->idActiveContext != pContext->id)\140 if ((pState)->idActiveContext != (pContext)->id) \ 138 141 { \ 139 Bool makecurret = glXMakeCurrent( pState->display,\140 pContext->window,\141 pContext->glxContext);\142 Bool makecurret = glXMakeCurrent((pState)->display, \ 143 (pContext)->window, \ 144 (pContext)->glxContext); \ 142 145 Assert(makecurret == True); \ 143 pState->idActiveContext = pContext->id;\144 } 146 (pState)->idActiveContext = (pContext)->id; \ 147 } else do { } while (0) 145 148 #endif 146 149 147 #ifdef DEBUG 148 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) \ 149 Assert(pState->idActiveContext == pContext->id); \ 150 pContext->lastError = glGetError(); \ 151 AssertMsgReturn(pContext->lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, pContext->lastError), VERR_INTERNAL_ERROR); 150 #ifdef VBOX_STRICT 151 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { \ 152 Assert((pState)->idActiveContext == (pContext)->id); \ 153 (pContext)->lastError = glGetError(); \ 154 AssertMsgReturn((pContext)->lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, (pContext)->lastError), VERR_INTERNAL_ERROR); \ 155 } while (0) 152 156 #else 153 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) ;157 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { } while (0) 154 158 #endif 155 159 156 #ifdef DEBUG 157 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) \ 158 Assert(pState->idActiveContext == pContext->id); \ 159 pContext->lastError = glGetError(); \ 160 AssertMsg(pContext->lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, pContext->lastError)); 160 #ifdef VBOX_STRICT 161 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { \ 162 Assert((pState)->idActiveContext == (pContext)->id); \ 163 (pContext)->lastError = glGetError(); \ 164 AssertMsg((pContext)->lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, (pContext)->lastError)); \ 165 } while (0) 161 166 #else 162 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) ;167 # define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { } while (0) 163 168 #endif 164 169 … … 322 327 /* Device context window handle. */ 323 328 HWND hwnd; 324 #elif RT_OS_DARWIN329 #elif defined(RT_OS_DARWIN) 325 330 /* OpenGL rendering context */ 326 331 NativeNSOpenGLContextRef cocoaContext; … … 433 438 /** Window request semaphore. */ 434 439 RTSEMEVENT WndRequestSem; 435 #elif RT_OS_LINUX440 #elif defined(RT_OS_LINUX) 436 441 /* The X display */ 437 442 Display *display; … … 752 757 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 753 758 glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &pState->caps.maxTextureBufferSize); 754 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 759 #ifdef DEBUG_bird 760 if (pState->fGLVersion >= 3.1) /* darwin: Requires GL 3.1, so triggers on older mac os x versions. */ 761 #endif 762 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 755 763 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &pState->caps.maxTextures); 756 764 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); … … 972 980 973 981 RTSemEventDestroy(pState->WndRequestSem); 974 #elif RT_OS_DARWIN975 976 #elif RT_OS_LINUX982 #elif defined(RT_OS_DARWIN) 983 984 #elif defined(RT_OS_LINUX) 977 985 /* signal to the thread that it is supposed to exit */ 978 986 pState->bTerminate = true; … … 2805 2813 BOOL ret = SwapBuffers(pContext->hdc); 2806 2814 AssertMsg(ret, ("SwapBuffers failed with %d\n", GetLastError())); 2807 #elif RT_OS_DARWIN2815 #elif defined(RT_OS_DARWIN) 2808 2816 vmsvga3dCocoaSwapBuffers(pContext->cocoaContext); 2809 2817 #else … … 2991 2999 } 2992 3000 2993 #elif RT_OS_DARWIN3001 #elif defined(RT_OS_DARWIN) 2994 3002 /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */ 2995 3003 NativeNSOpenGLContextRef shareContext = NULL; … … 3188 3196 int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_DESTROYWINDOW, (WPARAM)pContext->hwnd, 0); 3189 3197 AssertRC(rc); 3190 #elif RT_OS_DARWIN3198 #elif defined(RT_OS_DARWIN) 3191 3199 vmsvga3dCocoaDestroyView(pContext->cocoaView); 3192 3200 vmsvga3dCocoaDestroyContext(pContext->cocoaContext); 3193 #elif RT_OS_LINUX3201 #elif defined(RT_OS_LINUX) 3194 3202 glXMakeCurrent(pState->display, None, NULL); 3195 3203 glXDestroyContext(pState->display, pContext->glxContext); … … 3232 3240 int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_RESIZEWINDOW, (WPARAM)pContext->hwnd, (LPARAM)&cs); 3233 3241 AssertRC(rc); 3234 #elif RT_OS_DARWIN3242 #elif defined(RT_OS_DARWIN) 3235 3243 vmsvga3dCocoaViewSetSize(pContext->cocoaView, pThis->svga.uWidth, pThis->svga.uHeight); 3236 #elif RT_OS_LINUX3244 #elif defined(RT_OS_LINUX) 3237 3245 XWindowChanges wc; 3238 3246 wc.width = pThis->svga.uWidth; … … 5564 5572 AssertFailed(); 5565 5573 break; 5574 case SVGA3D_DECLUSAGE_MAX: AssertFailed(); break; /* shut up gcc */ 5566 5575 } 5567 5576 } … … 5632 5641 case SVGA3D_DECLUSAGE_SAMPLE: 5633 5642 break; 5643 case SVGA3D_DECLUSAGE_MAX: AssertFailed(); break; /* shut up gcc */ 5634 5644 } 5635 5645 } … … 5841 5851 pTexture = &pState->paSurface[pContext->aSidActiveTexture[activeTextureUnit - GL_TEXTURE0]]; 5842 5852 5843 AssertMsg(pTexture->oglId.texture == activeTexture, ("%x vs %x unit %d - %d\n", pTexture->oglId.texture, activeTexture, i, activeTextureUnit - GL_TEXTURE0));5853 AssertMsg(pTexture->oglId.texture == (GLuint)activeTexture, ("%x vs %x unit %d - %d\n", pTexture->oglId.texture, activeTexture, i, activeTextureUnit - GL_TEXTURE0)); 5844 5854 } 5845 5855 }
Note:
See TracChangeset
for help on using the changeset viewer.