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

◆ CreateNativeDeclaration()

unsafe void Microsoft.Xna.Framework.Graphics.DeclarationManager.CreateNativeDeclaration ( DeclarationBinding::BindingNode node)
inlineprivate

Definition at line 295 of file DeclarationManager.cs.

296 {
297 int num = 0;
298 int num2 = 0;
300 if (0 < num3)
301 {
302 DeclarationBinding[] array = currentDeclarations;
303 do
304 {
305 num = (int)((nint)array[num2].elements.LongLength + num);
306 num2++;
307 }
308 while (num2 < num3);
309 }
311 if (num > maxVertexStreams)
312 {
313 device._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileMaxVertexElements, maxVertexStreams);
314 }
315 int num4 = num + 1;
316 _D3DVERTEXELEMENT9* ptr = (_D3DVERTEXELEMENT9*)_003CModule_003E.new_005B_005D(((uint)num4 > 536870911u) ? uint.MaxValue : ((uint)(num4 << 3)), (nothrow_t*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.std_002Enothrow));
317 if (ptr == null)
318 {
319 throw new OutOfMemoryException();
320 }
321 try
322 {
323 int num5 = 0;
324 for (int i = 0; i < currentDeclarationCount; i++)
325 {
326 VertexElement[] elements = currentDeclarations[i].elements;
327 for (int j = 0; j < (nint)elements.LongLength; j++)
328 {
330 *(short*)ptr2 = (short)i;
331 *(short*)((byte*)ptr2 + 2) = (short)elements[j].Offset;
332 ((byte*)ptr2)[4] = _003CModule_003E.ConvertXnaVertexElementFormatToDx(elements[j].VertexElementFormat);
333 ((byte*)ptr2)[5] = 0;
334 ((byte*)ptr2)[6] = _003CModule_003E.ConvertXnaVertexElementUsageToDx(elements[j].VertexElementUsage);
335 ((byte*)ptr2)[7] = (byte)elements[j].UsageIndex;
336 while (IsDuplicateElement(ptr, num5))
337 {
338 byte b = (byte)(((byte*)ptr2)[7] + 1);
339 ((byte*)ptr2)[7] = b;
341 {
342 throw new ArgumentException(string.Format(args: new object[2]
343 {
344 elements[j].VertexElementUsage,
345 elements[j].UsageIndex
346 }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.DuplicateVertexElement));
347 }
348 }
349 num5++;
350 }
351 }
353 *(short*)(&d3DVERTEXELEMENT) = 255;
359 // IL cpblk instruction
363 int num6 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DVERTEXELEMENT9*, IDirect3DVertexDeclaration9**, int>)(int)(*(uint*)(*(int*)pComPtr + 344)))((nint)pComPtr, ptr, &ptr3);
364 if (num6 < 0)
365 {
366 throw GraphicsHelpers.GetExceptionFromResult((uint)num6);
367 }
368 VertexShaderInputSemantics* ptr4 = (VertexShaderInputSemantics*)_003CModule_003E.@new(32u, (nothrow_t*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.std_002Enothrow));
369 VertexShaderInputSemantics* ptr5;
370 try
371 {
373 VertexShaderInputSemantics* ptr6 = ptr5;
374 }
375 catch
376 {
377 //try-fault
379 throw;
380 }
381 node.pSemantics = ptr5;
382 if (ptr5 == null)
383 {
385 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr + 8)))((nint)intPtr);
386 throw new OutOfMemoryException();
387 }
388 node.pDecl = ptr3;
389 }
390 finally
391 {
392 _003CModule_003E.delete_005B_005D(ptr);
393 }
394 }
static unsafe bool IsDuplicateElement(_D3DVERTEXELEMENT9 *elements, int pos)
static CultureInfo CurrentCulture
static unsafe void CopyBlockUnaligned(void *destination, void *source, uint byteCount)
Definition Unsafe.cs:101

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, System.array, System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(), System.Globalization.CultureInfo.CurrentCulture, Microsoft.Xna.Framework.Graphics.DeclarationManager.currentDeclarationCount, Microsoft.Xna.Framework.Graphics.DeclarationManager.currentDeclarations, Microsoft.Xna.Framework.Graphics.DeclarationManager.device, Microsoft.Xna.Framework.FrameworkResources.DuplicateVertexElement, Microsoft.Xna.Framework.Graphics.DeclarationBinding.elements, System.Globalization.Format, System.format, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.DeclarationManager.IsDuplicateElement(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxVertexStreams, Microsoft.Xna.Framework.Graphics.VertexElement.Offset, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfileMaxVertexElements, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), Microsoft.Xna.Framework.Graphics.VertexElement.UsageIndex, and Microsoft.Xna.Framework.Graphics.VertexElement.VertexElementUsage.

Referenced by Microsoft.Xna.Framework.Graphics.DeclarationManager.SetNativeDeclaration().