File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,29 @@ bool CRenderWareSA::ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTe
260260 perTxdInfo.usingTextures .push_back (pNewTexture);
261261 }
262262
263+ // Request space from the SA streaming system for the new textures.
264+ // This reduces mem pressure/OOM by encouraging the engine to free unused resources.
265+ // Note: We do not modify CStreamingInfo::sizeInBlocks as that affects disk I/O during model reload.
266+ // Only perform this check for new rasters (not copies) to avoid double-counting shared resources.
267+ if (!perTxdInfo.bTexturesAreCopies && pGame->GetStreaming ())
268+ {
269+ uint32_t uiTotalSize = 0 ;
270+ for (RwTexture* pNewTexture : perTxdInfo.usingTextures )
271+ {
272+ if (pNewTexture && SharedUtil::IsReadablePointer (pNewTexture, sizeof (RwTexture)) && pNewTexture->raster )
273+ {
274+ // Estimate texture size (Width * Height * 4 bytes for 32-bit).
275+ // This helps the SA streaming system manage memory pressure.
276+ uiTotalSize += pNewTexture->raster ->width * pNewTexture->raster ->height * 4 ;
277+ }
278+ }
279+
280+ if (uiTotalSize > 0 )
281+ {
282+ pGame->GetStreaming ()->MakeSpaceFor (uiTotalSize);
283+ }
284+ }
285+
263286 //
264287 // Add each texture to the target txd
265288 //
You can’t perform that action at this time.
0 commit comments