Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Dynamic Texture Loading #24

Merged

Conversation

Lehm2000
Copy link
Contributor

@Lehm2000 Lehm2000 commented Jun 3, 2024

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.

Copy link
Collaborator

@SamBoots SamBoots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seems good here, works as intended.

@SamBoots SamBoots merged commit afae0c4 into BredaUniversityGames:main Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants