MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / d3d_FreeTextureCache

Function d3d_FreeTextureCache

legacy/renderer/Direct3D.cpp:876–935  ·  view source on GitHub ↗

Frees all the memory used by the texture cache

Source from the content-addressed store, hash-verified

874
875// Frees all the memory used by the texture cache
876void d3d_FreeTextureCache() {
877 int i;
878
879 if (UploadSurfaces) {
880 for (i = 0; i < NUM_TEXTURE_CLASSES; i++) {
881 UploadSurfaces[i]->Release();
882 }
883
884 mem_free(UploadSurfaces);
885 UploadSurfaces = NULL;
886 }
887
888 if (Upload4444Surfaces) {
889 for (i = 0; i < NUM_TEXTURE_CLASSES; i++) {
890 Upload4444Surfaces[i]->Release();
891 }
892
893 mem_free(Upload4444Surfaces);
894 Upload4444Surfaces = NULL;
895 }
896
897 if (BitmapTextureSurfaces) {
898 for (i = 0; i < MAX_BITMAPS; i++) {
899 if (GameBitmaps[i].cache_slot != -1) {
900 if (GameBitmaps[i].cache_slot != i) {
901 mprintf(0, "Error cache slot is %d when it should be %d!\n", GameBitmaps[i].cache_slot, i);
902 }
903
904 ASSERT(GameBitmaps[i].cache_slot == i);
905
906 d3d_FreePreUploadedTexture(i, MAP_TYPE_BITMAP);
907 }
908 }
909
910 mem_free(BitmapTextureSurfaces);
911 BitmapTextureSurfaces = NULL;
912 }
913
914 if (BumpmapTextureSurfaces) {
915 for (i = 0; i < MAX_BUMPMAPS; i++) {
916 if (GameBumpmaps[i].cache_slot != -1) {
917 ASSERT(GameBumpmaps[i].cache_slot == i);
918 d3d_FreePreUploadedTexture(i, MAP_TYPE_BUMPMAP);
919 }
920 }
921 mem_free(BumpmapTextureSurfaces);
922 BumpmapTextureSurfaces = NULL;
923 }
924
925 if (LightmapTextureSurfaces) {
926 for (i = 0; i < MAX_LIGHTMAPS; i++) {
927 if (GameLightmaps[i].cache_slot != -1) {
928 ASSERT(GameLightmaps[i].cache_slot == i);
929 d3d_FreePreUploadedTexture(i, MAP_TYPE_LIGHTMAP);
930 }
931 }
932 mem_free(LightmapTextureSurfaces);
933 LightmapTextureSurfaces = NULL;

Callers 2

d3d_CloseFunction · 0.85
d3d_ResetCacheFunction · 0.85

Calls 1

Tested by

no test coverage detected