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

◆ SetVertexBuffers() [2/2]

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffers ( VertexBufferBinding * pBindings,
int vertexBufferCount )
inlinepackage

Definition at line 2399 of file GraphicsDevice.cs.

2400 {
2401 IntPtr intPtr = (IntPtr)pComPtr;
2402 Helpers.CheckDisposed(this, intPtr);
2403 int maxVertexStreams = _profileCapabilities.MaxVertexStreams;
2404 if (vertexBufferCount > maxVertexStreams)
2405 {
2406 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileMaxVertexStreams, maxVertexStreams);
2407 }
2408 int i = 0;
2409 try
2410 {
2411 for (i = 0; i < vertexBufferCount; i++)
2412 {
2413 VertexBuffer vertexBuffer = ((VertexBufferBinding*)(System.Runtime.CompilerServices.Unsafe.SizeOf<VertexBufferBinding>() * i + (byte*)pBindings))->_vertexBuffer;
2414 if (vertexBuffer == null)
2415 {
2416 throw new ArgumentException(FrameworkResources.NullNotAllowed);
2417 }
2418 IntPtr intPtr2 = (IntPtr)vertexBuffer.pComPtr;
2419 IntPtr intPtr3 = intPtr2;
2420 Helpers.CheckDisposed(vertexBuffer, intPtr2);
2421 if (vertexBuffer.GraphicsDevice != this)
2422 {
2423 throw new InvalidOperationException(FrameworkResources.InvalidDevice);
2424 }
2425 VertexBufferBinding[] array = currentVertexBuffers;
2426 VertexBuffer vertexBuffer2 = array[i]._vertexBuffer;
2427 VertexBufferBinding* ptr = (VertexBufferBinding*)((byte*)pBindings + System.Runtime.CompilerServices.Unsafe.SizeOf<VertexBufferBinding>() * i);
2428 int vertexOffset = ptr->_vertexOffset;
2429 int instanceFrequency = ptr->_instanceFrequency;
2430 if (vertexBuffer != vertexBuffer2 || vertexOffset != array[i]._vertexOffset || instanceFrequency != array[i]._instanceFrequency)
2431 {
2432 int vertexStride = vertexBuffer._vertexDeclaration._vertexStride;
2433 IDirect3DDevice9* ptr2 = pComPtr;
2434 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, IDirect3DVertexBuffer9*, uint, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 400)))((nint)ptr2, (uint)i, vertexBuffer.pComPtr, (uint)(vertexStride * vertexOffset), (uint)vertexStride);
2435 if (num < 0)
2436 {
2437 throw GraphicsHelpers.GetExceptionFromResult((uint)num);
2438 }
2439 ref VertexBufferBinding reference = ref currentVertexBuffers[i];
2440 reference = System.Runtime.CompilerServices.Unsafe.Read<VertexBufferBinding>(System.Runtime.CompilerServices.Unsafe.SizeOf<VertexBufferBinding>() * i + (byte*)pBindings);
2441 if (instanceFrequency != 0)
2442 {
2443 instanceStreamMask |= 1 << i;
2444 }
2445 else
2446 {
2447 instanceStreamMask &= ~(1 << i);
2448 }
2449 }
2450 }
2451 }
2452 finally
2453 {
2454 int num2 = i;
2456 {
2457 do
2458 {
2459 IDirect3DDevice9* ptr2 = pComPtr;
2460 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, IDirect3DVertexBuffer9*, uint, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 400)))((nint)ptr2, (uint)num2, null, 0u, 0u);
2461 currentVertexBuffers[num2] = default(VertexBufferBinding);
2462 instanceStreamMask &= ~(1 << num2);
2463 num2++;
2464 }
2465 while (num2 < currentVertexBufferCount);
2466 }
2468 }
2469 if (vertexBufferCount > 0)
2470 {
2471 vertexDeclarationManager.SetVertexDeclaration(pBindings, vertexBufferCount);
2472 }
2473 }
unsafe void SetVertexDeclaration(VertexBufferBinding *vertexBuffers, int count)

References Microsoft.Xna.Framework.Graphics.VertexBufferBinding._instanceFrequency, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.Graphics.VertexBuffer._vertexDeclaration, Microsoft.Xna.Framework.Graphics.VertexBufferBinding._vertexOffset, Microsoft.Xna.Framework.Graphics.VertexDeclaration._vertexStride, System.array, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentVertexBufferCount, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentVertexBuffers, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.GraphicsResource.GraphicsDevice, Microsoft.Xna.Framework.Graphics.GraphicsDevice.instanceStreamMask, Microsoft.Xna.Framework.FrameworkResources.InvalidDevice, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxVertexStreams, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.VertexBuffer.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfileMaxVertexStreams, Microsoft.Xna.Framework.Graphics.DeclarationManager.SetVertexDeclaration(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), and Microsoft.Xna.Framework.Graphics.GraphicsDevice.vertexDeclarationManager.

Referenced by Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset(), Microsoft.Xna.Framework.Graphics.SavedDeviceState.Restore(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffer(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffer(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffers(), and Terraria.DataStructures.SpriteDrawBuffer.Unbind().