upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/vk_harness.cpp
diff options
context:
space:
mode:
authorIAmNotSiob <273832158+IAmNotSiob@users.noreply.github.com>2026-11-22 17:31:21 +0100
committerIAmNotSiob <273832158+IAmNotSiob@users.noreply.github.com>2026-11-22 17:31:21 +0100
commit9b99a5f030cfd6c8bf96f0af2002dc939aa13b5b (patch)
tree3d2d0bfd501a978d00a12f755c8e5bc6eee12f32 /runtime/test/vk_harness.cpp
parentfaa42a61c5ffb24fe4046a5336102bba996872e7 (diff)
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
Merge remote-tracking branch 'origin/main' into d3d12-queues-v2
# Conflicts: # runtime/test/vk_test_device.h
Diffstat (limited to 'runtime/test/vk_harness.cpp')
-rw-r--r--runtime/test/vk_harness.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp
index f7f86fa51..360a20fa7 100644
--- a/runtime/test/vk_harness.cpp
+++ b/runtime/test/vk_harness.cpp
@@ -240,6 +240,17 @@ int main(int argc, char** argv) {
240 return 2; 240 return 2;
241 } 241 }
242 } 242 }
243 // Translated shaders declare a 144-byte push-constant block (user SGPRs, heap base, code base; see VKH_SGPRS /
244 // VKH_HEAP); --mesh-compute modules and their vertex shaders add the output address (152 bytes). A device with
245 // fewer bytes (128, the Vulkan minimum, as on some Intel Arc drivers and AMD's Windows driver for RDNA2 iGPUs)
246 // cannot take that range: declaring it anyway is invalid, and there a shader reading past the limit crashed or
247 // hung the device. 77, as vk_texture_test and vk_bindless_test: a device limit, not a wrong result (D3D-14).
248 const uint32_t pc_bytes = mesh_compute ? 152u : 144u;
249 if (props.limits.maxPushConstantsSize < pc_bytes) {
250 std::fprintf(stderr, "unsupported: need %u push constant bytes, device has %u\n", pc_bytes,
251 props.limits.maxPushConstantsSize);
252 return 77;
253 }
243 // VKH_MESH=1: the first shader is a mesh shader (VK_EXT_mesh_shader), drawn with vkCmdDrawMeshTasksEXT(1,1,1). 254 // VKH_MESH=1: the first shader is a mesh shader (VK_EXT_mesh_shader), drawn with vkCmdDrawMeshTasksEXT(1,1,1).
244 const bool mesh = !mesh_compute && (group_readback || std::getenv("VKH_MESH") != nullptr); 255 const bool mesh = !mesh_compute && (group_readback || std::getenv("VKH_MESH") != nullptr);
245 VkPhysicalDeviceMeshShaderFeaturesEXT meshf{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT}; 256 VkPhysicalDeviceMeshShaderFeaturesEXT meshf{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT};
@@ -454,12 +465,11 @@ int main(int argc, char** argv) {
454 VkPipelineColorBlendAttachmentState cba{}; cba.colorWriteMask = 0xF; 465 VkPipelineColorBlendAttachmentState cba{}; cba.colorWriteMask = 0xF;
455 VkPipelineColorBlendStateCreateInfo cb{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; 466 VkPipelineColorBlendStateCreateInfo cb{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO};
456 cb.attachmentCount = 1; cb.pAttachments = &cba; 467 cb.attachmentCount = 1; cb.pAttachments = &cba;
457 // Translated shaders declare a 144-byte push-constant block (user SGPRs, heap base, code base; see VKH_SGPRS / 468 // The push-constant block (pc_bytes, checked against the device limit above).
458 // VKH_HEAP); --mesh-compute modules and their vertex shaders add the output address (152 bytes).
459 const VkShaderStageFlags pcs = (mesh ? VK_SHADER_STAGE_MESH_BIT_EXT : VK_SHADER_STAGE_VERTEX_BIT) | 469 const VkShaderStageFlags pcs = (mesh ? VK_SHADER_STAGE_MESH_BIT_EXT : VK_SHADER_STAGE_VERTEX_BIT) |
460 VK_SHADER_STAGE_FRAGMENT_BIT | (gs_path ? VK_SHADER_STAGE_GEOMETRY_BIT : 0) | 470 VK_SHADER_STAGE_FRAGMENT_BIT | (gs_path ? VK_SHADER_STAGE_GEOMETRY_BIT : 0) |
461 (mesh_compute ? VK_SHADER_STAGE_COMPUTE_BIT : 0); 471 (mesh_compute ? VK_SHADER_STAGE_COMPUTE_BIT : 0);
462 VkPushConstantRange pcr{pcs, 0, mesh_compute ? 152u : 144u}; 472 VkPushConstantRange pcr{pcs, 0, pc_bytes};
463 VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; 473 VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
464 pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr; 474 pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr;
465 VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl)); 475 VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl));
@@ -564,7 +574,6 @@ int main(int argc, char** argv) {
564 std::memcpy(pc, shifts, sizeof(shifts)); 574 std::memcpy(pc, shifts, sizeof(shifts));
565 } 575 }
566 auto push = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetDeviceProcAddr(dev, "vkCmdPushConstants")); 576 auto push = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetDeviceProcAddr(dev, "vkCmdPushConstants"));
567 const uint32_t pc_bytes = mesh_compute ? 152u : 144u;
568 if (mesh_compute) { 577 if (mesh_compute) {
569 // The mesh shader as compute, then make its stores visible to the vertex shader's reads. 578 // The mesh shader as compute, then make its stores visible to the vertex shader's reads.
570 LOADD(vkCmdDispatch); LOADD(vkCmdPipelineBarrier); 579 LOADD(vkCmdDispatch); LOADD(vkCmdPipelineBarrier);
@@ -591,7 +600,11 @@ int main(int argc, char** argv) {
591 } 600 }
592 vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe); 601 vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe);
593 push(cmd, pl, pcs, 0, pc_bytes, pc); 602 push(cmd, pl, pcs, 0, pc_bytes, pc);
594 if (mesh_compute) 603 // VKH_VERTICES=<n>: draw n vertices instead of one triangle, so a vertex shader fills whole waves (TEST-251).
604 const char* vertices_env = std::getenv("VKH_VERTICES");
605 if (const unsigned vertices = vertices_env ? unsigned(std::strtoul(vertices_env, nullptr, 10)) : 0; vertices && !mesh)
606 vkCmdDraw(cmd, vertices, 1, 0, 0);
607 else if (mesh_compute)
595 vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0); 608 vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0);
596 else if (mesh) 609 else if (mesh)
597 reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]); 610 reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]);