Skip to content

Commit d1d1007

Browse files
Update WgslSourceGenerator.cs
1 parent 2fd7a8d commit d1d1007

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/ImageSharp.Drawing.WebGPU.ShaderGen/WgslSourceGenerator.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,20 @@ private static string ToPropertyName(string path)
393393
return builder.ToString();
394394
}
395395

396-
// AdditionalFiles come through as full paths. The generated API is keyed by the relative
397-
// path beneath the raw WGSL source tree so imports remain stable across machines.
396+
// AdditionalFiles come through as full paths with the platform's native separators.
397+
// Normalize first so Linux/macOS and Windows builds all resolve the same shader-relative
398+
// path beneath Shaders/WgslSource.
398399
private static string? GetRelativeShaderPath(string path)
399400
{
400-
const string marker = "\\Shaders\\WgslSource\\";
401-
int index = path.LastIndexOf(marker, StringComparison.OrdinalIgnoreCase);
401+
string normalizedPath = NormalizePath(path);
402+
const string marker = "/Shaders/WgslSource/";
403+
int index = normalizedPath.LastIndexOf(marker, StringComparison.OrdinalIgnoreCase);
402404
if (index < 0)
403405
{
404406
return null;
405407
}
406408

407-
return NormalizePath(path.Substring(index + marker.Length));
409+
return normalizedPath.Substring(index + marker.Length);
408410
}
409411

410412
private static string NormalizePath(string path)

0 commit comments

Comments
 (0)