VirtualBox

Ignore:
Timestamp:
Apr 14, 2020 6:25:47 PM (5 years ago)
Author:
vboxsync
Message:

WDDM: surface definition.

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/SvgaHostObjects.cpp

    r83578 r83694  
    319319    AssertReturn(Status == STATUS_SUCCESS, Status);
    320320
    321     AssertReturn(cSizes <= pSvga->u32MaxTextureLevels, STATUS_INVALID_PARAMETER);
     321    /* A surface must have dimensions. */
     322    AssertReturn(cSizes >= 1, STATUS_INVALID_PARAMETER);
     323
     324    /* Number of faces ('cFaces') is specified as the number of the first non-zero elements in the
     325     * 'pCreateParms->mip_levels' array.
     326     * Since only plain surfaces (cFaces == 1) and cubemaps (cFaces == 6) are supported
     327     * (see also SVGA3dCmdDefineSurface definition in svga3d_reg.h), we ignore anything else.
     328     */
     329    uint32_t cRemainingSizes = cSizes;
     330    uint32_t cFaces = 0;
     331    for (uint32_t i = 0; i < RT_ELEMENTS(pCreateParms->mip_levels); ++i)
     332    {
     333        if (pCreateParms->mip_levels[i] == 0)
     334            break;
     335
     336        /* Can't have too many mip levels. */
     337        AssertReturn(pCreateParms->mip_levels[i] <= pSvga->u32MaxTextureLevels, STATUS_INVALID_PARAMETER);
     338
     339        /* All SVGA3dSurfaceFace structures must have the same value of numMipLevels field */
     340        AssertReturn(pCreateParms->mip_levels[i] == pCreateParms->mip_levels[0], STATUS_INVALID_PARAMETER);
     341
     342        /* The miplevels count value can't be greater than the number of remaining elements in the paSizes array. */
     343        AssertReturn(pCreateParms->mip_levels[i] <= cRemainingSizes, STATUS_INVALID_PARAMETER);
     344        cRemainingSizes -= pCreateParms->mip_levels[i];
     345
     346        ++cFaces;
     347    }
     348    for (uint32_t i = cFaces; i < RT_ELEMENTS(pCreateParms->mip_levels); ++i)
     349        AssertReturn(pCreateParms->mip_levels[i] == 0, STATUS_INVALID_PARAMETER);
     350
     351    /* cFaces must be 6 for a cubemap and 1 otherwise. */
     352    AssertReturn(cFaces == (uint32_t)((pCreateParms->flags & SVGA3D_SURFACE_CUBEMAP) ? 6 : 1), STATUS_INVALID_PARAMETER);
     353
     354    /* Sum of pCreateParms->mip_levels[i] must be equal to cSizes. */
     355    AssertReturn(cRemainingSizes == 0, STATUS_INVALID_PARAMETER);
    322356
    323357    SURFACEOBJECT *pSO = (SURFACEOBJECT *)GaMemAllocZero(sizeof(SURFACEOBJECT));
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/VBoxMPGaWddm.cpp

    r83578 r83694  
    17381738            }
    17391739
     1740            if (pGaSurfaceDefine->cbReq < sizeof(GASURFCREATE))
     1741            {
     1742                Status = STATUS_INVALID_PARAMETER;
     1743                break;
     1744            }
     1745
     1746            uint32_t const cSizes = (pGaSurfaceDefine->cbReq - sizeof(GASURFCREATE)) / sizeof(GASURFSIZE);
     1747            if (cSizes != pGaSurfaceDefine->cSizes)
     1748            {
     1749                Status = STATUS_INVALID_PARAMETER;
     1750                break;
     1751            }
     1752
    17401753            GASURFCREATE *pCreateParms = (GASURFCREATE *)&pGaSurfaceDefine[1];
    17411754            GASURFSIZE *paSizes = (GASURFSIZE *)&pCreateParms[1];
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