renderer_vulkan: Add vulkan initialization code (#6620)
* common: Move dynamic library to common * This is so that video_core can use it * logging: Add vulkan log target * common: Allow defered library loading * Also add some comments to the functions * renderer_vulkan: Add vulkan initialization code * renderer_vulkan: Address feedback
This commit is contained in:
@ -5,35 +5,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace DynamicLibrary {
|
||||
namespace Common {
|
||||
|
||||
class DynamicLibrary {
|
||||
public:
|
||||
explicit DynamicLibrary();
|
||||
explicit DynamicLibrary(std::string_view name, int major = -1, int minor = -1);
|
||||
~DynamicLibrary();
|
||||
|
||||
bool IsLoaded() {
|
||||
/// Returns true if the library is loaded, otherwise false.
|
||||
[[nodiscard]] bool IsLoaded() {
|
||||
return handle != nullptr;
|
||||
}
|
||||
|
||||
std::string_view GetLoadError() {
|
||||
/// Loads (or replaces) the handle with the specified library file name.
|
||||
/// Returns true if the library was loaded and can be used.
|
||||
[[nodiscard]] bool Load(std::string_view filename);
|
||||
|
||||
/// Returns a string containing the last generated load error, if it occured.
|
||||
[[nodiscard]] std::string_view GetLoadError() const {
|
||||
return load_error;
|
||||
}
|
||||
|
||||
/// Obtains the address of the specified symbol, automatically casting to the correct type.
|
||||
template <typename T>
|
||||
T GetSymbol(std::string_view name) {
|
||||
[[nodiscard]] T GetSymbol(std::string_view name) const {
|
||||
return reinterpret_cast<T>(GetRawSymbol(name));
|
||||
}
|
||||
|
||||
static std::string GetLibraryName(std::string_view name, int major = -1, int minor = -1);
|
||||
/// Returns the specified library name in platform-specific format.
|
||||
/// Major/minor versions will not be included if set to -1.
|
||||
/// If libname already contains the "lib" prefix, it will not be added again.
|
||||
[[nodiscard]] static std::string GetLibraryName(std::string_view name, int major = -1,
|
||||
int minor = -1);
|
||||
|
||||
private:
|
||||
void* GetRawSymbol(std::string_view name);
|
||||
void* GetRawSymbol(std::string_view name) const;
|
||||
|
||||
void* handle;
|
||||
std::string load_error;
|
||||
};
|
||||
|
||||
} // namespace DynamicLibrary
|
||||
} // namespace Common
|
||||
|
Reference in New Issue
Block a user