resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::VRAM::Entry Class Reference

One entry of the GS video memory block table. More...

#include <vram.h>

Collaboration diagram for Rnd::VRAM::Entry:

Public Member Functions

void MakeFree (unsigned short nMemAddr, unsigned short nBlocks)
 Mark the record as a free run of the given size.
void Reset ()
 Forget which blocks the record described.
void SetPinned (int bPinned)
 Pin the record against eviction, or release the pin.
void SetupSurface (int nWidth, int nHeight, int nBitsPerPixel, int nPsm, int nKind)
 Size the record for an image and put it on the used list, without allocating any blocks.
int ComputeBlockSize (int nWidth, int nHeight, int nBitsPerPixel, int nPsm) const
 Blocks an image of the given shape occupies.
int GetBlockAddr ()
 Mark the record as used this packet and return the GS address of its blocks.
int UploadImage (const void *pSource, int nWidth, int nHeight, int nBitsPerPixel, int nPsm)
 Move an image into the record's blocks, allocating them first if the record is not resident.
void UploadSubImage (const void *pSource, int nWidth, int nHeight, int nBitsPerPixel, int nPsm, int nBlockOffset)
 Move an image into the record's blocks at an offset, without allocating.
void FreeSelf ()
 Release the record, returning its blocks to the free list and itself to the pool.

Public Attributes

unsigned short mMemAddr
 First block of the run, zero while the record is not resident.
unsigned short mSize
 Blocks in the run.
unsigned char mKind
 One of VramBlockKind.
unsigned char mLockMask
 Generation bits plus kVramLockPinned.
unsigned short mReserved06
int mLastUsed
 Value of VRAM::mFlushCount at the last GetBlockAddr().
Entry * mpPrev
 Previous record on whichever of the three lists this record is on.
Entry * mpNext
 Next record on the same list.
Entry * mpLower
 Record describing the run immediately below this one, or null at the bottom.
Entry * mpUpper
 Record describing the run immediately above this one, or null at the top.

Detailed Description

One entry of the GS video memory block table.

The class is not polymorphic and has no RTTI. Its name comes from the debugging symbols of the North American demo release. The demo's SetUnused() and InitRaw() have the same instructions as Reset() and MakeFree(). Of the members, only mMemAddr, mpPrev, and mpNext are attested by a literal, the first two through the sibling diagnostic "Pal entry in chain has mMemAddr of 0 (mpPrev: %p, mpNext: %p)" and the parallel layout of the two records. Every other title is inferred from use.

A record describes a run of blocks at mMemAddr, whether that run is free or owned by a surface. It appears on exactly one of the three lists through mpPrev and mpNext, and separately on the address ordered chain through mpLower and mpUpper. The chain is what lets a freed run merge with the runs on either side of it.

The image records no access control. Every member and method below is reached from VRAM or from Rnd::PsTex. A friend declaration fits the image as well as the public section written here.

Member Function Documentation

◆ MakeFree()

void Rnd::VRAM::Entry::MakeFree ( unsigned short nMemAddr,
unsigned short nBlocks )

Mark the record as a free run of the given size.

Parameters
nMemAddrFirst block of the run.
nBlocksBlocks in the run.
Ghidra address:
NTSC-U/C: 0x00515148
Ghidra address:
PAL: 0x00555478

◆ Reset()

void Rnd::VRAM::Entry::Reset ( )

Forget which blocks the record described.

Ghidra address:
NTSC-U/C: 0x00514ee8
Ghidra address:
PAL: 0x00555218

◆ SetPinned()

void Rnd::VRAM::Entry::SetPinned ( int bPinned)

Pin the record against eviction, or release the pin.

Parameters
bPinnedNon-zero to pin.
Ghidra address:
NTSC-U/C: 0x00514ef8
Ghidra address:
PAL: 0x00555228

◆ SetupSurface()

void Rnd::VRAM::Entry::SetupSurface ( int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm,
int nKind )

Size the record for an image and put it on the used list, without allocating any blocks.

The record starts non-resident, with mMemAddr zero, so the first GetBlockAddr() counts a miss and the first UploadImage() allocates.

Parameters
nWidthImage width in texels.
nHeightImage height in texels.
nBitsPerPixelBits per texel. The routine does not read it.
nPsmGS pixel storage mode.
nKindOne of VramBlockKind.
Ghidra address:
NTSC-U/C: 0x00514f18
Ghidra address:
PAL: 0x00555248

◆ ComputeBlockSize()

int Rnd::VRAM::Entry::ComputeBlockSize ( int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm ) const

Blocks an image of the given shape occupies.

The count is whole GS pages, because the allocator works in pages rather than in texels. The page shape follows the storage mode, 128 by 128 texels for four-bit, 128 by 64 for eight-bit, 64 by 64 for sixteen-bit, and 64 by 32 for everything else.

Parameters
nWidthImage width in texels.
nHeightImage height in texels.
nBitsPerPixelBits per texel. The routine does not read it.
nPsmGS pixel storage mode.
Returns
Blocks the image occupies.
Ghidra address:
NTSC-U/C: 0x00515058
Ghidra address:
PAL: 0x00555388

◆ GetBlockAddr()

int Rnd::VRAM::Entry::GetBlockAddr ( )

Mark the record as used this packet and return the GS address of its blocks.

The first call within a packet adds the record to the current generation's lock list, which protects it from eviction until the generation comes round again. A record with no blocks counts a miss and returns zero, and the caller is expected to upload.

Returns
First block of the run, rounded up to a page for a render target.
Ghidra address:
NTSC-U/C: 0x00513690
Ghidra address:
PAL: 0x00553978

◆ UploadImage()

int Rnd::VRAM::Entry::UploadImage ( const void * pSource,
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm )

Move an image into the record's blocks, allocating them first if the record is not resident.

Parameters
pSourceTexels to move, or null to allocate without transferring.
nWidthImage width in texels.
nHeightImage height in texels.
nBitsPerPixelBits per texel. The routine does not read it.
nPsmGS pixel storage mode.
Returns
First block of the run, rounded up to a page for a render target.
Ghidra address:
NTSC-U/C: 0x00515160
Ghidra address:
PAL: 0x00555490

◆ UploadSubImage()

void Rnd::VRAM::Entry::UploadSubImage ( const void * pSource,
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm,
int nBlockOffset )

Move an image into the record's blocks at an offset, without allocating.

A mip chain uses it for every level after the first.

Parameters
pSourceTexels to move.
nWidthImage width in texels.
nHeightImage height in texels.
nBitsPerPixelBits per texel. The routine does not read it.
nPsmGS pixel storage mode.
nBlockOffsetBlocks past mMemAddr to write at.
Ghidra address:
NTSC-U/C: 0x005152a8
Ghidra address:
PAL: 0x005555d8

◆ FreeSelf()

void Rnd::VRAM::Entry::FreeSelf ( )

Release the record, returning its blocks to the free list and itself to the pool.

Ghidra address:
NTSC-U/C: 0x00514fa8
Ghidra address:
PAL: 0x005552d8

Member Data Documentation

◆ mMemAddr

unsigned short Rnd::VRAM::Entry::mMemAddr

First block of the run, zero while the record is not resident.

Attested.

◆ mSize

unsigned short Rnd::VRAM::Entry::mSize

Blocks in the run.

◆ mKind

unsigned char Rnd::VRAM::Entry::mKind

One of VramBlockKind.

◆ mLockMask

unsigned char Rnd::VRAM::Entry::mLockMask

Generation bits plus kVramLockPinned.

The literals write it "lockmask".

◆ mReserved06

unsigned short Rnd::VRAM::Entry::mReserved06

No instruction reads or writes it. +0x06

◆ mLastUsed

int Rnd::VRAM::Entry::mLastUsed

Value of VRAM::mFlushCount at the last GetBlockAddr().

◆ mpPrev

Entry* Rnd::VRAM::Entry::mpPrev

Previous record on whichever of the three lists this record is on.

Attested.

◆ mpNext

Entry* Rnd::VRAM::Entry::mpNext

Next record on the same list.

Attested.

◆ mpLower

Entry* Rnd::VRAM::Entry::mpLower

Record describing the run immediately below this one, or null at the bottom.

◆ mpUpper

Entry* Rnd::VRAM::Entry::mpUpper

Record describing the run immediately above this one, or null at the top.


The documentation for this class was generated from the following file: