Пример #1
0
//-----------------------------------------------------------------------------
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
{
	if (isCachePath(path))
	{
	   PROFILE_START(dumpDirectories);

	   ResourceManager->initExcludedDirectories();

	   const S32 len = dStrlen(path)+1;
	   char newpath[len];
	   dSprintf(newpath, len, "%s", path);
	   if(newpath[len - 1] == '/')
		  newpath[len - 1] = '\0'; // cut off the trailing slash, if there is one

		// Insert base path to follow what Windows does.
		if ( !noBasePath )
			directoryVector.push_back(StringTable->insert(newpath));

		bool ret = recurseDumpDirectoriesCache(newpath, "", directoryVector, depth, noBasePath);
	   PROFILE_END();

	   return ret;
	}

   PROFILE_START(dumpDirectories);
   ResourceManager->initExcludedDirectories();
   bool ret = android_DumpDirectories(path, "", directoryVector, depth, noBasePath);
   PROFILE_END();
   
   return ret;
}
Пример #2
0
//-----------------------------------------------------------------------------
bool Platform::dumpPath(const char *path, Vector<Platform::FileInfo>& fileVector, S32 depth)
{
	if (isCachePath(path))
	{
		PROFILE_START(dumpPath);
		const S32 len = dStrlen(path) + 1;
	    char newpath[255];

		strcpy(newpath, path);

	   if(newpath[len - 2] == '/')
		  newpath[len - 2] = '\0'; // cut off the trailing slash, if there is one

	   bool ret = recurseDumpPathCache( newpath, fileVector, depth);
	   PROFILE_END();

	   return ret;
	}

   PROFILE_START(dumpPath);
   bool ret = android_DumpPath( path, fileVector, depth);
   PROFILE_END();
   
   return ret;
}
Пример #3
0
int main (int argc, char **argv)
{
  struct sockaddr_in sa;
  int    rc, i;

  if (argc != 2)
  {
    printf ("Usage: %s num-sockets", argv[0]);
    return (0);
  }
  max_socks = atoi (argv[1]);
  if (max_socks == 0)
  {
    printf ("Usage: %s num-sockets", argv[0]);
    return (0);
  }

  setup();
  socks = calloc (max_socks, sizeof(int));
  assert (socks != NULL);

  for (i = 0; i < max_socks; i++)
  {
    PROFILE_START ("socket");
    socks[i] = socket (AF_INET, SOCK_STREAM, 0);
    PROFILE_STOP();
    if (socks[i] < 0)
    {
      perror ("socket");
      max_socks = i;
      break;
    }
  }

  for (i = 0; i < max_socks; i++)
  {
    sa.sin_family      = AF_INET;
    sa.sin_port        = htons (test_port);
    sa.sin_addr.s_addr = INADDR_ANY;
    PROFILE_START ("bind");
    rc = bind (socks[i], (struct sockaddr*)&sa, sizeof(sa));
    PROFILE_STOP();
    if (rc < 0)
    {
      perror ("bind");
      break;
    }
  }

  for (i = 0; i < max_socks; i++)
  {
    PROFILE_START ("close_s");
    close_s (socks[i]);
    PROFILE_STOP();
  }
  free (socks);
  return (0);
}
Пример #4
0
void TerrainRenderer::RenderTerrainShader(const CShaderDefines& context, ShadowMap* shadow, bool filtered)
{
	ENSURE(m->phase == Phase_Render);

	std::vector<CPatchRData*>& visiblePatches = filtered ? m->filteredPatches : m->visiblePatches;
	std::vector<CDecalRData*>& visibleDecals = filtered ? m->filteredDecals : m->visibleDecals;
	if (visiblePatches.empty() && visibleDecals.empty())
		return;

	// render the solid black sides of the map first
	CShaderTechniquePtr techSolid = g_Renderer.GetShaderManager().LoadEffect(str_gui_solid);
	techSolid->BeginPass();
	CShaderProgramPtr shaderSolid = techSolid->GetShader();
	shaderSolid->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
	shaderSolid->Uniform(str_color, 0.0f, 0.0f, 0.0f, 1.0f);

	PROFILE_START("render terrain sides");
	for (size_t i = 0; i < visiblePatches.size(); ++i)
		visiblePatches[i]->RenderSides(shaderSolid);
	PROFILE_END("render terrain sides");

	techSolid->EndPass();

	PROFILE_START("render terrain base");
	CPatchRData::RenderBases(visiblePatches, context, shadow);
	PROFILE_END("render terrain base");

	// no need to write to the depth buffer a second time
	glDepthMask(0);

	// render blend passes for each patch
	PROFILE_START("render terrain blends");
	CPatchRData::RenderBlends(visiblePatches, context, shadow, false);
	PROFILE_END("render terrain blends");

	PROFILE_START("render terrain decals");
	CDecalRData::RenderDecals(visibleDecals, context, shadow, false);
	PROFILE_END("render terrain decals");

	// restore OpenGL state
	g_Renderer.BindTexture(1, 0);
	g_Renderer.BindTexture(2, 0);
	g_Renderer.BindTexture(3, 0);

	glDepthMask(1);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDisable(GL_BLEND);
}
void GroupOfPlanes::SearchMVs(MVGroupOfFrames *pSrcGOF, MVGroupOfFrames *pRefGOF,
                              SearchType searchType, int nSearchParam, int nPelSearch, int nLambda,
                              int lsad, int pnew, int plevel, bool global, int flags,
							  int *out, short *outfilebuf, int fieldShift, DCTClass * _DCT, int pzero, int pglobal, int badSAD, int badrange)
{
	int i;

   nFlags |= flags;

   // write group's size
   out[0] = GetArraySize();

   // write validity : 1 in that case
   out[1] = 1;

   out += 2;

   int fieldShiftCur = (nLevelCount - 1 == 0) ? fieldShift : 0; // may be non zero for finest level only

   VECTOR globalMV; // create and init global motion vector as zero
   globalMV.x = zeroMV.x;
   globalMV.y = zeroMV.y;
   globalMV.sad = zeroMV.sad;

   if (!global)
        pglobal = pzero;

   int meanLumaChange = 0;

	// Search the motion vectors, for the low details interpolations first
	// Refining the search until we reach the highest detail interpolation.
//         DebugPrintf("SearchMV level %i", nLevelCount-1);
   planes[nLevelCount - 1]->SearchMVs(pSrcGOF->GetFrame(nLevelCount-1),
                                      pRefGOF->GetFrame(nLevelCount-1),
                                      searchType, nSearchParam, nLambda, lsad, pnew, plevel, flags,
									  out, &globalMV, outfilebuf, fieldShiftCur, _DCT, &meanLumaChange, divideExtra,
									  pzero, pglobal, badSAD, badrange);

   out += planes[nLevelCount - 1]->GetArraySize(divideExtra);

	for ( i = nLevelCount - 2; i >= 0; i-- )
	{
	    int nSearchParamLevel = (i==0) ? nPelSearch : nSearchParam; // special case for finest level
         PROFILE_START(MOTION_PROFILE_PREDICTION);
		if (global)
		{
		   planes[i+1]->EstimateGlobalMVDoubled(&globalMV); // get updated global MV (doubled)
//        DebugPrintf("SearchMV globalMV %i, %i", globalMV.x, globalMV.y);
		}
		planes[i]->InterpolatePrediction(*(planes[i+1]));
         PROFILE_STOP(MOTION_PROFILE_PREDICTION);
	    fieldShiftCur = (i == 0) ? fieldShift : 0; // may be non zero for finest level only
 //        DebugPrintf("SearchMV level %i", i);
		planes[i]->SearchMVs(pSrcGOF->GetFrame(i), pRefGOF->GetFrame(i),
              searchType, nSearchParamLevel, nLambda, lsad, pnew, plevel, flags,
			  out, &globalMV, outfilebuf, fieldShiftCur, _DCT, &meanLumaChange, divideExtra,
			  pzero, pglobal, badSAD, badrange);
      out += planes[i]->GetArraySize(divideExtra);
	}
}
static void
TestFIA_IOLoadColourArrayData(CuTest* tc)
{
	FIBITMAP *dib1 = NULL, *dib2 = NULL;
	FREE_IMAGE_TYPE type;
	int bpp, err;
    
	const char *file = "C:\\cup.tif";
	dib1 = FIA_LoadFIBFromFile(file);

	CuAssertTrue(tc, dib1 != NULL);

	dib2 = FreeImage_AllocateT (FIT_BITMAP, FreeImage_GetWidth(dib1), FreeImage_GetHeight(dib1), 8, 0, 0, 0);

	PROFILE_START("CopyColourBytesToFIBitmap");

	for(int i=0; i < 1000; i++) {

		//FIA_CopyColourBytesToFIBitmap (dib2, FreeImage_GetBits(dib1), 0, 1, COLOUR_ORDER_RGB);
		FIA_CopyColourBytesTo8BitFIBitmap (dib2, FreeImage_GetBits(dib1), 24, FI_RGBA_RED, 0, 1);

	}

	PROFILE_STOP("CopyColourBytesToFIBitmap");

	FIA_SaveFIBToFile (dib2, TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp", BIT8);

	FreeImage_Unload(dib1);
	FreeImage_Unload(dib2);
}
Пример #7
0
void SortModelRenderer::PrepareModels()
{
    CMatrix3D worldToCam;

    if (m->models.size() == 0)
        return;

    g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam);

    for(std::vector<SModel*>::iterator it = m->models.begin(); it != m->models.end(); ++it)
    {
        SModel* smdl = *it;
        CModel* model = smdl->GetModel();

        ENSURE(model->GetRenderData() == smdl);

        m->vertexRenderer->UpdateModelData(model, smdl->m_Data, smdl->m_UpdateFlags);
        smdl->m_UpdateFlags = 0;

        CVector3D modelpos = model->GetTransform().GetTranslation();

        modelpos = worldToCam.Transform(modelpos);

        smdl->m_Distance = modelpos.Z;
    }

    PROFILE_START( "sorting transparent" );
    std::sort(m->models.begin(), m->models.end(), SortModelsByDist());
    PROFILE_END( "sorting transparent" );
}
Пример #8
0
void SceneRenderState::renderObjects( SceneObject** objects, U32 numObjects )
{
   // Let the objects batch their stuff.

   PROFILE_START( SceneRenderState_prepRenderImages );
   for( U32 i = 0; i < numObjects; ++ i )
   {
      SceneObject* object = objects[ i ];
      object->prepRenderImage( this );
   }

#ifdef TORQUE_EXPERIMENTAL_EC
   U32 interfaceCount = RenderComponentInterface::all.size();
   for (U32 i = 0; i < RenderComponentInterface::all.size(); i++)
   {
      Component* comp = dynamic_cast<Component*>(RenderComponentInterface::all[i]);

      if (comp->isClientObject() && comp->isActive())
      {
         RenderComponentInterface::all[i]->prepRenderImage(this);
      }
   }
#endif

   PROFILE_END();

   // Render what the objects have batched.

   getRenderPass()->renderPass( this );
}
Пример #9
0
// This function takes a lot of CPU, so make sure it's not called often!  Don't call this function directly, use UpdateEnemy instead whenever possible.
CBaseEntity* AvHTurret::FindBestEnemy()
{
    PROFILE_START()
	CBaseEntity* theEntityList[100];
	
	int theMaxRange = this->GetXYRange();
	
	Vector delta = Vector(theMaxRange, theMaxRange, theMaxRange);
	CBaseEntity* theCurrentEntity = NULL;
	CBaseEntity* theBestPlayer = NULL;
	CBaseEntity* theBestStructure = NULL;

	float theCurrentEntityRange = 100000;
	
	// Find only monsters/clients in box, NOT limited to PVS
	int theCount = UTIL_EntitiesInBox(theEntityList, 100, this->pev->origin - delta, this->pev->origin + delta, FL_CLIENT | FL_MONSTER);
	for(int i = 0; i < theCount; i++ )
	{
		theCurrentEntity = theEntityList[i];
		if((theCurrentEntity != this) && theCurrentEntity->IsAlive())
		{
			// the looker will want to consider this entity
			// don't check anything else about an entity that can't be seen, or an entity that you don't care about.
			if(this->IRelationship(theCurrentEntity ) != R_NO && FInViewCone(theCurrentEntity) && !FBitSet(theCurrentEntity->pev->flags, FL_NOTARGET))
			{
				AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theCurrentEntity);
				if(!thePlayer || thePlayer->GetCanBeAffectedByEnemies())
				{
					if(this->GetIsValidTarget(theCurrentEntity))
					{
						// Find nearest enemy
						float theRangeToTarget = VectorDistance2D(this->pev->origin, theCurrentEntity->pev->origin);
						if(theRangeToTarget < theCurrentEntityRange)
						{
                            // FVisible is expensive, so defer until necessary
                            if(!this->GetRequiresLOS() || FVisible(theCurrentEntity))
                            {
                                theCurrentEntityRange = theRangeToTarget;
								if ( thePlayer ) 
								{
									theBestPlayer = theCurrentEntity;
								}
								else
								{
									theBestStructure = theCurrentEntity;
								}
                            }
						}
					}
				}
			}
		}
	}
    PROFILE_END(kAvHTurretFindBestEnemy);

	return (theBestPlayer != NULL ) ? theBestPlayer : theBestStructure;
}
Пример #10
0
/**
 * Combined threads and events loop.
 *
 * The loop processes first threads (_prepare_cb), then events
 * (ev_stat_cb, ev_io_cb). It sleeps until the earliest thread resume
 * time, or an I/O event occurs.
 *
 */
int
mrkthr_loop(void)
{
    int res;

    PROFILE_START(mrkthr_sched0_p);
    res = ev_run(the_loop, 0);
    PROFILE_STOP(mrkthr_sched0_p);
    return res;
}
Пример #11
0
void SceneObject::setRenderTransform(const MatrixF& mat)
{
   PROFILE_START(SceneObj_setRenderTransform);
   mRenderObjToWorld = mRenderWorldToObj = mat;
   mRenderWorldToObj.affineInverse();

   AssertFatal(mObjBox.isValidBox(), "Bad object box!");
   resetRenderWorldBox();
   PROFILE_END();
}
Пример #12
0
void AtlasClipMapBatcher::sort()
{
   PROFILE_START(AtlasClipMapBatcher_sort);

   // Sort our elements. The other lists are already good to go, and there's
   // no benefit to drawing them in a specific order as this pass (the first
   // pass) will already set up the Z buffer.
   for(S32 i=1; i<4; i++)
      dQsort(mRenderList[i].address(),mRenderList[i].size(),sizeof(RenderNote*),cmpRenderNote);

   PROFILE_END();
}
bool WindEmitter::findBest(   const Point3F& cameraPos, 
                              const VectorF& cameraDir,
                              F32 viewDistance,
                              U32 maxResults,
                              WindEmitterList* results )
{
   PROFILE_START(WindEmitter_findBest);

   // Build a sphere from the camera point.
	SphereF cameraSphere;
   cameraSphere.center = cameraPos;
   cameraSphere.radius = viewDistance;

   // Collect the active spheres within the camera space and score them.
   WindEmitterList best;
   WindEmitterList::iterator iter = smAllEmitters.begin();
   for ( ; iter != smAllEmitters.end(); iter++ )
   {        
      const SphereF& sphere = *(*iter);

      // Skip any spheres outside of our camera range or that are disabled.
      if ( !(*iter)->mEnabled || !cameraSphere.isIntersecting( sphere ) )
         continue;

      // Simple score calculation...
      //
      // score = ( radius / distance to camera ) * dot( cameraDir, vector from camera to sphere )
      //
      Point3F vect = sphere.center - cameraSphere.center;
      F32 dist = vect.len();
      (*iter)->mScore = dist * sphere.radius;
      vect /= getMax( dist, 0.001f );
      (*iter)->mScore *= mDot( vect, cameraDir );

      best.push_back( *iter );
   }

   // Sort the results by score!
   dQsort( best.address(), best.size(), sizeof(WindEmitter*), &WindEmitter::_sortByScore );

   // Clip the results to the max requested.
   if ( best.size() > maxResults )
      best.setSize( maxResults );

   // Merge the results and return.
   results->merge( best );

   PROFILE_END(); // WindEmitter_findBest

   return best.size() > 0;
}
Пример #14
0
void AtlasClipMapBatcher::renderClipMap( SceneGraphData& sgData, BaseMatInstance* overrideMat )
{
   PROFILE_START(AtlasClipMapBatcher_renderClipMap);

   for(S32 curBin=1; curBin<4; curBin++)
   {
      // If bin is empty, skip.
      if(mRenderList[curBin].size() == 0)
         continue;

      for(S32 i=0; i<mRenderList[curBin].size(); i++)
      {
         // Grab the render note.
         const RenderNote *rn = mRenderList[curBin][i];

         // Set up clipmap levels.
         if( !mFixedFunction )
         {
            BaseMatInstance* material = overrideMat;
            if( !material )
               switch( rn->levelCount )
               {
               case 2:     material = mClipMap->getMaterialAndTextures( rn->levelEnd, rn->levelStart, -1, -1, false ); break;
               case 3:     material = mClipMap->getMaterialAndTextures( rn->levelEnd, rn->levelStart + 1, rn->levelStart, -1, false ); break;
               case 4:     material = mClipMap->getMaterialAndTextures( rn->levelEnd, rn->levelStart + 2, rn->levelStart + 1, rn->levelStart, false ); break;
               default:    material = MaterialManager::get()->getWarningMatInstance();
               }

            while( material->setupPass( mState, sgData ) )
               rn->chunk->render();
         }
         else
         {
            Point4F clipmapMapping;
            for( U32 curLayer = rn->levelEnd; curLayer >= rn->levelStart; -- curLayer )
            {
               BaseMatInstance* material = overrideMat;
               if( !material )
                  material = mClipMap->bindTexturesFF( curLayer, clipmapMapping, curLayer == rn->levelEnd, false );

               while( material->setupPass( mState, sgData ) )
                  rn->chunk->render();
            }
         }
      }
   }

   PROFILE_END();
}
Пример #15
0
// Updated transforms
void PolygonSortModelRenderer::UpdateModelData(CModel* model, void* data, int updateflags)
{
    PSModel* psmdl = (PSModel*)data;

    if (updateflags & (RENDERDATA_UPDATE_VERTICES|RENDERDATA_UPDATE_COLOR))
    {
        CModelDefPtr mdef = model->GetModelDef();
        size_t numVertices = mdef->GetNumVertices();

        // build vertices

        // allocate working space for computing normals
        if (numVertices > m->normalsNumVertices)
        {
            rtl_FreeAligned(m->normals);

            size_t newSize = round_up_to_pow2(numVertices);
            m->normals = (char*)rtl_AllocateAligned(newSize*16, 16);
            m->normalsNumVertices = newSize;
        }

        VertexArrayIterator<CVector3D> Position = psmdl->m_Position.GetIterator<CVector3D>();
        VertexArrayIterator<CVector3D> Normal = VertexArrayIterator<CVector3D>(m->normals, 16);

        ModelRenderer::BuildPositionAndNormals(model, Position, Normal);

        VertexArrayIterator<SColor4ub> Color = psmdl->m_Color.GetIterator<SColor4ub>();

        ModelRenderer::BuildColor4ub(model, Normal, Color);

        // upload everything to vertex buffer
        psmdl->m_Array.Upload();
    }

    // resort model indices from back to front, according to the view camera position - and store
    // the returned sqrd distance to the centre of the nearest triangle
    // Use the view camera instead of the cull camera because:
    //  a) polygon sorting implicitly uses the view camera (and changing that would be costly)
    //  b) using the cull camera is likely not interesting from a debugging POV
    PROFILE_START( "sorting transparent" );

    CMatrix3D worldToCam;
    g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam);

    psmdl->BackToFrontIndexSort(worldToCam);
    PROFILE_END( "sorting transparent" );
}
Пример #16
0
void GFXD3D9QueryFence::issue()
{
   PROFILE_START( GFXD3D9QueryFence_issue );

   // Create the query if we need to
   if( mQuery == NULL )
   {
      HRESULT hRes = static_cast<GFXD3D9Device *>( mDevice )->getDevice()->CreateQuery( D3DQUERYTYPE_EVENT, &mQuery );

      AssertFatal( hRes != D3DERR_NOTAVAILABLE, "Hardware does not support D3D9 Queries, this should be caught before this fence type is created" );
      AssertISV( hRes != E_OUTOFMEMORY, "Out of memory" );
   }

   // Issue the query
   mQuery->Issue( D3DISSUE_END );

   PROFILE_END();
}
static void
TestFIA_ErosionTest(CuTest* tc)
{
	const char *file = TEST_DATA_DIR "\\morpholology_test.bmp";

	FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);
	
	CuAssertTrue(tc, dib1 != NULL);
	
	FIBITMAP *threshold_dib = FreeImage_Threshold(dib1, 20);

	CuAssertTrue(tc, threshold_dib != NULL);

	FIBITMAP *threshold_8bit_dib = FreeImage_ConvertTo8Bits(threshold_dib);

	CuAssertTrue(tc, threshold_8bit_dib != NULL);

	FIABITMAP *border_dib = FIA_SetBorder(threshold_8bit_dib, 2, 2
        , BorderType_Constant, 0.0);

	PROFILE_START("ErosionFilter");

	FilterKernel kernel = FIA_NewKernel(2, 2, kernel_values, 1.0);

	FIBITMAP* result_dib = FIA_BinaryErosion(border_dib, kernel);

	CuAssertTrue(tc, result_dib != NULL);

	PROFILE_STOP("ErosionFilter");

	FIA_SaveFIBToFile(result_dib, TEST_DATA_OUTPUT_DIR "\\erosion_result.jpg", BIT24);

	result_dib = FIA_BinaryInnerBorder(threshold_8bit_dib);

	FIA_SimpleSaveFIBToFile(result_dib, TEST_DATA_OUTPUT_DIR "morphology/inner_border_result.bmp");

	FreeImage_Unload(dib1);
	FreeImage_Unload(threshold_dib);
	FreeImage_Unload(threshold_8bit_dib);
	FIA_Unload(border_dib);
	FreeImage_Unload(result_dib);
}
Пример #18
0
std::string cache_read() {
	PROFILE_FUNC();

	std::string data;

	PROFILE_START(action_find); // Starts new action which will be inner to ACTION_READ
	bool found = find_record();
	PROFILE_STOP(action_find);

	if (!found) {
		PROFILE_BLOCK(load_from_disk);

		data = read_from_disk();
		put_into_cache(data);
		return data; // Here all action guards are destructed and actions are correctly finished
	}
	data = load_from_cache();

	return data;
}
static void TestFIA_HistogramTest(CuTest* tc)
{
    const char *file= TEST_DATA_DIR "drone-bee-greyscale.jpg";
    
    FIBITMAP *dib = FIA_LoadFIBFromFile(file);
    
    CuAssertTrue(tc, dib != NULL);
    
    unsigned long hist[256];
    
    PROFILE_START("FreeImageAlgorithms_Histogram");
    
    if (FIA_Histogram(dib, 0, 255, 2, hist) == FIA_ERROR) {
        CuFail(tc, "Failed");
    }
    
    PROFILE_STOP("FreeImageAlgorithms_Histogram");
    
    FreeImage_Unload(dib);
}
static void TestFIA_CentroidTest(CuTest* tc)
{
    const char *file= TEST_DATA_DIR "drone-bee-greyscale.jpg";
    
    FIBITMAP *dib = FIA_LoadFIBFromFile(file);
    
    CuAssertTrue(tc, dib != NULL);
    
    PROFILE_START("FreeImageAlgorithms_StatisticReport");
    
    float x_centroid, y_centroid;
    
    if (FIA_Centroid(dib, &x_centroid, &y_centroid) == FIA_ERROR) {
        CuFail(tc, "Failed");
    }
    
    PROFILE_STOP("FreeImageAlgorithms_StatisticReport");
    
    FreeImage_Unload(dib);
}
Пример #21
0
void ProcessList::advanceObjects()
{
   PROFILE_START(ProcessList_AdvanceObjects);

   // A little link list shuffling is done here to avoid problems
   // with objects being deleted from within the process method.
   ProcessObject list;
   list.plLinkBefore(mHead.mProcessLink.next);
   mHead.plUnlink();
   for (ProcessObject * pobj = list.mProcessLink.next; pobj != &list; pobj = list.mProcessLink.next)
   {
      pobj->plUnlink();
      pobj->plLinkBefore(&mHead);
      
      onTickObject(pobj);
   }

   mTotalTicks++;

   PROFILE_END();
}
Пример #22
0
void MVFlowInter::ProcessFrameIntoGroupOfFrames(PMVGroupOfFrames *srcGOF, PVideoFrame *src, PVideoFrame *src2x, 
                                                int const Sharp, int const pixelType, int const nHeight, int const nWidth, 
                                                int const nPel, bool const isse)
{
    (*srcGOF)->ConvertVideoFrame(src, src2x, pixelType, nWidth, nHeight, nPel, isse);

    PROFILE_START(MOTION_PROFILE_INTERPOLATION);

    if (*src2x) {
        // do nothing
    }
    else {
        (*srcGOF)->Pad(YUVPLANES);
        (*srcGOF)->Refine(YUVPLANES, Sharp);
    }

    PROFILE_STOP(MOTION_PROFILE_INTERPOLATION);

    // set processed
    (*srcGOF)->SetProcessed();
}
Пример #23
0
void AtlasClipMapBatcher::init(ClipMap *acm, SceneState *state, AtlasInstance *renderer)
{
   PROFILE_START(AtlasClipMapBatcher_init);

   // Note our render state.
   mClipMap = acm;
   mState = state;
   mObject = renderer;
   
   // Empty the render lists...
   for(S32 i=1; i<4; i++)
      mRenderList[i].clear();
   mDetailList.clear();
   mLightList.clear();
   mFogList.clear();

   // And clear the render notes.
   mRenderNoteAlloc.freeBlocks();

   PROFILE_END();
}
Пример #24
0
   void vertexBufferCopy(vertexType vtype)
   {
      PROFILE_SCOPE(Terrain_vbufferCopy);

      // Do vertexes
      if (vtype == vertexTypeFullClipMapping)
      {
         GVertexBufferHandle<GAtlasVert2>  v(GRAPHIC, mCurVertex, GBufferTypeVolatile);
         PROFILE_START(Terrain_bufferCopy_lockV);
         v.lock();
         PROFILE_END();

         dMemcpy(&v[0], &mVertexStore[0], sizeof(GAtlasVert2) * mCurVertex);

         PROFILE_START(Terrain_bufferCopy_unlockV);
         v.unlock();
         PROFILE_END();
         GRAPHIC->setVertexBuffer(v);
      }
      else if (vtype == vertexTypeDLight)
      {
         GVertexBufferHandle<GVertexPCNTT> vPCNTT(GRAPHIC, mCurVertex, GBufferTypeVolatile);
         PROFILE_START(Terrain_bufferCopy_lockVPCNTT);
         vPCNTT.lock();
         PROFILE_END();

         dMemcpy(&vPCNTT[0], &mVertexStorePCNTT[0], sizeof(GVertexPCNTT) * mCurVertex);

         PROFILE_START(Terrain_bufferCopy_unlockVPCNTT);
         vPCNTT.unlock();
         PROFILE_END();
         GRAPHIC->setVertexBuffer(vPCNTT);
      }
      else
      {
         GVertexBufferHandle<GVertexPCNT> vPCNT(GRAPHIC, mCurVertex, GBufferTypeVolatile);
         PROFILE_START(Terrain_bufferCopy_lockVPCNT);
         vPCNT.lock();
         PROFILE_END();

         dMemcpy(&vPCNT[0], &mVertexStorePCNT[0], sizeof(GVertexPCNT) * mCurVertex);

         PROFILE_START(Terrain_bufferCopy_unlockVPCNT);
         vPCNT.unlock();
         PROFILE_END();
         GRAPHIC->setVertexBuffer(vPCNT);
      }
   }
Пример #25
0
bool ProcessList::advanceTime(SimTime timeDelta)
{
   PROFILE_START(ProcessList_AdvanceTime);

   // some drivers change the FPU control state, which will break our control object simulation
   // (leading to packet mismatch errors due to small FP differences).  So set it to the known 
   // state before advancing.
   // TODO: revisit this.
   //U32 mathState = Platform::getMathControlState();
   //Platform::setMathControlStateKnown();

   if (mDirty) 
      orderList();

   SimTime targetTime = mLastTime + timeDelta;
   SimTime targetTick = targetTime - (targetTime % TickMs);
   SimTime tickDelta = targetTick - mLastTick;
   bool tickPass = mLastTick != targetTick;

   if ( tickPass )
      mPreTick.trigger();

   // Advance all the objects.
   for (; mLastTick != targetTick; mLastTick += TickMs)
      onAdvanceObjects();

   mLastTime = targetTime;
   mLastDelta = ((TickMs - ((targetTime+1) % TickMs)) % TickMs) / F32(TickMs);

   if ( tickPass )
      mPostTick.trigger( tickDelta );

   // restore math control state in case others are relying on it being a certain value
   // TODO: revisit this.
   //Platform::setMathControlState(mathState);

   PROFILE_END();
   return tickPass;
}
Пример #26
0
//-----------------------------------------------------------------------------
U32 convertUTF16toUTF8( const UTF16 *unistring, UTF8  *outbuffer, U32 len)
{
   AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator.");
   PROFILE_START(convertUTF16toUTF8);
   U32 walked, nCodeunits, codeunitLen;
   UTF32 middleman;
   
   nCodeunits=0;
   while( *unistring != '\0' && nCodeunits + 3 < len )
   {
      walked = 1;
      middleman  = oneUTF16toUTF32(unistring,&walked);
      codeunitLen = oneUTF32toUTF8(middleman, &outbuffer[nCodeunits]);
      unistring += walked;
      nCodeunits += codeunitLen;
   }

   nCodeunits = getMin(nCodeunits,len - 1);
   outbuffer[nCodeunits] = '\0';
   
   PROFILE_END();
   return nCodeunits;
}
Пример #27
0
/*
 * Our WinPcap send function.
 * Not sure if partial writes are possible with NPF. Retry if rc != length.
 */
int pkt_send (const void *tx, int length)
{
  const ADAPTER *adapter;
  PACKET pkt;
  int    tx_cnt, rc = 0;

  ASSERT_PKT_INF (0);

  adapter = (const ADAPTER*) _pkt_inf->adapter;

  PROFILE_START ("pkt_send");

  for (tx_cnt = 1 + pkt_txretries; tx_cnt > 0; tx_cnt--)
  {
    pkt.Buffer = (void*) tx;
    pkt.Length = length;
    if (PacketSendPacket (adapter, &pkt, TRUE))
    {
      rc = length;
      break;
    }
    STAT (macstats.num_tx_retry++);
  }

  if (rc == length)
  {
    num_tx_pkt++;
    num_tx_bytes += length;
  }
  else
  {
    num_tx_errors++;  /* local copy */
    STAT (macstats.num_tx_err++);
  }
  PROFILE_STOP();
  return (rc);
}
Пример #28
0
bool StandardMainLoop::doMainLoop()
{
   #ifdef TORQUE_DEBUG
   if( gStartupTimer )
   {
      Con::printf( "Started up in %.2f seconds...",
         F32( gStartupTimer->getElapsedMs() ) / 1000.f );
      SAFE_DELETE( gStartupTimer );
   }
   #endif
   
   bool keepRunning = true;
//   while(keepRunning)
   {
      tm->setBackgroundThreshold(mClamp(sgBackgroundProcessSleepTime, 1, 200));
      tm->setForegroundThreshold(mClamp(sgTimeManagerProcessInterval, 1, 200));
      // update foreground/background status
      if(WindowManager->getFirstWindow())
      {
         static bool lastFocus = false;
         bool newFocus = ( WindowManager->getFocusedWindow() != NULL );
         if(lastFocus != newFocus)
         {
#ifndef TORQUE_SHIPPING
            Con::printf("Window focus status changed: focus: %d", newFocus);
            if (!newFocus)
               Con::printf("  Using background sleep time: %u", Platform::getBackgroundSleepTime());
#endif

#ifdef TORQUE_OS_MAC
            if (newFocus)
               WindowManager->getFirstWindow()->show();
               
#endif
            lastFocus = newFocus;
         }
         
#ifndef TORQUE_OS_MAC         
         // under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
         if (!Platform::getWebDeployment())
            tm->setBackground(!newFocus);
         else
            tm->setBackground(false);
#else
         tm->setBackground(false);
#endif
      }
      else
      {
         tm->setBackground(false);
      }
      
      PROFILE_START(MainLoop);
      Sampler::beginFrame();

      if(!Process::processEvents())
         keepRunning = false;

      ThreadPool::processMainThreadWorkItems();
      Sampler::endFrame();
      PROFILE_END_NAMED(MainLoop);
   }
   
   return keepRunning;
}
Пример #29
0
// Process a time event and update all sub-processes
void processTimeEvent(S32 elapsedTime)
{
   PROFILE_START(ProcessTimeEvent);

   // If recording a video and not playinb back a journal, override the elapsedTime
   if (VIDCAP->isRecording() && !Journal::IsPlaying())
      elapsedTime = VIDCAP->getMsPerFrame();   
   
   // cap the elapsed time to one second
   // if it's more than that we're probably in a bad catch-up situation
   if(elapsedTime > 1024)
      elapsedTime = 1024;
   
   U32 timeDelta;
   if(ATTS(gTimeAdvance))
      timeDelta = ATTS(gTimeAdvance);
   else
      timeDelta = (U32) (elapsedTime * ATTS(gTimeScale));
   
   Platform::advanceTime(elapsedTime);
   
   // Don't build up more time than a single tick... this makes the sim
   // frame rate dependent but is a useful hack for singleplayer.
   if ( ATTS(gFrameSkip) )
      if ( timeDelta > TickMs )
         timeDelta = TickMs;

   bool tickPass;
   
   PROFILE_START(ServerProcess);
   tickPass = serverProcess(timeDelta);
   PROFILE_END();
   
   PROFILE_START(ServerNetProcess);
   // only send packets if a tick happened
   if(tickPass)
      GNet->processServer();
   // Used to indicate if server was just ticked.
   Con::setBoolVariable( "$pref::hasServerTicked", tickPass );
   PROFILE_END();

   
   PROFILE_START(SimAdvanceTime);
   Sim::advanceTime(timeDelta);
   PROFILE_END();
   
   PROFILE_START(ClientProcess);
   tickPass = clientProcess(timeDelta);
   // Used to indicate if client was just ticked.
   Con::setBoolVariable( "$pref::hasClientTicked", tickPass );
   PROFILE_END_NAMED(ClientProcess);
   
   PROFILE_START(ClientNetProcess);
   if(tickPass)
      GNet->processClient();
   PROFILE_END();
   
   GNet->checkTimeouts();
   
   gFPS.update();

   // Give the texture manager a chance to cleanup any
   // textures that haven't been referenced for a bit.
   if( GFX )
      TEXMGR->cleanupCache( 5 );

   PROFILE_END();
   
   // Update the console time
   Con::setFloatVariable("Sim::Time",F32(Platform::getVirtualMilliseconds()) / 1000);
}
bool QuadTreeTracer::castRay(const Point3F &start, const Point3F &end, RayInfo *info)
{
   PROFILE_START(QuadTreeTracer_castRay);

   // Do some precalculations we'll use for the rest of this routine.
   // Set up our intercept calculation methods.
   F32 invDeltaX;
   if(end.x == start.x)
   {
      calcInterceptX = calcInterceptNone;
      invDeltaX = 0;
   }
   else
   {
      invDeltaX = 1.f / (end.x - start.x);
      calcInterceptX = calcInterceptV;
   }

   F32 invDeltaY;
   if(end.y == start.y)
   {
      calcInterceptY = calcInterceptNone;
      invDeltaY = 0;
   }
   else
   {
      invDeltaY = 1.f / (end.y - start.y);
      calcInterceptY = calcInterceptV;
   }

   // Subdivide our space based on the size of the lowest level of the tree...
   const F32 invSize   = 1.f / F32(BIT(mTreeDepth-1));

   // Grab this off the frame allocator, we don't want to do a proper alloc
   // on every ray!
   FrameAllocatorMarker stackAlloc;
   RayStackNode *stack = (RayStackNode*)stackAlloc.alloc(sizeof(RayStackNode) * (mTreeDepth * 3 + 1));

   U32 stackSize = 1;

   // Kick off the stack with the root node.
   stack[0].startT   = 0;
   stack[0].endT     = 1;
   stack[0].squarePos.set(0,0);
   stack[0].level    = mTreeDepth - 1;

   //Con::printf("QuadTreeTracer::castRay(%x)", this);

   // Aright, now let's do some raycasting!
   while(stackSize--)
   {
      // Get the current node for easy access...
      RayStackNode *sn = stack + stackSize;

      const U32 level         = sn->level;
      const F32 startT        = sn->startT;
      const F32 endT          = sn->endT;
      const Point2I squarePos = sn->squarePos;

      AssertFatal((startT >= 0.f) && (startT <= 1.f),  "QuadTreeTracer::castRay - out of range startT on stack!");
      AssertFatal((endT >= 0.f) && (endT <= 1.f),     "QuadTreeTracer::castRay - out of range endT   on stack!");

      //Con::printf(" -- node(%d, %d @ %d), sT=%f, eT=%f", squarePos.x, squarePos.y, level, startT, endT);

      // Figure our start and end Z.
      const F32 startZ = startT * (end.z - start.z) + start.z;
      const F32 endZ   = endT   * (end.z - start.z) + start.z;

      // Ok, now let's see if we hit the lower bound
      const F32 squareMin = getSquareMin(level, squarePos);

      if(startZ < squareMin && endZ < squareMin)
         continue; //Nope, skip out.

      // Hmm, let's check the upper bound.
      const F32 squareMax = getSquareMax(level, squarePos);

      if(startZ > squareMax && endZ > squareMax)
         continue; //Nope, skip out.

      // We might be intersecting something... If we've hit
      // the tree depth let's deal with the leaf intersection.
      if(level == 0)
      {
         //Con::printf(" ++ check node(%d, %d @ %d), sT=%f, eT=%f", squarePos.x, squarePos.y, level, startT, endT);

         if(castLeafRay(squarePos, start, end, startT, endT, info))
         {
            PROFILE_END();
            return true; // We hit, tell 'em so!
         }
         continue; // Otherwise, keep looking.
      }
      else
      {
         // Ok, we have to push our children as we're an inner node.

         // First, figure out some widths...
         U32 subSqSize  = BIT(level - 1);

         // Now, calculate intercepts so we know how to deal with this
         // situation... (intercept = position, int = t value for that pos)

         const F32 xIntercept = (squarePos.x + subSqSize) * invSize;
         F32 xInt = calcInterceptX(start.x, invDeltaX, xIntercept);

         const F32 yIntercept = (squarePos.y + subSqSize) * invSize;
         F32 yInt = calcInterceptY(start.y, invDeltaY, yIntercept);

         // Our starting position for this subray...
         const F32 startX = startT * (end.x - start.x) + start.x;
         const F32 startY = startT * (end.y - start.y) + start.y;

         // Deal with squares that might be "behind" the ray.
         if(xInt < startT) xInt = F32_MAX;
         if(yInt < startT) yInt = F32_MAX;

         // Do a little magic to calculate our next checks...
         const U32 x0 = (startX > xIntercept) * subSqSize;
         const U32 y0 = (startY > yIntercept) * subSqSize;

         const U32 x1 = subSqSize - x0;
         const U32 y1 = subSqSize - y0;

         const U32 nextLevel = level - 1;

         // Ok, now let's figure out what nodes, in what order, need to go
         // on the stack. We push things on in reverse order of processing.
         if(xInt > endT && yInt > endT)
         {
            stack[stackSize].squarePos.set(squarePos.x + x0, squarePos.y + y0);
            stack[stackSize].level = nextLevel;
            stackSize++;
         }
         else if(xInt < yInt)
         {
            F32 nextIntersect = endT;

            if(yInt <= endT)
            {
               stack[stackSize].squarePos.set(squarePos.x + x1, squarePos.y + y1);
               stack[stackSize].startT = yInt;
               stack[stackSize].endT   = endT;
               stack[stackSize].level  = nextLevel;
               nextIntersect = yInt;
               stackSize++;
            }

            // Do middle two, order doesn't matter.
            stack[stackSize].squarePos.set(squarePos.x + x1, squarePos.y + y0);
            stack[stackSize].startT = xInt;
            stack[stackSize].endT   = nextIntersect;
            stack[stackSize].level  = nextLevel;

            stack[stackSize+1].squarePos.set(squarePos.x + x0, squarePos.y + y0);
            stack[stackSize+1].startT = startT;
            stack[stackSize+1].endT   = xInt;
            stack[stackSize+1].level  = nextLevel;
            stackSize += 2;
         }
         else if(yInt < xInt)
         {
            F32 nextIntersect = endT;
            if(xInt <= endT)
            {
               stack[stackSize].squarePos.set(squarePos.x + x1, squarePos.y + y1);
               stack[stackSize].startT = xInt;
               stack[stackSize].endT   = endT;
               stack[stackSize].level  = nextLevel;
               nextIntersect = xInt;
               stackSize++;
            }
            stack[stackSize].squarePos.set(squarePos.x + x0, squarePos.y + y1);
            stack[stackSize].startT  = yInt;
            stack[stackSize].endT    = nextIntersect;
            stack[stackSize].level   = nextLevel;

            stack[stackSize+1].squarePos.set(squarePos.x + x0, squarePos.y + y0);
            stack[stackSize+1].startT = startT;
            stack[stackSize+1].endT   = yInt;
            stack[stackSize+1].level  = nextLevel;
            stackSize += 2;
         }
         else
         {
            stack[stackSize].squarePos.set(squarePos.x + x1, squarePos.y + y1);
            stack[stackSize].startT = xInt;
            stack[stackSize].endT   = endT;
            stack[stackSize].level  = nextLevel;

            stack[stackSize+1].squarePos.set(squarePos.x + x0, squarePos.y + y0);
            stack[stackSize+1].startT = startT;
            stack[stackSize+1].endT   = xInt;
            stack[stackSize+1].level  = nextLevel;
            stackSize += 2;
         }
      }
   }

   // Nothing found, so give up.
   PROFILE_END();
   return false;
}