@@ -379,16 +379,12 @@ void EmitContext::DefineInputs() {
379
379
input_params[i] = {id, input_f32, F32[1 ], 4 };
380
380
}
381
381
382
+ u32 patch_base_location = runtime_info.vs_info .hs_output_cp_stride >> 4 ;
382
383
for (size_t index = 0 ; index < 30 ; ++index) {
383
384
if (!(info.uses_patches & (1U << index))) {
384
385
continue ;
385
386
}
386
- const Id id{
387
- DefineInput (F32[4 ], 31 - index)}; // TODO: this should usually work, but might
388
- // overlap with per-vertex outputs.
389
- // Safer solution might require recompiling for every hull/domain permutation to make
390
- // sure patch variables match in location
391
- Decorate (id, spv::Decoration::Patch);
387
+ const Id id{DefineInput (F32[4 ], patch_base_location + index)};
392
388
Name (id, fmt::format (" patch_in{}" , index));
393
389
patches[index] = id;
394
390
}
@@ -456,14 +452,12 @@ void EmitContext::DefineOutputs() {
456
452
output_params[i] = {id, output_f32, F32[1 ], 4 };
457
453
}
458
454
459
- // TODO is it ok to share output locations between patch consts and
460
- // per-vertex output attrs?
461
- // spirv-val doesn't complain so idk
455
+ u32 patch_base_location = runtime_info.hs_info .hs_output_cp_stride >> 4 ;
462
456
for (size_t index = 0 ; index < 30 ; ++index) {
463
457
if (!(info.uses_patches & (1U << index))) {
464
458
continue ;
465
459
}
466
- const Id id{DefineOutput (F32[4 ], 31 - index)};
460
+ const Id id{DefineOutput (F32[4 ], patch_base_location + index)};
467
461
Decorate (id, spv::Decoration::Patch);
468
462
Name (id, fmt::format (" patch_out{}" , index));
469
463
patches[index] = id;
0 commit comments