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 @@ -263,6 +263,29 @@ bool CRenderWareSA::ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTe
263263 perTxdInfo.usingTextures .push_back (pNewTexture);
264264 }
265265
266+ // Request space from the SA streaming system for the new textures.
267+ // This reduces mem pressure/OOM by encouraging the engine to free unused resources.
268+ // Note: We do not modify CStreamingInfo::sizeInBlocks as that affects disk I/O during model reload.
269+ // Only perform this check for new rasters (not copies) to avoid double-counting shared resources.
270+ if (!perTxdInfo.bTexturesAreCopies && pGame->GetStreaming ())
271+ {
272+ uint32_t uiTotalSize = 0 ;
273+ for (RwTexture* pNewTexture : perTxdInfo.usingTextures )
274+ {
275+ if (pNewTexture && SharedUtil::IsReadablePointer (pNewTexture, sizeof (RwTexture)) && pNewTexture->raster )
276+ {
277+ // Estimate texture size (Width * Height * 4 bytes for 32-bit).
278+ // This helps the SA streaming system manage memory pressure.
279+ uiTotalSize += pNewTexture->raster ->width * pNewTexture->raster ->height * 4 ;
280+ }
281+ }
282+
283+ if (uiTotalSize > 0 )
284+ {
285+ pGame->GetStreaming ()->MakeSpaceFor (uiTotalSize);
286+ }
287+ }
288+
266289 //
267290 // Add each texture to the target txd
268291 //
You can’t perform that action at this time.
0 commit comments