- Timestamp:
- Nov 25, 2019 11:18:42 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r82114 r82165 410 410 /** Height in blocks: (height + cyBlock - 1) / cyBlock. SSM: not saved, recalculated on load. */ 411 411 uint32_t cBlocksY; 412 /** Number of blocks: cBlocksX * cBlocksY * mipmapSize.depth. SSM: not saved, recalculated on load. */ 413 uint32_t cBlocks; 412 414 /** The scanline/pitch size in bytes: at least cBlocksX * cbBlock. */ 413 415 uint32_t cbSurfacePitch; … … 582 584 uint32_t cxBlock; /* Block width in pixels. SSM: not saved, recalculated on load. */ 583 585 uint32_t cyBlock; /* Block height in pixels. SSM: not saved, recalculated on load. */ 586 #ifdef VMSVGA3D_OPENGL 587 uint32_t cbBlockGL; /* Block size of the OpenGL texture, same as cbBlock for not-emulated formats. */ 588 #endif 584 589 585 590 /* Dirty state; surface was manually updated. */ … … 1056 1061 PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; 1057 1062 PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; 1063 PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage; 1058 1064 PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; 1059 1065 PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r82114 r82165 686 686 GLGETPROC_(PFNGLTEXIMAGE3DPROC , glTexImage3D, ""); 687 687 GLGETPROC_(PFNGLTEXSUBIMAGE3DPROC , glTexSubImage3D, ""); 688 GLGETPROC_(PFNGLGETCOMPRESSEDTEXIMAGEPROC , glGetCompressedTexImage, ""); 688 689 GLGETPROC_(PFNGLCOMPRESSEDTEXIMAGE2DPROC , glCompressedTexImage2D, ""); 689 690 GLGETPROC_(PFNGLCOMPRESSEDTEXIMAGE3DPROC , glCompressedTexImage3D, ""); … … 1645 1646 #define AssertTestFmt(f) do {} while(0) 1646 1647 #endif 1648 /* Init cbBlockGL for non-emulated formats. */ 1649 pSurface->cbBlockGL = pSurface->cbBlock; 1650 1647 1651 switch (format) 1648 1652 { … … 1939 1943 pSurface->formatGL = GL_BGRA; 1940 1944 pSurface->typeGL = GL_UNSIGNED_INT_8_8_8_8_REV; 1945 pSurface->cbBlockGL = 4 * pSurface->cxBlock * pSurface->cyBlock; 1941 1946 break; 1942 1947 … … 2127 2132 || pSurfaceDst->internalFormatGL == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) 2128 2133 { 2134 uint32_t const cBlocksX = (clipBox.w + pSurfaceSrc->cxBlock - 1) / pSurfaceSrc->cxBlock; 2135 uint32_t const cBlocksY = (clipBox.h + pSurfaceSrc->cyBlock - 1) / pSurfaceSrc->cyBlock; 2136 uint32_t const imageSize = cBlocksX * cBlocksY * clipBox.d * pSurfaceSrc->cbBlock; 2129 2137 pState->ext.glCompressedTexSubImage3D(target, dest.mipmap, 2130 2138 clipBox.x, clipBox.y, clipBox.z, 2131 2139 clipBox.w, clipBox.h, clipBox.d, 2132 pSurfaceSrc-> formatGL, pSurfaceSrc->typeGL, pSrcBits);2140 pSurfaceSrc->internalFormatGL, (GLsizei)imageSize, pSrcBits); 2133 2141 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2134 2142 } … … 2148 2156 || pSurfaceDst->internalFormatGL == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) 2149 2157 { 2158 uint32_t const cBlocksX = (clipBox.w + pSurfaceSrc->cxBlock - 1) / pSurfaceSrc->cxBlock; 2159 uint32_t const cBlocksY = (clipBox.h + pSurfaceSrc->cyBlock - 1) / pSurfaceSrc->cyBlock; 2160 uint32_t const imageSize = cBlocksX * cBlocksY * pSurfaceSrc->cbBlock; 2150 2161 pState->ext.glCompressedTexSubImage2D(target, dest.mipmap, 2151 2162 clipBox.x, clipBox.y, clipBox.w, clipBox.h, 2152 pSurfaceSrc-> formatGL, pSurfaceSrc->typeGL, pSrcBits);2163 pSurfaceSrc->internalFormatGL, (GLsizei)imageSize, pSrcBits); 2153 2164 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2154 2165 } … … 2847 2858 uint32_t cbSurfacePitch; 2848 2859 uint8_t *pDoubleBuffer; 2849 uint 32_t offHst;2860 uint64_t offHst; 2850 2861 2851 2862 uint32_t const u32HostBlockX = pBox->x / pSurface->cxBlock; 2852 2863 uint32_t const u32HostBlockY = pBox->y / pSurface->cyBlock; 2864 uint32_t const u32HostZ = pBox->z; 2853 2865 Assert(u32HostBlockX * pSurface->cxBlock == pBox->x); 2854 2866 Assert(u32HostBlockY * pSurface->cyBlock == pBox->y); … … 2856 2868 uint32_t const u32GuestBlockX = pBox->srcx / pSurface->cxBlock; 2857 2869 uint32_t const u32GuestBlockY = pBox->srcy / pSurface->cyBlock; 2870 uint32_t const u32GuestZ = pBox->srcz / pSurface->cyBlock; 2858 2871 Assert(u32GuestBlockX * pSurface->cxBlock == pBox->srcx); 2859 2872 Assert(u32GuestBlockY * pSurface->cyBlock == pBox->srcy); … … 2878 2891 } 2879 2892 2880 /* The buffer must be large enough to hold entire texture in the OpenGL format. 2881 * Multiply by the width and height "reduction" factors. 2882 * This can allocate more memory than required, but it is simpler for now. 2883 * Actually cbBuf = cbGLPixel * pMipmapLevel->mipmapSize.width * pMipmapLevel->mipmapSize.height 2884 */ 2885 pDoubleBuffer = (uint8_t *)RTMemAlloc(pMipLevel->cbSurface * pSurface->cxBlock * pSurface->cyBlock); 2893 /* The buffer must be large enough to hold entire texture in the OpenGL format. */ 2894 pDoubleBuffer = (uint8_t *)RTMemAlloc(pSurface->cbBlockGL * pMipLevel->cBlocks); 2886 2895 AssertReturn(pDoubleBuffer, VERR_NO_MEMORY); 2887 2896 2888 2897 if (transfer == SVGA3D_READ_HOST_VRAM) 2889 2898 { 2899 /* Read the entire texture to the double buffer. */ 2890 2900 GLint activeTexture; 2891 2901 … … 2906 2916 vmsvga3dOglSetPackParams(pState, pContext, pSurface, &SavedParams); 2907 2917 2908 glGetTexImage(texImageTarget, 2909 uHostMipmap, 2910 pSurface->formatGL, 2911 pSurface->typeGL, 2912 pDoubleBuffer); 2913 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2918 if ( pSurface->internalFormatGL == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 2919 || pSurface->internalFormatGL == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 2920 || pSurface->internalFormatGL == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) 2921 { 2922 pState->ext.glGetCompressedTexImage(texImageTarget, uHostMipmap, pDoubleBuffer); 2923 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2924 } 2925 else 2926 { 2927 glGetTexImage(texImageTarget, uHostMipmap, pSurface->formatGL, pSurface->typeGL, pDoubleBuffer); 2928 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2929 } 2914 2930 2915 2931 vmsvga3dOglRestorePackParams(pState, pContext, pSurface, &SavedParams); … … 2919 2935 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2920 2936 2921 offHst = u32HostBlockX * pSurface->cbBlock + u32HostBlockY * pMipLevel->cbSurfacePitch ;2937 offHst = u32HostBlockX * pSurface->cbBlock + u32HostBlockY * pMipLevel->cbSurfacePitch + u32HostZ * pMipLevel->cbSurfacePlane; 2922 2938 cbSurfacePitch = pMipLevel->cbSurfacePitch; 2923 2939 } … … 2929 2945 } 2930 2946 2931 uint32_t const offGst = u32GuestBlockX * pSurface->cbBlock + u32GuestBlockY * cbGuestPitch; 2932 2933 rc = vmsvgaR3GmrTransfer(pThis, 2934 pThisCC, 2935 transfer, 2936 pDoubleBuffer, 2937 pMipLevel->cbSurface, 2938 offHst, 2939 cbSurfacePitch, 2940 GuestPtr, 2941 offGst, 2942 cbGuestPitch, 2943 cBlocksX * pSurface->cbBlock, 2944 cBlocksY); 2945 AssertRC(rc); 2947 uint64_t offGst = u32GuestBlockX * pSurface->cbBlock + u32GuestBlockY * cbGuestPitch + u32GuestZ * cbGuestPitch * pMipLevel->mipmapSize.height; 2948 2949 for (uint32_t iPlane = 0; iPlane < pBox->d; ++iPlane) 2950 { 2951 AssertBreak(offHst < UINT32_MAX); 2952 AssertBreak(offGst < UINT32_MAX); 2953 2954 rc = vmsvgaR3GmrTransfer(pThis, 2955 pThisCC, 2956 transfer, 2957 pDoubleBuffer, 2958 pMipLevel->cbSurface, 2959 (uint32_t)offHst, 2960 cbSurfacePitch, 2961 GuestPtr, 2962 (uint32_t)offGst, 2963 cbGuestPitch, 2964 cBlocksX * pSurface->cbBlock, 2965 cBlocksY); 2966 AssertRC(rc); 2967 2968 offHst += pMipLevel->cbSurfacePlane; 2969 offGst += pMipLevel->mipmapSize.height * cbGuestPitch; 2970 } 2946 2971 2947 2972 /* Update the opengl surface data. */ … … 2977 3002 pBox->h, 2978 3003 pBox->d, 2979 pSurface-> formatGL,2980 pSurface->typeGL,3004 pSurface->internalFormatGL, 3005 cbSurfacePitch * cBlocksY * pBox->d, 2981 3006 pDoubleBuffer); 2982 3007 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r82114 r82165 314 314 pMipmapLevel->cBlocksX = cBlocksX; 315 315 pMipmapLevel->cBlocksY = cBlocksY; 316 pMipmapLevel->cBlocks = cBlocksX * cBlocksY * pMipmapLevel->mipmapSize.depth; 316 317 pMipmapLevel->cbSurfacePitch = cbSurfacePitch; 317 318 pMipmapLevel->cbSurfacePlane = cbSurfacePlane;
Note:
See TracChangeset
for help on using the changeset viewer.