vulkan-zig icon indicating copy to clipboard operation
vulkan-zig copied to clipboard

Mark wrapper functions inline

Open VoilaNeighbor opened this issue 2 years ago • 2 comments

Zig has well-defined return copy elision. If we define the wrapper functions to be inline, then many copies from a semantical view would be eliminated. For example:

pub fn getPhysicalDeviceProperties(
    self: Self,
    physical_device: PhysicalDevice,
) callconv(.Inline) PhysicalDeviceProperties {
    var properties: PhysicalDeviceProperties = undefined;
    self.dispatch.vkGetPhysicalDeviceProperties(
        physical_device,
        &properties,
    );
    return properties;
}

VoilaNeighbor avatar Sep 02 '23 05:09 VoilaNeighbor

Wow sorry, I completely missed this issue. Considering that this is mostly just a light-weight wrapper, I think there is no downside into making these function inline (there shouldn't be too much extra processing time).

Snektron avatar Nov 30 '23 22:11 Snektron

I was new to Zig. Lately I found that we could just write pub inline fn, simpler than my original proposal

VoilaNeighbor avatar Dec 01 '23 00:12 VoilaNeighbor