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

◆ ReplayDrawingCommands()

unsafe void Microsoft.Xna.Framework.Graphics.GuideRenderer.ReplayDrawingCommands ( IntPtr commandData,
int commandDataSize )
inlineprivate

Definition at line 172 of file GuideRenderer.cs.

173 {
175 byte* ptr = (byte*)commandData.ToPointer();
176 byte* ptr2 = ptr + commandDataSize;
185 while (ptr < ptr2)
186 {
187 int num = *(int*)ptr;
188 ptr += 4;
189 switch (num)
190 {
191 case 1:
192 {
193 int num38 = *(int*)ptr;
194 ptr += 4;
196 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)resource_003CIUnknown_003E + 8)))((nint)resource_003CIUnknown_003E);
198 break;
199 }
200 case 2:
201 {
202 int key2 = *(int*)ptr;
203 ptr += 4;
204 int num10 = *(int*)ptr;
205 ptr += 4;
207 ptr = ((num10 * 8 + 3) & -4) + ptr;
208 _D3DVERTEXELEMENT9* ptr6 = (_D3DVERTEXELEMENT9*)_003CModule_003E.new_005B_005D(((uint)(num10 + 1) > 536870911u) ? uint.MaxValue : ((uint)(num10 + 1 << 3)), (nothrow_t*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.std_002Enothrow));
209 if (ptr6 == null)
210 {
211 throw new OutOfMemoryException();
212 }
213 try
214 {
215 for (int i = 0; i < num10; i++)
216 {
217 // IL cpblk instruction
218 System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(i * 8 + (byte*)ptr6, i * 8 + (byte*)ptr5, 8);
219 }
220 *(short*)(&d3DVERTEXELEMENT) = 255;
226 // IL cpblk instruction
228 int num11 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DVERTEXELEMENT9*, IDirect3DVertexDeclaration9**, int>)(int)(*(uint*)(*(int*)pComPtr + 344)))((nint)pComPtr, ptr6, &value3);
229 if (num11 < 0)
230 {
231 throw GraphicsHelpers.GetExceptionFromResult((uint)num11);
232 }
233 IntPtr value4 = new IntPtr(value3);
235 }
236 finally
237 {
238 _003CModule_003E.delete_005B_005D(ptr6);
239 }
240 break;
241 }
242 case 3:
243 {
244 int key4 = *(int*)ptr;
245 ptr += 4;
246 int num16 = *(int*)ptr;
247 ptr += 4;
248 byte* ptr9 = ptr;
249 ptr = ((num16 + 3) & -4) + ptr;
250 int num17 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint*, IDirect3DVertexShader9**, int>)(int)(*(uint*)(*(int*)pComPtr + 364)))((nint)pComPtr, (uint*)ptr9, &value7);
251 if (num17 < 0)
252 {
253 throw GraphicsHelpers.GetExceptionFromResult((uint)num17);
254 }
255 IntPtr value8 = new IntPtr(value7);
257 break;
258 }
259 case 4:
260 {
261 int key3 = *(int*)ptr;
262 ptr += 4;
263 int num14 = *(int*)ptr;
264 ptr += 4;
265 byte* ptr8 = ptr;
266 ptr = ((num14 + 3) & -4) + ptr;
267 int num15 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint*, IDirect3DPixelShader9**, int>)(int)(*(uint*)(*(int*)pComPtr + 424)))((nint)pComPtr, (uint*)ptr8, &value5);
268 if (num15 < 0)
269 {
270 throw GraphicsHelpers.GetExceptionFromResult((uint)num15);
271 }
272 IntPtr value6 = new IntPtr(value5);
274 break;
275 }
276 case 5:
277 {
278 int key = *(int*)ptr;
279 ptr += 4;
280 int num6 = *(int*)ptr;
281 ptr += 4;
282 int num7 = *(int*)ptr;
283 ptr += 4;
284 int num8 = *(int*)ptr;
285 ptr += 4;
287 ptr += 4;
288 int num9 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, uint, uint, _D3DFORMAT, _D3DPOOL, IDirect3DTexture9**, void**, int>)(int)(*(uint*)(*(int*)pComPtr + 92)))((nint)pComPtr, (uint)num6, (uint)num7, (uint)num8, 0u, d3DFORMAT2, (_D3DPOOL)1, &value, null);
289 if (num9 < 0)
290 {
291 throw GraphicsHelpers.GetExceptionFromResult((uint)num9);
292 }
293 IntPtr value2 = new IntPtr(value);
295 break;
296 }
297 case 6:
298 {
299 int handle5 = *(int*)ptr;
300 ptr += 4;
301 int num30 = *(int*)ptr;
302 ptr += 4;
303 // IL cpblk instruction
305 ptr += 16;
306 int num31 = *(int*)ptr;
307 ptr += 4;
308 byte* ptr12 = ptr;
309 ptr = ((num31 + 3) & -4) + ptr;
312 if (num32 < 0)
313 {
314 throw GraphicsHelpers.GetExceptionFromResult((uint)num32);
315 }
317 if (num33 < 0)
318 {
319 throw GraphicsHelpers.GetExceptionFromResult((uint)num33);
320 }
322 if (*(int*)(&d3DSURFACE_DESC) == 827611204 || *(int*)(&d3DSURFACE_DESC) == 844388420 || *(int*)(&d3DSURFACE_DESC) == 861165636 || *(int*)(&d3DSURFACE_DESC) == 877942852 || *(int*)(&d3DSURFACE_DESC) == 894720068)
323 {
324 num34 /= 4;
325 }
326 int num35 = num31 / num34;
327 if (0 < num34)
328 {
329 int num36 = num34;
330 do
331 {
334 ptr12 = num35 + ptr12;
335 num36--;
336 }
337 while (num36 != 0);
338 }
339 int num37 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, int>)(int)(*(uint*)(*(int*)resource_003CIDirect3DTexture9_003E + 80)))((nint)resource_003CIDirect3DTexture9_003E, (uint)num30);
340 if (num37 < 0)
341 {
342 throw GraphicsHelpers.GetExceptionFromResult((uint)num37);
343 }
344 break;
345 }
346 case 7:
347 {
348 int handle4 = *(int*)ptr;
349 ptr += 4;
350 int num29 = *(int*)pComPtr + 348;
352 break;
353 }
354 case 8:
355 {
356 int handle3 = *(int*)ptr;
357 ptr += 4;
358 int num28 = *(int*)pComPtr + 368;
360 break;
361 }
362 case 9:
363 {
364 int handle2 = *(int*)ptr;
365 ptr += 4;
366 int num27 = *(int*)pComPtr + 428;
368 break;
369 }
370 case 10:
371 {
372 int num25 = *(int*)ptr;
373 ptr += 4;
374 int handle = *(int*)ptr;
375 ptr += 4;
376 int num26 = *(int*)pComPtr + 260;
378 break;
379 }
380 case 11:
381 {
383 ptr += 4;
384 uint num24 = *(uint*)ptr;
385 ptr += 4;
386 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 228)))((nint)pComPtr, d3DRENDERSTATETYPE, num24);
387 break;
388 }
389 case 12:
390 {
391 uint num22 = *(uint*)ptr;
392 ptr += 4;
394 ptr += 4;
395 uint num23 = *(uint*)ptr;
396 ptr += 4;
397 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DSAMPLERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 276)))((nint)pComPtr, num22, d3DSAMPLERSTATETYPE, num23);
398 break;
399 }
400 case 13:
401 {
402 uint num20 = *(uint*)ptr;
403 ptr += 4;
404 uint num21 = *(uint*)ptr;
405 ptr += 4;
406 float* ptr11 = (float*)ptr;
407 ptr = ((int)(num21 * 16 + 3) & -4) + ptr;
408 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, float*, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 376)))((nint)pComPtr, num20, ptr11, num21);
409 break;
410 }
411 case 14:
412 {
413 uint num18 = *(uint*)ptr;
414 ptr += 4;
415 uint num19 = *(uint*)ptr;
416 ptr += 4;
417 float* ptr10 = (float*)ptr;
418 ptr = ((int)(num19 * 16 + 3) & -4) + ptr;
419 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, float*, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 436)))((nint)pComPtr, num18, ptr10, num19);
420 break;
421 }
422 case 15:
423 {
425 ptr += 4;
426 int num12 = *(int*)ptr;
427 ptr += 4;
428 int num13 = *(int*)ptr;
429 ptr += 4;
430 byte* ptr7 = ptr;
431 ptr = ((GetVertexCount(d3DPRIMITIVETYPE2, num12) * num13 + 3) & -4) + ptr;
433 {
434 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr + 164)))((nint)pComPtr);
435 graphicsDevice._insideScene = true;
436 }
437 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DPRIMITIVETYPE, uint, void*, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 332)))((nint)pComPtr, d3DPRIMITIVETYPE2, (uint)num12, ptr7, (uint)num13);
438 break;
439 }
440 case 16:
441 {
443 ptr += 4;
444 int num2 = *(int*)ptr;
445 ptr += 4;
446 int num3 = *(int*)ptr;
447 ptr += 4;
448 int num4 = *(int*)ptr;
449 ptr += 4;
450 int num5 = *(int*)ptr;
451 ptr += 4;
453 ptr += 4;
454 byte* ptr3 = ptr;
455 ptr = ((GetVertexCount(d3DPRIMITIVETYPE, num2) * num4 + 3) & -4) + ptr;
456 byte* ptr4 = ptr;
457 ptr = ((num5 * num3 + 3) & -4) + ptr;
459 {
460 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr + 164)))((nint)pComPtr);
461 graphicsDevice._insideScene = true;
462 }
463 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DPRIMITIVETYPE, uint, uint, uint, void*, _D3DFORMAT, void*, uint, int>)(int)(*(uint*)(*(int*)pComPtr + 336)))((nint)pComPtr, d3DPRIMITIVETYPE, 0u, (uint)num3, (uint)num2, ptr3, d3DFORMAT, ptr4, (uint)num5);
464 break;
465 }
466 default:
467 throw new InvalidOperationException();
468 }
469 }
470 if (ptr > ptr2)
471 {
472 throw new ArgumentOutOfRangeException("commandDataSize");
473 }
474 }
unsafe IDirect3DVertexDeclaration9 * GetResource_003CIDirect3DVertexDeclaration9_003E(int handle)
unsafe IDirect3DVertexShader9 * GetResource_003CIDirect3DVertexShader9_003E(int handle)
unsafe IUnknown * GetResource_003CIUnknown_003E(int handle)
unsafe IDirect3DTexture9 * GetResource_003CIDirect3DTexture9_003E(int handle)
static int GetVertexCount(_D3DPRIMITIVETYPE primitiveType, int primitiveCount)
unsafe IDirect3DPixelShader9 * GetResource_003CIDirect3DPixelShader9_003E(int handle)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static unsafe void CopyBlock(void *destination, void *source, uint byteCount)
Definition Unsafe.cs:85
static unsafe void CopyBlockUnaligned(void *destination, void *source, uint byteCount)
Definition Unsafe.cs:101

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._insideScene, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Runtime.CompilerServices.Unsafe.CopyBlock(), System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetResource_003CIDirect3DPixelShader9_003E(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetResource_003CIDirect3DTexture9_003E(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetResource_003CIDirect3DVertexDeclaration9_003E(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetResource_003CIDirect3DVertexShader9_003E(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetResource_003CIUnknown_003E(), Microsoft.Xna.Framework.Graphics.GuideRenderer.GetVertexCount(), Microsoft.Xna.Framework.Graphics.GuideRenderer.graphicsDevice, System.handle, System.Runtime.InteropServices.IUnknown, System.key, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), Microsoft.Xna.Framework.Graphics.GuideRenderer.resourceTable, and System.value.

Referenced by Microsoft.Xna.Framework.Graphics.GuideRenderer.DrawGuide().