This commit is contained in:
2025-12-20 23:02:42 +02:00
parent e3f5af530b
commit 8631b389c1
5 changed files with 43 additions and 20 deletions

View File

@@ -4,8 +4,9 @@
#if defined(__clang__) #if defined(__clang__)
#define DLLEXPORT __attribute__ ((__visibility__ ("default"))) #define DLLEXPORT __attribute__((__visibility__("default")))
#define DLLIMPORT #define DLLIMPORT
#define USED __attribute__((used))
#define THREADLOCAL __thread #define THREADLOCAL __thread
#define STDCALL __attribute__((stdcall)) #define STDCALL __attribute__((stdcall))
#define CDECL __attribute__((cdecl)) #define CDECL __attribute__((cdecl))
@@ -19,7 +20,7 @@
#define PACK_BEGIN() #define PACK_BEGIN()
#define PACK_END() __attribute__((__packed__)) #define PACK_END() __attribute__((__packed__))
#define ALIGN_BEGIN(_align) #define ALIGN_BEGIN(_align)
#define ALIGN_END(_align) __attribute__( (aligned(_align) ) ) #define ALIGN_END(_align) __attribute__((aligned(_align)))
#define OFFSET_OF(X, Y) __builtin_offsetof(X, Y) #define OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS \ #define PRAGMA_DISABLE_DEPRECATION_WARNINGS \
_Pragma("clang diagnostic push") \ _Pragma("clang diagnostic push") \
@@ -37,8 +38,9 @@
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define DLLEXPORT __attribute__ ((__visibility__ ("default"))) #define DLLEXPORT __attribute__((__visibility__("default")))
#define DLLIMPORT #define DLLIMPORT
#define USED __attribute__((used))
#define THREADLOCAL __thread #define THREADLOCAL __thread
#define STDCALL __attribute__((stdcall)) #define STDCALL __attribute__((stdcall))
#define CDECL __attribute__((cdecl)) #define CDECL __attribute__((cdecl))
@@ -52,7 +54,7 @@
#define PACK_BEGIN() #define PACK_BEGIN()
#define PACK_END() __attribute__((__packed__)) #define PACK_END() __attribute__((__packed__))
#define ALIGN_BEGIN(_align) #define ALIGN_BEGIN(_align)
#define ALIGN_END(_align) __attribute__( (aligned(_align) ) ) #define ALIGN_END(_align) __attribute__((aligned(_align)))
#define OFFSET_OF(X, Y) __builtin_offsetof(X, Y) #define OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS #define PRAGMA_DISABLE_DEPRECATION_WARNINGS
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS #define PRAGMA_ENABLE_DEPRECATION_WARNINGS
@@ -67,6 +69,7 @@
#define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
#define DLLIMPORT __declspec(dllimport) #define DLLIMPORT __declspec(dllimport)
#define USED
#define THREADLOCAL __declspec(thread) #define THREADLOCAL __declspec(thread)
#define STDCALL __stdcall #define STDCALL __stdcall
#define CDECL __cdecl #define CDECL __cdecl

View File

@@ -450,7 +450,7 @@ public:
/// <summary> /// <summary>
/// The high-level renderer context. Used to collect the draw calls for the scene rendering. Can be used to perform a custom rendering. /// The high-level renderer context. Used to collect the draw calls for the scene rendering. Can be used to perform a custom rendering.
/// </summary> /// </summary>
API_STRUCT(NoDefault) struct RenderContext API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContext
{ {
DECLARE_SCRIPTING_TYPE_MINIMAL(RenderContext); DECLARE_SCRIPTING_TYPE_MINIMAL(RenderContext);
@@ -491,7 +491,7 @@ API_STRUCT(NoDefault) struct RenderContext
/// <summary> /// <summary>
/// The high-level renderer context batch that encapsulates multiple rendering requests within a single task (eg. optimize main view scene rendering and shadow projections at once). /// The high-level renderer context batch that encapsulates multiple rendering requests within a single task (eg. optimize main view scene rendering and shadow projections at once).
/// </summary> /// </summary>
API_STRUCT(NoDefault) struct RenderContextBatch API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContextBatch
{ {
DECLARE_SCRIPTING_TYPE_MINIMAL(RenderContextBatch); DECLARE_SCRIPTING_TYPE_MINIMAL(RenderContextBatch);

View File

@@ -112,7 +112,7 @@ void LinuxInput::UpdateState()
if (time - lastUpdateTime > 1.0f) if (time - lastUpdateTime > 1.0f)
{ {
PROFILE_CPU_NAMED("Input.ScanGamepads"); PROFILE_CPU_NAMED("Input.ScanGamepads");
DetectGamePads(); //DetectGamePads();
lastUpdateTime = time; lastUpdateTime = time;
for (int i = 0; i < foundGamepads; i++) for (int i = 0; i < foundGamepads; i++)
{ {

View File

@@ -760,6 +760,11 @@ namespace Flax.Build.Bindings
genericArgs += ", " + typeInfo.GenericArgs[1]; genericArgs += ", " + typeInfo.GenericArgs[1];
result = $"Array<{genericArgs}>({result})"; result = $"Array<{genericArgs}>({result})";
} }
else if (arrayApiType?.Name == "bool")
{
type = "bool*";
result = "Array<bool>({0}, {1})";
}
return result; return result;
} }
@@ -1234,8 +1239,12 @@ namespace Flax.Build.Bindings
callParams += ", "; callParams += ", ";
separator = true; separator = true;
var name = parameterInfo.Name; var name = parameterInfo.Name;
var countParamName = $"__{parameterInfo.Name}Count";
if (CppParamsThatNeedConversion[i] && (!FindApiTypeInfo(buildData, parameterInfo.Type, caller)?.IsStruct ?? false)) if (CppParamsThatNeedConversion[i] && (!FindApiTypeInfo(buildData, parameterInfo.Type, caller)?.IsStruct ?? false))
{
name = '*' + name; name = '*' + name;
countParamName = '*' + countParamName;
}
string param = string.Empty; string param = string.Empty;
if (string.IsNullOrWhiteSpace(CppParamsWrappersCache[i])) if (string.IsNullOrWhiteSpace(CppParamsWrappersCache[i]))
@@ -1248,7 +1257,7 @@ namespace Flax.Build.Bindings
else else
{ {
// Convert value // Convert value
param += string.Format(CppParamsWrappersCache[i], name); param += string.Format(CppParamsWrappersCache[i], name, countParamName);
} }
// Special case for output result parameters that needs additional converting from native to managed format (such as non-POD structures or output array parameter) // Special case for output result parameters that needs additional converting from native to managed format (such as non-POD structures or output array parameter)
@@ -1283,11 +1292,18 @@ namespace Flax.Build.Bindings
callParams += parameterInfo.Name; callParams += parameterInfo.Name;
callParams += "Temp"; callParams += "Temp";
} }
// Instruct for more optoimized value move operation // Instruct for more optimized value move operation
else if (parameterInfo.Type.IsMoveRef) else if (parameterInfo.Type.IsMoveRef)
{ {
callParams += $"MoveTemp({param})"; callParams += $"MoveTemp({param})";
} }
else if (parameterInfo.Type.IsRef && !parameterInfo.Type.IsConst)
{
// Non-const lvalue reference parameters needs to be passed via temporary value
contents.Append(indent).AppendFormat("auto {0}Temp = {1};", parameterInfo.Name, param).AppendLine();
callParams += parameterInfo.Name;
callParams += "Temp";
}
else else
{ {
callParams += param; callParams += param;
@@ -2987,16 +3003,19 @@ namespace Flax.Build.Bindings
header.Append("template<>").AppendLine(); header.Append("template<>").AppendLine();
header.AppendFormat("struct MConverter<{0}>", fullName).AppendLine(); header.AppendFormat("struct MConverter<{0}>", fullName).AppendLine();
header.Append('{').AppendLine(); header.Append('{').AppendLine();
header.AppendFormat(" MObject* Box(const {0}& data, const MClass* klass)", fullName).AppendLine();
header.AppendFormat(" DLLEXPORT USED MObject* Box(const {0}& data, const MClass* klass)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.Append(" auto managed = ToManaged(data);").AppendLine(); header.Append(" auto managed = ToManaged(data);").AppendLine();
header.Append(" return MCore::Object::Box((void*)&managed, klass);").AppendLine(); header.Append(" return MCore::Object::Box((void*)&managed, klass);").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" void Unbox({0}& result, MObject* data)", fullName).AppendLine();
header.AppendFormat(" DLLEXPORT USED void Unbox({0}& result, MObject* data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.AppendFormat(" result = ToNative(*reinterpret_cast<{0}*>(MCore::Object::Unbox(data)));", wrapperName).AppendLine(); header.AppendFormat(" result = ToNative(*reinterpret_cast<{0}*>(MCore::Object::Unbox(data)));", wrapperName).AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" void ToManagedArray(MArray* result, const Span<{0}>& data)", fullName).AppendLine();
header.AppendFormat(" DLLEXPORT USED void ToManagedArray(MArray* result, const Span<{0}>& data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.AppendFormat(" MClass* klass = {0}::TypeInitializer.GetClass();", fullName).AppendLine(); header.AppendFormat(" MClass* klass = {0}::TypeInitializer.GetClass();", fullName).AppendLine();
header.AppendFormat(" {0}* resultPtr = ({0}*)MCore::Array::GetAddress(result);", wrapperName).AppendLine(); header.AppendFormat(" {0}* resultPtr = ({0}*)MCore::Array::GetAddress(result);", wrapperName).AppendLine();
@@ -3006,7 +3025,8 @@ namespace Flax.Build.Bindings
header.Append(" MCore::GC::WriteValue(&resultPtr[i], &managed, 1, klass);").AppendLine(); header.Append(" MCore::GC::WriteValue(&resultPtr[i], &managed, 1, klass);").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" void ToNativeArray(Span<{0}>& result, const MArray* data)", fullName).AppendLine();
header.AppendFormat(" DLLEXPORT USED void ToNativeArray(Span<{0}>& result, const MArray* data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.AppendFormat(" {0}* dataPtr = ({0}*)MCore::Array::GetAddress(data);", wrapperName).AppendLine(); header.AppendFormat(" {0}* dataPtr = ({0}*)MCore::Array::GetAddress(data);", wrapperName).AppendLine();
header.Append(" for (int32 i = 0; i < result.Length(); i++)").AppendLine(); header.Append(" for (int32 i = 0; i < result.Length(); i++)").AppendLine();
@@ -3098,7 +3118,7 @@ namespace Flax.Build.Bindings
header.AppendFormat("struct MConverter<{0}>", fullName).AppendLine(); header.AppendFormat("struct MConverter<{0}>", fullName).AppendLine();
header.Append('{').AppendLine(); header.Append('{').AppendLine();
header.AppendFormat(" static MObject* Box(const {0}& data, const MClass* klass)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED static MObject* Box(const {0}& data, const MClass* klass)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.Append(" MObject* obj = MCore::Object::New(klass);").AppendLine(); header.Append(" MObject* obj = MCore::Object::New(klass);").AppendLine();
for (var i = 0; i < fields.Count; i++) for (var i = 0; i < fields.Count; i++)
@@ -3118,13 +3138,13 @@ namespace Flax.Build.Bindings
header.Append(" return obj;").AppendLine(); header.Append(" return obj;").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" static MObject* Box(const {0}& data)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED static MObject* Box(const {0}& data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.AppendFormat(" MClass* klass = {0}::TypeInitializer.GetClass();", fullName).AppendLine(); header.AppendFormat(" MClass* klass = {0}::TypeInitializer.GetClass();", fullName).AppendLine();
header.Append(" return Box(data, klass);").AppendLine(); header.Append(" return Box(data, klass);").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" static void Unbox({0}& result, MObject* obj)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED static void Unbox({0}& result, MObject* obj)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.Append(" MClass* klass = MCore::Object::GetClass(obj);").AppendLine(); header.Append(" MClass* klass = MCore::Object::GetClass(obj);").AppendLine();
header.Append(" void* v = nullptr;").AppendLine(); header.Append(" void* v = nullptr;").AppendLine();
@@ -3146,20 +3166,20 @@ namespace Flax.Build.Bindings
} }
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" static {0} Unbox(MObject* data)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED static {0} Unbox(MObject* data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.AppendFormat(" {0} result;", fullName).AppendLine(); header.AppendFormat(" {0} result;", fullName).AppendLine();
header.Append(" Unbox(result, data);").AppendLine(); header.Append(" Unbox(result, data);").AppendLine();
header.Append(" return result;").AppendLine(); header.Append(" return result;").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" void ToManagedArray(MArray* result, const Span<{0}>& data)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED void ToManagedArray(MArray* result, const Span<{0}>& data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.Append(" for (int32 i = 0; i < data.Length(); i++)").AppendLine(); header.Append(" for (int32 i = 0; i < data.Length(); i++)").AppendLine();
header.Append(" MCore::GC::WriteArrayRef(result, Box(data[i]), i);").AppendLine(); header.Append(" MCore::GC::WriteArrayRef(result, Box(data[i]), i);").AppendLine();
header.Append(" }").AppendLine(); header.Append(" }").AppendLine();
header.AppendFormat(" void ToNativeArray(Span<{0}>& result, const MArray* data)", fullName).AppendLine(); header.AppendFormat(" DLLEXPORT USED void ToNativeArray(Span<{0}>& result, const MArray* data)", fullName).AppendLine();
header.Append(" {").AppendLine(); header.Append(" {").AppendLine();
header.Append(" MObject** dataPtr = (MObject**)MCore::Array::GetAddress(data);").AppendLine(); header.Append(" MObject** dataPtr = (MObject**)MCore::Array::GetAddress(data);").AppendLine();
header.Append(" for (int32 i = 0; i < result.Length(); i++)").AppendLine(); header.Append(" for (int32 i = 0; i < result.Length(); i++)").AppendLine();

View File

@@ -282,7 +282,7 @@ namespace Flax.Build
dotnetRuntimeVersions = MergeVersions(dotnetRuntimeVersions, GetVersions(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App"))); dotnetRuntimeVersions = MergeVersions(dotnetRuntimeVersions, GetVersions(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App")));
dotnetSdkVersions = dotnetSdkVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "sdk", x, ".version"))); dotnetSdkVersions = dotnetSdkVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "sdk", x, ".version")));
dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App", x, ".version"))); dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => File.Exists(Path.Combine(dotnetPath, "shared", "Microsoft.NETCore.App", x, "System.dll")));
dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => Directory.Exists(Path.Combine(dotnetPath, "packs", "Microsoft.NETCore.App.Ref", x))); dotnetRuntimeVersions = dotnetRuntimeVersions.Where(x => Directory.Exists(Path.Combine(dotnetPath, "packs", "Microsoft.NETCore.App.Ref", x)));
dotnetSdkVersions = dotnetSdkVersions.OrderByDescending(ParseVersion); dotnetSdkVersions = dotnetSdkVersions.OrderByDescending(ParseVersion);