191 lines
6.2 KiB
C#
191 lines
6.2 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security;
|
|
using UnityEngine.Scripting;
|
|
|
|
namespace UnityEngine
|
|
{
|
|
// Token: 0x0200002D RID: 45
|
|
public sealed class ComputeBuffer : IDisposable
|
|
{
|
|
// Token: 0x060003AC RID: 940 RVA: 0x00006768 File Offset: 0x00004968
|
|
public ComputeBuffer(int count, int stride)
|
|
: this(count, stride, ComputeBufferType.Default, 3)
|
|
{
|
|
}
|
|
|
|
// Token: 0x060003AD RID: 941 RVA: 0x00006778 File Offset: 0x00004978
|
|
public ComputeBuffer(int count, int stride, ComputeBufferType type)
|
|
: this(count, stride, type, 3)
|
|
{
|
|
}
|
|
|
|
// Token: 0x060003AE RID: 942 RVA: 0x00006788 File Offset: 0x00004988
|
|
internal ComputeBuffer(int count, int stride, ComputeBufferType type, int stackDepth)
|
|
{
|
|
if (count <= 0)
|
|
{
|
|
throw new ArgumentException("Attempting to create a zero length compute buffer", "count");
|
|
}
|
|
if (stride < 0)
|
|
{
|
|
throw new ArgumentException("Attempting to create a compute buffer with a negative stride", "stride");
|
|
}
|
|
this.m_Ptr = IntPtr.Zero;
|
|
ComputeBuffer.InitBuffer(this, count, stride, type);
|
|
}
|
|
|
|
// Token: 0x060003AF RID: 943 RVA: 0x000067E0 File Offset: 0x000049E0
|
|
~ComputeBuffer()
|
|
{
|
|
this.Dispose(false);
|
|
}
|
|
|
|
// Token: 0x060003B0 RID: 944 RVA: 0x00006814 File Offset: 0x00004A14
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
// Token: 0x060003B1 RID: 945 RVA: 0x00006824 File Offset: 0x00004A24
|
|
private void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
ComputeBuffer.DestroyBuffer(this);
|
|
}
|
|
else if (this.m_Ptr != IntPtr.Zero)
|
|
{
|
|
Debug.LogWarning("GarbageCollector disposing of ComputeBuffer. Please use ComputeBuffer.Release() or .Dispose() to manually release the buffer.");
|
|
}
|
|
this.m_Ptr = IntPtr.Zero;
|
|
}
|
|
|
|
// Token: 0x060003B2 RID: 946
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern void InitBuffer(ComputeBuffer buf, int count, int stride, ComputeBufferType type);
|
|
|
|
// Token: 0x060003B3 RID: 947
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern void DestroyBuffer(ComputeBuffer buf);
|
|
|
|
// Token: 0x060003B4 RID: 948 RVA: 0x00006874 File Offset: 0x00004A74
|
|
public void Release()
|
|
{
|
|
this.Dispose();
|
|
}
|
|
|
|
// Token: 0x170000CB RID: 203
|
|
// (get) Token: 0x060003B5 RID: 949
|
|
public extern int count
|
|
{
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
get;
|
|
}
|
|
|
|
// Token: 0x170000CC RID: 204
|
|
// (get) Token: 0x060003B6 RID: 950
|
|
public extern int stride
|
|
{
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
get;
|
|
}
|
|
|
|
// Token: 0x060003B7 RID: 951 RVA: 0x00006880 File Offset: 0x00004A80
|
|
[SecuritySafeCritical]
|
|
public void SetData(Array data)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new ArgumentNullException("data");
|
|
}
|
|
this.InternalSetData(data, 0, 0, data.Length, Marshal.SizeOf(data.GetType().GetElementType()));
|
|
}
|
|
|
|
// Token: 0x060003B8 RID: 952 RVA: 0x000068B4 File Offset: 0x00004AB4
|
|
[SecuritySafeCritical]
|
|
public void SetData(Array data, int managedBufferStartIndex, int computeBufferStartIndex, int count)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new ArgumentNullException("data");
|
|
}
|
|
if (managedBufferStartIndex < 0 || computeBufferStartIndex < 0 || count < 0 || managedBufferStartIndex + count > data.Length)
|
|
{
|
|
throw new ArgumentOutOfRangeException(string.Format("Bad indices/count arguments (managedBufferStartIndex:{0} computeBufferStartIndex:{1} count:{2})", managedBufferStartIndex, computeBufferStartIndex, count));
|
|
}
|
|
this.InternalSetData(data, managedBufferStartIndex, computeBufferStartIndex, count, Marshal.SizeOf(data.GetType().GetElementType()));
|
|
}
|
|
|
|
// Token: 0x060003B9 RID: 953
|
|
[SecurityCritical]
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private extern void InternalSetData(Array data, int managedBufferStartIndex, int computeBufferStartIndex, int count, int elemSize);
|
|
|
|
// Token: 0x060003BA RID: 954 RVA: 0x00006938 File Offset: 0x00004B38
|
|
[SecurityCritical]
|
|
public void GetData(Array data)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new ArgumentNullException("data");
|
|
}
|
|
this.InternalGetData(data, 0, 0, data.Length, Marshal.SizeOf(data.GetType().GetElementType()));
|
|
}
|
|
|
|
// Token: 0x060003BB RID: 955 RVA: 0x0000696C File Offset: 0x00004B6C
|
|
[SecurityCritical]
|
|
public void GetData(Array data, int managedBufferStartIndex, int computeBufferStartIndex, int count)
|
|
{
|
|
if (data == null)
|
|
{
|
|
throw new ArgumentNullException("data");
|
|
}
|
|
if (managedBufferStartIndex < 0 || computeBufferStartIndex < 0 || count < 0 || managedBufferStartIndex + count > data.Length)
|
|
{
|
|
throw new ArgumentOutOfRangeException(string.Format("Bad indices/count argument (managedBufferStartIndex:{0} computeBufferStartIndex:{1} count:{2})", managedBufferStartIndex, computeBufferStartIndex, count));
|
|
}
|
|
this.InternalGetData(data, managedBufferStartIndex, computeBufferStartIndex, count, Marshal.SizeOf(data.GetType().GetElementType()));
|
|
}
|
|
|
|
// Token: 0x060003BC RID: 956
|
|
[SecurityCritical]
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private extern void InternalGetData(Array data, int managedBufferStartIndex, int computeBufferStartIndex, int count, int elemSize);
|
|
|
|
// Token: 0x060003BD RID: 957
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
public extern void SetCounterValue(uint counterValue);
|
|
|
|
// Token: 0x060003BE RID: 958
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
public static extern void CopyCount(ComputeBuffer src, ComputeBuffer dst, int dstOffsetBytes);
|
|
|
|
// Token: 0x060003BF RID: 959 RVA: 0x000069F0 File Offset: 0x00004BF0
|
|
public IntPtr GetNativeBufferPtr()
|
|
{
|
|
IntPtr intPtr;
|
|
ComputeBuffer.INTERNAL_CALL_GetNativeBufferPtr(this, out intPtr);
|
|
return intPtr;
|
|
}
|
|
|
|
// Token: 0x060003C0 RID: 960
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern void INTERNAL_CALL_GetNativeBufferPtr(ComputeBuffer self, out IntPtr value);
|
|
|
|
// Token: 0x0400003C RID: 60
|
|
internal IntPtr m_Ptr;
|
|
}
|
|
}
|