static void R_MME_CheckCvars( void ) { int pixelCount, blurTotal, passTotal; mmeBlurControl_t* blurControl = &blurData.control; mmeBlurControl_t* passControl = &passData.control; pixelCount = glConfig.vidHeight * glConfig.vidWidth; if (mme_blurFrames->integer > BLURMAX) { ri.Cvar_Set( "mme_blurFrames", va( "%d", BLURMAX) ); } else if (mme_blurFrames->integer < 0) { ri.Cvar_Set( "mme_blurFrames", "0" ); } if (mme_blurOverlap->integer > BLURMAX ) { ri.Cvar_Set( "mme_blurOverlap", va( "%d", BLURMAX) ); } else if (mme_blurOverlap->integer < 0 ) { ri.Cvar_Set( "mme_blurOverlap", "0"); } if (mme_dofFrames->integer > BLURMAX ) { ri.Cvar_Set( "mme_dofFrames", va( "%d", BLURMAX) ); } else if (mme_dofFrames->integer < 0 ) { ri.Cvar_Set( "mme_dofFrames", "0"); } blurTotal = mme_blurFrames->integer + mme_blurOverlap->integer ; passTotal = mme_dofFrames->integer; if ( (mme_blurType->modified || passTotal != passControl->totalFrames || blurTotal != blurControl->totalFrames || pixelCount != mainData.pixelCount || blurControl->overlapFrames != mme_blurOverlap->integer) && !allocFailed ) { workUsed = 0; mainData.pixelCount = pixelCount; blurCreate( blurControl, mme_blurType->string, blurTotal ); blurControl->totalFrames = blurTotal; blurControl->totalIndex = 0; blurControl->overlapFrames = mme_blurOverlap->integer; blurControl->overlapIndex = 0; R_MME_MakeBlurBlock( &blurData.shot, pixelCount * 3, blurControl ); // R_MME_MakeBlurBlock( &blurData.stencil, pixelCount * 1, blurControl ); R_MME_MakeBlurBlock( &blurData.depth, pixelCount * 1, blurControl ); R_MME_JitterTable( blurData.jitter[0], blurTotal ); //Multi pass data blurCreate( passControl, "median", passTotal ); passControl->totalFrames = passTotal; passControl->totalIndex = 0; passControl->overlapFrames = 0; passControl->overlapIndex = 0; R_MME_MakeBlurBlock( &passData.dof, pixelCount * 3, passControl ); R_MME_JitterTable( passData.jitter[0], passTotal ); } mme_blurOverlap->modified = qfalse; mme_blurType->modified = qfalse; mme_blurFrames->modified = qfalse; mme_dofFrames->modified = qfalse; }
void R_MME_CheckCvars (qboolean init, shotData_t *shotData) { int pixelCount, blurTotal, passTotal; //mmeBlurControl_t* blurControl = &blurData.control; mmeBlurControl_t* passControl; passData_t *passData; if (shotData == &shotDataMain) { passControl = &passDataMain.control; passData = &passDataMain; } else if (shotData == &shotDataLeft) { passControl = &passDataLeft.control; passData = &passDataLeft; } else { ri.Error(ERR_DROP, "%s unknown shotData structure", __FUNCTION__); } pixelCount = glConfig.vidHeight * glConfig.vidWidth; if (mme_blurType->modified) { // can't just reset the specified *shotData since mme_blurType->modfied needs to be set to qfalse at this point (to avoid looping) shotDataMain.forceReset = qtrue; shotDataLeft.forceReset = qtrue; mme_blurType->modified = qfalse; //FIXME use something like shotData->lastSetBlurType } if (mme_blurFrames->integer < 0) { ri.Cvar_Set( "mme_blurFrames", "0" ); } if (mme_blurOverlap->integer < 0 ) { ri.Cvar_Set( "mme_blurOverlap", "0" ); } blurTotal = mme_blurFrames->integer + mme_blurOverlap->integer ; // blurTotal > BLURMAX:256 will overflow internal buffers if (blurTotal > BLURMAX) { ri.Printf(PRINT_ALL, "^1blurFrames + blurOverlap (%d + %d) have to be less than or equal to %d, resetting\n", mme_blurFrames->integer, mme_blurOverlap->integer, BLURMAX); ri.Cvar_Set( "mme_blurFrames", "0" ); ri.Cvar_Set( "mme_blurOverlap", "0" ); blurTotal = 0; } if (mme_dofFrames->integer > BLURMAX ) { ri.Cvar_Set( "mme_dofFrames", va( "%d", BLURMAX) ); } else if (mme_dofFrames->integer < 0 ) { ri.Cvar_Set( "mme_dofFrames", "0"); } passTotal = mme_dofFrames->integer; if (!init && (mme_blurFrames->integer != shotData->lastSetBlurFrames || mme_blurOverlap->integer != shotData->lastSetOverlapFrames || mme_dofFrames->integer != shotData->lastSetDofFrames)) { R_MME_InitMemory(qfalse, shotData); } if (!init && ((shotData->forceReset || passTotal != passControl->totalFrames || blurTotal != shotData->control.totalFrames || pixelCount != shotData->pixelCount || shotData->control.overlapFrames != mme_blurOverlap->integer) && !shotData->allocFailed)) { shotData->forceReset = qfalse; blurCreate(&shotData->control, mme_blurType->string, blurTotal); shotData->control.totalFrames = blurTotal; shotData->control.totalIndex = 0; shotData->control.overlapFrames = mme_blurOverlap->integer; shotData->control.overlapIndex = 0; if (blurTotal > 0) { if (!R_MME_MakeBlurBlock(&shotData->shot, pixelCount * 3, &shotData->control, shotData)) { ri.Printf(PRINT_ALL, "^1blur block creation failed\n"); shotData->allocFailed = qtrue; goto alloc_Skip; } } #if 0 //FIXME implement R_MME_MakeBlurBlock( &blurData.stencil, pixelCount * 1, blurControl ); R_MME_MakeBlurBlock( &blurData.depth, pixelCount * 1, blurControl ); #endif R_MME_JitterTable( shotData->jitter[0], blurTotal ); //Multi pass data blurCreate( passControl, "median", passTotal ); passControl->totalFrames = passTotal; passControl->totalIndex = 0; passControl->overlapFrames = 0; passControl->overlapIndex = 0; if (passTotal > 0) { if (!R_MME_MakeBlurBlock( &passData->dof, pixelCount * 3, passControl, shotData )) { ri.Printf(PRINT_ALL, "^1blur pass creation failed\n"); shotData->allocFailed = qtrue; goto alloc_Skip; } } R_MME_JitterTable( passData->jitter[0], passTotal ); //ri.Printf(PRINT_ALL, "^6shotData reset\n"); } alloc_Skip: shotData->pixelCount = pixelCount; }