diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Additions/common/crOpenGL/pack | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Additions/common/crOpenGL/pack')
11 files changed, 287 insertions, 15 deletions
diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu.h b/src/VBox/Additions/common/crOpenGL/pack/packspu.h index 27f3526f..942761a8 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu.h +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu.h @@ -19,6 +19,9 @@ #include "cr_spu.h" #include "cr_threads.h" #include "state/cr_client.h" +#ifdef VBOX_WITH_CRPACKSPU_DUMPER +# include "cr_dump.h" +#endif typedef struct thread_info_t ThreadInfo; typedef struct context_info_t ContextInfo; @@ -70,6 +73,13 @@ typedef struct { bool bRunningUnderWDDM; #endif +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + SPUDispatchTable self; + + CR_RECORDER Recorder; + CR_DBGPRINT_DUMPER Dumper; +#endif + int numContexts; ContextInfo context[CR_MAX_CONTEXTS]; } PackSPU; @@ -82,7 +92,8 @@ extern PackSPU pack_spu; extern CRmutex _PackMutex; extern CRtsd _PackTSD; #define GET_THREAD_VAL() (crGetTSD(&_PackTSD)) -#define GET_THREAD_VAL_ID(_id) (&(pack_spu.thread[(_id) - THREAD_OFFSET_MAGIC])) +#define GET_THREAD_IDX(_id) ((_id) - THREAD_OFFSET_MAGIC) +#define GET_THREAD_VAL_ID(_id) (&(pack_spu.thread[GET_THREAD_IDX(_id)])) #else #define GET_THREAD_VAL() (&(pack_spu.thread[0])) #endif diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c index 8a741137..53cd3aff 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c @@ -130,3 +130,31 @@ packspu_BindBufferARB( GLenum target, GLuint buffer ) crStateBindBufferARB(target, buffer); crPackBindBufferARB(target, buffer); } + +void PACKSPU_APIENTRY packspu_GenBuffersARB( GLsizei n, GLuint * buffer ) +{ + GET_THREAD(thread); + int writeback = 1; + if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network)) + { + crError( "packspu_GenBuffersARB doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" ); + } + if (pack_spu.swap) + { + crPackGenBuffersARBSWAP( n, buffer, &writeback ); + } + else + { + crPackGenBuffersARB( n, buffer, &writeback ); + } + packspuFlush( (void *) thread ); + CRPACKSPU_WRITEBACK_WAIT(thread, writeback); + + crStateRegBuffers(n, buffer); +} + +void PACKSPU_APIENTRY packspu_DeleteBuffersARB( GLsizei n, const GLuint * buffer ) +{ + crStateDeleteBuffersARB( n, buffer ); + crPackDeleteBuffersARB(n, buffer); +} diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c index 90fb5f90..08e41300 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c @@ -130,6 +130,8 @@ packspu_VBoxConFlush(GLint con) CRASSERT(CRPACKSPU_IS_WDDM_CRHGSMI()); CRASSERT(thread->packer); packspuFlush((void *) thread); +#else + crError("VBoxConFlush not implemented!"); #endif } @@ -148,8 +150,17 @@ packspu_VBoxConDestroy(GLint con) crPackDeleteContext(thread->packer); + if (thread->buffer.pack) + { + crNetFree(thread->netServer.conn, thread->buffer.pack); + thread->buffer.pack = NULL; + } + crNetFreeConnection(thread->netServer.conn); + if (thread->netServer.name) + crFree(thread->netServer.name); + pack_spu.numThreads--; /*note can't shift the array here, because other threads have TLS references to array elements*/ crMemZero(thread, sizeof(ThreadInfo)); @@ -173,6 +184,63 @@ packspu_VBoxConDestroy(GLint con) #endif } +GLvoid PACKSPU_APIENTRY +packspu_VBoxConChromiumParameteriCR(GLint con, GLenum param, GLint value) +{ + GET_THREAD(thread); + CRPackContext * curPacker = crPackGetContext(); + ThreadInfo *curThread = thread; + int writeback = 1; + GLint serverCtx = (GLint) -1; + + CRASSERT(!curThread == !curPacker); + CRASSERT(!curThread || !curPacker || curThread->packer == curPacker); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&_PackMutex); +#endif + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + CRASSERT(!con == !CRPACKSPU_IS_WDDM_CRHGSMI()); +#endif + + if (CRPACKSPU_IS_WDDM_CRHGSMI()) + { + if (!con) + { + crError("connection should be specified!"); + return; + } + thread = GET_THREAD_VAL_ID(con); + } + else + { + CRASSERT(!con); + if (!thread) + { + thread = packspuNewThread( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + NULL +#endif + ); + } + } + CRASSERT(thread); + CRASSERT(thread->packer); + + crPackSetContext( thread->packer ); + + packspu_ChromiumParameteriCR(param, value); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&_PackMutex); +#endif + + if (CRPACKSPU_IS_WDDM_CRHGSMI()) + { + /* restore the packer context to the tls */ + crPackSetContext(curPacker); + } +} GLint PACKSPU_APIENTRY packspu_VBoxCreateContext( GLint con, const char *dpyName, GLint visual, GLint shareCtx ) @@ -412,7 +480,7 @@ void PACKSPU_APIENTRY packspu_MakeCurrent( GLint window, GLint nativeWindow, GLi } else { - if (!newCtx->fAutoFlush) + if (newCtx->fAutoFlush) { if (newCtx->currentThread && newCtx->currentThread != thread) { diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c index 555e60cd..ed555c48 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2009 Oracle Corporation + * Copyright (C) 2009-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -59,8 +59,8 @@ packspu_DeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers) void PACKSPU_APIENTRY packspu_DeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers) { - crStateDeleteFramebuffersEXT(n, renderbuffers); - crPackDeleteFramebuffersEXT(n, renderbuffers); + crStateDeleteRenderbuffersEXT(n, renderbuffers); + crPackDeleteRenderbuffersEXT(n, renderbuffers); } void PACKSPU_APIENTRY @@ -97,3 +97,47 @@ packspu_CheckFramebufferStatusEXT(GLenum target) crStateSetFramebufferStatus(target, status); return status; } + +void PACKSPU_APIENTRY packspu_GenFramebuffersEXT( GLsizei n, GLuint * framebuffers ) +{ + GET_THREAD(thread); + int writeback = 1; + if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network)) + { + crError( "packspu_GenFramebuffersEXT doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" ); + } + if (pack_spu.swap) + { + crPackGenFramebuffersEXTSWAP( n, framebuffers, &writeback ); + } + else + { + crPackGenFramebuffersEXT( n, framebuffers, &writeback ); + } + packspuFlush( (void *) thread ); + CRPACKSPU_WRITEBACK_WAIT(thread, writeback); + + crStateRegFramebuffers(n, framebuffers); +} + +void PACKSPU_APIENTRY packspu_GenRenderbuffersEXT( GLsizei n, GLuint * renderbuffers ) +{ + GET_THREAD(thread); + int writeback = 1; + if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network)) + { + crError( "packspu_GenRenderbuffersEXT doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" ); + } + if (pack_spu.swap) + { + crPackGenRenderbuffersEXTSWAP( n, renderbuffers, &writeback ); + } + else + { + crPackGenRenderbuffersEXT( n, renderbuffers, &writeback ); + } + packspuFlush( (void *) thread ); + CRPACKSPU_WRITEBACK_WAIT(thread, writeback); + + crStateRegRenderbuffers(n, renderbuffers); +} diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py b/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py index 25aa4de2..82f00a85 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py @@ -48,7 +48,6 @@ GLboolean crPackIsPixelStoreParm(GLenum pname) """ from get_sizes import * -from get_components import * easy_swaps = { 'GenTextures': '(unsigned int) n', @@ -117,6 +116,11 @@ for func_name in keys: #ifdef CR_ARB_vertex_program || pname == GL_MAX_VERTEX_ATTRIBS_ARB #endif +#ifndef GL_EXT_framebuffer_object + || pname == GL_FRAMEBUFFER_BINDING_EXT + || pname == GL_READ_FRAMEBUFFER_BINDING_EXT + || pname == GL_DRAW_FRAMEBUFFER_BINDING_EXT +#endif ) { #ifdef DEBUG @@ -200,7 +204,7 @@ for func_name in keys: if func_name in hard_funcs.keys(): print '\tif (pack_spu.swap)' print '\t{' - print '\t\tfor (i = 0 ; i < lookupComponents(pname) ; i++)' + print '\t\tfor (i = 0 ; i < crStateHlpComponentsCount(pname) ; i++)' print '\t\t{' if hard_funcs[func_name] == 'SWAPDOUBLE': print '\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName) diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_getshaders.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_getshaders.c index d0cc9040..6b3271d5 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_getshaders.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_getshaders.c @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2009 Oracle Corporation + * Copyright (C) 2009-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -98,7 +98,7 @@ void PACKSPU_APIENTRY packspu_GetAttachedShaders(GLuint program, GLsizei maxCoun crFree(pLocal); } -void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj) +void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei * count, VBoxGLhandleARB * obj) { GET_THREAD(thread); int writeback = 1; @@ -106,7 +106,7 @@ void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(GLhandleARB containerObj, GL if (!obj) return; - pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei)); + pLocal = (GLsizei*) crAlloc(maxCount*sizeof(VBoxGLhandleARB)+sizeof(GLsizei)); if (!pLocal) return; crPackGetAttachedObjectsARB(containerObj, maxCount, pLocal, NULL, &writeback); @@ -115,13 +115,13 @@ void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(GLhandleARB containerObj, GL CRPACKSPU_WRITEBACK_WAIT(thread, writeback); if (count) *count=*pLocal; - crMemcpy(obj, &pLocal[1], *pLocal*sizeof(GLhandleARB)); + crMemcpy(obj, &pLocal[1], *pLocal*sizeof(VBoxGLhandleARB)); crFree(pLocal); } AssertCompile(sizeof(GLsizei) == 4); -void PACKSPU_APIENTRY packspu_GetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) +void PACKSPU_APIENTRY packspu_GetInfoLogARB(VBoxGLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) { GET_THREAD(thread); int writeback = 1; diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c index e19959a3..d58202ef 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2009 Oracle Corporation + * Copyright (C) 2009-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -129,12 +129,14 @@ void PACKSPU_APIENTRY packspu_DeleteProgram(GLuint program) crPackDeleteProgram(program); } -void PACK_APIENTRY packspu_DeleteObjectARB(GLhandleARB obj) +void PACK_APIENTRY packspu_DeleteObjectARB(VBoxGLhandleARB obj) { GLuint hwid = crStateGetProgramHWID(obj); CRASSERT(obj); + /* we do not track shader creation inside guest since it is not needed currently. + * this is why we only care about programs here */ if (hwid) { crStateDeleteProgram(obj); @@ -143,8 +145,57 @@ void PACK_APIENTRY packspu_DeleteObjectARB(GLhandleARB obj) crPackDeleteObjectARB(obj); } +#ifdef VBOX_WITH_CRPACKSPU_DUMPER +static void packspu_RecCheckInitRec() +{ + if (pack_spu.Recorder.pDumper) + return; + + crDmpDbgPrintInit(&pack_spu.Dumper); + + crRecInit(&pack_spu.Recorder, NULL /*pBlitter: we do not support blitter operations here*/, &pack_spu.self, &pack_spu.Dumper.Base); +} +#endif + void PACKSPU_APIENTRY packspu_LinkProgram(GLuint program) { +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + GLint linkStatus = 0; +#endif + crStateLinkProgram(program); crPackLinkProgram(program); + +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + pack_spu.self.GetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &linkStatus); + Assert(linkStatus); + if (!linkStatus) + { + CRContext *ctx = crStateGetCurrent(); + packspu_RecCheckInitRec(); + crRecDumpProgram(&pack_spu.Recorder, ctx, program, program); + } +#endif } + +void PACKSPU_APIENTRY packspu_CompileShader(GLuint shader) +{ +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + GLint compileStatus = 0; +#endif + +// crStateCompileShader(shader); + crPackCompileShader(shader); + +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + pack_spu.self.GetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus); + Assert(compileStatus); + if (!compileStatus) + { + CRContext *ctx = crStateGetCurrent(); + packspu_RecCheckInitRec(); + crRecDumpShader(&pack_spu.Recorder, ctx, shader, shader); + } +#endif +} + diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c index 6682058d..2781fa6f 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c @@ -50,6 +50,10 @@ packSPUInit( int id, SPU *child, SPU *self, pack_spu.bRunningUnderWDDM = !!GetModuleHandle(VBOX_MODNAME_DISPD3D); #endif +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + memset(&pack_spu.Dumper, 0, sizeof (pack_spu.Dumper)); +#endif + if (!CRPACKSPU_IS_WDDM_CRHGSMI()) { /* This connects to the server, sets up the packer, etc. */ @@ -75,7 +79,12 @@ packSPUInit( int id, SPU *child, SPU *self, static void packSPUSelfDispatch(SPUDispatchTable *self) { +#ifdef VBOX_WITH_CRPACKSPU_DUMPER + crSPUInitDispatchTable( &(pack_spu.self) ); + crSPUCopyDispatchTable( &(pack_spu.self), self ); +#else (void)self; +#endif } static int diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c index ee4d4f88..3048bbc3 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c @@ -615,9 +615,18 @@ void PACKSPU_APIENTRY packspu_VBoxDetachThread() crPackSetContext(NULL); CR_UNLOCK_PACKER_CONTEXT(thread->packer); crPackDeleteContext(pack_spu.thread[i].packer); + + if (pack_spu.thread[i].buffer.pack) + { + crNetFree(pack_spu.thread[i].netServer.conn, pack_spu.thread[i].buffer.pack); + pack_spu.thread[i].buffer.pack = NULL; + } } crNetFreeConnection(pack_spu.thread[i].netServer.conn); + if (pack_spu.thread[i].netServer.name) + crFree(pack_spu.thread[i].netServer.name); + pack_spu.numThreads--; /*note can't shift the array here, because other threads have TLS references to array elements*/ crMemZero(&pack_spu.thread[i], sizeof(ThreadInfo)); @@ -712,3 +721,11 @@ void PACKSPU_APIENTRY packspu_VBoxPackDetachThread() { } #endif /*CHROMIUM_THREADSAFE*/ + +void PACKSPU_APIENTRY packspu_VBoxPresentComposition(GLint win, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry) +{ +} + +void PACKSPU_APIENTRY packspu_StringMarkerGREMEDY(GLsizei len, const GLvoid *string) +{ +} diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_special b/src/VBox/Additions/common/crOpenGL/pack/packspu_special index 6b9edd95..d7a12124 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_special +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_special @@ -107,11 +107,13 @@ VBoxPackSetInjectID VBoxAttachThread VBoxDetachThread VBoxCreateContext +VBoxConChromiumParameteriCR VBoxWindowCreate VBoxWindowDestroy VBoxConCreate VBoxConDestroy VBoxConFlush +VBoxPresentComposition ChromiumParameteriCR CompressedTexImage1DARB CompressedTexImage2DARB @@ -119,3 +121,12 @@ CompressedTexImage3DARB CompressedTexSubImage1DARB CompressedTexSubImage2DARB CompressedTexSubImage3DARB +GenFramebuffersEXT +GenRenderbuffersEXT +DeleteFramebuffersEXT +DeleteRenderbuffersEXT +GenBuffersARB +DeleteBuffersARB +StringMarkerGREMEDY +GenTextures +CompileShader
\ No newline at end of file diff --git a/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c b/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c index b5c60aec..fca7fe66 100644 --- a/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c +++ b/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2009 Oracle Corporation + * Copyright (C) 2009-2010 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -39,3 +39,32 @@ void PACKSPU_APIENTRY packspu_DeleteTextures(GLsizei n, const GLuint * textures) crPackDeleteTextures(n, textures); } +void PACKSPU_APIENTRY packspu_GenTextures( GLsizei n, GLuint * textures ) +{ + GET_THREAD(thread); + int writeback = 1; + unsigned int i; + if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network)) + { + crError( "packspu_GenTextures doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" ); + } + if (pack_spu.swap) + { + crPackGenTexturesSWAP( n, textures, &writeback ); + } + else + { + crPackGenTextures( n, textures, &writeback ); + } + packspuFlush( (void *) thread ); + CRPACKSPU_WRITEBACK_WAIT(thread, writeback); + if (pack_spu.swap) + { + for (i = 0 ; i < (unsigned int) n ; i++) + { + textures[i] = SWAP32(textures[i]); + } + } + + crStateRegTextures(n, textures); +} |