forked from cafeberry/cafeberry
refactor: remove X360 specific stuff from non X360 platforms
and abit of PS3 only stuff from PSVita
This commit is contained in:
@@ -46,20 +46,11 @@ using namespace Windows::Foundation::Collections;
|
||||
//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device)
|
||||
#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
|
||||
|
||||
//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
|
||||
#define NUM_PROFILE_VALUES 5
|
||||
#define NUM_PROFILE_SETTINGS 4
|
||||
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
{
|
||||
#ifdef _XBOX
|
||||
XPROFILE_OPTION_CONTROLLER_VIBRATION,
|
||||
XPROFILE_GAMER_YAXIS_INVERSION,
|
||||
XPROFILE_GAMER_CONTROL_SENSITIVITY,
|
||||
XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL,
|
||||
XPROFILE_TITLE_SPECIFIC1,
|
||||
#else
|
||||
0,0,0,0,0
|
||||
#endif
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
@@ -234,61 +225,9 @@ void DefineActions(void)
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN);
|
||||
}
|
||||
|
||||
#if 0
|
||||
HRESULT InitD3D( IDirect3DDevice9 **ppDevice,
|
||||
D3DPRESENT_PARAMETERS *pd3dPP )
|
||||
{
|
||||
IDirect3D9 *pD3D;
|
||||
|
||||
pD3D = Direct3DCreate9( D3D_SDK_VERSION );
|
||||
|
||||
// Set up the structure used to create the D3DDevice
|
||||
// Using a permanent 1280x720 backbuffer now no matter what the actual video resolution.right Have also disabled letterboxing,
|
||||
// which would letterbox a 1280x720 output if it detected a 4:3 video source - we're doing an anamorphic squash in this
|
||||
// mode so don't need this functionality.
|
||||
|
||||
ZeroMemory( pd3dPP, sizeof(D3DPRESENT_PARAMETERS) );
|
||||
XVIDEO_MODE VideoMode;
|
||||
XGetVideoMode( &VideoMode );
|
||||
g_bWidescreen = VideoMode.fIsWideScreen;
|
||||
pd3dPP->BackBufferWidth = 1280;
|
||||
pd3dPP->BackBufferHeight = 720;
|
||||
pd3dPP->BackBufferFormat = D3DFMT_A8R8G8B8;
|
||||
pd3dPP->BackBufferCount = 1;
|
||||
pd3dPP->EnableAutoDepthStencil = TRUE;
|
||||
pd3dPP->AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
pd3dPP->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
pd3dPP->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
//pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX;
|
||||
//ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled
|
||||
// in the launcher/dashboard.
|
||||
if(g_bWidescreen)
|
||||
pd3dPP->Flags=0;
|
||||
else
|
||||
pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX;
|
||||
|
||||
// Create the device.
|
||||
return pD3D->CreateDevice(
|
||||
0,
|
||||
D3DDEVTYPE_HAL,
|
||||
NULL,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES,
|
||||
pd3dPP,
|
||||
ppDevice );
|
||||
}
|
||||
#endif
|
||||
//#define MEMORY_TRACKING
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
void ResetMem();
|
||||
void DumpMem();
|
||||
void MemPixStuff();
|
||||
#else
|
||||
void MemSect(int sect)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
HINSTANCE g_hInst = NULL;
|
||||
|
||||
@@ -465,62 +404,8 @@ void Render()
|
||||
g_swapChain->Present( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
void oldWinMainInit()
|
||||
{
|
||||
#if 0
|
||||
// Main message loop
|
||||
MSG msg = {0};
|
||||
while( WM_QUIT != msg.message )
|
||||
{
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
return (int) msg.wParam;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
ResetMem();
|
||||
MEMORYSTATUS memStat;
|
||||
GlobalMemoryStatus(&memStat);
|
||||
printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// Initialize D3D
|
||||
hr = InitD3D( &pDevice, &d3dpp );
|
||||
g_pD3DDevice = pDevice;
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
app.DebugPrintf
|
||||
( "Failed initializing D3D.\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Initialize the application, assuming sharing of the d3d interface.
|
||||
hr = app.InitShared( pDevice, &d3dpp,
|
||||
XuiPNGTextureLoader );
|
||||
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
app.DebugPrintf
|
||||
( "Failed initializing application.\n" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
app.loadMediaArchive();
|
||||
|
||||
RenderManager.Initialise(g_d3dDevice.Get(), g_swapChain.Get());
|
||||
@@ -533,25 +418,6 @@ void oldWinMainInit()
|
||||
// Initialise //
|
||||
////////////////
|
||||
|
||||
#if 0
|
||||
// 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params
|
||||
// are just copied from a sample app and may need changed for our purposes
|
||||
// Start XAudio2
|
||||
hr = XAudio2Create( &g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR );
|
||||
if( FAILED( hr ) )
|
||||
{
|
||||
app.DebugPrintf( "Initializing XAudio2 failed (err = 0x%08x)!\n", hr );
|
||||
app.FatalLoadError();
|
||||
}
|
||||
|
||||
// Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers)
|
||||
hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL);
|
||||
if ( FAILED( hr ) )
|
||||
{
|
||||
app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr );
|
||||
app.FatalLoadError();
|
||||
}
|
||||
#endif
|
||||
app.InitTime();
|
||||
|
||||
// Set the number of possible joypad layouts that the user can switch between, and the number of actions
|
||||
@@ -649,99 +515,22 @@ void oldWinMainInit()
|
||||
// app.SetDefaultOptions(ProfileManager.GetGameDefinedProfileData(i),i);
|
||||
// }
|
||||
|
||||
|
||||
#if 0
|
||||
//bool bDisplayPauseMenu=false;
|
||||
|
||||
// set the default gamma level
|
||||
float fVal=50.0f*327.68f;
|
||||
RenderManager.UpdateGamma((unsigned short)fVal);
|
||||
|
||||
// load any skins
|
||||
//app.AddSkinsToMemoryTextureFiles();
|
||||
|
||||
// set the achievement text for a trial achievement, now we have the string table loaded
|
||||
ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL);
|
||||
ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT);
|
||||
ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT);
|
||||
ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT);
|
||||
ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT);
|
||||
ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app);
|
||||
|
||||
// Set up a debug character press sequence
|
||||
#ifndef _FINAL_BUILD
|
||||
app.SetDebugSequence("LRLRYYY");
|
||||
#endif
|
||||
|
||||
// Initialise the social networking manager.
|
||||
CSocialManager::Instance()->Initialise();
|
||||
|
||||
// Update the base scene quick selects now that the minecraft class exists
|
||||
//CXuiSceneBase::UpdateScreenSettings(0);
|
||||
#endif
|
||||
app.InitialiseTips();
|
||||
#if 0
|
||||
|
||||
DWORD initData=0;
|
||||
#ifdef _TEMPORARY_CREATE_GAME
|
||||
app.TemporaryCreateGameStart();
|
||||
|
||||
|
||||
|
||||
#ifndef _FINAL_BUILD
|
||||
#ifndef _DEBUG
|
||||
#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Set the default sound levels
|
||||
pMinecraft->options->set(Options::Option::MUSIC,1.0f);
|
||||
pMinecraft->options->set(Options::Option::SOUND,1.0f);
|
||||
|
||||
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//app.TemporaryCreateGameStart();
|
||||
|
||||
//Sleep(10000);
|
||||
#if 0
|
||||
// Intro loop ?
|
||||
while(app.IntroRunning())
|
||||
{
|
||||
ProfileManager.Tick();
|
||||
// Tick XUI
|
||||
app.RunFrame();
|
||||
|
||||
// 4J : WESTY : Added to ensure we always have clear background for intro.
|
||||
RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255));
|
||||
RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Render XUI
|
||||
hr = app.Render();
|
||||
|
||||
// Present the frame.
|
||||
RenderManager.Present();
|
||||
|
||||
// Update XUI Timers
|
||||
hr = XuiTimersRun();
|
||||
}
|
||||
Sleep(10000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void oldWinMainTick()
|
||||
{
|
||||
static bool bTrialTimerDisplayed=true;
|
||||
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
RenderManager.StartFrame();
|
||||
#if 0
|
||||
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
|
||||
!pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
|
||||
!pMinecraft->soundEngine->isPlayingStreamingCDMusic() )
|
||||
{
|
||||
// play some music in the menus
|
||||
pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
app.UpdateTime();
|
||||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
@@ -756,18 +545,6 @@ void oldWinMainTick()
|
||||
RenderManager.Tick();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
// Tick the social networking manager.
|
||||
PIXBeginNamedEvent(0,"Social network manager tick");
|
||||
// CSocialManager::Instance()->Tick();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
// Tick sentient.
|
||||
PIXBeginNamedEvent(0,"Sentient tick");
|
||||
MemSect(37);
|
||||
// SentientManager.Tick();
|
||||
MemSect(0);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
GameProgress::Tick();
|
||||
|
||||
PIXBeginNamedEvent(PIX_COLOR_INDEX(2),"Network manager do work #1");
|
||||
@@ -796,89 +573,8 @@ void oldWinMainTick()
|
||||
|
||||
pMinecraft->soundEngine->playMusicTick();
|
||||
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
static bool bResetMemTrack = false;
|
||||
static bool bDumpMemTrack = false;
|
||||
|
||||
MemPixStuff();
|
||||
|
||||
if( bResetMemTrack )
|
||||
{
|
||||
ResetMem();
|
||||
MEMORYSTATUS memStat;
|
||||
GlobalMemoryStatus(&memStat);
|
||||
printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
||||
bResetMemTrack = false;
|
||||
}
|
||||
|
||||
if( bDumpMemTrack )
|
||||
{
|
||||
DumpMem();
|
||||
bDumpMemTrack = false;
|
||||
MEMORYSTATUS memStat;
|
||||
GlobalMemoryStatus(&memStat);
|
||||
printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
||||
printf("Renderer used: %d\n",RenderManager.CBuffSize(-1));
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static bool bDumpTextureUsage = false;
|
||||
if( bDumpTextureUsage )
|
||||
{
|
||||
RenderManager.TextureGetStats();
|
||||
bDumpTextureUsage = false;
|
||||
}
|
||||
#endif
|
||||
ui.tick();
|
||||
ui.render();
|
||||
#if 0
|
||||
app.HandleButtonPresses();
|
||||
|
||||
// store the minecraft renderstates, and re-set them after the xui render
|
||||
GetRenderAndSamplerStates(pDevice,RenderStateA,SamplerStateA);
|
||||
|
||||
// Tick XUI
|
||||
PIXBeginNamedEvent(0,"Xui running");
|
||||
app.RunFrame();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
// Render XUI
|
||||
|
||||
PIXBeginNamedEvent(0,"XUI render");
|
||||
MemSect(7);
|
||||
hr = app.Render();
|
||||
MemSect(0);
|
||||
GetRenderAndSamplerStates(pDevice,RenderStateA2,SamplerStateA2);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
for(int i=0;i<8;i++)
|
||||
{
|
||||
if(RenderStateA2[i]!=RenderStateA[i])
|
||||
{
|
||||
//printf("Reseting RenderStateA[%d] after a XUI render\n",i);
|
||||
pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]);
|
||||
}
|
||||
}
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
if(SamplerStateA2[i]!=SamplerStateA[i])
|
||||
{
|
||||
//printf("Reseting SamplerStateA[%d] after a XUI render\n",i);
|
||||
pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]);
|
||||
}
|
||||
}
|
||||
|
||||
RenderManager.Set_matrixDirty();
|
||||
#endif
|
||||
|
||||
#if 0 // ndef _CONTENT_PACKAGE
|
||||
if( InputManager.ButtonPressed(0,MINECRAFT_ACTION_DPAD_LEFT) ||
|
||||
InputManager.ButtonPressed(0,ACTION_MENU_STICK_PRESS))
|
||||
{
|
||||
RenderManager.DoScreenGrabOnNextPresent();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Present the frame.
|
||||
RenderManager.Present();
|
||||
@@ -919,11 +615,6 @@ void oldWinMainTick()
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Check to see if we can post to social networks.
|
||||
CSocialManager::Instance()->RefreshPostingCapability();
|
||||
#endif
|
||||
|
||||
// clear the flag
|
||||
app.uiGameDefinedDataChangedBitmask=0;
|
||||
|
||||
@@ -938,19 +629,11 @@ void oldWinMainTick()
|
||||
|
||||
PIXBeginNamedEvent(0,"Network manager do work #2");
|
||||
// 4J Stu - Added this back as it was causing horrendous lag (and eventually a crash on a client) when playing with multiple clients
|
||||
g_NetworkManager.DoWork(); // TODO - consider putting this back in. Removed because we are having trouble with how long the tick is taking on Durango
|
||||
g_NetworkManager.DoWork();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
#if 0
|
||||
PIXBeginNamedEvent(0,"Misc extra xui");
|
||||
// Update XUI Timers
|
||||
hr = XuiTimersRun();
|
||||
#endif
|
||||
// Any threading type things to deal with from the xui side?
|
||||
app.HandleXuiActions();
|
||||
#if 0
|
||||
PIXEndNamedEvent();
|
||||
#endif
|
||||
|
||||
// 4J-PB - Update the trial timer display if we are in the trial version
|
||||
if(!ProfileManager.IsFullVersion())
|
||||
@@ -980,194 +663,3 @@ void oldWinMainTick()
|
||||
// A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset
|
||||
Vec3::resetPool();
|
||||
}
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
|
||||
int totalAllocGen = 0;
|
||||
unordered_map<int,int> allocCounts;
|
||||
bool trackEnable = false;
|
||||
bool trackStarted = false;
|
||||
volatile size_t sizeCheckMin = 1160;
|
||||
volatile size_t sizeCheckMax = 1160;
|
||||
volatile int sectCheck = 48;
|
||||
CRITICAL_SECTION memCS;
|
||||
DWORD tlsIdx;
|
||||
|
||||
LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes)
|
||||
{
|
||||
if( !trackStarted )
|
||||
{
|
||||
void *p = XMemAllocDefault(dwSize,dwAllocAttributes);
|
||||
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
|
||||
totalAllocGen += realSize;
|
||||
return p;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&memCS);
|
||||
|
||||
void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes);
|
||||
size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16;
|
||||
|
||||
if( trackEnable )
|
||||
{
|
||||
#if 1
|
||||
int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f;
|
||||
*(((unsigned char *)p)+realSize) = sect;
|
||||
|
||||
if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) )
|
||||
{
|
||||
app.DebugPrintf("Found one\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if( p )
|
||||
{
|
||||
totalAllocGen += realSize;
|
||||
trackEnable = false;
|
||||
int key = ( sect << 26 ) | realSize;
|
||||
int oldCount = allocCounts[key];
|
||||
allocCounts[key] = oldCount + 1;
|
||||
|
||||
trackEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&memCS);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void* operator new (size_t size)
|
||||
{
|
||||
return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
|
||||
}
|
||||
|
||||
void operator delete (void *p)
|
||||
{
|
||||
XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
|
||||
}
|
||||
|
||||
void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes)
|
||||
{
|
||||
bool special = false;
|
||||
if( dwAllocAttributes == 0 )
|
||||
{
|
||||
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP);
|
||||
special = true;
|
||||
}
|
||||
if(!trackStarted )
|
||||
{
|
||||
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
|
||||
XMemFreeDefault(pAddress, dwAllocAttributes);
|
||||
totalAllocGen -= realSize;
|
||||
return;
|
||||
}
|
||||
EnterCriticalSection(&memCS);
|
||||
if( pAddress )
|
||||
{
|
||||
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
||||
|
||||
if(trackEnable)
|
||||
{
|
||||
int sect = *(((unsigned char *)pAddress)+realSize);
|
||||
totalAllocGen -= realSize;
|
||||
trackEnable = false;
|
||||
int key = ( sect << 26 ) | realSize;
|
||||
int oldCount = allocCounts[key];
|
||||
allocCounts[key] = oldCount - 1;
|
||||
trackEnable = true;
|
||||
|
||||
}
|
||||
XMemFreeDefault(pAddress, dwAllocAttributes);
|
||||
}
|
||||
LeaveCriticalSection(&memCS);
|
||||
}
|
||||
|
||||
SIZE_T WINAPI XMemSize(
|
||||
PVOID pAddress,
|
||||
DWORD dwAllocAttributes
|
||||
)
|
||||
{
|
||||
if( trackStarted )
|
||||
{
|
||||
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
return XMemSizeDefault(pAddress, dwAllocAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DumpMem()
|
||||
{
|
||||
int totalLeak = 0;
|
||||
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
|
||||
{
|
||||
if(it->second > 0 )
|
||||
{
|
||||
app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second);
|
||||
totalLeak += ( it->first & 0x03ffffff ) * it->second;
|
||||
}
|
||||
}
|
||||
app.DebugPrintf("Total %d\n",totalLeak);
|
||||
}
|
||||
|
||||
void ResetMem()
|
||||
{
|
||||
if( !trackStarted )
|
||||
{
|
||||
trackEnable = true;
|
||||
trackStarted = true;
|
||||
totalAllocGen = 0;
|
||||
InitializeCriticalSection(&memCS);
|
||||
tlsIdx = TlsAlloc();
|
||||
}
|
||||
EnterCriticalSection(&memCS);
|
||||
trackEnable = false;
|
||||
allocCounts.clear();
|
||||
trackEnable = true;
|
||||
LeaveCriticalSection(&memCS);
|
||||
}
|
||||
|
||||
void MemSect(int section)
|
||||
{
|
||||
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
|
||||
if( section == 0 ) // pop
|
||||
{
|
||||
value = (value >> 6) & 0x03ffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (value << 6) | section;
|
||||
}
|
||||
TlsSetValue(tlsIdx, (LPVOID)value);
|
||||
}
|
||||
|
||||
void MemPixStuff()
|
||||
{
|
||||
const int MAX_SECT = 46;
|
||||
|
||||
int totals[MAX_SECT] = {0};
|
||||
|
||||
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
|
||||
{
|
||||
if(it->second > 0 )
|
||||
{
|
||||
int sect = ( it->first >> 26 ) & 0x3f;
|
||||
int bytes = it->first & 0x03ffffff;
|
||||
totals[sect] += bytes * it->second;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int allSectsTotal = 0;
|
||||
for( int i = 0; i < MAX_SECT; i++ )
|
||||
{
|
||||
allSectsTotal += totals[i];
|
||||
PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i);
|
||||
}
|
||||
|
||||
PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user