diff options
| author | S1m0ne1997 <347981799+S1m0ne1997@users.noreply.github.com> | 2026-11-22 15:04:48 +0100 |
|---|---|---|
| committer | S1m0ne1997 <347981799+S1m0ne1997@users.noreply.github.com> | 2026-11-22 15:04:48 +0100 |
| commit | 1f32be4f4bc6ea19358fb8eaf9fc4f635f1cdcb8 (patch) | |
| tree | 18344a1c807120e1569a91dbdf50d9194ccf3d8f /runtime/test/vk_texture_test.cpp | |
| parent | 4e99a4951d28e1ff01e87a39ecedfe0188450495 (diff) | |
| parent | 89b047cd8fab50675a43d76722a6a8a881f55dc2 (diff) | |
Merge remote-tracking branch 'origin/main' into shader-33-vs-inputs
# Conflicts:
# runtime/test/shaders/check.py
# scripts/run_gpu_tests.py
# tests/test_shader_checks.py
Diffstat (limited to 'runtime/test/vk_texture_test.cpp')
| -rw-r--r-- | runtime/test/vk_texture_test.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/runtime/test/vk_texture_test.cpp b/runtime/test/vk_texture_test.cpp index d5a211c0c..6a638dc19 100644 --- a/runtime/test/vk_texture_test.cpp +++ b/runtime/test/vk_texture_test.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | // registers that T# -> image index 1 and the shader's literal S# -> sampler index 1, binds an 8x8 gradient at | 5 | // registers that T# -> image index 1 and the shader's literal S# -> sampler index 1, binds an 8x8 gradient at |
| 6 | // index 1 and a magenta fallback at index 0, draws a full-screen triangle and dumps the RGBA32F result. | 6 | // index 1 and a magenta fallback at index 0, draws a full-screen triangle and dumps the RGBA32F result. |
| 7 | // | 7 | // |
| 8 | // vk_texture_test <vs.spv> <fs.spv> <out.raw> <ptr_sgpr> <s0> <s1> <s2> <s3> [--two-mip] (S# words as hex) | 8 | // vk_texture_test <vs.spv> <fs.spv> <out.raw> <ptr_sgpr> <s0> <s1> <s2> <s3> [--two-mip|--two-mip-sint] (S# words as hex) |
| 9 | // --two-mip: expose a 128x128 quadrant texture and its solid cyan mip 1 to the 64x64 draw. | 9 | // --two-mip: expose a 128x128 quadrant texture and its solid cyan mip 1 to the 64x64 draw. |
| 10 | // vk_texture_test cube [out.raw]: ps_cube_sample against two 8x8 cubes, a 12-layer 2D array at binding 3 (the | 10 | // vk_texture_test cube [out.raw]: ps_cube_sample against two 8x8 cubes, a 12-layer 2D array at binding 3 (the |
| 11 | // translator's view of a cube array); every pixel must be the texel a cube sample of its direction reads. | 11 | // translator's view of a cube array); every pixel must be the texel a cube sample of its direction reads. |
| @@ -63,7 +63,8 @@ static bool declares_capability(const std::vector<uint32_t>& spv, uint32_t cap) | |||
| 63 | 63 | ||
| 64 | int main(int argc, char** argv) { | 64 | int main(int argc, char** argv) { |
| 65 | const uint32_t W = 64, H = 64, TW = 8; | 65 | const uint32_t W = 64, H = 64, TW = 8; |
| 66 | const bool two_mip = argc == 10 && std::strcmp(argv[9], "--two-mip") == 0; | 66 | const bool signed_mips = argc == 10 && std::strcmp(argv[9], "--two-mip-sint") == 0; |
| 67 | const bool two_mip = signed_mips || (argc == 10 && std::strcmp(argv[9], "--two-mip") == 0); | ||
| 67 | // With vs_ids spanning UV [0,1] over the viewport, adjacent fragments differ by two base texels. | 68 | // With vs_ids spanning UV [0,1] over the viewport, adjacent fragments differ by two base texels. |
| 68 | const uint32_t texture_side = two_mip ? 2 * W : TW; | 69 | const uint32_t texture_side = two_mip ? 2 * W : TW; |
| 69 | const uint32_t levels = two_mip ? 2 : 1; | 70 | const uint32_t levels = two_mip ? 2 : 1; |
| @@ -108,23 +109,29 @@ int main(int argc, char** argv) { | |||
| 108 | if (dref) | 109 | if (dref) |
| 109 | ssharp[0] |= 3u << 12; // the shader's S#: DEPTH_COMPARE_FUNC = LESSEQUAL | 110 | ssharp[0] |= 3u << 12; // the shader's S#: DEPTH_COMPARE_FUNC = LESSEQUAL |
| 110 | } else { | 111 | } else { |
| 111 | std::fprintf(stderr, "usage: vk_texture_test [cube|dref|dref_a16] [out] | vs fs out ptr_sgpr s0 s1 s2 s3 [--two-mip]\n"); | 112 | std::fprintf(stderr, "usage: vk_texture_test [cube|dref|dref_a16] [out] | vs fs out ptr_sgpr s0 s1 s2 s3 [--two-mip|--two-mip-sint]\n"); |
| 112 | return 2; | 113 | return 2; |
| 113 | } | 114 | } |
| 114 | // Word 1 also selects the numeric type when the shader fetches through this key. | 115 | // Word 1 also selects the numeric type when the shader fetches through this key. |
| 115 | const VkFormat sampled_format = dref ? VK_FORMAT_D32_SFLOAT : VK_FORMAT_R8G8B8A8_UNORM; | 116 | const VkFormat sampled_format = dref ? VK_FORMAT_D32_SFLOAT : |
| 117 | signed_mips ? VK_FORMAT_R8G8B8A8_SINT : VK_FORMAT_R8G8B8A8_UNORM; | ||
| 116 | uint32_t tsharp[8] = {0x11111111, leonida::gfx10::format_from_vulkan(sampled_format) << 20, 0x33333333, 0x44444444, | 118 | uint32_t tsharp[8] = {0x11111111, leonida::gfx10::format_from_vulkan(sampled_format) << 20, 0x33333333, 0x44444444, |
| 117 | 0x55555555, 0x66666666, 0x77777777, 0x88888888}; | 119 | 0x55555555, 0x66666666, 0x77777777, 0x88888888}; |
| 118 | const uint32_t tsharp_va = 256; | 120 | const uint32_t tsharp_va = 256; |
| 119 | 121 | ||
| 120 | gipa = load_vulkan(); | 122 | gipa = load_vulkan(); |
| 121 | if (!gipa) { std::fprintf(stderr, "the Vulkan loader was not found\n"); return 1; } | 123 | if (!gipa) { std::fprintf(stderr, "the Vulkan loader was not found\n"); return 77; } |
| 122 | VkInstance inst = VK_NULL_HANDLE; | 124 | VkInstance inst = VK_NULL_HANDLE; |
| 123 | #define LI(n) auto n = reinterpret_cast<PFN_##n>(gipa(inst, #n)) | 125 | #define LI(n) auto n = reinterpret_cast<PFN_##n>(gipa(inst, #n)) |
| 124 | LI(vkCreateInstance); | 126 | LI(vkCreateInstance); |
| 125 | VkApplicationInfo app{VK_STRUCTURE_TYPE_APPLICATION_INFO}; app.apiVersion = VK_API_VERSION_1_2; | 127 | VkApplicationInfo app{VK_STRUCTURE_TYPE_APPLICATION_INFO}; app.apiVersion = VK_API_VERSION_1_2; |
| 126 | VkInstanceCreateInfo ici{VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO}; ici.pApplicationInfo = &app; | 128 | VkInstanceCreateInfo ici{VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO}; ici.pApplicationInfo = &app; |
| 127 | CHECK(vkCreateInstance(&ici, nullptr, &inst)); | 129 | const VkResult instance_result = vkCreateInstance(&ici, nullptr, &inst); |
| 130 | if (instance_result == VK_ERROR_INCOMPATIBLE_DRIVER) return 77; // no ICD, as on a GPU-less runner | ||
| 131 | if (instance_result != VK_SUCCESS) { | ||
| 132 | std::fprintf(stderr, "FAILED vkCreateInstance -> %d (line %d)\n", instance_result, __LINE__); | ||
| 133 | return 1; | ||
| 134 | } | ||
| 128 | LI(vkEnumeratePhysicalDevices); LI(vkGetPhysicalDeviceProperties); LI(vkGetPhysicalDeviceQueueFamilyProperties); | 135 | LI(vkEnumeratePhysicalDevices); LI(vkGetPhysicalDeviceProperties); LI(vkGetPhysicalDeviceQueueFamilyProperties); |
| 129 | LI(vkGetPhysicalDeviceMemoryProperties); LI(vkCreateDevice); LI(vkGetDeviceProcAddr); | 136 | LI(vkGetPhysicalDeviceMemoryProperties); LI(vkCreateDevice); LI(vkGetDeviceProcAddr); |
| 130 | uint32_t n = 0; | 137 | uint32_t n = 0; |
| @@ -133,7 +140,7 @@ int main(int argc, char** argv) { | |||
| 133 | if (n) CHECK(vkEnumeratePhysicalDevices(inst, &n, pds.data())); | 140 | if (n) CHECK(vkEnumeratePhysicalDevices(inst, &n, pds.data())); |
| 134 | if (!n) { | 141 | if (!n) { |
| 135 | std::fprintf(stderr, "unsupported: no Vulkan physical device\n"); | 142 | std::fprintf(stderr, "unsupported: no Vulkan physical device\n"); |
| 136 | return two_mip ? 77 : 1; | 143 | return 77; // a missing device is a skip in every texture-test mode |
| 137 | } | 144 | } |
| 138 | VkPhysicalDevice pd = VK_NULL_HANDLE; | 145 | VkPhysicalDevice pd = VK_NULL_HANDLE; |
| 139 | VkPhysicalDeviceProperties properties{}; | 146 | VkPhysicalDeviceProperties properties{}; |
| @@ -160,7 +167,7 @@ int main(int argc, char** argv) { | |||
| 160 | while (qi < qn && !(qf[qi].queueFlags & VK_QUEUE_GRAPHICS_BIT)) ++qi; | 167 | while (qi < qn && !(qf[qi].queueFlags & VK_QUEUE_GRAPHICS_BIT)) ++qi; |
| 161 | if (qi == qn) { | 168 | if (qi == qn) { |
| 162 | std::fprintf(stderr, "unsupported: no graphics queue family\n"); | 169 | std::fprintf(stderr, "unsupported: no graphics queue family\n"); |
| 163 | return two_mip ? 77 : 1; | 170 | return 77; // a missing queue is a skip in every texture-test mode |
| 164 | } | 171 | } |
| 165 | float prio = 1; | 172 | float prio = 1; |
| 166 | VkDeviceQueueCreateInfo qci{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO}; | 173 | VkDeviceQueueCreateInfo qci{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO}; |
| @@ -302,6 +309,9 @@ int main(int argc, char** argv) { | |||
| 302 | : (x * 32u) | ((y * 32u) << 8) | (128u << 16) | (255u << 24); | 309 | : (x * 32u) | ((y * 32u) << 8) | (128u << 16) | (255u << 24); |
| 303 | } | 310 | } |
| 304 | } | 311 | } |
| 312 | // The signed two-mip fixture uses 0 or -128 in each channel, including the alpha channel. | ||
| 313 | if (signed_mips) | ||
| 314 | for (auto& texel : texels) texel &= 0x80808080u; | ||
| 305 | if (dref) { // same size as the 8x8 gradient: one 32-bit word a texel | 315 | if (dref) { // same size as the 8x8 gradient: one 32-bit word a texel |
| 306 | for (uint32_t y = 0; y < TW; y++) | 316 | for (uint32_t y = 0; y < TW; y++) |
| 307 | for (uint32_t x = 0; x < TW; x++) { | 317 | for (uint32_t x = 0; x < TW; x++) { |