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

◆ VerifyCanDraw()

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyCanDraw ( [MarshalAs(UnmanagedType.U1)] bool bUserPrimitives,
[MarshalAs(UnmanagedType.U1)] bool bIndexedPrimitives )
inlinepackage

Definition at line 881 of file GraphicsDevice.cs.

882 {
883 if (lazyClearFlags != 0)
884 {
886 }
887 int num = 0;
889 {
890 do
891 {
892 currentRenderTargets[num].pTexture.SetContentLost(isContentLost: false);
893 num++;
894 }
895 while (num < currentRenderTargetCount);
896 }
897 StateTrackerDevice* ptr = pStateTracker;
898 uint num2 = *(uint*)((byte*)ptr + 20);
899 uint num3 = *(uint*)((byte*)ptr + 24);
900 Texture texture;
901 if (num2 != 0 && num3 != 0)
902 {
903 bool num4 = num2 < 768;
904 int num5 = ((num3 < 768) ? 1 : 0);
905 if ((num4 ? 1 : 0) != num5)
906 {
907 throw new InvalidOperationException(FrameworkResources.CannotMixShader2and3);
908 }
909 if (!_003CModule_003E.Microsoft_002EXna_002EFramework_002EGraphics_002EVertexShaderInputSemantics_002EIsCompatibleWithDecl((VertexShaderInputSemantics*)((byte*)ptr + 28), (VertexShaderInputSemantics*)((byte*)ptr + 60)))
910 {
911 string text = FrameworkResources.MissingVertexShaderInput;
912 ptr = pStateTracker;
913 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DDECLUSAGE usage);
914 System.Runtime.CompilerServices.Unsafe.SkipInit(out int num6);
915 if (_003CModule_003E.Microsoft_002EXna_002EFramework_002EGraphics_002EVertexShaderInputSemantics_002EGetMissingSemantic((VertexShaderInputSemantics*)((byte*)ptr + 28), (VertexShaderInputSemantics*)((byte*)ptr + 60), &usage, &num6))
916 {
917 text = string.Format(args: new object[3]
918 {
919 text,
920 _003CModule_003E.ConvertDxVertexElementUsageToXna(usage),
921 num6
922 }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.MissingVertexShaderInputDetails);
923 }
925 }
926 if (!willItBlend && *(int*)((byte*)pStateTracker + 112) != 0)
927 {
928 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileInvalidBlendFormat, whyWontItBlend);
929 }
930 StateTrackerDevice* ptr2 = pStateTracker;
931 uint num7 = (*(uint*)((byte*)ptr2 + 124) | *(uint*)((byte*)ptr2 + 120) | *(uint*)((byte*)ptr2 + 116)) & *(uint*)((byte*)ptr2 + 136);
932 if (num7 != 0)
933 {
934 int num8 = 0;
935 if ((num7 & 1) == 0)
936 {
937 do
938 {
939 num8++;
940 }
941 while (((uint)(1 << num8) & num7) == 0);
942 if (num8 >= 16)
943 {
944 texture = pVertexTextureCollection[num8 - 16];
945 goto IL_0183;
946 }
947 }
948 texture = pTextureCollection[num8];
949 goto IL_0183;
950 }
951 goto IL_01ad;
952 }
953 throw new InvalidOperationException(FrameworkResources.CannotDrawNoShader);
954 IL_0183:
955 SurfaceFormat surfaceFormat = texture?.Format ?? ((SurfaceFormat)(-1));
956 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileInvalidFilterFormat, surfaceFormat);
957 goto IL_01ad;
958 IL_01ad:
959 ptr = pStateTracker;
960 if (((*(int*)((byte*)ptr + 132) | *(int*)((byte*)ptr + 128)) & *(int*)((byte*)ptr + 140)) != 0)
961 {
962 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileNoWrapNonPow2);
963 }
964 if (!bUserPrimitives)
965 {
966 if (bIndexedPrimitives && _currentIB == null)
967 {
968 throw new InvalidOperationException(FrameworkResources.CannotDrawNoData);
969 }
971 {
972 throw new InvalidOperationException(FrameworkResources.CannotDrawNoData);
973 }
974 }
975 }
static CultureInfo CurrentCulture
void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._currentIB, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.FrameworkResources.CannotDrawNoData, Microsoft.Xna.Framework.FrameworkResources.CannotDrawNoShader, Microsoft.Xna.Framework.FrameworkResources.CannotMixShader2and3, Microsoft.Xna.Framework.Graphics.GraphicsDevice.ClearDirtyBuffers(), System.Globalization.CultureInfo.CurrentCulture, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargetCount, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargets, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentVertexBufferCount, Microsoft.Xna.Framework.Graphics.Texture.Format, System.format, Microsoft.Xna.Framework.Graphics.GraphicsDevice.lazyClearFlags, Microsoft.Xna.Framework.FrameworkResources.MissingVertexShaderInput, Microsoft.Xna.Framework.FrameworkResources.MissingVertexShaderInputDetails, Microsoft.Xna.Framework.FrameworkResources.ProfileInvalidBlendFormat, Microsoft.Xna.Framework.FrameworkResources.ProfileInvalidFilterFormat, Microsoft.Xna.Framework.FrameworkResources.ProfileNoWrapNonPow2, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pStateTracker, Microsoft.Xna.Framework.Graphics.RenderTargetHelper.pTexture, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pTextureCollection, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pVertexTextureCollection, Microsoft.Xna.Framework.Graphics.IDynamicGraphicsResource.SetContentLost(), System.text, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.whyWontItBlend, and Microsoft.Xna.Framework.Graphics.GraphicsDevice.willItBlend.

Referenced by Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawInstancedPrimitives(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawPrimitives(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserIndexedPrimitives< T >(), and Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives< T >().