diff options
| author | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 12:39:36 +0100 |
|---|---|---|
| committer | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 13:03:37 +0100 |
| commit | ce305ec6b3a0641cf7e02c3f43be34cede7192f9 (patch) | |
| tree | 69cee17452bbcce6db1476fc47cd62fc25a398ee /runtime/test/vk_harness.cpp | |
| parent | 99f99890c5ebe186ef2f9fe8ff6d675745d9e621 (diff) | |
Translator: wave64 VS/PS/GS on 32-wide subgroups when the halves can't tell (SHADER-10)
tools/wave64_halves.py classifies each wave64 VS/PS/GS by partition
invariance: A exact as translated, B exact by construction (waterfall loops,
wave-aggregated atomics up to slot order, readfirstlane/readlane of values
that are the same in every lane), C not exact (lane counts/ranks/ids,
readlane of varying data, stale scalars behind votes, masks as data, ...).
index.json gets wave64_graphics, wave64_graphics_reasons and
wave64_graphics_idioms; --wave64-graphics warn|error|off (error refuses
tier C). One rewrite: readlane of a proven-uniform VGPR reads the own copy.
--census prints tier counts from an index.json. ps_w64_* fixtures,
w64_graphics.py (fragment subgroup size required 64 vs 32) and semantic
tests; vk_harness gets VKH_HEAP_DUMP and a subgroup-size report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/vk_harness.cpp')
| -rw-r--r-- | runtime/test/vk_harness.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp index 107e595cc..f7f86fa51 100644 --- a/runtime/test/vk_harness.cpp +++ b/runtime/test/vk_harness.cpp | |||
| @@ -9,6 +9,11 @@ | |||
| 9 | // VKH_SGPRS=w0,w1,... sets s0, s1, ... (decimal or 0x hex) | 9 | // VKH_SGPRS=w0,w1,... sets s0, s1, ... (decimal or 0x hex) |
| 10 | // VKH_HEAP=addr=word,... allocates a zeroed 64 KiB heap (Xbox VA 0 = its device address), writes each word at | 10 | // VKH_HEAP=addr=word,... allocates a zeroed 64 KiB heap (Xbox VA 0 = its device address), writes each word at |
| 11 | // its address and passes the heap base, so a V# in VKH_SGPRS can point into it. | 11 | // its address and passes the heap base, so a V# in VKH_SGPRS can point into it. |
| 12 | // VKH_HEAP_DUMP=<file> after the draw, writes the 64 KiB heap (needs VKH_HEAP, which may be empty-valued as | ||
| 13 | // "0=0"), so a test can read what the pixel shader stored or atomically added. | ||
| 14 | // VKH_SUBGROUP_SIZE=32|64 requires that subgroup size of the fragment shader (or of the compute or geometry | ||
| 15 | // stage under test); stderr says "fragment subgroup size: N" when it took effect and | ||
| 16 | // "... not available" when the device cannot require it (exit code stays 0). | ||
| 12 | // | 17 | // |
| 13 | #define VK_NO_PROTOTYPES | 18 | #define VK_NO_PROTOTYPES |
| 14 | #include "vulkan_loader.h" | 19 | #include "vulkan_loader.h" |
| @@ -432,6 +437,9 @@ int main(int argc, char** argv) { | |||
| 432 | stages[2].pNext = &reqSg; | 437 | stages[2].pNext = &reqSg; |
| 433 | else if (!mesh && !gs_tested && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_FRAGMENT_BIT)) | 438 | else if (!mesh && !gs_tested && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_FRAGMENT_BIT)) |
| 434 | stages[1].pNext = &reqSg; | 439 | stages[1].pNext = &reqSg; |
| 440 | if (stages[1].pNext == &reqSg) std::fprintf(stderr, "fragment subgroup size: %u\n", req_sg); | ||
| 441 | } else if (req_sg > 0) { | ||
| 442 | std::fprintf(stderr, "fragment subgroup size: %u not available\n", req_sg); | ||
| 435 | } | 443 | } |
| 436 | VkPipelineVertexInputStateCreateInfo vin{VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; | 444 | VkPipelineVertexInputStateCreateInfo vin{VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; |
| 437 | VkPipelineInputAssemblyStateCreateInfo ia{VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; | 445 | VkPipelineInputAssemblyStateCreateInfo ia{VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; |
| @@ -494,6 +502,7 @@ int main(int argc, char** argv) { | |||
| 494 | bai.memoryTypeIndex = memtype(br.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); | 502 | bai.memoryTypeIndex = memtype(br.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 495 | VkDeviceMemory bmem; CHECK(vkAllocateMemory(dev, &bai, nullptr, &bmem)); | 503 | VkDeviceMemory bmem; CHECK(vkAllocateMemory(dev, &bai, nullptr, &bmem)); |
| 496 | CHECK(vkBindBufferMemory(dev, buf, bmem, 0)); | 504 | CHECK(vkBindBufferMemory(dev, buf, bmem, 0)); |
| 505 | void* heap_map = nullptr; | ||
| 497 | if (heap_env) { | 506 | if (heap_env) { |
| 498 | LOADD(vkGetBufferDeviceAddress); | 507 | LOADD(vkGetBufferDeviceAddress); |
| 499 | VkBufferCreateInfo hbi{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; | 508 | VkBufferCreateInfo hbi{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; |
| @@ -509,6 +518,7 @@ int main(int argc, char** argv) { | |||
| 509 | VkDeviceMemory hmem; CHECK(vkAllocateMemory(dev, &hai, nullptr, &hmem)); | 518 | VkDeviceMemory hmem; CHECK(vkAllocateMemory(dev, &hai, nullptr, &hmem)); |
| 510 | CHECK(vkBindBufferMemory(dev, heap, hmem, 0)); | 519 | CHECK(vkBindBufferMemory(dev, heap, hmem, 0)); |
| 511 | void* hp; CHECK(vkMapMemory(dev, hmem, 0, heap_bytes, 0, &hp)); | 520 | void* hp; CHECK(vkMapMemory(dev, hmem, 0, heap_bytes, 0, &hp)); |
| 521 | heap_map = hp; | ||
| 512 | std::memset(hp, 0, heap_bytes); | 522 | std::memset(hp, 0, heap_bytes); |
| 513 | for (auto [addr, word] : heap_words) std::memcpy(static_cast<char*>(hp) + addr, &word, 4); | 523 | for (auto [addr, word] : heap_words) std::memcpy(static_cast<char*>(hp) + addr, &word, 4); |
| 514 | VkBufferDeviceAddressInfo hda{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; | 524 | VkBufferDeviceAddressInfo hda{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; |
| @@ -599,6 +609,12 @@ int main(int argc, char** argv) { | |||
| 599 | output.write(static_cast<const char*>(p), std::streamsize(bi.size)); | 609 | output.write(static_cast<const char*>(p), std::streamsize(bi.size)); |
| 600 | output.close(); | 610 | output.close(); |
| 601 | if (!output) { std::fprintf(stderr, "failed to write %s\n", argv[3]); return 1; } | 611 | if (!output) { std::fprintf(stderr, "failed to write %s\n", argv[3]); return 1; } |
| 612 | if (const char* dump = std::getenv("VKH_HEAP_DUMP"); dump && *dump && heap_map) { | ||
| 613 | std::ofstream hf(dump, std::ios::binary); | ||
| 614 | hf.write(static_cast<const char*>(heap_map), heap_bytes); | ||
| 615 | hf.close(); | ||
| 616 | if (!hf) { std::fprintf(stderr, "failed to write %s\n", dump); return 1; } | ||
| 617 | } | ||
| 602 | std::fprintf(stderr, "ok %ux%u -> %s\n", W, H, argv[3]); | 618 | std::fprintf(stderr, "ok %ux%u -> %s\n", W, H, argv[3]); |
| 603 | return 0; | 619 | return 0; |
| 604 | } | 620 | } |