VirtualBox

Changeset 98908 in vbox for trunk


Ignore:
Timestamp:
Mar 10, 2023 4:34:32 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156244
Message:

Devices/Graphics: fixed src/dst mismatch in vmsvga3dScreenUpdate; logging

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

Legend:

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

    r98103 r98908  
    50615061        Assert(uFace == 0 && uMipmap == 0); /* The caller ensures this. */
    50625062        /** @todo This causes flickering when a buffer is invalidated and re-created right before a draw call. */
    5063         //vmsvga3dBackSurfaceDestroy(pThisCC, pSurface);
     5063        //vmsvga3dBackSurfaceDestroy(pThisCC, false, pSurface);
    50645064    }
    50655065    else
     
    64156415                        D3D_RELEASE(pBlob);
    64166416                    }
     6417                    LogFunc(("Shader: set cid=%u shid=%u type=%d, GuestSignatures %d\n", pDXContext->cid, shaderId, pDXShader->enmShaderType, pDXShader->shaderInfo.fGuestSignatures));
    64176418#endif
    64186419
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp

    r98103 r98908  
    577577
    578578#ifdef DUMP_BITMAPS
    579 static void vmsvga3dDXDrawDumpRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
     579static void vmsvga3dDXDrawDumpRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, const char *pszPrefix = NULL)
    580580{
    581581    for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)
     
    594594            if (RT_SUCCESS(rc))
    595595            {
    596                 vmsvga3dMapWriteBmpFile(&map, "rt-");
     596                vmsvga3dMapWriteBmpFile(&map, pszPrefix ? pszPrefix : "rt-");
    597597                vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten =  */ false);
    598598            }
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp

    r98693 r98908  
    962962    for (uint32_t i = 0; i < cRects; i++)
    963963    {
    964         LogFunc(("clipping rect %d (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom));
     964        LogFunc(("clipping rect[%d] (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom));
    965965    }
    966966
     
    10931093    VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idDstScreen];
    10941094
     1095    uint32_t const cbScreenPixel = (pScreen->cBpp + 7) / 8;
     1096    ASSERT_GUEST_RETURN(cbScreenPixel == pSurface->cbBlock,
     1097                        VERR_INVALID_PARAMETER); /* Format conversion is not supported. */
     1098
    10951099    if (   srcRect.right <= srcRect.left
    10961100        || srcRect.bottom <= srcRect.top)
     
    11151119    dstBox.d = 1;
    11161120
    1117     SVGA3dSize dstBound;
    1118     dstBound.width = pScreen->cWidth;
    1119     dstBound.height = pScreen->cHeight;
    1120     dstBound.depth = 1;
    1121 
    1122     vmsvgaR3ClipBox(&dstBound, &dstBox);
     1121    SVGA3dSize dstClippingSize;
     1122    dstClippingSize.width = pScreen->cWidth;
     1123    dstClippingSize.height = pScreen->cHeight;
     1124    dstClippingSize.depth = 1;
     1125
     1126    vmsvgaR3ClipBox(&dstClippingSize, &dstBox);
    11231127    ASSERT_GUEST_RETURN(dstBox.w > 0 && dstBox.h > 0, VERR_INVALID_PARAMETER);
    11241128    RT_UNTRUSTED_VALIDATED_FENCE();
     
    11261130    /* All dst clip rects will be clipped by the dst box because
    11271131     * "The clip rectangle coordinates are measured relative to the top-left corner of destRect."
    1128      * Therefore they are relative to the top-left corner of srcRect as well.
    11291132     */
    1130     dstBound.width = dstBox.w;
    1131     dstBound.height = dstBox.h;
    1132     dstBound.depth = 1;
     1133    dstClippingSize.width = dstBox.w;
     1134    dstClippingSize.height = dstBox.h;
     1135    dstClippingSize.depth = 1;
    11331136
    11341137    SVGA3dBox srcBox; /* SurfaceMap will clip the box as necessary (srcMap.box). */
     
    11441147    if (RT_SUCCESS(rc))
    11451148    {
     1149        /* Clipping rectangle. */
     1150        SVGASignedRect srcBoundRect;
     1151        srcBoundRect.left   = srcMap.box.x;
     1152        srcBoundRect.top    = srcMap.box.y;
     1153        srcBoundRect.right  = srcMap.box.x + srcMap.box.w;
     1154        srcBoundRect.bottom = srcMap.box.y + srcMap.box.h;
     1155
     1156        /* Clipping rectangle relative to the original srcRect. */
     1157        srcBoundRect.left   -= srcRect.left;
     1158        srcBoundRect.top    -= srcRect.top;
     1159        srcBoundRect.right  -= srcRect.left;
     1160        srcBoundRect.bottom -= srcRect.top;
     1161
    11461162        uint8_t const *pu8Src = (uint8_t *)srcMap.pvData;
    11471163
    11481164        uint32_t const cbDst = pScreen->cHeight * pScreen->cbPitch;
    1149         uint32_t cbScreenPixel = RT_ALIGN(pScreen->cBpp, 8) / 8;
    11501165        uint8_t *pu8Dst;
    11511166        if (pScreen->pvScreenBitmap)
     
    11691184        for (uint32_t i = 0; i < cDstClipRects; i++)
    11701185        {
    1171             SVGASignedRect const *pDstClipRect = &paDstClipRect[i];
    1172 
    1173             SVGA3dBox box;
    1174             box.x = pDstClipRect->left;
    1175             box.y = pDstClipRect->top;
    1176             box.z = 0;
    1177             box.w = pDstClipRect->right - pDstClipRect->left;
    1178             box.h = pDstClipRect->bottom - pDstClipRect->top;
    1179             box.d = 1;
    1180 
    1181             vmsvgaR3ClipBox(&dstBound, &box);
    1182             ASSERT_GUEST_CONTINUE(box.w > 0 && box.h > 0);
     1186            /* Clip rects are relative to corners of src and dst rectangles. */
     1187            SVGASignedRect clipRect = paDstClipRect[i];
     1188
     1189            /* Clip the rectangle by mapped source box. */
     1190            vmsvgaR3ClipRect(&srcBoundRect, &clipRect);
     1191
     1192            SVGA3dBox clipBox;
     1193            clipBox.x = clipRect.left;
     1194            clipBox.y = clipRect.top;
     1195            clipBox.z = 0;
     1196            clipBox.w = clipRect.right - clipRect.left;
     1197            clipBox.h = clipRect.bottom - clipRect.top;
     1198            clipBox.d = 1;
     1199
     1200            vmsvgaR3ClipBox(&dstClippingSize, &clipBox);
     1201            ASSERT_GUEST_CONTINUE(clipBox.w > 0 && clipBox.h > 0);
    11831202
    11841203            /* 'pu8Src' points to the mapped 'srcRect'. Take the clipping box into account. */
    11851204            uint8_t const *pu8SrcBox = pu8Src
    1186                 + ((box.x + pSurface->cxBlock - 1) / pSurface->cxBlock) * pSurface->cxBlock * pSurface->cbBlock
    1187                 + ((box.y + pSurface->cyBlock - 1) / pSurface->cyBlock) * pSurface->cyBlock * srcMap.cbRowPitch;
    1188 
    1189             /* The 'box' is in coordinates relative to the top-left dstRect or srcRect corner.
    1190              * The 'dstBoxAbs' and 'srcBoxAbs' are absolute coordinates of 'box' within screen object or texture face (respectively).
    1191              */
    1192             SVGA3dBox srcBoxAbs = box, dstBoxAbs = box;
    1193 
    1194             srcBoxAbs.x += srcBox.x;
    1195             srcBoxAbs.y += srcBox.y;
    1196 
    1197             dstBoxAbs.x += dstBox.x;
    1198             dstBoxAbs.y += dstBox.y;
    1199 
    1200             uint32_t offDst = pScreen->cbPitch * dstBoxAbs.y + cbScreenPixel * dstBoxAbs.x;
    1201 
    1202             VMSGA3D_BOX_DIMENSIONS srcDims;
    1203             rc = vmsvga3dGetBoxDimensions(pThisCC, &srcImage, &srcBoxAbs, &srcDims);
    1204             if (RT_SUCCESS(rc))
     1205                + ((clipBox.x + pSurface->cxBlock - 1) / pSurface->cxBlock) * pSurface->cxBlock * pSurface->cbBlock
     1206                + ((clipBox.y + pSurface->cyBlock - 1) / pSurface->cyBlock) * pSurface->cyBlock * srcMap.cbRowPitch;
     1207
     1208            /* Calculate the offset of destination box in the screen buffer. */
     1209            uint32_t const offDstBox = (dstBox.x + clipBox.x) * cbScreenPixel + (dstBox.y + clipBox.y) * pScreen->cbPitch;
     1210
     1211            ASSERT_GUEST_BREAK(   offDstBox <= cbDst
     1212                               && pScreen->cbPitch * (clipBox.h - 1) + cbScreenPixel * clipBox.w <= cbDst - offDstBox);
     1213            RT_UNTRUSTED_VALIDATED_FENCE();
     1214
     1215            uint8_t *pu8DstBox = pu8Dst + offDstBox;
     1216
     1217            if (   pSurface->format == SVGA3D_R8G8B8A8_UNORM
     1218                || pSurface->format == SVGA3D_R8G8B8A8_UNORM_SRGB)
    12051219            {
    1206                 AssertContinue(srcDims.cyBlocks > 0);
    1207 
    1208                 ASSERT_GUEST_BREAK(   offDst <= cbDst
    1209                                    && pScreen->cbPitch * (srcDims.cyBlocks - 1) + srcDims.cbRow <= cbDst - offDst);
    1210                 RT_UNTRUSTED_VALIDATED_FENCE();
    1211 
    1212                 uint8_t *pu8DstBox = pu8Dst + offDst;
    1213 
    1214                 if (   pSurface->format == SVGA3D_R8G8B8A8_UNORM
    1215                     || pSurface->format == SVGA3D_R8G8B8A8_UNORM_SRGB)
     1220                for (uint32_t iRow = 0; iRow < clipBox.h; ++iRow)
    12161221                {
    1217                     for (uint32_t iRow = 0; iRow < srcDims.cyBlocks; ++iRow)
     1222                    for (uint32_t x = 0; x < clipBox.w * 4; x += 4) /* 'x' is a byte index. */
    12181223                    {
    1219                         for (uint32_t x = 0; x < box.w * 4; x += 4) /* 'x' is a byte index. */
    1220                         {
    1221                             pu8DstBox[x    ] = pu8SrcBox[x + 2];
    1222                             pu8DstBox[x + 1] = pu8SrcBox[x + 1];
    1223                             pu8DstBox[x + 2] = pu8SrcBox[x    ];
    1224                             pu8DstBox[x + 3] = pu8SrcBox[x + 3];
    1225                         }
    1226 
    1227                         pu8SrcBox += srcMap.cbRowPitch;
    1228                         pu8DstBox += pScreen->cbPitch;
     1224                        pu8DstBox[x    ] = pu8SrcBox[x + 2];
     1225                        pu8DstBox[x + 1] = pu8SrcBox[x + 1];
     1226                        pu8DstBox[x + 2] = pu8SrcBox[x    ];
     1227                        pu8DstBox[x + 3] = pu8SrcBox[x + 3];
    12291228                    }
     1229
     1230                    pu8SrcBox += srcMap.cbRowPitch;
     1231                    pu8DstBox += pScreen->cbPitch;
    12301232                }
    1231                 else
     1233            }
     1234            else
     1235            {
     1236                for (uint32_t iRow = 0; iRow < clipBox.h; ++iRow)
    12321237                {
    1233                     for (uint32_t iRow = 0; iRow < srcDims.cyBlocks; ++iRow)
    1234                     {
    1235                         memcpy(pu8DstBox, pu8SrcBox, srcDims.cbRow);
    1236 
    1237                         pu8SrcBox += srcMap.cbRowPitch;
    1238                         pu8DstBox += pScreen->cbPitch;
    1239                     }
     1238                    memcpy(pu8DstBox, pu8SrcBox, cbScreenPixel * clipBox.w);
     1239
     1240                    pu8SrcBox += srcMap.cbRowPitch;
     1241                    pu8DstBox += pScreen->cbPitch;
    12401242                }
    12411243            }
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