diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 16:38:18 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 16:38:18 -0500 |
| commit | e9cb0b0e68956ecffe0b52a05a8ccad034bbb06f (patch) | |
| tree | a09c56e68ee12f6f4cd2e78153c46de1bfab8d48 /runtime/test/vk_harness.cpp | |
| parent | 6ae2755f29a8c80257840df5ce632c7309cb2402 (diff) | |
| parent | f348eb9be0eb087d659803605509aaa241cb1c50 (diff) | |
Merge pull request #203 from Ayinaki
# Conflicts:
# tests/test_shader_checks.py
Diffstat (limited to 'runtime/test/vk_harness.cpp')
| -rw-r--r-- | runtime/test/vk_harness.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp index b2293222b..2a197fd58 100644 --- a/runtime/test/vk_harness.cpp +++ b/runtime/test/vk_harness.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #define VK_NO_PROTOTYPES | 8 | #define VK_NO_PROTOTYPES |
| 9 | #include "vulkan_loader.h" | 9 | #include "vulkan_loader.h" |
| 10 | 10 | ||
| 11 | #include <cstddef> | ||
| 11 | #include <cstdio> | 12 | #include <cstdio> |
| 12 | #include <cstdlib> | 13 | #include <cstdlib> |
| 13 | #include <cstring> | 14 | #include <cstring> |
| @@ -110,6 +111,25 @@ int main(int argc, char** argv) { | |||
| 110 | for (auto& x : exts) if (!std::strcmp(x.extensionName, e)) return true; | 111 | for (auto& x : exts) if (!std::strcmp(x.extensionName, e)) return true; |
| 111 | return false; | 112 | return false; |
| 112 | }; | 113 | }; |
| 114 | // A translated pixel shader that reads BaryCoordKHR aborts the driver when the device lacks barycentrics | ||
| 115 | // (llvmpipe and other software devices), so the suite reports it as unsupported instead. 77 is the existing | ||
| 116 | // "this device cannot run the test" code (runtime/test/shaders/check.py, scripts/run_gpu_tests.py). | ||
| 117 | const std::vector<uint32_t> fs_code = read_spv(argv[2]); | ||
| 118 | bool needs_barycentric = false; | ||
| 119 | for (std::size_t i = 5; i + 1 < fs_code.size();) { // instructions follow the 5-word SPIR-V header | ||
| 120 | const uint32_t words = fs_code[i] >> 16, op = fs_code[i] & 0xffffu; | ||
| 121 | if (!words) break; | ||
| 122 | if (op == 17 && fs_code[i + 1] == 5284) { // OpCapability FragmentBarycentricKHR | ||
| 123 | needs_barycentric = true; | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | i += words; | ||
| 127 | } | ||
| 128 | if (needs_barycentric && !has(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME)) { | ||
| 129 | std::fprintf(stderr, "unsupported: %s reads BaryCoordKHR and the device has no %s\n", | ||
| 130 | argv[2], VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); | ||
| 131 | return 77; | ||
| 132 | } | ||
| 113 | std::vector<const char*> enable; | 133 | std::vector<const char*> enable; |
| 114 | void* chain = nullptr; | 134 | void* chain = nullptr; |
| 115 | VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR bary{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR}; | 135 | VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR bary{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR}; |