Changeset 44908 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render
- Timestamp:
- Mar 4, 2013 11:16:25 AM (12 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL/render
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
r44887 r44908 13 13 #include "renderspu.h" 14 14 #include "cr_extstring.h" 15 16 #include <iprt/asm.h> 15 17 16 18 … … 180 182 */ 181 183 184 if (sharedContext) 185 ASMAtomicIncU32(&sharedContext->cRefs); 186 context->cRefs = 1; 187 182 188 return context; 183 189 } … … 209 215 } 210 216 217 static uint32_t renderspuContextRelease( ContextInfo *context ); 218 static void renderspuDestroyContextTerminate( ContextInfo *context ) 219 { 220 CRASSERT(context->BltInfo.Base.id == -1); 221 renderspu_SystemDestroyContext( context ); 222 if (context->extensionString) { 223 crFree(context->extensionString); 224 context->extensionString = NULL; 225 } 226 227 if (context->shared) 228 renderspuContextRelease( context->shared ); 229 230 crFree(context); 231 } 232 233 static uint32_t renderspuContextRelease( ContextInfo *context ) 234 { 235 uint32_t cRefs = ASMAtomicDecU32(&context->cRefs); 236 if (!cRefs) 237 renderspuDestroyContextTerminate( context ); 238 else 239 CRASSERT(cRefs < UINT32_MAX/2); 240 return cRefs; 241 } 242 243 uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context ) 244 { 245 /* invalidate the context id to mark it as deleted */ 246 context->BltInfo.Base.id = -1; 247 248 /* some drivers do not like when the base (shared) context is deleted before its referals, 249 * this is why we keep a context refference counting the base (shared) context will be destroyed as soon as*/ 250 return renderspuContextRelease( context ); 251 } 252 211 253 static void RENDER_APIENTRY 212 254 renderspuDestroyContext( GLint ctx ) … … 224 266 context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx); 225 267 CRASSERT(context); 268 { 269 if (!context) 270 { 271 crWarning("request to delete inexistent context"); 272 return; 273 } 274 } 226 275 227 276 curCtx = GET_CONTEXT_VAL(); … … 235 284 } 236 285 237 renderspu_SystemDestroyContext( context ); 238 if (context->extensionString) { 239 crFree(context->extensionString); 240 context->extensionString = NULL; 241 } 242 crHashtableDelete(render_spu.contextTable, ctx, crFree); 286 crHashtableDelete(render_spu.contextTable, ctx, NULL); 287 288 renderspuContextMarkDeletedAndRelease(context); 243 289 } 244 290 -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
r44887 r44908 168 168 struct _ContextInfo *shared; 169 169 char *extensionString; 170 volatile uint32_t cRefs; 170 171 } ContextInfo; 171 172 … … 416 417 extern void RENDER_APIENTRY renderspuSwapBuffers( GLint window, GLint flags ); 417 418 419 extern uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context ); 420 418 421 #ifdef __cplusplus 419 422 extern "C" { -
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c
r44887 r44908 411 411 { 412 412 ContextInfo *context = (ContextInfo *) data; 413 renderspu_SystemDestroyContext(context); 414 crFree(context); 413 renderspuContextMarkDeletedAndRelease(context); 415 414 } 416 415
Note:
See TracChangeset
for help on using the changeset viewer.