| 1795 | // mBoundTexture |
| 1796 | |
| 1797 | void BaseRenderer::UpdateTileSnapshot( u32 index, u32 tile_idx ) |
| 1798 | { |
| 1799 | DAEDALUS_PROFILE( "BaseRenderer::UpdateTileSnapshot" ); |
| 1800 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 1801 | DAEDALUS_ASSERT( tile_idx < 8, "Invalid tile index %d", tile_idx ); |
| 1802 | DAEDALUS_ASSERT( index < kNumBoundTextures, "Invalid texture index %d", index ); |
| 1803 | #endif |
| 1804 | // This hapens a lot! Even for index 0 (i.e. the main texture!) |
| 1805 | // It might just be code that lazily does a texrect with Primcolour (i.e. not using either T0 or T1)? |
| 1806 | // DAEDALUS_ASSERT( gRDPStateManager.IsTileInitialised( tile_idx ), "Tile %d hasn't been set up (index %d)", tile_idx, index ); |
| 1807 | |
| 1808 | const TextureInfo & ti {gRDPStateManager.GetUpdatedTextureDescriptor( tile_idx )}; |
| 1809 | const RDP_Tile & rdp_tile {gRDPStateManager.GetTile( tile_idx )}; |
| 1810 | const RDP_TileSize & tile_size {gRDPStateManager.GetTileSize( tile_idx )}; |
| 1811 | |
| 1812 | // Avoid texture update, if texture is the same as last time around. |
| 1813 | if( mBoundTexture[ index ] == nullptr || mBoundTextureInfo[ index ] != ti ) |
| 1814 | { |
| 1815 | // // Check for 0 width/height textures |
| 1816 | // if( ti.GetWidth() == 0 || ti.GetHeight() == 0 ) |
| 1817 | // { |
| 1818 | // DAEDALUS_DL_ERROR( "Loading texture with bad width/height %dx%d in slot %d", ti.GetWidth(), ti.GetHeight(), index ); |
| 1819 | // } |
| 1820 | // else |
| 1821 | // { |
| 1822 | CRefPtr<CNativeTexture> texture = CTextureCache::Get()->GetOrCreateTexture( ti ); |
| 1823 | |
| 1824 | if( texture != nullptr && texture != mBoundTexture[ index ] ) |
| 1825 | { |
| 1826 | mBoundTextureInfo[index] = ti; |
| 1827 | mBoundTexture[index] = texture; |
| 1828 | |
| 1829 | #ifdef DAEDALUS_PSP |
| 1830 | //If second texture is loaded try to merge two textures RGB(T0) + A(T1) into one RGBA(T1) //Corn |
| 1831 | //If T1 Hack is not enabled index can never be other than 0 |
| 1832 | if(index) |
| 1833 | { |
| 1834 | T1Hack(mBoundTextureInfo[0], mBoundTexture[0], mBoundTextureInfo[1], mBoundTexture[1]); |
| 1835 | } |
| 1836 | #endif |
| 1837 | // } |
| 1838 | } |
| 1839 | } |
| 1840 | |
| 1841 | // Initialise the clamping state. When the mask is 0, it forces clamp mode. |
| 1842 | // |
| 1843 | u32 mode_u {(u32)((rdp_tile.clamp_s | (rdp_tile.mask_s == 0)) ? GU_CLAMP : GU_REPEAT)}; |
| 1844 | u32 mode_v {(u32)((rdp_tile.clamp_t | (rdp_tile.mask_t == 0)) ? GU_CLAMP : GU_REPEAT)}; |
| 1845 | |
| 1846 | // In CRDPStateManager::GetTextureDescriptor, we limit the maximum dimension of a |
| 1847 | // texture to that define by the mask_s/mask_t value. |
| 1848 | // It this happens, the tile size can be larger than the truncated width/height |
| 1849 | // as the rom can set clamp_s/clamp_t to wrap up to a certain value, then clamp. |
| 1850 | // We can't support both wrapping and clamping (without manually repeating a texture...) |
| 1851 | // so we choose to prefer wrapping. |
| 1852 | // The castle in the background of the first SSB level is a good example of this behaviour. |
| 1853 | // It sets up a texture with a mask_s/t of 6/6 (64x64), but sets the tile size to |
| 1854 | // 256*128. clamp_s/t are set, meaning the texture wraps 4x and 2x. |
nothing calls this directly
no test coverage detected