Skip to content

Does ash use function pointers or link against the loader directly? #683

Closed Answered by MarijnS95
Jerrody asked this question in Q&A
Discussion options

You must be logged in to vote

@Jerrody PFN_vkCmdDraw it the type of a function pointer. The loader exports a function with this signature as vkCmdDraw, to be linked against directly but with aforementioned dispatch table overhead. Ash does not use those and instead loads it via vkGetDeviceProcAddr(device, "vkCmdDraw") directly, as written in that article:

ash/ash/src/vk/features.rs

Lines 3051 to 3052 in 29b935b

let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdDraw\0");
let val = _f(cname);

_f here is the loader function:

ash/ash/src/device.rs

Lines 22 to 24 in 29b935b

let load_fn = |name: &std::ffi::CStr| {
mem::transmute((instance_fn.get_device_proc_addr)(device,

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MarijnS95
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #682 on November 20, 2022 12:42.