Example #1
0
// If there is a PVS, this tags the associated things.  Otherwise,
// it tags everything.
void d3d_TagVisibleLeaves(const ViewParams& Params)
{
	//go through and queue all objects and the world
	VisibleSet *pVisibleSet = &g_VisibleSet;

	// Initialize frame for the world
	if (g_Device.m_pRenderWorld)
	{
		if (g_CV_DrawWorld)
			g_Device.m_pRenderWorld->StartFrame(Params);
	}

//	if(!g_CV_LockPVS)
	{
		// Rebuild the visible set.
		pVisibleSet->ClearSet();

		CountAdder cntAdd(&g_pStruct->m_Time_Vis);
		d3d_QueueObjectsInFrustum(Params);
	}

	// Handle the new rendering path.
	if (g_Device.m_pRenderWorld)
	{
		if (g_CV_DrawWorld)
			g_Device.m_pRenderWorld->Draw(Params);
		else
			g_Device.m_pRenderWorld->Release();
	}
}
Example #2
0
void dfree(void *ptr)
{
	if(!ptr)
		return;

	char *pCharPtr = (char*)ptr;

	#ifdef TRACK_MEMORY_USAGE
		MemTrack *pMemTrack;

		pCharPtr -= sizeof(MemTrack);
		pMemTrack = (MemTrack*)pCharPtr;

		if(pMemTrack->m_AllocSize > g_MemoryUsage)
		{
			dsi_PrintToConsole("Error: engine freed more memory than allocated!");
		}

		g_MemoryUsage -= pMemTrack->m_AllocSize;
	#endif

	--g_nAllocations;
	++g_nTotalFrees;
	
	{
		CountAdder cntAdd(&g_PD_Free);
		LTMemFree(pCharPtr);
	}
}
Example #3
0
void* dalloc(size_t size)
{
	//[DLK] Removed to avoid allocation errors with D3DXEffectCompiler
	/*
	if(size == 0)
	{
		return NULL;
	}
	*/

	size_t fullAllocSize;

	// Add 4 bytes if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		MemTrack *pMemTrack;
		fullAllocSize = size + sizeof(MemTrack);
	#else
		fullAllocSize = size;
	#endif

	
	char *ptr;
	// Try to allocate the memory.
	{
		CountAdder cntAdd(&g_PD_Malloc);
		LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc(fullAllocSize),LT_MEM_TYPE_UNKNOWN);
	}

	if(!ptr)
	{
		dsi_OnMemoryFailure();
	}

	// Store the size in there if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		g_MemoryUsage += size;
		pMemTrack = (MemTrack*)ptr;
		pMemTrack->m_AllocSize = size;
		pMemTrack->m_AllocNumber = g_nAllocations;
		ptr += sizeof(MemTrack);
	#endif

	++g_nAllocations;
	++g_nTotalAllocations;

	return ptr;
}
Example #4
0
void* dalloc(uint32 size)
{

	if(size == 0)
		return NULL;

	unsigned long fullAllocSize;

	// Add 4 bytes if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		MemTrack *pMemTrack;
		fullAllocSize = size + sizeof(MemTrack);
	#else
		fullAllocSize = size;
	#endif

	
	char *ptr;
	// Try to allocate the memory.
	{
		CountAdder cntAdd(&g_PD_Malloc);
		LT_MEM_TRACK_ALLOC(ptr = (char*)LTMemAlloc((size_t)fullAllocSize),LT_MEM_TYPE_UNKNOWN);
	}

	if(!ptr)
	{
		dsi_OnMemoryFailure();
	}

	// Store the size in there if we're tracking memory usage.
	#ifdef TRACK_MEMORY_USAGE
		g_MemoryUsage += size;
		pMemTrack = (MemTrack*)ptr;
		pMemTrack->m_AllocSize = size;
		pMemTrack->m_AllocNumber = g_nAllocations;
		ptr += sizeof(MemTrack);
	#endif

	++g_nAllocations;
	++g_nTotalAllocations;

	return ptr;
	
}