Browse Source

Merge branch 'master' into console

console
Nico de Poel 5 years ago
parent
commit
6f290779c4
  1. 8
      .gitignore
  2. 23
      Assets/Plugins/FMOD/Platform.cs
  3. 11
      Assets/Plugins/FMOD/Platform.cs.meta
  4. 1794
      Assets/Plugins/FMOD/fmod.cs
  5. 47
      Assets/Plugins/FMOD/fmod_dsp.cs
  6. BIN
      Assets/Plugins/windows/x86/fmod.dll
  7. BIN
      Assets/Plugins/windows/x86/fmodL.dll
  8. BIN
      Assets/Plugins/windows/x86_64/fmod.dll
  9. BIN
      Assets/Plugins/windows/x86_64/fmodL.dll
  10. 8
      Assets/Scenes/SplitScreenTest.unity
  11. 8
      Assets/Scripts/CallbackHandler.cs
  12. 45
      Assets/Scripts/Modules/GameModule.Interop.cs
  13. 10
      Assets/Scripts/Modules/GameModule.cs
  14. 66
      Assets/Scripts/Modules/RenderModule.Interop.cs
  15. 76
      Assets/Scripts/Modules/SystemModule.Interop.cs
  16. 4
      Assets/Scripts/SplitScreenTest.cs
  17. 24
      Assets/Scripts/UniQuake.Interop.cs
  18. 13
      Assets/Scripts/UniQuake.cs
  19. 232
      engine/FMOD/inc/fmod.cs
  20. 3
      engine/FMOD/inc/fmod.h
  21. 3
      engine/FMOD/inc/fmod.hpp
  22. 114
      engine/FMOD/inc/fmod_common.h
  23. 47
      engine/FMOD/inc/fmod_dsp.cs
  24. 36
      engine/FMOD/inc/fmod_dsp_effects.h
  25. 2
      engine/FMOD/inc/fmod_output.h
  26. BIN
      engine/FMOD/lib/x64/fmod.dll
  27. BIN
      engine/FMOD/lib/x64/fmodL.dll
  28. BIN
      engine/FMOD/lib/x64/fmodL_vc.lib
  29. BIN
      engine/FMOD/lib/x64/fmod_vc.lib
  30. BIN
      engine/FMOD/lib/x86/fmod.dll
  31. BIN
      engine/FMOD/lib/x86/fmodL.dll
  32. BIN
      engine/FMOD/lib/x86/fmodL_vc.lib
  33. BIN
      engine/FMOD/lib/x86/fmod_vc.lib
  34. BIN
      engine/FMOD/lib/x86/libfmod.a
  35. BIN
      engine/FMOD/lib/x86/libfmodL.a
  36. 31
      engine/UniQuake/game_uniquake.c
  37. 35
      engine/UniQuake/gl_uniquake.c
  38. 61
      engine/UniQuake/sys_uniquake.c
  39. 6
      engine/UniQuake/uniquake.c
  40. 9
      engine/UniQuake/uniquake.h

8
.gitignore

@ -14,10 +14,6 @@ mods/
*.DotSettings *.DotSettings
*.orig *.orig
Debug Portable/ Debug Portable/
BuildPS4/
ORBIS_Debug/
Prospero_Debug/
Assets/StreamingAssets/ Assets/StreamingAssets/
BuildPS5/
BuildXB1/
BuildXSX/
Build*/
*_Debug/

23
Assets/Plugins/FMOD/Platform.cs

@ -0,0 +1,23 @@
namespace FMOD
{
public partial class VERSION
{
#if DEVELOPMENT_BUILD
public const string dllSuffix = "L";
#else
public const string dllSuffix = "";
#endif
#if UNITY_EDITOR
public const string dll = "fmodL";
#elif UNITY_STANDALONE_WIN
public const string dll = "fmod" + dllSuffix;
#elif UNITY_WSA
public const string dll = "fmod" + dllSuffix;
#elif UNITY_STANDALONE_LINUX
public const string dll = "fmod" + dllSuffix;
#elif UNITY_STANDALONE_OSX
public const string dll = "fmod" + dllSuffix;
#endif
}
}

11
Assets/Plugins/FMOD/Platform.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82997004563d9de42b3aeedd2da0153b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1794
Assets/Plugins/FMOD/fmod.cs
File diff suppressed because it is too large
View File

47
Assets/Plugins/FMOD/fmod_dsp.cs

@ -72,10 +72,10 @@ namespace FMOD
/* /*
DSP functions DSP functions
*/ */
public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, StringWrapper file, int line, StringWrapper function, StringWrapper format);
public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr format);
public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate); public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate);
public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize); public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize);
public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output); public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output);
@ -306,6 +306,27 @@ namespace FMOD
} }
} }
[StructLayout(LayoutKind.Sequential)]
public struct DSP_LOUDNESS_METER_INFO_TYPE
{
public float momentaryloudness;
public float shorttermloudness;
public float integratedloudness;
public float loudness10thpercentile;
public float loudness95thpercentile;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 66)]
public float[] loudnesshistogram;
public float maxtruepeak;
public float maxmomentaryloudness;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_LOUDNESS_METER_WEIGHTING_TYPE
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public float[] channelweight;
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct DSP_DESCRIPTION public struct DSP_DESCRIPTION
{ {
@ -718,6 +739,24 @@ namespace FMOD
DOMINANT_FREQ DOMINANT_FREQ
} }
public enum DSP_LOUDNESS_METER : int
{
STATE,
WEIGHTING,
INFO
}
public enum DSP_LOUDNESS_METER_STATE_TYPE : int
{
RESET_INTEGRATED = -3,
RESET_MAXPEAK = -2,
RESET_ALL = -1,
PAUSED = 0,
ANALYZING = 1
}
public enum DSP_ENVELOPEFOLLOWER : int public enum DSP_ENVELOPEFOLLOWER : int
{ {
ATTACK, ATTACK,

BIN
Assets/Plugins/windows/x86/fmod.dll

BIN
Assets/Plugins/windows/x86/fmodL.dll

BIN
Assets/Plugins/windows/x86_64/fmod.dll

BIN
Assets/Plugins/windows/x86_64/fmodL.dll

8
Assets/Scenes/SplitScreenTest.unity

@ -158,22 +158,22 @@ MonoBehaviour:
baseGame: 0 baseGame: 0
modPath: modPath:
arguments: arguments:
libraryName:
playerNumber: 1
- mainCamera: {fileID: 821010101} - mainCamera: {fileID: 821010101}
baseGame: 1 baseGame: 1
modPath: modPath:
arguments: arguments:
libraryName: uniquake2
playerNumber: 2
- mainCamera: {fileID: 1512894441} - mainCamera: {fileID: 1512894441}
baseGame: 2 baseGame: 2
modPath: modPath:
arguments: arguments:
libraryName: uniquake3
playerNumber: 3
- mainCamera: {fileID: 506815091} - mainCamera: {fileID: 506815091}
baseGame: 0 baseGame: 0
modPath: dopa modPath: dopa
arguments: arguments:
libraryName: uniquake4
playerNumber: 4
visualStyles: visualStyles:
- {fileID: 11400000, guid: d187fe54fb9a3e047bf4cec083877e72, type: 2} - {fileID: 11400000, guid: d187fe54fb9a3e047bf4cec083877e72, type: 2}
--- !u!4 &157597865 --- !u!4 &157597865

8
Assets/Scripts/CallbackHandler.cs

@ -8,9 +8,9 @@ public abstract class CallbackHandler<THandler>
private GCHandle selfHandle; private GCHandle selfHandle;
private GCHandle callbacksHandle; private GCHandle callbacksHandle;
public IntPtr CallbacksPtr => callbacksHandle.AddrOfPinnedObject();
public IntPtr ContextPtr => GCHandle.ToIntPtr(selfHandle);
protected IntPtr TargetPtr => GCHandle.ToIntPtr(selfHandle);
public IntPtr CallbacksPtr => callbacksHandle.AddrOfPinnedObject();
protected CallbackHandler() protected CallbackHandler()
{ {
@ -36,8 +36,8 @@ public abstract class CallbackHandler<THandler>
callbacksHandle = GCHandle.Alloc(callbacks, GCHandleType.Pinned); callbacksHandle = GCHandle.Alloc(callbacks, GCHandleType.Pinned);
} }
protected static THandler GetSelf(IntPtr target)
protected static THandler GetSelf(IntPtr context)
{ {
return (THandler)GCHandle.FromIntPtr(target).Target;
return (THandler)GCHandle.FromIntPtr(context).Target;
} }
} }

45
Assets/Scripts/Modules/GameModule.Interop.cs

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using AOT; using AOT;
using UnityEngine; using UnityEngine;
using UnityEngine.Profiling;
public partial class GameModule : CallbackHandler<GameModule> public partial class GameModule : CallbackHandler<GameModule>
{ {
@ -11,8 +12,6 @@ public partial class GameModule : CallbackHandler<GameModule>
{ {
var callbacks = new Callbacks var callbacks = new Callbacks
{ {
target = TargetPtr,
SetEntityModel = CreateCallback<GameSetEntityModelCallback>(Callback_GameSetEntityModel), SetEntityModel = CreateCallback<GameSetEntityModelCallback>(Callback_GameSetEntityModel),
SetEntityTransform = CreateCallback<GameSetEntityTransformCallback>(Callback_GameSetEntityTransform), SetEntityTransform = CreateCallback<GameSetEntityTransformCallback>(Callback_GameSetEntityTransform),
RemoveEntity = CreateCallback<GameRemoveEntityCallback>(Callback_GameRemoveEntity), RemoveEntity = CreateCallback<GameRemoveEntityCallback>(Callback_GameRemoveEntity),
@ -29,8 +28,6 @@ public partial class GameModule : CallbackHandler<GameModule>
[StructLayout(LayoutKind.Sequential, Pack = 0)] [StructLayout(LayoutKind.Sequential, Pack = 0)]
private class Callbacks private class Callbacks
{ {
public IntPtr target;
public IntPtr SetEntityModel; public IntPtr SetEntityModel;
public IntPtr SetEntityTransform; public IntPtr SetEntityTransform;
public IntPtr RemoveEntity; public IntPtr RemoveEntity;
@ -39,47 +36,57 @@ public partial class GameModule : CallbackHandler<GameModule>
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntityModelCallback(IntPtr target, int entityNum, [MarshalAs(UnmanagedType.LPStr)] string modelName);
private delegate void GameSetEntityModelCallback(IntPtr context, int entityNum, [MarshalAs(UnmanagedType.LPStr)] string modelName);
[MonoPInvokeCallback(typeof(GameSetEntityModelCallback))] [MonoPInvokeCallback(typeof(GameSetEntityModelCallback))]
private static void Callback_GameSetEntityModel(IntPtr target, int entityNum, string modelName)
private static void Callback_GameSetEntityModel(IntPtr context, int entityNum, string modelName)
{ {
GetSelf(target).SetEntityModel(entityNum, modelName);
Profiler.BeginSample("GameSetEntityModel");
GetSelf(context).SetEntityModel(entityNum, modelName);
Profiler.EndSample();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntityTransformCallback(IntPtr target, int entityNum, ref QVec3 origin, ref QVec3 angles);
private delegate void GameSetEntityTransformCallback(IntPtr context, int entityNum, ref QVec3 origin, ref QVec3 angles);
[MonoPInvokeCallback(typeof(GameSetEntityTransformCallback))] [MonoPInvokeCallback(typeof(GameSetEntityTransformCallback))]
private static void Callback_GameSetEntityTransform(IntPtr target, int entityNum, ref QVec3 origin, ref QVec3 angles)
private static void Callback_GameSetEntityTransform(IntPtr context, int entityNum, ref QVec3 origin, ref QVec3 angles)
{ {
GetSelf(target).SetEntityTransform(entityNum, origin, angles);
Profiler.BeginSample("GameSetEntityTransform");
GetSelf(context).SetEntityTransform(entityNum, origin, angles);
Profiler.EndSample();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameRemoveEntityCallback(IntPtr target, int entityNum);
private delegate void GameRemoveEntityCallback(IntPtr context, int entityNum);
[MonoPInvokeCallback(typeof(GameRemoveEntityCallback))] [MonoPInvokeCallback(typeof(GameRemoveEntityCallback))]
private static void Callback_GameRemoveEntity(IntPtr target, int entityNum)
private static void Callback_GameRemoveEntity(IntPtr context, int entityNum)
{ {
GetSelf(target).RemoveEntity(entityNum);
Profiler.BeginSample("GameRemoveEntity");
GetSelf(context).RemoveEntity(entityNum);
Profiler.EndSample();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameUpdateEntityAnimationCallback(IntPtr target, int entityNum, int pose1, int pose2, float blend);
private delegate void GameUpdateEntityAnimationCallback(IntPtr context, int entityNum, int pose1, int pose2, float blend);
[MonoPInvokeCallback(typeof(GameUpdateEntityAnimationCallback))] [MonoPInvokeCallback(typeof(GameUpdateEntityAnimationCallback))]
private static void Callback_GameUpdateEntityAnimation(IntPtr target, int entityNum, int pose1, int pose2, float blend)
private static void Callback_GameUpdateEntityAnimation(IntPtr context, int entityNum, int pose1, int pose2, float blend)
{ {
GetSelf(target).UpdateEntityAnimation(entityNum, pose1, pose2, blend);
Profiler.BeginSample("GameUpdateEntityAnimation");
GetSelf(context).UpdateEntityAnimation(entityNum, pose1, pose2, blend);
Profiler.EndSample();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntitySkinCallback(IntPtr target, int entityNum, int skinNum);
private delegate void GameSetEntitySkinCallback(IntPtr context, int entityNum, int skinNum);
[MonoPInvokeCallback(typeof(GameSetEntitySkinCallback))] [MonoPInvokeCallback(typeof(GameSetEntitySkinCallback))]
private static void Callback_GameSetEntitySkin(IntPtr target, int entityNum, int skinNum)
private static void Callback_GameSetEntitySkin(IntPtr context, int entityNum, int skinNum)
{ {
GetSelf(target).SetEntitySkin(entityNum, skinNum);
Profiler.BeginSample("GameSetEntitySkin");
GetSelf(context).SetEntitySkin(entityNum, skinNum);
Profiler.EndSample();
} }
} }

10
Assets/Scripts/Modules/GameModule.cs

@ -16,7 +16,7 @@ public partial class GameModule
{ {
if (string.IsNullOrEmpty(modelName)) if (string.IsNullOrEmpty(modelName))
{ {
uq.GameState.GetEntity(entityNum)?.ClearModel();
uq.GameState.GetEntity(entityNum).ClearModel();
return; return;
} }
@ -41,7 +41,7 @@ public partial class GameModule
if (modelName.EndsWith(".spr")) if (modelName.EndsWith(".spr"))
{ {
// TODO: sprite // TODO: sprite
uq.GameState.GetEntity(entityNum)?.ClearModel();
uq.GameState.GetEntity(entityNum).ClearModel();
return; return;
} }
@ -50,7 +50,7 @@ public partial class GameModule
private void SetEntityTransform(int entityNum, QVec3 origin, QVec3 angles) private void SetEntityTransform(int entityNum, QVec3 origin, QVec3 angles)
{ {
uq.GameState.GetEntity(entityNum)?.SetTransform(origin.ToUnityPosition(), angles.ToUnityRotation());
uq.GameState.GetEntity(entityNum).SetTransform(origin.ToUnityPosition(), angles.ToUnityRotation());
} }
private void RemoveEntity(int entityNum) private void RemoveEntity(int entityNum)
@ -60,11 +60,11 @@ public partial class GameModule
private void UpdateEntityAnimation(int entityNum, int pose1, int pose2, float blend) private void UpdateEntityAnimation(int entityNum, int pose1, int pose2, float blend)
{ {
uq.GameState.GetEntity(entityNum)?.UpdateAnimation(pose1, pose2, blend);
uq.GameState.GetEntity(entityNum).UpdateAnimation(pose1, pose2, blend);
} }
private void SetEntitySkin(int entityNum, int skinNum) private void SetEntitySkin(int entityNum, int skinNum)
{ {
uq.GameState.GetEntity(entityNum)?.SetSkin(skinNum);
uq.GameState.GetEntity(entityNum).SetSkin(skinNum);
} }
} }

66
Assets/Scripts/Modules/RenderModule.Interop.cs

@ -2,6 +2,7 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using AOT; using AOT;
using UnityEngine; using UnityEngine;
using UnityEngine.Profiling;
public partial class RenderModule: CallbackHandler<RenderModule> public partial class RenderModule: CallbackHandler<RenderModule>
{ {
@ -11,8 +12,6 @@ public partial class RenderModule: CallbackHandler<RenderModule>
{ {
var callbacks = new Callbacks var callbacks = new Callbacks
{ {
target = TargetPtr,
UploadAliasModel = CreateCallback<UploadAliasModelCallback>(Callback_UploadAliasModel), UploadAliasModel = CreateCallback<UploadAliasModelCallback>(Callback_UploadAliasModel),
UploadBrushModel = CreateCallback<UploadBrushModelCallback>(Callback_UploadBrushModel), UploadBrushModel = CreateCallback<UploadBrushModelCallback>(Callback_UploadBrushModel),
UploadWorldModel = CreateCallback<UploadWorldModelCallback>(Callback_UploadWorldModel), UploadWorldModel = CreateCallback<UploadWorldModelCallback>(Callback_UploadWorldModel),
@ -31,8 +30,6 @@ public partial class RenderModule: CallbackHandler<RenderModule>
[StructLayout(LayoutKind.Sequential, Pack = 0)] [StructLayout(LayoutKind.Sequential, Pack = 0)]
private class Callbacks private class Callbacks
{ {
public IntPtr target;
public IntPtr UploadAliasModel; public IntPtr UploadAliasModel;
public IntPtr UploadBrushModel; public IntPtr UploadBrushModel;
public IntPtr UploadWorldModel; public IntPtr UploadWorldModel;
@ -42,12 +39,12 @@ public partial class RenderModule: CallbackHandler<RenderModule>
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate int UploadAliasModelCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string name,
private delegate int UploadAliasModelCallback(IntPtr context, [MarshalAs(UnmanagedType.LPStr)] string name,
QAliasHeader header, QAliasFrameType frameType, IntPtr frames, QAliasHeader header, QAliasFrameType frameType, IntPtr frames,
[MarshalAs(UnmanagedType.LPArray, SizeConst = MaxAliasFrames)] IntPtr[] poseVerts, IntPtr triangles, IntPtr stVerts); [MarshalAs(UnmanagedType.LPArray, SizeConst = MaxAliasFrames)] IntPtr[] poseVerts, IntPtr triangles, IntPtr stVerts);
[MonoPInvokeCallback(typeof(UploadAliasModelCallback))] [MonoPInvokeCallback(typeof(UploadAliasModelCallback))]
private static int Callback_UploadAliasModel(IntPtr target,
private static int Callback_UploadAliasModel(IntPtr context,
string name, QAliasHeader header, QAliasFrameType frameType, IntPtr frames, string name, QAliasHeader header, QAliasFrameType frameType, IntPtr frames,
IntPtr[] poseVerts, IntPtr triangles, IntPtr stVerts) IntPtr[] poseVerts, IntPtr triangles, IntPtr stVerts)
{ {
@ -57,6 +54,8 @@ public partial class RenderModule: CallbackHandler<RenderModule>
return 0; return 0;
} }
Profiler.BeginSample("UploadAliasModel");
if (header.numFrames > MaxAliasFrames) if (header.numFrames > MaxAliasFrames)
header.numFrames = MaxAliasFrames; header.numFrames = MaxAliasFrames;
@ -83,68 +82,89 @@ public partial class RenderModule: CallbackHandler<RenderModule>
fbTextures[i] = header.fbTextures[i * 4].ToStructArray<QGLTexture>(4); fbTextures[i] = header.fbTextures[i * 4].ToStructArray<QGLTexture>(4);
} }
return GetSelf(target).UploadAliasModel(
int result = GetSelf(context).UploadAliasModel(
name, header, frameType, poseVertices, name, header, frameType, poseVertices,
triangles.ToStructArray<QTriangle>(header.numTriangles), triangles.ToStructArray<QTriangle>(header.numTriangles),
stVerts.ToStructArray<QSTVert>(header.numVerts), stVerts.ToStructArray<QSTVert>(header.numVerts),
glTextures, fbTextures); glTextures, fbTextures);
Profiler.EndSample();
return result;
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int UploadBrushModelCallback(IntPtr target, QModel model);
private delegate int UploadBrushModelCallback(IntPtr context, QModel model);
[MonoPInvokeCallback(typeof(UploadBrushModelCallback))] [MonoPInvokeCallback(typeof(UploadBrushModelCallback))]
private static int Callback_UploadBrushModel(IntPtr target, QModel model)
private static int Callback_UploadBrushModel(IntPtr context, QModel model)
{ {
if (model == null || model.type != QModelType.Brush) if (model == null || model.type != QModelType.Brush)
return -1; return -1;
return GetSelf(target).UploadBrushModel(model);
Profiler.BeginSample("UploadBrushModel");
int result = GetSelf(context).UploadBrushModel(model);
Profiler.EndSample();
return result;
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int UploadWorldModelCallback(IntPtr target, QModel model);
private delegate int UploadWorldModelCallback(IntPtr context, QModel model);
[MonoPInvokeCallback(typeof(UploadBrushModelCallback))] [MonoPInvokeCallback(typeof(UploadBrushModelCallback))]
private static int Callback_UploadWorldModel(IntPtr target, QModel model)
private static int Callback_UploadWorldModel(IntPtr context, QModel model)
{ {
if (model == null || model.type != QModelType.Brush) if (model == null || model.type != QModelType.Brush)
return -1; return -1;
return GetSelf(target).UploadWorldModel(model);
Profiler.BeginSample("UploadWorldModel");
int result = GetSelf(context).UploadWorldModel(model);
Profiler.EndSample();
return result;
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool UploadTextureCallback(IntPtr target, QGLTexture texture, IntPtr data, ref uint texNum);
private delegate bool UploadTextureCallback(IntPtr context, QGLTexture texture, IntPtr data, ref uint texNum);
[MonoPInvokeCallback(typeof(UploadTextureCallback))] [MonoPInvokeCallback(typeof(UploadTextureCallback))]
private static bool Callback_UploadTexture(IntPtr target, QGLTexture texture, IntPtr data, ref uint texNum)
private static bool Callback_UploadTexture(IntPtr context, QGLTexture texture, IntPtr data, ref uint texNum)
{ {
Profiler.BeginSample("UploadTexture");
byte[] dataBytes = new byte[texture.width * texture.height * 4]; // 32 bits per pixel byte[] dataBytes = new byte[texture.width * texture.height * 4]; // 32 bits per pixel
Marshal.Copy(data, dataBytes, 0, dataBytes.Length); Marshal.Copy(data, dataBytes, 0, dataBytes.Length);
return GetSelf(target).UploadTexture(texture, dataBytes, ref texNum);
bool result = GetSelf(context).UploadTexture(texture, dataBytes, ref texNum);
Profiler.EndSample();
return result;
} }
private readonly byte[] lightmapBytes = new byte[QConstants.LightmapBlockWidth * QConstants.LightmapBlockHeight * 4]; // 32 bits per pixel private readonly byte[] lightmapBytes = new byte[QConstants.LightmapBlockWidth * QConstants.LightmapBlockHeight * 4]; // 32 bits per pixel
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool UploadLightmapCallback(IntPtr target, int lmap, IntPtr data);
private delegate bool UploadLightmapCallback(IntPtr context, int lmap, IntPtr data);
[MonoPInvokeCallback(typeof(UploadLightmapCallback))] [MonoPInvokeCallback(typeof(UploadLightmapCallback))]
private static bool Callback_UploadLightmap(IntPtr target, int lmap, IntPtr data)
private static bool Callback_UploadLightmap(IntPtr context, 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 // 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);
var self = GetSelf(context);
Marshal.Copy(data, self.lightmapBytes, 0, self.lightmapBytes.Length); 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)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SetupViewCallback(IntPtr target, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf);
private delegate void SetupViewCallback(IntPtr context, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf);
[MonoPInvokeCallback(typeof(SetupViewCallback))] [MonoPInvokeCallback(typeof(SetupViewCallback))]
private static void Callback_SetupView(IntPtr target, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf)
private static void Callback_SetupView(IntPtr context, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf)
{ {
GetSelf(target).SetupView(origin, angles, viewLeaf);
Profiler.BeginSample("SetupView");
GetSelf(context).SetupView(origin, angles, viewLeaf);
Profiler.EndSample();
} }
} }

76
Assets/Scripts/Modules/SystemModule.Interop.cs

@ -8,8 +8,6 @@ public partial class SystemModule: CallbackHandler<SystemModule>
{ {
var callbacks = new Callbacks var callbacks = new Callbacks
{ {
target = TargetPtr,
SysPrint = CreateCallback<SysPrintCallback>(Callback_SysPrint), SysPrint = CreateCallback<SysPrintCallback>(Callback_SysPrint),
SysError = CreateCallback<SysErrorCallback>(Callback_SysError), SysError = CreateCallback<SysErrorCallback>(Callback_SysError),
SysQuit = CreateCallback<SysQuitCallback>(Callback_SysQuit), SysQuit = CreateCallback<SysQuitCallback>(Callback_SysQuit),
@ -34,8 +32,6 @@ public partial class SystemModule: CallbackHandler<SystemModule>
[StructLayout(LayoutKind.Sequential, Pack = 0)] [StructLayout(LayoutKind.Sequential, Pack = 0)]
private class Callbacks private class Callbacks
{ {
public IntPtr target;
public IntPtr SysPrint; public IntPtr SysPrint;
public IntPtr SysError; public IntPtr SysError;
public IntPtr SysQuit; public IntPtr SysQuit;
@ -52,112 +48,112 @@ public partial class SystemModule: CallbackHandler<SystemModule>
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate void SysPrintCallback(IntPtr target,
private delegate void SysPrintCallback(IntPtr context,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(QuakeTextMarshaler))] string message); [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(QuakeTextMarshaler))] string message);
[MonoPInvokeCallback(typeof(SysPrintCallback))] [MonoPInvokeCallback(typeof(SysPrintCallback))]
private static void Callback_SysPrint(IntPtr target, string message)
private static void Callback_SysPrint(IntPtr context, string message)
{ {
GetSelf(target).Print(message);
GetSelf(context).Print(message);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate void SysErrorCallback(IntPtr target,
private delegate void SysErrorCallback(IntPtr context,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(QuakeTextMarshaler))] string message); [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(QuakeTextMarshaler))] string message);
[MonoPInvokeCallback(typeof(SysErrorCallback))] [MonoPInvokeCallback(typeof(SysErrorCallback))]
private static void Callback_SysError(IntPtr target, string message)
private static void Callback_SysError(IntPtr context, string message)
{ {
GetSelf(target).Error(message);
GetSelf(context).Error(message);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysQuitCallback(IntPtr target);
private delegate void SysQuitCallback(IntPtr context);
[MonoPInvokeCallback(typeof(SysQuitCallback))] [MonoPInvokeCallback(typeof(SysQuitCallback))]
private static void Callback_SysQuit(IntPtr target)
private static void Callback_SysQuit(IntPtr context)
{ {
GetSelf(target).Quit();
GetSelf(context).Quit();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate double SysDoubleTimeCallback(IntPtr target);
private delegate double SysDoubleTimeCallback(IntPtr context);
[MonoPInvokeCallback(typeof(SysDoubleTimeCallback))] [MonoPInvokeCallback(typeof(SysDoubleTimeCallback))]
private static double Callback_SysDoubleTime(IntPtr target)
private static double Callback_SysDoubleTime(IntPtr context)
{ {
return GetSelf(target).DoubleTime();
return GetSelf(context).DoubleTime();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate int SysFileOpenReadCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string path, out int handle);
private delegate int SysFileOpenReadCallback(IntPtr context, [MarshalAs(UnmanagedType.LPStr)] string path, out int handle);
[MonoPInvokeCallback(typeof(SysFileOpenReadCallback))] [MonoPInvokeCallback(typeof(SysFileOpenReadCallback))]
private static int Callback_SysFileOpenRead(IntPtr target, string path, out int handle)
private static int Callback_SysFileOpenRead(IntPtr context, string path, out int handle)
{ {
return GetSelf(target).FileOpenRead(path, out handle);
return GetSelf(context).FileOpenRead(path, out handle);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate int SysFileOpenWriteCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string path);
private delegate int SysFileOpenWriteCallback(IntPtr context, [MarshalAs(UnmanagedType.LPStr)] string path);
[MonoPInvokeCallback(typeof(SysFileOpenWriteCallback))] [MonoPInvokeCallback(typeof(SysFileOpenWriteCallback))]
private static int Callback_SysFileOpenWrite(IntPtr target, string path)
private static int Callback_SysFileOpenWrite(IntPtr context, string path)
{ {
return GetSelf(target).FileOpenWrite(path);
return GetSelf(context).FileOpenWrite(path);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysFileCloseCallback(IntPtr target, int handle);
private delegate void SysFileCloseCallback(IntPtr context, int handle);
[MonoPInvokeCallback(typeof(SysFileCloseCallback))] [MonoPInvokeCallback(typeof(SysFileCloseCallback))]
private static void Callback_SysFileClose(IntPtr target, int handle)
private static void Callback_SysFileClose(IntPtr context, int handle)
{ {
GetSelf(target).FileClose(handle);
GetSelf(context).FileClose(handle);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysFileSeekCallback(IntPtr target, int handle, int position);
private delegate void SysFileSeekCallback(IntPtr context, int handle, int position);
[MonoPInvokeCallback(typeof(SysFileSeekCallback))] [MonoPInvokeCallback(typeof(SysFileSeekCallback))]
private static void Callback_SysFileSeek(IntPtr target, int handle, int position)
private static void Callback_SysFileSeek(IntPtr context, int handle, int position)
{ {
GetSelf(target).FileSeek(handle, position);
GetSelf(context).FileSeek(handle, position);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int SysFileReadCallback(IntPtr target, int handle, IntPtr dest, int count);
private delegate int SysFileReadCallback(IntPtr context, int handle, IntPtr dest, int count);
[MonoPInvokeCallback(typeof(SysFileReadCallback))] [MonoPInvokeCallback(typeof(SysFileReadCallback))]
private static int Callback_SysFileRead(IntPtr target, int handle, IntPtr dest, int count)
private static int Callback_SysFileRead(IntPtr context, int handle, IntPtr dest, int count)
{ {
return GetSelf(target).FileRead(handle, dest, count);
return GetSelf(context).FileRead(handle, dest, count);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int SysFileWriteCallback(IntPtr target, int handle, IntPtr data, int count);
private delegate int SysFileWriteCallback(IntPtr context, int handle, IntPtr data, int count);
[MonoPInvokeCallback(typeof(SysFileWriteCallback))] [MonoPInvokeCallback(typeof(SysFileWriteCallback))]
private static int Callback_SysFileWrite(IntPtr target, int handle, IntPtr data, int count)
private static int Callback_SysFileWrite(IntPtr context, int handle, IntPtr data, int count)
{ {
return GetSelf(target).FileWrite(handle, data, count);
return GetSelf(context).FileWrite(handle, data, count);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate int SysFileTimeCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string path);
private delegate int SysFileTimeCallback(IntPtr context, [MarshalAs(UnmanagedType.LPStr)] string path);
[MonoPInvokeCallback(typeof(SysFileTimeCallback))] [MonoPInvokeCallback(typeof(SysFileTimeCallback))]
private static int Callback_SysFileTime(IntPtr target, string path)
private static int Callback_SysFileTime(IntPtr context, string path)
{ {
return GetSelf(target).FileTime(path);
return GetSelf(context).FileTime(path);
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private delegate bool SysMkDirCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string path);
private delegate bool SysMkDirCallback(IntPtr context, [MarshalAs(UnmanagedType.LPStr)] string path);
[MonoPInvokeCallback(typeof(SysMkDirCallback))] [MonoPInvokeCallback(typeof(SysMkDirCallback))]
private static bool Callback_SysMkDir(IntPtr target, string path)
private static bool Callback_SysMkDir(IntPtr context, string path)
{ {
return GetSelf(target).MkDir(path);
return GetSelf(context).MkDir(path);
} }
} }

4
Assets/Scripts/SplitScreenTest.cs

@ -31,7 +31,7 @@ public class SplitScreenTest : MonoBehaviour
uq.Camera = gameInstance.mainCamera; uq.Camera = gameInstance.mainCamera;
uq.GameLayer = gameLayer; uq.GameLayer = gameLayer;
uq.ViewModelLayer = viewLayer; uq.ViewModelLayer = viewLayer;
uq.LibraryOverride = gameInstance.libraryName;
uq.PlayerNumber = gameInstance.playerNumber;
uq.SetVisualStyle(visualStyles[0]); uq.SetVisualStyle(visualStyles[0]);
gameLayer += layerStride; gameLayer += layerStride;
@ -58,6 +58,6 @@ public class SplitScreenTest : MonoBehaviour
public string arguments; public string arguments;
public string libraryName;
public int playerNumber;
} }
} }

24
Assets/Scripts/UniQuake.Interop.cs

@ -22,7 +22,7 @@ public partial class UniQuake
private IntPtr libraryHandle; private IntPtr libraryHandle;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void UniQuake_InitFunc(IntPtr parms, IntPtr sysCalls, IntPtr glCalls, IntPtr gameCalls);
private delegate void UniQuake_InitFunc(IntPtr parms);
private UniQuake_InitFunc UniQuake_Init; private UniQuake_InitFunc UniQuake_Init;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@ -37,16 +37,23 @@ public partial class UniQuake
private delegate void UniQuake_SetFmodSystemFunc(IntPtr fmodSystem, int playerNumber = 0); private delegate void UniQuake_SetFmodSystemFunc(IntPtr fmodSystem, int playerNumber = 0);
private UniQuake_SetFmodSystemFunc UniQuake_SetFmodSystem; private UniQuake_SetFmodSystemFunc UniQuake_SetFmodSystem;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void UniQuake_SetCallbacksFunc(IntPtr context, IntPtr callbacks);
private UniQuake_SetCallbacksFunc UniQuake_SetSysCallbacks;
private UniQuake_SetCallbacksFunc UniQuake_SetRenderCallbacks;
private UniQuake_SetCallbacksFunc UniQuake_SetGameCallbacks;
private void LoadLibrary() private void LoadLibrary()
{ {
string dllFile = Path.Combine(Application.dataPath, DllPath); string dllFile = Path.Combine(Application.dataPath, DllPath);
// Experimental code to allow running multiple instances of Quake next to each other // Experimental code to allow running multiple instances of Quake next to each other
if (!string.IsNullOrEmpty(LibraryOverride))
if (PlayerNumber > 1)
{ {
string directory = Path.GetDirectoryName(dllFile); string directory = Path.GetDirectoryName(dllFile);
string filename = Path.GetFileNameWithoutExtension(dllFile);
string extension = Path.GetExtension(dllFile); string extension = Path.GetExtension(dllFile);
dllFile = Path.Combine(directory, LibraryOverride + extension);
dllFile = Path.Combine(directory, filename + PlayerNumber + extension);
} }
libraryHandle = SystemLibrary.LoadLibrary(dllFile); libraryHandle = SystemLibrary.LoadLibrary(dllFile);
@ -55,10 +62,13 @@ public partial class UniQuake
throw new DllNotFoundException($"Failed to load UniQuake library from path: {dllFile}, last error = {Marshal.GetLastWin32Error()}"); throw new DllNotFoundException($"Failed to load UniQuake library from path: {dllFile}, last error = {Marshal.GetLastWin32Error()}");
} }
UniQuake_Init = LoadLibraryFunction<UniQuake_InitFunc>("UniQuake_Init");
UniQuake_Update = LoadLibraryFunction<UniQuake_UpdateFunc>("UniQuake_Update");
UniQuake_Shutdown = LoadLibraryFunction<UniQuake_ShutdownFunc>("UniQuake_Shutdown");
UniQuake_SetFmodSystem = LoadLibraryFunction<UniQuake_SetFmodSystemFunc>("UniQuake_SetFmodSystem");
UniQuake_Init = LoadLibraryFunction<UniQuake_InitFunc>(nameof(UniQuake_Init));
UniQuake_Update = LoadLibraryFunction<UniQuake_UpdateFunc>(nameof(UniQuake_Update));
UniQuake_Shutdown = LoadLibraryFunction<UniQuake_ShutdownFunc>(nameof(UniQuake_Shutdown));
UniQuake_SetFmodSystem = LoadLibraryFunction<UniQuake_SetFmodSystemFunc>(nameof(UniQuake_SetFmodSystem));
UniQuake_SetSysCallbacks = LoadLibraryFunction<UniQuake_SetCallbacksFunc>(nameof(UniQuake_SetSysCallbacks));
UniQuake_SetRenderCallbacks = LoadLibraryFunction<UniQuake_SetCallbacksFunc>(nameof(UniQuake_SetRenderCallbacks));
UniQuake_SetGameCallbacks = LoadLibraryFunction<UniQuake_SetCallbacksFunc>(nameof(UniQuake_SetGameCallbacks));
} }
private TDelegate LoadLibraryFunction<TDelegate>(string functionName) private TDelegate LoadLibraryFunction<TDelegate>(string functionName)

13
Assets/Scripts/UniQuake.cs

@ -5,7 +5,7 @@ using UnityEngine;
public partial class UniQuake: MonoBehaviour public partial class UniQuake: MonoBehaviour
{ {
private const int DefaultMemSize = 0x8000000; // 128 MB of heap space
private const int DefaultMemSize = 0x10000000; // 256 MB of heap space
public int memorySize = DefaultMemSize; public int memorySize = DefaultMemSize;
@ -28,7 +28,7 @@ public partial class UniQuake: MonoBehaviour
public string ModDirectory { get; set; } public string ModDirectory { get; set; }
public string[] AdditionalArguments { get; set; } public string[] AdditionalArguments { get; set; }
public string LibraryOverride { get; set; }
public int PlayerNumber { get; set; }
/// <summary> /// <summary>
/// Time since startup for this particular instance of Quake /// Time since startup for this particular instance of Quake
@ -106,9 +106,12 @@ public partial class UniQuake: MonoBehaviour
try try
{ {
UniQuake_SetFmodSystem(AudioManager.Instance.FmodSystem.handle);
UniQuake_Init(quakeParms.ToNativePtr(),
systemModule.CallbacksPtr, renderModule.CallbacksPtr, gameModule.CallbacksPtr);
UniQuake_SetFmodSystem(AudioManager.Instance.FmodSystem.handle, PlayerNumber);
UniQuake_SetSysCallbacks(systemModule.ContextPtr, systemModule.CallbacksPtr);
UniQuake_SetRenderCallbacks(renderModule.ContextPtr, renderModule.CallbacksPtr);
UniQuake_SetGameCallbacks(gameModule.ContextPtr, gameModule.CallbacksPtr);
UniQuake_Init(quakeParms.ToNativePtr());
initialized = true; initialized = true;
} }

232
engine/FMOD/inc/fmod.cs

@ -17,24 +17,10 @@ namespace FMOD
FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion
0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number. 0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number.
*/ */
public class VERSION
{
public const int number = 0x00020016;
#if (UNITY_IPHONE || UNITY_TVOS || UNITY_SWITCH || UNITY_WEBGL) && !UNITY_EDITOR
public const string dll = "__Internal";
#elif (UNITY_PS4) && DEVELOPMENT_BUILD
public const string dll = "libfmodL";
#elif (UNITY_PS4) && !UNITY_EDITOR
public const string dll = "libfmod";
#elif (UNITY_PSP2) && !UNITY_EDITOR
public const string dll = "libfmodstudio";
#elif ((UNITY_WSA || UNITY_ANDROID || UNITY_XBOXONE || UNITY_STADIA) && DEVELOPMENT_BUILD)
public const string dll = "fmodL";
#elif (UNITY_EDITOR) || (UNITY_STANDALONE && DEVELOPMENT_BUILD)
public const string dll = "fmodstudioL";
#elif (UNITY_STANDALONE)
public const string dll = "fmodstudio";
#else
public partial class VERSION
{
public const int number = 0x00020111;
#if !UNITY_2017_4_OR_NEWER
public const string dll = "fmod"; public const string dll = "fmod";
#endif #endif
} }
@ -510,28 +496,31 @@ namespace FMOD
PREUPDATE = 0x00000400, PREUPDATE = 0x00000400,
POSTUPDATE = 0x00000800, POSTUPDATE = 0x00000800,
RECORDLISTCHANGED = 0x00001000, RECORDLISTCHANGED = 0x00001000,
BUFFEREDNOMIX = 0x00002000,
DEVICEREINITIALIZE = 0x00004000,
OUTPUTUNDERRUN = 0x00008000,
ALL = 0xFFFFFFFF, ALL = 0xFFFFFFFF,
} }
/* /*
FMOD Callbacks FMOD Callbacks
*/ */
public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, StringWrapper file, int line, StringWrapper func, StringWrapper message);
public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message);
public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata); public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata);
public delegate RESULT CHANNELCONTROL_CALLBACK(IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2);
public delegate RESULT CHANNELCONTROL_CALLBACK (IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2);
public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result); public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result);
public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen); public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen);
public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype); public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype);
public delegate RESULT FILE_OPEN_CALLBACK (StringWrapper name, ref uint filesize, ref IntPtr handle, IntPtr userdata);
public delegate RESULT FILE_OPEN_CALLBACK (IntPtr name, ref uint filesize, ref IntPtr handle, IntPtr userdata);
public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata); public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata);
public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata); public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata);
public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata); public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata);
public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata); public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata);
public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata); public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata);
public delegate RESULT FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result); public delegate RESULT FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result);
public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance); public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance);
public enum DSP_RESAMPLER : int public enum DSP_RESAMPLER : int
@ -744,12 +733,9 @@ namespace FMOD
public float distanceFilterCenterFreq; public float distanceFilterCenterFreq;
public int reverb3Dinstance; public int reverb3Dinstance;
public int DSPBufferPoolSize; public int DSPBufferPoolSize;
public uint stackSizeStream;
public uint stackSizeNonBlocking;
public uint stackSizeMixer;
public DSP_RESAMPLER resamplerMethod; public DSP_RESAMPLER resamplerMethod;
public uint commandQueueSize;
public uint randomSeed; public uint randomSeed;
public int maxConvolutionThreads;
} }
[Flags] [Flags]
@ -759,6 +745,119 @@ namespace FMOD
DEFAULT = 0x00000002, DEFAULT = 0x00000002,
} }
public enum THREAD_PRIORITY : int
{
/* Platform specific priority range */
PLATFORM_MIN = -32 * 1024,
PLATFORM_MAX = 32 * 1024,
/* Platform agnostic priorities, maps internally to platform specific value */
DEFAULT = PLATFORM_MIN - 1,
LOW = PLATFORM_MIN - 2,
MEDIUM = PLATFORM_MIN - 3,
HIGH = PLATFORM_MIN - 4,
VERY_HIGH = PLATFORM_MIN - 5,
EXTREME = PLATFORM_MIN - 6,
CRITICAL = PLATFORM_MIN - 7,
/* Thread defaults */
MIXER = EXTREME,
FEEDER = CRITICAL,
STREAM = VERY_HIGH,
FILE = HIGH,
NONBLOCKING = HIGH,
RECORD = HIGH,
GEOMETRY = LOW,
PROFILER = MEDIUM,
STUDIO_UPDATE = MEDIUM,
STUDIO_LOAD_BANK = MEDIUM,
STUDIO_LOAD_SAMPLE = MEDIUM,
CONVOLUTION1 = VERY_HIGH,
CONVOLUTION2 = VERY_HIGH
}
public enum THREAD_STACK_SIZE : uint
{
DEFAULT = 0,
MIXER = 80 * 1024,
FEEDER = 16 * 1024,
STREAM = 96 * 1024,
FILE = 64 * 1024,
NONBLOCKING = 112 * 1024,
RECORD = 16 * 1024,
GEOMETRY = 48 * 1024,
PROFILER = 128 * 1024,
STUDIO_UPDATE = 96 * 1024,
STUDIO_LOAD_BANK = 96 * 1024,
STUDIO_LOAD_SAMPLE = 96 * 1024,
CONVOLUTION1 = 16 * 1024,
CONVOLUTION2 = 16 * 1024
}
[Flags]
public enum THREAD_AFFINITY : long // avoid ulong for Bolt compatibility
{
/* Platform agnostic thread groupings */
GROUP_DEFAULT = 0x4000000000000000,
GROUP_A = 0x4000000000000001,
GROUP_B = 0x4000000000000002,
GROUP_C = 0x4000000000000003,
/* Thread defaults */
MIXER = GROUP_A,
FEEDER = GROUP_C,
STREAM = GROUP_C,
FILE = GROUP_C,
NONBLOCKING = GROUP_C,
RECORD = GROUP_C,
GEOMETRY = GROUP_C,
PROFILER = GROUP_C,
STUDIO_UPDATE = GROUP_B,
STUDIO_LOAD_BANK = GROUP_C,
STUDIO_LOAD_SAMPLE = GROUP_C,
CONVOLUTION1 = GROUP_C,
CONVOLUTION2 = GROUP_C,
/* Core mask, valid up to 1 << 61 */
CORE_ALL = 0,
CORE_0 = 1 << 0,
CORE_1 = 1 << 1,
CORE_2 = 1 << 2,
CORE_3 = 1 << 3,
CORE_4 = 1 << 4,
CORE_5 = 1 << 5,
CORE_6 = 1 << 6,
CORE_7 = 1 << 7,
CORE_8 = 1 << 8,
CORE_9 = 1 << 9,
CORE_10 = 1 << 10,
CORE_11 = 1 << 11,
CORE_12 = 1 << 12,
CORE_13 = 1 << 13,
CORE_14 = 1 << 14,
CORE_15 = 1 << 15
}
public enum THREAD_TYPE : int
{
MIXER,
FEEDER,
STREAM,
FILE,
NONBLOCKING,
RECORD,
GEOMETRY,
PROFILER,
STUDIO_UPDATE,
STUDIO_LOAD_BANK,
STUDIO_LOAD_SAMPLE,
CONVOLUTION1,
CONVOLUTION2,
MAX
}
/* /*
FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started. FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started.
*/ */
@ -817,6 +916,24 @@ namespace FMOD
#endregion #endregion
} }
public struct Thread
{
public static RESULT SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity = THREAD_AFFINITY.GROUP_DEFAULT, THREAD_PRIORITY priority = THREAD_PRIORITY.DEFAULT, THREAD_STACK_SIZE stacksize = THREAD_STACK_SIZE.DEFAULT)
{
if ((affinity & THREAD_AFFINITY.GROUP_DEFAULT) != 0)
{
affinity &= ~THREAD_AFFINITY.GROUP_DEFAULT;
affinity = (THREAD_AFFINITY)(((ulong)affinity) | 0x8000000000000000);
}
return FMOD5_Thread_SetAttributes(type, affinity, priority, stacksize);
}
#region importfunctions
[DllImport(VERSION.dll)]
private static extern RESULT FMOD5_Thread_SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity, THREAD_PRIORITY priority, THREAD_STACK_SIZE stacksize);
#endregion
}
/* /*
'System' API. 'System' API.
*/ */
@ -899,12 +1016,12 @@ namespace FMOD
} }
public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings) public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings)
{ {
settings.cbSize = Marshal.SizeOf(settings);
settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
return FMOD5_System_SetAdvancedSettings(this.handle, ref settings); return FMOD5_System_SetAdvancedSettings(this.handle, ref settings);
} }
public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings) public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings)
{ {
settings.cbSize = Marshal.SizeOf(settings);
settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
return FMOD5_System_GetAdvancedSettings(this.handle, ref settings); return FMOD5_System_GetAdvancedSettings(this.handle, ref settings);
} }
public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL) public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL)
@ -1096,6 +1213,10 @@ namespace FMOD
{ {
return FMOD5_System_GetCPUUsage(this.handle, out dsp, out stream, out geometry, out update, out total); return FMOD5_System_GetCPUUsage(this.handle, out dsp, out stream, out geometry, out update, out total);
} }
public RESULT getCPUUsageEx(out float convolutionThread1, out float convolutionThread2)
{
return FMOD5_System_GetCPUUsageEx(this.handle, out convolutionThread1, out convolutionThread2);
}
public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead) public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead)
{ {
return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead); return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead);
@ -1120,7 +1241,7 @@ namespace FMOD
public RESULT createSound(string name, MODE mode, out Sound sound) public RESULT createSound(string name, MODE mode, out Sound sound)
{ {
CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
exinfo.cbsize = Marshal.SizeOf(exinfo);
exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
return createSound(name, mode, ref exinfo, out sound); return createSound(name, mode, ref exinfo, out sound);
} }
@ -1142,7 +1263,7 @@ namespace FMOD
public RESULT createStream(string name, MODE mode, out Sound sound) public RESULT createStream(string name, MODE mode, out Sound sound)
{ {
CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
exinfo.cbsize = Marshal.SizeOf(exinfo);
exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
return createStream(name, mode, ref exinfo, out sound); return createStream(name, mode, ref exinfo, out sound);
} }
@ -1184,6 +1305,10 @@ namespace FMOD
{ {
return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle); return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle);
} }
public RESULT getDSPInfoByType(DSP_TYPE type, out IntPtr description)
{
return FMOD5_System_GetDSPInfoByType(this.handle, type, out description);
}
public RESULT getMasterChannelGroup(out ChannelGroup channelgroup) public RESULT getMasterChannelGroup(out ChannelGroup channelgroup)
{ {
return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle); return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle);
@ -1439,6 +1564,8 @@ namespace FMOD
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out float dsp, out float stream, out float geometry, out float update, out float total); private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out float dsp, out float stream, out float geometry, out float update, out float total);
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetCPUUsageEx (IntPtr system, out float convolutionThread1, out float convolutionThread2);
[DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead); private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead);
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
@ -1465,6 +1592,8 @@ namespace FMOD
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel); private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel);
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetDSPInfoByType (IntPtr system, DSP_TYPE type, out IntPtr description);
[DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup); private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup);
[DllImport(VERSION.dll)] [DllImport(VERSION.dll)]
private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup); private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup);
@ -1520,6 +1649,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public System(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -1837,6 +1967,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public Sound(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -2415,6 +2546,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public Channel(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -2886,6 +3018,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public ChannelGroup(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -3023,6 +3156,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public SoundGroup(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -3160,11 +3294,7 @@ namespace FMOD
{ {
IntPtr descPtr; IntPtr descPtr;
RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr); RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr);
#if (UNITY_2017_4_OR_NEWER) && !NET_4_6
desc = (DSP_PARAMETER_DESC)Marshal.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC));
#else
desc = Marshal.PtrToStructure<DSP_PARAMETER_DESC>(descPtr);
#endif // (UNITY_2017_4_OR_NEWER) && !NET_4_6
desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC));
return result; return result;
} }
public RESULT getDataParameterIndex(int datatype, out int index) public RESULT getDataParameterIndex(int datatype, out int index)
@ -3333,6 +3463,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public DSP(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -3408,6 +3539,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public DSPConnection(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -3553,6 +3685,7 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public Geometry(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
@ -3630,18 +3763,24 @@ namespace FMOD
public IntPtr handle; public IntPtr handle;
public Reverb3D(IntPtr ptr) { this.handle = ptr; }
public bool hasHandle() { return this.handle != IntPtr.Zero; } public bool hasHandle() { return this.handle != IntPtr.Zero; }
public void clearHandle() { this.handle = IntPtr.Zero; } public void clearHandle() { this.handle = IntPtr.Zero; }
#endregion #endregion
} }
#region String Helper Functions
#region Helper Functions
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct StringWrapper public struct StringWrapper
{ {
IntPtr nativeUtf8Ptr; IntPtr nativeUtf8Ptr;
public StringWrapper(IntPtr ptr)
{
nativeUtf8Ptr = ptr;
}
public static implicit operator string(StringWrapper fstring) public static implicit operator string(StringWrapper fstring)
{ {
using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
@ -3790,5 +3929,22 @@ namespace FMOD
} }
} }
// Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541
// Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings
public static class MarshalHelper
{
#pragma warning disable 618
public static int SizeOf(Type t)
{
return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations
}
public static object PtrToStructure(IntPtr ptr, Type structureType)
{
return Marshal.PtrToStructure(ptr, structureType);
}
#pragma warning restore 618
}
#endregion #endregion
} }

3
engine/FMOD/inc/fmod.h

@ -27,6 +27,7 @@ FMOD_RESULT F_API FMOD_Memory_GetStats (int *currentalloced, int *ma
FMOD_RESULT F_API FMOD_Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode, FMOD_DEBUG_CALLBACK callback, const char *filename); FMOD_RESULT F_API FMOD_Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode, FMOD_DEBUG_CALLBACK callback, const char *filename);
FMOD_RESULT F_API FMOD_File_SetDiskBusy (int busy); FMOD_RESULT F_API FMOD_File_SetDiskBusy (int busy);
FMOD_RESULT F_API FMOD_File_GetDiskBusy (int *busy); FMOD_RESULT F_API FMOD_File_GetDiskBusy (int *busy);
FMOD_RESULT F_API FMOD_Thread_SetAttributes (FMOD_THREAD_TYPE type, FMOD_THREAD_AFFINITY affinity, FMOD_THREAD_PRIORITY priority, FMOD_THREAD_STACK_SIZE stacksize);
/* /*
FMOD System factory functions. Use this to create an FMOD System Instance. below you will see FMOD_System_Init/Close to get started. FMOD System factory functions. Use this to create an FMOD System Instance. below you will see FMOD_System_Init/Close to get started.
@ -101,6 +102,7 @@ FMOD_RESULT F_API FMOD_System_GetVersion (FMOD_SYSTEM *system, un
FMOD_RESULT F_API FMOD_System_GetOutputHandle (FMOD_SYSTEM *system, void **handle); FMOD_RESULT F_API FMOD_System_GetOutputHandle (FMOD_SYSTEM *system, void **handle);
FMOD_RESULT F_API FMOD_System_GetChannelsPlaying (FMOD_SYSTEM *system, int *channels, int *realchannels); FMOD_RESULT F_API FMOD_System_GetChannelsPlaying (FMOD_SYSTEM *system, int *channels, int *realchannels);
FMOD_RESULT F_API FMOD_System_GetCPUUsage (FMOD_SYSTEM *system, float *dsp, float *stream, float *geometry, float *update, float *total); FMOD_RESULT F_API FMOD_System_GetCPUUsage (FMOD_SYSTEM *system, float *dsp, float *stream, float *geometry, float *update, float *total);
FMOD_RESULT F_API FMOD_System_GetCPUUsageEx (FMOD_SYSTEM *system, float *convolutionThread1, float *convolutionThread2);
FMOD_RESULT F_API FMOD_System_GetFileUsage (FMOD_SYSTEM *system, long long *sampleBytesRead, long long *streamBytesRead, long long *otherBytesRead); FMOD_RESULT F_API FMOD_System_GetFileUsage (FMOD_SYSTEM *system, long long *sampleBytesRead, long long *streamBytesRead, long long *otherBytesRead);
/* Sound/DSP/Channel/FX creation and retrieval. */ /* Sound/DSP/Channel/FX creation and retrieval. */
@ -114,6 +116,7 @@ FMOD_RESULT F_API FMOD_System_CreateReverb3D (FMOD_SYSTEM *system, FM
FMOD_RESULT F_API FMOD_System_PlaySound (FMOD_SYSTEM *system, FMOD_SOUND *sound, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel); FMOD_RESULT F_API FMOD_System_PlaySound (FMOD_SYSTEM *system, FMOD_SOUND *sound, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_PlayDSP (FMOD_SYSTEM *system, FMOD_DSP *dsp, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel); FMOD_RESULT F_API FMOD_System_PlayDSP (FMOD_SYSTEM *system, FMOD_DSP *dsp, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_GetChannel (FMOD_SYSTEM *system, int channelid, FMOD_CHANNEL **channel); FMOD_RESULT F_API FMOD_System_GetChannel (FMOD_SYSTEM *system, int channelid, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_GetDSPInfoByType (FMOD_SYSTEM *system, FMOD_DSP_TYPE type, const FMOD_DSP_DESCRIPTION **description);
FMOD_RESULT F_API FMOD_System_GetMasterChannelGroup (FMOD_SYSTEM *system, FMOD_CHANNELGROUP **channelgroup); FMOD_RESULT F_API FMOD_System_GetMasterChannelGroup (FMOD_SYSTEM *system, FMOD_CHANNELGROUP **channelgroup);
FMOD_RESULT F_API FMOD_System_GetMasterSoundGroup (FMOD_SYSTEM *system, FMOD_SOUNDGROUP **soundgroup); FMOD_RESULT F_API FMOD_System_GetMasterSoundGroup (FMOD_SYSTEM *system, FMOD_SOUNDGROUP **soundgroup);

3
engine/FMOD/inc/fmod.hpp

@ -38,6 +38,7 @@ namespace FMOD
inline FMOD_RESULT Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode = FMOD_DEBUG_MODE_TTY, FMOD_DEBUG_CALLBACK callback = 0, const char *filename = 0) { return FMOD_Debug_Initialize(flags, mode, callback, filename); } inline FMOD_RESULT Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode = FMOD_DEBUG_MODE_TTY, FMOD_DEBUG_CALLBACK callback = 0, const char *filename = 0) { return FMOD_Debug_Initialize(flags, mode, callback, filename); }
inline FMOD_RESULT File_SetDiskBusy (int busy) { return FMOD_File_SetDiskBusy(busy); } inline FMOD_RESULT File_SetDiskBusy (int busy) { return FMOD_File_SetDiskBusy(busy); }
inline FMOD_RESULT File_GetDiskBusy (int *busy) { return FMOD_File_GetDiskBusy(busy); } inline FMOD_RESULT File_GetDiskBusy (int *busy) { return FMOD_File_GetDiskBusy(busy); }
inline FMOD_RESULT Thread_SetAttributes (FMOD_THREAD_TYPE type, FMOD_THREAD_AFFINITY affinity = FMOD_THREAD_AFFINITY_GROUP_DEFAULT, FMOD_THREAD_PRIORITY priority = FMOD_THREAD_PRIORITY_DEFAULT, FMOD_THREAD_STACK_SIZE stacksize = FMOD_THREAD_STACK_SIZE_DEFAULT) { return FMOD_Thread_SetAttributes(type, affinity, priority, stacksize); }
/* /*
FMOD System factory functions. FMOD System factory functions.
@ -123,6 +124,7 @@ namespace FMOD
FMOD_RESULT F_API getOutputHandle (void **handle); FMOD_RESULT F_API getOutputHandle (void **handle);
FMOD_RESULT F_API getChannelsPlaying (int *channels, int *realchannels = 0); FMOD_RESULT F_API getChannelsPlaying (int *channels, int *realchannels = 0);
FMOD_RESULT F_API getCPUUsage (float *dsp, float *stream, float *geometry, float *update, float *total); FMOD_RESULT F_API getCPUUsage (float *dsp, float *stream, float *geometry, float *update, float *total);
FMOD_RESULT F_API getCPUUsageEx (float *convolutionThread1, float *convolutionThread2);
FMOD_RESULT F_API getFileUsage (long long *sampleBytesRead, long long *streamBytesRead, long long *otherBytesRead); FMOD_RESULT F_API getFileUsage (long long *sampleBytesRead, long long *streamBytesRead, long long *otherBytesRead);
// Sound/DSP/Channel/FX creation and retrieval. // Sound/DSP/Channel/FX creation and retrieval.
@ -137,6 +139,7 @@ namespace FMOD
FMOD_RESULT F_API playSound (Sound *sound, ChannelGroup *channelgroup, bool paused, Channel **channel); FMOD_RESULT F_API playSound (Sound *sound, ChannelGroup *channelgroup, bool paused, Channel **channel);
FMOD_RESULT F_API playDSP (DSP *dsp, ChannelGroup *channelgroup, bool paused, Channel **channel); FMOD_RESULT F_API playDSP (DSP *dsp, ChannelGroup *channelgroup, bool paused, Channel **channel);
FMOD_RESULT F_API getChannel (int channelid, Channel **channel); FMOD_RESULT F_API getChannel (int channelid, Channel **channel);
FMOD_RESULT F_API getDSPInfoByType (FMOD_DSP_TYPE type, const FMOD_DSP_DESCRIPTION **description);
FMOD_RESULT F_API getMasterChannelGroup (ChannelGroup **channelgroup); FMOD_RESULT F_API getMasterChannelGroup (ChannelGroup **channelgroup);
FMOD_RESULT F_API getMasterSoundGroup (SoundGroup **soundgroup); FMOD_RESULT F_API getMasterSoundGroup (SoundGroup **soundgroup);

114
engine/FMOD/inc/fmod_common.h

@ -58,7 +58,7 @@ typedef unsigned long long FMOD_PORT_INDEX;
/* /*
FMOD constants FMOD constants
*/ */
#define FMOD_VERSION 0x00020016 /* 0xaaaabbcc -> aaaa = product version, bb = major version, cc = minor version.*/
#define FMOD_VERSION 0x00020111 /* 0xaaaabbcc -> aaaa = product version, bb = major version, cc = minor version.*/
typedef unsigned int FMOD_DEBUG_FLAGS; typedef unsigned int FMOD_DEBUG_FLAGS;
#define FMOD_DEBUG_LEVEL_NONE 0x00000000 #define FMOD_DEBUG_LEVEL_NONE 0x00000000
@ -126,6 +126,9 @@ typedef unsigned int FMOD_SYSTEM_CALLBACK_TYPE;
#define FMOD_SYSTEM_CALLBACK_PREUPDATE 0x00000400 #define FMOD_SYSTEM_CALLBACK_PREUPDATE 0x00000400
#define FMOD_SYSTEM_CALLBACK_POSTUPDATE 0x00000800 #define FMOD_SYSTEM_CALLBACK_POSTUPDATE 0x00000800
#define FMOD_SYSTEM_CALLBACK_RECORDLISTCHANGED 0x00001000 #define FMOD_SYSTEM_CALLBACK_RECORDLISTCHANGED 0x00001000
#define FMOD_SYSTEM_CALLBACK_BUFFEREDNOMIX 0x00002000
#define FMOD_SYSTEM_CALLBACK_DEVICEREINITIALIZE 0x00004000
#define FMOD_SYSTEM_CALLBACK_OUTPUTUNDERRUN 0x00008000
#define FMOD_SYSTEM_CALLBACK_ALL 0xFFFFFFFF #define FMOD_SYSTEM_CALLBACK_ALL 0xFFFFFFFF
typedef unsigned int FMOD_MODE; typedef unsigned int FMOD_MODE;
@ -169,7 +172,6 @@ typedef unsigned int FMOD_CHANNELMASK;
#define FMOD_CHANNELMASK_BACK_LEFT 0x00000040 #define FMOD_CHANNELMASK_BACK_LEFT 0x00000040
#define FMOD_CHANNELMASK_BACK_RIGHT 0x00000080 #define FMOD_CHANNELMASK_BACK_RIGHT 0x00000080
#define FMOD_CHANNELMASK_BACK_CENTER 0x00000100 #define FMOD_CHANNELMASK_BACK_CENTER 0x00000100
#define FMOD_CHANNELMASK_MONO (FMOD_CHANNELMASK_FRONT_LEFT) #define FMOD_CHANNELMASK_MONO (FMOD_CHANNELMASK_FRONT_LEFT)
#define FMOD_CHANNELMASK_STEREO (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT) #define FMOD_CHANNELMASK_STEREO (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT)
#define FMOD_CHANNELMASK_LRC (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER) #define FMOD_CHANNELMASK_LRC (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER)
@ -180,6 +182,89 @@ typedef unsigned int FMOD_CHANNELMASK;
#define FMOD_CHANNELMASK_7POINT0 (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER | FMOD_CHANNELMASK_SURROUND_LEFT | FMOD_CHANNELMASK_SURROUND_RIGHT | FMOD_CHANNELMASK_BACK_LEFT | FMOD_CHANNELMASK_BACK_RIGHT) #define FMOD_CHANNELMASK_7POINT0 (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER | FMOD_CHANNELMASK_SURROUND_LEFT | FMOD_CHANNELMASK_SURROUND_RIGHT | FMOD_CHANNELMASK_BACK_LEFT | FMOD_CHANNELMASK_BACK_RIGHT)
#define FMOD_CHANNELMASK_7POINT1 (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER | FMOD_CHANNELMASK_LOW_FREQUENCY | FMOD_CHANNELMASK_SURROUND_LEFT | FMOD_CHANNELMASK_SURROUND_RIGHT | FMOD_CHANNELMASK_BACK_LEFT | FMOD_CHANNELMASK_BACK_RIGHT) #define FMOD_CHANNELMASK_7POINT1 (FMOD_CHANNELMASK_FRONT_LEFT | FMOD_CHANNELMASK_FRONT_RIGHT | FMOD_CHANNELMASK_FRONT_CENTER | FMOD_CHANNELMASK_LOW_FREQUENCY | FMOD_CHANNELMASK_SURROUND_LEFT | FMOD_CHANNELMASK_SURROUND_RIGHT | FMOD_CHANNELMASK_BACK_LEFT | FMOD_CHANNELMASK_BACK_RIGHT)
typedef int FMOD_THREAD_PRIORITY;
/* Platform specific priority range */
#define FMOD_THREAD_PRIORITY_PLATFORM_MIN (-32 * 1024)
#define FMOD_THREAD_PRIORITY_PLATFORM_MAX ( 32 * 1024)
/* Platform agnostic priorities, maps internally to platform specific value */
#define FMOD_THREAD_PRIORITY_DEFAULT (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 1)
#define FMOD_THREAD_PRIORITY_LOW (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 2)
#define FMOD_THREAD_PRIORITY_MEDIUM (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 3)
#define FMOD_THREAD_PRIORITY_HIGH (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 4)
#define FMOD_THREAD_PRIORITY_VERY_HIGH (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 5)
#define FMOD_THREAD_PRIORITY_EXTREME (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 6)
#define FMOD_THREAD_PRIORITY_CRITICAL (FMOD_THREAD_PRIORITY_PLATFORM_MIN - 7)
/* Thread defaults */
#define FMOD_THREAD_PRIORITY_MIXER FMOD_THREAD_PRIORITY_EXTREME
#define FMOD_THREAD_PRIORITY_FEEDER FMOD_THREAD_PRIORITY_CRITICAL
#define FMOD_THREAD_PRIORITY_STREAM FMOD_THREAD_PRIORITY_VERY_HIGH
#define FMOD_THREAD_PRIORITY_FILE FMOD_THREAD_PRIORITY_HIGH
#define FMOD_THREAD_PRIORITY_NONBLOCKING FMOD_THREAD_PRIORITY_HIGH
#define FMOD_THREAD_PRIORITY_RECORD FMOD_THREAD_PRIORITY_HIGH
#define FMOD_THREAD_PRIORITY_GEOMETRY FMOD_THREAD_PRIORITY_LOW
#define FMOD_THREAD_PRIORITY_PROFILER FMOD_THREAD_PRIORITY_MEDIUM
#define FMOD_THREAD_PRIORITY_STUDIO_UPDATE FMOD_THREAD_PRIORITY_MEDIUM
#define FMOD_THREAD_PRIORITY_STUDIO_LOAD_BANK FMOD_THREAD_PRIORITY_MEDIUM
#define FMOD_THREAD_PRIORITY_STUDIO_LOAD_SAMPLE FMOD_THREAD_PRIORITY_MEDIUM
#define FMOD_THREAD_PRIORITY_CONVOLUTION1 FMOD_THREAD_PRIORITY_VERY_HIGH
#define FMOD_THREAD_PRIORITY_CONVOLUTION2 FMOD_THREAD_PRIORITY_VERY_HIGH
typedef unsigned int FMOD_THREAD_STACK_SIZE;
#define FMOD_THREAD_STACK_SIZE_DEFAULT 0
#define FMOD_THREAD_STACK_SIZE_MIXER (80 * 1024)
#define FMOD_THREAD_STACK_SIZE_FEEDER (16 * 1024)
#define FMOD_THREAD_STACK_SIZE_STREAM (96 * 1024)
#define FMOD_THREAD_STACK_SIZE_FILE (64 * 1024)
#define FMOD_THREAD_STACK_SIZE_NONBLOCKING (112 * 1024)
#define FMOD_THREAD_STACK_SIZE_RECORD (16 * 1024)
#define FMOD_THREAD_STACK_SIZE_GEOMETRY (48 * 1024)
#define FMOD_THREAD_STACK_SIZE_PROFILER (128 * 1024)
#define FMOD_THREAD_STACK_SIZE_STUDIO_UPDATE (96 * 1024)
#define FMOD_THREAD_STACK_SIZE_STUDIO_LOAD_BANK (96 * 1024)
#define FMOD_THREAD_STACK_SIZE_STUDIO_LOAD_SAMPLE (96 * 1024)
#define FMOD_THREAD_STACK_SIZE_CONVOLUTION1 (16 * 1024)
#define FMOD_THREAD_STACK_SIZE_CONVOLUTION2 (16 * 1024)
typedef unsigned long long FMOD_THREAD_AFFINITY;
/* Platform agnostic thread groupings */
#define FMOD_THREAD_AFFINITY_GROUP_DEFAULT 0x8000000000000000
#define FMOD_THREAD_AFFINITY_GROUP_A 0x8000000000000001
#define FMOD_THREAD_AFFINITY_GROUP_B 0x8000000000000002
#define FMOD_THREAD_AFFINITY_GROUP_C 0x8000000000000003
/* Thread defaults */
#define FMOD_THREAD_AFFINITY_MIXER FMOD_THREAD_AFFINITY_GROUP_A
#define FMOD_THREAD_AFFINITY_FEEDER FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_STREAM FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_FILE FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_NONBLOCKING FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_RECORD FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_GEOMETRY FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_PROFILER FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_STUDIO_UPDATE FMOD_THREAD_AFFINITY_GROUP_B
#define FMOD_THREAD_AFFINITY_STUDIO_LOAD_BANK FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_STUDIO_LOAD_SAMPLE FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_CONVOLUTION1 FMOD_THREAD_AFFINITY_GROUP_C
#define FMOD_THREAD_AFFINITY_CONVOLUTION2 FMOD_THREAD_AFFINITY_GROUP_C
/* Core mask, valid up to 1 << 62 */
#define FMOD_THREAD_AFFINITY_CORE_ALL 0
#define FMOD_THREAD_AFFINITY_CORE_0 (1 << 0)
#define FMOD_THREAD_AFFINITY_CORE_1 (1 << 1)
#define FMOD_THREAD_AFFINITY_CORE_2 (1 << 2)
#define FMOD_THREAD_AFFINITY_CORE_3 (1 << 3)
#define FMOD_THREAD_AFFINITY_CORE_4 (1 << 4)
#define FMOD_THREAD_AFFINITY_CORE_5 (1 << 5)
#define FMOD_THREAD_AFFINITY_CORE_6 (1 << 6)
#define FMOD_THREAD_AFFINITY_CORE_7 (1 << 7)
#define FMOD_THREAD_AFFINITY_CORE_8 (1 << 8)
#define FMOD_THREAD_AFFINITY_CORE_9 (1 << 9)
#define FMOD_THREAD_AFFINITY_CORE_10 (1 << 10)
#define FMOD_THREAD_AFFINITY_CORE_11 (1 << 11)
#define FMOD_THREAD_AFFINITY_CORE_12 (1 << 12)
#define FMOD_THREAD_AFFINITY_CORE_13 (1 << 13)
#define FMOD_THREAD_AFFINITY_CORE_14 (1 << 14)
#define FMOD_THREAD_AFFINITY_CORE_15 (1 << 15)
/* Preset for FMOD_REVERB_PROPERTIES */ /* Preset for FMOD_REVERB_PROPERTIES */
#define FMOD_PRESET_OFF { 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f } #define FMOD_PRESET_OFF { 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f }
#define FMOD_PRESET_GENERIC { 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f } #define FMOD_PRESET_GENERIC { 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f }
@ -212,6 +297,26 @@ typedef unsigned int FMOD_CHANNELMASK;
#define FMOD_REVERB_MAXINSTANCES 4 #define FMOD_REVERB_MAXINSTANCES 4
#define FMOD_PORT_INDEX_NONE 0xFFFFFFFFFFFFFFFF #define FMOD_PORT_INDEX_NONE 0xFFFFFFFFFFFFFFFF
typedef enum FMOD_THREAD_TYPE
{
FMOD_THREAD_TYPE_MIXER,
FMOD_THREAD_TYPE_FEEDER,
FMOD_THREAD_TYPE_STREAM,
FMOD_THREAD_TYPE_FILE,
FMOD_THREAD_TYPE_NONBLOCKING,
FMOD_THREAD_TYPE_RECORD,
FMOD_THREAD_TYPE_GEOMETRY,
FMOD_THREAD_TYPE_PROFILER,
FMOD_THREAD_TYPE_STUDIO_UPDATE,
FMOD_THREAD_TYPE_STUDIO_LOAD_BANK,
FMOD_THREAD_TYPE_STUDIO_LOAD_SAMPLE,
FMOD_THREAD_TYPE_CONVOLUTION1,
FMOD_THREAD_TYPE_CONVOLUTION2,
FMOD_THREAD_TYPE_MAX,
FMOD_THREAD_TYPE_FORCEINT = 65536
} FMOD_THREAD_TYPE;
typedef enum FMOD_RESULT typedef enum FMOD_RESULT
{ {
FMOD_OK, FMOD_OK,
@ -659,12 +764,9 @@ typedef struct FMOD_ADVANCEDSETTINGS
float distanceFilterCenterFreq; float distanceFilterCenterFreq;
int reverb3Dinstance; int reverb3Dinstance;
int DSPBufferPoolSize; int DSPBufferPoolSize;
unsigned int stackSizeStream;
unsigned int stackSizeNonBlocking;
unsigned int stackSizeMixer;
FMOD_DSP_RESAMPLER resamplerMethod; FMOD_DSP_RESAMPLER resamplerMethod;
unsigned int commandQueueSize;
unsigned int randomSeed; unsigned int randomSeed;
int maxConvolutionThreads;
} FMOD_ADVANCEDSETTINGS; } FMOD_ADVANCEDSETTINGS;
typedef struct FMOD_TAG typedef struct FMOD_TAG

47
engine/FMOD/inc/fmod_dsp.cs

@ -72,10 +72,10 @@ namespace FMOD
/* /*
DSP functions DSP functions
*/ */
public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, StringWrapper sourcestr);
public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, StringWrapper file, int line, StringWrapper function, StringWrapper format);
public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr format);
public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate); public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate);
public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize); public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize);
public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output); public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output);
@ -306,6 +306,27 @@ namespace FMOD
} }
} }
[StructLayout(LayoutKind.Sequential)]
public struct DSP_LOUDNESS_METER_INFO_TYPE
{
public float momentaryloudness;
public float shorttermloudness;
public float integratedloudness;
public float loudness10thpercentile;
public float loudness95thpercentile;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 66)]
public float[] loudnesshistogram;
public float maxtruepeak;
public float maxmomentaryloudness;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_LOUDNESS_METER_WEIGHTING_TYPE
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public float[] channelweight;
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct DSP_DESCRIPTION public struct DSP_DESCRIPTION
{ {
@ -718,6 +739,24 @@ namespace FMOD
DOMINANT_FREQ DOMINANT_FREQ
} }
public enum DSP_LOUDNESS_METER : int
{
STATE,
WEIGHTING,
INFO
}
public enum DSP_LOUDNESS_METER_STATE_TYPE : int
{
RESET_INTEGRATED = -3,
RESET_MAXPEAK = -2,
RESET_ALL = -1,
PAUSED = 0,
ANALYZING = 1
}
public enum DSP_ENVELOPEFOLLOWER : int public enum DSP_ENVELOPEFOLLOWER : int
{ {
ATTACK, ATTACK,

36
engine/FMOD/inc/fmod_dsp_effects.h

@ -404,6 +404,42 @@ typedef enum
FMOD_DSP_FFT_DOMINANT_FREQ FMOD_DSP_FFT_DOMINANT_FREQ
} FMOD_DSP_FFT; } FMOD_DSP_FFT;
#define FMOD_DSP_LOUDNESS_METER_HISTOGRAM_SAMPLES 66
typedef enum
{
FMOD_DSP_LOUDNESS_METER_STATE,
FMOD_DSP_LOUDNESS_METER_WEIGHTING,
FMOD_DSP_LOUDNESS_METER_INFO
} FMOD_DSP_LOUDNESS_METER;
typedef enum
{
FMOD_DSP_LOUDNESS_METER_STATE_RESET_INTEGRATED = -3,
FMOD_DSP_LOUDNESS_METER_STATE_RESET_MAXPEAK = -2,
FMOD_DSP_LOUDNESS_METER_STATE_RESET_ALL = -1,
FMOD_DSP_LOUDNESS_METER_STATE_PAUSED = 0,
FMOD_DSP_LOUDNESS_METER_STATE_ANALYZING = 1
} FMOD_DSP_LOUDNESS_METER_STATE_TYPE;
typedef struct FMOD_DSP_LOUDNESS_METER_INFO_TYPE
{
float momentaryloudness;
float shorttermloudness;
float integratedloudness;
float loudness10thpercentile;
float loudness95thpercentile;
float loudnesshistogram[FMOD_DSP_LOUDNESS_METER_HISTOGRAM_SAMPLES];
float maxtruepeak;
float maxmomentaryloudness;
} FMOD_DSP_LOUDNESS_METER_INFO_TYPE;
typedef struct FMOD_DSP_LOUDNESS_METER_WEIGHTING_TYPE
{
float channelweight[32];
} FMOD_DSP_LOUDNESS_METER_WEIGHTING_TYPE;
typedef enum typedef enum
{ {

2
engine/FMOD/inc/fmod_output.h

@ -67,7 +67,7 @@ typedef struct FMOD_OUTPUT_DESCRIPTION
unsigned int apiversion; unsigned int apiversion;
const char *name; const char *name;
unsigned int version; unsigned int version;
FMOD_OUTPUT_METHOD polling; /* This will become "method" on the next major version */
FMOD_OUTPUT_METHOD method;
FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK getnumdrivers; FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK getnumdrivers;
FMOD_OUTPUT_GETDRIVERINFO_CALLBACK getdriverinfo; FMOD_OUTPUT_GETDRIVERINFO_CALLBACK getdriverinfo;
FMOD_OUTPUT_INIT_CALLBACK init; FMOD_OUTPUT_INIT_CALLBACK init;

BIN
engine/FMOD/lib/x64/fmod.dll

BIN
engine/FMOD/lib/x64/fmodL.dll

BIN
engine/FMOD/lib/x64/fmodL_vc.lib

BIN
engine/FMOD/lib/x64/fmod_vc.lib

BIN
engine/FMOD/lib/x86/fmod.dll

BIN
engine/FMOD/lib/x86/fmodL.dll

BIN
engine/FMOD/lib/x86/fmodL_vc.lib

BIN
engine/FMOD/lib/x86/fmod_vc.lib

BIN
engine/FMOD/lib/x86/libfmod.a

BIN
engine/FMOD/lib/x86/libfmodL.a

31
engine/UniQuake/game_uniquake.c

@ -4,38 +4,43 @@
typedef struct unity_gamecalls_s typedef struct unity_gamecalls_s
{ {
void *target;
void(*SetEntityModel)(void *target, int entityNum, const char *modelName);
void(*SetEntityTransform)(void *target, int entityNum, vec3_t origin, vec3_t angles);
void(*RemoveEntity)(void *target, int entityNum);
void(*UpdateEntityAnimation)(void *target, int entityNum, int pose1, int pose2, float blend);
void(*SetEntitySkin)(void *target, int entityNum, int skinNum);
void(*SetEntityModel)(void *context, int entityNum, const char *modelName);
void(*SetEntityTransform)(void *context, int entityNum, vec3_t origin, vec3_t angles);
void(*RemoveEntity)(void *context, int entityNum);
void(*UpdateEntityAnimation)(void *context, int entityNum, int pose1, int pose2, float blend);
void(*SetEntitySkin)(void *context, int entityNum, int skinNum);
} unity_gamecalls_t; } unity_gamecalls_t;
const unity_gamecalls_t *unity_gamecalls;
static void *unity_context;
static const unity_gamecalls_t *unity_gamecalls;
UNIQUAKE_API void UniQuake_SetGameCallbacks(void *context, const unity_gamecalls_t *callbacks)
{
unity_context = context;
unity_gamecalls = callbacks;
}
void UQ_Game_SetEntityModel(int entityNum, const char *modelName) void UQ_Game_SetEntityModel(int entityNum, const char *modelName)
{ {
unity_gamecalls->SetEntityModel(unity_gamecalls->target, entityNum, modelName);
unity_gamecalls->SetEntityModel(unity_context, entityNum, modelName);
} }
void UQ_Game_SetEntityTransform(int entityNum, vec3_t origin, vec3_t angles) void UQ_Game_SetEntityTransform(int entityNum, vec3_t origin, vec3_t angles)
{ {
unity_gamecalls->SetEntityTransform(unity_gamecalls->target, entityNum, origin, angles);
unity_gamecalls->SetEntityTransform(unity_context, entityNum, origin, angles);
} }
void UQ_Game_RemoveEntity(int entityNum) void UQ_Game_RemoveEntity(int entityNum)
{ {
unity_gamecalls->RemoveEntity(unity_gamecalls->target, entityNum);
unity_gamecalls->RemoveEntity(unity_context, entityNum);
} }
void UQ_Game_UpdateEntityAnimation(int entityNum, int pose1, int pose2, float blend) void UQ_Game_UpdateEntityAnimation(int entityNum, int pose1, int pose2, float blend)
{ {
unity_gamecalls->UpdateEntityAnimation(unity_gamecalls->target, entityNum, pose1, pose2, blend);
unity_gamecalls->UpdateEntityAnimation(unity_context, entityNum, pose1, pose2, blend);
} }
void UQ_Game_SetEntitySkin(int entityNum, int skinNum) void UQ_Game_SetEntitySkin(int entityNum, int skinNum)
{ {
unity_gamecalls->SetEntitySkin(unity_gamecalls->target, entityNum, skinNum);
unity_gamecalls->SetEntitySkin(unity_context, entityNum, skinNum);
} }

35
engine/UniQuake/gl_uniquake.c

@ -5,47 +5,52 @@
typedef struct unity_glcalls_s typedef struct unity_glcalls_s
{ {
void *target;
int(*UploadAliasModel)(void *target, const char *name, aliashdr_t *aliashdr, aliasframetype_t frametype, maliasframedesc_t *frames, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts);
int(*UploadBrushModel)(void *target, qmodel_t *model);
int(*UploadWorldModel)(void *target, qmodel_t *model);
qboolean(*UploadTexture)(void *target, gltexture_t *texture, unsigned *data, GLuint *texnum);
qboolean(*UploadLightmap)(void *target, int lmap, byte *data);
void(*SetupView)(void *target, vec3_t origin, vec3_t angles, mleaf_t *viewLeaf);
int(*UploadAliasModel)(void *context, const char *name, aliashdr_t *aliashdr, aliasframetype_t frametype, maliasframedesc_t *frames, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts);
int(*UploadBrushModel)(void *context, qmodel_t *model);
int(*UploadWorldModel)(void *context, qmodel_t *model);
qboolean(*UploadTexture)(void *context, gltexture_t *texture, unsigned *data, GLuint *texnum);
qboolean(*UploadLightmap)(void *context, int lmap, byte *data);
void(*SetupView)(void *context, vec3_t origin, vec3_t angles, mleaf_t *viewLeaf);
} unity_glcalls_t; } unity_glcalls_t;
const unity_glcalls_t *unity_glcalls;
static void *unity_context;
static const unity_glcalls_t *unity_glcalls;
UNIQUAKE_API void UniQuake_SetRenderCallbacks(void *context, const unity_glcalls_t *callbacks)
{
unity_context = context;
unity_glcalls = callbacks;
}
int UQ_GL_UploadAliasModel(qmodel_t *model, aliashdr_t *aliashdr, aliasframetype_t frametype, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts) int UQ_GL_UploadAliasModel(qmodel_t *model, aliashdr_t *aliashdr, aliasframetype_t frametype, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts)
{ {
// C# doesn't really understand this idea of a variable-length embedded array of structs, // C# doesn't really understand this idea of a variable-length embedded array of structs,
// so we pass along the pointer to the first frame struct which allows us to manually marshal the entire array. // so we pass along the pointer to the first frame struct which allows us to manually marshal the entire array.
return unity_glcalls->UploadAliasModel(unity_glcalls->target, model->name, aliashdr, frametype, &aliashdr->frames[0], poseVerts, triangles, stVerts);
return unity_glcalls->UploadAliasModel(unity_context, model->name, aliashdr, frametype, &aliashdr->frames[0], poseVerts, triangles, stVerts);
} }
int UQ_GL_UploadBrushModel(qmodel_t *model) int UQ_GL_UploadBrushModel(qmodel_t *model)
{ {
return unity_glcalls->UploadBrushModel(unity_glcalls->target, model);
return unity_glcalls->UploadBrushModel(unity_context, model);
} }
int UQ_GL_UploadWorldModel(qmodel_t *model) int UQ_GL_UploadWorldModel(qmodel_t *model)
{ {
return unity_glcalls->UploadWorldModel(unity_glcalls->target, model);
return unity_glcalls->UploadWorldModel(unity_context, model);
} }
qboolean UQ_GL_UploadTexture(gltexture_t *texture, unsigned *data) qboolean UQ_GL_UploadTexture(gltexture_t *texture, unsigned *data)
{ {
// Allow UniQuake to either sync up its internal texture reference number, or assign a new one. // Allow UniQuake to either sync up its internal texture reference number, or assign a new one.
return unity_glcalls->UploadTexture(unity_glcalls->target, texture, data, &texture->texnum);
return unity_glcalls->UploadTexture(unity_context, texture, data, &texture->texnum);
} }
qboolean UQ_GL_UploadLightmap(int lmap, byte *data) qboolean UQ_GL_UploadLightmap(int lmap, byte *data)
{ {
return unity_glcalls->UploadLightmap(unity_glcalls->target, lmap, data);
return unity_glcalls->UploadLightmap(unity_context, lmap, data);
} }
void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf) void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf)
{ {
unity_glcalls->SetupView(unity_glcalls->target, origin, angles, viewLeaf);
unity_glcalls->SetupView(unity_context, origin, angles, viewLeaf);
} }

61
engine/UniQuake/sys_uniquake.c

@ -8,24 +8,29 @@ cvar_t sys_throttle = { "sys_throttle", "0.02", CVAR_ARCHIVE };
typedef struct unity_syscalls_s typedef struct unity_syscalls_s
{ {
void *target;
void(*SysPrint)(void *target, const char *msg);
void(*SysError)(void *target, const char *msg);
void(*SysQuit)(void *target);
double(*SysDoubleTime)(void *target);
int(*SysFileOpenRead)(void *target, const char *path, int *hndl);
int(*SysFileOpenWrite)(void *target, const char *path);
void(*SysFileClose)(void *target, int handle);
void(*SysFileSeek)(void *target, int handle, int position);
int(*SysFileRead)(void *target, int handle, void *dest, int count);
int(*SysFileWrite)(void *target, int handle, const void *data, int count);
int(*SysFileTime)(void *target, const char *path);
qboolean(*SysMkDir)(void *target, const char *path);
void(*SysPrint)(void *context, const char *msg);
void(*SysError)(void *context, const char *msg);
void(*SysQuit)(void *context);
double(*SysDoubleTime)(void *context);
int(*SysFileOpenRead)(void *context, const char *path, int *hndl);
int(*SysFileOpenWrite)(void *context, const char *path);
void(*SysFileClose)(void *context, int handle);
void(*SysFileSeek)(void *context, int handle, int position);
int(*SysFileRead)(void *context, int handle, void *dest, int count);
int(*SysFileWrite)(void *context, int handle, const void *data, int count);
int(*SysFileTime)(void *context, const char *path);
qboolean(*SysMkDir)(void *context, const char *path);
} unity_syscalls_t; } unity_syscalls_t;
const unity_syscalls_t *unity_syscalls;
static void *unity_context;
static const unity_syscalls_t *unity_syscalls;
UNIQUAKE_API void UniQuake_SetSysCallbacks(void *context, const unity_syscalls_t *callbacks)
{
unity_context = context;
unity_syscalls = callbacks;
}
void Sys_Error(const char *error, ...) void Sys_Error(const char *error, ...)
{ {
@ -36,7 +41,7 @@ void Sys_Error(const char *error, ...)
q_vsnprintf(text, sizeof(text), error, argptr); q_vsnprintf(text, sizeof(text), error, argptr);
va_end(argptr); va_end(argptr);
unity_syscalls->SysError(unity_syscalls->target, text);
unity_syscalls->SysError(unity_context, text);
} }
void Sys_Printf(const char *fmt, ...) void Sys_Printf(const char *fmt, ...)
@ -48,57 +53,57 @@ void Sys_Printf(const char *fmt, ...)
q_vsnprintf(text, sizeof(text), fmt, argptr); q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr); va_end(argptr);
unity_syscalls->SysPrint(unity_syscalls->target, text);
unity_syscalls->SysPrint(unity_context, text);
} }
void Sys_Quit(void) void Sys_Quit(void)
{ {
unity_syscalls->SysQuit(unity_syscalls->target);
unity_syscalls->SysQuit(unity_context);
} }
double Sys_DoubleTime(void) double Sys_DoubleTime(void)
{ {
return unity_syscalls->SysDoubleTime(unity_syscalls->target);
return unity_syscalls->SysDoubleTime(unity_context);
} }
int Sys_FileOpenRead(const char *path, int *hndl) int Sys_FileOpenRead(const char *path, int *hndl)
{ {
return unity_syscalls->SysFileOpenRead(unity_syscalls->target, path, hndl);
return unity_syscalls->SysFileOpenRead(unity_context, path, hndl);
} }
int Sys_FileOpenWrite(const char *path) int Sys_FileOpenWrite(const char *path)
{ {
return unity_syscalls->SysFileOpenWrite(unity_syscalls->target, path);
return unity_syscalls->SysFileOpenWrite(unity_context, path);
} }
void Sys_FileClose(int handle) void Sys_FileClose(int handle)
{ {
unity_syscalls->SysFileClose(unity_syscalls->target, handle);
unity_syscalls->SysFileClose(unity_context, handle);
} }
void Sys_FileSeek(int handle, int position) void Sys_FileSeek(int handle, int position)
{ {
unity_syscalls->SysFileSeek(unity_syscalls->target, handle, position);
unity_syscalls->SysFileSeek(unity_context, handle, position);
} }
int Sys_FileRead(int handle, void *dest, int count) int Sys_FileRead(int handle, void *dest, int count)
{ {
return unity_syscalls->SysFileRead(unity_syscalls->target, handle, dest, count);
return unity_syscalls->SysFileRead(unity_context, handle, dest, count);
} }
int Sys_FileWrite(int handle, const void *data, int count) int Sys_FileWrite(int handle, const void *data, int count)
{ {
return unity_syscalls->SysFileWrite(unity_syscalls->target, handle, data, count);
return unity_syscalls->SysFileWrite(unity_context, handle, data, count);
} }
int Sys_FileTime(const char *path) int Sys_FileTime(const char *path)
{ {
return unity_syscalls->SysFileTime(unity_syscalls->target, path);
return unity_syscalls->SysFileTime(unity_context, path);
} }
void Sys_mkdir(const char *path) void Sys_mkdir(const char *path)
{ {
if (!unity_syscalls->SysMkDir(unity_syscalls->target, path))
if (!unity_syscalls->SysMkDir(unity_context, path))
Sys_Error("Unable to create directory %s", path); Sys_Error("Unable to create directory %s", path);
} }

6
engine/UniQuake/uniquake.c

@ -14,14 +14,10 @@ UNIQUAKE_API void UniQuake_SetFmodSystem(FMOD_SYSTEM *system, int playernumber)
} }
#endif #endif
UNIQUAKE_API void UniQuake_Init(quakeparms_t *parms, const unity_syscalls_t *syscalls, const unity_glcalls_t *glcalls, const unity_gamecalls_t *gamecalls)
UNIQUAKE_API void UniQuake_Init(quakeparms_t *parms)
{ {
host_parms = parms; host_parms = parms;
unity_syscalls = syscalls;
unity_glcalls = glcalls;
unity_gamecalls = gamecalls;
COM_InitArgv(parms->argc, parms->argv); COM_InitArgv(parms->argc, parms->argv);
parms->argc = com_argc; parms->argc = com_argc;
parms->argv = com_argv; parms->argv = com_argv;

9
engine/UniQuake/uniquake.h

@ -8,12 +8,3 @@
#else #else
#define UNIQUAKE_API __declspec(dllimport) #define UNIQUAKE_API __declspec(dllimport)
#endif #endif
typedef struct unity_syscalls_s unity_syscalls_t;
extern const unity_syscalls_t *unity_syscalls;
typedef struct unity_glcalls_s unity_glcalls_t;
extern const unity_glcalls_t *unity_glcalls;
typedef struct unity_gamecalls_s unity_gamecalls_t;
extern const unity_gamecalls_t *unity_gamecalls;
Loading…
Cancel
Save