/* ============= RE_EndRegistration Touch all images to make sure they are resident ============= */ void RE_EndRegistration( void ) { R_IssuePendingRenderCommands(); if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } }
/* ============= RE_EndRegistration Touch all images to make sure they are resident ============= */ void RE_EndRegistration( void ) { R_SyncRenderThread(); if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } }
/* ============= RB_SwapBuffers ============= */ const void *RB_SwapBuffers( const void *data ) { const swapBuffersCommand_t *cmd; // finish any 2D drawing if needed if ( tess.numIndexes ) { RB_EndSurface(); } // texture swapping test if ( r_showImages->integer ) { RB_ShowImages(); } cmd = (const swapBuffersCommand_t *)data; // we measure overdraw by reading back the stencil buffer and // counting up the number of increments that have happened // there is an extension to read from stencil buffer on GLES, but it's not available on every device, and I'm too lazy #ifndef GL_VERSION_ES_CM_1_0 if ( r_measureOverdraw->integer ) { int i; long sum = 0; unsigned char *stencilReadback; stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { sum += stencilReadback[i]; } backEnd.pc.c_overDraw += sum; ri.Hunk_FreeTempMemory( stencilReadback ); } #endif if ( !glState.finishCalled ) { qglFinish(); } GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); GLimp_EndFrame(); /* if (r_cardboardStereo->integer && Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CONSOLE)) { qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); qglClear(GL_COLOR_BUFFER_BIT); } */ #ifdef __ANDROID__ // On-screen keyboard messes up GL state a bit glState.currenttextures[0] = 0; glState.currenttmu = 0; glState.texEnv[glState.currenttmu] = GL_MODULATE; glState.glStateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS); glState.glStateBits |= (GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); #endif backEnd.projection2D = qfalse; backEnd.doneBloom = qfalse; backEnd.donepostproc = qfalse; backEnd.doneSurfaces = qfalse; return (const void *)(cmd + 1); }
/* ============= RB_SwapBuffers ============= */ const void *RB_SwapBuffers( const void *data ) { const swapBuffersCommand_t *cmd; // finish any 2D drawing if needed if ( tess.numIndexes ) { RB_EndSurface(); } // texture swapping test if ( r_showImages->integer ) { RB_ShowImages(); } cmd = (const swapBuffersCommand_t *)data; // we measure overdraw by reading back the stencil buffer and // counting up the number of increments that have happened if ( r_measureOverdraw->integer ) { int i; long sum = 0; unsigned char *stencilReadback; stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { sum += stencilReadback[i]; } backEnd.pc.c_overDraw += sum; ri.Hunk_FreeTempMemory( stencilReadback ); } if (glRefConfig.framebufferObject) { if (!backEnd.framePostProcessed) { if (tr.msaaResolveFbo && r_hdr->integer) { // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } else if (tr.renderFbo) { FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } } } if ( !glState.finishCalled ) { qglFinish(); } GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); GLimp_EndFrame(); backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; return (const void *)(cmd + 1); }
/* ============= RB_SwapBuffers ============= */ static int RB_SwapBuffers( const void *data ) { // finish any 2D drawing if needed if ( tess.numIndexes ) { RB_EndSurface(); } // texture swapping test if ( r_showImages->integer ) { RB_ShowImages(); } backEnd.projection2D = qfalse; tr.capturingDofOrStereo = qfalse; tr.latestDofOrStereoFrame = qfalse; /* Take and merge DOF frames */ if ( r_stereoSeparation->value <= 0.0f && !tr.finishStereo) { if ( R_MME_MultiPassNext() ) { return 1; } } else if ( r_stereoSeparation->value > 0.0f) { if ( R_MME_MultiPassNextStereo() ) { return 1; } } // we measure overdraw by reading back the stencil buffer and // counting up the number of increments that have happened if ( r_measureOverdraw->integer ) { int i; long sum = 0; unsigned char *stencilReadback; stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { sum += stencilReadback[i]; } backEnd.pc.c_overDraw += sum; ri.Hunk_FreeTempMemory( stencilReadback ); } if ( !glState.finishCalled ) { qglFinish(); } /* Allow MME to take a screenshot */ if ( r_stereoSeparation->value < 0.0f && tr.finishStereo) { tr.capturingDofOrStereo = qtrue; tr.latestDofOrStereoFrame = qtrue; Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value); return 1; } else if ( r_stereoSeparation->value <= 0.0f) { if ( R_MME_TakeShot( ) && r_stereoSeparation->value != 0.0f) { tr.capturingDofOrStereo = qtrue; tr.latestDofOrStereoFrame = qfalse; Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value); tr.finishStereo = qtrue; return 1; } } else if ( r_stereoSeparation->value > 0.0f) { if ( tr.finishStereo) { R_MME_TakeShotStereo( ); R_MME_DoNotTake( ); Cvar_SetValue("r_stereoSeparation", -r_stereoSeparation->value); tr.finishStereo = qfalse; } } R_FrameBuffer_EndFrame(); GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); GLimp_EndFrame(); return 0; }