format source files

This commit is contained in:
nmzik committed 2026-07-18 09:01:52 +02:00
1 parent 6c1bd853ac
commit 601c82a031
53 files changed
+1622 -1573

No files matched your search

+41 -43
View File
@@ -299,8 +299,7 @@ static bool Gen5Standard64KBLayout(uint32_t format, uint32_t* bytes_per_element,
}
}
static bool Gen5Thin64KBBlockSizeFromElementBytes(uint32_t bytes_per_element,
uint32_t* block_width,
static bool Gen5Thin64KBBlockSizeFromElementBytes(uint32_t bytes_per_element, uint32_t* block_width,
uint32_t* block_height) {
// AGC thin 64 KiB block table, shared by depth and render-target tiles.
switch (bytes_per_element) {
@@ -1181,8 +1180,8 @@ static void ConvertRenderTargetTyped(uint32_t width, uint32_t height, uint32_t p
uint32_t block_width = 0;
uint32_t block_height = 0;
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
static_cast<uint32_t>(sizeof(T)), &block_width, &block_height));
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(static_cast<uint32_t>(sizeof(T)),
&block_width, &block_height));
const uint64_t blocks_per_row = (static_cast<uint64_t>(pitch) + block_width - 1u) / block_width;
const uint32_t block_columns = (width == 0 ? 0 : 1u + (width - 1u) / block_width);
@@ -1487,9 +1486,9 @@ void TileConvertLinearToTiledStandard64KB32(void* dst, const void* src, uint32_t
dst, src, width, height, pitch, size);
}
auto* dst32 = static_cast<uint32_t*>(dst);
const auto* src32 = static_cast<const uint32_t*>(src);
const auto& tables = GetStandard64KB32Tables();
auto* dst32 = static_cast<uint32_t*>(dst);
const auto* src32 = static_cast<const uint32_t*>(src);
const auto& tables = GetStandard64KB32Tables();
const auto blocks_per_row = (static_cast<uint64_t>(pitch) + 127u) >> 7u;
const auto block_rows = (static_cast<uint64_t>(height) + 127u) >> 7u;
if (blocks_per_row > UINT64_MAX / block_rows / 65536u ||
@@ -1800,10 +1799,10 @@ static void TileConvertLinearToTiledStandard64KB64Elements(
"size=0x%016" PRIx64 " dst_size=0x%016" PRIx64 " dst=%u,%u\n",
width_elements, height_elements, pitch_elements, size, dst_size, dst_x, dst_y);
}
auto* dst64 = static_cast<uint64_t*>(dst);
const auto* src64 = static_cast<const uint64_t*>(src);
const auto& tables = GetStandard64KB64Tables();
const auto size_words = size >> 3u;
auto* dst64 = static_cast<uint64_t*>(dst);
const auto* src64 = static_cast<const uint64_t*>(src);
const auto& tables = GetStandard64KB64Tables();
const auto size_words = size >> 3u;
const auto dst_size_words = dst_size >> 3u;
for (uint32_t y = 0; y < height_elements; y++) {
const uint64_t src_row = static_cast<uint64_t>(y) * pitch_elements;
@@ -2222,14 +2221,12 @@ static void TileConvertDepth(void* dst, const void* src, uint32_t format, uint32
const uint32_t block_width = supported_bpe && bytes_per_element <= 2 ? 256u : 128u;
const uint32_t block_height = supported_bpe ? 65536u / (block_width * bytes_per_element) : 0;
if (dst == nullptr || src == nullptr || width == 0 || height == 0 || pitch < width ||
!supported_bpe || pitch % block_width != 0 ||
size == 0 || size % 65536u != 0) {
!supported_bpe || pitch % block_width != 0 || size == 0 || size % 65536u != 0) {
EXIT("unsupported depth conversion, dst=%p src=%p format=%u "
"extent=%ux%u pitch=%u size=0x%016" PRIx64 "\n",
dst, src, format, width, height, pitch, size);
}
const uint64_t block_rows =
(static_cast<uint64_t>(height) + block_height - 1u) / block_height;
const uint64_t block_rows = (static_cast<uint64_t>(height) + block_height - 1u) / block_height;
const uint64_t blocks_per_row = pitch / block_width;
if (blocks_per_row > UINT64_MAX / block_rows ||
blocks_per_row * block_rows > UINT64_MAX / 65536u ||
@@ -2504,13 +2501,13 @@ void TileConvertLinearToTiledRenderTarget(void* dst, const void* src, uint32_t w
KYTY_PROFILER_FUNCTION();
const bool tail_block = dst_size != 0 && (dst_x != 0 || dst_y != 0 || size < dst_size);
if (tail_block) {
//Not sure about this at all
// Not sure about this at all
if (bytes_per_element != 8) {
EXIT("unsupported linear-to-tiled render-target tail element size: %u\n",
bytes_per_element);
}
TileConvertLinearToTiledStandard64KB64Elements(dst, src, width, height, pitch, size,
dst_size, dst_x, dst_y);
dst_size, dst_x, dst_y);
return;
}
@@ -2596,8 +2593,8 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t
uint32_t TileGetRenderTargetPitch(uint32_t width, uint32_t bytes_per_element) {
uint32_t block_width = 0;
uint32_t block_height = 0;
if (width == 0 || !Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width,
&block_height)) {
if (width == 0 ||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height)) {
return 0;
}
const uint64_t pitch = (static_cast<uint64_t>(width) + block_width - 1u) &
@@ -2611,8 +2608,7 @@ bool TileGetRenderTargetSize(uint32_t width, uint32_t height, uint32_t pitch,
uint32_t block_width = 0;
uint32_t block_height = 0;
if (height == 0 || pitch == 0 ||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width,
&block_height) ||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height) ||
pitch != TileGetRenderTargetPitch(width, bytes_per_element)) {
return false;
}
@@ -2655,8 +2651,8 @@ bool TileGetRenderTargetMipLayout(uint32_t width, uint32_t height, uint32_t pitc
default: return false;
}
TileGetTextureSize(format, width, height, pitch, levels,
Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), total_size, level_sizes,
padded_size);
Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), total_size,
level_sizes, padded_size);
return total_size->size != 0 && total_size->align == 65536;
}
@@ -2738,8 +2734,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
bytes_per_element != 0 && tile == 27 && levels == 1) {
uint32_t block_width = 0;
uint32_t block_height = 0;
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height));
EXIT_NOT_IMPLEMENTED(
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height));
const uint32_t padded_width = AlignUp(pitch, block_width);
const uint32_t padded_height = AlignUp(height, block_height);
@@ -2767,8 +2763,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
bytes_per_element != 0 && tile == 27 && levels > 1) {
uint32_t block_width = 0;
uint32_t block_height = 0;
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height));
EXIT_NOT_IMPLEMENTED(
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height));
const uint32_t bytes_log2 = IntLog2(bytes_per_element);
const uint32_t tail_width_limit = block_width >> 1u;
@@ -2990,11 +2986,11 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
if (tile == 24 && levels == 1) {
const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
if (bytes_per_element != 0) {
uint32_t block_width = 0;
uint32_t block_height = 0;
const bool supported = bytes_per_element <= 4 &&
Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height);
uint32_t block_width = 0;
uint32_t block_height = 0;
const bool supported =
bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height);
if (supported) {
const uint32_t padded_width = (pitch + block_width - 1u) & ~(block_width - 1u);
@@ -3024,11 +3020,11 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
if (tile == 24 && levels > 1) {
const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
if (bytes_per_element != 0) {
uint32_t block_width = 0;
uint32_t block_height = 0;
const bool supported = bytes_per_element <= 4 &&
Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height);
uint32_t block_width = 0;
uint32_t block_height = 0;
const bool supported =
bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height);
if (supported) {
static bool logged = false;
@@ -3271,7 +3267,8 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
uint32_t pitch = width;
if (tile == 27) {
if (const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format); bytes_per_element != 0) {
if (const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
bytes_per_element != 0) {
uint32_t block_width = 0;
uint32_t block_height = 0;
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
@@ -3281,7 +3278,8 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
}
if (tile == 0) {
if (const auto bytes_per_element = Prospero::NumBytesPerElement(format); bytes_per_element != 0) {
if (const auto bytes_per_element = Prospero::NumBytesPerElement(format);
bytes_per_element != 0) {
pitch = AlignUp(pitch * bytes_per_element, 256u) / bytes_per_element;
}
}
@@ -3297,10 +3295,10 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
}
if (tile == 24) {
const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
uint32_t block_width = 0;
uint32_t block_height = 0;
if (bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
bytes_per_element, &block_width, &block_height)) {
uint32_t block_width = 0;
uint32_t block_height = 0;
if (bytes_per_element <= 4 &&
Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height)) {
pitch = AlignUp(pitch, block_width);
}
}