Changeset 53756 in vbox for trunk/src/VBox/Devices/Graphics
- Timestamp:
- Jan 6, 2015 11:28:38 PM (10 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r53755 r53756 2871 2871 * @returns VBox status code. 2872 2872 * @param pThis VGA device instance data. 2873 * @param transferTransfer type (read/write)2874 * @param p Dest Host destination pointer2873 * @param enmTransferType Transfer type (read/write) 2874 * @param pbDst Host destination pointer 2875 2875 * @param cbDestPitch Destination buffer pitch 2876 2876 * @param src GMR description 2877 * @param cbSrcOffsetSource buffer offset2877 * @param offSrc Source buffer offset 2878 2878 * @param cbSrcPitch Source buffer pitch 2879 2879 * @param cbWidth Source width in bytes 2880 2880 * @param cHeight Source height 2881 2881 */ 2882 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType transfer, uint8_t *pDest, int32_t cbDestPitch, SVGAGuestPtr src, uint32_t cbSrcOffset, int32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight) 2882 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType, uint8_t *pbDst, int32_t cbDestPitch, 2883 SVGAGuestPtr src, uint32_t offSrc, int32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight) 2883 2884 { 2884 2885 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; … … 2886 2887 int rc; 2887 2888 PVMSVGAGMRDESCRIPTOR pDesc; 2888 unsigned uDescOffset = 0; 2889 2890 Log(("vmsvgaGMRTransfer: gmr=%x offset=%x pitch=%d cbWidth=%d cHeight=%d; src offset=%d src pitch=%d\n", src.gmrId, src.offset, cbDestPitch, cbWidth, cHeight, cbSrcOffset, cbSrcPitch)); 2889 unsigned offDesc = 0; 2890 2891 Log(("vmsvgaGMRTransfer: gmr=%x offset=%x pitch=%d cbWidth=%d cHeight=%d; src offset=%d src pitch=%d\n", 2892 src.gmrId, src.offset, cbDestPitch, cbWidth, cHeight, offSrc, cbSrcPitch)); 2891 2893 Assert(cbWidth && cHeight); 2892 2894 … … 2894 2896 if (src.gmrId == SVGA_GMR_FRAMEBUFFER) 2895 2897 { 2896 cbSrcOffset += src.offset; 2897 AssertReturn(src.offset < pThis->vram_size, VERR_INVALID_PARAMETER); 2898 AssertReturn(cbSrcOffset + cbSrcPitch * (cHeight - 1) + cbWidth <= pThis->vram_size, VERR_INVALID_PARAMETER); 2899 2900 uint8_t *pSrc = pThis->CTX_SUFF(vram_ptr) + cbSrcOffset; 2901 2902 if (transfer == SVGA3D_READ_HOST_VRAM) 2898 offSrc += src.offset; 2899 AssertMsgReturn(src.offset < pThis->vram_size, 2900 ("src.offset=%#x offSrc=%#x cbSrcPitch=%#x cHeight=%#x cbWidth=%#x cbTotal=%#x vram_size=%#x\n", 2901 src.offset, offSrc, cbSrcPitch, cHeight, cbWidth, pThis->vram_size), 2902 VERR_INVALID_PARAMETER); 2903 AssertMsgReturn(offSrc + cbSrcPitch * (cHeight - 1) + cbWidth <= pThis->vram_size, 2904 ("src.offset=%#x offSrc=%#x cbSrcPitch=%#x cHeight=%#x cbWidth=%#x cbTotal=%#x vram_size=%#x\n", 2905 src.offset, offSrc, cbSrcPitch, cHeight, cbWidth, pThis->vram_size), 2906 VERR_INVALID_PARAMETER); 2907 2908 uint8_t *pSrc = pThis->CTX_SUFF(vram_ptr) + offSrc; 2909 2910 if (enmTransferType == SVGA3D_READ_HOST_VRAM) 2903 2911 { 2904 2912 /* switch src & dest */ 2905 uint8_t *pTemp = p Dest;2913 uint8_t *pTemp = pbDst; 2906 2914 int32_t cbTempPitch = cbDestPitch; 2907 2915 2908 p Dest = pSrc;2916 pbDst = pSrc; 2909 2917 pSrc = pTemp; 2910 2918 … … 2917 2925 && cbSrcPitch == cbDestPitch) 2918 2926 { 2919 memcpy(p Dest, pSrc, cbWidth * cHeight);2927 memcpy(pbDst, pSrc, cbWidth * cHeight); 2920 2928 } 2921 2929 else … … 2923 2931 for(uint32_t i = 0; i < cHeight; i++) 2924 2932 { 2925 memcpy(p Dest, pSrc, cbWidth);2926 2927 p Dest += cbDestPitch;2933 memcpy(pbDst, pSrc, cbWidth); 2934 2935 pbDst += cbDestPitch; 2928 2936 pSrc += cbSrcPitch; 2929 2937 } … … 2936 2944 pDesc = pGMR->paDesc; 2937 2945 2938 cbSrcOffset += src.offset; 2939 AssertReturn(src.offset < pGMR->cbTotal, VERR_INVALID_PARAMETER); 2940 AssertReturn(cbSrcOffset + cbSrcPitch * (cHeight - 1) + cbWidth <= pGMR->cbTotal, VERR_INVALID_PARAMETER); 2941 2942 for (unsigned i = 0; i < cHeight; i++) 2943 { 2944 unsigned cbCurrentWidth = cbWidth; 2945 unsigned uCurrentOffset = cbSrcOffset; 2946 uint8_t *pCurrentDest = pDest; 2946 offSrc += src.offset; 2947 AssertMsgReturn(src.offset < pGMR->cbTotal, 2948 ("src.gmrId=%#x src.offset=%#x offSrc=%#x cbSrcPitch=%#x cHeight=%#x cbWidth=%#x cbTotal=%#x\n", 2949 src.gmrId, src.offset, offSrc, cbSrcPitch, cHeight, cbWidth, pGMR->cbTotal), 2950 VERR_INVALID_PARAMETER); 2951 AssertMsgReturn(offSrc + cbSrcPitch * (cHeight - 1) + cbWidth <= pGMR->cbTotal, 2952 ("src.gmrId=%#x src.offset=%#x offSrc=%#x cbSrcPitch=%#x cHeight=%#x cbWidth=%#x cbTotal=%#x\n", 2953 src.gmrId, src.offset, offSrc, cbSrcPitch, cHeight, cbWidth, pGMR->cbTotal), 2954 VERR_INVALID_PARAMETER); 2955 2956 for (uint32_t i = 0; i < cHeight; i++) 2957 { 2958 uint32_t cbCurrentWidth = cbWidth; 2959 uint32_t offCurrent = offSrc; 2960 uint8_t *pCurrentDest = pbDst; 2947 2961 2948 2962 /* Find the right descriptor */ 2949 while ( uDescOffset + pDesc->numPages * PAGE_SIZE <= uCurrentOffset)2950 { 2951 uDescOffset+= pDesc->numPages * PAGE_SIZE;2952 AssertReturn( uDescOffset< pGMR->cbTotal, VERR_INTERNAL_ERROR); /* overflow protection */2963 while (offDesc + pDesc->numPages * PAGE_SIZE <= offCurrent) 2964 { 2965 offDesc += pDesc->numPages * PAGE_SIZE; 2966 AssertReturn(offDesc < pGMR->cbTotal, VERR_INTERNAL_ERROR); /* overflow protection */ 2953 2967 pDesc++; 2954 2968 } … … 2956 2970 while (cbCurrentWidth) 2957 2971 { 2958 u nsignedcbToCopy;2959 2960 if ( uCurrentOffset + cbCurrentWidth <= uDescOffset+ pDesc->numPages * PAGE_SIZE)2972 uint32_t cbToCopy; 2973 2974 if (offCurrent + cbCurrentWidth <= offDesc + pDesc->numPages * PAGE_SIZE) 2961 2975 { 2962 2976 cbToCopy = cbCurrentWidth; … … 2964 2978 else 2965 2979 { 2966 cbToCopy = ( uDescOffset + pDesc->numPages * PAGE_SIZE - uCurrentOffset);2980 cbToCopy = (offDesc + pDesc->numPages * PAGE_SIZE - offCurrent); 2967 2981 AssertReturn(cbToCopy <= cbCurrentWidth, VERR_INVALID_PARAMETER); 2968 2982 } 2969 2983 2970 LogFlow(("vmsvgaGMRTransfer: %s phys=%RGp\n", ( transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", pDesc->GCPhys + uCurrentOffset - uDescOffset));2971 2972 if ( transfer== SVGA3D_WRITE_HOST_VRAM)2973 rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pDesc->GCPhys + uCurrentOffset - uDescOffset, pCurrentDest, cbToCopy);2984 LogFlow(("vmsvgaGMRTransfer: %s phys=%RGp\n", (enmTransferType == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", pDesc->GCPhys + offCurrent - offDesc)); 2985 2986 if (enmTransferType == SVGA3D_WRITE_HOST_VRAM) 2987 rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pDesc->GCPhys + offCurrent - offDesc, pCurrentDest, cbToCopy); 2974 2988 else 2975 rc = PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), pDesc->GCPhys + uCurrentOffset - uDescOffset, pCurrentDest, cbToCopy);2989 rc = PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), pDesc->GCPhys + offCurrent - offDesc, pCurrentDest, cbToCopy); 2976 2990 AssertRCBreak(rc); 2977 2991 2978 2992 cbCurrentWidth -= cbToCopy; 2979 uCurrentOffset+= cbToCopy;2993 offCurrent += cbToCopy; 2980 2994 pCurrentDest += cbToCopy; 2981 2995 … … 2983 2997 if (cbCurrentWidth) 2984 2998 { 2985 uDescOffset+= pDesc->numPages * PAGE_SIZE;2999 offDesc += pDesc->numPages * PAGE_SIZE; 2986 3000 pDesc++; 2987 3001 } 2988 3002 } 2989 3003 2990 cbSrcOffset+= cbSrcPitch;2991 p Dest+= cbDestPitch;3004 offSrc += cbSrcPitch; 3005 pbDst += cbDestPitch; 2992 3006 } 2993 3007 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r53755 r53756 2762 2762 #endif 2763 2763 rc = vmsvgaGMRTransfer(pThis, 2764 2765 2764 transfer, 2765 pBufferStart, 2766 2766 #ifdef MANUAL_FLIP_SURFACE_DATA 2767 2767 -(int32_t)pMipLevel->cbSurfacePitch, 2768 2768 #else 2769 2769 (int32_t)pMipLevel->cbSurfacePitch, 2770 2770 #endif 2771 2772 2773 2774 2775 2771 guest.ptr, 2772 pBoxes[i].srcx * pSurface->cbBlock + (pBoxes[i].srcy + pBoxes[i].srcz * pBoxes[i].h) * cbSrcPitch, 2773 cbSrcPitch, 2774 pBoxes[i].w * pSurface->cbBlock, 2775 pBoxes[i].d * pBoxes[i].h); 2776 2776 2777 2777 Log4(("first line:\n%.*Rhxd\n", pMipLevel->cbSurface, pMipLevel->pSurfaceData)); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r53755 r53756 45 45 46 46 void vmsvgaGMRFree(PVGASTATE pThis, uint32_t idGMR); 47 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType transfer, uint8_t *pDest, int32_t cbDestPitch, SVGAGuestPtr src, uint32_t cbSrcOffset, int32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight); 47 int vmsvgaGMRTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType, uint8_t *pDest, int32_t cbDestPitch, 48 SVGAGuestPtr src, uint32_t offSrc, int32_t cbSrcPitch, uint32_t cbWidth, uint32_t cHeight); 48 49 49 50 int vmsvga3dInit(PVGASTATE pThis);
Note:
See TracChangeset
for help on using the changeset viewer.