| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | | const comptimePrint = std.fmt.comptimePrint; |
| 3 | 2 | |
| 4 | 3 | /// Will make `ptr` contain the location of the current invocation within the |
| 5 | 4 | /// 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 { |
| 81 | 80 | /// Forms the main linkage for `input` and `output` address spaces. |
| 82 | 81 | /// `ptr` must be a reference to variable or struct field. |
| 83 | 82 | pub fn location(comptime ptr: anytype, comptime loc: u32) void { |
| 84 | | const code = comptimePrint("OpDecorate %ptr Location {}", .{loc}); |
| 85 | | asm volatile (code |
| 83 | asm volatile ("OpDecorate %ptr Location $loc" |
| 86 | 84 | : |
| 87 | 85 | : [ptr] "" (ptr), |
| 86 | [loc] "c" (loc), |
| 88 | 87 | ); |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | /// Forms the main linkage for `input` and `output` address spaces. |
| 92 | 91 | /// `ptr` must be a reference to variable or struct field. |
| 93 | | pub fn binding(comptime ptr: anytype, comptime group: u32, comptime bind: u32) void { |
| 94 | | const code = comptimePrint( |
| 95 | | \\OpDecorate %ptr DescriptorSet {} |
| 96 | | \\OpDecorate %ptr Binding {} |
| 97 | | , .{ group, bind }); |
| 98 | | asm volatile (code |
| 92 | pub fn binding(comptime ptr: anytype, comptime set: u32, comptime bind: u32) void { |
| 93 | asm volatile ( |
| 94 | \\OpDecorate %ptr DescriptorSet $set |
| 95 | \\OpDecorate %ptr Binding $bind |
| 99 | 96 | : |
| 100 | 97 | : [ptr] "" (ptr), |
| 98 | [set] "c" (set), |
| 99 | [bind] "c" (bind), |
| 101 | 100 | ); |
| 102 | 101 | } |
| 103 | 102 | |
| ... | ... | @@ -111,13 +110,10 @@ pub const Origin = enum(u32) { |
| 111 | 110 | /// The coordinates appear to originate in the specified `origin`. |
| 112 | 111 | /// Only valid with the `Fragment` calling convention. |
| 113 | 112 | pub fn fragmentOrigin(comptime entry_point: anytype, comptime origin: Origin) void { |
| 114 | | const origin_enum = switch (origin) { |
| 115 | | .upper_left => .OriginUpperLeft, |
| 116 | | .lower_left => .OriginLowerLeft, |
| 117 | | }; |
| 118 | | asm volatile ("OpExecutionMode %entry_point " ++ @tagName(origin_enum) |
| 113 | asm volatile ("OpExecutionMode %entry_point $origin" |
| 119 | 114 | : |
| 120 | 115 | : [entry_point] "" (entry_point), |
| 116 | [origin] "c" (@intFromEnum(origin)), |
| 121 | 117 | ); |
| 122 | 118 | } |
| 123 | 119 | |
| ... | ... | @@ -141,37 +137,33 @@ pub const DepthMode = enum(u32) { |
| 141 | 137 | |
| 142 | 138 | /// Only valid with the `Fragment` calling convention. |
| 143 | 139 | pub fn depthMode(comptime entry_point: anytype, comptime mode: DepthMode) void { |
| 144 | | const code = comptimePrint("OpExecutionMode %entry_point {}", .{@intFromEnum(mode)}); |
| 145 | | asm volatile (code |
| 140 | asm volatile ("OpExecutionMode %entry_point $mode" |
| 146 | 141 | : |
| 147 | 142 | : [entry_point] "" (entry_point), |
| 143 | [mode] "c" (mode), |
| 148 | 144 | ); |
| 149 | 145 | } |
| 150 | 146 | |
| 151 | 147 | /// Indicates the workgroup size in the `x`, `y`, and `z` dimensions. |
| 152 | 148 | /// Only valid with the `GLCompute` or `Kernel` calling conventions. |
| 153 | 149 | pub fn workgroupSize(comptime entry_point: anytype, comptime size: @Vector(3, u32)) void { |
| 154 | | const code = comptimePrint("OpExecutionMode %entry_point LocalSize {} {} {}", .{ |
| 155 | | size[0], |
| 156 | | size[1], |
| 157 | | size[2], |
| 158 | | }); |
| 159 | | asm volatile (code |
| 150 | asm volatile ("OpExecutionMode %entry_point LocalSize %x %y %z" |
| 160 | 151 | : |
| 161 | 152 | : [entry_point] "" (entry_point), |
| 153 | [x] "c" (size[0]), |
| 154 | [y] "c" (size[1]), |
| 155 | [z] "c" (size[2]), |
| 162 | 156 | ); |
| 163 | 157 | } |
| 164 | 158 | |
| 165 | 159 | /// A hint to the client, which indicates the workgroup size in the `x`, `y`, and `z` dimensions. |
| 166 | 160 | /// Only valid with the `GLCompute` or `Kernel` calling conventions. |
| 167 | 161 | pub fn workgroupSizeHint(comptime entry_point: anytype, comptime size: @Vector(3, u32)) void { |
| 168 | | const code = comptimePrint("OpExecutionMode %entry_point LocalSizeHint {} {} {}", .{ |
| 169 | | size[0], |
| 170 | | size[1], |
| 171 | | size[2], |
| 172 | | }); |
| 173 | | asm volatile (code |
| 162 | asm volatile ("OpExecutionMode %entry_point LocalSizeHint %x %y %z" |
| 174 | 163 | : |
| 175 | 164 | : [entry_point] "" (entry_point), |
| 165 | [x] "c" (size[0]), |
| 166 | [y] "c" (size[1]), |
| 167 | [z] "c" (size[2]), |
| 176 | 168 | ); |
| 177 | 169 | } |