Skip to content

Commit

Permalink
change ShaderCOptions.includeDirs to an array of C strings (#2)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
samloeschen authored Jul 7, 2024
1 parent b10ebd7 commit 2e9e96d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)__
2 changes: 1 addition & 1 deletion examples/02-runtime-shaderc/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions src/shaderc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2e9e96d

Please sign in to comment.