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:
authorCLHelper <359823989+CLHelper@users.noreply.github.com>2026-11-22 14:44:30 +0000
committerCLHelper <359823989+CLHelper@users.noreply.github.com>2026-11-22 14:44:30 +0000
commit4a20110919dd671d4e5b40f2dafd3377239305da (patch)
treedc7542659b68a4466e737b375cf61245cf244eec /runtime/test/vk_harness.cpp
parent003e78129303643a3fdc9e5f0e31a01b09759236 (diff)
GPU tests: vk_harness skips a device with fewer push-constant bytes than it pushes
vk_harness declared a 144-byte push-constant range (152 with --mesh-compute) without checking maxPushConstantsSize. On a device with 128 bytes, the Vulkan minimum, that is invalid (VUID-VkPushConstantRange-size-00298), and on an AMD Radeon 610M on AMD's Windows driver ms_clip crashed (0xC0000005) and ms_w64x_ballot under LEONIDA_W64_EMULATE=1 hung until the runner's timeout. It now checks the limit once, right after it knows whether it runs a --mesh-compute module, and exits 77 with "unsupported: need N push constant bytes, device has M", as vk_texture_test (#862) and vk_bindless_test/vk_image_fuzz (#1113) already do. The range and the pushes use the same pc_bytes.
Diffstat (limited to 'runtime/test/vk_harness.cpp')
-rw-r--r--runtime/test/vk_harness.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp
index f7f86fa51..0244c2c76 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);