Browse Source

Add get_gpu_instance() function and Organized the instance class codes. (#4630)

tags/20230517
張小凡 GitHub 3 years ago
parent
commit
d87e895a1f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions
  1. +5
    -0
      src/gpu.cpp
  2. +12
    -0
      src/gpu.h

+ 5
- 0
src/gpu.cpp View File

@@ -1612,6 +1612,11 @@ int create_gpu_instance()
return 0;
}

VkInstance get_gpu_instance()
{
return (VkInstance)g_instance;
}

void destroy_gpu_instance()
{
MutexLockGuard lock(g_instance_lock);


+ 12
- 0
src/gpu.h View File

@@ -28,7 +28,19 @@
namespace ncnn {

// instance

// Create VkInstance and initialize some objects that need to be calculated by GPU
// Creates a VkInstance object, Checks the extended attributes supported by the Vulkan instance concerned,
// Initializes, and creates Vulkan validation layers (if ENABLE_VALIDATION_LAYER is enabled),
// Iterates over all supported physical devices, etc.
NCNN_EXPORT int create_gpu_instance();

// Get global VkInstance variable
// Must be called after create_gpu_instance() and before destroy_gpu_instance()
NCNN_EXPORT VkInstance get_gpu_instance();

// Destroy VkInstance object and free the memory of the associated object
// Usually called in the destructor of the main program exit
NCNN_EXPORT void destroy_gpu_instance();

// instance extension capability


Loading…
Cancel
Save