VirtualBox

Changeset 53792 in vbox


Ignore:
Timestamp:
Jan 13, 2015 7:53:38 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97600
Message:

DevVGA-SVGA3d-ogl.cpp: Fixed gcc warnings and made it build on my linux system with half busted gl headers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp

    r53756 r53792  
    7777# include <GL/glx.h>
    7878# include <GL/glext.h>
    79 //HACK FOR NOW
    80 typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
     79# define VBOX_VMSVGA3D_GL_HACK_LEVEL 0x103
    8180#endif
    8281#include "vmsvga_glext/glext.h"
     
    9998*   Defined Constants And Macros                                               *
    10099*******************************************************************************/
     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
    101111#ifndef VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE
    102112# define VBOX_VMSVGA3D_DEFAULT_OGL_PROFILE 1.0
     
    569579        PFNGLFRAMEBUFFERTEXTURELAYERPROC                glFramebufferTextureLayer;
    570580        PFNGLPOINTPARAMETERFPROC                        glPointParameterf;
     581#if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102
     582        PFNGLBLENDCOLORPROC                             glBlendColor;
    571583        PFNGLBLENDEQUATIONPROC                          glBlendEquation;
     584#endif
    572585        PFNGLBLENDEQUATIONSEPARATEPROC                  glBlendEquationSeparate;
    573586        PFNGLBLENDFUNCSEPARATEPROC                      glBlendFuncSeparate;
    574587        PFNGLSTENCILOPSEPARATEPROC                      glStencilOpSeparate;
    575588        PFNGLSTENCILFUNCSEPARATEPROC                    glStencilFuncSeparate;
    576         PFNGLBLENDCOLORPROC                             glBlendColor;
    577589        PFNGLBINDBUFFERPROC                             glBindBuffer;
    578590        PFNGLDELETEBUFFERSPROC                          glDeleteBuffers;
     
    588600        PFNGLDRAWELEMENTSBASEVERTEXPROC                 glDrawElementsBaseVertex;
    589601        PFNGLACTIVETEXTUREPROC                          glActiveTexture;
     602#if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103
    590603        PFNGLCLIENTACTIVETEXTUREPROC                    glClientActiveTexture;
     604#endif
    591605        PFNGLGETPROGRAMIVARBPROC                        glGetProgramivARB;
    592606        PFNGLPROVOKINGVERTEXPROC                        glProvokingVertex;
     
    718732
    719733    /* Temporarily.  Later start if (fMinGLVersion != 0.0 && fActualGLVersion >= fMinGLVersion) return true; */
     734#ifdef RT_OS_DARWIN
    720735    AssertMsg(   fMinGLVersion == 0.0
    721736              || 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));
    724744#endif
    725               , ("%s actual:%d min:%d fRet=%d\n",
    726                  pszWantedExtension, (int)(pState->fGLVersion * 10), (int)(fMinGLVersion * 10), fRet));
    727745    return fRet;
    728746}
     
    12371255    pState->ext.glPointParameterf           = (PFNGLPOINTPARAMETERFPROC)OGLGETPROCADDRESS("glPointParameterf");
    12381256    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);
    12391260    pState->ext.glBlendEquation             = (PFNGLBLENDEQUATIONPROC)OGLGETPROCADDRESS("glBlendEquation");
    12401261    AssertMsgReturn(pState->ext.glBlendEquation, ("glBlendEquation missing"), VERR_NOT_IMPLEMENTED);
     1262#endif
    12411263    pState->ext.glBlendEquationSeparate     = (PFNGLBLENDEQUATIONSEPARATEPROC)OGLGETPROCADDRESS("glBlendEquationSeparate");
    12421264    AssertMsgReturn(pState->ext.glBlendEquationSeparate, ("glBlendEquationSeparate missing"), VERR_NOT_IMPLEMENTED);
     
    12471269    pState->ext.glStencilFuncSeparate       = (PFNGLSTENCILFUNCSEPARATEPROC)OGLGETPROCADDRESS("glStencilFuncSeparate");
    12481270    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);
    12511271    pState->ext.glBindBuffer                = (PFNGLBINDBUFFERPROC)OGLGETPROCADDRESS("glBindBuffer");
    12521272    AssertMsgReturn(pState->ext.glBindBuffer, ("glBindBuffer missing"), VERR_NOT_IMPLEMENTED);
     
    12711291    pState->ext.glActiveTexture             = (PFNGLACTIVETEXTUREPROC)OGLGETPROCADDRESS("glActiveTexture");
    12721292    AssertMsgReturn(pState->ext.glActiveTexture, ("glActiveTexture missing"), VERR_NOT_IMPLEMENTED);
     1293#if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103
    12731294    pState->ext.glClientActiveTexture       = (PFNGLCLIENTACTIVETEXTUREPROC)OGLGETPROCADDRESS("glClientActiveTexture");
    12741295    AssertMsgReturn(pState->ext.glClientActiveTexture, ("glClientActiveTexture missing"), VERR_NOT_IMPLEMENTED);
     1296#endif
    12751297    pState->ext.glGetProgramivARB           = (PFNGLGETPROGRAMIVARBPROC)OGLGETPROCADDRESS("glGetProgramivARB");
    12761298    AssertMsgReturn(pState->ext.glGetProgramivARB, ("glGetProgramivARB missing"), VERR_NOT_IMPLEMENTED);
     
    22122234#endif
    22132235
    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)
     2236int 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)
    22162239{
    22172240    PVMSVGA3DSURFACE pSurface;
     
    23292352    pSurface->flags             = surfaceFlags;
    23302353    pSurface->format            = format;
    2331     memcpy(pSurface->faces, face, sizeof(face));
     2354    memcpy(pSurface->faces, face, sizeof(pSurface->faces));
    23322355    pSurface->cFaces            = 1;        /* check for cube maps later */
    23332356    pSurface->multiSampleCount  = multisampleCount;
     
    44684491                                                    vmsvga3dBlendEquation2GL(pContext->state.aRenderState[SVGA3D_RS_BLENDEQUATIONALPHA].uintValue));
    44694492            else
     4493            {
     4494#if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x102
     4495                glBlendEquation(vmsvga3dBlendEquation2GL(pRenderState[i].uintValue));
     4496#else
    44704497                pState->ext.glBlendEquation(vmsvga3dBlendEquation2GL(pRenderState[i].uintValue));
     4498#endif
     4499            }
    44714500            VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    44724501            break;
     
    44784507            vmsvgaColor2GLFloatArray(pRenderState[i].uintValue, &red, &green, &blue, &alpha);
    44794508
     4509#if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x102
     4510            glBlendColor(red, green, blue, alpha);
     4511#else
    44804512            pState->ext.glBlendColor(red, green, blue, alpha);
     4513#endif
    44814514            VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    44824515            break;
     
    57955828    /* Store for vm state save/restore. */
    57965829    pContext->state.aClipPlane[index].fValid = true;
    5797     memcpy(pContext->state.aClipPlane[index].plane, plane, sizeof(plane));
    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) */
    58005833    oglPlane[0] = (double)plane[0];
    58015834    oglPlane[1] = (double)plane[1];
     
    61096142            pState->ext.glEnableVertexAttribArray(index);
    61106143            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);
    61126146            VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61136147            /* case SVGA3D_DECLUSAGE_COLOR:    @todo color component order not identical!! test GL_BGRA!!  */
     
    61216155                glEnableClientState(GL_VERTEX_ARRAY);
    61226156                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);
    61246159                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61256160                break;
     
    61336168                glEnableClientState(GL_NORMAL_ARRAY);
    61346169                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);
    61366172                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61376173                break;
     
    61416177            case SVGA3D_DECLUSAGE_TEXCOORD:
    61426178                /* Specify the affected texture unit. */
     6179#if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x103
     6180                glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
     6181#else
    61436182                pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
     6183#endif
    61446184                glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    61456185                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);
    61476188                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61486189                break;
     
    61596200                AssertFailed(); /* see position_transformed in Wine */
    61606201                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!! */
    61626203                glEnableClientState(GL_COLOR_ARRAY);
    61636204                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);
    61656207                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61666208                break;
     
    61686210                glEnableClientState(GL_FOG_COORD_ARRAY);
    61696211                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);
    61716214                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
    61726215                break;
     
    62226265            case SVGA3D_DECLUSAGE_TEXCOORD:
    62236266                /* Specify the affected texture unit. */
     6267#if VBOX_VMSVGA3D_GL_HACK_LEVEL >= 0x103
     6268                glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
     6269#else
    62246270                pState->ext.glClientActiveTexture(GL_TEXTURE0 + pVertexDecl[iVertex].identity.usageIndex);
     6271#endif
    62256272                glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    62266273                VMSVGA3D_CHECK_LAST_ERROR(pState, pContext);
     
    63946441            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));
    63956442            if (pRange[iPrimitive].indexBias == 0)
    6396             {
    63976443                glDrawElements(modeDraw,
    63986444                               cVertices,
    63996445                               (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 */
    64026447            else
    64036448                pState->ext.glDrawElementsBaseVertex(modeDraw,
    64046449                                                     cVertices,
    64056450                                                     (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);        /* basevertex */
     6451                                                     (GLvoid *)(uintptr_t)pRange[iPrimitive].indexArray.offset, /* byte offset in indices buffer */
     6452                                                     pRange[iPrimitive].indexBias);  /* basevertex */
    64086453
    64096454            /* Unbind the index buffer after usage. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette