#include <Windows.h>#include <Stdio.h>#include <Assert.h>#include <DDraw.h>#include <D3D.h>#include "D3DCache.h"Go to the source code of this file.
|
|
Definition at line 33 of file WireFrame/D3dcache.cpp. |
|
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
Definition at line 433 of file WireFrame/D3dcache.cpp. References AppendHack, D3DCache_Slot::CacheType, D3DCache::CacheTypes, D3DCache_FreeAllSlots(), D3DCache_IsValid(), D3DCACHE_MAX_CACHE_TYPES, D3DCache_SetupSlot(), D3DCache_WriteToFile(), D3DMain_Log(), DDMemMgr_PartitionAllocMem(), DDMemMgr_PartitionReset(), D3DCache_Type::ddsd, GE_FALSE, GE_TRUE, geBoolean, D3DCache_Type::Height, int32, D3DCache_Type::Log, NULL, D3DCache_Type::NumUsedSlots, D3DCache::Partition, D3DCache_Type::RefCount, D3DCache_Slot::SelfCheck, D3DCache_Type::Slots, D3DCache_Type::Stage, uint32, D3DCache::UseStages, and D3DCache_Type::Width. Referenced by THandle_CheckCache().
00434 {
00435 D3DCache_Type *pCacheType;
00436 int32 i, Total, NumPasses;
00437
00438 assert(D3DCache_IsValid(Cache));
00439
00440 D3DCache_FreeAllSlots(Cache); // Just get rid of everything for now...
00441 DDMemMgr_PartitionReset(Cache->Partition); // Reset the caches memory manager
00442
00443 Total = 0;
00444 NumPasses = 0;
00445
00446 while(1)
00447 {
00448 D3DCache_Slot *LastSlot;
00449
00450 LastSlot = NULL;
00451
00452 pCacheType = Cache->CacheTypes;
00453
00454 for (i=0; i< D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00455 {
00456 D3DCache_Slot *pSlot;
00457 uint32 Size, Width, Height, Result;
00458
00459 if (pCacheType->RefCount <= 0)
00460 {
00461 assert(pCacheType->Slots == NULL);
00462 continue;
00463 }
00464
00465 if (pCacheType->NumUsedSlots >= pCacheType->RefCount)
00466 continue; // This is all we need for this slot...
00467
00468 if (pCacheType->NumUsedSlots >= MaxTable[pCacheType->Log])
00469 continue;
00470
00471 if (!pCacheType->Slots) // If no slots have been allocated, allocate them now...
00472 {
00473 pCacheType->Slots = (D3DCache_Slot*)malloc(sizeof(D3DCache_Type)*pCacheType->RefCount);
00474 memset(pCacheType->Slots, 0, sizeof(D3DCache_Type)*pCacheType->RefCount);
00475 }
00476
00477 Width = pCacheType->Width;
00478 Height = pCacheType->Height;
00479
00480 Size = Width*Height*(pCacheType->ddsd.ddpfPixelFormat.dwRGBBitCount>>3); // (BitCount/8)
00481
00482 if (UsePartition)
00483 {
00484 if (!DDMemMgr_PartitionAllocMem(Cache->Partition, Size))
00485 {
00486 LastSlot = NULL; // Make a complete stop
00487 break; // No more memory in the partition, stop now...
00488 }
00489 }
00490
00491 pSlot = &pCacheType->Slots[pCacheType->NumUsedSlots];
00492 pSlot->SelfCheck = pSlot;
00493
00494 pSlot->CacheType = pCacheType;
00495
00496 // Allocate surfaces now
00497 Result = D3DCache_SetupSlot(Cache, pSlot, Width, Height, &pCacheType->ddsd, Cache->UseStages, pCacheType->Stage);
00498
00499 if (!Result)
00500 {
00501 memset(pSlot, 0, sizeof(D3DCache_Slot));
00502 break;
00503 }
00504 else if (Result == -1)
00505 {
00506 D3DMain_Log("D3DCache_AdjustSlots: D3DCache_SetupSlot failed.\n");
00507 return GE_FALSE;
00508 }
00509
00510 pCacheType->NumUsedSlots++;
00511 Total++;
00512
00513 LastSlot = pSlot;
00514 }
00515
00516 NumPasses++;
00517
00518 if (!LastSlot) // Nothing was allocated on that pass, so assume we are out of memory
00519 break;
00520 }
00521
00522 pCacheType = Cache->CacheTypes;
00523
00524 // Go through one last time, and make sure all got allocated
00525 for (i=0; i< D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00526 {
00527 if (pCacheType->RefCount <= 0)
00528 {
00529 assert(pCacheType->Slots == NULL);
00530 continue;
00531 }
00532
00533 if (pCacheType->NumUsedSlots <= 0)
00534 {
00535 D3DMain_Log("D3DCache_AdjustSlots: Out of ram creating surfaces for cache.\n");
00536 D3DMain_Log("D3DCache_AdjustSlots: Pick a display mode with a smaller resolution.\n");
00537 return GE_FALSE; // Not all slots with refs got a texture
00538 }
00539
00540 assert(pCacheType->Slots != NULL);
00541 }
00542
00543 D3DCache_WriteToFile(Cache, "D3DCache.Log", AppendHack);
00544 AppendHack = GE_TRUE;
00545
00546 return GE_TRUE;
00547 }
|
|
||||||||||||||||||||
|
Definition at line 91 of file WireFrame/D3dcache.cpp. References D3DCACHE_MAX_NAME, lpDD, D3DCache::lpDD, D3DCache::Name, NULL, Partition, D3DCache::Partition, D3DCache::SelfCheck, and D3DCache::UseStages. Referenced by THandle_Startup().
00092 {
00093 D3DCache *Cache;
00094
00095 assert(strlen(Name) < D3DCACHE_MAX_NAME);
00096
00097 Cache = (D3DCache*)malloc(sizeof(D3DCache));
00098
00099 if (!Cache)
00100 return NULL;
00101
00102 memset(Cache, 0, sizeof(D3DCache));
00103
00104 Cache->lpDD = lpDD;
00105
00106 Cache->Partition = Partition;
00107
00108 Cache->UseStages = UseStages;
00109
00110 Cache->SelfCheck = Cache;
00111
00112 strcpy(Cache->Name, Name);
00113
00114 return Cache;
00115 }
|
|
|
Definition at line 120 of file WireFrame/D3dcache.cpp. References D3DCache_FreeAllSlots(). Referenced by FreeAllCaches().
00121 {
00122 assert(Cache);
00123
00124 D3DCache_FreeAllSlots(Cache);
00125
00126 free(Cache);
00127 }
|
|
|
Definition at line 145 of file WireFrame/D3dcache.cpp. References D3DCache::CacheTypes, D3DCache_IsValid(), D3DCACHE_MAX_CACHE_TYPES, D3DCache_SlotSetUserData(), D3DCache_TypeIsValid(), GE_TRUE, geBoolean, int32, NULL, D3DCache_Type::NumUsedSlots, D3DCache_Type::RefCount, s, and D3DCache_Type::Slots. Referenced by D3DMain_RestoreAllSurfaces().
00146 {
00147 int32 i;
00148 D3DCache_Type *pCacheType;
00149
00150 assert(D3DCache_IsValid(Cache));
00151
00152 for (pCacheType = Cache->CacheTypes, i=0; i< D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00153 {
00154 D3DCache_Slot *pSlot;
00155 int32 s;
00156
00157 if (!pCacheType->RefCount)
00158 continue;
00159
00160 assert(D3DCache_TypeIsValid(pCacheType));
00161
00162 for (pSlot = pCacheType->Slots, s=0; s<pCacheType->NumUsedSlots; s++, pSlot++)
00163 {
00164 D3DCache_SlotSetUserData(pSlot, NULL);
00165 }
00166 }
00167
00168 return GE_TRUE;
00169 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 173 of file WireFrame/D3dcache.cpp. References D3DCache::CacheTypes, D3DCache_IsValid(), D3DCACHE_MAX_CACHE_TYPES, D3DCache_TypeIsValid(), D3DCache_Type::ddsd, D3DCache_Type::Height, int32, NULL, D3DCache_Type::NumMipLevels, D3DCache_Type::RefCount, D3DCache_Type::Stage, and D3DCache_Type::Width. Referenced by D3DCache_TypeCreate().
00174 {
00175 int32 i;
00176 D3DCache_Type *pCacheType;
00177
00178 assert(D3DCache_IsValid(Cache));
00179
00180 pCacheType = Cache->CacheTypes;
00181
00182 for (i=0; i<D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00183 {
00184 if (pCacheType->RefCount == 0) // Nobody is using this slot yet
00185 continue;
00186
00187 assert(D3DCache_TypeIsValid(pCacheType));
00188
00189 if (pCacheType->Width != Width)
00190 continue;
00191 if (pCacheType->Height != Height)
00192 continue;
00193
00194 if (pCacheType->NumMipLevels != NumMipLevels)
00195 continue;
00196
00197 if (pCacheType->Stage != Stage)
00198 continue;
00199
00200 if (memcmp(&pCacheType->ddsd, ddsd, sizeof(DDSURFACEDESC2)))
00201 continue;
00202
00203 return pCacheType; // Found a match
00204 }
00205
00206 return NULL; // Cache Type not found!!!
00207 }
|
|
|
Definition at line 326 of file WireFrame/D3dcache.cpp. References D3DCache::CacheTypes, D3DCache_IsValid(), D3DCACHE_MAX_CACHE_TYPES, D3DCache_SlotIsValid(), D3DCache_TypeIsValid(), DDMemMgr_PartitionReset(), GE_TRUE, geBoolean, int32, NULL, D3DCache_Type::NumUsedSlots, D3DCache::Partition, D3DCache_Type::RefCount, D3DCache_Type::Slots, D3DCache_Slot::Surface, and D3DCache_Slot::Texture. Referenced by D3DCache_AdjustSlots(), and D3DCache_Destroy().
00327 {
00328 int32 i;
00329 D3DCache_Type *pCacheType;
00330
00331 assert(D3DCache_IsValid(Cache));
00332
00333 pCacheType = Cache->CacheTypes;
00334
00335 for (i=0; i< D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00336 {
00337 D3DCache_Slot *pSlot;
00338 int32 k;
00339
00340 assert(pCacheType->RefCount >= 0);
00341
00342 if (pCacheType->RefCount == 0)
00343 {
00344 assert(pCacheType->Slots == NULL);
00345 continue;
00346 }
00347
00348 assert(D3DCache_TypeIsValid(pCacheType));
00349
00350 // Go through each slot, and free all the surfaces on them
00351 for (pSlot = pCacheType->Slots, k=0; k< pCacheType->NumUsedSlots; k++, pSlot++)
00352 {
00353 assert(D3DCache_SlotIsValid(pSlot));
00354 assert(pSlot->Surface);
00355 assert(pSlot->Texture);
00356
00357 if (pSlot->Texture)
00358 pSlot->Texture->Release();
00359 if (pSlot->Surface)
00360 pSlot->Surface->Release();
00361 }
00362
00363 if (pCacheType->Slots)
00364 free(pCacheType->Slots);
00365
00366 pCacheType->Slots = NULL;
00367 pCacheType->NumUsedSlots = 0;
00368 }
00369
00370 DDMemMgr_PartitionReset(Cache->Partition); // Reset the caches memory manager
00371
00372 return GE_TRUE;
00373 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 211 of file WireFrame/D3dcache.cpp. References D3DCache_Type::Cache, D3DCache::CacheTypes, D3DCache_IsValid(), D3DCACHE_MAX_CACHE_TYPES, D3DCache_Type::ddsd, GetLog(), D3DCache_Type::Height, int32, D3DCache_Type::Log, NULL, D3DCache_Type::NumMipLevels, D3DCache_Type::NumUsedSlots, D3DCache_Type::RefCount, D3DCache_Type::SelfCheck, D3DCache_Type::Slots, D3DCache_Type::Stage, and D3DCache_Type::Width. Referenced by D3DCache_TypeCreate().
00212 {
00213 int32 i;
00214 D3DCache_Type *pCacheType;
00215
00216 assert(D3DCache_IsValid(Cache));
00217
00218 pCacheType = Cache->CacheTypes;
00219
00220 for (i=0; i<D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00221 {
00222 if (pCacheType->RefCount == 0) // Nobody is using this slot yet
00223 break;
00224 }
00225
00226 if (i == D3DCACHE_MAX_CACHE_TYPES) // No types left
00227 return NULL;
00228
00229 assert(pCacheType->Slots == NULL);
00230 assert(pCacheType->NumUsedSlots == 0);
00231
00232 pCacheType->Width = Width;
00233 pCacheType->Height = Height;
00234 pCacheType->NumMipLevels = NumMipLevels;
00235 pCacheType->Stage = Stage;
00236 pCacheType->ddsd = *ddsd;
00237
00238 pCacheType->SelfCheck = pCacheType;
00239 pCacheType->Cache = Cache;
00240
00241 pCacheType->Log = GetLog(Width, Height);
00242
00243 // Found one
00244 pCacheType->RefCount++;
00245
00246 return pCacheType;
00247 }
|
|
|
Definition at line 132 of file WireFrame/D3dcache.cpp. References GE_FALSE, GE_TRUE, geBoolean, and D3DCache::SelfCheck. Referenced by D3DCache_AdjustSlots(), D3DCache_EvictAllSurfaces(), D3DCache_FindCacheType(), D3DCache_FreeAllSlots(), D3DCache_InsertCacheType(), D3DCache_SetupSlot(), D3DCache_TypeCreate(), and D3DCache_TypeIsValid().
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 570 of file WireFrame/D3dcache.cpp. References D3DCache_IsValid(), D3DCache_SlotIsValid(), int32, D3DCache::lpDD, NULL, D3DCache_Slot::Surface, and D3DCache_Slot::Texture. Referenced by D3DCache_AdjustSlots().
00571 {
00572 LPDIRECTDRAWSURFACE4 Surface;
00573 DDSURFACEDESC2 ddsd;
00574 HRESULT Hr;
00575
00576 assert(D3DCache_IsValid(Cache));
00577 assert(D3DCache_SlotIsValid(Slot));
00578
00579 memcpy(&ddsd, SurfDesc, sizeof(DDSURFACEDESC2));
00580
00581 ddsd.dwSize = sizeof(DDSURFACEDESC2);
00582 ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
00583
00584 if (UseStage)
00585 ddsd.dwFlags |= DDSD_TEXTURESTAGE;
00586
00587 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
00588 ddsd.ddsCaps.dwCaps2 = DDSCAPS2_HINTDYNAMIC;
00589 ddsd.ddsCaps.dwCaps3 = 0;
00590 ddsd.ddsCaps.dwCaps4 = 0;
00591 ddsd.dwHeight = Width;
00592 ddsd.dwWidth = Height;
00593
00594 ddsd.dwTextureStage = Stage;
00595
00596 Hr = Cache->lpDD->CreateSurface(&ddsd, &Surface, NULL);
00597
00598 if(Hr != DD_OK)
00599 {
00600 if (Hr == DDERR_OUTOFVIDEOMEMORY)
00601 {
00602 return 0;
00603 }
00604
00605 return -1;
00606 }
00607
00608 Slot->Surface = Surface;
00609
00610 // Set the color key
00611 #if 0
00612 {
00613 DDCOLORKEY CKey;
00614
00615 // Create the color key for this surface
00616 CKey.dwColorSpaceLowValue = 1;
00617 CKey.dwColorSpaceHighValue = 1;
00618
00619 if (Slot->Surface->SetColorKey(DDCKEY_SRCBLT , &CKey) != DD_OK)
00620 {
00621 Slot->Surface->Release();
00622 Slot->Surface = NULL;
00623 return -1;
00624 }
00625 }
00626 #endif
00627
00628 Hr = Surface->QueryInterface(IID_IDirect3DTexture2, (void**)&Slot->Texture);
00629
00630 if(Hr != DD_OK)
00631 {
00632 Surface->Release();
00633 return -1;
00634 }
00635
00636 return 1; // All good dude
00637 }
|
|
|
Definition at line 707 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), D3DCache_Slot::LRU, and uint32.
00708 {
00709 assert(D3DCache_SlotIsValid(Slot));
00710
00711 return Slot->LRU;
00712 }
|
|
|
Definition at line 721 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), and D3DCache_Slot::Surface. Referenced by SetupLMap(), and SetupTexture().
00722 {
00723 assert(D3DCache_SlotIsValid(Slot));
00724
00725 return Slot->Surface;
00726 }
|
|
|
Definition at line 714 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), and D3DCache_Slot::Texture. Referenced by SetupLMap(), and SetupTexture().
00715 {
00716 assert(D3DCache_SlotIsValid(Slot));
00717
00718 return Slot->Texture;
00719 }
|
|
|
Definition at line 687 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), and D3DCache_Slot::UserData. Referenced by SetupMipData().
00688 {
00689 assert(D3DCache_SlotIsValid(Slot));
00690
00691 return Slot->UserData;
00692 }
|
|
|
Definition at line 552 of file WireFrame/D3dcache.cpp. References GE_FALSE, GE_TRUE, geBoolean, and D3DCache_Slot::SelfCheck. Referenced by D3DCache_FreeAllSlots(), D3DCache_SetupSlot(), D3DCache_SlotGetLRU(), D3DCache_SlotGetSurface(), D3DCache_SlotGetTexture(), D3DCache_SlotGetUserData(), D3DCache_SlotSetLRU(), D3DCache_SlotSetUserData(), D3DCache_TypeDestroy(), and D3DCache_TypeFindSlot().
|
|
||||||||||||
|
Definition at line 697 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), and D3DCache_Slot::LRU. Referenced by SetupLMap(), and SetupTexture().
00698 {
00699 assert(D3DCache_SlotIsValid(Slot));
00700
00701 Slot->LRU = LRU;
00702 }
|
|
||||||||||||
|
Definition at line 677 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), and D3DCache_Slot::UserData. Referenced by D3DCache_EvictAllSurfaces(), and SetupMipData().
00678 {
00679 assert(D3DCache_SlotIsValid(Slot));
00680
00681 Slot->UserData = UserData;
00682 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 251 of file WireFrame/D3dcache.cpp. References D3DCache_FindCacheType(), D3DCache_InsertCacheType(), D3DCache_IsValid(), and D3DCache_Type::RefCount. Referenced by Create3DTHandle(), and CreateLightmapTHandle().
00252 {
00253 D3DCache_Type *CacheType;
00254
00255 assert(D3DCache_IsValid(Cache));
00256
00257 CacheType = D3DCache_FindCacheType(Cache, Width, Height, NumMipLevels, Stage, ddsd);
00258
00259 if (CacheType)
00260 {
00261 CacheType->RefCount++;
00262 return CacheType;
00263 }
00264
00265 // Could not find one allready in the list, so add a new one...
00266 return D3DCache_InsertCacheType(Cache, Width, Height, NumMipLevels, Stage, ddsd);
00267 }
|
|
|
Definition at line 272 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), D3DCache_TypeIsValid(), int32, NULL, D3DCache_Type::NumUsedSlots, D3DCache_Type::RefCount, D3DCache_Type::Slots, D3DCache_Slot::Surface, and D3DCache_Slot::Texture. Referenced by THandle_Destroy().
00273 {
00274 assert(CacheType->RefCount > 0);
00275 assert(D3DCache_TypeIsValid(CacheType));
00276
00277 CacheType->RefCount--;
00278
00279 if (CacheType->RefCount == 0)
00280 {
00281 if (CacheType->Slots)
00282 {
00283 D3DCache_Slot *pSlot;
00284 int32 k;
00285
00286 // Go through each slot, and free all the surfaces on them
00287 for (pSlot = CacheType->Slots, k=0; k< CacheType->NumUsedSlots; k++, pSlot++)
00288 {
00289 assert(D3DCache_SlotIsValid(pSlot));
00290 assert(pSlot->Surface);
00291 assert(pSlot->Texture);
00292
00293 if (pSlot->Texture)
00294 pSlot->Texture->Release();
00295 if (pSlot->Surface)
00296 pSlot->Surface->Release();
00297 }
00298
00299 free(CacheType->Slots);
00300 CacheType->Slots = NULL;
00301 CacheType->NumUsedSlots = 0;
00302 }
00303 }
00304 }
|
|
|
Definition at line 643 of file WireFrame/D3dcache.cpp. References D3DCache_SlotIsValid(), D3DCache_TypeIsValid(), int32, D3DCache_Slot::LRU, NULL, D3DCache_Type::NumUsedSlots, D3DCache_Type::Slots, uint32, and D3DCache_Slot::UserData. Referenced by SetupMipData().
00644 {
00645 D3DCache_Slot *pBestSlot, *pSlot;
00646 uint32 BestLRU;
00647 int32 i;
00648
00649 assert(D3DCache_TypeIsValid(CacheType));
00650
00651 assert(CacheType->Slots);
00652
00653 pSlot = CacheType->Slots;
00654 pBestSlot = pSlot;
00655 BestLRU = pBestSlot->LRU;
00656
00657 for (i=0; i< CacheType->NumUsedSlots; i++, pSlot++)
00658 {
00659 assert(D3DCache_SlotIsValid(pSlot));
00660
00661 if (pSlot->LRU < BestLRU)
00662 {
00663 pBestSlot = pSlot;
00664 BestLRU = pSlot->LRU;
00665 }
00666 }
00667
00668 pBestSlot->LRU = 0;
00669 pBestSlot->UserData = NULL;
00670
00671 return pBestSlot;
00672 }
|
|
|
Definition at line 309 of file WireFrame/D3dcache.cpp. References D3DCache_Type::Cache, D3DCache_IsValid(), GE_FALSE, GE_TRUE, geBoolean, and D3DCache_Type::SelfCheck. Referenced by D3DCache_EvictAllSurfaces(), D3DCache_FindCacheType(), D3DCache_FreeAllSlots(), D3DCache_TypeDestroy(), and D3DCache_TypeFindSlot().
|
|
||||||||||||||||
|
Definition at line 378 of file WireFrame/D3dcache.cpp. References D3DCache::CacheTypes, D3DCACHE_MAX_CACHE_TYPES, DDMemMgr_PartitionGetFreeMem(), DDMemMgr_PartitionGetTotalMem(), GE_FALSE, GE_TRUE, geBoolean, D3DCache_Type::Height, int32, D3DCache::Name, D3DCache_Type::NumMipLevels, D3DCache_Type::NumUsedSlots, D3DCache::Partition, D3DCache_Type::RefCount, D3DCache_Type::Stage, and D3DCache_Type::Width. Referenced by D3DCache_AdjustSlots().
00379 {
00380 int32 i;
00381 D3DCache_Type *pCacheType;
00382 int32 TotalRef, TotalUsed;
00383 SYSTEMTIME Time;
00384 FILE *f;
00385
00386 if (Append)
00387 f = fopen(FileName, "a+t");
00388 else
00389 f = fopen(FileName, "w");
00390
00391 if (!f)
00392 return GE_FALSE;
00393
00394 GetSystemTime(&Time);
00395
00396 fprintf(f, "=======================================================\n");
00397 fprintf(f, "Date: %i/%i/%i, Time: %i:%i\n", Time.wMonth, Time.wDay, Time.wYear, Time.wHour, Time.wMinute);
00398 fprintf(f, "Cache Name: %s\n", Cache->Name);
00399 fprintf(f, "Total Mem: %5i\n", DDMemMgr_PartitionGetTotalMem(Cache->Partition));
00400 fprintf(f, "Free Mem: %5i\n", DDMemMgr_PartitionGetFreeMem(Cache->Partition));
00401 fprintf(f, " --- Slots ---\n");
00402
00403 TotalRef = TotalUsed = 0;
00404
00405 pCacheType = Cache->CacheTypes;
00406
00407 for (i=0; i< D3DCACHE_MAX_CACHE_TYPES; i++, pCacheType++)
00408 {
00409 if (!pCacheType->RefCount)
00410 continue;
00411
00412 fprintf(f, "Width: %3i, Height %3i, Mips: %2i, Stage: %2i, Ref: %4i, Used: %4i\n",
00413 pCacheType->Width, pCacheType->Height, pCacheType->NumMipLevels, pCacheType->Stage, pCacheType->RefCount, pCacheType->NumUsedSlots);
00414
00415 TotalRef += pCacheType->RefCount;
00416 TotalUsed += pCacheType->NumUsedSlots;
00417 }
00418
00419 fprintf(f, "Total Ref: %4i, Total Used: %4i\n", TotalRef, TotalUsed);
00420
00421 fclose(f);
00422
00423 return GE_TRUE;
00424 }
|
|
||||||||||||
|
||||||||||||
|
Definition at line 779 of file WireFrame/D3dcache.cpp. References int32, Log2(), max, and SnapToPower2(). Referenced by Create2DTHandle(), Create3DTexture(), Create3DTHandle(), CreateLightmapTexture(), CreateLightmapTHandle(), D3DCache_InsertCacheType(), and THandle_Create().
00780 {
00781 int32 LWidth = SnapToPower2(max(Width, Height));
00782
00783 return Log2(LWidth);
00784 }
|
|
|
Definition at line 732 of file WireFrame/D3dcache.cpp. Referenced by GetLog().
|
|
|
Definition at line 747 of file WireFrame/D3dcache.cpp. References int32. Referenced by Create3DTexture(), CreateTexture(), DrawDecal(), GetLog(), GTHandle_SetupInfo(), and THandle_Create().
00748 {
00749 #if 1
00750 if (Width > 0 && Width <= 1) Width = 1;
00751 else if (Width > 1 && Width <= 2) Width = 2;
00752 else if (Width > 2 && Width <= 4) Width = 4;
00753 else if (Width > 4 && Width <= 8) Width = 8;
00754 else if (Width > 8 && Width <= 16) Width =16;
00755 else if (Width > 16 && Width <= 32) Width = 32;
00756 else if (Width > 32 && Width <= 64) Width = 64;
00757 else if (Width > 64 && Width <= 128) Width = 128;
00758 else if (Width > 128 && Width <= 256) Width = 256;
00759 else
00760 return -1;
00761 #else
00762
00763 if (Width > 1 && Width <= 8) Width = 8;
00764 else if (Width > 8 && Width <= 16) Width =16;
00765 else if (Width > 16 && Width <= 32) Width = 32;
00766 else if (Width > 32 && Width <= 64) Width = 64;
00767 else if (Width > 64 && Width <= 128) Width = 128;
00768 else if (Width > 128 && Width <= 256) Width = 256;
00769 else
00770 return -1;
00771 #endif
00772
00773 return Width;
00774 }
|
|
|
Definition at line 426 of file WireFrame/D3dcache.cpp. Referenced by D3DCache_AdjustSlots(). |
1.3.2