diff options
| author | Jess-Doit <doit.jesss@gmail.com> | 2026-11-21 19:11:32 -0800 |
|---|---|---|
| committer | Jess-Doit <doit.jesss@gmail.com> | 2026-11-21 22:28:25 -0800 |
| commit | 4030a386fbdfc127561c61b83ebeba2ca2b70b49 (patch) | |
| tree | 85c3d2a58e2318eae07cef87da68b226fc5a3993 /runtime/test/vk_harness.cpp | |
| parent | 43d470316ec6cbcd64002bc3792998d9f5745dac (diff) | |
Translator: --bary-fallback for raw barycentrics without VK_KHR_fragment_shader_barycentric (SHADER-98)
The 321 pixel shaders that read the raw barycentric pair are translated to
BuiltIn BaryCoordKHR, so they can't run on a device without the extension
(NVIDIA Pascal, for one). With --bary-fallback the pair comes from an
ordinary vec3 input one location past the shader's attributes; the module
needs neither the capability nor the extension, and the index records the
location as bary_fallback_input. tools/bary_fallback_gs.py writes the
pass-through geometry shader that fills it: Position and the PS's inputs
copied unchanged, plus (1,0,0), (0,1,0), (0,0,1) at the three vertices,
whose perspective interpolation is the BaryCoordKHR value.
- LEONIDA_BARY_FALLBACK=1 for build.py, check.py and run_gpu_tests.py
(like LEONIDA_W64_EMULATE): translate with the flag, build
<name>.bary_gs.spv, draw those shaders through it.
- vk_harness: VKH_GS_HELPER=1 keeps VKH_SUBGROUP_SIZE on the fragment
stage when the GS only feeds the pixel shader under test.
- tests/semantic/test_bary_fallback.py and the ps_bary fixture.
- docs/design.md contract row and index key, docs/testing.md section.
GTX 1060 (Pascal): ps_bary 4096/4096 exact, ps_uniform_branch and
ps_scc_mask32 pass with the fallback (SKIP without it). Pixel-shader corpus:
12,101/12,101 translate and pass spirv-val with and without the flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSJXX67xeoorUsLJ2f9zms
Diffstat (limited to 'runtime/test/vk_harness.cpp')
| -rw-r--r-- | runtime/test/vk_harness.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp index 838d04b35..f5b4673f5 100644 --- a/runtime/test/vk_harness.cpp +++ b/runtime/test/vk_harness.cpp | |||
| @@ -248,7 +248,8 @@ int main(int argc, char** argv) { | |||
| 248 | dci.queueCreateInfoCount = 1; dci.pQueueCreateInfos = &qci; | 248 | dci.queueCreateInfoCount = 1; dci.pQueueCreateInfos = &qci; |
| 249 | dci.enabledExtensionCount = uint32_t(enable.size()); dci.ppEnabledExtensionNames = enable.data(); | 249 | dci.enabledExtensionCount = uint32_t(enable.size()); dci.ppEnabledExtensionNames = enable.data(); |
| 250 | dci.pNext = chain; | 250 | dci.pNext = chain; |
| 251 | // VKH_GS=<geometry.spv>: insert a geometry stage between the vertex and fragment shaders. | 251 | // VKH_GS=<geometry.spv>: insert a geometry stage between the vertex and fragment shaders. VKH_SUBGROUP_SIZE then |
| 252 | // applies to it, unless VKH_GS_HELPER=1 says the GS only feeds the pixel shader under test. | ||
| 252 | const char* gs_path = std::getenv("VKH_GS"); | 253 | const char* gs_path = std::getenv("VKH_GS"); |
| 253 | if (gs_path && !f2q.features.geometryShader) { // MoltenVK: Metal has no geometry stage | 254 | if (gs_path && !f2q.features.geometryShader) { // MoltenVK: Metal has no geometry stage |
| 254 | std::fprintf(stderr, "unsupported: no geometryShader\n"); | 255 | std::fprintf(stderr, "unsupported: no geometryShader\n"); |
| @@ -382,11 +383,14 @@ int main(int argc, char** argv) { | |||
| 382 | reqSg.requiredSubgroupSize = req_sg; | 383 | reqSg.requiredSubgroupSize = req_sg; |
| 383 | if (req_sg > 0 && f13q.subgroupSizeControl && | 384 | if (req_sg > 0 && f13q.subgroupSizeControl && |
| 384 | req_sg >= sgProps.minSubgroupSize && req_sg <= sgProps.maxSubgroupSize) { | 385 | req_sg >= sgProps.minSubgroupSize && req_sg <= sgProps.maxSubgroupSize) { |
| 386 | // VKH_GS_HELPER=1: the geometry shader only feeds the pixel shader under test (the --bary-fallback | ||
| 387 | // pass-through), so the size still goes to the fragment stage. | ||
| 388 | const bool gs_tested = gs_path && !std::getenv("VKH_GS_HELPER"); | ||
| 385 | if (mesh && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_MESH_BIT_EXT)) | 389 | if (mesh && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_MESH_BIT_EXT)) |
| 386 | stages[0].pNext = &reqSg; | 390 | stages[0].pNext = &reqSg; |
| 387 | else if (gs_path && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_GEOMETRY_BIT)) | 391 | else if (gs_tested && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_GEOMETRY_BIT)) |
| 388 | stages[2].pNext = &reqSg; | 392 | stages[2].pNext = &reqSg; |
| 389 | else if (!mesh && !gs_path && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_FRAGMENT_BIT)) | 393 | else if (!mesh && !gs_tested && (sgProps.requiredSubgroupSizeStages & VK_SHADER_STAGE_FRAGMENT_BIT)) |
| 390 | stages[1].pNext = &reqSg; | 394 | stages[1].pNext = &reqSg; |
| 391 | } | 395 | } |
| 392 | VkPipelineVertexInputStateCreateInfo vin{VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; | 396 | VkPipelineVertexInputStateCreateInfo vin{VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO}; |