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

◆ CreateEffectFromCode()

unsafe void Microsoft.Xna.Framework.Graphics.Effect.CreateEffectFromCode ( GraphicsDevice graphicsDevice,
byte[] effectCode )
inlineprivateinherited

Definition at line 94 of file Effect.cs.

95 {
96 //The blocks IL_0203 are reachable both inside and outside the pinned region starting at IL_0057. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
97 //The blocks IL_0203 are reachable both inside and outside the pinned region starting at IL_00ac. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
98 if (effectCode != null)
99 {
100 int num = effectCode.Length;
101 if (num != 0)
102 {
103 if (num % 4 != 0)
104 {
105 string text = "effectCode";
106 throw new ArgumentException(string.Format(FrameworkResources.ArrayMultipleFour, text), text);
107 }
108 if (graphicsDevice == null)
109 {
110 throw new ArgumentNullException("graphicsDevice", FrameworkResources.DeviceCannotBeNullOnResourceCreate);
111 }
112 if ((uint)num >= 8u)
113 {
114 ID3DXBuffer* ptr = null;
115 fixed (void* ptr2 = &System.Runtime.CompilerServices.Unsafe.As<byte, void>(ref effectCode[0]))
116 {
117 uint* ptr3 = (uint*)ptr2;
118 if (*ptr3 == 3169848271u)
119 {
120 ptr3++;
121 uint num2 = *ptr3;
122 if ((nint)effectCode.LongLength >= (int)(num2 + 4))
123 {
125 if (*(int*)ptr4 == -16840447)
126 {
127 StateTrackerDevice* pStateTracker = graphicsDevice.pStateTracker;
128 *(int*)((byte*)pStateTracker + 92) = 0;
129 *(int*)((byte*)pStateTracker + 96) = 0;
130 *(int*)((byte*)pStateTracker + 100) = 0;
132 {
133 int num3 = _003CModule_003E.D3DXCreateEffectEx((IDirect3DDevice9*)pStateTracker, ptr4, (uint)((nint)effectCode.LongLength - (int)num2), null, null, null, 131072u, null, ptr5, &ptr);
134 if (ptr != null)
135 {
137 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr + 8)))((nint)intPtr);
138 ptr = null;
139 }
140 uint num4 = *(uint*)((byte*)pStateTracker + 92);
141 if (num4 != 0)
142 {
143 graphicsDevice._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileVertexShaderModel, FormatShaderModel(num4));
144 }
145 uint num5 = *(uint*)((byte*)pStateTracker + 96);
146 if (num5 != 0)
147 {
148 graphicsDevice._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfilePixelShaderModel, FormatShaderModel(num5));
149 }
150 if (num3 < 0)
151 {
152 throw GraphicsHelpers.GetExceptionFromResult((uint)num3);
153 }
154 int num6 = *(int*)((byte*)pStateTracker + 100);
155 if (num6 < 0)
156 {
157 throw GraphicsHelpers.GetExceptionFromResult((uint)num6);
158 }
159 _parent = graphicsDevice;
161 graphicsDevice.Resources.AddTrackedObject(this, pComPtr, 0u, _internalHandle, ref _internalHandle);
165 if (!enumerator.MoveNext())
166 {
167 return;
168 }
169 do
170 {
172 if (!enumerator2.MoveNext())
173 {
174 continue;
175 }
176 uint* ptr6 = ptr3 + 1;
177 do
178 {
179 EffectPass current = enumerator2.Current;
180 if (ptr6 < ptr4)
181 {
182 ptr3++;
183 ptr6++;
184 current._stateFlags = (EffectStateFlags)(*ptr3);
185 ptr3++;
186 ptr6++;
187 current._textureFlags = *ptr3;
188 continue;
189 }
190 throw new InvalidOperationException(FrameworkResources.MustUserShaderCode);
191 }
192 while (enumerator2.MoveNext());
193 }
194 while (enumerator.MoveNext());
195 return;
196 }
197 }
198 }
199 }
200 throw new InvalidOperationException(FrameworkResources.MustUserShaderCode);
201 }
202 }
203 throw new InvalidOperationException(FrameworkResources.MustUserShaderCode);
204 }
205 }
206 throw new ArgumentNullException("effectCode", FrameworkResources.NullNotAllowed);
207 }
static string FormatShaderModel(uint shaderModel)
Definition Effect.cs:209
unsafe EffectTechnique CurrentTechnique
Definition Effect.cs:34
EffectTechniqueCollection pTechniqueCollection
Definition Effect.cs:13

References Microsoft.Xna.Framework.Graphics.GraphicsResource._internalHandle, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.Graphics.DeviceResourceManager.AddTrackedObject(), Microsoft.Xna.Framework.FrameworkResources.ArrayMultipleFour, Microsoft.Xna.Framework.Graphics.Effect.CurrentTechnique, Microsoft.Xna.Framework.FrameworkResources.DeviceCannotBeNullOnResourceCreate, System.Globalization.Format, Microsoft.Xna.Framework.Graphics.Effect.FormatShaderModel(), Microsoft.Xna.Framework.Graphics.EffectTechniqueCollection.GetEnumerator(), System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.Effect.InitializeHelpers(), Microsoft.Xna.Framework.FrameworkResources.MustUserShaderCode, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.Graphics.Effect.pCachedEffectData, Microsoft.Xna.Framework.Graphics.Effect.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfilePixelShaderModel, Microsoft.Xna.Framework.FrameworkResources.ProfileVertexShaderModel, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pStateTracker, Microsoft.Xna.Framework.Graphics.Effect.pTechniqueCollection, Microsoft.Xna.Framework.Graphics.GraphicsDevice.Resources, System.text, and Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException().

Referenced by Microsoft.Xna.Framework.Graphics.Effect.Effect(), and Microsoft.Xna.Framework.Graphics.Effect.RecreateAndPopulateObject().