react-native-vision-camera-spoof-detector 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -24
- package/VisionCameraSpoofDetector.podspec +12 -2
- package/ios/HybridSpoofDetectorOutput.swift +72 -157
- package/ios/NcnnLivenessDetector.h +24 -0
- package/ios/NcnnLivenessDetector.mm +248 -0
- package/ios/ncnn.xcframework/Info.plist +27 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/A/ncnn +0 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/allocator.h +433 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/benchmark.h +28 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/blob.h +33 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/c_api.h +401 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/command.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/cpu.h +177 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/datareader.h +111 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/expression.h +17 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/gpu.h +566 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer.h +212 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_shader_type.h +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_shader_type_enum.h +5 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_type.h +19 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/layer_type_enum.h +115 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/mat.h +1868 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/modelbin.h +69 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/ncnn_export.h +43 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/net.h +252 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/option.h +151 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/paramdict.h +66 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/pipeline.h +101 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/pipelinecache.h +71 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/platform.h +372 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplemath.h +98 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simpleocv.h +492 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simpleomp.h +42 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplestl.h +598 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/simplevk.h +2196 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/vulkan_header_fix.h +1674 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Resources/Info.plist +18 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/ncnn +0 -0
- package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/ncnn +0 -0
- package/ios/openmp.xcframework/Info.plist +27 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/A/openmp +0 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Headers/omp.h +521 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Headers/ompx.h +165 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/Resources/Info.plist +18 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/Versions/Current/openmp +0 -0
- package/ios/openmp.xcframework/ios-arm64/openmp.framework/openmp +0 -0
- package/package.json +1 -1
package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/datareader.h
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2019 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_DATAREADER_H
|
|
5
|
+
#define NCNN_DATAREADER_H
|
|
6
|
+
|
|
7
|
+
#include "platform.h"
|
|
8
|
+
#if NCNN_STDIO
|
|
9
|
+
#include <stdio.h>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#if NCNN_PLATFORM_API
|
|
13
|
+
#if __ANDROID_API__ >= 9
|
|
14
|
+
#include <android/asset_manager.h>
|
|
15
|
+
#endif
|
|
16
|
+
#endif // NCNN_PLATFORM_API
|
|
17
|
+
|
|
18
|
+
namespace ncnn {
|
|
19
|
+
|
|
20
|
+
// data read wrapper
|
|
21
|
+
class NCNN_EXPORT DataReader
|
|
22
|
+
{
|
|
23
|
+
public:
|
|
24
|
+
DataReader();
|
|
25
|
+
virtual ~DataReader();
|
|
26
|
+
|
|
27
|
+
#if NCNN_STRING
|
|
28
|
+
// parse plain param text
|
|
29
|
+
// return 1 if scan success
|
|
30
|
+
virtual int scan(const char* format, void* p) const;
|
|
31
|
+
#endif // NCNN_STRING
|
|
32
|
+
|
|
33
|
+
// read binary param and model data
|
|
34
|
+
// return bytes read
|
|
35
|
+
virtual size_t read(void* buf, size_t size) const;
|
|
36
|
+
|
|
37
|
+
// get model data reference
|
|
38
|
+
// return bytes referenced
|
|
39
|
+
virtual size_t reference(size_t size, const void** buf) const;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
#if NCNN_STDIO
|
|
43
|
+
class DataReaderFromStdioPrivate;
|
|
44
|
+
class NCNN_EXPORT DataReaderFromStdio : public DataReader
|
|
45
|
+
{
|
|
46
|
+
public:
|
|
47
|
+
explicit DataReaderFromStdio(FILE* fp);
|
|
48
|
+
virtual ~DataReaderFromStdio();
|
|
49
|
+
|
|
50
|
+
#if NCNN_STRING
|
|
51
|
+
virtual int scan(const char* format, void* p) const;
|
|
52
|
+
#endif // NCNN_STRING
|
|
53
|
+
virtual size_t read(void* buf, size_t size) const;
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
DataReaderFromStdio(const DataReaderFromStdio&);
|
|
57
|
+
DataReaderFromStdio& operator=(const DataReaderFromStdio&);
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
DataReaderFromStdioPrivate* const d;
|
|
61
|
+
};
|
|
62
|
+
#endif // NCNN_STDIO
|
|
63
|
+
|
|
64
|
+
class DataReaderFromMemoryPrivate;
|
|
65
|
+
class NCNN_EXPORT DataReaderFromMemory : public DataReader
|
|
66
|
+
{
|
|
67
|
+
public:
|
|
68
|
+
explicit DataReaderFromMemory(const unsigned char*& mem);
|
|
69
|
+
virtual ~DataReaderFromMemory();
|
|
70
|
+
|
|
71
|
+
#if NCNN_STRING
|
|
72
|
+
virtual int scan(const char* format, void* p) const;
|
|
73
|
+
#endif // NCNN_STRING
|
|
74
|
+
virtual size_t read(void* buf, size_t size) const;
|
|
75
|
+
virtual size_t reference(size_t size, const void** buf) const;
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
DataReaderFromMemory(const DataReaderFromMemory&);
|
|
79
|
+
DataReaderFromMemory& operator=(const DataReaderFromMemory&);
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
DataReaderFromMemoryPrivate* const d;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
#if NCNN_PLATFORM_API
|
|
86
|
+
#if __ANDROID_API__ >= 9
|
|
87
|
+
class DataReaderFromAndroidAssetPrivate;
|
|
88
|
+
class NCNN_EXPORT DataReaderFromAndroidAsset : public DataReader
|
|
89
|
+
{
|
|
90
|
+
public:
|
|
91
|
+
explicit DataReaderFromAndroidAsset(AAsset* asset);
|
|
92
|
+
virtual ~DataReaderFromAndroidAsset();
|
|
93
|
+
|
|
94
|
+
#if NCNN_STRING
|
|
95
|
+
virtual int scan(const char* format, void* p) const;
|
|
96
|
+
#endif // NCNN_STRING
|
|
97
|
+
virtual size_t read(void* buf, size_t size) const;
|
|
98
|
+
|
|
99
|
+
private:
|
|
100
|
+
DataReaderFromAndroidAsset(const DataReaderFromAndroidAsset&);
|
|
101
|
+
DataReaderFromAndroidAsset& operator=(const DataReaderFromAndroidAsset&);
|
|
102
|
+
|
|
103
|
+
private:
|
|
104
|
+
DataReaderFromAndroidAssetPrivate* const d;
|
|
105
|
+
};
|
|
106
|
+
#endif // __ANDROID_API__ >= 9
|
|
107
|
+
#endif // NCNN_PLATFORM_API
|
|
108
|
+
|
|
109
|
+
} // namespace ncnn
|
|
110
|
+
|
|
111
|
+
#endif // NCNN_DATAREADER_H
|
package/ios/ncnn.xcframework/ios-arm64/ncnn.framework/Versions/Current/Headers/ncnn/expression.h
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2025 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#include "mat.h"
|
|
5
|
+
|
|
6
|
+
namespace ncnn {
|
|
7
|
+
|
|
8
|
+
// count how many blobs are referenced inside expression
|
|
9
|
+
NCNN_EXPORT int count_expression_blobs(const std::string& expr);
|
|
10
|
+
|
|
11
|
+
// resolve reshape shape from expression and input blobs
|
|
12
|
+
// resolve slice indices(starts, ends) from expression and input blobs
|
|
13
|
+
// see docs/developer-guide/expression.md
|
|
14
|
+
// return 0 if success
|
|
15
|
+
NCNN_EXPORT int eval_list_expression(const std::string& expr, const std::vector<Mat>& blobs, std::vector<int>& outlist);
|
|
16
|
+
|
|
17
|
+
} // namespace ncnn
|
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
// Copyright 2018 Tencent
|
|
2
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
3
|
+
|
|
4
|
+
#ifndef NCNN_GPU_H
|
|
5
|
+
#define NCNN_GPU_H
|
|
6
|
+
|
|
7
|
+
#include "platform.h"
|
|
8
|
+
|
|
9
|
+
#if NCNN_VULKAN
|
|
10
|
+
|
|
11
|
+
#include "mat.h"
|
|
12
|
+
|
|
13
|
+
namespace ncnn {
|
|
14
|
+
|
|
15
|
+
// instance
|
|
16
|
+
|
|
17
|
+
// Create VkInstance and initialize some objects that need to be calculated by GPU
|
|
18
|
+
// Creates a VkInstance object, Checks the extended attributes supported by the Vulkan instance concerned,
|
|
19
|
+
// Initializes, and creates Vulkan validation layers (if ENABLE_VALIDATION_LAYER is enabled),
|
|
20
|
+
// Iterates over all supported physical devices, etc.
|
|
21
|
+
NCNN_EXPORT int create_gpu_instance(const char* driver_path = 0);
|
|
22
|
+
|
|
23
|
+
// Get global VkInstance variable
|
|
24
|
+
// Must be called after create_gpu_instance() and before destroy_gpu_instance()
|
|
25
|
+
NCNN_EXPORT VkInstance get_gpu_instance();
|
|
26
|
+
|
|
27
|
+
// Destroy VkInstance object and free the memory of the associated object
|
|
28
|
+
// Usually called in the destructor of the main program exit
|
|
29
|
+
// The function will internally ensure that all vulkan devices are idle before proceeding with destruction.
|
|
30
|
+
NCNN_EXPORT void destroy_gpu_instance();
|
|
31
|
+
|
|
32
|
+
// vulkan core
|
|
33
|
+
extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
|
|
34
|
+
extern PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
|
|
35
|
+
extern PFN_vkAllocateMemory vkAllocateMemory;
|
|
36
|
+
extern PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
|
|
37
|
+
extern PFN_vkBindBufferMemory vkBindBufferMemory;
|
|
38
|
+
extern PFN_vkBindImageMemory vkBindImageMemory;
|
|
39
|
+
extern PFN_vkCmdBeginQuery vkCmdBeginQuery;
|
|
40
|
+
extern PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
|
|
41
|
+
extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
|
|
42
|
+
extern PFN_vkCmdBindPipeline vkCmdBindPipeline;
|
|
43
|
+
extern PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
|
|
44
|
+
extern PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
|
|
45
|
+
extern PFN_vkCmdCopyImage vkCmdCopyImage;
|
|
46
|
+
extern PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
|
|
47
|
+
extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
|
|
48
|
+
extern PFN_vkCmdDispatch vkCmdDispatch;
|
|
49
|
+
extern PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
|
|
50
|
+
extern PFN_vkCmdEndQuery vkCmdEndQuery;
|
|
51
|
+
extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
|
|
52
|
+
extern PFN_vkCmdFillBuffer vkCmdFillBuffer;
|
|
53
|
+
extern PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
|
|
54
|
+
extern PFN_vkCmdPushConstants vkCmdPushConstants;
|
|
55
|
+
extern PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
|
|
56
|
+
extern PFN_vkCmdResolveImage vkCmdResolveImage;
|
|
57
|
+
extern PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
|
|
58
|
+
extern PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
|
|
59
|
+
extern PFN_vkCreateBuffer vkCreateBuffer;
|
|
60
|
+
extern PFN_vkCreateBufferView vkCreateBufferView;
|
|
61
|
+
extern PFN_vkCreateCommandPool vkCreateCommandPool;
|
|
62
|
+
extern PFN_vkCreateComputePipelines vkCreateComputePipelines;
|
|
63
|
+
extern PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
|
|
64
|
+
extern PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
|
|
65
|
+
extern PFN_vkCreateDevice vkCreateDevice;
|
|
66
|
+
extern PFN_vkCreateFence vkCreateFence;
|
|
67
|
+
extern PFN_vkCreateImage vkCreateImage;
|
|
68
|
+
extern PFN_vkCreateImageView vkCreateImageView;
|
|
69
|
+
extern PFN_vkCreatePipelineCache vkCreatePipelineCache;
|
|
70
|
+
extern PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
|
|
71
|
+
extern PFN_vkCreateQueryPool vkCreateQueryPool;
|
|
72
|
+
extern PFN_vkCreateSampler vkCreateSampler;
|
|
73
|
+
extern PFN_vkCreateSemaphore vkCreateSemaphore;
|
|
74
|
+
extern PFN_vkCreateShaderModule vkCreateShaderModule;
|
|
75
|
+
extern PFN_vkDestroyBuffer vkDestroyBuffer;
|
|
76
|
+
extern PFN_vkDestroyBufferView vkDestroyBufferView;
|
|
77
|
+
extern PFN_vkDestroyCommandPool vkDestroyCommandPool;
|
|
78
|
+
extern PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
|
|
79
|
+
extern PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
|
|
80
|
+
extern PFN_vkDestroyDevice vkDestroyDevice;
|
|
81
|
+
extern PFN_vkDestroyFence vkDestroyFence;
|
|
82
|
+
extern PFN_vkDestroyImage vkDestroyImage;
|
|
83
|
+
extern PFN_vkDestroyImageView vkDestroyImageView;
|
|
84
|
+
extern PFN_vkDestroyInstance vkDestroyInstance;
|
|
85
|
+
extern PFN_vkDestroyPipeline vkDestroyPipeline;
|
|
86
|
+
extern PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
|
|
87
|
+
extern PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
|
|
88
|
+
extern PFN_vkDestroyQueryPool vkDestroyQueryPool;
|
|
89
|
+
extern PFN_vkDestroySampler vkDestroySampler;
|
|
90
|
+
extern PFN_vkDestroySemaphore vkDestroySemaphore;
|
|
91
|
+
extern PFN_vkDestroyShaderModule vkDestroyShaderModule;
|
|
92
|
+
extern PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
|
|
93
|
+
extern PFN_vkEndCommandBuffer vkEndCommandBuffer;
|
|
94
|
+
extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
|
|
95
|
+
extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
|
|
96
|
+
extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
|
|
97
|
+
extern PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
|
|
98
|
+
extern PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
|
|
99
|
+
extern PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
|
|
100
|
+
extern PFN_vkFreeMemory vkFreeMemory;
|
|
101
|
+
extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
|
|
102
|
+
extern PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
|
|
103
|
+
extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
|
|
104
|
+
extern PFN_vkGetDeviceQueue vkGetDeviceQueue;
|
|
105
|
+
extern PFN_vkGetFenceStatus vkGetFenceStatus;
|
|
106
|
+
extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
|
|
107
|
+
extern PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
|
|
108
|
+
extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
|
|
109
|
+
extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
|
|
110
|
+
extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
|
|
111
|
+
extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
|
|
112
|
+
extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
|
|
113
|
+
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
|
|
114
|
+
extern PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
|
|
115
|
+
extern PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
|
|
116
|
+
extern PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
|
|
117
|
+
extern PFN_vkMapMemory vkMapMemory;
|
|
118
|
+
extern PFN_vkMergePipelineCaches vkMergePipelineCaches;
|
|
119
|
+
extern PFN_vkQueueSubmit vkQueueSubmit;
|
|
120
|
+
extern PFN_vkQueueWaitIdle vkQueueWaitIdle;
|
|
121
|
+
extern PFN_vkResetCommandBuffer vkResetCommandBuffer;
|
|
122
|
+
extern PFN_vkResetCommandPool vkResetCommandPool;
|
|
123
|
+
extern PFN_vkResetDescriptorPool vkResetDescriptorPool;
|
|
124
|
+
extern PFN_vkResetFences vkResetFences;
|
|
125
|
+
extern PFN_vkUnmapMemory vkUnmapMemory;
|
|
126
|
+
extern PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
|
|
127
|
+
extern PFN_vkWaitForFences vkWaitForFences;
|
|
128
|
+
|
|
129
|
+
// instance extension capability
|
|
130
|
+
extern int support_VK_KHR_external_memory_capabilities;
|
|
131
|
+
extern int support_VK_KHR_get_physical_device_properties2;
|
|
132
|
+
extern int support_VK_KHR_get_surface_capabilities2;
|
|
133
|
+
extern int support_VK_KHR_surface;
|
|
134
|
+
extern int support_VK_EXT_debug_utils;
|
|
135
|
+
extern int support_VK_EXT_validation_features;
|
|
136
|
+
extern int support_VK_EXT_validation_flags;
|
|
137
|
+
#if __ANDROID_API__ >= 26
|
|
138
|
+
extern int support_VK_KHR_android_surface;
|
|
139
|
+
#endif // __ANDROID_API__ >= 26
|
|
140
|
+
|
|
141
|
+
// VK_KHR_cooperative_matrix
|
|
142
|
+
extern PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR;
|
|
143
|
+
|
|
144
|
+
// VK_KHR_external_memory_capabilities
|
|
145
|
+
extern PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
|
|
146
|
+
|
|
147
|
+
// VK_KHR_get_physical_device_properties2
|
|
148
|
+
extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
|
|
149
|
+
extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
|
|
150
|
+
extern PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR;
|
|
151
|
+
extern PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR;
|
|
152
|
+
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR;
|
|
153
|
+
extern PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
|
|
154
|
+
|
|
155
|
+
// VK_KHR_get_surface_capabilities2
|
|
156
|
+
extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR;
|
|
157
|
+
extern PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR;
|
|
158
|
+
|
|
159
|
+
// VK_KHR_surface
|
|
160
|
+
extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
|
|
161
|
+
extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
|
|
162
|
+
extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
|
|
163
|
+
extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
|
|
164
|
+
extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
|
|
165
|
+
|
|
166
|
+
#if __ANDROID_API__ >= 26
|
|
167
|
+
// VK_KHR_android_surface
|
|
168
|
+
extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
|
|
169
|
+
#endif // __ANDROID_API__ >= 26
|
|
170
|
+
|
|
171
|
+
// VK_NV_cooperative_matrix
|
|
172
|
+
extern PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV;
|
|
173
|
+
|
|
174
|
+
// VK_NV_cooperative_matrix2
|
|
175
|
+
extern PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV;
|
|
176
|
+
|
|
177
|
+
// VK_NV_cooperative_vector
|
|
178
|
+
extern PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV vkGetPhysicalDeviceCooperativeVectorPropertiesNV;
|
|
179
|
+
|
|
180
|
+
// get info
|
|
181
|
+
NCNN_EXPORT int get_gpu_count();
|
|
182
|
+
NCNN_EXPORT int get_default_gpu_index();
|
|
183
|
+
|
|
184
|
+
class GpuInfoPrivate;
|
|
185
|
+
class NCNN_EXPORT GpuInfo
|
|
186
|
+
{
|
|
187
|
+
public:
|
|
188
|
+
explicit GpuInfo();
|
|
189
|
+
virtual ~GpuInfo();
|
|
190
|
+
|
|
191
|
+
int device_index() const;
|
|
192
|
+
|
|
193
|
+
// vulkan physical device
|
|
194
|
+
VkPhysicalDevice physicalDevice() const;
|
|
195
|
+
VkPhysicalDevice physical_device() const; // api compatibility
|
|
196
|
+
|
|
197
|
+
// features
|
|
198
|
+
const VkPhysicalDeviceFeatures& physicalDevicefeatures() const;
|
|
199
|
+
|
|
200
|
+
// properties
|
|
201
|
+
const VkPhysicalDeviceProperties& physicalDeviceProperties() const;
|
|
202
|
+
|
|
203
|
+
// memory properties
|
|
204
|
+
const VkPhysicalDeviceMemoryProperties& physicalDeviceMemoryProperties() const;
|
|
205
|
+
const VkPhysicalDeviceMemoryProperties& physical_device_memory_properties() const; // api compatibility
|
|
206
|
+
|
|
207
|
+
// extension properties
|
|
208
|
+
const std::vector<VkExtensionProperties>& deviceExtensionProperties() const;
|
|
209
|
+
|
|
210
|
+
// info
|
|
211
|
+
uint32_t api_version() const;
|
|
212
|
+
uint32_t driver_version() const;
|
|
213
|
+
uint32_t vendor_id() const;
|
|
214
|
+
uint32_t device_id() const;
|
|
215
|
+
const char* device_name() const;
|
|
216
|
+
uint8_t* pipeline_cache_uuid() const;
|
|
217
|
+
|
|
218
|
+
// driver properties
|
|
219
|
+
uint32_t driver_id() const;
|
|
220
|
+
const char* driver_name() const;
|
|
221
|
+
|
|
222
|
+
// 0 = discrete gpu
|
|
223
|
+
// 1 = integrated gpu
|
|
224
|
+
// 2 = virtual gpu
|
|
225
|
+
// 3 = cpu
|
|
226
|
+
int type() const;
|
|
227
|
+
|
|
228
|
+
// hardware limit
|
|
229
|
+
uint32_t max_shared_memory_size() const;
|
|
230
|
+
uint32_t max_workgroup_count_x() const;
|
|
231
|
+
uint32_t max_workgroup_count_y() const;
|
|
232
|
+
uint32_t max_workgroup_count_z() const;
|
|
233
|
+
uint32_t max_workgroup_invocations() const;
|
|
234
|
+
uint32_t max_workgroup_size_x() const;
|
|
235
|
+
uint32_t max_workgroup_size_y() const;
|
|
236
|
+
uint32_t max_workgroup_size_z() const;
|
|
237
|
+
size_t memory_map_alignment() const;
|
|
238
|
+
size_t buffer_offset_alignment() const;
|
|
239
|
+
size_t non_coherent_atom_size() const;
|
|
240
|
+
size_t buffer_image_granularity() const;
|
|
241
|
+
uint32_t max_image_dimension_1d() const;
|
|
242
|
+
uint32_t max_image_dimension_2d() const;
|
|
243
|
+
uint32_t max_image_dimension_3d() const;
|
|
244
|
+
float timestamp_period() const;
|
|
245
|
+
|
|
246
|
+
// runtime
|
|
247
|
+
uint32_t compute_queue_family_index() const;
|
|
248
|
+
uint32_t transfer_queue_family_index() const;
|
|
249
|
+
|
|
250
|
+
uint32_t compute_queue_count() const;
|
|
251
|
+
uint32_t transfer_queue_count() const;
|
|
252
|
+
|
|
253
|
+
// property
|
|
254
|
+
bool unified_compute_transfer_queue() const;
|
|
255
|
+
|
|
256
|
+
// subgroup
|
|
257
|
+
uint32_t subgroup_size() const;
|
|
258
|
+
uint32_t min_subgroup_size() const;
|
|
259
|
+
uint32_t max_subgroup_size() const;
|
|
260
|
+
uint32_t max_compute_workgroup_subgroups() const;
|
|
261
|
+
bool support_subgroup_size_control() const;
|
|
262
|
+
bool support_compute_full_subgroups() const;
|
|
263
|
+
uint32_t support_subgroup_ops() const;
|
|
264
|
+
|
|
265
|
+
// bug is not feature
|
|
266
|
+
bool bug_storage_buffer_no_l1() const;
|
|
267
|
+
bool bug_corrupted_online_pipeline_cache() const;
|
|
268
|
+
bool bug_buffer_image_load_zero() const;
|
|
269
|
+
|
|
270
|
+
// but sometimes bug is a feature
|
|
271
|
+
bool bug_implicit_fp16_arithmetic() const;
|
|
272
|
+
|
|
273
|
+
// fp16 and int8 feature
|
|
274
|
+
bool support_fp16_packed() const;
|
|
275
|
+
bool support_fp16_storage() const;
|
|
276
|
+
bool support_fp16_uniform() const;
|
|
277
|
+
bool support_fp16_arithmetic() const;
|
|
278
|
+
bool support_int8_packed() const;
|
|
279
|
+
bool support_int8_storage() const;
|
|
280
|
+
bool support_int8_uniform() const;
|
|
281
|
+
bool support_int8_arithmetic() const;
|
|
282
|
+
|
|
283
|
+
// bf16 feature
|
|
284
|
+
bool support_bf16_packed() const;
|
|
285
|
+
bool support_bf16_storage() const; // bf16s implies bf16u
|
|
286
|
+
|
|
287
|
+
// r16f and r8s format in storage image
|
|
288
|
+
bool support_fp16_image() const;
|
|
289
|
+
bool support_int8_image() const;
|
|
290
|
+
|
|
291
|
+
// shader float controls2
|
|
292
|
+
bool support_fp_fast_math() const;
|
|
293
|
+
|
|
294
|
+
// ycbcr conversion feature
|
|
295
|
+
bool support_ycbcr_conversion() const;
|
|
296
|
+
|
|
297
|
+
// cooperative matrix feature
|
|
298
|
+
bool support_cooperative_matrix() const;
|
|
299
|
+
bool support_cooperative_matrix_8_8_16() const;
|
|
300
|
+
bool support_cooperative_matrix_16_8_8() const;
|
|
301
|
+
bool support_cooperative_matrix_16_8_16() const;
|
|
302
|
+
bool support_cooperative_matrix_16_16_16() const;
|
|
303
|
+
|
|
304
|
+
// extension capability
|
|
305
|
+
int support_VK_KHR_8bit_storage() const;
|
|
306
|
+
int support_VK_KHR_16bit_storage() const;
|
|
307
|
+
int support_VK_KHR_bind_memory2() const;
|
|
308
|
+
int support_VK_KHR_buffer_device_address() const;
|
|
309
|
+
int support_VK_KHR_create_renderpass2() const;
|
|
310
|
+
int support_VK_KHR_cooperative_matrix() const;
|
|
311
|
+
int support_VK_KHR_dedicated_allocation() const;
|
|
312
|
+
int support_VK_KHR_descriptor_update_template() const;
|
|
313
|
+
int support_VK_KHR_driver_properties() const;
|
|
314
|
+
int support_VK_KHR_external_memory() const;
|
|
315
|
+
int support_VK_KHR_get_memory_requirements2() const;
|
|
316
|
+
int support_VK_KHR_maintenance1() const;
|
|
317
|
+
int support_VK_KHR_maintenance2() const;
|
|
318
|
+
int support_VK_KHR_maintenance3() const;
|
|
319
|
+
int support_VK_KHR_multiview() const;
|
|
320
|
+
int support_VK_KHR_portability_subset() const;
|
|
321
|
+
int support_VK_KHR_push_descriptor() const;
|
|
322
|
+
int support_VK_KHR_robustness2() const;
|
|
323
|
+
int support_VK_KHR_sampler_ycbcr_conversion() const;
|
|
324
|
+
int support_VK_KHR_shader_bfloat16() const;
|
|
325
|
+
int support_VK_KHR_shader_float16_int8() const;
|
|
326
|
+
int support_VK_KHR_shader_float_controls() const;
|
|
327
|
+
int support_VK_KHR_shader_float_controls2() const;
|
|
328
|
+
int support_VK_KHR_shader_integer_dot_product() const;
|
|
329
|
+
int support_VK_KHR_shader_non_semantic_info() const;
|
|
330
|
+
int support_VK_KHR_shader_subgroup_extended_types() const;
|
|
331
|
+
int support_VK_KHR_shader_subgroup_rotate() const;
|
|
332
|
+
int support_VK_KHR_storage_buffer_storage_class() const;
|
|
333
|
+
int support_VK_KHR_swapchain() const;
|
|
334
|
+
int support_VK_KHR_vulkan_memory_model() const;
|
|
335
|
+
int support_VK_KHR_zero_initialize_workgroup_memory() const;
|
|
336
|
+
int support_VK_EXT_buffer_device_address() const;
|
|
337
|
+
int support_VK_EXT_descriptor_indexing() const;
|
|
338
|
+
int support_VK_EXT_memory_budget() const;
|
|
339
|
+
int support_VK_EXT_memory_priority() const;
|
|
340
|
+
int support_VK_EXT_queue_family_foreign() const;
|
|
341
|
+
int support_VK_EXT_robustness2() const;
|
|
342
|
+
int support_VK_EXT_shader_atomic_float() const;
|
|
343
|
+
int support_VK_EXT_shader_atomic_float2() const;
|
|
344
|
+
int support_VK_EXT_shader_float8() const;
|
|
345
|
+
int support_VK_EXT_subgroup_size_control() const;
|
|
346
|
+
int support_VK_AMD_device_coherent_memory() const;
|
|
347
|
+
#if __ANDROID_API__ >= 26
|
|
348
|
+
int support_VK_ANDROID_external_memory_android_hardware_buffer() const;
|
|
349
|
+
#endif // __ANDROID_API__ >= 26
|
|
350
|
+
int support_VK_NV_cooperative_matrix() const;
|
|
351
|
+
int support_VK_NV_cooperative_matrix2() const;
|
|
352
|
+
int support_VK_NV_cooperative_vector() const;
|
|
353
|
+
|
|
354
|
+
// extension features
|
|
355
|
+
const void* queryExtensionFeatures() const;
|
|
356
|
+
const VkPhysicalDevice8BitStorageFeaturesKHR& query8BitStorageFeatures() const;
|
|
357
|
+
const VkPhysicalDevice16BitStorageFeaturesKHR& query16BitStorageFeatures() const;
|
|
358
|
+
const VkPhysicalDeviceFloat16Int8FeaturesKHR& queryFloat16Int8Features() const;
|
|
359
|
+
const VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR& querySamplerYcbcrConversionFeatures() const;
|
|
360
|
+
const VkPhysicalDeviceCooperativeMatrixFeaturesKHR& queryCooperativeMatrixFeatures() const;
|
|
361
|
+
const VkPhysicalDeviceCooperativeMatrixFeaturesNV& queryCooperativeMatrixFeaturesNV() const;
|
|
362
|
+
const VkPhysicalDeviceCooperativeMatrix2FeaturesNV& queryCooperativeMatrix2FeaturesNV() const;
|
|
363
|
+
const VkPhysicalDeviceCooperativeVectorFeaturesNV& queryCooperativeVectorFeaturesNV() const;
|
|
364
|
+
const VkPhysicalDeviceRobustness2FeaturesKHR& queryRobustness2Features() const;
|
|
365
|
+
const VkPhysicalDeviceSubgroupSizeControlFeaturesEXT& querySubgroupSizeControlFeatures() const;
|
|
366
|
+
const VkPhysicalDeviceShaderBfloat16FeaturesKHR& queryShaderBfloat16Features() const;
|
|
367
|
+
const VkPhysicalDeviceShaderFloat8FeaturesEXT& queryShaderFloat8Features() const;
|
|
368
|
+
const VkPhysicalDeviceShaderFloatControls2FeaturesKHR& queryShaderFloatControls2Features() const;
|
|
369
|
+
const VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR& queryShaderIntegerDotProductFeatures() const;
|
|
370
|
+
const VkPhysicalDeviceShaderSubgroupRotateFeaturesKHR& queryShaderSubgroupRotateFeatures() const;
|
|
371
|
+
const VkPhysicalDeviceShaderAtomicFloatFeaturesEXT& queryShaderAtomicFloatFeatures() const;
|
|
372
|
+
const VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT& queryShaderAtomicFloat2Features() const;
|
|
373
|
+
const VkPhysicalDeviceVulkanMemoryModelFeaturesKHR& queryVulkanMemoryModelFeatures() const;
|
|
374
|
+
|
|
375
|
+
// extension properties
|
|
376
|
+
const void* queryExtensionProperties() const;
|
|
377
|
+
const VkPhysicalDeviceCooperativeMatrix2PropertiesNV& queryCooperativeMatrix2PropertiesNV() const;
|
|
378
|
+
const VkPhysicalDeviceCooperativeVectorPropertiesNV& queryCooperativeVectorPropertiesNV() const;
|
|
379
|
+
const VkPhysicalDeviceDriverPropertiesKHR& queryDriverProperties() const;
|
|
380
|
+
const VkPhysicalDeviceFloatControlsPropertiesKHR& queryFloatControlsProperties() const;
|
|
381
|
+
const VkPhysicalDeviceRobustness2PropertiesKHR& queryRobustness2Properties() const;
|
|
382
|
+
const VkPhysicalDeviceShaderIntegerDotProductProperties& queryShaderIntegerDotProductProperties() const;
|
|
383
|
+
const VkPhysicalDeviceSubgroupProperties& querySubgroupProperties() const;
|
|
384
|
+
const VkPhysicalDeviceSubgroupSizeControlPropertiesEXT& querySubgroupSizeControlProperties() const;
|
|
385
|
+
|
|
386
|
+
// extension sub properties
|
|
387
|
+
const std::vector<VkCooperativeMatrixPropertiesKHR>& queryCooperativeMatrixSubProperties() const;
|
|
388
|
+
const std::vector<VkCooperativeMatrixPropertiesNV>& queryCooperativeMatrixSubPropertiesNV() const;
|
|
389
|
+
const std::vector<VkCooperativeMatrixFlexibleDimensionsPropertiesNV>& queryCooperativeMatrixFlexibleDimensionsSubPropertiesNV() const;
|
|
390
|
+
const std::vector<VkCooperativeVectorPropertiesNV>& queryCooperativeVectorSubPropertiesNV() const;
|
|
391
|
+
|
|
392
|
+
// some utility functions
|
|
393
|
+
void get_optimal_cooperative_matrix_mnk(int M, int N, int K, VkComponentTypeKHR type, VkComponentTypeKHR acctype, VkScopeKHR scope, int& coopmat_M, int& coopmat_N, int& coopmat_K) const;
|
|
394
|
+
|
|
395
|
+
private:
|
|
396
|
+
GpuInfo(const GpuInfo&);
|
|
397
|
+
GpuInfo& operator=(const GpuInfo&);
|
|
398
|
+
|
|
399
|
+
private:
|
|
400
|
+
friend int create_gpu_instance(const char* driver_path);
|
|
401
|
+
GpuInfoPrivate* const d;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
NCNN_EXPORT const GpuInfo& get_gpu_info(int device_index = get_default_gpu_index());
|
|
405
|
+
|
|
406
|
+
class VkAllocator;
|
|
407
|
+
class VkCompute;
|
|
408
|
+
class Option;
|
|
409
|
+
class PipelineCache;
|
|
410
|
+
class VulkanDevicePrivate;
|
|
411
|
+
class NCNN_EXPORT VulkanDevice
|
|
412
|
+
{
|
|
413
|
+
public:
|
|
414
|
+
VulkanDevice(int device_index = get_default_gpu_index());
|
|
415
|
+
~VulkanDevice();
|
|
416
|
+
|
|
417
|
+
const GpuInfo& info;
|
|
418
|
+
|
|
419
|
+
VkDevice vkdevice() const;
|
|
420
|
+
bool is_valid() const;
|
|
421
|
+
|
|
422
|
+
VkShaderModule compile_shader_module(const uint32_t* spv_data, size_t spv_data_size) const;
|
|
423
|
+
|
|
424
|
+
// with fixed workgroup size
|
|
425
|
+
VkShaderModule compile_shader_module(const uint32_t* spv_data, size_t spv_data_size, uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z) const;
|
|
426
|
+
|
|
427
|
+
// helper for creating pipeline
|
|
428
|
+
int create_descriptorset_layout(int binding_count, const int* binding_types, VkDescriptorSetLayout* descriptorset_layout) const;
|
|
429
|
+
int create_pipeline_layout(int push_constant_count, VkDescriptorSetLayout descriptorset_layout, VkPipelineLayout* pipeline_layout) const;
|
|
430
|
+
int create_pipeline(VkShaderModule shader_module, VkPipelineLayout pipeline_layout, const std::vector<vk_specialization_type>& specializations, uint32_t subgroup_size, VkPipeline* pipeline) const;
|
|
431
|
+
int create_descriptor_update_template(int binding_count, const int* binding_types, VkDescriptorSetLayout descriptorset_layout, VkPipelineLayout pipeline_layout, VkDescriptorUpdateTemplateKHR* descriptor_update_template) const;
|
|
432
|
+
|
|
433
|
+
uint32_t find_memory_index(uint32_t memory_type_bits, VkFlags required, VkFlags preferred, VkFlags preferred_not) const;
|
|
434
|
+
bool is_mappable(uint32_t memory_type_index) const;
|
|
435
|
+
bool is_coherent(uint32_t memory_type_index) const;
|
|
436
|
+
|
|
437
|
+
VkQueue acquire_queue(uint32_t queue_family_index) const;
|
|
438
|
+
void reclaim_queue(uint32_t queue_family_index, VkQueue queue) const;
|
|
439
|
+
|
|
440
|
+
// allocator on this device
|
|
441
|
+
VkAllocator* acquire_blob_allocator() const;
|
|
442
|
+
void reclaim_blob_allocator(VkAllocator* allocator) const;
|
|
443
|
+
|
|
444
|
+
VkAllocator* acquire_staging_allocator() const;
|
|
445
|
+
void reclaim_staging_allocator(VkAllocator* allocator) const;
|
|
446
|
+
|
|
447
|
+
// immutable sampler for texelfetch
|
|
448
|
+
const VkSampler* immutable_texelfetch_sampler() const;
|
|
449
|
+
|
|
450
|
+
// dummy buffer image
|
|
451
|
+
VkMat get_dummy_buffer() const;
|
|
452
|
+
VkImageMat get_dummy_image() const;
|
|
453
|
+
VkImageMat get_dummy_image_readonly() const;
|
|
454
|
+
|
|
455
|
+
// pipeline cache on this device
|
|
456
|
+
const PipelineCache* get_pipeline_cache() const;
|
|
457
|
+
|
|
458
|
+
// test image allocation
|
|
459
|
+
bool shape_support_image_storage(const Mat& shape) const;
|
|
460
|
+
|
|
461
|
+
// current gpu heap memory budget in MB
|
|
462
|
+
uint32_t get_heap_budget() const;
|
|
463
|
+
|
|
464
|
+
// utility operator
|
|
465
|
+
void convert_packing(const VkMat& src, VkMat& dst, int dst_elempack, VkCompute& cmd, const Option& opt) const;
|
|
466
|
+
// cast_type_to 0=auto(same as src) 1=fp32 2=fp16 3=int32 4=int8 5=bf16
|
|
467
|
+
void convert_packing(const VkMat& src, VkMat& dst, int dst_elempack, int cast_type_to, VkCompute& cmd, const Option& opt) const;
|
|
468
|
+
|
|
469
|
+
// VK_KHR_bind_memory2
|
|
470
|
+
PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
|
|
471
|
+
PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
|
|
472
|
+
|
|
473
|
+
// VK_KHR_buffer_device_address
|
|
474
|
+
PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
|
|
475
|
+
PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
|
|
476
|
+
PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
|
|
477
|
+
|
|
478
|
+
// VK_KHR_descriptor_update_template
|
|
479
|
+
PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR;
|
|
480
|
+
PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR;
|
|
481
|
+
PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR;
|
|
482
|
+
|
|
483
|
+
// VK_KHR_get_memory_requirements2
|
|
484
|
+
PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
|
|
485
|
+
PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
|
|
486
|
+
|
|
487
|
+
// VK_KHR_maintenance1
|
|
488
|
+
PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
|
|
489
|
+
|
|
490
|
+
// VK_KHR_maintenance3
|
|
491
|
+
PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
|
|
492
|
+
|
|
493
|
+
// VK_KHR_push_descriptor
|
|
494
|
+
PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR;
|
|
495
|
+
PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR;
|
|
496
|
+
|
|
497
|
+
// VK_KHR_sampler_ycbcr_conversion
|
|
498
|
+
PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
|
|
499
|
+
PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
|
|
500
|
+
|
|
501
|
+
// VK_KHR_swapchain
|
|
502
|
+
PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
|
|
503
|
+
PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
|
|
504
|
+
PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
|
|
505
|
+
PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
|
|
506
|
+
PFN_vkQueuePresentKHR vkQueuePresentKHR;
|
|
507
|
+
|
|
508
|
+
// VK_EXT_buffer_device_address
|
|
509
|
+
PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT;
|
|
510
|
+
|
|
511
|
+
#if __ANDROID_API__ >= 26
|
|
512
|
+
// VK_ANDROID_external_memory_android_hardware_buffer
|
|
513
|
+
PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
|
|
514
|
+
PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
|
|
515
|
+
#endif // __ANDROID_API__ >= 26
|
|
516
|
+
|
|
517
|
+
// VK_NV_cooperative_vector
|
|
518
|
+
PFN_vkCmdConvertCooperativeVectorMatrixNV vkCmdConvertCooperativeVectorMatrixNV;
|
|
519
|
+
PFN_vkConvertCooperativeVectorMatrixNV vkConvertCooperativeVectorMatrixNV;
|
|
520
|
+
|
|
521
|
+
protected:
|
|
522
|
+
// device extension
|
|
523
|
+
int init_device_extension();
|
|
524
|
+
|
|
525
|
+
private:
|
|
526
|
+
VulkanDevice(const VulkanDevice&);
|
|
527
|
+
VulkanDevice& operator=(const VulkanDevice&);
|
|
528
|
+
|
|
529
|
+
private:
|
|
530
|
+
VulkanDevicePrivate* const d;
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
NCNN_EXPORT VulkanDevice* get_gpu_device(int device_index = get_default_gpu_index());
|
|
534
|
+
|
|
535
|
+
// online spirv compilation
|
|
536
|
+
NCNN_EXPORT int compile_spirv_module(const char* comp_string, const Option& opt, std::vector<uint32_t>& spirv);
|
|
537
|
+
NCNN_EXPORT int compile_spirv_module(const char* comp_data, int comp_data_size, const Option& opt, std::vector<uint32_t>& spirv);
|
|
538
|
+
NCNN_EXPORT int compile_spirv_module(int shader_type_index, const Option& opt, std::vector<uint32_t>& spirv);
|
|
539
|
+
|
|
540
|
+
// info from spirv
|
|
541
|
+
class NCNN_EXPORT ShaderInfo
|
|
542
|
+
{
|
|
543
|
+
public:
|
|
544
|
+
int specialization_count;
|
|
545
|
+
int binding_count;
|
|
546
|
+
int push_constant_count;
|
|
547
|
+
|
|
548
|
+
// 0 = null
|
|
549
|
+
// 1 = storage buffer
|
|
550
|
+
// 2 = storage image
|
|
551
|
+
// 3 = combined image sampler
|
|
552
|
+
int binding_types[16]; // 16 is large enough I think ...
|
|
553
|
+
|
|
554
|
+
int reserved_0;
|
|
555
|
+
int reserved_1;
|
|
556
|
+
int reserved_2;
|
|
557
|
+
int reserved_3;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
NCNN_EXPORT int resolve_shader_info(const uint32_t* spv_data, size_t spv_data_size, ShaderInfo& shader_info);
|
|
561
|
+
|
|
562
|
+
} // namespace ncnn
|
|
563
|
+
|
|
564
|
+
#endif // NCNN_VULKAN
|
|
565
|
+
|
|
566
|
+
#endif // NCNN_GPU_H
|