200 int UploadClut(
const void *pSource,
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm);
547 void MakeFree(
unsigned short nMemAddr,
unsigned short nBlocks);
580 void SetupSurface(
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm,
int nKind);
624 int UploadImage(
const void *pSource,
int nWidth,
int nHeight,
int nBitsPerPixel,
int nPsm);
@ kABitmapFormatCount
Definition abitmap.h:28
Description of a pixel rectangle, its layout, and its palette.
Definition abitmap.h:95
One entry of the GS video memory block table.
Definition vram.h:537
Entry * mpLower
Record describing the run immediately below this one, or null at the bottom.
Definition vram.h:671
Entry * mpNext
Next record on the same list.
Definition vram.h:669
unsigned char mKind
One of VramBlockKind.
Definition vram.h:660
unsigned char mLockMask
Generation bits plus kVramLockPinned.
Definition vram.h:662
int GetBlockAddr()
Mark the record as used this packet and return the GS address of its blocks.
unsigned short mSize
Blocks in the run.
Definition vram.h:658
int ComputeBlockSize(int nWidth, int nHeight, int nBitsPerPixel, int nPsm) const
Blocks an image of the given shape occupies.
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 mLastUsed
Value of VRAM::mFlushCount at the last GetBlockAddr().
Definition vram.h:665
void Reset()
Forget which blocks the record described.
Entry * mpPrev
Previous record on whichever of the three lists this record is on.
Definition vram.h:667
void MakeFree(unsigned short nMemAddr, unsigned short nBlocks)
Mark the record as a free run of the given size.
void SetPinned(int bPinned)
Pin the record against eviction, or release the pin.
unsigned short mMemAddr
First block of the run, zero while the record is not resident.
Definition vram.h:656
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 FreeSelf()
Release the record, returning its blocks to the free list and itself to the pool.
unsigned short mReserved06
Definition vram.h:663
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.
Entry * mpUpper
Record describing the run immediately above this one, or null at the top.
Definition vram.h:673
Cache of GS video memory, divided into a reserved palette region and a pool of texture blocks.
Definition vram.h:258
void Init()
Reserve the palette region above the display buffers and link every record into the pool.
Entry * mpChainTail
Highest record of the address ordered chain.
Definition vram.h:506
VramPalEntry * AllocPalEntry()
Take an unused record from the palette free list.
int mSwaps
Blocks released by eviction this frame.
Definition vram.h:475
void EndFrame()
Release every lock, fold the frame counters into the running totals, and reset them.
static void WipeVram()
Fill the whole of video memory with zeros, one 64 by 64 tile at a time.
int mPaletteEnd
First block above the palette region, where the texture pool begins.
Definition vram.h:514
void ReleaseEntry(Entry *pEntry)
Return a record to the pool and forget which blocks it described.
void UnlinkEntry(Entry *pEntry, int nList)
Take a record off one of the three lists.
int mAccumFreeMerges
Running total of mFreeMerges.
Definition vram.h:497
Entry * mpListTail[kVramListCount]
Last record of each of the three lists, indexed by VramList.
Definition vram.h:510
int mLoads
Transfers into video memory this frame.
Definition vram.h:477
Entry * mpListHead[kVramListCount]
First record of each of the three lists, indexed by VramList.
Definition vram.h:508
int mBlocksInUse
Blocks currently allocated out of the texture pool.
Definition vram.h:500
int mSpareFrameCounter
Definition vram.h:487
void Clear(int bClearPalettes)
Release every allocation and rebuild the pool as one free run covering the texture pool.
int mPaletteBase
First block of the palette region.
Definition vram.h:512
int mAccumMisses
Running total of mMisses.
Definition vram.h:495
int mAccumLoadBlocks
Running total of mLoadBlocks.
Definition vram.h:493
~VRAM()
Destroy the table.
void AdvanceLockCycle()
Move to the next lock generation and release everything the generation it arrives at locked.
int mAccumSwaps
Running total of mSwaps.
Definition vram.h:489
int mReserved30
Definition vram.h:498
int mLoadBlocks
Blocks those transfers moved.
Definition vram.h:479
int mRequests
Lookups this frame, which is the divisor of the two reported percentages.
Definition vram.h:485
void PrintStats(const char *pszPrefix)
Report occupancy and the cache counters through the log.
unsigned char mLockGeneration
Generation, from one to kVramLockGenerations, that a lookup locks into.
Definition vram.h:516
int mAccumLoads
Running total of mLoads.
Definition vram.h:491
void ReadBackBitmap(ABitmap *pBitmap, unsigned short nMemAddr)
Move a region of video memory back into a bitmap.
void AllocBlock(Entry *pEntry, unsigned short nBlocks)
Find blocks for a record, evicting resident blocks when the free list cannot serve it.
int mFlushCount
Packets submitted, advanced by GfxDevice::FlushGifPacket() through AdvanceLockCycle().
Definition vram.h:502
void Screendump(const char *pszName)
Write the display buffer to a numbered file.
void FreeBlock(Entry *pEntry)
Put a record on the free list and merge it with whichever neighbours are also free.
void RemoveFromChain(Entry *pEntry)
Take a record out of the address ordered chain and merge across the gap it leaves behind.
void BeginFrame()
Start a frame.
void MergeBlocks(Entry *pKeep, Entry *pAbsorb)
Absorb one free run into the free run below it.
void GetLastFrameLoads(int *pnLoads, int *pnBlocks) const
Report the loads the previous frame performed.
Entry * mpChainHead
Lowest record of the address ordered chain.
Definition vram.h:504
int mMisses
Lookups this frame that found their record not resident.
Definition vram.h:481
Entry * GetAvailEntry()
Take an unused record from the pool.
int mFreeMerges
Merges of adjacent free runs this frame.
Definition vram.h:483
One entry of the GS video memory palette table.
Definition vram.h:139
static int SwapOutOldest()
Release up to sixteen unlocked palettes, oldest first.
int GetBlockAddr()
Mark the record as used this packet and return the GS address of its palette.
int GetSlotIndex() const
Slot index of the record's blocks within the palette region.
int UploadClut(const void *pSource, int nWidth, int nHeight, int nBitsPerPixel, int nPsm)
Move a palette into the record's slot, allocating the slot first when needed.
void FreeSelf()
Release the record, freeing its slot and returning itself to the free list.
VramPalEntry * mpNext
Next record, towards the least recently used end.
Definition vram.h:219
static int AllocBlock()
Take a free palette slot, evicting unlocked palettes when every slot is taken.
unsigned short mMemAddr
First block of the slot, zero while the record is not resident.
Definition vram.h:211
void ClearLockMask()
Release every lock on the record.
VramPalEntry * mpPrev
Previous record, towards the most recently used end of the chain.
Definition vram.h:217
unsigned short mLockMask
Generation bits.
Definition vram.h:213
int mLastUsed
Value of Rnd::VRAM::mFlushCount at the last GetBlockAddr().
Definition vram.h:215
The rendering engine.
Definition animhelper.h:3
VRAM TheVRAM
The video memory cache.
sceGsLoadImage g_vramUploadLoadImage
Transfer descriptor Rnd::VRAM::Entry::UploadImage() reuses.
constexpr int kVramPalSlotsPerWord
Slots one word of the palette occupancy bitmap covers.
Definition vram.h:72
sceGsStoreImage g_vramReadBackStoreImage
Transfer descriptor Rnd::VRAM::ReadBackBitmap() reuses, and therefore Rnd::VRAM::Screendump().
constexpr int kVramPalSlots
Palette slots the reserved palette region divides into.
Definition vram.h:23
constexpr int kVramPageBlocks
Blocks in one GS page, which is 8 KiB.
Definition vram.h:14
int g_nVramLoadsLastFrame
Transfers the previous frame performed.
constexpr int kVramLockGenerations
Rotating lock generations, so a block locked for one packet is released two packets later.
Definition vram.h:35
constexpr int kVramWipeRows
Texel rows Rnd::VRAM::WipeVram() walks.
Definition vram.h:107
int g_nScreendumpIndex
Number the next Rnd::VRAM::Screendump() file takes, advanced after each dump.
constexpr int kVramPalSwapOutLimit
Palettes SwapOutOldest() releases at most in one pass.
Definition vram.h:75
constexpr int kVramSwapBudgetMultiple
Multiple of a request that eviction frees before the allocator retries its search.
Definition vram.h:116
unsigned g_adVramPalSlots[kVramPalSlotWords]
Occupancy of the palette region, one bit per slot.
const int g_anGsPixelStorageModes[kABitmapFormatCount]
GS storage mode of each ABitmapFormat, indexed by the format code.
Rnd::VRAM::Entry * g_apVramLocked[kVramLockGenerations][kVramLockedPerGeneration]
Block records each generation has locked, in the order they were locked.
int g_nVramLoadBlocksLastFrame
Blocks the previous frame's transfers moved.
constexpr int kVramBlockBytes
Bytes in one GS video memory block, the unit every address and size in this unit uses.
Definition vram.h:8
constexpr int kVramWipeBlocksPerRow
Blocks Rnd::VRAM::WipeVram() advances its destination by for each texel row.
Definition vram.h:110
constexpr int kVramWipeTileTexels
Texels along each edge of a tile Rnd::VRAM::WipeVram() writes.
Definition vram.h:104
sceGsLoadImage g_vramPalLoadImage
Transfer descriptor VramPalEntry::UploadClut() reuses.
Rnd::VRAM::Entry g_vramEntries[kVramTableEntries]
Every block table record.
constexpr int kVramBlocks
Blocks of GS video memory on the console, 4 MiB divided by the block size.
Definition vram.h:11
constexpr int kVramPalSlotWords
Words of the palette occupancy bitmap, one bit per slot.
Definition vram.h:26
GsPixelStorageMode
GS pixel storage modes this unit distinguishes.
Definition vram.h:92
@ kGsPsmCt32
Definition vram.h:93
@ kGsPsmT8
Definition vram.h:96
@ kGsPsmT4
Definition vram.h:97
@ kGsPsmCt16
Definition vram.h:95
@ kGsPsmCt24
Definition vram.h:94
sceGsLoadImage g_vramWipeLoadImage
Transfer descriptor Rnd::VRAM::WipeVram() reuses.
constexpr int kVramPalAreaBlocks
Blocks the palette region reserves, which is every slot at its full size.
Definition vram.h:32
VramPalEntry * g_apVramPalLocked[kVramLockGenerations][kVramLockedPerGeneration]
Palette records each generation has locked, in the order they were locked.
sceGsLoadImage g_vramUploadSubLoadImage
Transfer descriptor Rnd::VRAM::Entry::UploadSubImage() reuses.
constexpr int kVramLockGenerationMask
Bits of a record's lock mask the rotating generations own.
Definition vram.h:122
VramPalEntry g_vramPalEntries[kVramPalEntries]
Every palette table record.
constexpr int kVramPalBlocks
Blocks one palette occupies, so 1 KiB for a 256 entry 32-bit table.
Definition vram.h:29
const int g_anBitsPerPixelTable[kABitmapFormatCount]
Bits per texel of each ABitmapFormat once it reaches GS memory, indexed by the format code.
constexpr int kVramTableEntries
Records in the block table, all of them file scope and linked into one pool at start-up.
Definition vram.h:17
VramList
Which of the table's three record lists a record belongs to.
Definition vram.h:65
@ kVramListUsed
Definition vram.h:67
@ kVramListPool
Definition vram.h:68
@ kVramListFree
Definition vram.h:66
VramPalEntry * g_pVramPalFree
First unused palette record.
VramPalEntry * g_pVramPalUsed
First resident palette record, most recently used first.
constexpr int kGsTexelsPerTbwUnit
Texels one unit of a GS transfer buffer width covers.
Definition vram.h:81
constexpr int kVramLockPinned
Bit of a record's lock mask that pins it against eviction until a caller clears it.
Definition vram.h:119
constexpr int kVramPalEntries
Records in the palette table.
Definition vram.h:20
constexpr int kVramListCount
Record lists the table maintains, which is one head and one tail array of this length.
Definition vram.h:38
constexpr int kVramLockedPerGeneration
Records one generation may lock.
Definition vram.h:41
VramBlockKind
Kind of block a table record describes.
Definition vram.h:51
@ kVramBlockKindFree
Definition vram.h:55
@ kVramBlockKindNone
Definition vram.h:52
@ kVramBlockKindTexture
Definition vram.h:53
@ kVramBlockKindRenderTarget
Definition vram.h:54
constexpr int kVramFrameCounterBytes
Bytes of the frame counter run EndFrame() clears, from mSwaps through mSpareFrameCounter.
Definition vram.h:101
constexpr int kVramWipeTileBytes
Bytes of zeros Rnd::VRAM::WipeVram() builds, one tile at four bytes per texel.
Definition vram.h:113
int g_anVramPalLockCount[kVramLockGenerations]
Palette records each generation has locked.
constexpr int kVramPalTbw
Buffer width, in 64 texel units, that a palette transfer uses.
Definition vram.h:78
int g_anVramLockCount[kVramLockGenerations]
Block records each generation has locked.