diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 13:12:54 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 13:12:54 -0500 |
| commit | 407a53923e4ef32a10e95b1fb962018209cd0977 (patch) | |
| tree | 89db74ae407cb9c3af70c88f5fb7c4636fac03de /runtime/test/vk_harness.cpp | |
| parent | ff99084992d04f85a9fb9ca03c0e0b78b6f82f40 (diff) | |
| parent | 0ec464b0e11fb5c945cd7e9edba52d4cd330df7a (diff) | |
Merge pull request #2048 from whoalin1
# Conflicts:
# docs/testing.md
Diffstat (limited to 'runtime/test/vk_harness.cpp')
| -rw-r--r-- | runtime/test/vk_harness.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp index 417671f17..6dd5858f3 100644 --- a/runtime/test/vk_harness.cpp +++ b/runtime/test/vk_harness.cpp | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include "vulkan_loader.h" | 23 | #include "vulkan_loader.h" |
| 24 | #include "vk_device_pick.h" | 24 | #include "vk_device_pick.h" |
| 25 | #include "vk_shader_fma.h" | 25 | #include "vk_shader_fma.h" |
| 26 | #include "vk_pc_tail.h" | ||
| 26 | 27 | ||
| 27 | #include <cctype> | 28 | #include <cctype> |
| 28 | #include <cstddef> | 29 | #include <cstddef> |
| @@ -296,7 +297,16 @@ int main(int argc, char** argv) { | |||
| 296 | // fewer bytes (128, the Vulkan minimum, as on some Intel Arc drivers and AMD's Windows driver for RDNA2 iGPUs) | 297 | // fewer bytes (128, the Vulkan minimum, as on some Intel Arc drivers and AMD's Windows driver for RDNA2 iGPUs) |
| 297 | // cannot take that range: declaring it anyway is invalid, and there a shader reading past the limit crashed or | 298 | // cannot take that range: declaring it anyway is invalid, and there a shader reading past the limit crashed or |
| 298 | // hung the device. 77, as vk_texture_test and vk_bindless_test: a device limit, not a wrong result (D3D-14). | 299 | // hung the device. 77, as vk_texture_test and vk_bindless_test: a device limit, not a wrong result (D3D-14). |
| 299 | const uint32_t pc_bytes = mesh_compute ? 152u : 144u; | 300 | // LEONIDA_PC_TAIL_UBO=1 (rdna2spirv.py --pc-tail-ubo): s0..s31 only, 128 bytes, which every device has; the |
| 301 | // tail is a uniform block at set 1 (vk_pc_tail.h). tools/mesh_compute_vs.py's vertex shader still reads the | ||
| 302 | // --mesh-compute output address from push constants, so that combination isn't run. | ||
| 303 | const bool pc_tail = leonida::vk_test::pc_tail_requested(); | ||
| 304 | if (pc_tail && mesh_compute) { | ||
| 305 | std::fprintf(stderr, "unsupported: --mesh-compute's vertex shader reads the output address from push " | ||
| 306 | "constants, not from the --pc-tail-ubo block\n"); | ||
| 307 | return 77; | ||
| 308 | } | ||
| 309 | const uint32_t pc_bytes = pc_tail ? 128u : mesh_compute ? 152u : 144u; | ||
| 300 | if (props.limits.maxPushConstantsSize < pc_bytes) { | 310 | if (props.limits.maxPushConstantsSize < pc_bytes) { |
| 301 | std::fprintf(stderr, "unsupported: need %u push constant bytes, device has %u\n", pc_bytes, | 311 | std::fprintf(stderr, "unsupported: need %u push constant bytes, device has %u\n", pc_bytes, |
| 302 | props.limits.maxPushConstantsSize); | 312 | props.limits.maxPushConstantsSize); |
| @@ -472,8 +482,11 @@ int main(int argc, char** argv) { | |||
| 472 | VkFramebufferCreateInfo fbi{VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO}; | 482 | VkFramebufferCreateInfo fbi{VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO}; |
| 473 | fbi.renderPass = rp; fbi.attachmentCount = rpi.attachmentCount; fbi.pAttachments = views; fbi.width = W; fbi.height = H; fbi.layers = 1; | 483 | fbi.renderPass = rp; fbi.attachmentCount = rpi.attachmentCount; fbi.pAttachments = views; fbi.width = W; fbi.height = H; fbi.layers = 1; |
| 474 | VkFramebuffer fb; CHECK(vkCreateFramebuffer(dev, &fbi, nullptr, &fb)); | 484 | VkFramebuffer fb; CHECK(vkCreateFramebuffer(dev, &fbi, nullptr, &fb)); |
| 485 | bool tail_block = false; // some stage reads the --pc-tail-ubo block (declares set 1) | ||
| 475 | auto module = [&](const char* p, VkShaderModule* m) { | 486 | auto module = [&](const char* p, VkShaderModule* m) { |
| 476 | auto code = read_spv(p); | 487 | auto code = read_spv(p); |
| 488 | if (pc_tail && leonida::vk_test::spirv_declares_set(code.data(), code.size() * 4, leonida::vk_test::pc_tail_set)) | ||
| 489 | tail_block = true; | ||
| 477 | VkShaderModuleCreateInfo smi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; | 490 | VkShaderModuleCreateInfo smi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; |
| 478 | smi.codeSize = code.size() * 4; smi.pCode = code.data(); | 491 | smi.codeSize = code.size() * 4; smi.pCode = code.data(); |
| 479 | return vkCreateShaderModule(dev, &smi, nullptr, m); | 492 | return vkCreateShaderModule(dev, &smi, nullptr, m); |
| @@ -547,6 +560,14 @@ int main(int argc, char** argv) { | |||
| 547 | VkPushConstantRange pcr{pcs, 0, pc_bytes}; | 560 | VkPushConstantRange pcr{pcs, 0, pc_bytes}; |
| 548 | VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; | 561 | VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; |
| 549 | pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr; | 562 | pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr; |
| 563 | // --pc-tail-ubo: the tail block at set 1 (set 0 stays empty here), one slot for the one draw. | ||
| 564 | leonida::vk_test::PcTail tail; | ||
| 565 | if (tail_block && !tail.create(vkGetDeviceProcAddr, dev, mp, props.limits.minUniformBufferOffsetAlignment, pcs, 1)) { | ||
| 566 | std::fprintf(stderr, "FAILED creating the --pc-tail-ubo block\n"); | ||
| 567 | return 1; | ||
| 568 | } | ||
| 569 | const VkDescriptorSetLayout tail_layouts[] = {tail.empty_layout, tail.set_layout}; | ||
| 570 | if (tail_block) { pli.setLayoutCount = 2; pli.pSetLayouts = tail_layouts; } | ||
| 550 | VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl)); | 571 | VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl)); |
| 551 | VkGraphicsPipelineCreateInfo gpi{VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO}; | 572 | VkGraphicsPipelineCreateInfo gpi{VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO}; |
| 552 | gpi.stageCount = nstages; gpi.pStages = stages; | 573 | gpi.stageCount = nstages; gpi.pStages = stages; |
| @@ -708,6 +729,13 @@ int main(int argc, char** argv) { | |||
| 708 | } | 729 | } |
| 709 | vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe); | 730 | vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe); |
| 710 | push(cmd, pl, pcs, 0, pc_bytes, pc); | 731 | push(cmd, pl, pcs, 0, pc_bytes, pc); |
| 732 | if (tail_block) { | ||
| 733 | LOADD(vkCmdBindDescriptorSets); | ||
| 734 | tail.write(0, pc, 4); // heap base (VKH_HEAP) and code base, as pc[32..35] are without the flag | ||
| 735 | const uint32_t offset = tail.offset(0); | ||
| 736 | vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pl, leonida::vk_test::pc_tail_set, 1, &tail.set, | ||
| 737 | 1, &offset); | ||
| 738 | } | ||
| 711 | // VKH_VERTICES=<n>: draw n vertices instead of one triangle, so a vertex shader fills whole waves (TEST-251). | 739 | // VKH_VERTICES=<n>: draw n vertices instead of one triangle, so a vertex shader fills whole waves (TEST-251). |
| 712 | const char* vertices_env = std::getenv("VKH_VERTICES"); | 740 | const char* vertices_env = std::getenv("VKH_VERTICES"); |
| 713 | if (draw_mesh_path) { | 741 | if (draw_mesh_path) { |