Repository navigation
Conversation
_blockAlloc() frees textures with a growing weight limit until a free block is large enough. The loop has no exit: when the texture is larger than all VRAM the manager owns (4 MiB minus frame and z buffers), or when gsKit_TexManager_init() was never called (__head is NULL), the loop keeps incrementing the weight forever. The program hangs in gsKit_TexManager_bind(), e.g. SDL binds every texture through it, so one oversized SDL texture freezes the app. Count the textures that are still in VRAM during each pass. When a pass finds nothing left to free and no block fits, return NULL. Make gsKit_TexManager_bind() handle NULL: print an error, clear tex->Vram and tex->VramClut and return 0 without uploading. Tested on real hardware (PSX DESR-5100 via ps2link): binding a 256x256 texture into 64 KiB of free VRAM hangs unpatched and returns with an error message with this change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
gsKit_TexManager_bind()→_blockAlloc()frees textures with a growing weight limit until a free block is large enough. The loop has no exit condition: when the texture is larger than all the VRAM the manager owns (4 MiB minus the frame and z buffers), or whengsKit_TexManager_init()was never called (__headis NULL), the loop keeps incrementing the weight forever and the program hangs.Every texture goes through
gsKit_TexManager_bind()— for example SDL binds every texture that way — so a single oversized texture freezes the whole application.Fix
Count the textures still resident in VRAM on each pass. When a pass finds nothing left to free and no block fits,
_blockAlloc()returns NULL.gsKit_TexManager_bind()then handles NULL: it prints an error, clearstex->Vram/tex->VramClutand returns without uploading, instead of hanging.Testing
Tested on real hardware: a PSX DESR-5100 (PS2-based), with a test program started via ps2link. A 256×256 CT32 texture (256 KiB) is bound through a
GSGLOBALwhose free VRAM is only 64 KiB.gsKit_TexManager_bind()runs in a separate low-priority thread; the main thread waits up to 2 s.haengtafter 2 s and has to terminate it).gsKit: TexManager: texture does not fit in VRAM, and leavestex->Vram = 0.🤖 Generated with Claude Code