VirtualBox

Changeset 91011 in vbox


Ignore:
Timestamp:
Aug 30, 2021 7:34:32 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146651
Message:

3D/VMSVGA: Workaround for wrong sampler type declaration SVGA3DSAMP_UNKNOWN (usually happens with Linux guest having Mesa 21), bugref:10091

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

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

    r86593 r91011  
    3939    /** Version token. */
    4040    SVGA3dShaderVersion version;
     41
     42    SVGA3dShaderOpCodeType currentOpcode;
     43    union
     44    {
     45        SVGA3DOpDclArgs *pDclArgs;
     46    } u;
    4147} VMSVGA3DSHADERPARSECONTEXT;
    4248
     
    159165    Log3(("Dest: type %d, r0 %d, shfScale %d, dstMod %d, mask 0x%x, r1 %d, relAddr %d, num %d\n",
    160166        regType, dest.reserved0, dest.shfScale, dest.dstMod, dest.mask, dest.reserved1, dest.relAddr, dest.num));
     167
     168    if (pCtx->currentOpcode == SVGA3DOP_DCL && regType == SVGA3DREG_SAMPLER)
     169    {
     170        if (pCtx->u.pDclArgs->type == SVGA3DSAMP_UNKNOWN)
     171        {
     172            Log3(("Replacing SVGA3DSAMP_UNKNOWN with SVGA3DSAMP_2D\n"));
     173            pCtx->u.pDclArgs->type = SVGA3DSAMP_2D;
     174        }
     175    }
    161176
    162177    return vmsvga3dShaderParseRegOffset(pCtx, false, regType, dest.num);
     
    300315 * https://docs.microsoft.com/en-us/windows-hardware/drivers/display/shader-code-format
    301316 */
    302 int vmsvga3dShaderParse(SVGA3dShaderType type, uint32_t cbShaderData, uint32_t const* pShaderData)
    303 {
    304     uint32_t const* paTokensStart = (uint32_t*)pShaderData;
     317int vmsvga3dShaderParse(SVGA3dShaderType type, uint32_t cbShaderData, uint32_t* pShaderData)
     318{
     319    uint32_t *paTokensStart = (uint32_t*)pShaderData;
    305320    uint32_t const cTokens = cbShaderData / sizeof(uint32_t);
    306321
     
    341356
    342357    /* Scan the tokens. Immediately return an error code on any unexpected data. */
    343     uint32_t const* paTokensEnd = &paTokensStart[cTokens];
    344     uint32_t const* pToken = &paTokensStart[1]; /* Skip the version token. */
     358    uint32_t *paTokensEnd = &paTokensStart[cTokens];
     359    uint32_t *pToken = &paTokensStart[1]; /* Skip the version token. */
    345360    bool  bEndTokenFound = false;
    346361    while (pToken < paTokensEnd)
     
    366381        }
    367382
     383        ctx.currentOpcode = (SVGA3dShaderOpCodeType)token.op;
     384
    368385        /* If this instrution is in the aOps table. */
    369386        if (token.op <= SVGA3DOP_BREAKP)
    370387        {
    371388            VMSVGA3DSHADERPARSEOP const* pOp = &aOps[token.op];
     389
     390            if (ctx.currentOpcode == SVGA3DOP_DCL)
     391                ctx.u.pDclArgs = (SVGA3DOpDclArgs *)&pToken[1];
    372392
    373393            /* cInstLen can be greater than pOp->Length.
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h

    r89171 r91011  
    14081408#endif
    14091409
    1410 int vmsvga3dShaderParse(SVGA3dShaderType type, uint32_t cbShaderData, uint32_t const *pShaderData);
     1410int vmsvga3dShaderParse(SVGA3dShaderType type, uint32_t cbShaderData, uint32_t *pShaderData);
    14111411void vmsvga3dShaderLogRel(char const *pszMsg, SVGA3dShaderType type, uint32_t cbShaderData, uint32_t const *pShaderData);
    14121412
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