mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (MG_Backend/DirectVulkan): Add DirectVulkan backend.
This commit is contained in:
+4
-1
@@ -286,10 +286,13 @@ if (ANDROID)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
|
||||
android
|
||||
log
|
||||
vulkan
|
||||
)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC
|
||||
android
|
||||
log)
|
||||
log
|
||||
vulkan
|
||||
)
|
||||
endif()
|
||||
|
||||
if (MOBILEGL_BUILD_TEST)
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define MOBILEGL_BACKEND_TYPE_DILIGENT 1
|
||||
#define MOBILEGL_BACKEND_TYPE_MRHI 2
|
||||
#define MOBILEGL_BACKEND_TYPE_DIRECT_GLES 3
|
||||
#define MOBILEGL_BACKEND_TYPE_DIRECT_VULKAN 4
|
||||
|
||||
// ====================== MobileGL configurations ======================= //
|
||||
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_INFO
|
||||
|
||||
+2
-2
@@ -17,9 +17,11 @@
|
||||
#include <map>
|
||||
#include <array>
|
||||
#include <ctime>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <regex>
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
@@ -40,8 +42,6 @@
|
||||
#include <functional>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <bitset>
|
||||
#if __cplusplus >= 202302L && MOBILEGL_LOG_ENABLE_STACKTRACE
|
||||
#include <stacktrace>
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MobileGL {
|
||||
};
|
||||
|
||||
inline RendererInfo RendererInfoVulkan = {
|
||||
.RendererName = "MG-DE-Vulkan", // Renderer Name
|
||||
.RendererName = "Unknown", // Renderer Name
|
||||
.BackendName = "Diligent Engine (Vulkan)", // Backend Name
|
||||
.ExtraVendor = Nullopt, // Extra vendor
|
||||
.RendererGLInfo =
|
||||
@@ -52,7 +52,7 @@ namespace MobileGL {
|
||||
};
|
||||
|
||||
inline RendererInfo RendererInfoMetal = {
|
||||
.RendererName = "MG-DE-Metal", // Renderer Name
|
||||
.RendererName = "Unknown", // Renderer Name
|
||||
.BackendName = "Diligent Engine (Metal)", // Backend Name
|
||||
.ExtraVendor = Nullopt, // Extra vendor
|
||||
.RendererGLInfo =
|
||||
@@ -86,6 +86,24 @@ namespace MobileGL {
|
||||
};
|
||||
} // namespace DirectGLES
|
||||
|
||||
namespace DirectVulkan {
|
||||
inline RendererInfo RendererInfo = {
|
||||
.RendererName = "Magma", // Renderer Name
|
||||
.BackendName = "Direct (Vulkan)", // Backend Name
|
||||
.ExtraVendor = Nullopt, // Extra vendor
|
||||
.RendererGLInfo =
|
||||
{
|
||||
// OpenGL Info
|
||||
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
|
||||
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
|
||||
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
|
||||
V_OpenGL33},
|
||||
.IsCompatibilityProfile = false // Is Compatibility Profile
|
||||
},
|
||||
.BackendCapability = {.AllowVSOnlyPrograms = false} // Backend Capability
|
||||
};
|
||||
} // namespace DirectVulkan
|
||||
|
||||
void Init();
|
||||
} // namespace MG_Backend
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// End of Source File Header
|
||||
|
||||
#include "Backends.h"
|
||||
#include "MG_Util/Debug/Log.h"
|
||||
#include "MG_Util/Types.h"
|
||||
#include <Config.h>
|
||||
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
|
||||
@@ -51,6 +52,16 @@ namespace MobileGL {
|
||||
MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::g_glesCaps.version.Major,
|
||||
MG_External::GLES::g_glesCaps.version.Minor);
|
||||
return result;
|
||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_VULKAN
|
||||
#ifdef __ANDROID__
|
||||
MGLOG_D("DirectVulkan backend loaded on Android");
|
||||
return true;
|
||||
#else
|
||||
MGLOG_E("TODO: add Vulkan loader for non-Android platforms"); // TODO: add Vulkan loader for non-Android
|
||||
// platforms
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#else
|
||||
MGLOG_W("Unknown backend, skipping backend initialization");
|
||||
return false;
|
||||
@@ -73,6 +84,8 @@ namespace MobileGL {
|
||||
}
|
||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectGLES::RendererInfo);
|
||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_VULKAN
|
||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectVulkan::RendererInfo);
|
||||
#else
|
||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Unknown::RendererInfoUnknown);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user