New Feature: Dynamic Texture Loading #24
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added dynamic texture loading during level load to reduce memory footprint on the GPU. Now only loads textures needed for level instead of entire texture library.
Changes:
Renderer.h
Add new enum RT_MaterialTextureLoadState to specify if material textures are loaded or unloaded.
Add new fields texture_load_state, texture_load_state_next to RT_Material track current/future state of textures.
RTmaterials.h
Add new variable g_rt_material_paths_exist to track if individual textures exist.
Add new method RT_VerifyMaterialTexturesFromPaths to populate g_rt_material_paths_exist
RTmaterials.c
Updated RT_InitAllBitmaps to only load material information, no longer loads texture maps.
Added Function RT_SyncMaterialStates to compare current/future state of material and load/unload it accordingly.
level.c
Updated RT_UploadLevelGeometry() to record what textures are need for the level and then call RT_SyncMaterialStates()
Updated RT_LoadLevel to call RT_ResetLightEmission() to fix bug where blinking end levels lights would not get reset during level warp.
gameseq.c
Updated LoadLevel to move display of Loading (Prepare for Descent) box before the level attempts to load to act as a loading screen now that it takes longer due to textures loading.
Updated StartNewLevelSub to move reset_special_effects() before level load so that wall textures are reset and correct textures will be loaded in.
RenderBackend.cpp
Updated ReleaseTexture to add line g_d3d.resource_tracker.Release(texture_resource->texture) to fix issue with GPU not releasing texture memory. I found this through trial and error and not 100% certain this is the correct way to deal with this.
NOTE: This PR also contains fixes for compressed textures with less than 1 byte per pixel. May want to review/approve that PR first before this one.