Changeset 54659 in vbox
- Timestamp:
- Mar 5, 2015 9:32:14 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98807
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r54641 r54659 2930 2930 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 2931 2931 2932 rc = vmsvga3dContextDefine(pThis, pCmd->cid , false /*fOtherProfile*/);2932 rc = vmsvga3dContextDefine(pThis, pCmd->cid); 2933 2933 break; 2934 2934 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r54658 r54659 91 91 92 92 93 /* Generated by VBoxDef2LazyLoad from the VBoxSVGA3D.def and VBoxSVGA3DObjC.def files. */94 extern "C" int ExplicitlyLoadVBoxSVGA3D(bool fResolveAllImports, PRTERRINFO pErrInfo);95 #ifdef RT_OS_DARWIN96 extern "C" int ExplicitlyLoadVBoxSVGA3DObjC(bool fResolveAllImports, PRTERRINFO pErrInfo);97 #endif98 99 100 93 /******************************************************************************* 101 94 * Defined Constants And Macros * 102 95 *******************************************************************************/ 96 /** Experimental: Create a dedicated context for handling surfaces in, thus 97 * avoiding orphaned surfaces after context destruction. 98 * 99 * This cures, for instance, an assertion on fedora 21 that happens in 100 * vmsvga3dSurfaceStretchBlt if the login screen and the desktop has different 101 * sizes. The context of the login screen seems to have just been destroyed 102 * earlier and I believe the driver/X/whoever is attemting to strech the old 103 * screen content onto the new sized screen. 104 * 105 * @remarks This probably comes at a slight preformance expense, as we currently 106 * switches context when setting up the surface the first time. Not sure 107 * if we really need to, but as this is an experiment, I'm playing it safe. 108 */ 109 #define VMSVGA3D_OGL_WITH_SHARED_CTX 110 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 111 /** Fake surface ID for the shared context. */ 112 # define VMSVGA3D_SHARED_CTX_ID UINT32_C(0xffffeeee) 113 #endif 114 103 115 /** @def VBOX_VMSVGA3D_GL_HACK_LEVEL 104 116 * Turns out that on Linux gl.h may often define the first 2-4 OpenGL versions … … 146 158 //#define DEBUG_GFX_WINDOW 147 159 160 161 /** @name VMSVGA3D_DEF_CTX_F_XXX - vmsvga3dContextDefineOgl flags. 162 * @{ */ 163 /** When clear, the context is created using the default OpenGL profile. 164 * When set, it's created using the alternative profile. The latter is only 165 * allowed if the VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE is set. */ 166 #define VMSVGA3D_DEF_CTX_F_OTHER_PROFILE RT_BIT_32(0) 167 /** Defining the shared context. */ 168 #define VMSVGA3D_DEF_CTX_F_SHARED_CTX RT_BIT_32(1) 169 /** Defining the init time context (EMT). */ 170 #define VMSVGA3D_DEF_CTX_F_INIT RT_BIT_32(2) 171 /** @} */ 172 173 148 174 #define VMSVGA3D_CLEAR_CURRENT_CONTEXT(pState) \ 149 175 do { (pState)->idActiveContext = OPENGL_INVALID_ID; } while (0) … … 156 182 #ifdef RT_OS_WINDOWS 157 183 # define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \ 158 if ((pState)->idActiveContext != pContext->id) \184 if ((pState)->idActiveContext != (pContext)->id) \ 159 185 { \ 160 186 BOOL fMakeCurrentRc = wglMakeCurrent((pContext)->hdc, (pContext)->hglrc); \ … … 470 496 { 471 497 uint32_t id; 498 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 499 uint32_t idAssociatedContextUnused; 500 #else 472 501 uint32_t idAssociatedContext; 502 #endif 473 503 uint32_t flags; 474 504 SVGA3dSurfaceFormat format; … … 498 528 { 499 529 SSMFIELD_ENTRY( VMSVGA3DSURFACE, id), 530 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 531 SSMFIELD_ENTRY( VMSVGA3DSURFACE, idAssociatedContextUnused), 532 #else 500 533 SSMFIELD_ENTRY( VMSVGA3DSURFACE, idAssociatedContext), 534 #endif 501 535 SSMFIELD_ENTRY( VMSVGA3DSURFACE, flags), 502 536 SSMFIELD_ENTRY( VMSVGA3DSURFACE, format), … … 826 860 /** Shader talk back interface. */ 827 861 VBOXVMSVGASHADERIF ShaderIf; 862 863 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 864 /** The shared context. */ 865 VMSVGA3DCONTEXT SharedCtx; 866 #endif 828 867 } VMSVGA3DSTATE; 829 868 /** Pointer to the VMSVGA3d state. */ … … 909 948 * Internal Functions * 910 949 *******************************************************************************/ 911 RT_C_DECLS_BEGIN 912 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface);950 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface); 951 static int vmsvga3dContextDefineOgl(PVGASTATE pThis, uint32_t cid, uint32_t fFlags); 913 952 static void vmsvgaColor2GLFloatArray(uint32_t color, GLfloat *pRed, GLfloat *pGreen, GLfloat *pBlue, GLfloat *pAlpha); 914 RT_C_DECLS_END 953 954 /* Generated by VBoxDef2LazyLoad from the VBoxSVGA3D.def and VBoxSVGA3DObjC.def files. */ 955 extern "C" int ExplicitlyLoadVBoxSVGA3D(bool fResolveAllImports, PRTERRINFO pErrInfo); 956 #ifdef RT_OS_DARWIN 957 extern "C" int ExplicitlyLoadVBoxSVGA3DObjC(bool fResolveAllImports, PRTERRINFO pErrInfo); 958 #endif 915 959 916 960 … … 1386 1430 * OpenGL function calls aren't possible without a valid current context, so create a fake one here. 1387 1431 */ 1388 rc = vmsvga3dContextDefine (pThis, 1, false /*fOtherProfile*/);1432 rc = vmsvga3dContextDefineOgl(pThis, 1, VMSVGA3D_DEF_CTX_F_INIT); 1389 1433 AssertRCReturn(rc, rc); 1390 1434 … … 1411 1455 * figure out the shader model and stuff. 1412 1456 */ 1413 rc = vmsvga3dContextDefine (pThis, 2, true /*fOtherProfile*/);1457 rc = vmsvga3dContextDefineOgl(pThis, 2, VMSVGA3D_DEF_CTX_F_INIT | VMSVGA3D_DEF_CTX_F_OTHER_PROFILE); 1414 1458 AssertLogRelRCReturn(rc, rc); 1415 1459 pContext = &pState->paContext[1]; /* Array may have been reallocated. */ … … 2587 2631 memset(pSurface, 0, sizeof(*pSurface)); 2588 2632 pSurface->id = sid; 2633 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 2634 pSurface->idAssociatedContextUnused = SVGA3D_INVALID_ID; 2635 #else 2589 2636 pSurface->idAssociatedContext = SVGA3D_INVALID_ID; 2637 #endif 2590 2638 vmsvga3dSurfaceFormat2OGL(pSurface, format); 2591 2639 … … 2767 2815 #endif 2768 2816 2817 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 2818 pContext = &pState->SharedCtx; 2819 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 2820 #else 2769 2821 /* @todo stricter checks for associated context */ 2770 2822 uint32_t cid = pSurface->idAssociatedContext; … … 2790 2842 AssertReturn(pContext, VERR_INTERNAL_ERROR); /* otherwise crashes/fails; create temp context if this ever triggers! */ 2791 2843 } 2844 #endif 2792 2845 2793 2846 switch (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP)) … … 3004 3057 { 3005 3058 GLint activeTexture = 0; 3059 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3060 uint32_t idPrevCtx = pState->idActiveContext; 3061 pContext = &pState->SharedCtx; 3062 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3063 #endif 3006 3064 3007 3065 glGenTextures(1, &pSurface->oglId.texture); … … 3068 3126 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 3069 3127 3128 pSurface->flags |= SVGA3D_SURFACE_HINT_TEXTURE; 3129 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 3070 3130 LogFlow(("vmsvga3dCreateTexture: sid=%x idAssociatedContext %#x -> %#x; oglId.texture=%#x\n", 3071 3131 pSurface->id, pSurface->idAssociatedContext, idAssociatedContext, pSurface->oglId.texture)); 3072 pSurface->flags |= SVGA3D_SURFACE_HINT_TEXTURE;3073 3132 pSurface->idAssociatedContext = idAssociatedContext; 3133 #endif 3134 3135 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3136 if (idPrevCtx < pState->cContexts && pState->paContext[idPrevCtx].id == idPrevCtx) 3137 VMSVGA3D_SET_CURRENT_CONTEXT(pState, &pState->paContext[idPrevCtx]); 3138 #endif 3074 3139 return VINF_SUCCESS; 3075 3140 } … … 3098 3163 AssertReturn(pSurfaceDest->faces[0].numMipLevels > dest.mipmap, VERR_INVALID_PARAMETER); 3099 3164 3165 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3166 Log(("vmsvga3dSurfaceStretchBlt: src sid=%x (%d,%d)(%d,%d) dest sid=%x (%d,%d)(%d,%d) mode=%x\n", 3167 src.sid, srcBox.x, srcBox.y, srcBox.x + srcBox.w, srcBox.y + srcBox.h, 3168 dest.sid, destBox.x, destBox.y, destBox.x + destBox.w, destBox.y + destBox.h, mode)); 3169 cid = SVGA3D_INVALID_ID; 3170 pContext = &pState->SharedCtx; 3171 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3172 #else 3100 3173 Log(("vmsvga3dSurfaceStretchBlt: src sid=%x cid=%x (%d,%d)(%d,%d) dest sid=%x cid=%x (%d,%d)(%d,%d) mode=%x\n", 3101 3174 src.sid, pSurfaceSrc->idAssociatedContext, srcBox.x, srcBox.y, srcBox.x + srcBox.w, srcBox.y + srcBox.h, … … 3115 3188 pContext = &pState->paContext[cid]; 3116 3189 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3190 #endif 3117 3191 3118 3192 if (pSurfaceSrc->oglId.texture == OPENGL_INVALID_ID) … … 3381 3455 else 3382 3456 { 3457 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3458 PVMSVGA3DCONTEXT pContext = &pState->SharedCtx; 3459 #else 3383 3460 /* @todo stricter checks for associated context */ 3384 3461 uint32_t cid = pSurface->idAssociatedContext; … … 3390 3467 } 3391 3468 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid]; 3469 #endif 3392 3470 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3393 3471 … … 3713 3791 3714 3792 pSurface = &pState->paSurface[sid]; 3793 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 3715 3794 AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR); 3795 #endif 3716 3796 3717 3797 Assert(filter != SVGA3D_TEX_FILTER_FLATCUBIC); … … 3721 3801 Log(("vmsvga3dGenerateMipmaps: sid=%x filter=%d\n", sid, filter)); 3722 3802 3803 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3804 cid = SVGA3D_INVALID_ID; 3805 pContext = &pState->SharedCtx; 3806 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3807 #else 3723 3808 /* @todo stricter checks for associated context */ 3724 3809 cid = pSurface->idAssociatedContext; … … 3732 3817 pContext = &pState->paContext[cid]; 3733 3818 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3819 #endif 3734 3820 3735 3821 if (pSurface->oglId.texture == OPENGL_INVALID_ID) … … 3784 3870 3785 3871 pSurface = &pState->paSurface[sid]; 3872 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 3786 3873 AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR); 3787 3874 #endif 3875 3876 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3877 /* @todo stricter checks for associated context */ 3878 Log(("vmsvga3dCommandPresent: sid=%x cRects=%d\n", sid, cRects)); 3879 for (uint32_t i=0; i < cRects; i++) 3880 Log(("vmsvga3dCommandPresent: rectangle %d src=(%d,%d) (%d,%d)(%d,%d)\n", i, pRect[i].srcx, pRect[i].srcy, pRect[i].x, pRect[i].y, pRect[i].x + pRect[i].w, pRect[i].y + pRect[i].h)); 3881 3882 cid = SVGA3D_INVALID_ID; 3883 pContext = &pState->SharedCtx; 3884 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3885 #else 3788 3886 /* @todo stricter checks for associated context */ 3789 3887 cid = pSurface->idAssociatedContext; … … 3802 3900 pContext = &pState->paContext[cid]; 3803 3901 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3902 #endif 3804 3903 3805 3904 /* Source surface different size? */ … … 4083 4182 * @param pThis VGA device instance data. 4084 4183 * @param cid Context id 4085 * @param fOtherProfile When clear, the context is created using the default 4086 * OpenGL profile. When set, it's created using the 4087 * alternative profile. The latter is only allowed if 4088 * the VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE is set. 4184 * @param fFlags VMSVGA3D_DEF_CTX_F_XXX. 4089 4185 */ 4090 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid, bool fOtherProfile)4186 static int vmsvga3dContextDefineOgl(PVGASTATE pThis, uint32_t cid, uint32_t fFlags) 4091 4187 { 4092 4188 int rc; … … 4095 4191 4096 4192 AssertReturn(pState, VERR_NO_MEMORY); 4193 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 4194 AssertReturn( cid < SVGA3D_MAX_CONTEXT_IDS 4195 || (cid == VMSVGA3D_SHARED_CTX_ID && (fFlags & VMSVGA3D_DEF_CTX_F_SHARED_CTX)), VERR_INVALID_PARAMETER); 4196 #else 4097 4197 AssertReturn(cid < SVGA3D_MAX_CONTEXT_IDS, VERR_INVALID_PARAMETER); 4198 #endif 4098 4199 #if !defined(VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE) || !(defined(RT_OS_DARWIN)) 4099 AssertReturn(! fOtherProfile, VERR_INTERNAL_ERROR_3);4200 AssertReturn(!(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE), VERR_INTERNAL_ERROR_3); 4100 4201 #endif 4101 4202 … … 4105 4206 { 4106 4207 pState->idTestContext = 207; 4107 rc = vmsvga3dContextDefine(pThis, pState->idTestContext , false /*fOtherProfile*/);4208 rc = vmsvga3dContextDefine(pThis, pState->idTestContext); 4108 4209 AssertRCReturn(rc, rc); 4109 4210 } 4110 4211 #endif 4111 4212 4112 if (cid >= pState->cContexts) 4113 { 4114 pState->paContext = (PVMSVGA3DCONTEXT)RTMemRealloc(pState->paContext, sizeof(VMSVGA3DCONTEXT) * (cid + 1)); 4115 AssertReturn(pState->paContext, VERR_NO_MEMORY); 4116 memset(&pState->paContext[pState->cContexts], 0, sizeof(VMSVGA3DCONTEXT) * (cid + 1 - pState->cContexts)); 4117 for (uint32_t i = pState->cContexts; i < cid + 1; i++) 4118 pState->paContext[i].id = SVGA3D_INVALID_ID; 4119 4120 pState->cContexts = cid + 1; 4121 } 4122 /* If one already exists with this id, then destroy it now. */ 4123 if (pState->paContext[cid].id != SVGA3D_INVALID_ID) 4124 vmsvga3dContextDestroy(pThis, cid); 4125 4126 pContext = &pState->paContext[cid]; 4213 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 4214 if (cid == VMSVGA3D_SHARED_CTX_ID) 4215 pContext = &pState->SharedCtx; 4216 else 4217 #endif 4218 { 4219 if (cid >= pState->cContexts) 4220 { 4221 pState->paContext = (PVMSVGA3DCONTEXT)RTMemRealloc(pState->paContext, sizeof(VMSVGA3DCONTEXT) * (cid + 1)); 4222 AssertReturn(pState->paContext, VERR_NO_MEMORY); 4223 memset(&pState->paContext[pState->cContexts], 0, sizeof(VMSVGA3DCONTEXT) * (cid + 1 - pState->cContexts)); 4224 for (uint32_t i = pState->cContexts; i < cid + 1; i++) 4225 pState->paContext[i].id = SVGA3D_INVALID_ID; 4226 4227 pState->cContexts = cid + 1; 4228 } 4229 /* If one already exists with this id, then destroy it now. */ 4230 if (pState->paContext[cid].id != SVGA3D_INVALID_ID) 4231 vmsvga3dContextDestroy(pThis, cid); 4232 4233 pContext = &pState->paContext[cid]; 4234 } 4235 4236 /* 4237 * Find the shared context (necessary for sharing e.g. textures between contexts). 4238 */ 4239 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 4240 PVMSVGA3DCONTEXT pSharedCtx = NULL; 4241 if (!(fFlags & (VMSVGA3D_DEF_CTX_F_INIT | VMSVGA3D_DEF_CTX_F_SHARED_CTX))) 4242 { 4243 pSharedCtx = &pState->SharedCtx; 4244 if (pSharedCtx->id != VMSVGA3D_SHARED_CTX_ID) 4245 { 4246 rc = vmsvga3dContextDefineOgl(pThis, VMSVGA3D_SHARED_CTX_ID, VMSVGA3D_DEF_CTX_F_SHARED_CTX); 4247 AssertLogRelRCReturn(rc, rc); 4248 } 4249 } 4250 #else 4251 // TODO isn't this default on Linux since OpenGL 1.1? 4252 /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */ 4253 PVMSVGA3DCONTEXT pSharedCtx = NULL; 4254 for (uint32_t i = 0; i < pState->cContexts; i++) 4255 if ( pState->paContext[i].id != SVGA3D_INVALID_ID 4256 && i != cid 4257 # ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE 4258 && pState->paContext[i].fOtherProfile == RT_BOOL(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE) 4259 # endif 4260 ) 4261 { 4262 Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i)); 4263 pSharedCtx = &pState->paContext[i]; 4264 break; 4265 } 4266 #endif 4267 4268 /* 4269 * Initialize the context. 4270 */ 4127 4271 memset(pContext, 0, sizeof(*pContext)); 4128 4272 pContext->id = cid; … … 4210 4354 AssertMsgReturn(pContext->hglrc, ("wglCreateContext %x failed with %d\n", pContext->hdc, GetLastError()), VERR_INTERNAL_ERROR); 4211 4355 4212 // TODO isn't this default on Linux since OpenGL 1.1? 4213 /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */ 4214 for (uint32_t i = 0; i < pState->cContexts; i++) 4215 { 4216 if ( pState->paContext[i].id != SVGA3D_INVALID_ID 4217 && i != pContext->id) 4218 { 4219 Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i)); 4220 ret = wglShareLists(pState->paContext[i].hglrc, pContext->hglrc); 4221 Assert(ret == TRUE); 4222 break; 4223 } 4356 if (pSharedCtx) 4357 { 4358 ret = wglShareLists(pSharedCtx->hglrc, pContext->hglrc); 4359 AssertMsg(ret == TRUE, ("wglShareLists(%p, %p) failed with %d\n", pSharedCtx->hglrc, pContext->hglrc, GetLastError())); 4224 4360 } 4225 4361 4226 4362 #elif defined(RT_OS_DARWIN) 4227 pContext->fOtherProfile = fOtherProfile; 4228 4229 /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */ 4230 NativeNSOpenGLContextRef shareContext = NULL; 4231 for (uint32_t i = 0; i < pState->cContexts; i++) 4232 { 4233 if ( pState->paContext[i].id != SVGA3D_INVALID_ID 4234 && i != pContext->id 4235 && pState->paContext[i].fOtherProfile == fOtherProfile) 4236 { 4237 Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i)); 4238 shareContext = pState->paContext[i].cocoaContext; 4239 break; 4240 } 4241 } 4242 vmsvga3dCocoaCreateContext(&pContext->cocoaContext, shareContext, fOtherProfile); 4363 pContext->fOtherProfile = RT_BOOL(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE); 4364 4365 NativeNSOpenGLContextRef shareContext = pSharedCtx ? pSharedCtx->cocoaContext : NULL; 4366 vmsvga3dCocoaCreateContext(&pContext->cocoaContext, shareContext, pContext->fOtherProfile); 4243 4367 NativeNSViewRef pHostView = (NativeNSViewRef)pThis->svga.u64HostWindowId; 4244 4368 vmsvga3dCocoaCreateView(&pContext->cocoaView, pHostView); … … 4289 4413 /* the window is hidden by default and only mapped when CommandPresent is executed on it */ 4290 4414 4291 /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */ 4292 GLXContext shareContext = NULL; 4293 for (uint32_t i = 0; i < pState->cContexts; i++) 4294 { 4295 if ( pState->paContext[i].id != SVGA3D_INVALID_ID 4296 && i != pContext->id) 4297 { 4298 Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i)); 4299 shareContext = pState->paContext[i].glxContext; 4300 break; 4301 } 4302 } 4303 4415 GLXContext shareContext = pSharedCtx ? pSharedCtx->glxContext : NULL; 4304 4416 pContext->glxContext = glXCreateContext(pState->display, vi, shareContext, GL_TRUE); 4305 4417 AssertMsgReturn(pContext->glxContext, ("glXCreateContext failed"), VERR_INTERNAL_ERROR); … … 4346 4458 } 4347 4459 4460 4461 /** 4462 * Create a new 3d context 4463 * 4464 * @returns VBox status code. 4465 * @param pThis VGA device instance data. 4466 * @param cid Context id 4467 */ 4468 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid) 4469 { 4470 return vmsvga3dContextDefineOgl(pThis, cid, 0/*fFlags*/); 4471 } 4472 4473 4348 4474 /** 4349 4475 * Destroy an existing 3d context … … 4398 4524 } 4399 4525 4400 #if 1/* This is done on windows - prevents various assertions at runtime, as well as shutdown & reset assertions when destroying surfaces. */4526 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX /* This is done on windows - prevents various assertions at runtime, as well as shutdown & reset assertions when destroying surfaces. */ 4401 4527 /* Check for all surfaces that are associated with this context to remove all dependencies */ 4402 4528 for (uint32_t sid = 0; sid < pState->cSurfaces; sid++) … … 5672 5798 { 5673 5799 Log(("vmsvga3dSetRenderTarget: create renderbuffer to be used as render target; surface id=%x type=%d format=%d\n", target.sid, pRenderTarget->flags, pRenderTarget->internalFormatGL)); 5800 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 5801 pContext = &pState->SharedCtx; 5802 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 5803 #endif 5674 5804 pState->ext.glGenRenderbuffers(1, &pRenderTarget->oglId.renderbuffer); 5675 5805 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); … … 5684 5814 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 5685 5815 5816 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 5817 pState->ext.glBindRenderbuffer(GL_RENDERBUFFER, OPENGL_INVALID_ID); 5818 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 5819 5820 pContext = &pState->paContext[cid]; 5821 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 5822 #else 5686 5823 LogFlow(("vmsvga3dSetRenderTarget: sid=%x idAssociatedContext %#x -> %#x\n", pRenderTarget->id, pRenderTarget->idAssociatedContext, cid)); 5687 5824 pRenderTarget->idAssociatedContext = cid; 5688 } 5825 #endif 5826 } 5827 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 5689 5828 else 5829 #endif 5690 5830 { 5691 5831 pState->ext.glBindRenderbuffer(GL_RENDERBUFFER, pRenderTarget->oglId.renderbuffer); 5692 5832 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 5693 5833 } 5834 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 5694 5835 Assert(pRenderTarget->idAssociatedContext == cid); 5836 #endif 5695 5837 Assert(!pRenderTarget->fDirty); 5696 5838 AssertReturn(pRenderTarget->oglId.texture != OPENGL_INVALID_ID, VERR_INVALID_PARAMETER); … … 6020 6162 if (pSurface->oglId.texture == OPENGL_INVALID_ID) 6021 6163 { 6164 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 6022 6165 Assert(pSurface->idAssociatedContext == SVGA3D_INVALID_ID); 6166 #endif 6023 6167 Log(("CreateTexture (%d,%d) level=%d\n", pSurface->pMipmapLevels[0].size.width, pSurface->pMipmapLevels[0].size.height, pSurface->faces[0].numMipLevels)); 6024 6168 int rc = vmsvga3dCreateTexture(pState, pContext, cid, pSurface); … … 6751 6895 { 6752 6896 Log(("vmsvga3dDrawPrimitives: create vertex buffer fDirty=%d size=%x bytes\n", pVertexSurface->fDirty, pVertexSurface->pMipmapLevels[0].cbSurface)); 6897 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 6898 PVMSVGA3DCONTEXT pSavedCtx = pContext; 6899 pContext = &pState->SharedCtx; 6900 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6901 #endif 6902 6753 6903 pState->ext.glGenBuffers(1, &pVertexSurface->oglId.buffer); 6754 6904 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); … … 6766 6916 6767 6917 pVertexSurface->flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER; 6768 } 6918 6919 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 6920 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, OPENGL_INVALID_ID); 6921 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6922 6923 pContext = pSavedCtx; 6924 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6925 #endif 6926 } 6927 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 6769 6928 else 6929 #endif 6770 6930 { 6771 6931 Assert(pVertexSurface->fDirty == false); … … 6773 6933 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 6774 6934 } 6935 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 6775 6936 pVertexSurface->idAssociatedContext = pContext->id; 6776 6937 LogFlow(("vmsvga3dDrawPrimitivesProcessVertexDecls: sid=%x idAssociatedContext %#x -> %#x\n", pVertexSurface->id, pVertexSurface->idAssociatedContext, pContext->id)); 6938 #endif 6777 6939 6778 6940 /* Setup the vertex declarations. */ … … 7051 7213 { 7052 7214 Log(("vmsvga3dDrawPrimitives: create index buffer fDirty=%d size=%x bytes\n", pIndexSurface->fDirty, pIndexSurface->pMipmapLevels[0].cbSurface)); 7215 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 7216 pContext = &pState->SharedCtx; 7217 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7218 #endif 7053 7219 7054 7220 pState->ext.glGenBuffers(1, &pIndexSurface->oglId.buffer); … … 7068 7234 7069 7235 pIndexSurface->flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER; 7236 7237 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 7238 pState->ext.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OPENGL_INVALID_ID); 7239 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 7240 7241 pContext = &pState->paContext[cid]; 7242 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7243 #endif 7070 7244 } 7245 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 7071 7246 else 7247 #endif 7072 7248 { 7073 7249 Assert(pIndexSurface->fDirty == false); … … 7076 7252 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 7077 7253 } 7254 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX 7078 7255 LogFlow(("vmsvga3dDrawPrimitives: sid=%x idAssociatedContext %#x -> %#x\n", pIndexSurface->id, pIndexSurface->idAssociatedContext, pContext->id)); 7079 7256 pIndexSurface->idAssociatedContext = pContext->id; 7257 #endif 7080 7258 } 7081 7259 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h
r53755 r54659 49 49 uint32_t cPixelShaderConst, cVertexShaderConst, cPixelShaders, cVertexShaders; 50 50 51 rc = vmsvga3dContextDefine(pThis, cid , false /*fOtherProfile*/);51 rc = vmsvga3dContextDefine(pThis, cid); 52 52 AssertRCReturn(rc, rc); 53 53 … … 648 648 void *pData = NULL; 649 649 650 # ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 651 PVMSVGA3DCONTEXT pContext = &pState->SharedCtx; 652 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 653 # else 650 654 /* @todo stricter checks for associated context */ 651 655 uint32_t cid = pSurface->idAssociatedContext; … … 658 662 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid]; 659 663 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 664 # endif 660 665 661 666 Assert(pMipmapLevel->cbSurface); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r53780 r54659 2903 2903 * @param pThis VGA device instance data. 2904 2904 * @param cid Context id 2905 * @param fOtherProfile OpenGL(+darwin) specific argument, ignored.2906 2905 */ 2907 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid , bool fOtherProfile)2906 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid) 2908 2907 { 2909 2908 int rc; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r53756 r54659 63 63 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect); 64 64 65 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid , bool fOtherProfile);65 int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid); 66 66 int vmsvga3dContextDestroy(PVGASTATE pThis, uint32_t cid); 67 67
Note:
See TracChangeset
for help on using the changeset viewer.