Commit 7bbeac7f17
Changed files (1)
lib
std
lib/std/gpu.zig
@@ -1,5 +1,4 @@
const std = @import("std.zig");
-const comptimePrint = std.fmt.comptimePrint;
/// Will make `ptr` contain the location of the current invocation within the
/// global workgroup. Each component is equal to the index of the local workgroup
@@ -81,23 +80,23 @@ pub fn fragmentDepth(comptime ptr: *addrspace(.output) f32) void {
/// Forms the main linkage for `input` and `output` address spaces.
/// `ptr` must be a reference to variable or struct field.
pub fn location(comptime ptr: anytype, comptime loc: u32) void {
- const code = comptimePrint("OpDecorate %ptr Location {}", .{loc});
- asm volatile (code
+ asm volatile ("OpDecorate %ptr Location $loc"
:
: [ptr] "" (ptr),
+ [loc] "c" (loc),
);
}
/// Forms the main linkage for `input` and `output` address spaces.
/// `ptr` must be a reference to variable or struct field.
-pub fn binding(comptime ptr: anytype, comptime group: u32, comptime bind: u32) void {
- const code = comptimePrint(
- \\OpDecorate %ptr DescriptorSet {}
- \\OpDecorate %ptr Binding {}
- , .{ group, bind });
- asm volatile (code
+pub fn binding(comptime ptr: anytype, comptime set: u32, comptime bind: u32) void {
+ asm volatile (
+ \\OpDecorate %ptr DescriptorSet $set
+ \\OpDecorate %ptr Binding $bind
:
: [ptr] "" (ptr),
+ [set] "c" (set),
+ [bind] "c" (bind),
);
}
@@ -111,13 +110,10 @@ pub const Origin = enum(u32) {
/// The coordinates appear to originate in the specified `origin`.
/// Only valid with the `Fragment` calling convention.
pub fn fragmentOrigin(comptime entry_point: anytype, comptime origin: Origin) void {
- const origin_enum = switch (origin) {
- .upper_left => .OriginUpperLeft,
- .lower_left => .OriginLowerLeft,
- };
- asm volatile ("OpExecutionMode %entry_point " ++ @tagName(origin_enum)
+ asm volatile ("OpExecutionMode %entry_point $origin"
:
: [entry_point] "" (entry_point),
+ [origin] "c" (@intFromEnum(origin)),
);
}
@@ -141,37 +137,33 @@ pub const DepthMode = enum(u32) {
/// Only valid with the `Fragment` calling convention.
pub fn depthMode(comptime entry_point: anytype, comptime mode: DepthMode) void {
- const code = comptimePrint("OpExecutionMode %entry_point {}", .{@intFromEnum(mode)});
- asm volatile (code
+ asm volatile ("OpExecutionMode %entry_point $mode"
:
: [entry_point] "" (entry_point),
+ [mode] "c" (mode),
);
}
/// Indicates the workgroup size in the `x`, `y`, and `z` dimensions.
/// Only valid with the `GLCompute` or `Kernel` calling conventions.
pub fn workgroupSize(comptime entry_point: anytype, comptime size: @Vector(3, u32)) void {
- const code = comptimePrint("OpExecutionMode %entry_point LocalSize {} {} {}", .{
- size[0],
- size[1],
- size[2],
- });
- asm volatile (code
+ asm volatile ("OpExecutionMode %entry_point LocalSize %x %y %z"
:
: [entry_point] "" (entry_point),
+ [x] "c" (size[0]),
+ [y] "c" (size[1]),
+ [z] "c" (size[2]),
);
}
/// A hint to the client, which indicates the workgroup size in the `x`, `y`, and `z` dimensions.
/// Only valid with the `GLCompute` or `Kernel` calling conventions.
pub fn workgroupSizeHint(comptime entry_point: anytype, comptime size: @Vector(3, u32)) void {
- const code = comptimePrint("OpExecutionMode %entry_point LocalSizeHint {} {} {}", .{
- size[0],
- size[1],
- size[2],
- });
- asm volatile (code
+ asm volatile ("OpExecutionMode %entry_point LocalSizeHint %x %y %z"
:
: [entry_point] "" (entry_point),
+ [x] "c" (size[0]),
+ [y] "c" (size[1]),
+ [z] "c" (size[2]),
);
}