|
ReXGlue SDK
|
Xenos texture info, memory layout and format conversion. More...
#include <memory>#include <algorithm>#include <cstring>#include <functional>#include <rex/platform.h>#include <rex/assert.h>#include <rex/types.h>#include <rex/xenos/fetch.h>#include <rex/xenos/format.h>#include <rex/bit.h>Go to the source code of this file.
Classes | |
| struct | rex::xenos::GuestTextureLayout |
| struct | rex::xenos::GuestTextureLayout::Level |
| struct | rex::xenos::FormatInfo |
| struct | rex::xenos::TextureExtent |
| struct | rex::xenos::TextureMemoryRanges |
| struct | rex::xenos::TextureInfo |
| struct | rex::xenos::UntileRegion |
Namespaces | |
| namespace | rex |
Typedefs | |
| using | rex::xenos::CopyBlockCallback = std::function<void(xenos::Endian, void*, const void*, size_t)> |
| using | rex::xenos::UntileCopyBlockCallback = std::function<void(void*, const void*, size_t)> |
Enumerations | |
| enum class | rex::xenos::FormatType : u8 { kResolvable , kUncompressed , kCompressed } |
Functions | |
| void | rex::xenos::GetSubresourcesFromFetchConstant (const xenos::TextureFetch &fetch, u32 *width_minus_1_out, u32 *height_minus_1_out, u32 *depth_or_array_size_minus_1_out, u32 *base_page_out, u32 *mip_page_out, u32 *mip_min_level_out, u32 *mip_max_level_out) |
| u32 | rex::xenos::GetPackedMipLevel (u32 width, u32 height) |
| bool | rex::xenos::GetPackedMipOffset (u32 width, u32 height, u32 depth, xenos::TextureFormat format, u32 mip, u32 &x_blocks, u32 &y_blocks, u32 &z_blocks) |
| GuestTextureLayout | rex::xenos::GetGuestTextureLayout (xenos::DataDimension dimension, u32 base_pitch_texels_div_32, u32 width_texels, u32 height_texels, u32 depth_or_array_size, bool is_tiled, xenos::TextureFormat format, bool has_packed_levels, bool has_base, u32 max_level) |
| i32 | rex::xenos::GetTiledOffset2D (i32 x, i32 y, u32 pitch, u32 bytes_per_block_log2) |
| i32 | rex::xenos::GetTiledOffset3D (i32 x, i32 y, i32 z, u32 pitch, u32 height, u32 bytes_per_block_log2) |
| u32 | rex::xenos::GetTiledAddressLowerBound2D (u32 left, u32 top, u32 pitch, u32 bytes_per_block_log2) |
| u32 | rex::xenos::GetTiledAddressLowerBound3D (u32 left, u32 top, u32 front, u32 pitch, u32 height, u32 bytes_per_block_log2) |
| u32 | rex::xenos::GetTiledAddressUpperBound2D (u32 right, u32 bottom, u32 pitch, u32 bytes_per_block_log2) |
| u32 | rex::xenos::GetTiledAddressUpperBound3D (u32 right, u32 bottom, u32 back, u32 pitch, u32 height, u32 bytes_per_block_log2) |
| u8 | rex::xenos::SwizzleSigns (const xenos::TextureFetch &fetch) |
| constexpr bool | rex::xenos::HasNonSignedComponent (u8 packed_signs) |
| constexpr bool | rex::xenos::HasSignedComponent (u8 packed_signs) |
| void | rex::xenos::GetClampModesForDimension (const xenos::TextureFetch &fetch, xenos::ClampMode &clamp_x_out, xenos::ClampMode &clamp_y_out, xenos::ClampMode &clamp_z_out) |
| xenos::TextureFormat | rex::xenos::GetBaseFormat (xenos::TextureFormat texture_format) |
| size_t | rex::xenos::GetTexelSize (xenos::TextureFormat format) |
| xenos::TextureFormat | rex::xenos::ColorFormatToTextureFormat (xenos::ColorFormat color_format) |
| xenos::TextureFormat | rex::xenos::DepthRenderTargetToTextureFormat (xenos::DepthRenderTargetFormat depth_format) |
| void | rex::xenos::CopySwapBlock (xenos::Endian endian, void *output, const void *input, size_t length) |
| void | rex::xenos::ConvertTexelCTX1ToR8G8 (xenos::Endian endian, void *output, const void *input, size_t output_pitch) |
| void | rex::xenos::ConvertTexelDXT3AToDXT3 (xenos::Endian endian, void *output, const void *input, size_t length) |
| void | rex::xenos::Untile (u8 *output_buffer, const u8 *input_buffer, const UntileRegion *untile_info) |
Xenos texture info, memory layout and format conversion.
| using rex::xenos::CopyBlockCallback = std::function<void(xenos::Endian, void*, const void*, size_t)> |
Copies a block, swapping bytes by the given endian mode.
|
strong |
|
inline |
Returns the texture format with the same numeric value as a color format.
| void rex::xenos::ConvertTexelCTX1ToR8G8 | ( | xenos::Endian | endian, |
| void * | output, | ||
| const void * | input, | ||
| size_t | output_pitch ) |
Decodes an 8 byte CTX1 block into 4x4 R8G8 texels.
| endian | The swap mode of the source block. |
| output | Destination for 4 rows of 4 R8G8 texels. |
| input | Source CTX1 block. |
| output_pitch | Destination row pitch in bytes. |
| void rex::xenos::ConvertTexelDXT3AToDXT3 | ( | xenos::Endian | endian, |
| void * | output, | ||
| const void * | input, | ||
| size_t | length ) |
Expands a DXT3A block into a DXT3 block with the color half zeroed.
| endian | The swap mode of the source block. |
| output | Destination 16 byte DXT3 block. |
| input | Source 8 byte DXT3A block. |
| length | Unused. |
| void rex::xenos::CopySwapBlock | ( | xenos::Endian | endian, |
| void * | output, | ||
| const void * | input, | ||
| size_t | length ) |
Copies bytes, swapping them as endian specifies.
|
inline |
Returns the texture format that matches a depth render target format, or TextureFormat(~0) for an unhandled format.
|
inline |
Maps a resampling or gamma control variant to its base format.
| void rex::xenos::GetClampModesForDimension | ( | const xenos::TextureFetch & | fetch, |
| xenos::ClampMode & | clamp_x_out, | ||
| xenos::ClampMode & | clamp_y_out, | ||
| xenos::ClampMode & | clamp_z_out ) |
Reads the clamp modes a fetch constant uses for its dimension. Unused axes and cube textures get kClampToEdge.
| clamp_x_out | Receives the X clamp mode. |
| clamp_y_out | Receives the Y clamp mode. |
| clamp_z_out | Receives the Z clamp mode. |
| GuestTextureLayout rex::xenos::GetGuestTextureLayout | ( | xenos::DataDimension | dimension, |
| u32 | base_pitch_texels_div_32, | ||
| u32 | width_texels, | ||
| u32 | height_texels, | ||
| u32 | depth_or_array_size, | ||
| bool | is_tiled, | ||
| xenos::TextureFormat | format, | ||
| bool | has_packed_levels, | ||
| bool | has_base, | ||
| u32 | max_level ) |
Calculates the guest memory layout of a texture, all zero when it has no texels.
| base_pitch_texels_div_32 | Base level row pitch in texels divided by 32. |
| depth_or_array_size | Depth for 3D textures, array size otherwise. |
| is_tiled | True for tiled data, false for linear. |
| has_packed_levels | True when small levels share a packed mip tail. |
| has_base | True when the base level is present. |
|
inline |
Returns the first mip level stored in the packed mip tail.
| bool rex::xenos::GetPackedMipOffset | ( | u32 | width, |
| u32 | height, | ||
| u32 | depth, | ||
| xenos::TextureFormat | format, | ||
| u32 | mip, | ||
| u32 & | x_blocks, | ||
| u32 & | y_blocks, | ||
| u32 & | z_blocks ) |
Finds the offset of a mip level within the packed mip tail.
| depth | Depth in texels, 1 for textures other than 3D. |
| x_blocks | Receives the X offset in blocks. |
| y_blocks | Receives the Y offset in blocks. |
| z_blocks | Receives the Z offset in blocks. |
| void rex::xenos::GetSubresourcesFromFetchConstant | ( | const xenos::TextureFetch & | fetch, |
| u32 * | width_minus_1_out, | ||
| u32 * | height_minus_1_out, | ||
| u32 * | depth_or_array_size_minus_1_out, | ||
| u32 * | base_page_out, | ||
| u32 * | mip_page_out, | ||
| u32 * | mip_min_level_out, | ||
| u32 * | mip_max_level_out ) |
Reads the size and present levels from a fetch constant. Every output pointer may be null.
| width_minus_1_out | Receives the width in texels minus 1. |
| height_minus_1_out | Receives the height in texels minus 1. |
| depth_or_array_size_minus_1_out | Receives the depth or array size minus 1, 5 for cubes. |
| base_page_out | Receives the base level page, 0 when the base level is absent. |
| mip_page_out | Receives the mip page, 0 when no mips are present. |
| mip_min_level_out | Receives the first present level. |
| mip_max_level_out | Receives the last present level. |
|
inline |
Returns the size of one texel of an uncompressed format in bytes, or 0 for an unhandled format.
|
inline |
Returns the lowest address a 2D region can touch, the origin of its first 32x32 tile. The offset is in bytes.
| left | Left edge in blocks. |
| top | Top edge in blocks. |
| pitch | Row pitch in blocks. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
|
inline |
Returns the lowest address a 3D region can touch, the origin of its first 32x32x4 tile. The offset is in bytes.
| left | Left edge in blocks. |
| top | Top edge in blocks. |
| pitch | Row pitch in blocks. |
| height | Height in blocks. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
| u32 rex::xenos::GetTiledAddressUpperBound2D | ( | u32 | right, |
| u32 | bottom, | ||
| u32 | pitch, | ||
| u32 | bytes_per_block_log2 ) |
Returns the exclusive upper address bound of a 2D region, or 0 for an empty region. The region may extend past the pitch.
| right | Exclusive right edge in blocks. |
| bottom | Exclusive bottom edge in blocks. |
| pitch | Row pitch in blocks. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
| u32 rex::xenos::GetTiledAddressUpperBound3D | ( | u32 | right, |
| u32 | bottom, | ||
| u32 | back, | ||
| u32 | pitch, | ||
| u32 | height, | ||
| u32 | bytes_per_block_log2 ) |
Returns the exclusive upper address bound of a 3D region, or 0 for an empty region. The region may extend past the pitch and height.
| right | Exclusive right edge in blocks. |
| bottom | Exclusive bottom edge in blocks. |
| back | Exclusive back layer. |
| pitch | Row pitch in blocks. |
| height | Height in blocks. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
| i32 rex::xenos::GetTiledOffset2D | ( | i32 | x, |
| i32 | y, | ||
| u32 | pitch, | ||
| u32 | bytes_per_block_log2 ) |
Returns the offset of a block in a 2D tiled texture. Negative coordinates are valid.
| pitch | Row pitch in blocks, aligned to 32 internally. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
| i32 rex::xenos::GetTiledOffset3D | ( | i32 | x, |
| i32 | y, | ||
| i32 | z, | ||
| u32 | pitch, | ||
| u32 | height, | ||
| u32 | bytes_per_block_log2 ) |
Returns the offset of a block in a 3D tiled texture. Each 32 block row by 4 layer portion occupies its own 4 KB aligned range.
| pitch | Row pitch in blocks, aligned to 32 internally. |
| height | Height in blocks, aligned to 32 internally. |
| bytes_per_block_log2 | log2_floor of the bytes per block. |
|
constexpr |
Reports whether any component is not kSigned.
| packed_signs | Packed signs from SwizzleSigns. |
|
constexpr |
Reports whether any component is kSigned.
| packed_signs | Packed signs from SwizzleSigns. |
| u8 rex::xenos::SwizzleSigns | ( | const xenos::TextureFetch & | fetch | ) |
Packs the TextureSign of each component after the swizzle. Constant 0 and 1 count as unsigned unless every other component is signed.
| void rex::xenos::Untile | ( | u8 * | output_buffer, |
| const u8 * | input_buffer, | ||
| const UntileRegion * | untile_info ) |
Converts a region of a 2D tiled texture to linear layout.
| output_buffer | Linear destination. |
| input_buffer | Tiled source. |
| untile_info | The region, pitches, formats and block copy callback. |