coastline 0.0.4
Loading...
Searching...
No Matches
render.h File Reference

The renderer of the PC port: its mode, the routines that start and stop it, and the pool of the data of the models it draws. More...

Include dependency graph for render.h:

Go to the source code of this file.

Classes

struct  VertexConvCacheEntry
 A run of vertices of the console converted to floats. More...
struct  TextureMapEntry
 A texture of the console that a texture of another size replaces, from the texture map. More...

Macros

#define RENDER_BACKEND_MODE_D3D   1
 The mode of the renderer of the Direct3D library.
#define RENDER_BACKEND_MODE_GLIDE   3
 The mode of the renderer of the Glide library.
#define RENDER_BACKEND_MODE   RENDER_BACKEND_MODE_GLIDE
 The mode of the renderer of the library being built.
#define VERTEX_CONV_CACHE_SIZE   0x800
 The number of entries of g_aVertexConvCache.
#define TEXTURE_MAP_ENTRY_COUNT   256
 The number of entries of g_aTextureMapEntries.
#define TEXTURE_UPLOAD_QUEUE_SIZE   256
 The number of entries of g_aTextureUploadQueue.
#define TEXTURE_RESAMPLE_BUFFER_BYTES   0x80000
 The bytes of g_abTextureResampleBuffer.

Functions

int GetRenderBackendMode (void)
 The renderer the game was set to use.
void SetRenderBackendMode (int nMode)
 Record the mode of the renderer.
void InitializeRenderSubsystems (int nMode)
 Start the renderer of a mode: reset the device, start the texture subsystem and the renderer, and empty the pool of the data of the models.
void ResetRenderSubsystems (int nMode, int nWidth, int nHeight, int nBitDepth, int nExtra)
 Shut the renderer down when one runs, and start the renderer of a mode in a display mode.
int SetDisplayModeWithFallback (int nWidth, int nHeight, int nBitDepth, int nExtra)
 Set the size of the frame buffer.
void SetTextureEntryDamageLevel (int nEntry, int nDamageLevel)
 Set the level of damage of a texture the game loaded.
int InitGlideRenderDevice (void)
 Start the Glide device: set the routines that show a frame and shut the device down, find the hardware and its units of texture and its memory, and open the window of the size of the configuration.
void InitGbiGlideRenderer (void)
 Start the renderer of the display lists of the game with Glide.
void InitializeTextureSubsystem (void)
 Start the texture subsystem.
int GetMipLevelFromDimension (int nDimension)
 Get the exponent of the smallest power of two from 1 to 256 not below a dimension of a texture.
void CalculateTextureDimensions (int *pWidth, int *pHeight, int nLod, int nAspectRatio)
 Get the size of a texture from the codes of Glide for its level of detail and its aspect ratio.
void CopyConfigFramebufferSize (void)
 Make the size of the frame the size of the framebuffer of the configuration.
void RefreshScreenDimensions (void)
 Refresh screen dimensions from the configured framebuffer size.
void AddVertexConversionCacheEntry (const Vtx *pSource, int nVertexCount, ConvertedModelVertex *pFloatVerts)
 Add a run of vertices converted to g_aVertexConvCache while it has room.
void ByteSwapVertexArray (Vtx *pVertices, int nCount)
 Byte-swap the positions, flags, and texture coordinates of loaded Nintendo 64 vertices.
ConvertedModelVertex * ConvertVerticesToFloat (const Vtx *pVertices, int nCount)
 Convert Nintendo 64 vertex positions and texture coordinates to floats in the model data pool.
void ConvertN64VerticesCached (ModelVertexData *pVertices, int nCount)
 Reuse converted vertices for a previously seen source array, or convert and cache them.
void RelocateGbiVertexCommand (GbiCommand *pCommand)
 Relocate a display-list vertex command's source address and cache its converted vertices.
bool LookupTextureMapEntry (unsigned dwAddress, int *pnWidth, int *pnHeight)
 Get the size of the replacement of a texture of the console, searching the texture map from its last entry.
void InitializeTextureUploadQueue (void)
 Empty the queue of textures to upload and create its mutex.
void DestroyTextureUploadQueue (void)
 Empty the queue of textures to upload and close its mutex.
void SetTextureLoadCategory (int nCategory)
 Set the category of the textures loaded next.
int GetTexelsPerLoadWord (int nSize)
 Get the texels of a word of 8 bytes of the texture memory of the console for a size of texel.
void LoadHudOverlayTexture (void)
 Load the texture of the overlay of the display of the race.
void LoadHudGlyphTextureSets (void)
 Load the textures of the sets of glyphs of the display of the race.
void SelectTextureQualityFromVideoMemory (void)
 Select texture quality and maximum dimensions from available graphics memory.
unsigned CreateTextureFromN64ImageAutoLoadSize (const unsigned char *pImage, const unsigned char *pPalette, int nWidth, int nHeight, int nSize, int nFormat, int nOption6, int nOption7, int nOption8, int nOption9, int nOption10, int nOption11, int nOption12, int nOption13)
 Calculate the image load size from nWidth and delegate texture creation to the renderer.
unsigned DuplicateTextureEntryHalfScale (unsigned nTexture)
 Duplicate a texture entry with both texture-coordinate scales halved.
void LoadParticleTexture (void)
 Create the texture of the particles, 64 by 64 texels.
void LoadTireTrailTexture (void)
 Create the texture of the trails of the tyres, 32 by 64 texels.
void LoadVehicleEnvMapTexture (void)
 Create the map of the environment of the vehicles, 64 by 64 texels.
void CreateFallbackEnvironmentTexture (void)
 Create the texture of the environment used when none is loaded.
void CreateAlphaRampTextures (void)
 Create the textures of the ramps of alpha and of precipitation.
void ProcessTextureUploadQueueEntry (void)
 Upload the next texture of the queue of textures to upload.
void EnqueueTextureUploadEntry (int nEntry, TextureUploadData payload)
 Queue a texture to upload, under the mutex of the queue.
void CreateWeatherShadeTexture (void)
 Create a uniform intensity texture for the chosen weather.
unsigned QueryAvailableTextureMemory (void)
 Query the free video memory available for textures on the active DirectDraw device.
void ShutdownTextureSubsystem (void)
 Stop texture uploads and release texture surfaces and owned paint buffers.
void UploadTextureEntryToSurface (int nEntry, TextureUploadData payload)
 Copy a supplied pixel buffer into the device texture of a loaded entry.
void CreateDeviceTextureFromImageHeader (ModelTexture *pTexture, int nOption13)
 Replace a static model texture's image with its loaded device texture entry.
int CalculateTextureLodFromDimensions (int *pLod, int width, int height)
 Derive a texture level of detail from its larger dimension.
int ChooseTexturePixelFormat (int nSize, int nFormat, int bColorCombine)
 Select a device pixel format from N64 texture size, format and combine state.
int GetTexturePixelSize (int nPixelFormatId)
 Get the decoded bytes per texture pixel.
int FindMatchingTextureEntry (const TextureImageData *pImage)
 Find an entry with the same image, palette and applicable captured colors.
unsigned RegisterTextureEntry (const TextureImageData *pImage, int nTextureId)
 Append image metadata and a device texture identifier to the loaded entries.
void ResizeTextureImage (unsigned char *pDest, int width, int height, const unsigned char *pSource, int sourceWidth, int sourceHeight, int nPixelFormatId)
 Resize a decoded texture with bilinear sampling at pixel centers.
unsigned char * GetTextureImagePixels (TextureImageData *pImage)
 Decode an image descriptor into the texture pixel work buffers.
void ReloadTextureEntryData (int nEntry)
 Decode a loaded entry again and upload the resulting pixels.
unsigned ResizeTextureMipChain (unsigned char *pDest, const unsigned char *pSource, TextureImageData *pImage)
 Resize consecutive decoded mip levels and record the decoded source dimensions.
void ModulateTextureWithIntensityPlane (const TextureImageData *pImage, unsigned char *pPixels)
 Modulate decoded RGB by the half-sized intensity plane following its pixels.
void DecodeTexturePixels (unsigned char *pDest, int nSize, int nTexelSize, const unsigned char *pImage, const unsigned char *pPalette, int nFormat, int bMirrorS, int bMirrorT, int nTileIndex, int nTileLimit, const TexScanTile *pTiles, unsigned flags, int bColorCombine, unsigned envR, unsigned envG, unsigned envB, unsigned envA, unsigned primR, unsigned primG, unsigned primB, unsigned primA, unsigned nRowSwapMask)
 Decode captured N64 texture tiles into four-byte pixels.
int CreateTextureFromImage (TextureImageData *pImage, unsigned char *pPixels)
 Create a device texture from captured metadata and decoded pixels.
int CloneTextureEntryWithNewImageData (int nEntry, unsigned char *pImage, const unsigned char *pPalette)
 Clone texture metadata with replacement image and palette bytes.
int PreparePaintTexture (int *pWidth, int *pHeight, TextureImageData *pImage)
 Prepare paint texture metadata and adjust device dimensions.
void UploadTrackTextureVariants (ModelTexture *pTextures, int nCount)
 Create device textures for animated track frames and replace their image offsets with entries.
int DecodeN64TextureToPixelBuffer (void *pDest, const unsigned char *pImage, const unsigned char *pPalette, int nWidth, int nHeight, int nLineBytes, int nSize, int nFormat)
 Decode an N64 image into the pixel format selected for its texel size and format.
int CalculateTextureAspectRatio (int *pAspectRatio, int nWidth, int nHeight)
 Select an aspect ratio code from the truncated ratio of the dimensions.
unsigned CreateTextureFromN64Image (const unsigned char *pImage, const unsigned char *pPalette, int nWidth, int nHeight, int nLineBytes, int nSize, int nFormat, int nOption7, int nOption8, int nOption9, int nOption10, int nOption11, int nOption12, int nOption13, int nOption14)
 Create a device texture from an N64 image and its load options.
unsigned char * GetTextureEntryPixelsWithPaint (int nEntry, unsigned *pSize)
 Decode texture pixels, applying the selected paint damage image when needed.

Variables

void(* g_pfnRenderBackendSubmitDisplayList )(GbiCommand *pDisplayList)
 The active backend callback that submits a display list for rendering.
void(* g_pfnPresentFrame )(void)
 Show the frame drawn, set by the reset of the render device.
int g_dwRenderBackendMode
 The mode of the renderer, 0 before one is set.
int(* g_pfnRenderDeviceReset )(void)
 Reset the render device, set by SetRenderBackendMode().
void(* g_pfnRenderDeviceShutdown )(void)
 Release the render device, if one is set.
void(* g_pfnReloadTextureEntryData )(int nEntry)
 Load the data of a texture the game loaded again, set by InitializeTextureSubsystem().
ConvertedModelVertex * g_pModelDataPoolCursor
 The next free entry of g_afModelVertexPool.
VertexConvCacheEntry g_aVertexConvCache [VERTEX_CONV_CACHE_SIZE]
 The runs of vertices converted.
int g_dwVertexConvCacheCount
 The number of entries of g_aVertexConvCache in use.
TextureMapEntry g_aTextureMapEntries [TEXTURE_MAP_ENTRY_COUNT]
 The entries the texture map file lists.
int g_dwTextureMapEntryCount
 The entries of g_aTextureMapEntries in use.
TextureUploadRequest g_aTextureUploadQueue [TEXTURE_UPLOAD_QUEUE_SIZE]
 The textures to upload, a ring from g_dwTextureUploadQueueTail to g_dwTextureUploadQueueHead.
int g_dwTextureUploadQueueHead
 The entry of g_aTextureUploadQueue the next texture to queue takes.
int g_dwTextureUploadQueueTail
 The entry of g_aTextureUploadQueue of the next texture to upload.
HANDLE g_hTextureUploadQueueMutex
 The mutex of the queue of textures to upload.
int g_dwCopyTextureDataOnRelocate
 Whether the data of a texture is copied when its pointers are relocated.
int g_dwTextureLoadCategory
 The category of the textures loaded next.
unsigned g_dwHiResTextureMemoryThreshold
 The available texture-memory threshold for high-resolution textures, in bytes.
int g_dwMaxTexWidthHighQuality
 The maximum high-quality texture width, in texels.
int g_dwMaxTexHeightHighQuality
 The maximum high-quality texture height, in texels.
int g_dwMaxTexWidthLowQuality
 The maximum low-quality texture width, in texels.
int g_dwMaxTexHeightLowQuality
 The maximum low-quality texture height, in texels.
unsigned(* g_pfnCreateTextureFromN64ImageAutoLoadSize )(const unsigned char *, const unsigned char *, int, int, int, int, int, int, int, int, int, int, int, int)
 The backend callback that creates an N64 image texture after calculating its load size.
unsigned char g_abAlphaRampRgba [16][4]
 The 16 white RGBA colours of the alpha ramp, with alpha increasing by 17.
unsigned char g_abAlphaRampPixelStrip [64]
 The alpha ramp converted to device pixel format.
unsigned char g_abWeatherShadeTexture [16]
 The 4-by-4 intensity pixels of the current weather shade.
unsigned g_dwWeatherShadeTextureId
 The device texture identifier of the current weather shade.
unsigned g_dwTexturePixelByteCount
 The byte count produced by the last decoded texture operation.
unsigned char g_abTextureResampleBuffer [TEXTURE_RESAMPLE_BUFFER_BYTES]
 The pixels of a texture after resizing, or an intensity plane while it is applied.
const char g_szTidFromTextureAppendAmid []
 Allocation label for the device texture table.
decltype(&CreateDeviceTextureFromImageHeader) g_pfnCreateDeviceTextureFromImageHeader
 The backend callback that creates a device texture from a model texture header.
decltype(&CloneTextureEntryWithNewImageData) g_pfnCloneTextureEntryWithNewImageData
 The backend callback that clones a texture entry with replacement image data.
decltype(&UploadTrackTextureVariants) g_pfnUploadTrackTextureVariants
 The backend callback that uploads the texture variants of a track.
int g_dwCurrentMaxTextureWidth
 The width limit selected for the current texture category.
int g_dwCurrentMaxTextureHeight
 The height limit selected for the current texture category.

Detailed Description

The renderer of the PC port: its mode, the routines that start and stop it, and the pool of the data of the models it draws.

Macro Definition Documentation

◆ RENDER_BACKEND_MODE_D3D

#define RENDER_BACKEND_MODE_D3D   1

The mode of the renderer of the Direct3D library.

◆ RENDER_BACKEND_MODE_GLIDE

#define RENDER_BACKEND_MODE_GLIDE   3

The mode of the renderer of the Glide library.

◆ RENDER_BACKEND_MODE

#define RENDER_BACKEND_MODE   RENDER_BACKEND_MODE_GLIDE

The mode of the renderer of the library being built.

◆ VERTEX_CONV_CACHE_SIZE

#define VERTEX_CONV_CACHE_SIZE   0x800

The number of entries of g_aVertexConvCache.

◆ TEXTURE_MAP_ENTRY_COUNT

#define TEXTURE_MAP_ENTRY_COUNT   256

The number of entries of g_aTextureMapEntries.

◆ TEXTURE_UPLOAD_QUEUE_SIZE

#define TEXTURE_UPLOAD_QUEUE_SIZE   256

The number of entries of g_aTextureUploadQueue.

◆ TEXTURE_RESAMPLE_BUFFER_BYTES

#define TEXTURE_RESAMPLE_BUFFER_BYTES   0x80000

The bytes of g_abTextureResampleBuffer.

Function Documentation

◆ GetRenderBackendMode()

int GetRenderBackendMode ( void )

The renderer the game was set to use.

Returns
g_dwRenderBackendMode.
Ghidra address:
BRD3D: 0x1006a980

◆ SetRenderBackendMode()

void SetRenderBackendMode ( int nMode)

Record the mode of the renderer.

The mode of the renderer of the library sets the routines that reset its device and start the renderer and the texture subsystem.

Parameters
nModeThe mode.
Ghidra address:
BRD3D: 0x1006a990
Ghidra address:
BRGlide: 0x10063940

◆ InitializeRenderSubsystems()

void InitializeRenderSubsystems ( int nMode)

Start the renderer of a mode: reset the device, start the texture subsystem and the renderer, and empty the pool of the data of the models.

Parameters
nModeThe mode of the renderer.
Ghidra address:
BRD3D: 0x1006aa20
Ghidra address:
BRGlide: 0x100639d0

◆ ResetRenderSubsystems()

void ResetRenderSubsystems ( int nMode,
int nWidth,
int nHeight,
int nBitDepth,
int nExtra )

Shut the renderer down when one runs, and start the renderer of a mode in a display mode.

Parameters
nModeThe mode of the renderer.
nWidthThe width of the display mode.
nHeightThe height of the display mode.
nBitDepthThe bits of a pixel of the display mode.
nExtraThe fourth value of the display mode.
Ghidra address:
BRD3D: 0x1006a9c0
Ghidra address:
BRGlide: 0x10063970

◆ SetDisplayModeWithFallback()

int SetDisplayModeWithFallback ( int nWidth,
int nHeight,
int nBitDepth,
int nExtra )

Set the size of the frame buffer.

A size other than the current one closes the Glide window and opens one of the new size, or of 640 by 480 when that fails.

Parameters
nWidthThe width of the display mode.
nHeightThe height of the display mode.
nBitDepthThe bits of a pixel of the display mode, not read.
nExtraThe fourth value of the display mode, not read.
Returns
Whether a window of the size requested is open, or the result of opening the window of 640 by 480.
Ghidra address:
BRGlide: 0x1001e130

◆ SetTextureEntryDamageLevel()

void SetTextureEntryDamageLevel ( int nEntry,
int nDamageLevel )

Set the level of damage of a texture the game loaded.

Parameters
nEntryThe entry of the texture.
nDamageLevelThe level of damage.
Ghidra address:
BRD3D: 0x10025800
Ghidra address:
BRGlide: 0x10024e30

◆ InitGlideRenderDevice()

int InitGlideRenderDevice ( void )

Start the Glide device: set the routines that show a frame and shut the device down, find the hardware and its units of texture and its memory, and open the window of the size of the configuration.

Returns
Whether the hardware was found and the window opened.
Ghidra address:
BRGlide: 0x1001e080

◆ InitGbiGlideRenderer()

void InitGbiGlideRenderer ( void )

Start the renderer of the display lists of the game with Glide.

Ghidra address:
BRGlide: 0x10023b10

◆ InitializeTextureSubsystem()

void InitializeTextureSubsystem ( void )

Start the texture subsystem.

Ghidra address:
BRD3D: 0x1002a640
Ghidra address:
BRGlide: 0x10029b50

◆ GetMipLevelFromDimension()

int GetMipLevelFromDimension ( int nDimension)

Get the exponent of the smallest power of two from 1 to 256 not below a dimension of a texture.

Parameters
nDimensionThe dimension.
Returns
The exponent, from 0 to 8, and 8 for a dimension above 256.
Ghidra address:
BRD3D: 0x10027c00
Ghidra address:
BRGlide: 0x10027290

◆ CalculateTextureDimensions()

void CalculateTextureDimensions ( int * pWidth,
int * pHeight,
int nLod,
int nAspectRatio )

Get the size of a texture from the codes of Glide for its level of detail and its aspect ratio.

Parameters
pWidthReceives the width.
pHeightReceives the height. It is not written for an aspect ratio above 6.
nLodThe level of detail, from 0 for 256 texels to 8 for 1, and 1 texel above 8.
nAspectRatioThe aspect ratio, from 0 for eight times as wide as high to 6 for eight times as high as wide.
Ghidra address:
BRD3D: 0x10028720
Ghidra address:
BRGlide: 0x10029290

◆ CopyConfigFramebufferSize()

void CopyConfigFramebufferSize ( void )

Make the size of the frame the size of the framebuffer of the configuration.

Ghidra address:
BRD3D: 0x1003128c
Ghidra address:
BRGlide: 0x1002a93c

◆ RefreshScreenDimensions()

void RefreshScreenDimensions ( void )

Refresh screen dimensions from the configured framebuffer size.

Ghidra address:
BRD3D: 0x10031282
Ghidra address:
BRGlide: 0x1002a932

◆ AddVertexConversionCacheEntry()

void AddVertexConversionCacheEntry ( const Vtx * pSource,
int nVertexCount,
ConvertedModelVertex * pFloatVerts )

Add a run of vertices converted to g_aVertexConvCache while it has room.

Parameters
pSourceThe vertices of the console.
nVertexCountThe number of vertices.
pFloatVertsThe vertices converted.
Ghidra address:
BRD3D: 0x1002bf00
Ghidra address:
BRGlide: 0x10018fc0

◆ ByteSwapVertexArray()

void ByteSwapVertexArray ( Vtx * pVertices,
int nCount )

Byte-swap the positions, flags, and texture coordinates of loaded Nintendo 64 vertices.

Ghidra address:
BRD3D: 0x1002bdd0
Ghidra address:
BRGlide: 0x10018e90

◆ ConvertVerticesToFloat()

ConvertedModelVertex * ConvertVerticesToFloat ( const Vtx * pVertices,
int nCount )

Convert Nintendo 64 vertex positions and texture coordinates to floats in the model data pool.

Normal components are divided by 128.

Returns
The first converted vertex in the pool.
Ghidra address:
BRD3D: 0x1002be30
Ghidra address:
BRGlide: 0x10018ef0

◆ ConvertN64VerticesCached()

void ConvertN64VerticesCached ( ModelVertexData * pVertices,
int nCount )

Reuse converted vertices for a previously seen source array, or convert and cache them.

Ghidra address:
BRD3D: 0x1002bd50
Ghidra address:
BRGlide: 0x10018e10

◆ RelocateGbiVertexCommand()

void RelocateGbiVertexCommand ( GbiCommand * pCommand)

Relocate a display-list vertex command's source address and cache its converted vertices.

Ghidra address:
BRD3D: 0x1002c150
Ghidra address:
BRGlide: 0x10019210

◆ LookupTextureMapEntry()

bool LookupTextureMapEntry ( unsigned dwAddress,
int * pnWidth,
int * pnHeight )

Get the size of the replacement of a texture of the console, searching the texture map from its last entry.

Parameters
dwAddressThe address of the texture, before g_dwTextureMapAddressBias.
pnWidthReceives the width of the replacement.
pnHeightReceives the height of the replacement.
Returns
Whether the texture map lists the texture.
Ghidra address:
BRD3D: 0x10037930
Ghidra address:
BRGlide: 0x10030fd0

◆ InitializeTextureUploadQueue()

void InitializeTextureUploadQueue ( void )

Empty the queue of textures to upload and create its mutex.

Ghidra address:
BRD3D: 0x10074f20
Ghidra address:
BRGlide: 0x1006e180

◆ DestroyTextureUploadQueue()

void DestroyTextureUploadQueue ( void )

Empty the queue of textures to upload and close its mutex.

Ghidra address:
BRD3D: 0x10074f40
Ghidra address:
BRGlide: 0x1006e1a0

◆ SetTextureLoadCategory()

void SetTextureLoadCategory ( int nCategory)

Set the category of the textures loaded next.

Parameters
nCategoryThe category.
Ghidra address:
BRD3D: 0x10074dc0
Ghidra address:
BRGlide: 0x1006e020

◆ GetTexelsPerLoadWord()

int GetTexelsPerLoadWord ( int nSize)

Get the texels of a word of 8 bytes of the texture memory of the console for a size of texel.

Parameters
nSizeThe size of the texels, from 0 for 4 bits to 3 for 32 bits.
Returns
16, 8, 4, or 2.
Ghidra address:
BRD3D: 0x10028c70
Ghidra address:
BRGlide: 0x10027f80

◆ LoadHudOverlayTexture()

void LoadHudOverlayTexture ( void )

Load the texture of the overlay of the display of the race.

Ghidra address:
BRD3D: 0x100737e0
Ghidra address:
BRGlide: 0x1006c750

◆ LoadHudGlyphTextureSets()

void LoadHudGlyphTextureSets ( void )

Load the textures of the sets of glyphs of the display of the race.

The Glide renderer loads one texture for each font atlas instead.

Ghidra address:
BRD3D: 0x10073820
Ghidra address:
BRGlide: 0x1006c790

◆ SelectTextureQualityFromVideoMemory()

void SelectTextureQualityFromVideoMemory ( void )

Select texture quality and maximum dimensions from available graphics memory.

Ghidra address:
BRD3D: 0x1002a5a0
Ghidra address:
BRGlide: 0x10029b10

◆ CreateTextureFromN64ImageAutoLoadSize()

unsigned CreateTextureFromN64ImageAutoLoadSize ( const unsigned char * pImage,
const unsigned char * pPalette,
int nWidth,
int nHeight,
int nSize,
int nFormat,
int nOption6,
int nOption7,
int nOption8,
int nOption9,
int nOption10,
int nOption11,
int nOption12,
int nOption13 )

Calculate the image load size from nWidth and delegate texture creation to the renderer.

Returns
The renderer's texture entry identifier.
Ghidra address:
BRD3D: 0x10028bf0
Ghidra address:
BRGlide: 0x10027f00

◆ DuplicateTextureEntryHalfScale()

unsigned DuplicateTextureEntryHalfScale ( unsigned nTexture)

Duplicate a texture entry with both texture-coordinate scales halved.

Returns
The new texture entry identifier.
Ghidra address:
BRD3D: 0x10024ae0

◆ LoadParticleTexture()

void LoadParticleTexture ( void )

Create the texture of the particles, 64 by 64 texels.

Ghidra address:
BRD3D: 0x10073950
Ghidra address:
BRGlide: 0x1006c800

◆ LoadTireTrailTexture()

void LoadTireTrailTexture ( void )

Create the texture of the trails of the tyres, 32 by 64 texels.

Ghidra address:
BRD3D: 0x10073980
Ghidra address:
BRGlide: 0x1006c820

◆ LoadVehicleEnvMapTexture()

void LoadVehicleEnvMapTexture ( void )

Create the map of the environment of the vehicles, 64 by 64 texels.

Ghidra address:
BRD3D: 0x100739b0
Ghidra address:
BRGlide: 0x1006c850

◆ CreateFallbackEnvironmentTexture()

void CreateFallbackEnvironmentTexture ( void )

Create the texture of the environment used when none is loaded.

Ghidra address:
BRD3D: 0x100739e0
Ghidra address:
BRGlide: 0x1006c880

◆ CreateAlphaRampTextures()

void CreateAlphaRampTextures ( void )

Create the textures of the ramps of alpha and of precipitation.

Ghidra address:
BRD3D: 0x10073a10
Ghidra address:
BRGlide: 0x1006c8b0

◆ ProcessTextureUploadQueueEntry()

void ProcessTextureUploadQueueEntry ( void )

Upload the next texture of the queue of textures to upload.

Ghidra address:
BRD3D: 0x10074fc0
Ghidra address:
BRGlide: 0x1006e220

◆ EnqueueTextureUploadEntry()

void EnqueueTextureUploadEntry ( int nEntry,
TextureUploadData payload )

Queue a texture to upload, under the mutex of the queue.

Parameters
nEntryThe entry of the texture the game loaded.
payloadThe second argument of g_pfnUploadTextureEntryToSurface.
Ghidra address:
BRD3D: 0x10074f70
Ghidra address:
BRGlide: 0x1006e1d0

◆ CreateWeatherShadeTexture()

void CreateWeatherShadeTexture ( void )

Create a uniform intensity texture for the chosen weather.

Ghidra address:
BRD3D: 0x1002a740
Ghidra address:
BRGlide: 0x10029c70

◆ QueryAvailableTextureMemory()

unsigned QueryAvailableTextureMemory ( void )

Query the free video memory available for textures on the active DirectDraw device.

Returns
The free bytes reported by DirectDraw.
Ghidra address:
BRD3D: 0x1003e220

◆ ShutdownTextureSubsystem()

void ShutdownTextureSubsystem ( void )

Stop texture uploads and release texture surfaces and owned paint buffers.

Ghidra address:
BRD3D: 0x1002a7a0
Ghidra address:
BRGlide: 0x10029cd0

◆ UploadTextureEntryToSurface()

void UploadTextureEntryToSurface ( int nEntry,
TextureUploadData payload )

Copy a supplied pixel buffer into the device texture of a loaded entry.

Parameters
nEntryThe loaded texture entry.
payloadThe pixel buffer.
Ghidra address:
BRD3D: 0x10028e00
Ghidra address:
BRGlide: 0x100285e0

◆ CreateDeviceTextureFromImageHeader()

void CreateDeviceTextureFromImageHeader ( ModelTexture * pTexture,
int nOption13 )

Replace a static model texture's image with its loaded device texture entry.

Parameters
pTextureThe model texture descriptor.
nOption13The final texture creation option.
Ghidra address:
BRD3D: 0x1002a280
Ghidra address:
BRGlide: 0x100297f0

◆ CalculateTextureLodFromDimensions()

int CalculateTextureLodFromDimensions ( int * pLod,
int width,
int height )

Derive a texture level of detail from its larger dimension.

Parameters
pLodReceives the level, clamped to zero for dimensions above 256.
widthThe width.
heightThe height.
Returns
Whether the larger dimension is at most 256.
Ghidra address:
BRD3D: 0x100251a0

◆ ChooseTexturePixelFormat()

int ChooseTexturePixelFormat ( int nSize,
int nFormat,
int bColorCombine )

Select a device pixel format from N64 texture size, format and combine state.

Parameters
nSizeThe N64 texel size.
nFormatThe N64 image format.
bColorCombineThe scan's color combine state.
Returns
The device pixel format identifier.
Ghidra address:
BRD3D: 0x10027b90
Ghidra address:
BRGlide: 0x10027220

◆ GetTexturePixelSize()

int GetTexturePixelSize ( int nPixelFormatId)

Get the decoded bytes per texture pixel.

Parameters
nPixelFormatIdThe device pixel format identifier, ignored.
Returns
Four bytes.
Ghidra address:
BRD3D: 0x100257f0

◆ FindMatchingTextureEntry()

int FindMatchingTextureEntry ( const TextureImageData * pImage)

Find an entry with the same image, palette and applicable captured colors.

Parameters
pImageThe image metadata to match.
Returns
The first matching entry, or -1.
Ghidra address:
BRD3D: 0x10028630
Ghidra address:
BRGlide: 0x10027a70

◆ RegisterTextureEntry()

unsigned RegisterTextureEntry ( const TextureImageData * pImage,
int nTextureId )

Append image metadata and a device texture identifier to the loaded entries.

Parameters
pImageThe image metadata.
nTextureIdThe device texture identifier.
Returns
The loaded texture entry.
Ghidra address:
BRD3D: 0x100284a0
Ghidra address:
BRGlide: 0x10027850

◆ ResizeTextureImage()

void ResizeTextureImage ( unsigned char * pDest,
int width,
int height,
const unsigned char * pSource,
int sourceWidth,
int sourceHeight,
int nPixelFormatId )

Resize a decoded texture with bilinear sampling at pixel centers.

Parameters
pDestThe output pixels.
widthThe output width.
heightThe output height.
pSourceThe source pixels.
sourceWidthThe source width.
sourceHeightThe source height.
nPixelFormatIdThe decoded pixel format.
Ghidra address:
BRD3D: 0x10025350
Ghidra address:
BRGlide: 0x10024490

◆ GetTextureImagePixels()

unsigned char * GetTextureImagePixels ( TextureImageData * pImage)

Decode an image descriptor into the texture pixel work buffers.

Parameters
pImageThe image metadata.
Returns
The decoded pixels.
Ghidra address:
BRD3D: 0x10028860
Ghidra address:
BRGlide: 0x10027b60

◆ ReloadTextureEntryData()

void ReloadTextureEntryData ( int nEntry)

Decode a loaded entry again and upload the resulting pixels.

Parameters
nEntryThe loaded texture entry.
Ghidra address:
BRD3D: 0x10029060
Ghidra address:
BRGlide: 0x100287e0

◆ ResizeTextureMipChain()

unsigned ResizeTextureMipChain ( unsigned char * pDest,
const unsigned char * pSource,
TextureImageData * pImage )

Resize consecutive decoded mip levels and record the decoded source dimensions.

Parameters
pDestThe output mip pixels.
pSourceThe source mip pixels.
pImageThe image metadata.
Returns
The output byte count.
Ghidra address:
BRD3D: 0x10028b20
Ghidra address:
BRGlide: 0x10027e10

◆ ModulateTextureWithIntensityPlane()

void ModulateTextureWithIntensityPlane ( const TextureImageData * pImage,
unsigned char * pPixels )

Modulate decoded RGB by the half-sized intensity plane following its pixels.

Parameters
pImageThe image metadata.
pPixelsThe decoded pixels and following intensity plane.
Ghidra address:
BRD3D: 0x10028a10
Ghidra address:
BRGlide: 0x10027cd0

◆ DecodeTexturePixels()

void DecodeTexturePixels ( unsigned char * pDest,
int nSize,
int nTexelSize,
const unsigned char * pImage,
const unsigned char * pPalette,
int nFormat,
int bMirrorS,
int bMirrorT,
int nTileIndex,
int nTileLimit,
const TexScanTile * pTiles,
unsigned flags,
int bColorCombine,
unsigned envR,
unsigned envG,
unsigned envB,
unsigned envA,
unsigned primR,
unsigned primG,
unsigned primB,
unsigned primA,
unsigned nRowSwapMask )

Decode captured N64 texture tiles into four-byte pixels.

The Glide renderer decodes them into the 16-bit formats of Glide, and an intensity without the combine into bytes.

Parameters
pDestReceives decoded pixels.
nSizeThe output byte limit.
nTexelSizeThe N64 texel size.
pImageThe captured image bytes.
pPaletteThe captured palette bytes.
nFormatThe N64 image format.
bMirrorSWhether to append reflected columns to each row.
bMirrorTWhether to append reflected rows to each tile.
nTileIndexThe first tile.
nTileLimitThe exclusive tile limit.
pTilesThe captured tile records.
flagsThe image control flags.
bColorCombineThe captured combine state.
envRThe environment red byte.
envGThe environment green byte.
envBThe environment blue byte.
envAThe environment alpha byte.
primRThe primitive red byte.
primGThe primitive green byte.
primBThe primitive blue byte.
primAThe primitive alpha byte.
nRowSwapMaskThe row mask for swapped texture words.
Ghidra address:
BRD3D: 0x10025ab0
Ghidra address:
BRGlide: 0x100250d0

◆ CreateTextureFromImage()

int CreateTextureFromImage ( TextureImageData * pImage,
unsigned char * pPixels )

Create a device texture from captured metadata and decoded pixels.

Parameters
pImageThe image metadata.
pPixelsThe decoded pixels.
Returns
The registered texture entry.
Ghidra address:
BRD3D: 0x10028350
Ghidra address:
BRGlide: 0x10027710

◆ CloneTextureEntryWithNewImageData()

int CloneTextureEntryWithNewImageData ( int nEntry,
unsigned char * pImage,
const unsigned char * pPalette )

Clone texture metadata with replacement image and palette bytes.

Parameters
nEntryThe source texture entry.
pImageThe replacement image bytes.
pPaletteThe replacement palette bytes.
Returns
The new texture entry.
Ghidra address:
BRD3D: 0x1002a350
Ghidra address:
BRGlide: 0x100298c0

◆ PreparePaintTexture()

int PreparePaintTexture ( int * pWidth,
int * pHeight,
TextureImageData * pImage )

Prepare paint texture metadata and adjust device dimensions.

Parameters
pWidthReceives the device width.
pHeightReceives the device height.
pImageThe image metadata to prepare.
Returns
0 when paint is unavailable, otherwise 1.
Ghidra address:
BRD3D: 0x10024bf0
Ghidra address:
BRGlide: 0x10023d70

◆ UploadTrackTextureVariants()

void UploadTrackTextureVariants ( ModelTexture * pTextures,
int nCount )

Create device textures for animated track frames and replace their image offsets with entries.

Parameters
pTexturesThe track texture descriptors.
nCountThe descriptor count.
Ghidra address:
BRD3D: 0x1002a430
Ghidra address:
BRGlide: 0x100299a0

◆ DecodeN64TextureToPixelBuffer()

int DecodeN64TextureToPixelBuffer ( void * pDest,
const unsigned char * pImage,
const unsigned char * pPalette,
int nWidth,
int nHeight,
int nLineBytes,
int nSize,
int nFormat )

Decode an N64 image into the pixel format selected for its texel size and format.

Parameters
pDestReceives device pixels.
pImageThe source image bytes.
pPaletteThe source palette bytes.
nWidthThe source width.
nHeightThe source height.
nLineBytesThe captured tile line size.
nSizeThe N64 texel size.
nFormatThe N64 image format.
Returns
The device pixel byte count.
Ghidra address:
BRD3D: 0x10025830
Ghidra address:
BRGlide: 0x10024e60

◆ CalculateTextureAspectRatio()

int CalculateTextureAspectRatio ( int * pAspectRatio,
int nWidth,
int nHeight )

Select an aspect ratio code from the truncated ratio of the dimensions.

Parameters
pAspectRatioReceives the aspect ratio code.
nWidthThe width, nonzero when it is the divisor.
nHeightThe height, nonzero when it is the divisor.
Returns
Whether the ratio in eighths truncates to 8, 16, 32 or 64.
Ghidra address:
BRD3D: 0x10028200

◆ CreateTextureFromN64Image()

unsigned CreateTextureFromN64Image ( const unsigned char * pImage,
const unsigned char * pPalette,
int nWidth,
int nHeight,
int nLineBytes,
int nSize,
int nFormat,
int nOption7,
int nOption8,
int nOption9,
int nOption10,
int nOption11,
int nOption12,
int nOption13,
int nOption14 )

Create a device texture from an N64 image and its load options.

Ghidra address:
BRD3D: 0x10027c60
Ghidra address:
BRGlide: 0x100272f0

◆ GetTextureEntryPixelsWithPaint()

unsigned char * GetTextureEntryPixelsWithPaint ( int nEntry,
unsigned * pSize )

Decode texture pixels, applying the selected paint damage image when needed.

Parameters
nEntryThe texture entry.
pSizeReceives the decoded byte count.
Returns
The decoded pixels.
Ghidra address:
BRD3D: 0x10028e70
Ghidra address:
BRGlide: 0x10028620

Variable Documentation

◆ g_pfnRenderBackendSubmitDisplayList

void(* g_pfnRenderBackendSubmitDisplayList) (GbiCommand *pDisplayList) ( GbiCommand * pDisplayList)
extern

The active backend callback that submits a display list for rendering.

Ghidra address:
BRD3D: 0x10b501d0

◆ g_pfnPresentFrame

void(* g_pfnPresentFrame) (void) ( void )
extern

Show the frame drawn, set by the reset of the render device.

Ghidra address:
BRD3D: 0x10690a24
Ghidra address:
BRGlide: 0x106b7ab8

◆ g_dwRenderBackendMode

int g_dwRenderBackendMode
extern

The mode of the renderer, 0 before one is set.

Ghidra address:
BRD3D: 0x10b502e4
Ghidra address:
BRGlide: 0x10b73644

◆ g_pfnRenderDeviceReset

int(* g_pfnRenderDeviceReset) (void) ( void )
extern

Reset the render device, set by SetRenderBackendMode().

Ghidra address:
BRD3D: 0x10690a20
Ghidra address:
BRGlide: 0x106b7ab4

◆ g_pfnRenderDeviceShutdown

void(* g_pfnRenderDeviceShutdown) (void) ( void )
extern

Release the render device, if one is set.

The Glide library does not call it.

Ghidra address:
BRD3D: 0x10690a28
Ghidra address:
BRGlide: 0x106b7abc

◆ g_pfnReloadTextureEntryData

void(* g_pfnReloadTextureEntryData) (int nEntry) ( int nEntry)
extern

Load the data of a texture the game loaded again, set by InitializeTextureSubsystem().

Ghidra address:
BRD3D: 0x118aa0c0
Ghidra address:
BRGlide: 0x118ed1d8

◆ g_pModelDataPoolCursor

ConvertedModelVertex* g_pModelDataPoolCursor
extern

The next free entry of g_afModelVertexPool.

Ghidra address:
BRD3D: 0x100a81c8
Ghidra address:
BRGlide: 0x100a751c

◆ g_aVertexConvCache

VertexConvCacheEntry g_aVertexConvCache[VERTEX_CONV_CACHE_SIZE]
extern

The runs of vertices converted.

Ghidra address:
BRD3D: 0x10675548
Ghidra address:
BRGlide: 0x105b16f0

◆ g_dwVertexConvCacheCount

int g_dwVertexConvCacheCount
extern

The number of entries of g_aVertexConvCache in use.

Ghidra address:
BRD3D: 0x1067b54c
Ghidra address:
BRGlide: 0x105b76f4

◆ g_aTextureMapEntries

TextureMapEntry g_aTextureMapEntries[TEXTURE_MAP_ENTRY_COUNT]
extern

The entries the texture map file lists.

Ghidra address:
BRD3D: 0x106c7e78
Ghidra address:
BRGlide: 0x106eef08

◆ g_dwTextureMapEntryCount

int g_dwTextureMapEntryCount
extern

The entries of g_aTextureMapEntries in use.

Ghidra address:
BRD3D: 0x10a99778
Ghidra address:
BRGlide: 0x10ac0808

◆ g_aTextureUploadQueue

TextureUploadRequest g_aTextureUploadQueue[TEXTURE_UPLOAD_QUEUE_SIZE]
extern

The textures to upload, a ring from g_dwTextureUploadQueueTail to g_dwTextureUploadQueueHead.

Ghidra address:
BRD3D: 0x118a9880
Ghidra address:
BRGlide: 0x118ec998

◆ g_dwTextureUploadQueueHead

int g_dwTextureUploadQueueHead
extern

The entry of g_aTextureUploadQueue the next texture to queue takes.

Ghidra address:
BRD3D: 0x118a9878
Ghidra address:
BRGlide: 0x118ec990

◆ g_dwTextureUploadQueueTail

int g_dwTextureUploadQueueTail
extern

The entry of g_aTextureUploadQueue of the next texture to upload.

Ghidra address:
BRD3D: 0x118aa098
Ghidra address:
BRGlide: 0x118ed1b0

◆ g_hTextureUploadQueueMutex

HANDLE g_hTextureUploadQueueMutex
extern

The mutex of the queue of textures to upload.

Ghidra address:
BRD3D: 0x118aa0a0
Ghidra address:
BRGlide: 0x118ed1b8

◆ g_dwCopyTextureDataOnRelocate

int g_dwCopyTextureDataOnRelocate
extern

Whether the data of a texture is copied when its pointers are relocated.

Ghidra address:
BRD3D: 0x10675540
Ghidra address:
BRGlide: 0x105b16e8

◆ g_dwTextureLoadCategory

int g_dwTextureLoadCategory
extern

The category of the textures loaded next.

Its values are not recovered yet.

Ghidra address:
BRD3D: 0x118aa088
Ghidra address:
BRGlide: 0x118ed1a0

◆ g_dwHiResTextureMemoryThreshold

unsigned g_dwHiResTextureMemoryThreshold
extern

The available texture-memory threshold for high-resolution textures, in bytes.

Ghidra address:
BRD3D: 0x11829848
Ghidra address:
BRGlide: 0x1186c960

◆ g_dwMaxTexWidthHighQuality

int g_dwMaxTexWidthHighQuality
extern

The maximum high-quality texture width, in texels.

Ghidra address:
BRD3D: 0x100a7dfc

◆ g_dwMaxTexHeightHighQuality

int g_dwMaxTexHeightHighQuality
extern

The maximum high-quality texture height, in texels.

Ghidra address:
BRD3D: 0x100a7e00

◆ g_dwMaxTexWidthLowQuality

int g_dwMaxTexWidthLowQuality
extern

The maximum low-quality texture width, in texels.

Ghidra address:
BRD3D: 0x100a7e04

◆ g_dwMaxTexHeightLowQuality

int g_dwMaxTexHeightLowQuality
extern

The maximum low-quality texture height, in texels.

Ghidra address:
BRD3D: 0x100a7e08

◆ g_pfnCreateTextureFromN64ImageAutoLoadSize

unsigned(* g_pfnCreateTextureFromN64ImageAutoLoadSize) (const unsigned char *, const unsigned char *, int, int, int, int, int, int, int, int, int, int, int, int) ( const unsigned char * ,
const unsigned char * ,
int ,
int ,
int ,
int ,
int ,
int ,
int ,
int ,
int ,
int ,
int ,
int  )
extern

The backend callback that creates an N64 image texture after calculating its load size.

Ghidra address:
BRD3D: 0x118aa0b0

◆ g_abAlphaRampRgba

unsigned char g_abAlphaRampRgba[16][4]
extern

The 16 white RGBA colours of the alpha ramp, with alpha increasing by 17.

Ghidra address:
BRD3D: 0x11829330

◆ g_abAlphaRampPixelStrip

unsigned char g_abAlphaRampPixelStrip[64]
extern

The alpha ramp converted to device pixel format.

Ghidra address:
BRD3D: 0x11829118

◆ g_abWeatherShadeTexture

unsigned char g_abWeatherShadeTexture[16]
extern

The 4-by-4 intensity pixels of the current weather shade.

Ghidra address:
BRD3D: 0x104d51c0

◆ g_dwWeatherShadeTextureId

unsigned g_dwWeatherShadeTextureId
extern

The device texture identifier of the current weather shade.

Ghidra address:
BRD3D: 0x105553e4
Ghidra address:
BRGlide: 0x10697a4c

◆ g_dwTexturePixelByteCount

unsigned g_dwTexturePixelByteCount
extern

The byte count produced by the last decoded texture operation.

Ghidra address:
BRD3D: 0x105553f8
Ghidra address:
BRGlide: 0x10697a60

◆ g_abTextureResampleBuffer

unsigned char g_abTextureResampleBuffer[TEXTURE_RESAMPLE_BUFFER_BYTES]
extern

The pixels of a texture after resizing, or an intensity plane while it is applied.

Ghidra address:
BRD3D: 0x104d51d0
Ghidra address:
BRGlide: 0x105e1828

◆ g_szTidFromTextureAppendAmid

const char g_szTidFromTextureAppendAmid[]
extern

Allocation label for the device texture table.

Ghidra address:
BRD3D: 0x100a7e20

◆ g_pfnCreateDeviceTextureFromImageHeader

decltype(&CreateDeviceTextureFromImageHeader) g_pfnCreateDeviceTextureFromImageHeader
extern

The backend callback that creates a device texture from a model texture header.

Ghidra address:
BRD3D: 0x118aa0c8

◆ g_pfnCloneTextureEntryWithNewImageData

decltype(&CloneTextureEntryWithNewImageData) g_pfnCloneTextureEntryWithNewImageData
extern

The backend callback that clones a texture entry with replacement image data.

Ghidra address:
BRD3D: 0x118aa084

◆ g_pfnUploadTrackTextureVariants

decltype(&UploadTrackTextureVariants) g_pfnUploadTrackTextureVariants
extern

The backend callback that uploads the texture variants of a track.

Ghidra address:
BRD3D: 0x118aa0cc

◆ g_dwCurrentMaxTextureWidth

int g_dwCurrentMaxTextureWidth
extern

The width limit selected for the current texture category.

Ghidra address:
BRD3D: 0x100a7df4

◆ g_dwCurrentMaxTextureHeight

int g_dwCurrentMaxTextureHeight
extern

The height limit selected for the current texture category.

Ghidra address:
BRD3D: 0x100a7df8