Skip to content

Expand SPIR-V features #24681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cce9557
Rebase
DialecticalMaterialist Aug 8, 2025
7fbc4c5
Remove OpCapability and OpExtension
DialecticalMaterialist Aug 8, 2025
1576c53
Test exec_mode via CC
DialecticalMaterialist Aug 9, 2025
3a8884e
Merge branch 'ziglang:master' into expand-gpu
DialecticalMaterialist Aug 9, 2025
cb10f02
build: add `update-cpu-features` step
alichraghi Aug 9, 2025
a32574d
add spirv_kernel calling convention options
alichraghi Aug 9, 2025
df33ace
Add spirv_task and spirv_fragment
DialecticalMaterialist Aug 9, 2025
737e4e9
Add check
DialecticalMaterialist Aug 9, 2025
0cb96ab
forgot to check if vulkan
DialecticalMaterialist Aug 9, 2025
33a6d4e
Merge branch 'ziglang:master' into expand-gpu
DialecticalMaterialist Aug 10, 2025
e467214
Merge branch 'ziglang:master' into expand-gpu
DialecticalMaterialist Aug 11, 2025
8fd5f09
Merge branch 'ziglang:master' into expand-gpu
DialecticalMaterialist Aug 12, 2025
60a66ce
Fix ci failure
DialecticalMaterialist Aug 12, 2025
3e185a1
CI hack
DialecticalMaterialist Aug 12, 2025
6536a8d
Merge branch 'master' into expand-gpu
DialecticalMaterialist Aug 13, 2025
4f65db3
Merge branch 'master' into expand-gpu
DialecticalMaterialist Aug 16, 2025
c2dd2ad
Change type bit size
DialecticalMaterialist Aug 16, 2025
e527724
Make only gen_spirv_spec import spec.zig
DialecticalMaterialist Aug 16, 2025
f99c159
Remove loop
DialecticalMaterialist Aug 16, 2025
f79819d
Merge branch 'master' into expand-gpu
DialecticalMaterialist Aug 17, 2025
4c6c82a
Merge branch 'master' into expand-gpu
DialecticalMaterialist Aug 17, 2025
c183b74
Merge branch 'ziglang:master' into expand-gpu
DialecticalMaterialist Aug 19, 2025
7061ace
Add comment
DialecticalMaterialist Aug 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ pub fn build(b: *std.Build) !void {
b.getInstallStep().dependOn(&install_std_docs.step);
}

const update_cpu_features = b.addExecutable(.{
.name = "update-cpu-features",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/update_cpu_features.zig"),
.target = b.graph.host,
.imports = &.{.{
.name = "spirv_spec",
.module = b.createModule(.{
.root_source_file = b.path("src/codegen/spirv/spec.zig"),
.target = b.graph.host,
}),
}},
}),
});
const run_update_cpu_features = b.addRunArtifact(update_cpu_features);
if (b.args) |args| run_update_cpu_features.addArgs(args);

if (flat) {
b.installFile("LICENSE", "LICENSE");
b.installFile("README.md", "README.md");
Expand All @@ -81,6 +98,9 @@ pub fn build(b: *std.Build) !void {
docs_step.dependOn(langref_step);
docs_step.dependOn(std_docs_step);

const update_cpu_features_step = b.step("update-cpu-features", "Update CPU Features");
update_cpu_features_step.dependOn(&run_update_cpu_features.step);

const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
Expand Down
11 changes: 9 additions & 2 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ pub const Cpu = struct {
pub const Set = struct {
ints: [usize_count]usize,

pub const needed_bit_count = 288;
pub const needed_bit_count = 421;
pub const byte_count = (needed_bit_count + 7) / 8;
pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
pub const Index = std.math.Log2Int(std.meta.Int(.unsigned, usize_count * @bitSizeOf(usize)));
Expand Down Expand Up @@ -1772,6 +1772,8 @@ pub const Cpu = struct {
.spirv_kernel,
.spirv_fragment,
.spirv_vertex,
.spirv_task,
.spirv_mesh,
=> &.{ .spirv32, .spirv64 },
};
}
Expand Down Expand Up @@ -3033,6 +3035,12 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.longdouble => return 128,
},

// OpenGL has no well defined C ABI, we do this to prevent panic when using floating point types.
.opengl => switch (c_type) {
.char, .short, .ushort, .int, .uint, .float, .long, .ulong, .longlong, .ulonglong => return 32,
.double, .longdouble => return 64,
},

.opencl, .vulkan => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
Expand All @@ -3055,7 +3063,6 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {

.ps3,
.contiki,
.opengl,
=> @panic("specify the C integer and float type sizes for this OS"),
}
}
Expand Down
Loading