[GPU] Fix resolve destination offset and extent calculation

This commit is contained in:
Triang3l
2022-06-02 21:47:30 +03:00
parent a9a072bf00
commit 84fcd5defa
30 changed files with 27014 additions and 27627 deletions

View File

@@ -286,6 +286,37 @@ int32_t GetTiledOffset2D(int32_t x, int32_t y, uint32_t pitch,
uint32_t bytes_per_block_log2);
int32_t GetTiledOffset3D(int32_t x, int32_t y, int32_t z, uint32_t pitch,
uint32_t height, uint32_t bytes_per_block_log2);
// Because (0, 0, 0) within each 32x32x4-block tile is stored in memory first,
// and the tiled address grows monotonically with Z/4, then Y/32, then X/32
// blocks.
inline uint32_t GetTiledAddressLowerBound2D(uint32_t left, uint32_t top,
uint32_t pitch,
uint32_t bytes_per_block_log2) {
return uint32_t(
GetTiledOffset2D(int32_t(left & ~(xenos::kTextureTileWidthHeight - 1)),
int32_t(top & ~(xenos::kTextureTileWidthHeight - 1)),
pitch, bytes_per_block_log2));
}
inline uint32_t GetTiledAddressLowerBound3D(uint32_t left, uint32_t top,
uint32_t front, uint32_t pitch,
uint32_t height,
uint32_t bytes_per_block_log2) {
return uint32_t(
GetTiledOffset3D(int32_t(left & ~(xenos::kTextureTileWidthHeight - 1)),
int32_t(top & ~(xenos::kTextureTileWidthHeight - 1)),
int32_t(front & ~(xenos::kTextureTileDepth)), pitch,
height, bytes_per_block_log2));
}
// Supporting the right > pitch and bottom > height (in tiles) cases also, for
// estimation how far addresses can actually go even potentially beyond the
// subresource stride.
uint32_t GetTiledAddressUpperBound2D(uint32_t right, uint32_t bottom,
uint32_t pitch,
uint32_t bytes_per_block_log2);
uint32_t GetTiledAddressUpperBound3D(uint32_t right, uint32_t bottom,
uint32_t back, uint32_t pitch,
uint32_t height,
uint32_t bytes_per_block_log2);
// Returns four packed TextureSign values swizzled according to the swizzle in
// the fetch constant, so the shader can apply TextureSigns after reading a