Files
NX2navi/runtime/nvn_tex.h
chrg6 99de7b943f Give each file of copied code one license line.
Each file that contains copied code names its copyright holder and license and points at THIRD_PARTY_NOTICES.md; zlib code keeps its full notice and the mark that it was altered. Comments and probe text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 05:04:40 -05:00

23 lines
1.4 KiB
C

// NVN texture storage layout (Tegra X1 block-linear), see nvn_tex.c.
// Contains altered code Copyright (C) 2018-2020 fincs (zlib, license text in nvn_tex.c; see THIRD_PARTY_NOTICES.md).
// nvn_texdesc and nvn_texlayout are defined in nvn_obj.h.
#pragma once
#include <stdint.h>
#include "nvn_obj.h"
void nvn_tex_layout(const nvn_texdesc *d, nvn_texlayout *o);
uint64_t nvn_tex_level_offset(const nvn_texdesc *d, unsigned level);
int nvn_fmt_bpb(int format, int *bw, int *bh); // Bytes per block (0 = unknown format), block width and height
// Block height / block depth actually used by level `level` (log2 of the GOB count): the per-level block height shrinks with that level's row count (block rows), and deswizzling uses it level by level
void nvn_tex_level_tiles(const nvn_texdesc *d, unsigned level, unsigned *tileH, unsigned *tileD);
/* LINEAR_RENDER_TARGET (0x40) uses pitch storage even without LINEAR (0x10).
NX2NAVI's CPU-loaded water height/mask textures use that flag alone. */
static inline int nvn_tex_is_linear(const nvn_texdesc *d) { return (d->flags & 0x50) != 0; }
static inline uint32_t nvn_tex_linear_stride(const nvn_texdesc *d) {
if (d->stride) return d->stride;
int bw, bh; int bpb = nvn_fmt_bpb(d->format, &bw, &bh);
uint32_t align = (d->flags & 0x40) ? 128 : 32;
return (((d->width + bw - 1) / bw) * bpb + align - 1) & ~(align - 1);
}