mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +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
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
|
||||||
android
|
android
|
||||||
log
|
log
|
||||||
|
vulkan
|
||||||
)
|
)
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC
|
||||||
android
|
android
|
||||||
log)
|
log
|
||||||
|
vulkan
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MOBILEGL_BUILD_TEST)
|
if (MOBILEGL_BUILD_TEST)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#define MOBILEGL_BACKEND_TYPE_DILIGENT 1
|
#define MOBILEGL_BACKEND_TYPE_DILIGENT 1
|
||||||
#define MOBILEGL_BACKEND_TYPE_MRHI 2
|
#define MOBILEGL_BACKEND_TYPE_MRHI 2
|
||||||
#define MOBILEGL_BACKEND_TYPE_DIRECT_GLES 3
|
#define MOBILEGL_BACKEND_TYPE_DIRECT_GLES 3
|
||||||
|
#define MOBILEGL_BACKEND_TYPE_DIRECT_VULKAN 4
|
||||||
|
|
||||||
// ====================== MobileGL configurations ======================= //
|
// ====================== MobileGL configurations ======================= //
|
||||||
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_INFO
|
#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_INFO
|
||||||
|
|||||||
+2
-2
@@ -17,9 +17,11 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <bitset>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@@ -40,8 +42,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <mutex>
|
|
||||||
#include <bitset>
|
|
||||||
#if __cplusplus >= 202302L && MOBILEGL_LOG_ENABLE_STACKTRACE
|
#if __cplusplus >= 202302L && MOBILEGL_LOG_ENABLE_STACKTRACE
|
||||||
#include <stacktrace>
|
#include <stacktrace>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace MobileGL {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline RendererInfo RendererInfoVulkan = {
|
inline RendererInfo RendererInfoVulkan = {
|
||||||
.RendererName = "MG-DE-Vulkan", // Renderer Name
|
.RendererName = "Unknown", // Renderer Name
|
||||||
.BackendName = "Diligent Engine (Vulkan)", // Backend Name
|
.BackendName = "Diligent Engine (Vulkan)", // Backend Name
|
||||||
.ExtraVendor = Nullopt, // Extra vendor
|
.ExtraVendor = Nullopt, // Extra vendor
|
||||||
.RendererGLInfo =
|
.RendererGLInfo =
|
||||||
@@ -52,7 +52,7 @@ namespace MobileGL {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline RendererInfo RendererInfoMetal = {
|
inline RendererInfo RendererInfoMetal = {
|
||||||
.RendererName = "MG-DE-Metal", // Renderer Name
|
.RendererName = "Unknown", // Renderer Name
|
||||||
.BackendName = "Diligent Engine (Metal)", // Backend Name
|
.BackendName = "Diligent Engine (Metal)", // Backend Name
|
||||||
.ExtraVendor = Nullopt, // Extra vendor
|
.ExtraVendor = Nullopt, // Extra vendor
|
||||||
.RendererGLInfo =
|
.RendererGLInfo =
|
||||||
@@ -86,6 +86,24 @@ namespace MobileGL {
|
|||||||
};
|
};
|
||||||
} // namespace DirectGLES
|
} // 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();
|
void Init();
|
||||||
} // namespace MG_Backend
|
} // namespace MG_Backend
|
||||||
} // namespace MobileGL
|
} // namespace MobileGL
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "Backends.h"
|
#include "Backends.h"
|
||||||
|
#include "MG_Util/Debug/Log.h"
|
||||||
#include "MG_Util/Types.h"
|
#include "MG_Util/Types.h"
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_Util/BackendLoaders/OpenGL/Loader.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,
|
MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::g_glesCaps.version.Major,
|
||||||
MG_External::GLES::g_glesCaps.version.Minor);
|
MG_External::GLES::g_glesCaps.version.Minor);
|
||||||
return result;
|
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
|
#else
|
||||||
MGLOG_W("Unknown backend, skipping backend initialization");
|
MGLOG_W("Unknown backend, skipping backend initialization");
|
||||||
return false;
|
return false;
|
||||||
@@ -73,6 +84,8 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectGLES::RendererInfo);
|
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectGLES::RendererInfo);
|
||||||
|
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_VULKAN
|
||||||
|
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(DirectVulkan::RendererInfo);
|
||||||
#else
|
#else
|
||||||
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Unknown::RendererInfoUnknown);
|
MG_Config::RendererInfoPtr = MakeUnique<RendererInfo>(Unknown::RendererInfoUnknown);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user