From 2e9e96d4ee6b98af0595455de20e38c8db1ec5ea Mon Sep 17 00:00:00 2001 From: Sam Loeschen Date: Sun, 7 Jul 2024 09:19:22 -0500 Subject: [PATCH] change ShaderCOptions.includeDirs to an array of C strings (#2) Avoids segfault when providing more than one include path. `[:0]const u8` strings seem to work fine everywhere else, but includeDirs needs to be a `[*c]const u8` to keep shaderc happy --- AUTHORS.md | 2 ++ examples/02-runtime-shaderc/src/main.zig | 2 +- src/shaderc.zig | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 00d1765..1ae22e1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,3 +12,5 @@ The incomplete list of individuals below have provided patches or otherwise contributed to the project prior to the project being hosted on GitHub. See the GitHub commit log for a list of recent contributors. We would like to thank everyone who has contributed to the project in any way. + +* __[Sam Loeschen](https://github.com/samloeschen)__ \ No newline at end of file diff --git a/examples/02-runtime-shaderc/src/main.zig b/examples/02-runtime-shaderc/src/main.zig index b58d1f3..92466cc 100644 --- a/examples/02-runtime-shaderc/src/main.zig +++ b/examples/02-runtime-shaderc/src/main.zig @@ -103,7 +103,7 @@ pub fn buildProgram(allocator: std.mem.Allocator) !bgfx.ProgramHandle { const path = try std.fs.path.joinZ(allocator, &.{ exe_dir, "..", "include", "shaders" }); defer allocator.free(path); - var includes = [_][:0]const u8{path}; + var includes = [_][*c]const u8{path}; // Compile fs shader var fs_shader_options = shaderc.createDefaultOptionsForRenderer(bgfx.getRendererType()); diff --git a/src/shaderc.zig b/src/shaderc.zig index c7f8960..aaf86c7 100644 --- a/src/shaderc.zig +++ b/src/shaderc.zig @@ -219,9 +219,9 @@ pub const ShadercOptions = struct { profile: Profile, inputFilePath: ?[:0]const u8 = null, outputFilePath: ?[:0]const u8 = null, - includeDirs: ?[][:0]const u8 = null, - defines: ?[][:0]const u8 = null, - dependencies: ?[][:0]const u8 = null, + includeDirs: ?[][*c]const u8 = null, + defines: ?[][*c]const u8 = null, + dependencies: ?[][*c]const u8 = null, disasm: bool = false, raw: bool = false,