Files
ReSkate/Extension/World/texture_handle_limit.h
AyeZeeBB a83cb83bb4 Raise the streamed texture limit to 32764, and warn when it is close
The game can stream 20480 textures at once. When a map and its mods
need one more, it takes a slot past the end of its table and waits for
ever on a byte that is part of a counter: a hang, then a crash in the
hang's own report (crash reports of 2026-10-11).

The limit is raised to 32764, the most a texture's 16-bit handle can
index, before the game makes its texture streaming manager:

- The manager is allocated longer (6.0 MB, was 2.3 MB) and its slot
  table and per-slot floats moved behind its end. Each of the 226
  instructions that hold one of those offsets or sizes gets another
  number; no code is added. Its four fixed lists are pointed at longer
  storage once the constructor has run.
- The renderer keeps a block of floats per slot for each of four
  layers. Its object grows to match (27 instructions), and the two
  places that index a layer's block as layer * 20480 become a multiply
  by the new count, in the same twelve bytes.
- Three functions keep 20480 entries on their own stack. Two list
  filters go through a longer list a stretch at a time, and the sort
  is given scratch room of its own past that many. Up to 20480 they
  run as the game wrote them.

Every instruction is checked byte for byte first, and nothing is
changed if any differs or the manager already exists. An empty
texture_limit_stock.txt beside the game leaves the limit as it is.

Players are told when they come close: a notice at 90% of the limit
in force and an error at 100%, each once until use falls below 80%.
The log records each new high in steps of 5%.

Also: when a function of the game finds its stack written over, the
game ends itself with exit code 0xc0000409 and no crash report. The
log now names that function and its callers first.

The site table (texture_streaming_sites.inc) is generated from a sweep
of the supported build; texture_streaming.h describes the layout.

Tested in game below 20480 textures only. Nothing has run above the
old limit, where the three stack guards and the longer lists first
matter. At 32764 the game still hangs; the notice is the protection.
2026-10-11 19:26:23 -05:00

23 lines
1.0 KiB
C++

#pragma once
#include <cstdint>
// The game can stream 20480 textures at once and hangs when a map and its mods need more
// (Engine/Game/Build/<build>/texture_streaming.h). This raises the limit to 32764, the most a
// texture's handle can hold, by moving the manager's tables into a longer allocation before the
// game makes the manager; and it tells the player when the limit, raised or not, is close.
namespace dingosdk::texture_handle_limit {
// Checks every instruction this build is known by and changes them; once, before the game has
// made its texture streaming manager. False when the build differs or the manager is already
// there: the game keeps its own limit.
bool install(std::uintptr_t base) noexcept;
struct Use {
bool known{}; // the manager is there
std::uint32_t limit{}; // 20480, or 32764 when raised
std::uint32_t taken{}; // slots the manager has handed out at its two ends
};
Use use() noexcept;
// Client thread, every tick: a notice when the textures loaded come close to the limit.
void tick() noexcept;
}