Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions gpu/vk/vk_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2200,11 +2200,10 @@ VkPipeline build_graphics(const Program& p, const NvnState& s, const Targets& at
// tables) hung the GPU when the driver's optimizer built them: a device lost one to four minutes into Kokiri, each time with
// another of them first (RX 6600, issues 461 and 484); never in runs where they were built without it. They are built
// without it on AMD. RX_VK_MESH_OPT=1: with it, as the others)
static const bool amd = [] {
VkPhysicalDeviceProperties pr{};
vkGetPhysicalDeviceProperties(dev.physical, &pr);
return pr.vendorID == 0x1002;
}();
// (hookshot) Not on Mesa's RADV: there the task programs built without it run long enough to reset the GPU while the
// save loads at the Great Deku Tree (Steam Deck OLED, RX 6800 XT; issue 1000). Built with it, that reset is gone; other
// RADV hangs remain (issue 1000).
static const bool amd = dev.props.vendorID == 0x1002 && dev.driver_id != VK_DRIVER_ID_MESA_RADV;
static const bool mesh_opt = env_on("RX_VK_MESH_OPT");
if (amd && !mesh_opt) {
bool mesh = false;
Expand Down
31 changes: 31 additions & 0 deletions tests/test_radv_mesh_optimizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Task and mesh programs keep the driver's optimizer on Mesa's RADV.

On AMD the task and mesh programs are built without the optimizer (PR 430: the RX 6600 losing the device in issues 461 and 484),
but on RADV the unoptimized task programs run long enough to reset the GPU while the save loads at the Great Deku Tree
(issue 1000). This checks that the rule leaves RADV out and that RX_VK_MESH_OPT=1 still turns the optimizer back on.

python -I -B tests/test_radv_mesh_optimizer.py
"""
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
DRAW = ROOT / "gpu" / "vk" / "vk_draw.cpp"


def main():
draw = DRAW.read_text(encoding="utf-8")
start = draw.index("static const bool amd =")
for needle, why in (
("dev.props.vendorID == 0x1002", "the rule is no longer limited to AMD"),
("dev.driver_id != VK_DRIVER_ID_MESA_RADV", "RADV builds task and mesh programs without the optimizer again"),
('"RX_VK_MESH_OPT"', "RX_VK_MESH_OPT=1 no longer builds them with the optimizer"),
("if (amd && !mesh_opt)", "the optimizer is not turned off by the AMD rule and its override"),
("VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT", "the rule no longer turns the optimizer off"),
):
if needle not in draw[start:draw.index("told++", start)]:
raise SystemExit(f"vk_draw.cpp: {why}")
print("RADV task and mesh programs with the optimizer ok")


if __name__ == "__main__":
main()