diff options
| author | S1m0ne1997 <347981799+S1m0ne1997@users.noreply.github.com> | 2026-11-22 00:51:57 +0100 |
|---|---|---|
| committer | S1m0ne1997 <347981799+S1m0ne1997@users.noreply.github.com> | 2026-11-22 11:59:04 +0100 |
| commit | 07bd05fa95c2c47be1d1f0b671fb5e484b23a904 (patch) | |
| tree | 0021b22b12f60c13dc7ee98e247cbcdea7bd7101 /runtime/test/vk_harness.cpp | |
| parent | c2967a5e60060e4068fb992196d8f4b494a5046c (diff) | |
Translator: zero-based VS v0/v3 (VertexIndex - BaseVertex, InstanceIndex - BaseInstance); VS is legacy, not NGG (SHADER-33)
Corpus (scripts/vs_input_survey.py, all 2,236 VS): no exp prim, no s_sendmsg, no v_mbcnt, every
VS exports pos0/param, so the console runs them as legacy hardware VS. Their input VGPRs are
Mesa's GFX10 legacy layout (radv_shader_args.c, declare_vs_input_vgprs, not is_ngg): v0 vertex
id, v1 unused, v2 primitive id, v3 instance id; no VS reads v1/v2 on entry, 788 start with the
fetch call and read attributes from v4.
Those ids are zero-based on the hardware (ac_nir_lower_intrinsics_to_args.c: vertex_id is
load_vertex_id_zero_base, instance_id is load_instance_id; the bases come in SGPRs), while
Vulkan's VertexIndex/InstanceIndex include firstVertex|vertexOffset/firstInstance. The
translator now seeds v0 = VertexIndex - BaseVertex and v3 = InstanceIndex - BaseInstance
(DrawParameters; feature shaderDrawParameters in every VS's metadata).
GPU test vs_base_ids.asm, drawn with VKH_DRAW=16,7 (new vk_harness option): 0x101 on every
pixel, where before it was 0x7111. Run by check.py and run_gpu_tests.py. vk_harness,
vk_pipeline_check, vk_bindless_test, vk_texture_test and the runtime's Vulkan device enable
shaderDrawParameters. design.md's "Inputs and outputs" row replaces the "unverified" note.
AI-assisted (Claude Code).
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 | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp index 535c7879f..df4e069db 100644 --- a/runtime/test/vk_harness.cpp +++ b/runtime/test/vk_harness.cpp | |||
| @@ -248,12 +248,22 @@ int main(int argc, char** argv) { | |||
| 248 | m8.maintenance8 = VK_TRUE; m8.pNext = chain; chain = &m8; | 248 | m8.maintenance8 = VK_TRUE; m8.pNext = chain; chain = &m8; |
| 249 | } | 249 | } |
| 250 | #endif | 250 | #endif |
| 251 | VkPhysicalDeviceVulkan11Features f11q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES}; | ||
| 251 | VkPhysicalDeviceVulkan12Features f12q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES}; | 252 | VkPhysicalDeviceVulkan12Features f12q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES}; |
| 253 | f12q.pNext = &f11q; | ||
| 252 | VkPhysicalDeviceVulkan13Features f13q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | 254 | VkPhysicalDeviceVulkan13Features f13q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; |
| 253 | f13q.pNext = &f12q; | 255 | f13q.pNext = &f12q; |
| 254 | VkPhysicalDeviceFeatures2 f2q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; | 256 | VkPhysicalDeviceFeatures2 f2q{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; |
| 255 | f2q.pNext = &f13q; | 257 | f2q.pNext = &f13q; |
| 256 | vkGetPhysicalDeviceFeatures2(pd, &f2q); | 258 | vkGetPhysicalDeviceFeatures2(pd, &f2q); |
| 259 | // Translated vertex shaders read BaseVertex / BaseInstance (DrawParameters) to give v0 / v3 the hardware's | ||
| 260 | // zero-based ids. | ||
| 261 | VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES}; | ||
| 262 | if (f11q.shaderDrawParameters) { | ||
| 263 | f11.shaderDrawParameters = VK_TRUE; | ||
| 264 | f11.pNext = chain; | ||
| 265 | chain = &f11; | ||
| 266 | } | ||
| 257 | VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; | 267 | VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; |
| 258 | if (f13q.subgroupSizeControl) { | 268 | if (f13q.subgroupSizeControl) { |
| 259 | f13.subgroupSizeControl = VK_TRUE; | 269 | f13.subgroupSizeControl = VK_TRUE; |
| @@ -574,8 +584,12 @@ int main(int argc, char** argv) { | |||
| 574 | vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0); | 584 | vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0); |
| 575 | else if (mesh) | 585 | else if (mesh) |
| 576 | reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]); | 586 | reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]); |
| 577 | else | 587 | else { |
| 578 | vkCmdDraw(cmd, 3, 1, 0, 0); | 588 | // VKH_DRAW=<firstVertex>,<firstInstance>: draw the triangle with non-zero bases (vs_base_ids). |
| 589 | unsigned first_vertex = 0, first_instance = 0; | ||
| 590 | if (const char* d = std::getenv("VKH_DRAW")) std::sscanf(d, "%u,%u", &first_vertex, &first_instance); | ||
| 591 | vkCmdDraw(cmd, 3, 1, first_vertex, first_instance); | ||
| 592 | } | ||
| 579 | vkCmdEndRenderPass(cmd); | 593 | vkCmdEndRenderPass(cmd); |
| 580 | VkBufferImageCopy reg{}; reg.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; reg.imageExtent = {W, H, 1}; | 594 | VkBufferImageCopy reg{}; reg.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; reg.imageExtent = {W, H, 1}; |
| 581 | vkCmdCopyImageToBuffer(cmd, img, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buf, 1, ®); | 595 | vkCmdCopyImageToBuffer(cmd, img, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buf, 1, ®); |