graphics: cleanup

This commit is contained in:
nmzik committed 2026-07-23 23:21:26 +02:00
1 parent 7638c25d76
commit a720b28b7f
25 files changed
+422 -342

No files matched your search

@@ -120,11 +120,7 @@ public:
void SetUserDataMarker(HW::UserSgprType type) { m_user_data_marker = type; }
[[nodiscard]] HW::UserSgprType GetUserDataMarker() const { return m_user_data_marker; }
void SetEmbeddedDataMarker(const uint32_t* buffer, uint32_t num_dw, uint32_t align) {}
void PushMarker(const char* str) {}
void PopMarker() {}
void PrefetchL2(void* addr, uint32_t size) {}
void ResetDeCe();
void SetCeComplete(bool complete) { m_ce_complete = complete; }
void WaitCe();
@@ -2249,9 +2249,6 @@ KYTY_CP_OP_PARSER(CpOpDmaData) {
const uint64_t dst = buffer[3] | (static_cast<uint64_t>(buffer[4]) << 32u);
if (control == 0x60000000 && dst == 0x0003022c && (control2 >> 21u) == 0x141u) {
auto* addr = reinterpret_cast<void*>(src);
cp.PrefetchL2(addr, control2 & 0x1fffffu);
return 6;
}
@@ -2799,11 +2796,10 @@ KYTY_CP_OP_PARSER(CpOpMarker) {
// EXIT_NOT_IMPLEMENTED(cmd_id != 0xC0001000);
uint32_t id = buffer[0] & 0xfffu;
uint32_t align = (buffer[0] >> 12u) & 0xfu;
uint32_t len_dw = ((cmd_id >> 16u) & 0x3fffu);
switch (id) {
case 0x0: cp.SetEmbeddedDataMarker(buffer + 1, len_dw, align); break;
case 0x0: break;
case 0x4: cp.SetUserDataMarker(HW::UserSgprType::Vsharp); break;
case 0xd: cp.SetUserDataMarker(HW::UserSgprType::Region); break;
case 0x777: {
@@ -2875,8 +2871,6 @@ KYTY_CP_OP_PARSER(CpOpPopMarker) {
LOGF("Pop marker\n");
}
cp.PopMarker();
return dw_num + 1;
}
@@ -2892,8 +2886,6 @@ KYTY_CP_OP_PARSER(CpOpPushMarker) {
LOGF("Push marker: %s\n", str);
}
cp.PushMarker(str);
return dw_num + 1;
}
-4
View File
@@ -1538,10 +1538,6 @@ void GraphicsRunSubmitFlipPreparation() {
g_gpu->SubmitFlipPreparation();
}
void GraphicsRunWait() {
GraphicsRunSubmissionLock lock;
}
GraphicsRunSubmissionLock::GraphicsRunSubmissionLock() {
if (g_gpu == nullptr || g_current_processor != nullptr ||
g_submission_pause_depth == UINT32_MAX) {
-1
View File
@@ -22,7 +22,6 @@ void GraphicsRunSubmit(uint32_t* cmd_draw_buffer, uint32_t num_draw_dw, uint32_t
void GraphicsRunSubmitCompute(uint32_t queue, uint32_t* cmd_buffer, uint32_t num_dw,
bool trigger_agc_interrupt_on_done = false);
void GraphicsRunSubmitFlipPreparation();
void GraphicsRunWait();
void GraphicsRunDone();
int GraphicsRunGetFrameNum();
[[nodiscard]] bool GraphicsRunIsCommandProcessorThread() noexcept;
+58 -36
View File
@@ -406,8 +406,8 @@ struct TextureBlockLayout {
static bool GetTextureBlockLayout(uint32_t format, uint32_t tile, TextureBlockLayout& out) {
uint32_t width_log2 = 0, height_log2 = 0;
if (tile == 1 && Gen5Standard256BLayout(format, &out.bytes, &out.texel_width,
&out.texel_height, &width_log2, &height_log2)) {
if (tile == 1 && Gen5Standard256BLayout(format, &out.bytes, &out.texel_width, &out.texel_height,
&width_log2, &height_log2)) {
out.block_size = 256;
} else if (tile == 5 && Gen5Standard4KBLayout(format, &out.bytes, &out.texel_width,
&out.texel_height, &width_log2, &height_log2)) {
@@ -524,7 +524,7 @@ static void SetMacroMipLayout(const TextureBlockLayout& block, uint32_t tile, ui
}
bool TileGetTextureVolumeLayout(uint32_t format, uint32_t width, uint32_t height, uint32_t depth,
uint32_t levels, uint32_t tile, TileVolumeLayout& out) {
uint32_t levels, uint32_t tile, TileVolumeLayout& out) {
if (width == 0 || height == 0 || depth == 0 || levels == 0 || levels > 16) {
return false;
}
@@ -543,21 +543,26 @@ bool TileGetTextureVolumeLayout(uint32_t format, uint32_t width, uint32_t height
TileBlockLayout block {};
if (!TileGetBlockLayout(family, element.bytes, block)) return false;
out = {};
out.family = family;
out.bytes_per_element = element.bytes;
out.texel_width = element.texel_width;
out.texel_height = element.texel_height;
out.block_depth = block.block_depth;
out.first_tail_level = levels;
out = {};
out.family = family;
out.bytes_per_element = element.bytes;
out.texel_width = element.texel_width;
out.texel_height = element.texel_height;
out.block_depth = block.block_depth;
out.first_tail_level = levels;
const uint32_t width0 = (width + element.texel_width - 1u) / element.texel_width;
const uint32_t height0 = (height + element.texel_height - 1u) / element.texel_height;
const bool thick4 = family == TileBlockFamily::Standard4KB3D;
const bool thick64 =
family == TileBlockFamily::Standard64KB3D || family == TileBlockFamily::Prt64KB3D;
const uint32_t max_tail = thick4 ? 5u : (thick64 ? 10u : 12u);
uint32_t tail_width = thick4 ? block.block_width : block.block_width >> 1u;
uint32_t tail_height = thick4 ? block.block_height >> 1u : block.block_height;
uint32_t max_tail = 12u;
if (thick4) {
max_tail = 5u;
} else if (thick64) {
max_tail = 10u;
}
uint32_t tail_width = thick4 ? block.block_width : block.block_width >> 1u;
uint32_t tail_height = thick4 ? block.block_height >> 1u : block.block_height;
if (family == TileBlockFamily::Depth64KB && element.bytes < 4) {
tail_width = 64;
tail_height = 128;
@@ -574,18 +579,23 @@ bool TileGetTextureVolumeLayout(uint32_t format, uint32_t width, uint32_t height
}
out.level_widths[level] = AlignUp(mip_width, block.block_width);
out.level_heights[level] = AlignUp(mip_height, block.block_height);
out.level_sizes[level] = static_cast<uint64_t>(block.block_depth) *
out.level_widths[level] * out.level_heights[level] *
element.bytes;
out.level_sizes[level] = static_cast<uint64_t>(block.block_depth) *
out.level_widths[level] * out.level_heights[level] * element.bytes;
out.block_slice_size += out.level_sizes[level];
}
const auto bytes_log2 = std::countr_zero(element.bytes);
const auto bytes_log2 = std::countr_zero(element.bytes);
const Gen5MipTailLocation* tail_locations = nullptr;
if (thick4) {
tail_locations = GEN5_MIP_TAIL_LOCATIONS_THICK_4KB[bytes_log2];
} else if (thick64) {
tail_locations = GEN5_MIP_TAIL_LOCATIONS_THICK_64KB[bytes_log2];
} else {
tail_locations = GEN5_MIP_TAIL_LOCATIONS_THIN_64KB[bytes_log2];
}
for (uint32_t level = out.first_tail_level; level < levels; ++level) {
const auto index = level - out.first_tail_level;
const auto tail = thick4 ? GEN5_MIP_TAIL_LOCATIONS_THICK_4KB[bytes_log2][index]
: (thick64 ? GEN5_MIP_TAIL_LOCATIONS_THICK_64KB[bytes_log2][index]
: GEN5_MIP_TAIL_LOCATIONS_THIN_64KB[bytes_log2][index]);
const auto index = level - out.first_tail_level;
const auto tail = tail_locations[index];
out.level_sizes[level] = block.block_size;
out.level_widths[level] = block.block_width;
out.level_heights[level] = block.block_height;
@@ -1047,7 +1057,7 @@ static constexpr uint32_t Depth64KB64XOffsetBytes(uint32_t x);
static constexpr uint32_t Depth64KB64YOffsetBytes(uint32_t y);
bool TileGetBlockLayout(TileBlockFamily family, uint32_t bytes_per_element,
TileBlockLayout& layout) {
TileBlockLayout& layout) {
if (!std::has_single_bit(bytes_per_element) || bytes_per_element > 16) {
return false;
}
@@ -1067,13 +1077,25 @@ bool TileGetBlockLayout(TileBlockFamily family, uint32_t bytes_per_element,
};
switch (family) {
case TileBlockFamily::Standard256B:
result.block_size = 256;
result.block_width = bytes_per_element <= 2 ? 16 : (bytes_per_element <= 8 ? 8 : 4);
result.block_size = 256;
if (bytes_per_element <= 2) {
result.block_width = 16;
} else if (bytes_per_element <= 8) {
result.block_width = 8;
} else {
result.block_width = 4;
}
result.block_height = result.block_size / (result.block_width * bytes_per_element);
break;
case TileBlockFamily::Standard4KB:
result.block_size = 4096;
result.block_width = bytes_per_element <= 2 ? 64 : (bytes_per_element <= 8 ? 32 : 16);
result.block_size = 4096;
if (bytes_per_element <= 2) {
result.block_width = 64;
} else if (bytes_per_element <= 8) {
result.block_width = 32;
} else {
result.block_width = 16;
}
result.block_height = result.block_size / (result.block_width * bytes_per_element);
break;
case TileBlockFamily::Standard4KB3D: {
@@ -1126,7 +1148,7 @@ bool TileGetBlockLayout(TileBlockFamily family, uint32_t bytes_per_element,
}
bool TileGetBlockOffset(const TileBlockLayout& layout, uint32_t x, uint32_t y, uint32_t z,
uint32_t& byte_offset) {
uint32_t& byte_offset) {
TileBlockLayout expected {};
if (!TileGetBlockLayout(layout.family, layout.bytes_per_element, expected) ||
layout.block_size != expected.block_size || layout.block_width != expected.block_width ||
@@ -1226,12 +1248,12 @@ bool TileGetBlockOffset(const TileBlockLayout& layout, uint32_t x, uint32_t y, u
}
bool TileGetBlockXor(const TileBlockLayout& layout, uint32_t block_x, uint32_t block_y,
uint32_t& byte_offset) {
uint32_t& byte_offset) {
return TileGetBlockXor(layout, block_x, block_y, 0, byte_offset);
}
bool TileGetBlockXor(const TileBlockLayout& layout, uint32_t block_x, uint32_t block_y,
uint32_t block_z, uint32_t& byte_offset) {
uint32_t block_z, uint32_t& byte_offset) {
TileBlockLayout expected {};
if (!TileGetBlockLayout(layout.family, layout.bytes_per_element, expected) ||
layout.block_size != expected.block_size || layout.block_width != expected.block_width ||
@@ -1377,8 +1399,8 @@ bool TileGetHtileSize(uint32_t width, uint32_t height, TileSizeAlign& htile_size
}
bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t z_format,
uint32_t stencil_format, bool htile, TileSizeAlign& stencil_size,
TileSizeAlign& htile_size, TileSizeAlign& depth_size,
uint32_t stencil_format, bool htile, TileSizeAlign& stencil_size,
TileSizeAlign& htile_size, TileSizeAlign& depth_size,
uint32_t num_fragments_log2) {
EXIT_IF(pitch != 0);
// Prospero derives uncompressed depth/stencil as independent 64 KiB block surfaces.
@@ -1410,8 +1432,8 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t
if (depth_bytes_total <= UINT32_MAX && stencil_bytes_total <= UINT32_MAX && htile_valid) {
depth_size = {static_cast<uint32_t>(depth_bytes_total), 65536};
stencil_size = stencil_format == 1
? TileSizeAlign {static_cast<uint32_t>(stencil_bytes_total), 65536}
: TileSizeAlign {};
? TileSizeAlign {static_cast<uint32_t>(stencil_bytes_total), 65536}
: TileSizeAlign {};
htile_size = calculated_htile;
return true;
}
@@ -1441,7 +1463,7 @@ uint32_t TileGetDepthPitch(uint32_t width, uint32_t bytes_per_element,
}
bool TileGetRenderTargetSize(uint32_t width, uint32_t height, uint32_t pitch,
uint32_t bytes_per_element, TileSizeAlign& total_size,
uint32_t bytes_per_element, TileSizeAlign& total_size,
uint32_t num_fragments_log2) {
total_size = {};
uint32_t block_width = 0;
@@ -1466,7 +1488,7 @@ bool TileGetRenderTargetSize(uint32_t width, uint32_t height, uint32_t pitch,
bool TileGetRenderTargetMipLayout(uint32_t width, uint32_t height, uint32_t pitch,
uint32_t bytes_per_element, uint32_t levels,
TileSizeAlign& total_size, TileSizeOffset* level_sizes,
TileSizeAlign& total_size, TileSizeOffset* level_sizes,
TilePaddedSize* padded_size) {
total_size = {};
if (width == 0 || height == 0 || levels == 0 || levels > 16 ||
@@ -1578,7 +1600,7 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
void TileGetTextureTotalSize(uint32_t format, uint32_t width, uint32_t height, uint32_t depth,
uint32_t pitch, uint32_t levels, uint32_t tile, bool volume_texture,
TileSizeAlign& total_size) {
TileSizeAlign& total_size) {
EXIT_NOT_IMPLEMENTED(depth == 0);
if (volume_texture) {
TileVolumeLayout volume {};