VirtualBox

Ignore:
Timestamp:
Mar 11, 2013 11:01:17 AM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: fix glDrawXxx-based blitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp

    r44766 r44972  
    104104DECLINLINE(GLfloat*) crBltVtRectTFNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff)
    105105{
     106    /* going ccw:
     107     * 1. (left;top)        4. (right;top)
     108     *        |                    ^
     109     *        >                    |
     110     * 2. (left;bottom)  -> 3. (right;bottom) */
    106111    /* xLeft yTop */
    107112    pBuff[0] = ((float)pRect->xLeft)/((float)normalX);
     
    159164
    160165/* Indexed GL_TRIANGLES */
    161 DECLINLINE(GLfloat*) crBltVtRectITNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase)
     166DECLINLINE(GLfloat*) crBltVtRectITNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff)
    162167{
    163168    GLfloat* ret = crBltVtRectTFNormalized(pRect, normalX, normalY, pBuff);
     169    return ret;
     170}
     171
     172DECLINLINE(GLint*) crBltVtRectIT(RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase)
     173{
     174    GLint* ret = crBltVtRectTF(pRect, normalX, normalY, pBuff);
    164175
    165176    if (ppIndex)
     
    169180}
    170181
    171 DECLINLINE(GLint*) crBltVtRectIT(RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase)
    172 {
    173     GLint* ret = crBltVtRectTF(pRect, normalX, normalY, pBuff);
     182DECLINLINE(GLuint) crBltVtGetNumVerticiesTF(GLuint cRects)
     183{
     184    return cRects * 4;
     185}
     186
     187#define crBltVtGetNumVerticiesIT crBltVtGetNumVerticiesTF
     188
     189DECLINLINE(GLuint) crBltVtGetNumIndiciesIT(GLuint cRects)
     190{
     191    return 6 * cRects;
     192}
     193
     194
     195static GLfloat* crBltVtRectsITNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase)
     196{
     197    uint32_t i;
     198    for (i = 0; i < cRects; ++i)
     199    {
     200        pBuff = crBltVtRectITNormalized(&paRects[i], normalX, normalY, pBuff);
     201    }
     202
    174203
    175204    if (ppIndex)
    176         *ppIndex = crBltVtFillRectIndicies(*ppIndex, piBase);
    177 
    178     return ret;
    179 }
    180 
    181 DECLINLINE(GLuint) crBltVtGetNumVerticiesTF(GLuint cRects)
    182 {
    183     return cRects * 4;
    184 }
    185 
    186 #define crBltVtGetNumVerticiesIT crBltVtGetNumVerticiesTF
    187 
    188 DECLINLINE(GLuint) crBltVtGetNumIndiciesIT(GLuint cRects)
    189 {
    190     return 6 * cRects;
    191 }
    192 
    193 
    194 static GLfloat* crBltVtRectsITNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase)
    195 {
    196     for (uint32_t i = 0; i < cRects; ++i)
    197     {
    198         pBuff = crBltVtRectITNormalized(&paRects[i], normalX, normalY, pBuff, ppIndex, piBase);
    199     }
     205    {
     206        GLubyte *pIndex = (GLubyte*)pBuff;
     207        *ppIndex = pIndex;
     208        for (i = 0; i < cRects; ++i)
     209        {
     210            pIndex = crBltVtFillRectIndicies(pIndex, piBase);
     211        }
     212        pBuff = (GLfloat*)pIndex;
     213    }
     214
    200215    return pBuff;
    201216}
     
    310325        {
    311326            pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies));
    312             pTexCoords = crBltVtRectTFNormalized(paDstRect, normalX, normalY, pVerticies);
     327            pTexCoords = crBltVtRectTFNormalized(paDstRect, 1, 1, pVerticies);
    313328            crBltVtRectTFNormalized(paSrcRect, normalX, normalY, pTexCoords);
    314329        }
     
    318333
    319334        pBlitter->pDispatch->EnableClientState(GL_TEXTURE_COORD_ARRAY);
    320         pBlitter->pDispatch->VertexPointer(2, GL_FLOAT, 0, pTexCoords);
     335        pBlitter->pDispatch->TexCoordPointer(2, GL_FLOAT, 0, pTexCoords);
    321336
    322337        pBlitter->pDispatch->Enable(pSrc->target);
     
    347362        {
    348363            pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies));
    349             pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase);
     364            pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase);
    350365            crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL);
    351366        }
     
    355370
    356371        pBlitter->pDispatch->EnableClientState(GL_TEXTURE_COORD_ARRAY);
    357         pBlitter->pDispatch->VertexPointer(2, GL_FLOAT, 0, pTexCoords);
     372        pBlitter->pDispatch->TexCoordPointer(2, GL_FLOAT, 0, pTexCoords);
    358373
    359374        pBlitter->pDispatch->Enable(pSrc->target);
     
    411426    if (pBlitter->pRestoreCtxInfo != &pBlitter->CtxInfo)
    412427    {
    413 //        GLuint idDrawFBO, idReadFBO;
    414 //        CR_BLITTER_WINDOW *pRestoreMural = pBlitter->pRestoreMural;
    415 //        if (pRestoreMural->fUseFBO && crServerSupportRedirMuralFBO())
    416 //        {
    417 //            idDrawFBO = pRestoreMural->aidFBOs[pRestoreMural->iCurDrawBuffer];
    418 //            idReadFBO = pRestoreMural->aidFBOs[pRestoreMural->iCurReadBuffer];
    419 //        }
    420 //        else
    421 //        {
    422 //            idDrawFBO = 0;
    423 //            idReadFBO = 0;
    424 //        }
    425428
    426429        pBlitter->pDispatch->MakeCurrent(pBlitter->pRestoreMural->Base.id, 0,
    427430                pBlitter->pRestoreCtxInfo->Base.id >= 0
    428431                    ? pBlitter->pRestoreCtxInfo->Base.id : pBlitter->pRestoreCtxInfo->Base.id);
    429 //        crStateSwitchPostprocess(pBlitter->pRestoreCtxInfo->pContext, NULL, idDrawFBO, idReadFBO);
    430432    }
    431433    else
     
    455457        pBlitter->pRestoreCtxInfo = pRestoreCtxInfo;
    456458        pBlitter->pRestoreMural = pRestoreMural;
    457 
    458 //        GLuint idDrawFBO, idReadFBO;
    459 //
    460 //        if (pRestoreMural->fUseFBO && crServerSupportRedirMuralFBO())
    461 //        {
    462 //            idDrawFBO = pRestoreMural->aidFBOs[pRestoreMural->iCurDrawBuffer];
    463 //            idReadFBO = pRestoreMural->aidFBOs[pRestoreMural->iCurReadBuffer];
    464 //        }
    465 //        else
    466 //        {
    467 //            idDrawFBO = 0;
    468 //            idReadFBO = 0;
    469 //        }
    470 //        crStateSwitchPrepare(NULL, pRestoreCtxInfo->pContext, idDrawFBO, idReadFBO);
    471459
    472460        pBlitter->pDispatch->Flush();
Note: See TracChangeset for help on using the changeset viewer.

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