45 u32* height_minus_1_out, u32* depth_or_array_size_minus_1_out,
46 u32* base_page_out, u32* mip_page_out, u32* mip_min_level_out,
47 u32* mip_max_level_out);
52 return log2_size > 4 ? log2_size - 4 : 0;
65 u32& x_blocks, u32& y_blocks, u32& z_blocks);
76 u32 z_layer_stride_block_rows;
89 u32 mips_total_extent_bytes;
105 u32 base_pitch_texels_div_32, u32 width_texels,
106 u32 height_texels, u32 depth_or_array_size,
bool is_tiled,
108 bool has_base, u32 max_level);
139 static_cast<i32
>(left & ~(xenos::kTextureTileWidthHeight - 1)),
140 static_cast<i32
>(top & ~(xenos::kTextureTileWidthHeight - 1)), pitch, bytes_per_block_log2));
154 u32 bytes_per_block_log2) {
155 return static_cast<u32
>(
156 GetTiledOffset3D(
static_cast<i32
>(left & ~(xenos::kTextureTileWidthHeight - 1)),
157 static_cast<i32
>(top & ~(xenos::kTextureTileWidthHeight - 1)),
158 static_cast<i32
>(front & ~(xenos::kTextureTileDepth - 1)), pitch, height,
159 bytes_per_block_log2));
185 u32 bytes_per_block_log2);
211 return ((xor_signed | (xor_signed >> 1)) & 0b01010101) != 0b01010101;
227namespace rex::xenos {
235 switch (texture_format) {
236 case xenos::TextureFormat::k_16_EXPAND:
237 return xenos::TextureFormat::k_16_FLOAT;
238 case xenos::TextureFormat::k_16_16_EXPAND:
239 return xenos::TextureFormat::k_16_16_FLOAT;
240 case xenos::TextureFormat::k_16_16_16_16_EXPAND:
241 return xenos::TextureFormat::k_16_16_16_16_FLOAT;
242 case xenos::TextureFormat::k_8_8_8_8_AS_16_16_16_16:
243 return xenos::TextureFormat::k_8_8_8_8;
244 case xenos::TextureFormat::k_DXT1_AS_16_16_16_16:
245 return xenos::TextureFormat::k_DXT1;
246 case xenos::TextureFormat::k_DXT2_3_AS_16_16_16_16:
247 return xenos::TextureFormat::k_DXT2_3;
248 case xenos::TextureFormat::k_DXT4_5_AS_16_16_16_16:
249 return xenos::TextureFormat::k_DXT4_5;
250 case xenos::TextureFormat::k_2_10_10_10_AS_16_16_16_16:
251 return xenos::TextureFormat::k_2_10_10_10;
252 case xenos::TextureFormat::k_10_11_11_AS_16_16_16_16:
253 return xenos::TextureFormat::k_10_11_11;
254 case xenos::TextureFormat::k_11_11_10_AS_16_16_16_16:
255 return xenos::TextureFormat::k_11_11_10;
256 case xenos::TextureFormat::k_8_8_8_8_GAMMA_EDRAM:
257 return xenos::TextureFormat::k_8_8_8_8;
262 return texture_format;
270 case xenos::TextureFormat::k_8:
272 case xenos::TextureFormat::k_1_5_5_5:
273 case xenos::TextureFormat::k_4_4_4_4:
274 case xenos::TextureFormat::k_5_6_5:
275 case xenos::TextureFormat::k_8_8:
277 case xenos::TextureFormat::k_2_10_10_10:
278 case xenos::TextureFormat::k_8_8_8_8:
279 case xenos::TextureFormat::k_16:
280 case xenos::TextureFormat::k_16_FLOAT:
281 case xenos::TextureFormat::k_16_16:
282 case xenos::TextureFormat::k_16_16_FLOAT:
283 case xenos::TextureFormat::k_32_FLOAT:
284 case xenos::TextureFormat::k_10_11_11:
285 case xenos::TextureFormat::k_11_11_10:
287 case xenos::TextureFormat::k_16_16_16_16:
288 case xenos::TextureFormat::k_16_16_16_16_FLOAT:
289 case xenos::TextureFormat::k_32_32_FLOAT:
291 case xenos::TextureFormat::k_32_32_32_32_FLOAT:
310 switch (depth_format) {
335 u32 GetBytesPerBlock()
const {
return block_width * block_height * bits_per_pixel / 8; }
345 return Get(
static_cast<u32
>(format));
373 bool is_tiled,
bool is_guest);
403 u32 depth_or_array_size_minus_1;
416 bool IsCompressed()
const {
return GetFormatInfo()->type == FormatType::kCompressed; }
418 u32 GetMipLevels()
const {
return 1 + (mip_max_level - mip_min_level); }
436 xenos::Endian endian, u32 pitch, u32 width, u32 height, u32 depth,
478 u32 packed_tile, u32* offset_x, u32* offset_y);
493 bool operator==(
const TextureInfo& other)
const =
default;
496 void SetupMemoryRanges(u32 base_address, u32 mip_address);
501namespace rex::xenos {
518 size_t output_pitch);
530using UntileCopyBlockCallback = std::function<void(
void*,
const void*,
size_t)>;
541 UntileCopyBlockCallback copy_callback;
#define REX_UNHANDLED_CASE(var)
Definition assert.h:119
Fetch constant layouts, texture sampling enums and limits.
ClampMode
Definition fetch.h:35
@ kSigned
Definition fetch.h:59
DataDimension
Definition fetch.h:27
T log2_ceil(T v)
Definition bit.h:263
u32 z_extent
Definition texture.h:80
u32 x_extent_blocks
Definition texture.h:78
u32 y_extent_blocks
Definition texture.h:79
u32 level_data_extent_bytes
Definition texture.h:82
u32 array_layer_data_extent_bytes
Definition texture.h:81
u32 row_pitch_bytes
Definition texture.h:75
u32 array_layer_stride_bytes
Definition texture.h:77
u32 packed_level
Definition texture.h:91
Level mips[xenos::kTextureMaxMips]
Definition texture.h:87
u32 max_level
Definition texture.h:90
u32 mip_offsets_bytes[xenos::kTextureMaxMips]
Definition texture.h:88
u32 array_size
Definition texture.h:92
u32 height
Definition texture.h:353
u32 GetAllBlocks() const
Definition texture.h:361
u32 block_width
Definition texture.h:354
u32 GetVisibleBlocks() const
Definition texture.h:364
static TextureExtent Calculate(const TextureInfo *texture_info, bool is_guest)
static TextureExtent Calculate(const FormatInfo *format_info, u32 pitch, u32 height, u32 depth, bool is_tiled, bool is_guest)
u32 block_height
Definition texture.h:355
u32 block_pitch_h
Definition texture.h:356
u32 block_pitch_v
Definition texture.h:357
xenos::DataDimension dimension
Definition texture.h:400
static bool FromFetchConstant(const xenos::TextureFetch &fetch, TextureInfo *out_info)
static bool FromResolve(u32 physical_address, xenos::TextureFormat texture_format, xenos::Endian endian, u32 pitch, u32 width, u32 height, u32 depth, TextureInfo *out_info)
TextureExtent extent
Definition texture.h:412
u32 GetMipLocation(u32 mip, u32 *offset_x, u32 *offset_y, bool is_guest) const
void GetMipSize(u32 mip, u32 *width, u32 *height) const
bool has_packed_mips
Definition texture.h:409
bool is_stacked
Definition texture.h:407
bool GetPackedMipOffset(u32 packed_tile, u32 *offset_x, u32 *offset_y) const
static bool GetPackedMipOffset(u32 width, u32 height, const FormatInfo *format_info, u32 packed_tile, u32 *offset_x, u32 *offset_y)
u32 GetMaxMipLevels() const
const TextureExtent GetMipExtent(u32 mip, bool is_guest) const
u32 mip_address
Definition texture.h:389
u32 base_address
Definition texture.h:387
u32 offset_x
Definition texture.h:533
u32 output_pitch
Definition texture.h:538
u32 input_pitch
Definition texture.h:537
u32 width
Definition texture.h:535
u32 offset_y
Definition texture.h:534
u32 height
Definition texture.h:536
void 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)
void GetClampModesForDimension(const xenos::TextureFetch &fetch, xenos::ClampMode &clamp_x_out, xenos::ClampMode &clamp_y_out, xenos::ClampMode &clamp_z_out)
i32 GetTiledOffset3D(i32 x, i32 y, i32 z, u32 pitch, u32 height, u32 bytes_per_block_log2)
size_t GetTexelSize(xenos::TextureFormat format)
Definition texture.h:268
std::function< void(xenos::Endian, void *, const void *, size_t)> CopyBlockCallback
Definition texture.h:504
void ConvertTexelCTX1ToR8G8(xenos::Endian endian, void *output, const void *input, size_t output_pitch)
xenos::TextureFormat DepthRenderTargetToTextureFormat(xenos::DepthRenderTargetFormat depth_format)
Definition texture.h:308
GuestTextureLayout 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)
xenos::TextureFormat GetBaseFormat(xenos::TextureFormat texture_format)
Definition texture.h:234
u32 GetTiledAddressLowerBound2D(u32 left, u32 top, u32 pitch, u32 bytes_per_block_log2)
Definition texture.h:137
constexpr bool HasNonSignedComponent(u8 packed_signs)
Definition texture.h:200
i32 GetTiledOffset2D(i32 x, i32 y, u32 pitch, u32 bytes_per_block_log2)
FormatType
Definition texture.h:321
@ kUncompressed
Definition texture.h:323
@ kResolvable
Definition texture.h:322
xenos::TextureFormat ColorFormatToTextureFormat(xenos::ColorFormat color_format)
Definition texture.h:300
u32 GetTiledAddressUpperBound3D(u32 right, u32 bottom, u32 back, u32 pitch, u32 height, u32 bytes_per_block_log2)
void CopySwapBlock(xenos::Endian endian, void *output, const void *input, size_t length)
void ConvertTexelDXT3AToDXT3(xenos::Endian endian, void *output, const void *input, size_t length)
u32 GetPackedMipLevel(u32 width, u32 height)
Definition texture.h:50
bool GetPackedMipOffset(u32 width, u32 height, u32 depth, xenos::TextureFormat format, u32 mip, u32 &x_blocks, u32 &y_blocks, u32 &z_blocks)
u32 GetTiledAddressLowerBound3D(u32 left, u32 top, u32 front, u32 pitch, u32 height, u32 bytes_per_block_log2)
Definition texture.h:153
u8 SwizzleSigns(const xenos::TextureFetch &fetch)
u32 GetTiledAddressUpperBound2D(u32 right, u32 bottom, u32 pitch, u32 bytes_per_block_log2)
void Untile(u8 *output_buffer, const u8 *input_buffer, const UntileRegion *untile_info)
constexpr bool HasSignedComponent(u8 packed_signs)
Definition texture.h:209
Integer types, byte order wrappers and size literals.