Changeset 53792 in vbox
- Timestamp:
- Jan 13, 2015 7:53:38 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 97600
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r53756 r53792 77 77 # include <GL/glx.h> 78 78 # include <GL/glext.h> 79 //HACK FOR NOW 80 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); 79 # define VBOX_VMSVGA3D_GL_HACK_LEVEL 0x103 81 80 #endif 82 81 #include "vmsvga_glext/glext.h" … … 99 98 * Defined Constants And Macros * 100 99 *******************************************************************************/ 100 /** @def VBOX_VMSVGA3D_GL_HACK_LEVEL 101 * Turns out that on Linux gl.h may often define the first 2-4 OpenGL versions 102 * worth of extensions, but missing out on a function pointer of fifteen. This 103 * causes headache for us when we use the function pointers below. This hack 104 * changes the code to call the known problematic functions directly. 105 * The value is ((x)<<16 | (y)) where x and y are taken from the GL_VERSION_x_y. 106 */ 107 #ifndef VBOX_VMSVGA3D_GL_HACK_LEVEL 108 # define VBOX_VMSVGA3D_GL_HACK_LEVEL 0 109 #endif 110 101 111 #ifndef VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE 102 112 # define VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE 1.0 … … 569 579 PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; 570 580 PFNGLPOINTPARAMETERFPROC glPointParameterf; 581 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102 582 PFNGLBLENDCOLORPROC glBlendColor; 571 583 PFNGLBLENDEQUATIONPROC glBlendEquation; 584 #endif 572 585 PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate; 573 586 PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; 574 587 PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; 575 588 PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; 576 PFNGLBLENDCOLORPROC glBlendColor;577 589 PFNGLBINDBUFFERPROC glBindBuffer; 578 590 PFNGLDELETEBUFFERSPROC glDeleteBuffers; … … 588 600 PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex; 589 601 PFNGLACTIVETEXTUREPROC glActiveTexture; 602 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103 590 603 PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; 604 #endif 591 605 PFNGLGETPROGRAMIVARBPROC glGetProgramivARB; 592 606 PFNGLPROVOKINGVERTEXPROC glProvokingVertex; … … 718 732 719 733 /* Temporarily. Later start if (fMinGLVersion != 0.0 && fActualGLVersion >= fMinGLVersion) return true; */ 734 #ifdef RT_OS_DARWIN 720 735 AssertMsg( fMinGLVersion == 0.0 721 736 || fRet == (pState->fGLVersion >= fMinGLVersion) 722 #ifdef RT_OS_DARWIN 723 || VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE == 2.1 737 || VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE == 2.1, 738 ("%s actual:%d min:%d fRet=%d\n", 739 pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet)); 740 #else 741 AssertMsg(fMinGLVersion == 0.0 || fRet == (pState->fGLVersion >= fMinGLVersion), 742 ("%s actual:%d min:%d fRet=%d\n", 743 pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet)); 724 744 #endif 725 , ("%s actual:%d min:%d fRet=%d\n",726 pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet));727 745 return fRet; 728 746 } … … 1237 1255 pState->ext.glPointParameterf = (PFNGLPOINTPARAMETERFPROC)OGLGETPROCADDRESS("glPointParameterf"); 1238 1256 AssertMsgReturn(pState->ext.glPointParameterf, ("glPointParameterf missing"), VERR_NOT_IMPLEMENTED); 1257 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102 1258 pState->ext.glBlendColor = (PFNGLBLENDCOLORPROC)OGLGETPROCADDRESS("glBlendColor"); 1259 AssertMsgReturn(pState->ext.glBlendColor, ("glBlendColor missing"), VERR_NOT_IMPLEMENTED); 1239 1260 pState->ext.glBlendEquation = (PFNGLBLENDEQUATIONPROC)OGLGETPROCADDRESS("glBlendEquation"); 1240 1261 AssertMsgReturn(pState->ext.glBlendEquation, ("glBlendEquation missing"), VERR_NOT_IMPLEMENTED); 1262 #endif 1241 1263 pState->ext.glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)OGLGETPROCADDRESS("glBlendEquationSeparate"); 1242 1264 AssertMsgReturn(pState->ext.glBlendEquationSeparate, ("glBlendEquationSeparate missing"), VERR_NOT_IMPLEMENTED); … … 1247 1269 pState->ext.glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)OGLGETPROCADDRESS("glStencilFuncSeparate"); 1248 1270 AssertMsgReturn(pState->ext.glStencilFuncSeparate, ("glStencilFuncSeparate missing"), VERR_NOT_IMPLEMENTED); 1249 pState->ext.glBlendColor = (PFNGLBLENDCOLORPROC)OGLGETPROCADDRESS("glBlendColor");1250 AssertMsgReturn(pState->ext.glBlendColor, ("glBlendColor missing"), VERR_NOT_IMPLEMENTED);1251 1271 pState->ext.glBindBuffer = (PFNGLBINDBUFFERPROC)OGLGETPROCADDRESS("glBindBuffer"); 1252 1272 AssertMsgReturn(pState->ext.glBindBuffer, ("glBindBuffer missing"), VERR_NOT_IMPLEMENTED); … … 1271 1291 pState->ext.glActiveTexture = (PFNGLACTIVETEXTUREPROC)OGLGETPROCADDRESS("glActiveTexture"); 1272 1292 AssertMsgReturn(pState->ext.glActiveTexture, ("glActiveTexture missing"), VERR_NOT_IMPLEMENTED); 1293 #if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103 1273 1294 pState->ext.glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)OGLGETPROCADDRESS("glClientActiveTexture"); 1274 1295 AssertMsgReturn(pState->ext.glClientActiveTexture, ("glClientActiveTexture missing"), VERR_NOT_IMPLEMENTED); 1296 #endif 1275 1297 pState->ext.glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)OGLGETPROCADDRESS("glGetProgramivARB"); 1276 1298 AssertMsgReturn(pState->ext.glGetProgramivARB, ("glGetProgramivARB missing"), VERR_NOT_IMPLEMENTED); … … 2212 2234 #endif 2213 2235 2214 int vmsvga3dSurfaceDefine(PVGASTATE pThis, uint32_t sid, uint32_t surfaceFlags, SVGA3dSurfaceFormat format, SVGA3dSurfaceFace face[SVGA3D_MAX_SURFACE_FACES], 2215 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, uint32_t cMipLevels, SVGA3dSize *pMipLevelSize) 2236 int vmsvga3dSurfaceDefine(PVGASTATE pThis, uint32_t sid, uint32_t surfaceFlags, SVGA3dSurfaceFormat format, 2237 SVGA3dSurfaceFace face[SVGA3D_MAX_SURFACE_FACES], uint32_t multisampleCount, 2238 SVGA3dTextureFilter autogenFilter, uint32_t cMipLevels, SVGA3dSize *pMipLevelSize) 2216 2239 { 2217 2240 PVMSVGA3DSURFACE pSurface; … … 2329 2352 pSurface->flags = surfaceFlags; 2330 2353 pSurface->format = format; 2331 memcpy(pSurface->faces, face, sizeof( face));2354 memcpy(pSurface->faces, face, sizeof(pSurface->faces)); 2332 2355 pSurface->cFaces = 1; /* check for cube maps later */ 2333 2356 pSurface->multiSampleCount = multisampleCount; … … 4468 4491 vmsvga3dBlendEquation2GL(pContext->state.aRenderState[SVGA3D_RS_BLENDEQUATIONALPHA].uintValue)); 4469 4492 else 4493 { 4494 #if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x102 4495 glBlendEquation(vmsvga3dBlendEquation2GL(pRenderState[i].uintValue)); 4496 #else 4470 4497 pState->ext.glBlendEquation(vmsvga3dBlendEquation2GL(pRenderState[i].uintValue)); 4498 #endif 4499 } 4471 4500 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 4472 4501 break; … … 4478 4507 vmsvgaColor2GLFloatArray(pRenderState[i].uintValue, &red, &green, &blue, &alpha); 4479 4508 4509 #if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x102 4510 glBlendColor(red, green, blue, alpha); 4511 #else 4480 4512 pState->ext.glBlendColor(red, green, blue, alpha); 4513 #endif 4481 4514 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 4482 4515 break; … … 5795 5828 /* Store for vm state save/restore. */ 5796 5829 pContext->state.aClipPlane[index].fValid = true; 5797 memcpy(pContext->state.aClipPlane[index].plane, plane, sizeof(p lane));5798 5799 /* @todo clip plane affected by model view in OpenGL & view in D3D + vertex shader -> not transformed (see Wine; state.c clipplane) */5830 memcpy(pContext->state.aClipPlane[index].plane, plane, sizeof(pContext->state.aClipPlane[index].plane)); 5831 5832 /** @todo clip plane affected by model view in OpenGL & view in D3D + vertex shader -> not transformed (see Wine; state.c clipplane) */ 5800 5833 oglPlane[0] = (double)plane[0]; 5801 5834 oglPlane[1] = (double)plane[1]; … … 6109 6142 pState->ext.glEnableVertexAttribArray(index); 6110 6143 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6111 pState->ext.glVertexAttribPointer(index, size, type, normalized, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6144 pState->ext.glVertexAttribPointer(index, size, type, normalized, pVertexDecl[iVertex].array.stride, 6145 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6112 6146 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6113 6147 /* case SVGA3D_DECLUSAGE_COLOR: @todo color component order not identical!! test GL_BGRA!! */ … … 6121 6155 glEnableClientState(GL_VERTEX_ARRAY); 6122 6156 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6123 glVertexPointer(size, type, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6157 glVertexPointer(size, type, pVertexDecl[iVertex].array.stride, 6158 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6124 6159 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6125 6160 break; … … 6133 6168 glEnableClientState(GL_NORMAL_ARRAY); 6134 6169 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6135 glNormalPointer(type, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6170 glNormalPointer(type, pVertexDecl[iVertex].array.stride, 6171 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6136 6172 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6137 6173 break; … … 6141 6177 case SVGA3D_DECLUSAGE_TEXCOORD: 6142 6178 /* Specify the affected texture unit. */ 6179 #if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x103 6180 glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex); 6181 #else 6143 6182 pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex); 6183 #endif 6144 6184 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 6145 6185 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6146 glTexCoordPointer(size, type, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6186 glTexCoordPointer(size, type, pVertexDecl[iVertex].array.stride, 6187 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6147 6188 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6148 6189 break; … … 6159 6200 AssertFailed(); /* see position_transformed in Wine */ 6160 6201 break; 6161 case SVGA3D_DECLUSAGE_COLOR: /* @todo color component order not identical!! test GL_BGRA!! */6202 case SVGA3D_DECLUSAGE_COLOR: /** @todo color component order not identical!! test GL_BGRA!! */ 6162 6203 glEnableClientState(GL_COLOR_ARRAY); 6163 6204 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6164 glColorPointer(size, type, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6205 glColorPointer(size, type, pVertexDecl[iVertex].array.stride, 6206 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6165 6207 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6166 6208 break; … … 6168 6210 glEnableClientState(GL_FOG_COORD_ARRAY); 6169 6211 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6170 pState->ext.glFogCoordPointer(type, pVertexDecl[iVertex].array.stride, (const GLvoid *)pVertexDecl[iVertex].array.offset); 6212 pState->ext.glFogCoordPointer(type, pVertexDecl[iVertex].array.stride, 6213 (const GLvoid *)(uintptr_t)pVertexDecl[iVertex].array.offset); 6171 6214 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6172 6215 break; … … 6222 6265 case SVGA3D_DECLUSAGE_TEXCOORD: 6223 6266 /* Specify the affected texture unit. */ 6267 #if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x103 6268 glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex); 6269 #else 6224 6270 pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex); 6271 #endif 6225 6272 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 6226 6273 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); … … 6394 6441 Log(("DrawIndexedPrimitive %x cPrimitives=%d cVertices=%d hint.first=%d hint.last=%d index offset=%d primitivecount=%d index width=%d index bias=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pVertexDecl[0].rangeHint.first, pVertexDecl[0].rangeHint.last, pRange[iPrimitive].indexArray.offset, pRange[iPrimitive].primitiveCount, pRange[iPrimitive].indexWidth, pRange[iPrimitive].indexBias)); 6395 6442 if (pRange[iPrimitive].indexBias == 0) 6396 {6397 6443 glDrawElements(modeDraw, 6398 6444 cVertices, 6399 6445 (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 6400 (GLvoid *)(pRange[iPrimitive].indexArray.offset)); /* byte offset in indices buffer */ 6401 } 6446 (GLvoid *)(uintptr_t)pRange[iPrimitive].indexArray.offset); /* byte offset in indices buffer */ 6402 6447 else 6403 6448 pState->ext.glDrawElementsBaseVertex(modeDraw, 6404 6449 cVertices, 6405 6450 (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, 6406 (GLvoid *)( pRange[iPrimitive].indexArray.offset),/* byte offset in indices buffer */6407 pRange[iPrimitive].indexBias); 6451 (GLvoid *)(uintptr_t)pRange[iPrimitive].indexArray.offset, /* byte offset in indices buffer */ 6452 pRange[iPrimitive].indexBias); /* basevertex */ 6408 6453 6409 6454 /* Unbind the index buffer after usage. */
Note:
See TracChangeset
for help on using the changeset viewer.