From bad290a635d7909c8a3d48a77093e73c45c8a397 Mon Sep 17 00:00:00 2001 From: DialecticalMaterialist <170803884+DialecticalMaterialist@users.noreply.github.com> Date: Sun, 3 Aug 2025 14:25:39 +0200 Subject: [PATCH] Inline gpu function calls It seems that the stage2 compiler when targetting spir-v does yet not have that many optimizations such as function inlining and DCE. Interestingly the function such as location get generated and gets a function call but it has an empty body. By appending inline to these functions they are not generated in the emitted binary only their instructions. --- lib/std/gpu.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/std/gpu.zig b/lib/std/gpu.zig index d72d298b32d2..fdc4973686a7 100644 --- a/lib/std/gpu.zig +++ b/lib/std/gpu.zig @@ -22,7 +22,7 @@ pub extern const instance_index: u32 addrspace(.input); /// 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 { +pub inline fn location(comptime ptr: anytype, comptime loc: u32) void { asm volatile ( \\OpDecorate %ptr Location $loc : @@ -33,7 +33,7 @@ pub fn location(comptime ptr: anytype, comptime loc: u32) void { /// 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 set: u32, comptime bind: u32) void { +pub inline fn binding(comptime ptr: anytype, comptime set: u32, comptime bind: u32) void { asm volatile ( \\OpDecorate %ptr DescriptorSet $set \\OpDecorate %ptr Binding $bind @@ -81,7 +81,7 @@ pub const ExecutionMode = union(Tag) { }; /// Declare the mode entry point executes in. -pub fn executionMode(comptime entry_point: anytype, comptime mode: ExecutionMode) void { +pub inline fn executionMode(comptime entry_point: anytype, comptime mode: ExecutionMode) void { const cc = @typeInfo(@TypeOf(entry_point)).@"fn".calling_convention; switch (mode) { .origin_upper_left,