/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; //printf("here 2a\n"); if ( !tr.registered ) { printf("tr.registered == false\n"); return; } //printf("here 2b\n"); cmd = R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { printf("R_GetCommandBuffer == 0\n"); return; } cmd->commandId = RC_SWAP_BUFFERS; //printf("here 2c\n"); R_IssueRenderCommands( qtrue ); //printf("here 2d\n"); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_ToggleSmpFrame(); //printf("here 2e\n"); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; //printf("here 2f\n"); }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame(int *frontEndMsec, int *backEndMsec) { renderCommandList_t *cmdList; if (!tr.registered) { return; } // Needs to use reserved space, so no R_GetCommandBuffer. cmdList = &backEndData->commands; assert(cmdList); // add swap-buffers command *( int * )(cmdList->cmds + cmdList->used) = RC_SWAP_BUFFERS; cmdList->used += sizeof(swapBuffersCommand_t); R_IssueRenderCommands(qtrue); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_InitNextFrame(); if (frontEndMsec) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if (backEndMsec) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
/* ============== CaptureRenderToFile ============== */ void idRenderSystemLocal::CaptureRenderToFile( const char *fileName, bool fixAlpha ) { if ( !glConfig.isInitialized ) { return; } renderCrop_t *rc = &renderCrops[currentRenderCrop]; guiModel->EmitFullScreen(); guiModel->Clear(); R_IssueRenderCommands(); qglReadBuffer( GL_BACK ); // include extra space for OpenGL padding to word boundaries int c = ( rc->width + 3 ) * rc->height; byte *data = (byte *)R_StaticAlloc( c * 3 ); qglReadPixels( rc->x, rc->y, rc->width, rc->height, GL_RGB, GL_UNSIGNED_BYTE, data ); byte *data2 = (byte *)R_StaticAlloc( c * 4 ); for ( int i = 0 ; i < c ; i++ ) { data2[ i * 4 ] = data[ i * 3 ]; data2[ i * 4 + 1 ] = data[ i * 3 + 1 ]; data2[ i * 4 + 2 ] = data[ i * 3 + 2 ]; data2[ i * 4 + 3 ] = 0xff; } R_WriteTGA( fileName, data2, rc->width, rc->height, true ); R_StaticFree( data ); R_StaticFree( data2 ); }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; if ( !tr.registered ) { return; } cmd = (swapBuffersCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } cmd->commandId = RC_SWAP_BUFFERS; R_IssueRenderCommands( qtrue ); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_ToggleSmpFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; for(int i=0;i<MAX_LIGHT_STYLES;i++) { styleUpdated[i] = false; } }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; if ( !tr.registered ) { return; } cmd = (swapBuffersCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } cmd->commandId = RC_SWAP_BUFFERS; R_IssueRenderCommands( qtrue ); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_InitNextFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
/* ==================== R_IssuePendingRenderCommands Issue any pending commands and wait for them to complete. ==================== */ void R_IssuePendingRenderCommands( void ) { if ( !tr.registered ) { return; } R_IssueRenderCommands( qfalse ); }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; if ( !tr.registered ) { return; } cmd = R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } cmd->commandId = RC_SWAP_BUFFERS; R_IssueRenderCommands( qtrue ); R_InitNextFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
/* ==================== R_SyncRenderThread Issue any pending commands and wait for them to complete. After exiting, the render thread will have completed its work and will remain idle and the main thread is free to issue OpenGL calls until R_IssueRenderCommands is called. ==================== */ void R_SyncRenderThread( void ) { #ifndef _XBOX if ( !tr.registered ) { return; } R_IssueRenderCommands( qfalse ); #endif }
/* ==================== R_SyncRenderThread Issue any pending commands and wait for them to complete. After exiting, the render thread will have completed its work and will remain idle and the main thread is free to issue OpenGL calls until R_IssueRenderCommands is called. ==================== */ void R_SyncRenderThread( void ) { if ( !tr.registered ) { return; } R_IssueRenderCommands( qfalse ); if ( !glConfig.smpActive ) { return; } GLimp_FrontEndSleep(); }
/* ============= EndFrame Returns the number of msec spent in the back end ============= */ void idRenderSystemLocal::EndFrame( int *frontEndMsec, int *backEndMsec, bool swapFrontBack ) { emptyCommand_t *cmd; if ( !glConfig.isInitialized ) { return; } // close any gui drawing guiModel->EmitFullScreen(); guiModel->Clear(); // save out timing information if ( frontEndMsec ) { *frontEndMsec = pc.frontEndMsec; } if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } // print any other statistics and clear all of them R_PerformanceCounters(); // check for dynamic changes that require some initialization R_CheckCvars(); // check for errors GL_CheckErrors(); // add the swapbuffers command if(swapFrontBack) { cmd = (emptyCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); cmd->commandId = RC_SWAP_BUFFERS; } // start the back end up again with the new command list R_IssueRenderCommands(); // use the other buffers next frame, because another CPU // may still be rendering into the current buffers R_ToggleSmpFrame(); // we can now release the vertexes used this frame vertexCache.EndFrame(); if ( session->writeDemo ) { session->writeDemo->WriteInt( DS_RENDER ); session->writeDemo->WriteInt( DC_END_FRAME ); if ( r_showDemo.GetBool() ) { common->Printf( "write DC_END_FRAME\n" ); } } }
/* ==================== R_SyncRenderThread Issue any pending commands and wait for them to complete. After exiting, the render thread will have completed its work and will remain idle and the main thread is free to issue OpenGL calls until R_IssueRenderCommands is called. ==================== */ void R_SyncRenderThread() { if (!tr.registered) { return; } R_IssueRenderCommands(false); if (!glConfig.smpActive) { return; } GLimp_SyncRenderThread(); }
frameInfo_t idRenderSystemLocal::LocalEndFrame() { frameInfo_t info; memset(&info, 0, sizeof(info)); if (!glConfig.isInitialized) { return info; } // close any gui drawing guiModel->EmitFullScreen(); guiModel->Clear(); // save out timing information info.time.frontEndMsec = pc.frontEndMsec; info.time.backEndMsec = backEnd.pc.msec; // print any other statistics and clear all of them R_PerformanceCounters(); // check for errors GL_CheckErrors(false); // add the swapbuffers command auto cmd = R_GetCommandBuffer<emptyCommand_t>(); cmd->commandId = RC_SWAP_BUFFERS; // start the back end up again with the new command list info.framebuffer = R_IssueRenderCommands(); // use the other buffers next frame, because another CPU // may still be rendering into the current buffers R_ToggleSmpFrame(); // we can now release the vertexes used this frame vertexCache.EndFrame(); if (session->writeDemo) { session->writeDemo->WriteInt(DS_RENDER); session->writeDemo->WriteInt(DC_END_FRAME); if (r_showDemo.GetBool()) { common->Printf("write DC_END_FRAME\n"); } } return info; }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; if ( !tr.registered ) { return; } GLimp_HandleCvars(); cmd = (swapBuffersCommand_t*) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } cmd->commandId = RC_SWAP_BUFFERS; R_IssueRenderCommands( qtrue ); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_ToggleSmpFrame(); // update the results of the vis tests R_UpdateVisTests(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
/* ============= RE_EndFrame Returns the number of msec spent in the back end ============= */ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { if ( !tr.registered ) { return; } if ( !R_GetCommandBuffer( RC_SWAP_BUFFERS, 0 ) ) { return; } R_IssueRenderCommands( qtrue ); // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_ToggleSmpFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
void __cdecl R_GenerateReflectionRawData(DiskGfxReflectionProbe* probeRawData) { if (!*g_ffDir) { sprintf_s(g_ffDir, "%s/%s/", Dvar_GetString("fs_basepath"), Dvar_GetString("fs_game")); } refdef_s refdef; char* ptr = *((char**)0x02FF5354); refdef_s* refsrc = (refdef_s*)(ptr + 0x8C100); memcpy(&refdef, refsrc, sizeof(refdef_s)); refdef.vieworg[1] = probeRawData->origin[0]; refdef.vieworg[2] = probeRawData->origin[1]; refdef.yaw = probeRawData->origin[2]; R_InitPrimaryLights(refdef.primaryLights[0].dir); for (int cubemapShot = 1; cubemapShot < 7; cubemapShot++) { R_BeginCubemapShot(256, 0); R_BeginFrame(); GfxCmdArray* s_cmdList = *(GfxCmdArray**)0x03B370C0; GfxBackEndData* frontEndDataOut = *(GfxBackEndData**)0x03B3708C; frontEndDataOut->cmds = &s_cmdList->cmds[s_cmdList->usedTotal]; frontEndDataOut->viewInfo[frontEndDataOut->viewInfoCount].cmds = NULL; R_ClearScene(0); FX_BeginUpdate(0); R_CalcCubeMapViewValues(&refdef, cubemapShot, 256); float* vec = (float*)0x3AC3060; vec[0] = refdef.vieworg[0]; vec[1] = refdef.vieworg[1]; vec[2] = refdef.vieworg[2]; int* unk1 = (int*)0x3AC3058; *unk1 = refdef.time; float* unk2 = (float*)0x3AC305C; *unk2 = refdef.time * 0.001f; R_UpdateFrameFog(refdef.localClientNum); R_UpdateFrameSun(); float zFar = R_GetFarPlaneDist(); FxCameraUpdate fxUpdateCmd; memset(&fxUpdateCmd, 0, sizeof(FxCameraUpdate)); FxCmd cmd; memset(&cmd, 0, sizeof(FxCmd)); FX_GetCameraUpdateFromRefdefAndZFar(&fxUpdateCmd, &refdef, zFar); FX_SetNextUpdateCamera(0, &fxUpdateCmd); FX_FillUpdateCmd(0, &cmd); Sys_ResetUpdateSpotLightEffectEvent(); Sys_AddWorkerCmdInternal((void*)0x00BA5420, &cmd, 0); Sys_ResetUpdateNonDependentEffectsEvent(); Sys_AddWorkerCmdInternal((void*)0x00BA52E0, &cmd, 0); Sys_AddWorkerCmdInternal((void*)0x00BA5300, &cmd, 0); Sys_AddWorkerCmdInternal((void*)0x00BA5330, &cmd, 0); R_RenderScene(&refdef, 0); R_EndFrame(); R_IssueRenderCommands(3); R_EndCubemapShot(cubemapShot); } R_CreateReflectionRawDataFromCubemapShot(probeRawData); }
void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { swapBuffersCommand_t *cmd; float x; float y; float w; float h; GLuint texID; static int b = 0; if ( !tr.registered ) { return; } cmd = R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } cmd->commandId = RC_SWAP_BUFFERS; R_IssueRenderCommands( qtrue ); //*** Rift post processing if (vr_warpingShader->integer) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); if (!backEnd.projection2D) { RB_SetGL2D(); } glViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight); // Render on the whole framebuffer, complete from the lower left corner to the upper right // Use our shader glUseProgram(glConfig.oculusProgId); glEnable(GL_TEXTURE_2D); { float VPX = 0.0f; float VPY = 0.0f; float VPW = glConfig.vidWidth; // ViewPort Width float VPH = glConfig.vidHeight; SetupShaderDistortion(0, VPX, VPY, VPW, VPH); // Left Eye } // Set our "renderedTexture" sampler to user Texture Unit 0 texID = glGetUniformLocation(glConfig.oculusProgId, "texid"); glUniform1i(texID, 0); qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight ); // if (stereoFrame == STEREO_LEFT) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, glConfig.oculusRenderTargetLeft); x = 0.0f; y = 0.0f; w = glConfig.vidWidth; h = glConfig.vidHeight; qglBegin (GL_QUADS); qglTexCoord2f( 0, 1 ); qglVertex2f( x, y ); qglTexCoord2f( 1, 1 ); qglVertex2f( x + w/2, y ); qglTexCoord2f( 1, 0 ); qglVertex2f( x + w/2, y + h ); qglTexCoord2f( 0, 0 ); qglVertex2f( x, y + h ); qglEnd(); } //else { { float VPX = 0; float VPY = 0.0f; float VPW = glConfig.vidWidth; // ViewPort Width float VPH = glConfig.vidHeight; SetupShaderDistortion(1, VPX, VPY, VPW, VPH); // Right Eye } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, glConfig.oculusRenderTargetRight); x = glConfig.vidWidth*0.5f; y = 0.0f; w = glConfig.vidWidth; h = glConfig.vidHeight; qglBegin (GL_QUADS); qglTexCoord2f( 0, 1 ); qglVertex2f( x, y ); qglTexCoord2f( 1, 1 ); qglVertex2f( x + w/2, y ); qglTexCoord2f( 1, 0 ); qglVertex2f( x + w/2, y + h ); qglTexCoord2f( 0, 0 ); qglVertex2f( x, y + h ); qglEnd(); } // unbind the GLSL program // this means that from here the OpenGL fixed functionality is used glUseProgram(0); } // use the other buffers next frame, because another CPU // may still be rendering into the current ones R_ToggleSmpFrame(); if ( frontEndMsec ) { *frontEndMsec = tr.frontEndMsec; } tr.frontEndMsec = 0; if ( backEndMsec ) { *backEndMsec = backEnd.pc.msec; } backEnd.pc.msec = 0; }
/* ==================== R_SyncRenderThread Issue any pending commands and wait for them to complete. After exiting, the render thread will have completed its work and will remain idle and the main thread is free to issue OpenGL calls until R_IssueRenderCommands is called. ==================== */ void R_SyncRenderThread( void ) { if ( !tr.registered ) { return; } R_IssueRenderCommands( qfalse ); }