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:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 21:42:29 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 21:42:29 +0100
commit0d58747e0da27dcb44b0127831260b763913fc2f (patch)
tree09f1e6ad535e3157d5e34c68c4c43d87ba3a107a /runtime/test/vk_harness.cpp
parent4c414d121663c06ab2cbfb04596cc2a39457be77 (diff)
ps_oracle: --format runs the pixel shader against other color targets
vk_harness takes VKH_COLOR_FORMAT=<VkFormat>:<bytes> for its color target and writes the target's texels as stored. ps_oracle.py --format picks it (the driver then picks the export format, as for a game pipeline), with an integer-output const template for integer targets. docs gets the export behaviour measured on gfx1036: 32_GR / 32_R take the last enabled channels, a compr export reaches 16-bit UNORM/SNORM/UINT/SINT targets bit for bit, FP16 targets get the halves as f16 (a NaN half becomes 0xfe00). AI-assisted.
Diffstat (limited to 'runtime/test/vk_harness.cpp')
-rw-r--r--runtime/test/vk_harness.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp
index c296c9df4..f906bc4f2 100644
--- a/runtime/test/vk_harness.cpp
+++ b/runtime/test/vk_harness.cpp
@@ -18,6 +18,8 @@
18// VKH_BINARY_OUT=<file> writes the pipeline's VK_KHR_pipeline_binary data after building it 18// VKH_BINARY_OUT=<file> writes the pipeline's VK_KHR_pipeline_binary data after building it
19// VKH_BINARY_IN=<file> builds the pipeline from such a file instead (tools/ps_oracle.py patches the pixel 19// VKH_BINARY_IN=<file> builds the pipeline from such a file instead (tools/ps_oracle.py patches the pixel
20// shader in it); both exit 77 without VK_KHR_pipeline_binary 20// shader in it); both exit 77 without VK_KHR_pipeline_binary
21// VKH_COLOR_FORMAT=<VkFormat>:<bytes> the color target's format and texel size (default RGBA32F, 16); out.raw
22// holds the texels as stored; 77 when the format is no color attachment
21// VKH_SUBGROUP_SIZE=32|64 requires that subgroup size of the fragment shader (or of the compute or geometry 23// VKH_SUBGROUP_SIZE=32|64 requires that subgroup size of the fragment shader (or of the compute or geometry
22// stage under test); stderr says "fragment subgroup size: N" when it took effect and 24// stage under test); stderr says "fragment subgroup size: N" when it took effect and
23// "... not available" when the device cannot require it (exit code stays 0). 25// "... not available" when the device cannot require it (exit code stays 0).
@@ -443,7 +445,23 @@ int main(int argc, char** argv) {
443 CHECK(vkCreateImageView(dev, &vi, nullptr, &view)); 445 CHECK(vkCreateImageView(dev, &vi, nullptr, &view));
444 return 0; 446 return 0;
445 }; 447 };
446 const VkFormat fmt = VK_FORMAT_R32G32B32A32_SFLOAT; 448 // VKH_COLOR_FORMAT=<VkFormat number>:<bytes per texel>: the color target's format (default RGBA32F, 16 bytes);
449 // out.raw then holds the target's texels as they are (tools/ps_oracle.py --format).
450 VkFormat fmt = VK_FORMAT_R32G32B32A32_SFLOAT;
451 uint32_t texel_bytes = 16;
452 if (const char* cf = std::getenv("VKH_COLOR_FORMAT"); cf && *cf) {
453 char* end = nullptr;
454 fmt = VkFormat(std::strtoul(cf, &end, 0));
455 texel_bytes = (end && *end == ':') ? uint32_t(std::strtoul(end + 1, nullptr, 0)) : 0;
456 if (!texel_bytes || texel_bytes > 16) { std::fprintf(stderr, "VKH_COLOR_FORMAT: want <format>:<bytes>\n"); return 2; }
457 auto get_fp = reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(
458 gipa(inst, "vkGetPhysicalDeviceFormatProperties"));
459 VkFormatProperties cp; get_fp(pd, fmt, &cp);
460 if (!(cp.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
461 std::fprintf(stderr, "unsupported: format %u is not a color attachment\n", unsigned(fmt));
462 return 77;
463 }
464 }
447 VkImage img; 465 VkImage img;
448 VkImageView views[2]{}; 466 VkImageView views[2]{};
449 if (attachment(fmt, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, 467 if (attachment(fmt, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
@@ -665,7 +683,7 @@ int main(int argc, char** argv) {
665 CHECK(vkCreateComputePipelines(dev, VK_NULL_HANDLE, 1, &cpi, nullptr, &cpipe)); 683 CHECK(vkCreateComputePipelines(dev, VK_NULL_HANDLE, 1, &cpi, nullptr, &cpipe));
666 } 684 }
667 VkBufferCreateInfo bi{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; 685 VkBufferCreateInfo bi{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
668 bi.size = VkDeviceSize(W) * H * 16; bi.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; 686 bi.size = VkDeviceSize(W) * H * texel_bytes; bi.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
669 VkBuffer buf; CHECK(vkCreateBuffer(dev, &bi, nullptr, &buf)); 687 VkBuffer buf; CHECK(vkCreateBuffer(dev, &bi, nullptr, &buf));
670 VkMemoryRequirements br; vkGetBufferMemoryRequirements(dev, buf, &br); 688 VkMemoryRequirements br; vkGetBufferMemoryRequirements(dev, buf, &br);
671 VkMemoryAllocateInfo bai{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO}; 689 VkMemoryAllocateInfo bai{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};