- Timestamp:
- Mar 10, 2023 4:34:32 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156244
- 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 5061 5061 Assert(uFace == 0 && uMipmap == 0); /* The caller ensures this. */ 5062 5062 /** @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); 5064 5064 } 5065 5065 else … … 6415 6415 D3D_RELEASE(pBlob); 6416 6416 } 6417 LogFunc(("Shader: set cid=%u shid=%u type=%d, GuestSignatures %d\n", pDXContext->cid, shaderId, pDXShader->enmShaderType, pDXShader->shaderInfo.fGuestSignatures)); 6417 6418 #endif 6418 6419 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp
r98103 r98908 577 577 578 578 #ifdef DUMP_BITMAPS 579 static void vmsvga3dDXDrawDumpRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext )579 static void vmsvga3dDXDrawDumpRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, const char *pszPrefix = NULL) 580 580 { 581 581 for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i) … … 594 594 if (RT_SUCCESS(rc)) 595 595 { 596 vmsvga3dMapWriteBmpFile(&map, "rt-");596 vmsvga3dMapWriteBmpFile(&map, pszPrefix ? pszPrefix : "rt-"); 597 597 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false); 598 598 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r98693 r98908 962 962 for (uint32_t i = 0; i < cRects; i++) 963 963 { 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)); 965 965 } 966 966 … … 1093 1093 VMSVGASCREENOBJECT *pScreen = &pSvgaR3State->aScreens[idDstScreen]; 1094 1094 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 1095 1099 if ( srcRect.right <= srcRect.left 1096 1100 || srcRect.bottom <= srcRect.top) … … 1115 1119 dstBox.d = 1; 1116 1120 1117 SVGA3dSize dst Bound;1118 dst Bound.width = pScreen->cWidth;1119 dst Bound.height = pScreen->cHeight;1120 dst Bound.depth = 1;1121 1122 vmsvgaR3ClipBox(&dst Bound, &dstBox);1121 SVGA3dSize dstClippingSize; 1122 dstClippingSize.width = pScreen->cWidth; 1123 dstClippingSize.height = pScreen->cHeight; 1124 dstClippingSize.depth = 1; 1125 1126 vmsvgaR3ClipBox(&dstClippingSize, &dstBox); 1123 1127 ASSERT_GUEST_RETURN(dstBox.w > 0 && dstBox.h > 0, VERR_INVALID_PARAMETER); 1124 1128 RT_UNTRUSTED_VALIDATED_FENCE(); … … 1126 1130 /* All dst clip rects will be clipped by the dst box because 1127 1131 * "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.1129 1132 */ 1130 dst Bound.width = dstBox.w;1131 dst Bound.height = dstBox.h;1132 dst Bound.depth = 1;1133 dstClippingSize.width = dstBox.w; 1134 dstClippingSize.height = dstBox.h; 1135 dstClippingSize.depth = 1; 1133 1136 1134 1137 SVGA3dBox srcBox; /* SurfaceMap will clip the box as necessary (srcMap.box). */ … … 1144 1147 if (RT_SUCCESS(rc)) 1145 1148 { 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 1146 1162 uint8_t const *pu8Src = (uint8_t *)srcMap.pvData; 1147 1163 1148 1164 uint32_t const cbDst = pScreen->cHeight * pScreen->cbPitch; 1149 uint32_t cbScreenPixel = RT_ALIGN(pScreen->cBpp, 8) / 8;1150 1165 uint8_t *pu8Dst; 1151 1166 if (pScreen->pvScreenBitmap) … … 1169 1184 for (uint32_t i = 0; i < cDstClipRects; i++) 1170 1185 { 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); 1183 1202 1184 1203 /* 'pu8Src' points to the mapped 'srcRect'. Take the clipping box into account. */ 1185 1204 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) 1205 1219 { 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) 1216 1221 { 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. */ 1218 1223 { 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]; 1229 1228 } 1229 1230 pu8SrcBox += srcMap.cbRowPitch; 1231 pu8DstBox += pScreen->cbPitch; 1230 1232 } 1231 else 1233 } 1234 else 1235 { 1236 for (uint32_t iRow = 0; iRow < clipBox.h; ++iRow) 1232 1237 { 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; 1240 1242 } 1241 1243 }
Note:
See TracChangeset
for help on using the changeset viewer.