|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using AOT; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Profiling; |
|
|
|
|
|
|
|
public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
{ |
|
|
|
@ -57,6 +58,8 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
Profiler.BeginSample("UploadAliasModel"); |
|
|
|
|
|
|
|
if (header.numFrames > MaxAliasFrames) |
|
|
|
header.numFrames = MaxAliasFrames; |
|
|
|
|
|
|
|
@ -83,11 +86,14 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
fbTextures[i] = header.fbTextures[i * 4].ToStructArray<QGLTexture>(4); |
|
|
|
} |
|
|
|
|
|
|
|
return GetSelf(target).UploadAliasModel( |
|
|
|
int result = GetSelf(target).UploadAliasModel( |
|
|
|
name, header, frameType, poseVertices, |
|
|
|
triangles.ToStructArray<QTriangle>(header.numTriangles), |
|
|
|
stVerts.ToStructArray<QSTVert>(header.numVerts), |
|
|
|
glTextures, fbTextures); |
|
|
|
|
|
|
|
Profiler.EndSample(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
|
|
|
@ -99,7 +105,10 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
if (model == null || model.type != QModelType.Brush) |
|
|
|
return -1; |
|
|
|
|
|
|
|
return GetSelf(target).UploadBrushModel(model); |
|
|
|
Profiler.BeginSample("UploadBrushModel"); |
|
|
|
int result = GetSelf(target).UploadBrushModel(model); |
|
|
|
Profiler.EndSample(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
|
|
|
@ -111,7 +120,10 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
if (model == null || model.type != QModelType.Brush) |
|
|
|
return -1; |
|
|
|
|
|
|
|
return GetSelf(target).UploadWorldModel(model); |
|
|
|
Profiler.BeginSample("UploadWorldModel"); |
|
|
|
int result = GetSelf(target).UploadWorldModel(model); |
|
|
|
Profiler.EndSample(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
|
|
|
@ -120,9 +132,14 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
[MonoPInvokeCallback(typeof(UploadTextureCallback))] |
|
|
|
private static bool Callback_UploadTexture(IntPtr target, QGLTexture texture, IntPtr data, ref uint texNum) |
|
|
|
{ |
|
|
|
Profiler.BeginSample("UploadTexture"); |
|
|
|
|
|
|
|
byte[] dataBytes = new byte[texture.width * texture.height * 4]; // 32 bits per pixel
|
|
|
|
Marshal.Copy(data, dataBytes, 0, dataBytes.Length); |
|
|
|
return GetSelf(target).UploadTexture(texture, dataBytes, ref texNum); |
|
|
|
bool result = GetSelf(target).UploadTexture(texture, dataBytes, ref texNum); |
|
|
|
|
|
|
|
Profiler.EndSample(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private readonly byte[] lightmapBytes = new byte[QConstants.LightmapBlockWidth * QConstants.LightmapBlockHeight * 4]; // 32 bits per pixel
|
|
|
|
@ -133,10 +150,15 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
[MonoPInvokeCallback(typeof(UploadLightmapCallback))] |
|
|
|
private static bool Callback_UploadLightmap(IntPtr target, int lmap, IntPtr data) |
|
|
|
{ |
|
|
|
Profiler.BeginSample("UploadLightmap"); |
|
|
|
|
|
|
|
// TODO: this is a fairly pointless additional data copy step; we could probably make this faster by wrapping the IntPtr directly into a NativeArray
|
|
|
|
var self = GetSelf(target); |
|
|
|
Marshal.Copy(data, self.lightmapBytes, 0, self.lightmapBytes.Length); |
|
|
|
return self.UploadLightmap(lmap, QConstants.LightmapBlockWidth, QConstants.LightmapBlockHeight, self.lightmapBytes); |
|
|
|
bool result = self.UploadLightmap(lmap, QConstants.LightmapBlockWidth, QConstants.LightmapBlockHeight, self.lightmapBytes); |
|
|
|
|
|
|
|
Profiler.EndSample(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
|
|
|
@ -145,6 +167,8 @@ public partial class RenderModule: CallbackHandler<RenderModule> |
|
|
|
[MonoPInvokeCallback(typeof(SetupViewCallback))] |
|
|
|
private static void Callback_SetupView(IntPtr target, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf) |
|
|
|
{ |
|
|
|
Profiler.BeginSample("SetupView"); |
|
|
|
GetSelf(target).SetupView(origin, angles, viewLeaf); |
|
|
|
Profiler.EndSample(); |
|
|
|
} |
|
|
|
} |