al - Audio Library Functions gDP - DP GBI Macros gdSP - General GBI Macros gSP - SP GBI Macros gt - Turbo Microcode RDP gu - Graphics Utilities Math - Math Functions nuSys - NuSystem os - N64 Operating System sp - Sprite Library Functions uh - Host to Target IO 64DD - N64 Disk Drive
|
gSPObjLoadTxtr [macro]Loads the texture loading parameters. Syntax
Arguments
Explanation
Cautions
GS_PIX2TMEM(pix, siz) GS_TB_TSIZE(pix, siz) GS_TB_TLINE(pix, siz) typedef struct { u32 type; /* Structure identifier (G_OBJLT_TXTRBLOCK) */ u64 *image; /* Texture source address in DRAM (8-byte alignment) */ u16 tmem; /* TMEM word address where texture will be loaded (8-byte word) */ u16 tsize; /* Texture size (specified by GS_TB_TSIZE) */ u16 tline; /* Texture line width (specified by GS_TB_TLINE) */ u16 sid; /* Status ID (multiple of 4: either 0, 4, 8, or 12) */ u32 flag; /* Status flag */ u32 mask; /* Status mask */ } uObjTxtrBlock_t; /* 24 bytes */ GS_TT_TWIDTH(pix, siz) GS_TT_THEIGHT(pix, siz) typedef struct { u32 type; /* Structure identifier (G_OBJLT_TXTRTILE) */ u64 *image; /* Texture source address in DRAM (8-byte alignment) */ u16 tmem; /* TMEM word address where texture will be loaded (8-byte word) */ u16 twidth; /* Texture width (specified by GS_TT_TWIDTH) */ u16 theight;/* Texture height (specified by GS_TT_THEIGHT) */ u16 sid; /* Status ID (multiple of 4: either 0, 4, 8, or 12) */ u32 flag; /* Status flag */ u32 mask; /* Status mask */ } uObjTxtrTile_t; /* 24 bytes */ GS_PAL_HEAD(head) GS_PAL_NUM(num) typedef struct { u32 type; /* Structure identifier (G_OBJLT_TLUT) */ u64 *image; /* Texture source address in DRAM */ u16 phead; /* Palette position at start of load (256~511) */ u16 pnum; /* Number of palettes to load - 1 */ u16 zero; /* Always assign 0 */ u16 sid; /* Status ID (multiple of 4: either 0, 4, 8, or 12) */ u32 flag; /* Status flag */ u32 mask; /* Status mask */ } uObjTxtrTLUT_t; /* 24 bytes */ typedef union { uObjTxtrBlock_t block; uObjTxtrTile_t tile; uObjTxtrTLUT_t tlut; long long int force_structure_alignment; } uObjTxtr; The three structures described above (uObjTxtrBlock_t, uObjTxtrTile_t, and uObjTxtrTLUT_t) have the common elements type, image, sid, flag, and mask.
The uObjTxtrBlock_t structure has the following elements in addition to the common elements described above:
The uObjTxtrTile_t structure has the following elements in addition to the common elements described above:
The uObjTxtrTLUT_t structure has the following elements in addition to the common elements described above:
The macro arguments for changing units are as follows:
Concerning the method used to decide whether to load a texture: For the RSP to completely handle the process of deciding whether or not a given texture already exists inside TMEM, the RSP must analyze the load destination area each time a texture is loaded. Spending time on this decision process is not efficient. Therefore, the S2DEX microcode does not have the RSP perform any analysis on the texture to be loaded. Instead, data related to the area in which the texture data structure is to be loaded is added in advance, and the loading decision is made by a simple calculation on this data. For example, a simple loading decision could be made by writing the ID corresponding to the loaded texture in a status area within the RSP when data is loaded in TMEM, and then making a comparison with that ID the next time data is loaded in TMEM. The loading decision process implemented in S2DEX is based on an extension of this concept. By setting the two 32-bit values for flag and mask, the loading decision process can also support the subdivision of TMEM and partial loads. Four 32-bit variable Status areas have been prepared as the status region in the RSP. The Status region values are all 0 when the microcode is booted. Which Status value to use is determined by sid. The values that sid can take are {0, 4, 8, 12}. This macro actually uses the following processes to decide whether or not a texture is to be loaded:
Status[sid] = (Status[sid] & ~mask) | (flag & mask); The simplest way of using flag is to assign -1 (=0xffffffff) to mask and the address of the texture source data (= image value) to flag. If no other texture data starts at the same address, this operates as a single texture cache. When (flag & ~mask) != 0, the texture will always be loaded since the decision expression is always false . When TMEM is managed by subdividing it into two parts, the Status[0] bits 31-16 are assigned to the first half of the TMEM area, the bits 15-0 are assigned to the second half, and a serial number is assigned to each texture. The value of sid is always zero.
To give an example, consider that all of texture 3 is loaded by C. If the first half of TMEM is subsequently changed by loading by A, the texture 3 data will still remain in the second half of TMEM. If D now attempts to load only the second half of texture 3, no loading will actually be performed. S2DEX makes use of this status-based processing to make similar decisions for display list branching in gSPSelectDL and gSPSelectBranchDL. Example
(1) Loading a RGBA16 texture with LoadBlock uObjTxtr objTxtrBlock_RGBA16 = { G_OBJLT_TXTRBLOCK, /* type */ (u64 *)textureRGBA16, /* image */ GS_PIX2TMEM(0, G_IM_SIZ_16b), /* tmem */ GS_TB_TSIZE(32*32, G_IM_SIZ_16b), /* tsize */ GS_TB_TLINE(32, G_IM_SIZ_16b), /* tline */ 0, /* sid */ (u32)textureRGBA16, /* flag */ -1 /* mask */ }; (2) Loading a CI4 texture with LoadTile uObjTxtr objTxtrTile_CI4 = { G_OBJLT_TXTRTILE, /* type */ (u64 *)textureCI4, /* image */ GS_PIX2TMEM (0, G_IM_SIZ_4b), /* tmem */ GS_TT_TWIDTH (32, G_IM_SIZ_4b), /* twidth */ GS_TT_THEIGHT(32, G_IM_SIZ_4b), /* theight */ 0, /* sid */ (u32)textureCI4, /* flag */ -1 /* mask */ }; (3) Loading a CI4 texture via a TLUT uObjTxtr objTLUT_CI4 = { G_OBJLT_TLUT, /* type */ (u64 *)textureCI4pal, /* image */ GS_PAL_HEAD(0), /* phead */ GS_PAL_NUM(16), /* pnum */ 0, /* zero */ 0, /* sid */ (u32)textureCI4pal, /* flag */ -1 /* mask */ }; See Also
Revision History
|