|
resonance 1.0.1
|
Texture, as a bitmap path plus the load state of its mip levels. More...
#include <tex.h>


Public Types | |
| enum | TexFunc { kTexFuncModulate = 0 , kTexFuncDecal = 1 , kTexFuncHighlight = 2 , kTexFuncHighlight2 = 3 } |
| Texture function, the GS TEX0.TFX field, which decides how a texel meets the vertex. More... | |
Public Member Functions | |
| Tex (const HxStr &name) | |
| Construct a texture with no bitmap. | |
| virtual | ~Tex () |
| Free the loaded bitmaps and drop every reference to this texture. | |
| int | GetBitmapInfo (int &nWidth, int &nHeight, int &nBitsPerPixel, int &nBytes) |
| Report the size of mip level 0 and the bytes every loaded level occupies. | |
| const HxStr & | GetRelativeBitmapPath () const |
| Report mBitmapPath relative to FilePath::sRoot. | |
| virtual void | DumpText (Dbg &sink) |
| Write the dimensions, the mip selector, the path, and the flag names to sink. | |
| virtual void | Save (Stream &stream) |
| Write revision 4, the three dimensions, the path, mFlags, and mMipSelect. | |
| virtual void | Replace (Object *pFrom, Object *pTo) |
| Do nothing. | |
| virtual const HxStr & | ClassName () const |
| Report the registered class name, "Tex". | |
| virtual void | Copy (const Object *pSource, unsigned nFlags) |
| Take the dimensions, path, mip selector, and flags of another texture and reload. | |
| virtual void | Load (Stream &stream) |
| Replace this texture's configuration from stream and reload. | |
| bool | IsLoadComplete () |
| Report whether every requested mip level has finished loading. | |
| void | SetBitmapConfig (int nWidth, int nHeight, int nBitsPerPixel, const HxStr &path, int nMipSelect, int nFlags) |
| Point the texture at a bitmap and restart its load. | |
| bool | PollAsyncMips () |
| Advance the asynchronous mip loads and report whether any level is still outstanding. | |
| void | AllocateBitmapFromStream () |
| Start loading the configured bitmap, or build a blank one when no path is set. | |
| void | CancelPendingMips () |
| Cancel whatever mip reads are still outstanding and drop every mip handle. | |
| virtual void | ReloadBitmaps () |
| Release the loaded bitmaps and start loading from the configured path again. | |
| virtual ACanvas * | LockMipBitmap (int nMip, int nReserved, int nFlags) |
| Lock the bitmap of one mip level for direct access. | |
| virtual void | UnlockMipBitmap () |
| Release the mip level that LockMipBitmap() locked. | |
| virtual void | SetPalette (APalette *pPalette, int nReserved) |
| Replace the palette every mip level shares. | |
| virtual void | SetGsPageInUse (bool bInUse) |
| Mark the texture's GS page as in use or free. | |
| virtual void | FreeLoadedBitmaps () |
| Release every loaded bitmap and cancel the outstanding reads. | |
| Public Member Functions inherited from Rnd::Object | |
| Object () | |
| Construct an unnamed object. | |
| Object (const HxStr &name) | |
| Construct an object and register it under name. | |
| virtual | ~Object () |
| Erase the registry entry and release the name buffer. | |
| void | SetName (const HxStr &name) |
| Re-register this object under a different name. | |
| void | AddRef (Object *pReferrer) |
| Register pReferrer as a store of a pointer to this object. | |
| void | RemoveRef (Object *pReferrer) |
| Drop one registration made by AddRef(). | |
Static Public Member Functions | |
| static void * | operator new (size_t nSize) |
| Allocate a texture block under the tag "Rnd::Tex". | |
| static void | operator delete (void *pBlock) |
| Release a texture block under the same tag. | |
Public Attributes | |
| int | mWidth |
| int | mHeight |
| int | mBitsPerPixel |
| int | mFlags |
| Flag word SetBitmapConfig() records and DumpText() labels " flags:". | |
| int | mMipSelect |
| Mip selector SetBitmapConfig() records, starting at -0x80. | |
| Public Attributes inherited from Rnd::Object | |
| HxStr | mName |
| int | mInternal |
Static Public Attributes | |
| static Tex *(* | sNew )(const HxStr &name) |
| Creator the registered "Tex" class builds through. | |
| static HxStr | sClassName |
| Registered class name of Rnd::Tex, the string "Tex". | |
Protected Member Functions | |
| void | WaitForMipsLoaded () |
| Block until every requested mip level has arrived, pumping the asynchronous reads meanwhile. | |
| virtual void | RestoreSurfaces () |
| Rebuild whatever the texture keeps in GS memory. | |
| virtual void | OnMipLoaded (int nMip) |
| Take delivery of one mip level whose read has just finished. | |
| Protected Member Functions inherited from Rnd::Object | |
| void | ReleaseAllRefs () |
| Tell every referrer to drop its pointer to this object. | |
Protected Attributes | |
| std::vector< int > | mMipHandles |
| unsigned char | mPendingMipMask |
| FilePath | mBitmapPath |
| int | mZone |
| std::vector< ABitmap * > | mLoadedBitmaps |
| Protected Attributes inherited from Rnd::Object | |
| std::list< Object * > | mRefs |
Texture, as a bitmap path plus the load state of its mip levels.
Its RTTI descriptor is at 0x008ef140. It has Rnd::Object as its one public non-virtual base at offset 0. The class factory allocates 0x58 bytes. The texture's members therefore occupy +0x1c through +0x57. The implementation file is rndtex.cpp, attested by its assert strings, and the bitmap header it includes is C:/FREQ/src/rndartt/abitmap.h.
A texture owns no pixels. The mip levels load asynchronously into the handle vector, and the hardware residency belongs to the PlayStation 2 subclass Rnd::PsTex, whose GS slot state extends the object past +0x4a8.
The vtable has sixteen entries, so the class declares eight virtuals of its own beyond the six of Rnd::Object. Slots 8 through 15 are ReloadBitmaps(), LockMipBitmap(), UnlockMipBitmap(), SetPalette(), SetGsPageInUse(), FreeLoadedBitmaps(), RestoreSurfaces(), and OnMipLoaded().
mFlags is the flag word DumpText() labels " flags:", and DumpText() lists its bits by name.
mBitmapPath is a Rnd::FilePath, whose routines sit in this unit and take the path's address rather than the texture's. SetBitmapConfig() installs the path through FilePath::Set() for a verbatim path and through FilePath::SetFromRoot() to prefix FilePath::sRoot.
| enum Rnd::Tex::TexFunc |
| Rnd::Tex::Tex | ( | const HxStr & | name | ) |
Construct a texture with no bitmap.
The mip selector starts at -0x80 and mZone at -1, which selects the tagged heap.
| name | The object name, passed to the Rnd::Object constructor. |
|
virtual |
Free the loaded bitmaps and drop every reference to this texture.
|
static |
Allocate a texture block under the tag "Rnd::Tex".
| nSize | The object size the compiler supplies. |
|
static |
Release a texture block under the same tag.
| pBlock | The block. |
| int Rnd::Tex::GetBitmapInfo | ( | int & | nWidth, |
| int & | nHeight, | ||
| int & | nBitsPerPixel, | ||
| int & | nBytes ) |
Report the size of mip level 0 and the bytes every loaded level occupies.
Level 0 is locked through LockMipBitmap() for its width, height, and depth. Every level is then locked with read-back requested, and each contributes its pixel bytes and four bytes per palette entry. A texture with no level 0 bitmap reports failure without unlocking it. The name is inferred.
| nWidth | Receives the width of level 0. |
| nHeight | Receives the height of level 0. |
| nBitsPerPixel | Receives the depth of level 0. |
| nBytes | Receives the bytes of every level. |
| const HxStr & Rnd::Tex::GetRelativeBitmapPath | ( | ) | const |
Report mBitmapPath relative to FilePath::sRoot.
The result lives in the function-local static FilePath::RelativeToRoot() returns. The routine has no caller in the shipped build. The name is inferred.
|
virtual |
Write the dimensions, the mip selector, the path, and the flag names to sink.
The flag word is dumped under " flags:" by name, or as "None" when it is zero. Bit kABitmapColorKeyBlack prints "TransparentWhite, " as bit kABitmapColorKeyWhite does, because the image reuses the one string for both.
| sink | The text sink. |
Reimplemented from Rnd::Object.
|
virtual |
Write revision 4, the three dimensions, the path, mFlags, and mMipSelect.
Rnd::Object::Save() is not called.
| stream | The stream to write to. |
Implements Rnd::Object.
Do nothing.
A texture has no object references to retarget.
| pFrom | Unused. |
| pTo | Unused. |
Implements Rnd::Object.
|
virtual |
Report the registered class name, "Tex".
Implements Rnd::Object.
|
virtual |
Take the dimensions, path, mip selector, and flags of another texture and reload.
The loaded bitmaps are freed first and AllocateBitmapFromStream() runs last. Rnd::Object::Copy() is not called, and nFlags is ignored.
| pSource | The texture to copy, which has to be a Rnd::Tex. |
| nFlags | Unused. |
Implements Rnd::Object.
|
virtual |
Replace this texture's configuration from stream and reload.
A revision above 4 is reported as "Can't load new Tex" and nothing else is read. Revision 1 stores the width and the height as 16-bit values. Revisions 1 and 2 store one byte after the flags that is read and discarded, and mMipSelect is stored from revision 4. The loaded bitmaps are freed before the read and AllocateBitmapFromStream() runs after it. Rnd::Object::Load() is not called.
| stream | The stream to read from. |
Implements Rnd::Object.
| bool Rnd::Tex::IsLoadComplete | ( | ) |
Report whether every requested mip level has finished loading.
| void Rnd::Tex::SetBitmapConfig | ( | int | nWidth, |
| int | nHeight, | ||
| int | nBitsPerPixel, | ||
| const HxStr & | path, | ||
| int | nMipSelect, | ||
| int | nFlags ) |
Point the texture at a bitmap and restart its load.
Records the bitmap dimensions, the mip selector, and the flags. An absolute path is stored through FilePath::Set() and any other through FilePath::SetFromRoot(). The pending mip reads are then cancelled and the mip handle vector is emptied. No load starts here.
| nWidth | The bitmap width. |
| nHeight | The bitmap height. |
| nBitsPerPixel | The bitmap depth. |
| path | The bitmap path. |
| nMipSelect | The mip selector, which starts at -0x80. |
| nFlags | The flag word, recorded in mFlags. |
| bool Rnd::Tex::PollAsyncMips | ( | ) |
Advance the asynchronous mip loads and report whether any level is still outstanding.
Each pending level is polled once. A level that has arrived is stored, reported through OnMipLoaded(), and cleared from the pending mask. A level that failed is reported through the failure sink and also cleared, which stops a caller spinning on a read that will never finish. RestoreSurfaces() runs once the mask empties.
| void Rnd::Tex::AllocateBitmapFromStream | ( | ) |
Start loading the configured bitmap, or build a blank one when no path is set.
The mip handles are dropped and the current zone becomes mZone. With a bitmap path the cached copies of the base level and its mip levels are queued for reading, and a failure zeroes the dimensions and the depth before RestoreSurfaces() runs. Without a path one blank level is allocated in a single block, from the tagged heap when mZone is -1 and from the zone otherwise. The block holds the bitmap header, then a palette for a depth of 8 bits or fewer, then the pixels on a 16-byte boundary. Flag 0x40 of mFlags triples the width and doubles the height of that level. The level is recorded as loaded and RestoreSurfaces() runs.
| void Rnd::Tex::CancelPendingMips | ( | ) |
Cancel whatever mip reads are still outstanding and drop every mip handle.
The pending mask is left as it was, so a later poll still waits on the cancelled levels.
|
virtual |
Release the loaded bitmaps and start loading from the configured path again.
Vtable slot 8. The body is FreeLoadedBitmaps() followed by AllocateBitmapFromStream(). Rnd::PsTex's table addresses a byte-identical per-unit copy at 0x0059a8c8. Rnd::Movie's SetFrameSelf() calls it after SetBitmapConfig(). The name is inferred.
|
virtual |
Lock the bitmap of one mip level for direct access.
Vtable slot 9. Rnd::Tex returns null without doing anything. Rnd::PsTex records the level so that UnlockMipBitmap() can mark it dirty. The second parameter is read by neither implementation, so its purpose is unrecovered. The name is inferred from the pairing with slot 10 rather than from any string in the image.
| nMip | The mip level. |
| nReserved | The second parameter. No recovered implementation reads it. Every recovered caller passes 0. |
| nFlags | Bit 1 requests a read-back from GS memory. |
Reimplemented in Rnd::PsTex.
|
virtual |
Release the mip level that LockMipBitmap() locked.
Vtable slot 10. Empty in Rnd::Tex. The name is inferred as above.
Reimplemented in Rnd::PsTex.
|
virtual |
Replace the palette every mip level shares.
Vtable slot 11. Empty in Rnd::Tex. The name is inferred as above.
| pPalette | The replacement palette. |
| nReserved | A second word, unread by every recovered implementation. Rnd::Movie's palette chunk handler passes -1 explicitly at 0x005cf55c. |
Reimplemented in Rnd::PsTex.
|
virtual |
Mark the texture's GS page as in use or free.
Vtable slot 12. Empty in Rnd::Tex. The PlayStation 2 override pins the video memory block of mip 0 against eviction, or releases the pin. The name is inferred.
| bInUse | Whether the page is in use. |
Reimplemented in Rnd::PsTex.
|
virtual |
Release every loaded bitmap and cancel the outstanding reads.
Vtable slot 13. A bitmap allocated from a zone goes with its zone. Only a bitmap from the tagged heap, while mZone is -1, is released, and the release is billed to rndtex.cpp line 610.
Reimplemented in Rnd::PsTex.
|
inlineprotected |
Block until every requested mip level has arrived, pumping the asynchronous reads meanwhile.
Rnd::PsTex open-codes the body in BindToGsSlot(), LockMipBitmap(), SetGsPageInUse(), and the routine at 0x00596d68. The out-of-line copy has no caller.
|
protectedvirtual |
Rebuild whatever the texture keeps in GS memory.
Vtable slot 14. The base body refreshes mWidth, mHeight, and mBitsPerPixel from the first loaded bitmap when there is one, and then empties the mip handle vector. The name is the routine's own. The PlayStation 2 override reports "ERROR - RestoreSurfaces(s), mipmap d has no bm!", and the helper it calls reports "Got NULL Palette in RestoreSurfaces".
Reimplemented in Rnd::PsTex.
|
protectedvirtual |
Take delivery of one mip level whose read has just finished.
Vtable slot 15. The level's block is a bitmap header followed by a palette and the pixels. An indexed format (4 bit, 8 bit, or run length 8 bit) points the bitmap at both. A direct colour format has no palette, and its pixels start where the palette would. Red and blue are then swapped unless g_nSkipColorSwap is set. Flag 0x10 of mFlags runs ABitmap::SetPaletteAlphaFromLowByte(0), or else flag 0x20 runs it with 1, and ABitmap::ApplyColorKey() receives mFlags whole. A level whose width or height is not a power of two is reported to Rnd::TheDbg. A level above zero whose size is not mWidth and mHeight shifted right by nMip is reported as well. Neither report stops the load. Rnd::PsTex runs this body first and then uploads the level to GS memory. The name is inferred from the position of the call inside PollAsyncMips().
| nMip | The level that arrived, which both implementations use to index the loaded bitmaps. |
Reimplemented in Rnd::PsTex.
Creator the registered "Tex" class builds through.
The default creator allocates 0x58 bytes and constructs a Rnd::Tex. GfxDevice::Init() and the PlayStation 2 texture layer both overwrite the hook with the Rnd::PsTex creator.
|
static |
Registered class name of Rnd::Tex, the string "Tex".
| int Rnd::Tex::mWidth |
| int Rnd::Tex::mHeight |
| int Rnd::Tex::mBitsPerPixel |
| int Rnd::Tex::mFlags |
Flag word SetBitmapConfig() records and DumpText() labels " flags:".
Public because Rnd::Movie's SetFrameSelf() reads it to pass it back unchanged. +0x28
|
protected |
|
protected |
| int Rnd::Tex::mMipSelect |
Mip selector SetBitmapConfig() records, starting at -0x80.
Public because Rnd::Movie's SetFrameSelf() reads it to pass it back unchanged. +0x3c
|
protected |
|
protected |
|
protected |