Changeset 81755 in vbox
- Timestamp:
- Nov 10, 2019 7:19:50 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134543
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r81754 r81755 9 9 * - Log3 for hex dump of shader code. 10 10 * - Log4 for hex dumps of 3D data. 11 * - Log5 for info about GMR pages.12 11 */ 13 12 … … 3934 3933 break; 3935 3934 3936 /** @todo Move to a separate function vmsvgaGMRRemap() */3937 3938 3935 /* Calc new total page count so we can use it instead of cMaxPages for allocations below. */ 3939 3936 uint32_t const cNewTotalPages = RT_MAX(pGMR->cbTotal >> X86_PAGE_SHIFT, pCmd->offsetPages + pCmd->numPages); … … 4024 4021 Assert(paDescs[iDescriptor].numPages); 4025 4022 paDescs[iDescriptor].numPages++; 4026 Log 5Func(("Page %x GCPhys=%RGp successor\n", i, GCPhys));4023 LogFlow(("Page %x GCPhys=%RGp successor\n", i, GCPhys)); 4027 4024 } 4028 4025 else … … 4031 4028 paDescs[iDescriptor].GCPhys = GCPhys; 4032 4029 paDescs[iDescriptor].numPages = 1; 4033 Log 5Func(("Page %x GCPhys=%RGp\n", i, paDescs[iDescriptor].GCPhys));4030 LogFlow(("Page %x GCPhys=%RGp\n", i, paDescs[iDescriptor].GCPhys)); 4034 4031 } 4035 4032 } 4036 4033 4037 4034 pGMR->cbTotal = cNewTotalPages << X86_PAGE_SHIFT; 4038 Log 5Func(("Nr of descriptors %x; cbTotal=%#x\n", iDescriptor + 1, cNewTotalPages));4035 LogFlow(("Nr of descriptors %x; cbTotal=%#x\n", iDescriptor + 1, cNewTotalPages)); 4039 4036 pGMR->numDescriptors = iDescriptor + 1; 4040 4037 } … … 5044 5041 RTGCPHYS const GCPhys = paDesc[iDesc].GCPhys + offGmrCurrent - offDesc; 5045 5042 5046 Log 5Func(("%s phys=%RGp\n", (enmTransferType == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", GCPhys));5043 LogFlowFunc(("%s phys=%RGp\n", (enmTransferType == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", GCPhys)); 5047 5044 5048 5045 if (enmTransferType == SVGA3D_WRITE_HOST_VRAM) -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r81754 r81755 357 357 * release builds. 358 358 */ 359 /** @todo Rename to VMSVGA3D_CHECK_LAST_ERROR_RETURN */360 359 # ifdef VBOX_STRICT 361 360 # define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { \ … … 562 561 GLenum targetGL; /* GL_TEXTURE_* */ 563 562 GLenum bindingGL; /* GL_TEXTURE_BINDING_* */ 564 /* Emulated formats */565 bool fEmulated; /* Whether the texture format is emulated. */566 GLuint idEmulated; /* GL name of the intermediate texture. */567 563 #endif 568 564 SVGA3dSurfaceFace faces[SVGA3D_MAX_SURFACE_FACES]; … … 944 940 945 941 946 #ifdef VMSVGA3D_OPENGL947 typedef struct VMSVGA3DFORMATCONVERTOR *PVMSVGA3DFORMATCONVERTOR;948 #endif949 950 942 /** 951 943 * VMSVGA3d state data. … … 1060 1052 PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; 1061 1053 PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; 1062 PFNGLDRAWBUFFERSPROC glDrawBuffers;1063 PFNGLCREATESHADERPROC glCreateShader;1064 PFNGLSHADERSOURCEPROC glShaderSource;1065 PFNGLCOMPILESHADERPROC glCompileShader;1066 PFNGLGETSHADERIVPROC glGetShaderiv;1067 PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;1068 PFNGLCREATEPROGRAMPROC glCreateProgram;1069 PFNGLATTACHSHADERPROC glAttachShader;1070 PFNGLLINKPROGRAMPROC glLinkProgram;1071 PFNGLGETPROGRAMIVPROC glGetProgramiv;1072 PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;1073 PFNGLUSEPROGRAMPROC glUseProgram;1074 PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;1075 PFNGLUNIFORM1IPROC glUniform1i;1076 PFNGLUNIFORM4FVPROC glUniform4fv;1077 PFNGLDETACHSHADERPROC glDetachShader;1078 PFNGLDELETESHADERPROC glDeleteShader;1079 PFNGLDELETEPROGRAMPROC glDeleteProgram;1080 1054 } ext; 1081 1055 … … 1118 1092 /** The shared context. */ 1119 1093 VMSVGA3DCONTEXT SharedCtx; 1120 1121 /** Conversion of emulated formats. Resources are created on the SharedCtx. */1122 PVMSVGA3DFORMATCONVERTOR pConv;1123 1094 # endif 1124 1095 #endif /* VMSVGA3D_OPENGL */ … … 1334 1305 #endif 1335 1306 1336 #ifdef VMSVGA3D_OPENGL1337 void vmsvga3dOnSharedContextDefine(PVMSVGA3DSTATE pState);1338 void vmsvga3dOnSharedContextDestroy(PVMSVGA3DSTATE pState);1339 1340 DECLINLINE(GLuint) GLTextureId(PVMSVGA3DSURFACE pSurface)1341 {1342 return pSurface->fEmulated ? pSurface->idEmulated : pSurface->oglId.texture;1343 }1344 1345 void FormatConvUpdateTexture(PVMSVGA3DSTATE pState,1346 PVMSVGA3DCONTEXT pCurrentContext,1347 PVMSVGA3DSURFACE pSurface,1348 uint32_t iMipmap);1349 void FormatConvReadTexture(PVMSVGA3DSTATE pState,1350 PVMSVGA3DCONTEXT pCurrentContext,1351 PVMSVGA3DSURFACE pSurface,1352 uint32_t iMipmap);1353 #endif1354 1355 1307 #endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_internal_h */ 1356 1308 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r81754 r81755 714 714 GLGETPROC_(PFNGLCLIENTACTIVETEXTUREPROC , glClientActiveTexture, ""); 715 715 #endif 716 GLGETPROC_(PFNGLDRAWBUFFERSPROC , glDrawBuffers, "");717 GLGETPROC_(PFNGLCREATESHADERPROC , glCreateShader, "");718 GLGETPROC_(PFNGLSHADERSOURCEPROC , glShaderSource, "");719 GLGETPROC_(PFNGLCOMPILESHADERPROC , glCompileShader, "");720 GLGETPROC_(PFNGLGETSHADERIVPROC , glGetShaderiv, "");721 GLGETPROC_(PFNGLGETSHADERINFOLOGPROC , glGetShaderInfoLog, "");722 GLGETPROC_(PFNGLCREATEPROGRAMPROC , glCreateProgram, "");723 GLGETPROC_(PFNGLATTACHSHADERPROC , glAttachShader, "");724 GLGETPROC_(PFNGLLINKPROGRAMPROC , glLinkProgram, "");725 GLGETPROC_(PFNGLGETPROGRAMIVPROC , glGetProgramiv, "");726 GLGETPROC_(PFNGLGETPROGRAMINFOLOGPROC , glGetProgramInfoLog, "");727 GLGETPROC_(PFNGLUSEPROGRAMPROC , glUseProgram, "");728 GLGETPROC_(PFNGLGETUNIFORMLOCATIONPROC , glGetUniformLocation, "");729 GLGETPROC_(PFNGLUNIFORM1IPROC , glUniform1i, "");730 GLGETPROC_(PFNGLUNIFORM4FVPROC , glUniform4fv, "");731 GLGETPROC_(PFNGLDETACHSHADERPROC , glDetachShader, "");732 GLGETPROC_(PFNGLDELETESHADERPROC , glDeleteShader, "");733 GLGETPROC_(PFNGLDELETEPROGRAMPROC , glDeleteProgram, "");734 716 735 717 /* OpenGL 3.0 core, GL_ARB_instanced_arrays. Same functions names in the ARB and core specs. */ … … 1329 1311 case SVGA3D_DEVCAP_SURFACEFMT_UYVY: 1330 1312 case SVGA3D_DEVCAP_SURFACEFMT_YUY2: 1331 result |= SVGA3DFORMAT_OP_OFFSCREENPLAIN1332 | SVGA3DFORMAT_OP_CONVERT_TO_ARGB1333 | SVGA3DFORMAT_OP_TEXTURE;1334 break;1335 1336 1313 case SVGA3D_DEVCAP_SURFACEFMT_NV12: 1337 1314 case SVGA3D_DEVCAP_SURFACEFMT_AYUV: … … 1922 1899 break; 1923 1900 1901 #if 0 1924 1902 /* Packed Video formats */ 1925 1903 case SVGA3D_UYVY: 1904 return D3DFMT_UYVY; 1926 1905 case SVGA3D_YUY2: 1927 /* Use a BRGA texture to hold the data and convert it to an actual BGRA. */ 1928 pSurface->fEmulated = true; 1929 pSurface->internalFormatGL = GL_RGBA8; 1930 pSurface->formatGL = GL_BGRA; 1931 pSurface->typeGL = GL_UNSIGNED_INT_8_8_8_8_REV; 1932 break; 1933 1934 #if 0 1906 return D3DFMT_YUY2; 1907 1935 1908 /* Planar video formats */ 1936 1909 case SVGA3D_NV12: … … 1994 1967 glDeleteTextures(1, &pSurface->oglId.texture); 1995 1968 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 1996 if (pSurface->fEmulated)1997 {1998 if (pSurface->idEmulated)1999 {2000 glDeleteTextures(1, &pSurface->idEmulated);2001 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);2002 }2003 }2004 else2005 {2006 Assert(!pSurface->idEmulated);2007 }2008 1969 break; 2009 1970 … … 2214 2175 glGenTextures(1, &pSurface->oglId.texture); 2215 2176 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 2216 if (pSurface->fEmulated)2217 {2218 glGenTextures(1, &pSurface->idEmulated);2219 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);2220 }2221 2177 pSurface->enmOGLResType = VMSVGA3D_OGLRESTYPE_TEXTURE; 2222 2178 … … 2365 2321 else 2366 2322 { 2367 /* Initialize the texture. */2368 2323 glTexImage2D(GL_TEXTURE_2D, 2369 2324 i, … … 2374 2329 pSurface->formatGL, 2375 2330 pSurface->typeGL, 2376 NULL); 2377 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2378 2379 /* Fetch texture data. The pSurfaceData buffer may be smaller than the entire texture 2380 * for emulated formats, in which case only part of the texture is synched. 2381 */ 2382 uint32_t cBlocksX = pMipLevel->mipmapSize.width / pSurface->cxBlock; 2383 uint32_t cBlocksY = pMipLevel->mipmapSize.height / pSurface->cyBlock; 2384 glTexSubImage2D(GL_TEXTURE_2D, 2385 i, 2386 0, 2387 0, 2388 cBlocksX, 2389 cBlocksY, 2390 pSurface->formatGL, 2391 pSurface->typeGL, 2392 pMipLevel->pSurfaceData); 2393 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2394 2395 if (pSurface->fEmulated) 2396 { 2397 /** @todo Update texture yusing the format converter. */ 2398 glBindTexture(GL_TEXTURE_2D, pSurface->idEmulated); 2399 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2400 2401 glTexImage2D(GL_TEXTURE_2D, 2402 i, 2403 pSurface->internalFormatGL, 2404 pMipLevel->mipmapSize.width, 2405 pMipLevel->mipmapSize.height, 2406 0, 2407 pSurface->formatGL, 2408 pSurface->typeGL, 2409 NULL); 2410 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2411 2412 glBindTexture(GL_TEXTURE_2D, pSurface->oglId.texture); 2413 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2414 } 2331 pMipLevel->pSurfaceData); 2415 2332 } 2416 VMSVGA3D_CHECK_LAST_ERROR _WARN(pState, pContext);2333 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 2417 2334 2418 2335 pMipLevel->fDirty = false; … … 2547 2464 */ 2548 2465 pSave->iAlignment = 1; 2549 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_ PACK_ALIGNMENT, &pSave->iAlignment), pState, pContext);2466 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &pSave->iAlignment), pState, pContext); 2550 2467 pSave->cxRow = 0; 2551 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_ PACK_ROW_LENGTH, &pSave->cxRow), pState, pContext);2468 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &pSave->cxRow), pState, pContext); 2552 2469 2553 2470 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING … … 2665 2582 RT_NOREF(iBox); 2666 2583 2667 switch (pSurface->enmOGLResType) 2668 { 2669 case VMSVGA3D_OGLRESTYPE_TEXTURE: 2584 switch (pSurface->surfaceFlags & VMSVGA3D_SURFACE_HINT_SWITCH_MASK) 2585 { 2586 case SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_DEPTHSTENCIL: 2587 case SVGA3D_SURFACE_HINT_DEPTHSTENCIL: 2588 case SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_HINT_TEXTURE: 2589 case SVGA3D_SURFACE_CUBEMAP | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET: 2590 case SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET: 2591 case SVGA3D_SURFACE_HINT_TEXTURE: 2592 case SVGA3D_SURFACE_HINT_RENDERTARGET: 2670 2593 { 2671 2594 uint32_t cbSurfacePitch; … … 2702 2625 } 2703 2626 2704 /* The buffer must be large enough to hold entire texture in the OpenGL format. 2705 * Multiply by the width and height "reduction" factors. 2706 * This can allocate more memory than required, but it is simpler for now. 2707 * Actually cbBuf = cbGLPixel * pMipmapLevel->mipmapSize.width * pMipmapLevel->mipmapSize.height 2708 */ 2709 pDoubleBuffer = (uint8_t *)RTMemAlloc(pMipLevel->cbSurface * pSurface->cxBlock * pSurface->cyBlock); 2627 pDoubleBuffer = (uint8_t *)RTMemAlloc(pMipLevel->cbSurface); 2710 2628 AssertReturn(pDoubleBuffer, VERR_NO_MEMORY); 2711 2629 … … 2718 2636 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2719 2637 2720 glBindTexture(pSurface->targetGL, GLTextureId(pSurface));2638 glBindTexture(pSurface->targetGL, pSurface->oglId.texture); 2721 2639 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2722 2723 if (pSurface->fEmulated)2724 {2725 FormatConvReadTexture(pState, pContext, pSurface, uHostMipmap);2726 }2727 2640 2728 2641 /* Set row length and alignment of the input data. */ … … 2776 2689 2777 2690 /* Must bind texture to the current context in order to change it. */ 2778 glBindTexture(pSurface->targetGL, GLTextureId(pSurface));2691 glBindTexture(pSurface->targetGL, pSurface->oglId.texture); 2779 2692 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 2780 2693 … … 2845 2758 pSurface->typeGL, 2846 2759 pDoubleBuffer); 2847 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);2848 2849 if (pSurface->fEmulated)2850 {2851 /* Convert the texture to the actual texture if necessary */2852 FormatConvUpdateTexture(pState, pContext, pSurface, uHostMipmap);2853 }2854 2760 } 2855 2761 } … … 2871 2777 } 2872 2778 2873 case VMSVGA3D_OGLRESTYPE_BUFFER: 2779 case SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_INDEXBUFFER: 2780 case SVGA3D_SURFACE_HINT_VERTEXBUFFER: 2781 case SVGA3D_SURFACE_HINT_INDEXBUFFER: 2874 2782 { 2875 2783 /* Buffers are uncompressed. */ … … 3087 2995 rc = vmsvga3dContextDefineOgl(pThis, VMSVGA3D_SHARED_CTX_ID, VMSVGA3D_DEF_CTX_F_SHARED_CTX); 3088 2996 AssertLogRelRCReturn(rc, rc); 3089 3090 /* Create resources which use the shared context. */3091 vmsvga3dOnSharedContextDefine(pState);3092 2997 } 3093 2998 } … … 3291 3196 3292 3197 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3293 3294 if (pContext->id == VMSVGA3D_SHARED_CTX_ID)3295 {3296 /* Delete resources which use the shared context. */3297 vmsvga3dOnSharedContextDestroy(pState);3298 }3299 3198 3300 3199 /* Destroy all leftover pixel shaders. */ … … 6316 6215 { 6317 6216 /* Render without an index buffer */ 6318 Log(("DrawPrimitive % d cPrimitives=%d cVertices=%d index index bias=%d cInstances=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pRange[iPrimitive].indexBias, cInstances));6217 Log(("DrawPrimitive %x cPrimitives=%d cVertices=%d index index bias=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pRange[iPrimitive].indexBias)); 6319 6218 if (cInstances == 0) 6320 6219 { … … 6341 6240 } 6342 6241 6343 Log(("DrawIndexedPrimitive % d cPrimitives=%d cVertices=%d hint.first=%d hint.last=%d index offset=%d primitivecount=%d index width=%d index bias=%d cInstances=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pVertexDecl[0].rangeHint.first, pVertexDecl[0].rangeHint.last, pRange[iPrimitive].indexArray.offset, pRange[iPrimitive].primitiveCount, pRange[iPrimitive].indexWidth, pRange[iPrimitive].indexBias, cInstances));6242 Log(("DrawIndexedPrimitive %x cPrimitives=%d cVertices=%d hint.first=%d hint.last=%d index offset=%d primitivecount=%d index width=%d index bias=%d\n", modeDraw, pRange[iPrimitive].primitiveCount, cVertices, pVertexDecl[0].rangeHint.first, pVertexDecl[0].rangeHint.last, pRange[iPrimitive].indexArray.offset, pRange[iPrimitive].primitiveCount, pRange[iPrimitive].indexWidth, pRange[iPrimitive].indexBias)); 6344 6243 if (cInstances == 0) 6345 6244 { … … 6451 6350 int rc2 = vmsvga3dSurfaceFromSid(pState, pContext->state.aRenderTargets[SVGA3D_RT_COLOR0], &pSurface); 6452 6351 if (RT_SUCCESS(rc2)) 6453 vmsvga3dInfoSurfaceToBitmap(NULL, pSurface, "bmp gl", "rt", "-post");6352 vmsvga3dInfoSurfaceToBitmap(NULL, pSurface, "bmp", "rt", "-post"); 6454 6353 } 6455 6354 #endif -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.cpp
r81754 r81755 396 396 397 397 case SVGA3D_UYVY: 398 *pcxBlock = 2;399 *pcyBlock = 1; 400 return 4;398 *pcxBlock = 1; 399 *pcyBlock = 1; 400 return 2; 401 401 402 402 case SVGA3D_YUY2: 403 *pcxBlock = 2;404 *pcyBlock = 1; 405 return 4;403 *pcxBlock = 1; 404 *pcyBlock = 1; 405 return 2; 406 406 407 407 case SVGA3D_V16U16: -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r81754 r81755 248 248 /* pSurface->emulated.pTexture = NULL; */ 249 249 #else 250 /* pSurface->fEmulated = false; */251 pSurface->idEmulated = OPENGL_INVALID_ID;252 250 vmsvga3dSurfaceFormat2OGL(pSurface, format); 253 251 #endif
Note:
See TracChangeset
for help on using the changeset viewer.