Skip to content

Conversation

@nihui
Copy link
Member

@nihui nihui commented Jan 9, 2026

  • link moltenvk, run on swiftshader
  • tbd
  • update doc

@github-actions github-actions bot added the core label Jan 9, 2026
@tencent-adm
Copy link
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.08%. Comparing base (41187d4) to head (42bbeb2).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/simplevk.cpp 85.71% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6499      +/-   ##
==========================================
+ Coverage   92.76%   93.08%   +0.31%     
==========================================
  Files         807      807              
  Lines      255091   255844     +753     
==========================================
+ Hits       236633   238147    +1514     
+ Misses      18458    17697     -761     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enables dynamic Vulkan loading on Apple platforms and adds support for the VK_DRIVER_FILES environment variable. Previously, Apple platforms only supported static Vulkan linkage; this change makes dynamic loading the primary method with static linkage as a fallback option.

Key changes:

  • Moved helper functions (get_driver_path_from_icd, get_driver_path_from_icd_env, get_driver_path_from_ncnn_env) outside of platform-specific conditional blocks to make them available on all platforms
  • Added VK_DRIVER_FILES environment variable support alongside VK_ICD_FILENAMES
  • Added Apple-specific well-known Vulkan driver paths (libMoltenVK.dylib, libvulkan_kosmickrisp.dylib)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

};
#elif __APPLE__
const char* well_known_path[] = {
"libMoltenVK.dylib",
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The well-known path entry "libvulkan_kosmickrisp.dylib" appears to be a non-standard or test/development library name. If this is a legitimate Vulkan implementation, it should be documented. If it's for testing purposes only, consider adding a comment explaining its purpose. The unusual name "kosmickrisp" may confuse future maintainers.

Suggested change
"libMoltenVK.dylib",
"libMoltenVK.dylib",
// Non-standard/internal Vulkan implementation used as an additional fallback on Apple platforms.

Copilot uses AI. Check for mistakes.
int nscan = sscanf(line, " \"library_path\" : \"%255[^\"]\"", path);
if (nscan == 1)
{
if (path[0] == '.' || (path[0] != '/' && !strchr(path, ':') && (strchr(path, '/') || strchr(path, '\\'))))
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path detection logic has a complex condition that may not correctly identify all relative paths. The condition path[0] != '/' && !strchr(path, ':') && (strchr(path, '/') || strchr(path, '\\')) will miss paths like "subdir/file" that don't start with '.' but are still relative. Consider simplifying the logic: paths starting with '.' are relative, paths starting with '/' (or containing ':' on Windows for absolute paths like C:) are absolute, and all other paths could be treated as filenames that should be searched relative to the ICD file location or in system paths.

Suggested change
if (path[0] == '.' || (path[0] != '/' && !strchr(path, ':') && (strchr(path, '/') || strchr(path, '\\'))))
bool is_absolute = (path[0] == '/' || path[0] == '\\' || strchr(path, ':'));
if (!is_absolute)

Copilot uses AI. Check for mistakes.
{
if (::vkGetInstanceProcAddr == NULL)
{
NCNN_LOGE("no static linked moltenvk");
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "no static linked moltenvk" is grammatically incorrect. It should be "no statically linked moltenvk" or "MoltenVK not statically linked".

Suggested change
NCNN_LOGE("no static linked moltenvk");
NCNN_LOGE("MoltenVK not statically linked");

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +61
char line[256];
while (!feof(fp))
{
char* s = fgets(line, 256, fp);
if (!s)
break;

// "library_path": "path to driver library",
char path[256];
int nscan = sscanf(line, " \"library_path\" : \"%255[^\"]\"", path);
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixed-size buffers 'line' and 'path' (both 256 bytes) could potentially overflow if the ICD JSON file contains very long library paths. While the sscanf format string limits to 255 characters, JSON files in the wild could have paths longer than this. Consider using dynamic allocation or a larger buffer size, or add proper error handling for truncated paths.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot added the doc label Jan 11, 2026
@nihui nihui merged commit fe7c0cd into Tencent:master Jan 11, 2026
141 of 147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants