#include <Windows.h>#include <DDraw.h>#include <D3D.h>#include "THandle.h"#include "BaseType.h"#include "D3DDrv.h"#include "DCommon.h"#include "D3DCache.h"#include "D3D_Main.h"#include "PCache.h"#include "D3d_FX.h"#include "TPage.h"Go to the source code of this file.
|
|
Definition at line 564 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 44 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 41 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 43 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 46 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 47 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 39 of file D3DDrv/THandle.cpp. |
|
||||||||||||||||||||||||
|
Definition at line 358 of file D3DDrv/THandle.cpp. References CurrentSurfDesc, GE_TRUE, GetLog(), geRDriver_THandle::Height, geRDriver_THandle::Log, geRDriver_THandle::MipData, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::Stride, THandle_CreateSurfaces(), THandle_Destroy(), THANDLE_MAX_MIP_LEVELS, uint8, and geRDriver_THandle::Width.
00359 {
00360 assert(NumMipLevels < THANDLE_MAX_MIP_LEVELS);
00361 assert(NumMipLevels == 1);
00362
00363 // Save some info about the lightmap
00364 THandle->Width = Width;
00365 THandle->Height = Height;
00366 THandle->NumMipLevels = (uint8)NumMipLevels;
00367 THandle->Log = (uint8)GetLog(Width, Height);
00368 THandle->Stride = Width;
00369
00370 // Create the surfaces to hold all the mips
00371 THandle->MipData = (THandle_MipData*)malloc(sizeof(THandle_MipData)*NumMipLevels);
00372 memset(THandle->MipData, 0, sizeof(THandle_MipData)*NumMipLevels);
00373
00374 if (!THandle->MipData)
00375 {
00376 THandle_Destroy(THandle);
00377 return NULL;
00378 }
00379
00380 if (!THandle_CreateSurfaces(&THandle->MipData[0], Width, Height, &CurrentSurfDesc, GE_TRUE, 0))
00381 {
00382 THandle_Destroy(THandle);
00383 return NULL;
00384 }
00385
00386 return THandle;
00387 }
|
|
||||||||||||||||||||||||
|
Definition at line 228 of file D3DDrv/THandle.cpp. References AppInfo, THandle_MipData::CacheType, App_Info::CanDoMultiTexture, CurrentSurfDesc, D3DCache_TypeCreate(), GE_FALSE, GetLog(), geRDriver_THandle::Height, int32, geRDriver_THandle::Log, geRDriver_THandle::MipData, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::Stride, TextureCache, THandle_CreateSurfaces(), THandle_Destroy(), THANDLE_MAX_MIP_LEVELS, TSTAGE_0, uint8, and geRDriver_THandle::Width.
00229 {
00230 int32 Size, i;
00231
00232 assert(NumMipLevels < THANDLE_MAX_MIP_LEVELS);
00233 assert(NumMipLevels <= 4);
00234
00235 // Store width/height info
00236 THandle->Width = Width;
00237 THandle->Height = Height;
00238 THandle->NumMipLevels = (uint8)NumMipLevels;
00239 THandle->Log = (uint8)GetLog(Width, Height);
00240 THandle->Stride = (1<<THandle->Log);
00241
00242 // Create the surfaces to hold all the mips
00243 THandle->MipData = (THandle_MipData*)malloc(sizeof(THandle_MipData)*NumMipLevels);
00244 memset(THandle->MipData, 0, sizeof(THandle_MipData)*NumMipLevels);
00245
00246 if (!THandle->MipData)
00247 {
00248 THandle_Destroy(THandle);
00249 return NULL;
00250 }
00251
00252 Size = 1<<THandle->Log;
00253
00254 // Create all the surfaces for each mip level
00255 for (i=0; i< NumMipLevels; i++)
00256 {
00257 int32 Stage;
00258
00259 if (!THandle_CreateSurfaces(&THandle->MipData[i], Size, Size, &CurrentSurfDesc, GE_FALSE, 0))
00260 {
00261 THandle_Destroy(THandle);
00262 return NULL;
00263 }
00264
00265 // get a cache type for this surface since it is a 3d surface, and will need to be cached on the video card
00266 //THandle->MipData[i].CacheType = D3DCache_TypeCreate(TextureCache, Size, Size, NumMipLevels, &CurrentSurfDesc);
00267 // We can use 1 miplevel for the type, since we are createing types for each miplevel...
00268 if (AppInfo.CanDoMultiTexture)
00269 Stage = TSTAGE_0;
00270 else
00271 Stage = 0;
00272
00273 THandle->MipData[i].CacheType = D3DCache_TypeCreate(TextureCache, Size, Size, 1, Stage, &CurrentSurfDesc);
00274
00275 if (!THandle->MipData[i].CacheType)
00276 {
00277 THandle_Destroy(THandle);
00278 return NULL;
00279 }
00280
00281 Size>>=1;
00282 }
00283
00284 return THandle;
00285 }
|
|
||||||||||||||||||||||||
|
Definition at line 290 of file D3DDrv/THandle.cpp. References AppInfo, THandle_MipData::CacheType, App_Info::CanDoMultiTexture, CurrentSurfDesc, D3DCache_TypeCreate(), D3DSetTexture(), THandle_MipData::Flags, GE_FALSE, GetLog(), geRDriver_THandle::Height, int32, LMapCache, geRDriver_THandle::Log, MAX_LMAP_LOG_SIZE, geRDriver_THandle::MipData, NULL, geRDriver_THandle::NumMipLevels, geRDriver_THandle::Stride, THandle_MipData::Texture, TextureCache, THandle_CreateSurfaces(), THandle_Destroy(), THANDLE_MAX_MIP_LEVELS, THANDLE_UPDATE, TSTAGE_1, uint8, and geRDriver_THandle::Width.
00291 {
00292 int32 Size, Stage;
00293
00294 assert(NumMipLevels < THANDLE_MAX_MIP_LEVELS);
00295
00296 assert(NumMipLevels == 1);
00297
00298 // Save some info about the lightmap
00299 THandle->Width = Width;
00300 THandle->Height = Height;
00301 THandle->NumMipLevels = (uint8)NumMipLevels;
00302 THandle->Log = (uint8)GetLog(Width, Height);
00303 THandle->Stride = 1<<THandle->Log;
00304
00305 assert(THandle->Log < MAX_LMAP_LOG_SIZE);
00306
00307 Size = 1<<THandle->Log;
00308
00309 THandle->MipData = (THandle_MipData*)malloc(sizeof(THandle_MipData)*NumMipLevels);
00310 memset(THandle->MipData, 0, sizeof(THandle_MipData)*NumMipLevels);
00311
00312 THandle->MipData[0].Flags = THANDLE_UPDATE;
00313
00314 #ifdef D3D_MANAGE_TEXTURES
00315 #ifndef USE_TPAGES
00316 {
00317 int32 Stage;
00318
00319 if (AppInfo.CanDoMultiTexture)
00320 Stage = STAGE_1;
00321 else
00322 Stage = 0;
00323
00324 if (!THandle_CreateSurfaces(&THandle->MipData[0], Size, Size, &CurrentSurfDesc, GE_FALSE, Stage))
00325 {
00326 THandle_Destroy(THandle);
00327 return NULL;
00328 }
00329
00330 D3DSetTexture(0, THandle->MipData[0].Texture);
00331 }
00332 #endif
00333 #endif
00334
00335 if (AppInfo.CanDoMultiTexture)
00336 Stage = TSTAGE_1;
00337 else
00338 Stage = 0;
00339
00340 #ifdef USE_ONE_CACHE
00341 THandle->MipData[0].CacheType = D3DCache_TypeCreate(TextureCache, Size, Size, NumMipLevels, Stage, &CurrentSurfDesc);
00342 #else
00343 THandle->MipData[0].CacheType = D3DCache_TypeCreate(LMapCache, Size, Size, NumMipLevels, Stage, &CurrentSurfDesc);
00344 #endif
00345
00346 if (!THandle->MipData[0].CacheType)
00347 {
00348 THandle_Destroy(THandle);
00349 return NULL;
00350 }
00351
00352 return THandle;
00353 }
|
|
|
Definition at line 600 of file D3DDrv/THandle.cpp. References AppInfo, App_Info::ddTexFormat, DestroySystemToVideoSurfaces(), GE_FALSE, GE_TRUE, geBoolean, int32, MAX_LMAP_LOG_SIZE, SystemToVideo, and THandle_CreateSurfaces().
00601 {
00602 int32 i;
00603 DDSURFACEDESC2 SurfDesc;
00604
00605 memcpy(&SurfDesc, &AppInfo.ddTexFormat, sizeof(DDSURFACEDESC2));
00606
00607 for (i=0; i<MAX_LMAP_LOG_SIZE; i++)
00608 {
00609 int32 Size;
00610
00611 Size = 1<<i;
00612
00613 if (!THandle_CreateSurfaces(&SystemToVideo[i], Size, Size, &SurfDesc, GE_FALSE, 1))
00614 {
00615 DestroySystemToVideoSurfaces();
00616 return GE_FALSE;
00617 }
00618 }
00619
00620 return GE_TRUE;
00621 }
|
|
|
Definition at line 626 of file D3DDrv/THandle.cpp. References int32, MAX_LMAP_LOG_SIZE, SystemToVideo, and THandle_DestroySurfaces().
00627 {
00628 int32 i;
00629
00630 for (i=0; i<MAX_LMAP_LOG_SIZE; i++)
00631 THandle_DestroySurfaces(&SystemToVideo[i]);
00632 }
|
|
|
Definition at line 115 of file D3DDrv/THandle.cpp. References geRDriver_THandle::Active, DRV_ERROR_GENERIC, int32, MAX_TEXTURE_HANDLES, NULL, SetLastDrvError(), and TextureHandles.
00116 {
00117 int32 i;
00118 geRDriver_THandle *pHandle;
00119
00120 pHandle = TextureHandles;
00121
00122 for (i=0; i< MAX_TEXTURE_HANDLES; i++, pHandle++)
00123 {
00124 if (!pHandle->Active)
00125 {
00126 memset(pHandle, 0, sizeof(geRDriver_THandle));
00127 pHandle->Active = 1;
00128 return pHandle;
00129 }
00130 }
00131
00132 SetLastDrvError(DRV_ERROR_GENERIC, "D3D_FindTextureHandle: No more handles left.\n");
00133
00134 return NULL;
00135 }
|
|
|
Definition at line 80 of file D3DDrv/THandle.cpp. References D3DCache_Destroy(), DDMemMgr_Destroy(), DDMemMgr_PartitionDestroy(), LMapCache, MemMgr, NULL, Partition, TextureCache, TPage_MgrDestroy(), and TPageMgr.
00081 {
00082 if (LMapCache)
00083 D3DCache_Destroy(LMapCache);
00084
00085 if (TextureCache)
00086 D3DCache_Destroy(TextureCache);
00087
00088 LMapCache = NULL;
00089 TextureCache = NULL;
00090
00091 if (Partition[1])
00092 DDMemMgr_PartitionDestroy(Partition[1]);
00093 if (Partition[0])
00094 DDMemMgr_PartitionDestroy(Partition[0]);
00095 if (MemMgr)
00096 DDMemMgr_Destroy(MemMgr);
00097
00098
00099 #ifdef USE_TPAGES
00100 if (TPageMgr)
00101 {
00102 TPage_MgrDestroy(&TPageMgr);
00103 TPageMgr = NULL;
00104 }
00105 #endif
00106
00107 Partition[1] = NULL;
00108 Partition[0] = NULL;
00109 MemMgr = NULL;
00110 }
|
|
|
Definition at line 140 of file D3DDrv/THandle.cpp. References geRDriver_THandle::Active, GE_FALSE, GE_TRUE, geBoolean, int32, MAX_TEXTURE_HANDLES, TextureHandles, and THandle_Destroy().
00141 {
00142 int32 i;
00143 geRDriver_THandle *pHandle;
00144
00145 pHandle = TextureHandles;
00146
00147 for (i=0; i< MAX_TEXTURE_HANDLES; i++, pHandle++)
00148 {
00149 if (!pHandle->Active)
00150 continue;
00151
00152 if (!THandle_Destroy(pHandle))
00153 return GE_FALSE;
00154 }
00155
00156 return GE_TRUE;
00157 }
|
|
|
Definition at line 392 of file D3DDrv/THandle.cpp. References AppInfo, CurrentSurfDesc, App_Info::ddFourBitAlphaSurfFormat, App_Info::ddOneBitAlphaSurfFormat, App_Info::ddTexFormat, DRV_ERROR_GENERIC, GE_FALSE, GE_PIXELFORMAT_16BIT_1555_ARGB, GE_PIXELFORMAT_16BIT_4444_ARGB, GE_PIXELFORMAT_16BIT_555_RGB, GE_PIXELFORMAT_16BIT_565_RGB, GE_TRUE, geBoolean, PixelFormat, and SetLastDrvError().
00393 {
00394 switch (PixelFormat)
00395 {
00396 case GE_PIXELFORMAT_16BIT_555_RGB:
00397 case GE_PIXELFORMAT_16BIT_565_RGB:
00398 {
00399 memcpy(&CurrentSurfDesc, &AppInfo.ddTexFormat, sizeof(DDSURFACEDESC2));
00400 break;
00401 }
00402 case GE_PIXELFORMAT_16BIT_4444_ARGB:
00403 {
00404 memcpy(&CurrentSurfDesc, &AppInfo.ddFourBitAlphaSurfFormat, sizeof(DDSURFACEDESC2));
00405 break;
00406 }
00407 case GE_PIXELFORMAT_16BIT_1555_ARGB:
00408 {
00409 memcpy(&CurrentSurfDesc, &AppInfo.ddOneBitAlphaSurfFormat, sizeof(DDSURFACEDESC2));
00410 break;
00411 }
00412
00413 default:
00414 {
00415 SetLastDrvError(DRV_ERROR_GENERIC, "SetupCurrent3dDesc: Invalid pixel format.\n");
00416 return GE_FALSE;
00417 }
00418 }
00419
00420 return GE_TRUE;
00421 }
|
|
|
Definition at line 724 of file D3DDrv/THandle.cpp. References AppInfo, CacheNeedsUpdate, App_Info::CanDoMultiTexture, D3DCache_AdjustSlots(), D3DMain_Log(), App_Info::DeviceIdentifier, GE_FALSE, GE_TRUE, geBoolean, int32, LMapCache, MAX_TEXTURE_HANDLES, geRDriver_THandle::MipData, NULL, geRDriver_THandle::NumMipLevels, THandle_MipData::Slot, TextureCache, TextureHandles, TSTAGE_0, and TSTAGE_1.
00725 {
00726 geRDriver_THandle *pTHandle;
00727 int32 i, Stage0, Stage1;
00728 int32 MaxTable1[9], MaxTable2[9];
00729
00730 if (!CacheNeedsUpdate)
00731 return GE_TRUE;
00732
00733 #ifndef D3D_MANAGE_TEXTURES // If D3D is managing textures, then we don't ned to do any of this...
00734 D3DMain_Log("THandle_CheckCache: Resetting texture cache...\n");
00735
00736 #ifdef USE_ONE_CACHE
00737 #pragma message ("There numbers ARE NOT DONE. So if USE_ONE_CACHE is defined, please finish this...")
00738 // Texture cache & Lightmap cache (we are only using one cache, so the combine into the TextureCache)
00739 MaxTable1[0] = 256; // 1x1
00740 MaxTable1[1] = 256; // 2x2
00741 MaxTable1[2] = 256; // 4x4
00742 MaxTable1[3] = 512; // 8x8
00743 MaxTable1[4] = 512; // 16x16
00744 MaxTable1[5] = 512; // 32x32
00745 MaxTable1[6] = 512; // 64x64
00746 MaxTable1[7] = 256; //128x128
00747 MaxTable1[8] = 256; //256x256
00748 #else
00749 if (AppInfo.DeviceIdentifier.dwVendorId == 4634) // 3dfx series have a limit on the number of texture handles
00750 {
00751 D3DMain_Log(" 3dfx card detected, using smaller number of handles...\n");
00752
00753 // Texture cache
00754 MaxTable1[0] = 24; // 1x1
00755 MaxTable1[1] = 24; // 2x2
00756 MaxTable1[2] = 24; // 4x4
00757 MaxTable1[3] = 24; // 8x8
00758 MaxTable1[4] = 24; // 16x16
00759 MaxTable1[5] = 128; // 32x32
00760 MaxTable1[6] = 128; // 64x64
00761 MaxTable1[7] = 128; //128x128
00762 MaxTable1[8] = 128; //256x256
00763
00764 // Lightmap cache
00765 MaxTable2[0] = 128; // 1x1
00766 MaxTable2[1] = 128; // 2x2
00767 MaxTable2[2] = 256; // 4x4
00768 MaxTable2[3] = 256; // 8x8
00769 MaxTable2[4] = 256; // 16x16
00770 MaxTable2[5] = 128; // 32x32
00771 MaxTable2[6] = 128; // 64x64
00772 MaxTable2[7] = 128; //128x128
00773 MaxTable2[8] = 128; //256x256
00774 }
00775 else
00776 {
00777 D3DMain_Log(" NO 3dfx card detected, using larger number of handles...\n");
00778
00779 // Texture cache
00780 MaxTable1[0] = 32; // 1x1
00781 MaxTable1[1] = 32; // 2x2
00782 MaxTable1[2] = 32; // 4x4
00783 MaxTable1[3] = 32; // 8x8
00784 MaxTable1[4] = 32; // 16x16
00785 MaxTable1[5] = 32; // 32x32
00786 MaxTable1[6] = 128; // 64x64
00787 MaxTable1[7] = 128; //128x128
00788 MaxTable1[8] = 128; //256x256
00789
00790 MaxTable2[0] = 128; // 1x1
00791 MaxTable2[1] = 128; // 2x2
00792 MaxTable2[2] = 256; // 4x4
00793 MaxTable2[3] = 1024; // 8x8
00794 MaxTable2[4] = 1024; // 16x16
00795 MaxTable2[5] = 512; // 32x32
00796 MaxTable2[6] = 256; // 64x64
00797 MaxTable2[7] = 256; //128x128
00798 MaxTable2[8] = 256; //256x256
00799 }
00800 #endif
00801
00802 if (AppInfo.CanDoMultiTexture)
00803 {
00804 Stage0 = TSTAGE_0;
00805 Stage1 = TSTAGE_1;
00806 }
00807 else
00808 {
00809 Stage0 = 0;
00810 Stage1 = 0;
00811 }
00812
00813 #ifndef USE_ONE_CACHE
00814 if (!D3DCache_AdjustSlots(LMapCache, MaxTable2, GE_TRUE))
00815 {
00816 D3DMain_Log("THandle_CheckCache: D3DCache_AdjustSlots failed for LMapCache.\n");
00817 return GE_FALSE;
00818 }
00819 #endif
00820
00821 if (!D3DCache_AdjustSlots(TextureCache, MaxTable1, GE_FALSE))
00822 {
00823 D3DMain_Log("THandle_CheckCache: D3DCache_AdjustSlots failed for TextureCache.\n");
00824 return GE_FALSE;
00825 }
00826
00827 #endif
00828
00829 // Make sure no THandles reference any slots, because they mave have been moved around, or gotten destroyed...
00830 // (Evict all textures in the cache)
00831 pTHandle = TextureHandles;
00832
00833 for (i=0; i< MAX_TEXTURE_HANDLES; i++, pTHandle++)
00834 {
00835 int32 m;
00836
00837 for (m=0; m< pTHandle->NumMipLevels; m++)
00838 {
00839 pTHandle->MipData[m].Slot = NULL;
00840 }
00841 }
00842
00843 CacheNeedsUpdate = GE_FALSE;
00844
00845 return GE_TRUE;
00846 }
|
|
||||||||||||||||||||
|
Definition at line 425 of file D3DDrv/THandle.cpp. References AppInfo, CacheNeedsUpdate, Create2DTHandle(), Create3DTHandle(), CreateLightmapTHandle(), CurrentSurfDesc, App_Info::ddSurfFormat, DRIVERCC, DRV_ERROR_GENERIC, FindTextureHandle(), geRDriver_PixelFormat::Flags, GE_TRUE, NULL, geRDriver_PixelFormat::PixelFormat, PixelFormat, geRDriver_THandle::PixelFormat, RDRIVER_PF_2D, RDRIVER_PF_3D, RDRIVER_PF_LIGHTMAP, SetLastDrvError(), and SetupCurrent3dDesc().
00426 {
00427 geRDriver_THandle *THandle;
00428
00429 THandle = FindTextureHandle();
00430
00431 if (!THandle)
00432 {
00433 SetLastDrvError(DRV_ERROR_GENERIC, "D3DDRV:THandle_Create: Out of texture handles.\n");
00434 return NULL;
00435 }
00436
00437 THandle->PixelFormat = *PixelFormat;
00438
00439 if (PixelFormat->Flags & RDRIVER_PF_3D)
00440 {
00441 // Get the pixel format desc for this thandle
00442 if (!SetupCurrent3dDesc(PixelFormat->PixelFormat))
00443 return NULL;
00444
00445 if (!Create3DTHandle(THandle, Width, Height, NumMipLevels, PixelFormat))
00446 return NULL;
00447
00448 CacheNeedsUpdate = GE_TRUE;
00449 }
00450 else if (PixelFormat->Flags & RDRIVER_PF_LIGHTMAP)
00451 {
00452 // Get the pixel format desc for this thandle
00453 if (!SetupCurrent3dDesc(PixelFormat->PixelFormat))
00454 return NULL;
00455
00456 if (!CreateLightmapTHandle(THandle, Width, Height, NumMipLevels, PixelFormat))
00457 return NULL;
00458
00459 CacheNeedsUpdate = GE_TRUE;
00460 }
00461 else if (PixelFormat->Flags & RDRIVER_PF_2D)
00462 {
00463 // 2d surfaces are always this format for now
00464 memcpy(&CurrentSurfDesc, &AppInfo.ddSurfFormat, sizeof(DDSURFACEDESC2));
00465
00466 if (!Create2DTHandle(THandle, Width, Height, NumMipLevels, PixelFormat))
00467 return NULL;
00468 }
00469
00470 return THandle;
00471 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 637 of file D3DDrv/THandle.cpp. References AppInfo, DRV_ERROR_GENERIC, FALSE, GE_FALSE, GE_TRUE, geBoolean, App_Info::lpDD, NULL, SetLastDrvError(), THandle_MipData::Surface, and THandle_MipData::Texture.
00638 {
00639 LPDIRECTDRAWSURFACE4 Surface;
00640 DDSURFACEDESC2 ddsd;
00641 HRESULT Hr;
00642
00643 memcpy(&ddsd, SurfDesc, sizeof(DDSURFACEDESC2));
00644
00645 ddsd.dwSize = sizeof(DDSURFACEDESC2);
00646 ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_TEXTURESTAGE;
00647
00648 #ifdef D3D_MANAGE_TEXTURES
00649 ColorKey = GE_TRUE; // Force a colorkey on system surfaces since we are letting D3D do our cacheing...
00650
00651 ddsd.ddsCaps.dwCaps = 0;
00652 ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_HINTDYNAMIC;
00653 #else
00654 ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
00655 ddsd.ddsCaps.dwCaps2 = 0;//DDSCAPS2_HINTDYNAMIC;
00656 #endif
00657
00658 ddsd.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
00659 ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_HINTDYNAMIC;
00660
00661 ddsd.ddsCaps.dwCaps3 = 0;
00662 ddsd.ddsCaps.dwCaps4 = 0;
00663 ddsd.dwWidth = Width;
00664 ddsd.dwHeight = Height;
00665
00666 ddsd.dwTextureStage = Stage;
00667
00668 Hr = AppInfo.lpDD->CreateSurface(&ddsd, &Surface, NULL);
00669
00670 if(Hr != DD_OK)
00671 {
00672 return FALSE;
00673 }
00674
00675 Surf->Surface = Surface;
00676
00677 Surf->Texture = NULL;
00678
00679 Hr = Surface->QueryInterface(IID_IDirect3DTexture2, (void**)&Surf->Texture);
00680
00681 if(Hr != DD_OK)
00682 {
00683 Surface->Release();
00684 return GE_FALSE;
00685 }
00686
00687 if (ColorKey)
00688 {
00689 DDCOLORKEY CKey;
00690
00691 // Create the color key for this surface
00692 CKey.dwColorSpaceLowValue = 1;
00693 CKey.dwColorSpaceHighValue = 1;
00694
00695 if (Surf->Surface->SetColorKey(DDCKEY_SRCBLT , &CKey) != DD_OK)
00696 {
00697 SetLastDrvError(DRV_ERROR_GENERIC, "THandle_CreateSurfaces: SetColorKey failed for texture.");
00698 Surf->Surface->Release();
00699 Surf->Surface = NULL;
00700 Surf->Texture->Release();
00701 Surf->Texture = NULL;
00702 return FALSE;
00703 }
00704 }
00705 return GE_TRUE; // All good dude
00706 }
|
|
|
Definition at line 476 of file D3DDrv/THandle.cpp. References geRDriver_THandle::Active, CacheNeedsUpdate, THandle_MipData::CacheType, D3DCache_TypeDestroy(), DRIVERCC, GE_TRUE, geBoolean, int32, geRDriver_THandle::MipData, NULL, geRDriver_THandle::NumMipLevels, THandle_MipData::Surface, THandle_MipData::Texture, and THandle_DestroySurfaces().
00477 {
00478 int32 i;
00479
00480 assert(THandle);
00481 assert(THandle->Active);
00482
00483 for (i=0; i< THandle->NumMipLevels; i++)
00484 {
00485 assert(THandle->MipData);
00486
00487 if (THandle->MipData[i].CacheType)
00488 {
00489 D3DCache_TypeDestroy(THandle->MipData[i].CacheType);
00490 CacheNeedsUpdate = GE_TRUE;
00491 THandle->MipData[i].CacheType = NULL;
00492 }
00493
00494 if (THandle->MipData[i].Surface)
00495 {
00496 assert(THandle->MipData[i].Texture);
00497
00498 THandle_DestroySurfaces(&THandle->MipData[i]);
00499 THandle->MipData[i].Surface = NULL;
00500 THandle->MipData[i].Texture = NULL;
00501 }
00502 }
00503
00504 if (THandle->MipData)
00505 free(THandle->MipData);
00506
00507 memset(THandle, 0, sizeof(geRDriver_THandle));
00508
00509 return GE_TRUE;
00510 }
|
|
|
Definition at line 711 of file D3DDrv/THandle.cpp. References THandle_MipData::Surface, and THandle_MipData::Texture.
00712 {
00713 if (Surf->Texture)
00714 Surf->Texture->Release();
00715 if (Surf->Surface)
00716 Surf->Surface->Release();
00717
00718 memset(Surf, 0, sizeof (THandle_MipData));
00719 }
|
|
||||||||||||||||
|
||||||||||||||||
|
Definition at line 514 of file D3DDrv/THandle.cpp. References DRIVERCC, THandle_MipData::Flags, GE_FALSE, GE_TRUE, geBoolean, geRDriver_THandle::MipData, NULL, THandle_MipData::Surface, and THANDLE_LOCKED.
00515 {
00516 DDSURFACEDESC2 SurfDesc;
00517 HRESULT Result;
00518
00519 assert(!(THandle->MipData[MipLevel].Flags & THANDLE_LOCKED));
00520
00521 // Lock the surface so it can be filled with the data
00522 memset(&SurfDesc, 0, sizeof(DDSURFACEDESC2));
00523 SurfDesc.dwSize = sizeof(DDSURFACEDESC2);
00524
00525 Result = THandle->MipData[MipLevel].Surface->Lock(NULL, &SurfDesc, DDLOCK_WAIT, NULL);
00526
00527 if (Result != DD_OK)
00528 {
00529 return GE_FALSE;
00530 }
00531
00532 THandle->MipData[MipLevel].Flags |= THANDLE_LOCKED;
00533
00534 *Bits = (void*)SurfDesc.lpSurface;
00535
00536 return GE_TRUE;
00537 }
|
|
|
Definition at line 216 of file D3DDrv/THandle.cpp. References CacheNeedsUpdate, DestroySystemToVideoSurfaces(), FreeAllCaches(), FreeAllTextureHandles(), and GE_FALSE.
00217 {
00218 FreeAllTextureHandles();
00219 FreeAllCaches();
00220 DestroySystemToVideoSurfaces();
00221
00222 CacheNeedsUpdate = GE_FALSE;
00223 }
|
|
|
Definition at line 161 of file D3DDrv/THandle.cpp. References AppInfo, App_Info::CanDoMultiTexture, CreateSystemToVideoSurfaces(), D3DCache_Create(), DDMemMgr_Create(), DDMemMgr_GetFreeMem(), DDMemMgr_PartitionCreate(), App_Info::ddTexFormat, GE_FALSE, GE_TRUE, geBoolean, geFloat, LMapCache, App_Info::lpDD, MemMgr, Partition, TEXTURE_CACHE_PERCENT, TextureCache, THandle_Shutdown(), TPage_MgrCreate(), TPageMgr, uint32, and App_Info::VidMemFree.
00162 {
00163 // Create the main memory manager
00164 MemMgr = DDMemMgr_Create(AppInfo.VidMemFree);
00165
00166 if (!MemMgr)
00167 goto ExitWithError;
00168
00169 // Create partition 0
00170 Partition[0] = DDMemMgr_PartitionCreate(MemMgr, (uint32)((geFloat)DDMemMgr_GetFreeMem(MemMgr)*TEXTURE_CACHE_PERCENT));
00171
00172 if (!Partition[0])
00173 goto ExitWithError;
00174
00175 // Create partition 1
00176 Partition[1] = DDMemMgr_PartitionCreate(MemMgr, DDMemMgr_GetFreeMem(MemMgr));
00177
00178 if (!Partition[1])
00179 goto ExitWithError;
00180
00181 // Create the texture cache from partition 0
00182 TextureCache = D3DCache_Create("Main Texture Cache", AppInfo.lpDD, Partition[0], AppInfo.CanDoMultiTexture);
00183
00184 if (!TextureCache)
00185 goto ExitWithError;
00186
00187 #ifndef USE_ONE_CACHE
00188 // Create the lmap cache from partition 1
00189 LMapCache = D3DCache_Create("Lightmap Cache", AppInfo.lpDD, Partition[1], AppInfo.CanDoMultiTexture);
00190
00191 if (!LMapCache)
00192 goto ExitWithError;
00193 #endif
00194
00195 // Create all the system to video surfaces (for lmaps)
00196 if (!CreateSystemToVideoSurfaces())
00197 goto ExitWithError;
00198
00199 #ifdef USE_TPAGES
00200 TPageMgr = TPage_MgrCreate(AppInfo.lpDD, &AppInfo.ddTexFormat, 512);
00201 if (!TPageMgr)
00202 goto ExitWithError;
00203 #endif
00204
00205 return GE_TRUE;
00206
00207 ExitWithError:
00208 {
00209 THandle_Shutdown();
00210 return GE_FALSE;
00211 }
00212 }
|
|
||||||||||||
|
Definition at line 542 of file D3DDrv/THandle.cpp. References DRIVERCC, THandle_MipData::Flags, GE_FALSE, GE_TRUE, geBoolean, geRDriver_THandle::MipData, NULL, THandle_MipData::Surface, THANDLE_LOCKED, and THANDLE_UPDATE.
00543 {
00544 HRESULT Result;
00545
00546 assert(MipLevel <= THandle->NumMipLevels);
00547 assert(THandle->MipData[MipLevel].Flags & THANDLE_LOCKED);
00548
00549 // Unlock the surface
00550 Result = THandle->MipData[MipLevel].Surface->Unlock(NULL);
00551
00552 if (Result != DD_OK)
00553 {
00554 return GE_FALSE;
00555 }
00556
00557 THandle->MipData[MipLevel].Flags |= THANDLE_UPDATE;
00558 THandle->MipData[MipLevel].Flags &= ~THANDLE_LOCKED;
00559
00560 return GE_TRUE;
00561 }
|
|
|
Definition at line 66 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 62 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 58 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 54 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 55 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 64 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 57 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 52 of file D3DDrv/THandle.cpp. |
|
|
Definition at line 60 of file D3DDrv/THandle.cpp. |
1.3.2