[D3D12] 3D texture resolve
This commit is contained in:
@@ -204,13 +204,13 @@ void GetTextureTotalSize(Dimension dimension, uint32_t width, uint32_t height,
|
||||
}
|
||||
|
||||
int32_t GetTiledOffset2D(int32_t x, int32_t y, uint32_t width,
|
||||
uint32_t log2_bpb) {
|
||||
uint32_t bpb_log2) {
|
||||
// https://github.com/gildor2/UModel/blob/de8fbd3bc922427ea056b7340202dcdcc19ccff5/Unreal/UnTexture.cpp#L489
|
||||
width = xe::align(width, 32u);
|
||||
// Top bits of coordinates.
|
||||
int32_t macro = ((x >> 5) + (y >> 5) * (width >> 5)) << (log2_bpb + 7);
|
||||
int32_t macro = ((x >> 5) + (y >> 5) * (width >> 5)) << (bpb_log2 + 7);
|
||||
// Lower bits of coordinates (result is 6-bit value).
|
||||
int32_t micro = ((x & 7) + ((y & 0xE) << 2)) << log2_bpb;
|
||||
int32_t micro = ((x & 7) + ((y & 0xE) << 2)) << bpb_log2;
|
||||
// Mix micro/macro + add few remaining x/y bits.
|
||||
int32_t offset =
|
||||
macro + ((micro & ~0xF) << 1) + (micro & 0xF) + ((y & 1) << 4);
|
||||
@@ -219,6 +219,31 @@ int32_t GetTiledOffset2D(int32_t x, int32_t y, uint32_t width,
|
||||
(((((y & 8) >> 2) + (x >> 3)) & 3) << 6) + (offset & 0x3F);
|
||||
}
|
||||
|
||||
int32_t GetTiledOffset3D(int32_t x, int32_t y, int32_t z, uint32_t width,
|
||||
uint32_t height, uint32_t bpb_log2) {
|
||||
// Reconstructed from disassembly of XGRAPHICS::TileVolume.
|
||||
width = xe::align(width, 32u);
|
||||
height = xe::align(height, 32u);
|
||||
int32_t macro_outer = ((y >> 4) + (z >> 2) * (height >> 4)) * (width >> 5);
|
||||
int32_t macro = ((((x >> 5) + macro_outer) << (bpb_log2 + 6)) & 0xFFFFFFF)
|
||||
<< 1;
|
||||
int32_t micro = (((x & 7) + ((y & 6) << 2)) << (bpb_log2 + 6)) >> 6;
|
||||
int32_t offset_outer = ((y >> 3) + (z >> 2)) & 1;
|
||||
int32_t offset1 =
|
||||
offset_outer + ((((x >> 3) + (offset_outer << 1)) & 3) << 1);
|
||||
int32_t offset2 = ((macro + (micro & ~15)) << 1) + (micro & 15) +
|
||||
((z & 3) << (bpb_log2 + 6)) + ((y & 1) << 4);
|
||||
int32_t address = (offset1 & 1) << 3;
|
||||
address += (offset2 >> 6) & 7;
|
||||
address <<= 3;
|
||||
address += offset1 & ~1;
|
||||
address <<= 2;
|
||||
address += offset2 & ~511;
|
||||
address <<= 3;
|
||||
address += offset2 & 63;
|
||||
return address;
|
||||
}
|
||||
|
||||
} // namespace texture_util
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
Reference in New Issue
Block a user