VirtualBox

Opened 2 years ago

Last modified 2 years ago

#21326 new defect

DirectX 9 image wrong offset in win7 guest

Reported by: pv32768 Owned by:
Component: 3D support Version: VirtualBox-7.0.4
Keywords: Cc:
Guest type: Windows Host type: all

Description

The few DX-9 applications that still run in a Windows 7 guest look like this:

VirtualBox 7.0.4, 3D Acceleration on

Host: Gentoo Linux

Guest: Windows 7

Application: DirectX 9.0 SDK, Tutorial 02

Fix:

diff -Naur a/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp b/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
--- a/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp	2022-11-17 22:12:55.000000000 +0300
+++ b/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp	2022-12-05 16:06:25.417632425 +0300
@@ -1093,6 +1093,8 @@
 
     VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idDstScreen];
 
+    uint32_t const  cbScreenPixel = RT_ALIGN(pScreen->cBpp, 8) / 8;
+
     if (   srcRect.right <= srcRect.left
         || srcRect.bottom <= srcRect.top)
         return VINF_SUCCESS; /* Empty src rect. */
@@ -1186,6 +1188,8 @@
                 + ((box.x + pSurface->cxBlock - 1) / pSurface->cxBlock) * pSurface->cxBlock * pSurface->cbBlock
                 + ((box.y + pSurface->cyBlock - 1) / pSurface->cyBlock) * pSurface->cyBlock * srcMap.cbRowPitch;
 
+            uint32_t const offDstBox = (dstBox.x + box.x) * cbScreenPixel + (dstBox.y + box.y) * pScreen->cbPitch;
+
             /* The 'box' is actually in the destination coordinates relative to the top-left corner of destRect.
              * Therefore it is relative to the top-left corner of srcRect as well.
              */
@@ -1198,11 +1202,11 @@
             {
                 AssertContinue(srcDims.cyBlocks > 0);
 
-                ASSERT_GUEST_BREAK(   srcDims.offBox <= cbDst
-                                   && pScreen->cbPitch * (srcDims.cyBlocks - 1) + srcDims.cbRow <= cbDst - srcDims.offBox);
+                ASSERT_GUEST_BREAK(   offDstBox <= cbDst
+                                   && pScreen->cbPitch * (srcDims.cyBlocks - 1) + srcDims.cbRow <= cbDst - offDstBox);
                 RT_UNTRUSTED_VALIDATED_FENCE();
 
-                uint8_t *pu8DstBox = pu8Dst + srcDims.offBox;
+                uint8_t *pu8DstBox = pu8Dst + offDstBox;
 
                 if (   pSurface->format == SVGA3D_R8G8B8A8_UNORM
                     || pSurface->format == SVGA3D_R8G8B8A8_UNORM_SRGB)

Attachments (3)

patch.txt (1.9 KB ) - added by pv32768 2 years ago.
Untitlet.png (1.9 KB ) - added by pv32768 2 years ago.
Untitled.png (37.8 KB ) - added by pv32768 2 years ago.

Download all attachments as: .zip

Change History (5)

by pv32768, 2 years ago

Attachment: patch.txt added

by pv32768, 2 years ago

Attachment: Untitlet.png added

by pv32768, 2 years ago

Attachment: Untitled.png added

comment:1 by Dmitrii Grigorev, 2 years ago

Hello. Thank you for the ticket and your patch. Could you attach VBox.log here (to be more specific)?

Version 0, edited 2 years ago by Dmitrii Grigorev (next)

comment:2 by Dmitrii Grigorev, 2 years ago

Hello.

Some more testing revealed that the issue is

  1. always reproduces in Windows 7 guest
  2. not observed on Windows 10 guest

This is a serious bug.

Note: See TracTickets for help on using tickets.

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