mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 13:39:58 -04:00
Give an empty slot's handle for a texture id out of range instead of ending the game.
nvnDeviceGetTextureHandle ended the game when the texture id was negative or past the table. The game passes -1 when it has no texture to give, as when its render-target heap is full; the handle of the last slot, which no game registers, draws the stand-in like any slot without a texture. Logged up to eight times. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -236,9 +236,19 @@ NVN_API(nvnDeviceRegisterFastClearDepth) { ret_x(c, 0); }
|
||||
NVN_API(nvnDeviceGetImageHandle) { ret_x(c, (uint64_t)(int64_t)(int)arg_x(c, 1)); }
|
||||
// NVNtextureHandle nvnDeviceGetTextureHandle(const NVNdevice *d, int texture_id, int sampler_id):
|
||||
// texture id (20 bits) | sampler id << 20, the encoding the replay decodes (NVN_HANDLE_TEX / NVN_HANDLE_SAMP)
|
||||
// An id out of range (-1: the game had no texture to give, as when its render-target heap is full) gets the handle of
|
||||
// the last texture slot, which no game registers (its pool has 32,768), so a draw through it samples the stand-in as
|
||||
// for any slot without a texture, and sampler 0. Ending the game here turned one missing texture into a crash.
|
||||
NVN_API(nvnDeviceGetTextureHandle) {
|
||||
int tid = (int)arg_x(c, 1), sid = (int)arg_x(c, 2);
|
||||
if (tid < 0 || tid >= (1 << 20) || sid < 0 || sid >= (1 << 12)) rt_fatal("nvn: texture handle ids out of range %d/%d", tid, sid);
|
||||
if (tid < 0 || tid >= (1 << 20) || sid < 0 || sid >= (1 << 12)) {
|
||||
static int said;
|
||||
if (said < 8 && ++said)
|
||||
rt_log("nvn: texture handle asked for with ids out of range (texture %d, sampler %d): the handle of an "
|
||||
"empty slot is given, which draws the stand-in", tid, sid);
|
||||
if (tid < 0 || tid >= (1 << 20)) tid = (1 << 20) - 1;
|
||||
if (sid < 0 || sid >= (1 << 12)) sid = 0;
|
||||
}
|
||||
ret_x(c, (uint64_t)tid | (uint64_t)sid << 20);
|
||||
}
|
||||
// NVNtextureHandle nvnDeviceGetTexelFetchHandle(const NVNdevice *d, int texture_id)
|
||||
|
||||
Reference in New Issue
Block a user