Got RenderApi project to compile

This commit is contained in:
Yoshi Askharoun
2021-07-11 23:41:18 -05:00
parent dfb03d2ec5
commit c2a463bd0e
45 changed files with 96 additions and 91 deletions
@@ -19,17 +19,16 @@ namespace Microsoft.Iris.Render.Internal
public override bool Equals(object oCompare)
{
switch (oCompare)
{
case uint num:
label_3:
return (int)this.m_value == (int)num;
case EventCookie eventCookie:
num = eventCookie.m_value;
goto label_3;
default:
return false;
}
uint num;
if (oCompare is EventCookie eventCookie)
num = eventCookie.m_value;
else if (oCompare is uint value)
num = value;
else
return false;
return (int)m_value == (int)num;
}
public override int GetHashCode() => (int)this.m_value;
@@ -213,14 +213,14 @@ namespace Microsoft.Iris.Render.Internal
InitMessageDump();
if (uMsg >= s_rgsMessageNames.Length)
return null;
string rgsMessageName = s_rgsMessageNames[(IntPtr)uMsg];
string rgsMessageName = s_rgsMessageNames[uMsg];
if (rgsMessageName != null)
return rgsMessageName;
uint num = uMsg;
while (uMsg > 0U)
{
--num;
rgsMessageName = s_rgsMessageNames[(IntPtr)num];
rgsMessageName = s_rgsMessageNames[num];
if (rgsMessageName != null)
break;
}
@@ -98,7 +98,7 @@ namespace Microsoft.Iris.Render.Protocol
else
{
byte* numPtr2 = (byte*)chPtr1;
for (byte* numPtr3 = numPtr2 + ((IntPtr)(str.Length + 1) * 2).ToInt64(); numPtr2 < numPtr3; numPtr2 += 2)
for (byte* numPtr3 = numPtr2 + ((long)(str.Length + 1) * 2); numPtr2 < numPtr3; numPtr2 += 2)
{
*numPtr1++ = numPtr2[1];
*numPtr1++ = *numPtr2;
@@ -123,7 +123,7 @@ namespace Microsoft.Iris.Render.Protocol
else
{
byte* numPtr2 = (byte*)renderhandlePtr;
for (byte* numPtr3 = numPtr2 + ((IntPtr)renderhandleArray.Length * 4).ToInt64(); numPtr2 < numPtr3; numPtr2 += 4)
for (byte* numPtr3 = numPtr2 + ((long)renderhandleArray.Length * 4); numPtr2 < numPtr3; numPtr2 += 4)
{
*numPtr1++ = numPtr2[3];
*numPtr1++ = numPtr2[2];
@@ -80,7 +80,7 @@ namespace Microsoft.Iris.Render.Protocol
get
{
this.ValidateSlot(index);
GCHandle gcHandle = this.m_objects[(IntPtr)index];
GCHandle gcHandle = this.m_objects[index];
return !gcHandle.IsAllocated ? null : (IRenderHandleOwner)gcHandle.Target;
}
set
@@ -101,7 +101,7 @@ namespace Microsoft.Iris.Render.Protocol
{
if (!this.ValidateAccess(index, expectedUniqueness, fAllowInvalid))
return null;
GCHandle gcHandle = this.m_objects[(IntPtr)index];
GCHandle gcHandle = this.m_objects[index];
return !gcHandle.IsAllocated ? null : (IRenderHandleOwner)gcHandle.Target;
}
@@ -185,16 +185,16 @@ namespace Microsoft.Iris.Render.Protocol
private void SetIndex(uint index, IRenderHandleOwner newOwner)
{
GCHandle gch = this.m_objects[(IntPtr)index];
GCHandle gch = this.m_objects[index];
if (!IsEmpty(gch))
{
((IRenderHandleOwner)gch.Target)?.OnDisconnect();
gch.Free();
}
if (newOwner != null)
this.m_objects[(IntPtr)index] = GCHandle.Alloc(newOwner, this.m_ht);
this.m_objects[index] = GCHandle.Alloc(newOwner, this.m_ht);
else
this.m_objects[(IntPtr)index] = s_gchEmpty;
this.m_objects[index] = s_gchEmpty;
}
private void UpdateUniqueness(uint index, out uint unique)
@@ -202,9 +202,9 @@ namespace Microsoft.Iris.Render.Protocol
byte num1 = 0;
if (this.m_uniqueness != null)
{
byte num2 = this.m_uniqueness[(IntPtr)index];
byte num2 = this.m_uniqueness[index];
num1 = num2 >= byte.MaxValue ? (byte)1 : (byte)(num2 + 1U);
this.m_uniqueness[(IntPtr)index] = num1;
this.m_uniqueness[index] = num1;
}
unique = num1;
}
@@ -214,7 +214,7 @@ namespace Microsoft.Iris.Render.Protocol
Debug2.Validate(unique <= byte.MaxValue, typeof(ArgumentOutOfRangeException), "Uniqueness must be a byte");
if (this.m_uniqueness == null)
return;
this.m_uniqueness[(IntPtr)index] = (byte)(unique & byte.MaxValue);
this.m_uniqueness[index] = (byte)(unique & byte.MaxValue);
}
private void ValidateSlot(uint index) => this.ValidateSlot(index, false);
@@ -222,7 +222,7 @@ namespace Microsoft.Iris.Render.Protocol
private bool ValidateSlot(uint index, bool fAllowInvalid)
{
bool flag = false;
if (index < this.m_alloc && ((int)this.m_usage[(IntPtr)(index >> 5)] & 1 << (int)index) != 0)
if (index < this.m_alloc && ((int)this.m_usage[index >> 5] & 1 << (int)index) != 0)
flag = true;
Debug2.Throw(flag || fAllowInvalid, "Slot is not allocated");
return flag;
@@ -233,7 +233,7 @@ namespace Microsoft.Iris.Render.Protocol
private bool ValidateSlotFree(uint index, bool fAllowInvalid)
{
bool flag = false;
if (index < this.m_alloc && ((int)this.m_usage[(IntPtr)(index >> 5)] & 1 << (int)index) == 0)
if (index < this.m_alloc && ((int)this.m_usage[index >> 5] & 1 << (int)index) == 0)
flag = true;
Debug2.Throw(flag || fAllowInvalid, "Slot is not free");
return flag;
@@ -247,7 +247,7 @@ namespace Microsoft.Iris.Render.Protocol
return false;
uint num = 0;
if (this.m_uniqueness != null)
num = this.m_uniqueness[(IntPtr)index];
num = this.m_uniqueness[index];
bool flag = (int)expectedUniqueness == (int)num;
Debug2.Throw(flag || fAllowInvalid, "Slot uniqueness is stale");
return flag;
@@ -259,7 +259,7 @@ namespace Microsoft.Iris.Render.Protocol
uint hint;
for (hint = this.m_hint; hint < m_usage.Length; ++hint)
{
num1 = this.m_usage[(IntPtr)hint];
num1 = this.m_usage[hint];
if (num1 != uint.MaxValue)
break;
}
@@ -278,7 +278,7 @@ namespace Microsoft.Iris.Render.Protocol
maxValue >>= (int)num2;
}
while (num2 != 0U);
this.m_usage[(IntPtr)hint] |= 1U << (int)num3;
this.m_usage[hint] |= 1U << (int)num3;
++this.m_used;
return hint << 5 | num3;
}
@@ -286,14 +286,14 @@ namespace Microsoft.Iris.Render.Protocol
private void AllocSlotAt(uint index)
{
this.ValidateSlotFree(index);
this.m_usage[(IntPtr)(index >> 5)] |= 1U << (int)index;
this.m_usage[index >> 5] |= 1U << (int)index;
++this.m_used;
}
private void FreeSlot(uint index)
{
uint num = index >> 5;
this.m_usage[(IntPtr)num] &= (uint)~(1 << (int)index);
this.m_usage[num] &= (uint)~(1 << (int)index);
--this.m_used;
if (this.m_hint <= num)
return;
@@ -315,15 +315,15 @@ namespace Microsoft.Iris.Render.Protocol
{
Debug2.Validate(newSize > this.m_alloc, typeof(ArgumentException), nameof(newSize));
Debug2.Validate(newSize <= this.m_maxObjects, typeof(InvalidOperationException), "Too many video resources have been allocated");
GCHandle[] gcHandleArray = new GCHandle[(IntPtr)newSize];
GCHandle[] gcHandleArray = new GCHandle[newSize];
uint[] numArray1 = null;
byte[] numArray2 = null;
uint num = (uint)((int)newSize + 32 - 1) >> 5;
if (this.m_usage == null || m_usage.Length < num)
numArray1 = new uint[(IntPtr)num];
numArray1 = new uint[num];
if (this.m_uniqueness != null)
{
numArray2 = new byte[(IntPtr)newSize];
numArray2 = new byte[newSize];
Array.Copy(m_uniqueness, numArray2, this.m_uniqueness.Length);
}
if (this.m_objects != null)
@@ -347,16 +347,16 @@ namespace Microsoft.Iris.Render.Protocol
public ObjectCopy(HandleGroup map)
{
uint used = map.m_used;
this.m_arObjects = new IRenderHandleOwner[(IntPtr)used];
this.m_arObjects = new IRenderHandleOwner[used];
uint num = 0;
for (uint index = 0; index < used; ++index)
{
GCHandle gch = map.m_objects[(IntPtr)index];
GCHandle gch = map.m_objects[index];
if (!IsEmpty(gch))
{
IRenderHandleOwner target = (IRenderHandleOwner)gch.Target;
if (target != null)
this.m_arObjects[(IntPtr)num++] = target;
this.m_arObjects[num++] = target;
}
}
}
@@ -25,10 +25,11 @@ namespace Microsoft.Iris.Render.Protocol
MessageCookieLayout layout)
{
Debug2.Validate(remoteContextId != ContextID.NULL, typeof(ArgumentNullException), nameof(remoteContextId));
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref new EngineApi.InitArgs(layout, remoteContextId)
var args = new EngineApi.InitArgs(layout, remoteContextId)
{
idObjectBrokerClass = brokerClassHandle
}, out this.m_renderThread));
};
EngineApi.IFC(EngineApi.SpRenderThreadInit(ref args, out this.m_renderThread));
}
protected override void Dispose(bool inDispose)
@@ -71,10 +71,10 @@ namespace Microsoft.Iris.Render.Protocol
break;
ushort* numPtr1 = (ushort*)pointer1;
ushort* numPtr2 = (ushort*)pointer1;
ushort* numPtr3 = (ushort*)((IntPtr)numPtr2 + new IntPtr(2));
ushort* numPtr3 = (ushort*)(numPtr2 + 2);
ushort num3 = *numPtr2;
ushort* numPtr4 = numPtr1;
ushort* numPtr5 = (ushort*)((IntPtr)numPtr4 + new IntPtr(2));
ushort* numPtr5 = (ushort*)(numPtr4 + 2);
int num4 = (ushort)((num3 & 65280) >> 8 | (num3 & byte.MaxValue) << 8);
*numPtr4 = (ushort)num4;
break;
@@ -39,7 +39,7 @@ namespace Microsoft.Iris.Render.Protocol
{
}
internal MessagingSession(
internal unsafe MessagingSession(
IRenderHost renderHost,
RenderToken token,
TimeoutHandler handlerTimeout,
@@ -13,7 +13,7 @@ namespace Microsoft.Iris.Render.Protocol
{
private bool m_fFreeOnDispose;
protected RenderPort m_renderPort;
protected RENDERHANDLE m_renderHandle;
internal RENDERHANDLE m_renderHandle;
public RemoteObject(RenderPort port, IRenderHandleOwner owner)
{
@@ -215,28 +215,30 @@ namespace Microsoft.Iris.Render.Protocol
{
Debug2.Validate(idRemoteBuffer != RENDERHANDLE.NULL, typeof(ArgumentNullException), nameof(idRemoteBuffer));
this.UpdateTraffic(0U, cbSize);
EngineApi.IFC(EngineApi.SpBufferOpen(&new EngineApi.BufferInfo()
var info = new EngineApi.BufferInfo
{
idContextSrc = this._session.LocalContext,
idContextDest = this._idRemoteContext,
idBuffer = idRemoteBuffer,
nFlags = 0,
cbSizeBuffer = cbSize
}, pvData));
};
EngineApi.IFC(EngineApi.SpBufferOpen(&info, pvData));
}
public unsafe void SendBatchBuffer(void* pvData, uint cbSize, RENDERHANDLE idRemoteBuffer)
{
int num = idRemoteBuffer != RENDERHANDLE.NULL ? 1 : 0;
this.UpdateTraffic(cbSize, 0U);
EngineApi.IFC(EngineApi.SpBufferOpen(&new EngineApi.BufferInfo()
var info = new EngineApi.BufferInfo()
{
idContextSrc = this._session.LocalContext,
idContextDest = this._idRemoteContext,
idBuffer = idRemoteBuffer,
nFlags = EngineApi.BufferFlags.IsBatch,
cbSizeBuffer = cbSize
}, pvData));
};
EngineApi.IFC(EngineApi.SpBufferOpen(&info, pvData));
}
public unsafe void SendMessageBuffer(Message* pmsg)
@@ -245,14 +247,15 @@ namespace Microsoft.Iris.Render.Protocol
uint src = pmsg->cbSize;
if (this.ForeignByteOrder)
src = Memory.ConvertEndian(src);
EngineApi.IFC(EngineApi.SpBufferOpen(&new EngineApi.BufferInfo()
var info = new EngineApi.BufferInfo()
{
idContextSrc = this._session.LocalContext,
idContextDest = this._idRemoteContext,
idBuffer = RENDERHANDLE.NULL,
nFlags = EngineApi.BufferFlags.CopyData,
cbSizeBuffer = src
}, pmsg));
};
EngineApi.IFC(EngineApi.SpBufferOpen(&info, pmsg));
}
private void UpdateTraffic(uint uControl, uint uData)
@@ -571,7 +574,7 @@ namespace Microsoft.Iris.Render.Protocol
private void DeferredHeapReleaseWorker(object args) => this._spareHeapCache.Push((MessageHeap)args);
private object HeapCacheCallback(ObjectCache.Operation operation, object data)
private unsafe object HeapCacheCallback(ObjectCache.Operation operation, object data)
{
this.Session.AssertOwningThread();
MessageHeap key = data as MessageHeap;
@@ -660,12 +663,12 @@ namespace Microsoft.Iris.Render.Protocol
uint num2 = 2U * num1;
if (num2 == 0U)
num2 = 16U;
RENDERHANDLE[] renderhandleArray = new RENDERHANDLE[(IntPtr)num2];
RENDERHANDLE[] renderhandleArray = new RENDERHANDLE[num2];
if (num1 > 0U)
Array.Copy(_pendingBatchDeletes, renderhandleArray, this._pendingBatchDeletes.Length);
this._pendingBatchDeletes = renderhandleArray;
}
this._pendingBatchDeletes[(IntPtr)this._pendingBatchDeleteSlot] = handle;
this._pendingBatchDeletes[this._pendingBatchDeleteSlot] = handle;
++this._pendingBatchDeleteSlot;
}
@@ -690,12 +693,12 @@ namespace Microsoft.Iris.Render.Protocol
uint num2 = 2U * num1;
if (num2 == 0U)
num2 = 16U;
RENDERGROUP[] rendergroupArray = new RENDERGROUP[(IntPtr)num2];
RENDERGROUP[] rendergroupArray = new RENDERGROUP[num2];
if (num1 > 0U)
Array.Copy(_pendingBatchGroupDeletes, rendergroupArray, this._pendingBatchGroupDeletes.Length);
this._pendingBatchGroupDeletes = rendergroupArray;
}
this._pendingBatchGroupDeletes[(IntPtr)this._pendingBatchGroupDeleteSlot] = group;
this._pendingBatchGroupDeletes[this._pendingBatchGroupDeleteSlot] = group;
++this._pendingBatchGroupDeleteSlot;
}
@@ -46,7 +46,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,
@@ -34,7 +34,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,
@@ -40,7 +40,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Nt
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,
@@ -32,7 +32,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Nt
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,
@@ -32,7 +32,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Nt
RemoteDesktopManager remoteDesktopManager = new RemoteDesktopManager(port, _priv_owner);
uint num = (uint)sizeof(RemoteDesktopManager.Msg2_Create);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
RemoteDesktopManager.Msg2_Create* msg2CreatePtr = (RemoteDesktopManager.Msg2_Create*)pMem;
msg2CreatePtr->_priv_size = num;
msg2CreatePtr->_priv_msgid = 2U;
@@ -28,7 +28,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Nt
RemoteFormWindow remoteFormWindow = new RemoteFormWindow(port, _priv_owner);
uint num = (uint)sizeof(RemoteFormWindow.Msg41_Create);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
RemoteFormWindow.Msg41_Create* msg41CreatePtr = (RemoteFormWindow.Msg41_Create*)pMem;
msg41CreatePtr->_priv_size = num;
msg41CreatePtr->_priv_msgid = 41U;
@@ -33,7 +33,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Nt
RemoteHwndHostWindow remoteHwndHostWindow = new RemoteHwndHostWindow(port, _priv_owner);
uint num = (uint)sizeof(RemoteHwndHostWindow.Msg4_Create);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
RemoteHwndHostWindow.Msg4_Create* msg4CreatePtr = (RemoteHwndHostWindow.Msg4_Create*)pMem;
msg4CreatePtr->_priv_size = num;
msg4CreatePtr->_priv_msgid = 4U;
@@ -30,7 +30,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop
RemoteInputRouter remoteInputRouter = new RemoteInputRouter(port, _priv_owner);
uint num = (uint)sizeof(RemoteInputRouter.Msg2_Create);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
RemoteInputRouter.Msg2_Create* msg2CreatePtr = (RemoteInputRouter.Msg2_Create*)pMem;
msg2CreatePtr->_priv_size = num;
msg2CreatePtr->_priv_msgid = 2U;
@@ -27,7 +27,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Desktop.Xenon
RemoteFormWindow remoteFormWindow = new RemoteFormWindow(port, _priv_owner);
uint num = (uint)sizeof(RemoteFormWindow.Msg41_Create);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
RemoteFormWindow.Msg41_Create* msg41CreatePtr = (RemoteFormWindow.Msg41_Create*)pMem;
msg41CreatePtr->_priv_size = num;
msg41CreatePtr->_priv_msgid = 41U;
@@ -34,7 +34,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Messaging
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,
@@ -28,7 +28,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Messaging
RENDERHANDLE callbackInstance = _priv_protocolInstance.RenderPortCallback_CallbackInstance;
uint num = (uint)sizeof(LocalRenderPortCallback.Msg0_OnBatchProcessed);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
LocalRenderPortCallback.Msg0_OnBatchProcessed* onBatchProcessedPtr = (LocalRenderPortCallback.Msg0_OnBatchProcessed*)pMem;
onBatchProcessedPtr->_priv_size = num;
onBatchProcessedPtr->_priv_msgid = 0U;
@@ -48,7 +48,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Messaging
RENDERHANDLE callbackInstance = _priv_protocolInstance.RenderPortCallback_CallbackInstance;
uint num = (uint)sizeof(LocalRenderPortCallback.Msg1_OnPingReply);
// ISSUE: untyped stack allocation
byte* pMem = (byte*)__untypedstackalloc(1 * (int)num);
byte* pMem = stackalloc byte[(int)num];
LocalRenderPortCallback.Msg1_OnPingReply* msg1OnPingReplyPtr = (LocalRenderPortCallback.Msg1_OnPingReply*)pMem;
msg1OnPingReplyPtr->_priv_size = num;
msg1OnPingReplyPtr->_priv_msgid = 1U;
@@ -75,7 +75,7 @@ namespace Microsoft.Iris.Render.Protocols.Splash.Messaging
public override int GetHashCode() => base.GetHashCode();
internal static RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
internal static unsafe RENDERHANDLE BindCallback(RenderPort port) => port.RegisterCallback(new PortCallback(DispatchCallback), out uint _);
private static unsafe void DispatchCallback(
RenderPort port,

Some files were not shown because too many files have changed in this diff Show More