DECLEXPORT(BOOL) WINAPI wglSwapLayerBuffers_prox( HDC hdc, UINT planes ) { CR_DDI_PROLOGUE(); if (planes == WGL_SWAP_MAIN_PLANE) { return wglSwapBuffers_prox(hdc); } else { crWarning( "wglSwapLayerBuffers: unsupported" ); return 0; } }
int renderspuIatPatcherPatchEntry(void *pvEntry, void *pvValue, void **ppvOldVal) { void **ppfn = (void**)pvEntry; DWORD dwOldProtect = 0; if (!VirtualProtect(pvEntry, sizeof (pvEntry), PAGE_READWRITE, &dwOldProtect)) { crWarning("VirtualProtect 1 failed, %d", GetLastError()); return VERR_ACCESS_DENIED; } if (ppvOldVal) *ppvOldVal = *ppfn; *ppfn = pvValue; if (!VirtualProtect(pvEntry, sizeof (pvEntry), dwOldProtect, &dwOldProtect)) { crWarning("VirtualProtect 2 failed, %d.. ignoring", GetLastError()); } return VINF_SUCCESS; }
void crServerRedirMuralFBO(CRMuralInfo *mural, GLboolean redir) { if (redir) { if (!crServerSupportRedirMuralFBO()) { crWarning("FBO not supported, can't redirect window output"); return; } cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, GL_FALSE); if (mural->idFBO==0) { crServerCreateMuralFBO(mural); } if (!crStateGetCurrent()->framebufferobject.drawFB) { cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->idFBO); } if (!crStateGetCurrent()->framebufferobject.readFB) { cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->idFBO); } crStateGetCurrent()->buffer.width = 0; crStateGetCurrent()->buffer.height = 0; } else { cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, mural->bVisible); if (mural->bUseFBO && crServerSupportRedirMuralFBO()) { if (!crStateGetCurrent()->framebufferobject.drawFB) { cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); } if (!crStateGetCurrent()->framebufferobject.readFB) { cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0); } } crStateGetCurrent()->buffer.width = mural->width; crStateGetCurrent()->buffer.height = mural->height; } mural->bUseFBO = redir; }
int CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural) { if (pMural) { if (!memcmp(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural))) return VINF_SUCCESS; memcpy(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural)); } else { if (CrBltIsEntered(pBlitter)) { crWarning("can not set null mural for entered bleater"); return VERR_INVALID_STATE; } if (!pBlitter->CurrentMural.Base.id) return VINF_SUCCESS; pBlitter->CurrentMural.Base.id = 0; } pBlitter->Flags.CurrentMuralChanged = 1; if (!CrBltIsEntered(pBlitter)) return VINF_SUCCESS; else if (!pBlitter->CtxInfo.Base.id) { crWarning("setting current mural for entered no-context blitter"); return VERR_INVALID_STATE; } crWarning("changing mural for entered blitter, is is somewhat expected?"); pBlitter->pDispatch->Flush(); pBlitter->pDispatch->MakeCurrent(pMural->Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id); return VINF_SUCCESS; }
void CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) { if (!CrBltIsEntered(pBlitter)) { crWarning("CrBltBlitTexMural: blitter not entered"); return; } RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height}; pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, fBb ? GL_BACK : GL_FRONT, &DstSize, paDstRects, cRects, fFlags); }
int main( int argc, char *argv[] ) { CRConnection *conn = crMothershipConnect( ); if (conn) { crMothershipSendString( conn, NULL, "reset" ); crMothershipDisconnect( conn ); } else { crWarning( "\n\nNO MOTHERSHIP RUNNING?!\n\n"); } return 0; }
/** * Transform the given object-space bounds to window coordinates and * update the window's bounding box union. */ static void AccumulateObjectBBox(const GLfloat * bbox) { GLfloat proj[16], modl[16], viewport[4]; GLfloat x1, y1, z1, x2, y2, z2; CRrecti winBox; GET_CONTEXT(context); WindowInfo *window = context->currentWindow; x1 = bbox[0]; y1 = bbox[1]; z1 = bbox[2]; x2 = bbox[3]; y2 = bbox[4]; z2 = bbox[5]; /* transform by modelview and projection */ binaryswap_spu.super.GetFloatv(GL_PROJECTION_MATRIX, proj); binaryswap_spu.super.GetFloatv(GL_MODELVIEW_MATRIX, modl); crProjectBBox(modl, proj, &x1, &y1, &z1, &x2, &y2, &z2); /* Sanity check... */ if (x2 < x1 || y2 < y1 || z2 < z1) { crWarning("Damnit!!!!, we screwed up the clipping somehow..."); return; } /* adjust depth for alpha composite */ binaryswap_spu.depth = z1; /* map to window coords */ binaryswap_spu.super.GetFloatv(GL_VIEWPORT, viewport); winBox.x1 = (int) ((x1 + 1.0f) * (viewport[2] * 0.5F) + viewport[0]); winBox.y1 = (int) ((y1 + 1.0f) * (viewport[3] * 0.5F) + viewport[1]); winBox.x2 = (int) ((x2 + 1.0f) * (viewport[2] * 0.5F) + viewport[0]); winBox.y2 = (int) ((y2 + 1.0f) * (viewport[3] * 0.5F) + viewport[1]); if (window->bboxUnion.x1 == 0 && window->bboxUnion.x2 == 0) { /* this is the first box */ window->bboxUnion = winBox; } else { /* compute union of current screen bbox and this one */ crRectiUnion(&window->bboxUnion, &window->bboxUnion, &winBox); } }
VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst) { if (!CrBltIsEntered(pBlitter)) { crWarning("CrBltImgFree: blitter not entered"); return; } if (pDst->pvData) { RTMemFree(pDst->pvData); pDst->pvData = NULL; } }
BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes) { CR_DDI_PROLOGUE(); if (fuPlanes == 1) { return DrvSwapBuffers(hdc); } else { crWarning( "DrvSwapLayerBuffers: unsupported" ); CRASSERT(false); return 0; } }
static void PushMatrix(void) { if (CurrentStack->depth < CurrentStack->maxDepth) { /* copy matrix */ *(CurrentStack->top + 1) = *(CurrentStack->top); /* Move the stack pointer */ CurrentStack->depth++; CurrentStack->top = CurrentStack->stack + CurrentStack->depth; } else { crWarning("Stack overflow in dlm_bbox.c"); } }
void DLM_APIENTRY crDLMListBase( GLuint base ) { CRDLMContextState *listState = CURRENT_STATE(); if (listState == NULL) { crWarning ("DLM error: ListBase(%d) called with no current state (%s line %d)\n", (int) base, __FILE__, __LINE__); return; } listState->listBase = base; }
GLuint DLM_APIENTRY crDLMGenLists(GLsizei range) { CRDLMContextState *listState = CURRENT_STATE(); if (listState == NULL) { crWarning ("DLM error: GenLists(%d) called with no current state (%s line %d)\n", (int) range, __FILE__, __LINE__); return 0; } return crHashtableAllocKeys(listState->dlm->displayLists, range); }
static void RENDER_APIENTRY renderspuDestroyContext( GLint ctx ) { ContextInfo *context, *curCtx; CRASSERT(ctx); if (ctx == CR_RENDER_DEFAULT_CONTEXT_ID) { crWarning("request to destroy a default context, ignoring"); return; } context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx); CRASSERT(context); { if (!context) { crWarning("request to delete inexistent context"); return; } } curCtx = GET_CONTEXT_VAL(); CRASSERT(curCtx); if (curCtx == context) { renderspuMakeCurrent( CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID ); curCtx = GET_CONTEXT_VAL(); Assert(curCtx); Assert(curCtx != context); } crHashtableDelete(render_spu.contextTable, ctx, NULL); renderspuContextMarkDeletedAndRelease(context); }
void CR_APIENTRY glSeparableFilter2D( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column ) #endif { (void) target; (void) internalformat; (void) width; (void) height; (void) format; (void) type; (void) row; (void) column; crWarning("glSeparableFilter2D not implemented by VMGL/Chromium"); }
VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural) { if (CrBltIsEntered(pBlitter)) { crWarning("CrBltBlitTexTex: blitter is entered"); return VERR_INVALID_STATE; } if (pBlitter->Flags.ShadersGloal || !CrGlslNeedsCleanup(&pBlitter->LocalGlslCache)) return VINF_SUCCESS; int rc = CrBltEnter(pBlitter, pRestoreCtxInfo, pRestoreMural); if (!RT_SUCCESS(rc)) { crWarning("CrBltEnter failed, rc %d", rc); return rc; } CrGlslCleanup(&pBlitter->LocalGlslCache); CrBltLeave(pBlitter); return VINF_SUCCESS; }
CRConnection *crMothershipConnect( void ) { const char *mother_server; crNetInit( NULL, NULL ); mother_server = crGetenv( "CRMOTHERSHIP" ); if (!mother_server) { crWarning( "Couldn't find the CRMOTHERSHIP environment variable, defaulting to localhost" ); mother_server = "localhost"; } return crNetConnectToServer( mother_server, DEFAULT_MOTHERSHIP_PORT, 8096, 0 ); }
VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget) { GLuint uiProg = crGlslProgGetNoAlpha(pCache, enmTexTarget); if (!uiProg) { crWarning("request to use inexistent program!"); return VERR_INVALID_STATE; } Assert(uiProg); pCache->pDispatch->UseProgram(uiProg); return VINF_SUCCESS; }
/* @param pCtxBase - contains the blitter context info. Its value is treated differently depending on the fCreateNewCtx value * @param fCreateNewCtx - if true - the pCtxBase must NOT be NULL. its visualBits is used as a visual bits info for the new context, * its id field is used to specified the shared context id to be used for blitter context. * The id can be null to specify no shared context is needed * if false - if pCtxBase is NOT null AND its id field is NOT null - * specified the blitter context to be used * blitter treats it as if it has default ogl state. * otherwise - * the blitter works in a "no-context" mode, i.e. a caller is responsible * to making a proper context current before calling the blitter. * Note that BltEnter/Leave MUST still be called, but the proper context * must be set before doing BltEnter, and ResoreContext info is ignored in that case. * Also note that blitter caches the current window info, and assumes the current context's values are preserved * wrt that window before the calls, so if one uses different contexts for one blitter, * the blitter current window values must be explicitly reset by doing CrBltMuralSetCurrent(pBlitter, NULL) * @param fForceDrawBlt - if true - forces the blitter to always use glDrawXxx-based blits even if GL_EXT_framebuffer_blit. * This is needed because BlitFramebufferEXT is known to be often buggy, and glDrawXxx-based blits appear to be more reliable */ int CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, SPUDispatchTable *pDispatch) { if (pCtxBase && pCtxBase->Base.id < 0) { crWarning("Default share context not initialized!"); return VERR_INVALID_PARAMETER; } if (!pCtxBase && fCreateNewCtx) { crWarning("pCtxBase is zero while fCreateNewCtx is set!"); return VERR_INVALID_PARAMETER; } memset(pBlitter, 0, sizeof (*pBlitter)); pBlitter->pDispatch = pDispatch; if (pCtxBase) pBlitter->CtxInfo = *pCtxBase; pBlitter->Flags.ForceDrawBlit = fForceDrawBlt; if (fCreateNewCtx) { pBlitter->CtxInfo.Base.id = pDispatch->CreateContext("", pCtxBase->Base.visualBits, pCtxBase->Base.id); if (!pBlitter->CtxInfo.Base.id) { memset(pBlitter, 0, sizeof (*pBlitter)); crWarning("CreateContext failed!"); return VERR_GENERAL_FAILURE; } pBlitter->Flags.CtxCreated = 1; } return VINF_SUCCESS; }
static GLint BINARYSWAPSPU_APIENTRY binaryswapspuWindowCreate(const char *dpyName, GLint visBits) { WindowInfo *window; static GLint freeID = 1; /* skip default window 0 */ GLint childVisBits, superVisBits; /* Error out on second window */ if (freeID != 1) { crError("Binaryswap can't deal with multiple windows!"); return 0; } /* allocate window */ window = (WindowInfo *) crCalloc(sizeof(WindowInfo)); if (!window) { crWarning("binaryswap SPU: unable to allocate window."); return -1; } binaryswapspuTweakVisBits(visBits, &childVisBits, &superVisBits); /* init window */ window->index = freeID; window->renderWindow = binaryswap_spu.super.WindowCreate(dpyName, superVisBits); window->childWindow = binaryswap_spu.child.WindowCreate(dpyName, childVisBits); window->width = -1; /* unknown */ window->height = -1; /* unknown */ window->msgBuffer = NULL; window->childVisBits = childVisBits; window->superVisBits = superVisBits; if (window->renderWindow < 0 || window->childWindow < 0) { crFree(window); return -1; } /* put into hash table */ crHashtableAdd(binaryswap_spu.windowTable, window->index, window); freeID++; return freeID - 1; }
void PACK_APIENTRY crPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) { unsigned char *data_ptr, *start_ptr; int packet_length = sizeof(int) + sizeof(mode) + sizeof(start) + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLuint); GLsizei indexsize; #ifdef CR_ARB_vertex_buffer_object CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; packet_length += sizeof(GLint); if (elementsBuffer && elementsBuffer->id) { /*@todo not sure it's possible, and not sure what to do*/ if (!elementsBuffer->data) { crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring."); return; } indexsize = 0; } else #endif { indexsize = crPackElementsIndexSize(type); } packet_length += count * indexsize; start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); WRITE_DATA_AI(GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE); WRITE_DATA_AI(GLenum, mode); WRITE_DATA_AI(GLuint, start); WRITE_DATA_AI(GLuint, end); WRITE_DATA_AI(GLsizei, count); WRITE_DATA_AI(GLenum, type); WRITE_DATA_AI(GLuint, (GLuint) ((uintptr_t) indices)); #ifdef CR_ARB_vertex_buffer_object WRITE_DATA_AI(GLint, (GLint) (indexsize>0)); #endif if (indexsize>0) { crMemcpy(data_ptr, indices, count * indexsize); } crHugePacket(CR_EXTEND_OPCODE, start_ptr); crPackFree(start_ptr); }
void CrDemEntryDestroy(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture) { #ifdef DEBUG { PCR_DISPLAY_ENTRY pEntry = (PCR_DISPLAY_ENTRY)crHashtableSearch(pMap->pTextureMap, idTexture); if (!pEntry) { crWarning("request to delete inexistent entry"); return; } Assert(!CrDpEntryIsUsed(pEntry)); } #endif crHashtableDelete(pMap->pTextureMap, idTexture, crFree); }
static stubDispatchVisibleRegions(WindowInfo *pWindow) { DWORD dwCount; LPRGNDATA lpRgnData; dwCount = GetRegionData(pWindow->hVisibleRegion, 0, NULL); lpRgnData = crAlloc(dwCount); if (lpRgnData) { GetRegionData(pWindow->hVisibleRegion, dwCount, lpRgnData); crDebug("Dispatched WindowVisibleRegion (%i, cRects=%i)", pWindow->spuWindow, lpRgnData->rdh.nCount); stub.spuDispatch.WindowVisibleRegion(pWindow->spuWindow, lpRgnData->rdh.nCount, (GLint*) lpRgnData->Buffer); crFree(lpRgnData); } else crWarning("GetRegionData failed, VisibleRegions update failed"); }
GLboolean DLM_APIENTRY crDLMIsList(GLuint list) { CRDLMContextState *listState = CURRENT_STATE(); if (listState == NULL) { crWarning ("DLM error: IsLists(%d) called with no current state (%s line %d)\n", (int) list, __FILE__, __LINE__); return 0; } if (list == 0) return GL_FALSE; return crHashtableIsKeyUsed(listState->dlm->displayLists, list); }
DECLEXPORT(void) STATE_APIENTRY crStateDeleteShader(GLuint shader) { CRGLSLShader *pShader = crStateGetShaderObj(shader); if (!pShader) { crWarning("Unknown shader %d", shader); return; } pShader->deleted = GL_TRUE; if (0==pShader->refCount) { CRContext *g = GetCurrentContext(); crHashtableDelete(g->glsl.shaders, shader, crStateFreeGLSLShader); } }
void SERVER_DISPATCH_APIENTRY crServerDispatchGetObjectParameterivARB( GLhandleARB obj, GLenum pname, GLint * params ) { GLint local_params[1]; GLuint hwid = crStateGetProgramHWID(obj); if (!hwid) { hwid = crStateGetShaderHWID(obj); if (!hwid) { crWarning("Unknown object %i, in crServerDispatchGetObjectParameterivARB", obj); } } (void) params; cr_server.head_spu->dispatch_table.GetObjectParameterivARB( hwid, pname, local_params ); crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) ); }
/* * This function is called by the packer functions when it detects and * OpenGL error. */ void __PackError( int line, const char *file, GLenum error, const char *info) { CR_GET_PACKER_CONTEXT(pc); if (pc->Error) pc->Error( line, file, error, info ); if (crGetenv("CR_DEBUG")) { char *glerr; switch (error) { case GL_NO_ERROR: glerr = "GL_NO_ERROR"; break; case GL_INVALID_VALUE: glerr = "GL_INVALID_VALUE"; break; case GL_INVALID_ENUM: glerr = "GL_INVALID_ENUM"; break; case GL_INVALID_OPERATION: glerr = "GL_INVALID_OPERATION"; break; case GL_STACK_OVERFLOW: glerr = "GL_STACK_OVERFLOW"; break; case GL_STACK_UNDERFLOW: glerr = "GL_STACK_UNDERFLOW"; break; case GL_OUT_OF_MEMORY: glerr = "GL_OUT_OF_MEMORY"; break; case GL_TABLE_TOO_LARGE: glerr = "GL_TABLE_TOO_LARGE"; break; default: glerr = "unknown"; break; } crWarning( "GL error in packer: %s, line %d: %s: %s", file, line, glerr, info ); } }
DECLEXPORT(void) STATE_APIENTRY crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) { CRContext *g = GetCurrentContext(); CRFramebufferObjectState *fbo = &g->framebufferobject; int i; CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0"); for (i = 0; i < n; i++) { if (renderbuffers[i]) { CRRenderbufferObject *rbo; rbo = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffers[i]); if (rbo) { int j; ctStateRenderbufferRefsCleanup(g, renderbuffers[i], rbo); CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(rbo, j) { /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, * so on restore, we set mark bits as used. * This is why g_pAvailableContexts[j] could be NULL * also g_pAvailableContexts[0] will hold default context, which we should discard */ CRContext *ctx = g_pAvailableContexts[j]; if (j && ctx) { CRFramebufferObjectState *ctxFbo; CRASSERT(ctx); ctxFbo = &ctx->framebufferobject; if (ctxFbo->renderbuffer==rbo) crWarning("deleting RBO being used by another context %d", ctx->id); ctStateRenderbufferRefsCleanup(ctx, renderbuffers[i], rbo); } else CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(rbo, j); } crHashtableDelete(g->shared->rbTable, renderbuffers[i], crStateFreeRBO); } } }
struct VBOXVR_SCR_COMPOSITOR * renderspuVBoxCompositorAcquire( WindowInfo *window) { int rc = RTCritSectEnter(&window->CompositorLock); if (RT_SUCCESS(rc)) { VBOXVR_SCR_COMPOSITOR * pCompositor = window->pCompositor; if (pCompositor) return pCompositor; /* if no compositor is set, release the lock and return */ RTCritSectLeave(&window->CompositorLock); } else { crWarning("RTCritSectEnter failed rc %d", rc); } return NULL; }
DECLEXPORT(void) STATE_APIENTRY crStateDeleteProgram(GLuint program) { CRContext *g = GetCurrentContext(); CRGLSLProgram *pProgram = crStateGetProgramObj(program); if (!pProgram) { crWarning("Unknown program %d", program); return; } if (g->glsl.activeProgram == pProgram) { g->glsl.activeProgram = NULL; } crHashtableDelete(g->glsl.programs, program, crStateFreeGLSLProgram); }
static void crStateFakeDecRefCountCB(unsigned long key, void *data1, void *data2) { CRGLSLShader *pShader = (CRGLSLShader *) data1; CRContext *ctx = (CRContext*) data2; CRGLSLShader *pRealShader; (void) key; pRealShader = crStateGetShaderObj(pShader->id); if (pRealShader) { crStateShaderDecRefCount(pRealShader); } else { crWarning("crStateFakeDecRefCountCB: NULL pRealShader"); } }