mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 14:39:58 -04:00
Import the base tree (MIT, see LICENSE)
This commit is contained in:
22
runtime/nvn_tex.h
Normal file
22
runtime/nvn_tex.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// NVN texture storage layout (Tegra X1 block-linear), see nvn_tex.c.
|
||||
// Ported from MacNativeGames games/<game>/third_party/d2r_gfx/gfx/nvn/nvn_tex.h @ b75be8cf (zlib, deko3d-derived; see nvn_tex.c).
|
||||
// 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);
|
||||
}
|
||||
Reference in New Issue
Block a user