Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyData< T >()

unsafe void Microsoft.Xna.Framework.Graphics.IndexBuffer.CopyData< T > ( int offsetInBytes,
T[] data,
int startIndex,
int elementCount,
uint options,
[MarshalAs(UnmanagedType.U1)] bool isSetting )
inlineprotected
Type Constraints
T :struct 

Definition at line 136 of file IndexBuffer.cs.

136 : struct
137 {
138 IntPtr intPtr = (IntPtr)pComPtr;
139 Helpers.CheckDisposed(this, intPtr);
140 if (data != null && data.Length != 0)
141 {
142 int num = -2147467259;
143 if ((options & 0x3010) == 0 && _parent.Indices == this)
144 {
145 throw GraphicsHelpers.GetExceptionFromResult(2147500036u);
146 }
147 if (!isSetting && (_usage & 8) == 8)
148 {
149 throw new NotSupportedException(FrameworkResources.WriteOnlyGetNotSupported);
150 }
151 Helpers.ValidateCopyParameters(data.Length, startIndex, elementCount);
152 try
153 {
154 uint num2 = (uint)(System.Runtime.CompilerServices.Unsafe.SizeOf<T>() * elementCount);
155 if ((uint)((int)num2 + offsetInBytes) > _bufferSize)
156 {
157 throw new InvalidOperationException(FrameworkResources.ResourceDataMustBeCorrectSize);
158 }
160 {
161 if (isSetting)
162 {
163 return;
164 }
165 fixed (T* ptr = &data[startIndex])
166 {
167 try
168 {
169 // IL initblk instruction
171 }
172 catch
173 {
174 //try-fault
175 ptr = null;
176 throw;
177 }
178 }
179 return;
180 }
181 void* ptr2 = null;
182 byte* ptr3 = (byte*)pBufferData;
183 if (IsWriteOnly && _pool == 1)
184 {
185 ptr3 = offsetInBytes + ptr3;
186 }
187 IDirect3DIndexBuffer9* ptr4 = pComPtr;
188 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, void**, uint, int>)(int)(*(uint*)(*(int*)ptr4 + 44)))((nint)ptr4, (uint)offsetInBytes, num2, &ptr2, options);
189 if (num >= 0)
190 {
191 fixed (T* ptr5 = &data[startIndex])
192 {
193 try
194 {
195 if (isSetting)
196 {
197 _003CModule_003E.memcpy_s(ptr2, _bufferSize - (uint)offsetInBytes, ptr5, num2);
198 if (IsWriteOnly && _pool == 1)
199 {
200 _003CModule_003E.memcpy_s(ptr3, _bufferSize - (uint)offsetInBytes, ptr5, num2);
201 }
202 }
203 else
204 {
205 _003CModule_003E.memcpy_s(ptr5, num2, ptr2, num2);
206 }
207 }
208 catch
209 {
210 //try-fault
211 ptr5 = null;
212 throw;
213 }
214 }
215 }
216 }
217 finally
218 {
219 if (num >= 0)
220 {
221 IDirect3DIndexBuffer9* intPtr2 = pComPtr;
222 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)intPtr2 + 48)))((nint)intPtr2);
223 }
224 }
225 if (num < 0)
226 {
227 throw GraphicsHelpers.GetExceptionFromResult((uint)num);
228 }
229 if (isSetting && this is IDynamicGraphicsResource dynamicGraphicsResource)
230 {
231 dynamicGraphicsResource.SetContentLost(isContentLost: false);
232 }
233 return;
234 }
235 throw new ArgumentNullException("data", FrameworkResources.NullNotAllowed);
236 }
unsafe IDirect3DIndexBuffer9 * pComPtr
static unsafe void InitBlock(void *startAddress, byte value, uint byteCount)
Definition Unsafe.cs:117

References Microsoft.Xna.Framework.Graphics.IndexBuffer._bufferSize, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Graphics.IndexBuffer._pool, Microsoft.Xna.Framework.Graphics.IndexBuffer._usage, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), System.Runtime.CompilerServices.Unsafe.InitBlock(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.IsDeviceLost, Microsoft.Xna.Framework.Graphics.IndexBuffer.IsWriteOnly, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, System.options, Microsoft.Xna.Framework.Graphics.IndexBuffer.pBufferData, Microsoft.Xna.Framework.Graphics.IndexBuffer.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ResourceDataMustBeCorrectSize, System.startIndex, Microsoft.Xna.Framework.Helpers.ValidateCopyParameters(), and Microsoft.Xna.Framework.FrameworkResources.WriteOnlyGetNotSupported.