forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics.cs
More file actions
1098 lines (917 loc) · 56.7 KB
/
Copy pathGraphics.cs
File metadata and controls
1098 lines (917 loc) · 56.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine.Bindings;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using uei = UnityEngine.Internal;
namespace UnityEngine
{
[RequiredByNativeCode]
public struct Resolution
{
// Keep in sync with ScreenManager::Resolution
private int m_Width;
private int m_Height;
private RefreshRate m_RefreshRate;
public int width { get { return m_Width; } set { m_Width = value; } }
public int height { get { return m_Height; } set { m_Height = value; } }
public RefreshRate refreshRateRatio { get { return m_RefreshRate; } set { m_RefreshRate = value; } }
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[Obsolete("Resolution.refreshRate is obsolete. Use refreshRateRatio instead.", false)]
public int refreshRate { get { return (int)Math.Round(m_RefreshRate.value); } set { m_RefreshRate.numerator = (uint)value; m_RefreshRate.denominator = 1; } }
public override string ToString()
{
return UnityString.Format("{0} x {1} @ {2}Hz", m_Width, m_Height, m_RefreshRate);
}
}
[StructLayout(LayoutKind.Sequential)]
public partial struct RenderBuffer
{
internal int m_RenderTextureInstanceID;
internal IntPtr m_BufferPtr;
internal RenderBufferLoadAction loadAction { get { return GetLoadAction(); } set { SetLoadAction(value); } }
internal RenderBufferStoreAction storeAction { get { return GetStoreAction(); } set { SetStoreAction(value); } }
}
public struct RenderTargetSetup
{
public RenderBuffer[] color;
public RenderBuffer depth;
public int mipLevel;
public CubemapFace cubemapFace;
public int depthSlice;
public Rendering.RenderBufferLoadAction[] colorLoad;
public Rendering.RenderBufferStoreAction[] colorStore;
public Rendering.RenderBufferLoadAction depthLoad;
public Rendering.RenderBufferStoreAction depthStore;
public RenderTargetSetup(
RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face,
Rendering.RenderBufferLoadAction[] colorLoad, Rendering.RenderBufferStoreAction[] colorStore,
Rendering.RenderBufferLoadAction depthLoad, Rendering.RenderBufferStoreAction depthStore
)
{
this.color = color;
this.depth = depth;
this.mipLevel = mip;
this.cubemapFace = face;
this.depthSlice = 0;
this.colorLoad = colorLoad;
this.colorStore = colorStore;
this.depthLoad = depthLoad;
this.depthStore = depthStore;
}
internal static Rendering.RenderBufferLoadAction[] LoadActions(RenderBuffer[] buf)
{
// preserve old discard behaviour: render surface flags are applied only on first activation
// this will be used only in ctor without load/store actions specified
Rendering.RenderBufferLoadAction[] ret = new Rendering.RenderBufferLoadAction[buf.Length];
for (int i = 0; i < buf.Length; ++i)
{
ret[i] = buf[i].loadAction;
buf[i].loadAction = Rendering.RenderBufferLoadAction.Load;
}
return ret;
}
internal static Rendering.RenderBufferStoreAction[] StoreActions(RenderBuffer[] buf)
{
// preserve old discard behaviour: render surface flags are applied only on first activation
// this will be used only in ctor without load/store actions specified
Rendering.RenderBufferStoreAction[] ret = new Rendering.RenderBufferStoreAction[buf.Length];
for (int i = 0; i < buf.Length; ++i)
{
ret[i] = buf[i].storeAction;
buf[i].storeAction = Rendering.RenderBufferStoreAction.Store;
}
return ret;
}
// TODO: when we enable default arguments support these can be combined into one method
public RenderTargetSetup(RenderBuffer color, RenderBuffer depth)
: this(new RenderBuffer[] { color }, depth)
{
}
public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel)
: this(new RenderBuffer[] { color }, depth, mipLevel)
{
}
public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel, CubemapFace face)
: this(new RenderBuffer[] { color }, depth, mipLevel, face)
{
}
public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel, CubemapFace face, int depthSlice)
: this(new RenderBuffer[] { color }, depth, mipLevel, face)
{
this.depthSlice = depthSlice;
}
// TODO: when we enable default arguments support these can be combined into one method
public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth)
: this(color, depth, 0, CubemapFace.Unknown)
{
}
public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mipLevel)
: this(color, depth, mipLevel, CubemapFace.Unknown)
{
}
public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face)
: this(color, depth, mip, face, LoadActions(color), StoreActions(color), depth.loadAction, depth.storeAction)
{
}
}
public struct RenderParams
{
public RenderParams(Material mat)
{
layer = 0;
renderingLayerMask = RenderingLayerMask.defaultRenderingLayerMask;
rendererPriority = 0;
worldBounds = new Bounds(Vector3.zero, Vector3.zero);
camera = null;
motionVectorMode = MotionVectorGenerationMode.Camera;
reflectionProbeUsage = ReflectionProbeUsage.Off;
material = mat;
matProps = null;
shadowCastingMode = ShadowCastingMode.Off;
receiveShadows = false;
lightProbeUsage = LightProbeUsage.Off;
lightProbeProxyVolume = null;
overrideSceneCullingMask = false;
sceneCullingMask = 0;
instanceID = 0;
}
public int layer {get; set;}
public uint renderingLayerMask {get; set;}
public int rendererPriority {get; set;}
public int instanceID {get; set;}
public Bounds worldBounds {get; set;}
public Camera camera {get; set;}
public MotionVectorGenerationMode motionVectorMode {get; set;}
public ReflectionProbeUsage reflectionProbeUsage {get; set;}
public Material material {get; set;}
public MaterialPropertyBlock matProps {get; set;}
public ShadowCastingMode shadowCastingMode {get; set;}
public bool receiveShadows {get; set;}
public LightProbeUsage lightProbeUsage {get; set;}
public LightProbeProxyVolume lightProbeProxyVolume {get; set;}
public bool overrideSceneCullingMask { get; set; }
public ulong sceneCullingMask { get; set; }
}
internal readonly struct RenderInstancedDataLayout
{
public RenderInstancedDataLayout(System.Type t)
{
size = Marshal.SizeOf(t);
offsetObjectToWorld = t == typeof(Matrix4x4) ? 0 : Marshal.OffsetOf(t, "objectToWorld").ToInt32();
// fill optional data members
try {offsetPrevObjectToWorld = Marshal.OffsetOf(t, "prevObjectToWorld").ToInt32();} catch (ArgumentException) {offsetPrevObjectToWorld = -1;}
try {offsetRenderingLayerMask = Marshal.OffsetOf(t, "renderingLayerMask").ToInt32();} catch (ArgumentException) {offsetRenderingLayerMask = -1;}
}
public int size {get;}
public int offsetObjectToWorld {get;}
public int offsetPrevObjectToWorld {get;}
public int offsetRenderingLayerMask {get;}
}
}
//
// Graphics.SetRenderTarget
//
namespace UnityEngine
{
public partial class Graphics
{
internal static void CheckLoadActionValid(Rendering.RenderBufferLoadAction load, string bufferType)
{
if (load != Rendering.RenderBufferLoadAction.Load && load != Rendering.RenderBufferLoadAction.DontCare)
throw new ArgumentException(UnityString.Format("Bad {0} LoadAction provided.", bufferType));
}
internal static void CheckStoreActionValid(Rendering.RenderBufferStoreAction store, string bufferType)
{
if (store != Rendering.RenderBufferStoreAction.Store && store != Rendering.RenderBufferStoreAction.DontCare)
throw new ArgumentException(UnityString.Format("Bad {0} StoreAction provided.", bufferType));
}
internal static void SetRenderTargetImpl(RenderTargetSetup setup)
{
if (setup.color.Length == 0)
throw new ArgumentException("Invalid color buffer count for SetRenderTarget");
if (setup.color.Length != setup.colorLoad.Length)
throw new ArgumentException("Color LoadAction and Buffer arrays have different sizes");
if (setup.color.Length != setup.colorStore.Length)
throw new ArgumentException("Color StoreAction and Buffer arrays have different sizes");
foreach (var load in setup.colorLoad)
CheckLoadActionValid(load, "Color");
foreach (var store in setup.colorStore)
CheckStoreActionValid(store, "Color");
CheckLoadActionValid(setup.depthLoad, "Depth");
CheckStoreActionValid(setup.depthStore, "Depth");
if ((int)setup.cubemapFace < (int)CubemapFace.Unknown || (int)setup.cubemapFace > (int)CubemapFace.NegativeZ)
throw new ArgumentException("Bad CubemapFace provided");
Internal_SetMRTFullSetup(
setup.color, setup.depth, setup.mipLevel, setup.cubemapFace, setup.depthSlice,
setup.colorLoad, setup.colorStore, setup.depthLoad, setup.depthStore
);
}
internal static void SetRenderTargetImpl(RenderBuffer colorBuffer, RenderBuffer depthBuffer, int mipLevel, CubemapFace face, int depthSlice)
{
Internal_SetRTSimple(colorBuffer, depthBuffer, mipLevel, face, depthSlice);
}
internal static void SetRenderTargetImpl(RenderTexture rt, int mipLevel, CubemapFace face, int depthSlice)
{
if (rt) SetRenderTargetImpl(rt.colorBuffer, rt.depthBuffer, mipLevel, face, depthSlice);
else Internal_SetNullRT();
}
internal static void SetRenderTargetImpl(GraphicsTexture rt, int mipLevel, CubemapFace face, int depthSlice)
{
if (rt != null) Internal_SetGfxRT(rt, mipLevel, face, depthSlice);
else Internal_SetNullRT();
}
internal static void SetRenderTargetImpl(RenderBuffer[] colorBuffers, RenderBuffer depthBuffer, int mipLevel, CubemapFace face, int depthSlice)
{
RenderBuffer depth = depthBuffer;
Internal_SetMRTSimple(colorBuffers, depth, mipLevel, face, depthSlice);
}
public static void SetRenderTarget(RenderTexture rt, [uei.DefaultValue("0")] int mipLevel, [uei.DefaultValue("CubemapFace.Unknown")] CubemapFace face, [uei.DefaultValue("0")] int depthSlice)
{
SetRenderTargetImpl(rt, mipLevel, face, depthSlice);
}
public static void SetRenderTarget(GraphicsTexture rt, [uei.DefaultValue("0")] int mipLevel, [uei.DefaultValue("CubemapFace.Unknown")] CubemapFace face, [uei.DefaultValue("0")] int depthSlice)
{
SetRenderTargetImpl(rt, mipLevel, face, depthSlice);
}
public static void SetRenderTarget(RenderBuffer colorBuffer, RenderBuffer depthBuffer, [uei.DefaultValue("0")] int mipLevel, [uei.DefaultValue("CubemapFace.Unknown")] CubemapFace face, [uei.DefaultValue("0")] int depthSlice)
{
SetRenderTargetImpl(colorBuffer, depthBuffer, mipLevel, face, depthSlice);
}
public static void SetRenderTarget(RenderBuffer[] colorBuffers, RenderBuffer depthBuffer)
{
SetRenderTargetImpl(colorBuffers, depthBuffer, 0, CubemapFace.Unknown, 0);
}
public static void SetRenderTarget(RenderTargetSetup setup)
{
SetRenderTargetImpl(setup);
}
}
public partial class Graphics
{
public static RenderBuffer activeColorBuffer { get { return GetActiveColorBuffer(); } }
public static RenderBuffer activeDepthBuffer { get { return GetActiveDepthBuffer(); } }
public static void SetRandomWriteTarget(int index, RenderTexture uav)
{
if (index < 0 || index >= SystemInfo.supportedRandomWriteTargetCount)
throw new ArgumentOutOfRangeException("index", string.Format("must be non-negative less than {0}.", SystemInfo.supportedRandomWriteTargetCount));
Internal_SetRandomWriteTargetRT(index, uav);
}
public static void SetRandomWriteTarget(int index, ComputeBuffer uav, [uei.DefaultValue("false")] bool preserveCounterValue)
{
if (uav == null) throw new ArgumentNullException("uav");
if (uav.m_Ptr == IntPtr.Zero) throw new System.ObjectDisposedException("uav");
if (index < 0 || index >= SystemInfo.supportedRandomWriteTargetCount)
throw new ArgumentOutOfRangeException("index", string.Format("must be non-negative less than {0}.", SystemInfo.supportedRandomWriteTargetCount));
Internal_SetRandomWriteTargetBuffer(index, uav, preserveCounterValue);
}
public static void SetRandomWriteTarget(int index, GraphicsBuffer uav, [uei.DefaultValue("false")] bool preserveCounterValue)
{
if (uav == null) throw new ArgumentNullException("uav");
if (uav.m_Ptr == IntPtr.Zero) throw new System.ObjectDisposedException("uav");
if (index < 0 || index >= SystemInfo.supportedRandomWriteTargetCount)
throw new ArgumentOutOfRangeException("index", string.Format("must be non-negative less than {0}.", SystemInfo.supportedRandomWriteTargetCount));
Internal_SetRandomWriteTargetGraphicsBuffer(index, uav, preserveCounterValue);
}
public static void CopyTexture(Texture src, Texture dst)
{
CopyTexture_Full(src, dst);
}
public static void CopyTexture(Texture src, int srcElement, Texture dst, int dstElement)
{
CopyTexture_Slice_AllMips(src, srcElement, dst, dstElement);
}
public static void CopyTexture(Texture src, int srcElement, int srcMip, Texture dst, int dstElement, int dstMip)
{
CopyTexture_Slice(src, srcElement, srcMip, dst, dstElement, dstMip);
}
public static void CopyTexture(Texture src, int srcElement, int srcMip, int srcX, int srcY, int srcWidth, int srcHeight, Texture dst, int dstElement, int dstMip, int dstX, int dstY)
{
CopyTexture_Region(src, srcElement, srcMip, srcX, srcY, srcWidth, srcHeight, dst, dstElement, dstMip, dstX, dstY);
}
public static void CopyTexture(GraphicsTexture src, GraphicsTexture dst)
{
CopyTexture_Full_Gfx(src, dst);
}
public static void CopyTexture(GraphicsTexture src, int srcElement, GraphicsTexture dst, int dstElement)
{
CopyTexture_Slice_AllMips_Gfx(src, srcElement, dst, dstElement);
}
public static void CopyTexture(GraphicsTexture src, int srcElement, int srcMip, GraphicsTexture dst, int dstElement, int dstMip)
{
CopyTexture_Slice_Gfx(src, srcElement, srcMip, dst, dstElement, dstMip);
}
public static void CopyTexture(GraphicsTexture src, int srcElement, int srcMip, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsTexture dst, int dstElement, int dstMip, int dstX, int dstY)
{
CopyTexture_Region_Gfx(src, srcElement, srcMip, srcX, srcY, srcWidth, srcHeight, dst, dstElement, dstMip, dstX, dstY);
}
public static bool ConvertTexture(Texture src, Texture dst)
{
return ConvertTexture_Full(src, dst);
}
public static bool ConvertTexture(Texture src, int srcElement, Texture dst, int dstElement)
{
return ConvertTexture_Slice(src, srcElement, dst, dstElement);
}
public static bool ConvertTexture(GraphicsTexture src, GraphicsTexture dst)
{
return ConvertTexture_Full_Gfx(src, dst);
}
public static bool ConvertTexture(GraphicsTexture src, int srcElement, GraphicsTexture dst, int dstElement)
{
return ConvertTexture_Slice_Gfx(src, srcElement, dst, dstElement);
}
public static GraphicsFence CreateAsyncGraphicsFence([uei.DefaultValue("SynchronisationStage.PixelProcessing")] SynchronisationStage stage)
{
return CreateGraphicsFence(GraphicsFenceType.AsyncQueueSynchronisation, GraphicsFence.TranslateSynchronizationStageToFlags(stage));
}
public static GraphicsFence CreateAsyncGraphicsFence()
{
return CreateGraphicsFence(GraphicsFenceType.AsyncQueueSynchronisation, SynchronisationStageFlags.PixelProcessing);
}
public static GraphicsFence CreateGraphicsFence(GraphicsFenceType fenceType, [uei.DefaultValue("SynchronisationStage.PixelProcessing")] SynchronisationStageFlags stage)
{
GraphicsFence newFence = new GraphicsFence();
newFence.m_FenceType = fenceType;
newFence.m_Ptr = CreateGPUFenceImpl(fenceType, stage);
newFence.InitPostAllocation();
newFence.Validate();
return newFence;
}
public static void WaitOnAsyncGraphicsFence(GraphicsFence fence)
{
WaitOnAsyncGraphicsFence(fence, SynchronisationStage.PixelProcessing);
}
public static void WaitOnAsyncGraphicsFence(GraphicsFence fence, [uei.DefaultValue("SynchronisationStage.PixelProcessing")] SynchronisationStage stage)
{
if (fence.m_FenceType != GraphicsFenceType.AsyncQueueSynchronisation)
throw new ArgumentException("Graphics.WaitOnGraphicsFence can only be called with fences created with GraphicsFenceType.AsyncQueueSynchronization.");
fence.Validate();
//Don't wait on a fence that's already known to have passed
if (fence.IsFencePending())
WaitOnGPUFenceImpl(fence.m_Ptr, GraphicsFence.TranslateSynchronizationStageToFlags(stage));
}
internal static void ValidateCopyBuffer(GraphicsBuffer source, GraphicsBuffer dest)
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (dest == null) throw new ArgumentNullException(nameof(dest));
var sourceSize = (long)source.count * source.stride;
var destSize = (long)dest.count * dest.stride;
if (sourceSize != destSize)
throw new ArgumentException($"CopyBuffer source and destination buffers must be the same size, source was {sourceSize} bytes, dest was {destSize} bytes");
if ((source.target & GraphicsBuffer.Target.CopySource) == 0)
throw new ArgumentException($"CopyBuffer source must have {nameof(GraphicsBuffer.Target.CopySource)} target", nameof(source));
if ((dest.target & GraphicsBuffer.Target.CopyDestination) == 0)
throw new ArgumentException($"CopyBuffer destination must have {nameof(GraphicsBuffer.Target.CopyDestination)} target", nameof(dest));
}
public static void CopyBuffer(GraphicsBuffer source, GraphicsBuffer dest)
{
ValidateCopyBuffer(source, dest);
CopyBufferImpl(source, dest);
}
}
}
//
// Graphics.Draw*
//
namespace UnityEngine
{
[VisibleToOtherModules("UnityEngine.IMGUIModule")]
internal struct Internal_DrawTextureArguments
{
public Rect screenRect, sourceRect;
public int leftBorder, rightBorder, topBorder, bottomBorder;
public Color leftBorderColor, rightBorderColor, topBorderColor, bottomBorderColor;
public Color color;
public Vector4 borderWidths;
public Vector4 cornerRadiuses;
public bool smoothCorners;
public int pass;
public Texture texture;
public Material mat;
}
public partial class Graphics
{
private static void DrawTextureImpl(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat, int pass)
{
Internal_DrawTextureArguments args = new Internal_DrawTextureArguments();
args.screenRect = screenRect; args.sourceRect = sourceRect;
args.leftBorder = leftBorder; args.rightBorder = rightBorder; args.topBorder = topBorder; args.bottomBorder = bottomBorder;
args.color = color;
args.leftBorderColor = Color.black;
args.topBorderColor = Color.black;
args.rightBorderColor = Color.black;
args.bottomBorderColor = Color.black;
args.pass = pass;
args.texture = texture;
args.smoothCorners = true;
args.mat = mat;
Internal_DrawTexture(ref args);
}
public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, [uei.DefaultValue("null")] Material mat, [uei.DefaultValue("-1")] int pass)
{
DrawTextureImpl(screenRect, texture, sourceRect, leftBorder, rightBorder, topBorder, bottomBorder, color, mat, pass);
}
public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, [uei.DefaultValue("null")] Material mat, [uei.DefaultValue("-1")] int pass)
{
Color32 color = new Color32(128, 128, 128, 128);
DrawTextureImpl(screenRect, texture, sourceRect, leftBorder, rightBorder, topBorder, bottomBorder, color, mat, pass);
}
public static void DrawTexture(Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, [uei.DefaultValue("null")] Material mat, [uei.DefaultValue("-1")] int pass)
{
DrawTexture(screenRect, texture, new Rect(0, 0, 1, 1), leftBorder, rightBorder, topBorder, bottomBorder, mat, pass);
}
public static void DrawTexture(Rect screenRect, Texture texture, [uei.DefaultValue("null")] Material mat, [uei.DefaultValue("-1")] int pass)
{
DrawTexture(screenRect, texture, 0, 0, 0, 0, mat, pass);
}
public unsafe static void RenderMesh(in RenderParams rparams, Mesh mesh, int submeshIndex, Matrix4x4 objectToWorld, [uei.DefaultValue("null")] Matrix4x4? prevObjectToWorld = null)
{
if (prevObjectToWorld.HasValue)
{
Matrix4x4 temp = prevObjectToWorld.Value;
Internal_RenderMesh(rparams, mesh, submeshIndex, objectToWorld, &temp);
}
else
Internal_RenderMesh(rparams, mesh, submeshIndex, objectToWorld, null);
}
internal static Dictionary<int, RenderInstancedDataLayout> s_RenderInstancedDataLayouts = new Dictionary<int, RenderInstancedDataLayout>();
private static RenderInstancedDataLayout GetCachedRenderInstancedDataLayout(Type type)
{
int typeHashCode = type.GetHashCode();
RenderInstancedDataLayout layout;
if(!s_RenderInstancedDataLayouts.TryGetValue(typeHashCode, out layout))
{
layout = new RenderInstancedDataLayout(type);
s_RenderInstancedDataLayouts.Add(typeHashCode, layout);
}
return layout;
}
public unsafe static void RenderMeshInstanced<T>(in RenderParams rparams, Mesh mesh, int submeshIndex, T[] instanceData, [uei.DefaultValue("-1")] int instanceCount = -1, [uei.DefaultValue("0")] int startInstance = 0) where T : unmanaged
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
else if (!rparams.material.enableInstancing)
throw new InvalidOperationException("Material needs to enable instancing for use with RenderMeshInstanced.");
else if (instanceData == null)
throw new ArgumentNullException("instanceData");
RenderInstancedDataLayout layout = GetCachedRenderInstancedDataLayout(typeof(T));
uint count = Math.Min((uint)instanceCount, (uint)Math.Max(0, instanceData.Length - startInstance));
fixed(T *data = instanceData) {Internal_RenderMeshInstanced(rparams, mesh, submeshIndex, (IntPtr)(data + startInstance), layout, count);}
}
public unsafe static void RenderMeshInstanced<T>(in RenderParams rparams, Mesh mesh, int submeshIndex, List<T> instanceData, [uei.DefaultValue("-1")] int instanceCount = -1, [uei.DefaultValue("0")] int startInstance = 0) where T : unmanaged
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
else if (!rparams.material.enableInstancing)
throw new InvalidOperationException("Material needs to enable instancing for use with RenderMeshInstanced.");
else if (instanceData == null)
throw new ArgumentNullException("instanceData");
RenderInstancedDataLayout layout = GetCachedRenderInstancedDataLayout(typeof(T));
uint count = Math.Min((uint)instanceCount, (uint)Math.Max(0, instanceData.Count - startInstance));
fixed(T *data = NoAllocHelpers.ExtractArrayFromList(instanceData)) {Internal_RenderMeshInstanced(rparams, mesh, submeshIndex, (IntPtr)(data + startInstance), layout, count);}
}
public unsafe static void RenderMeshInstanced<T>(RenderParams rparams, Mesh mesh, int submeshIndex, NativeArray<T> instanceData, [uei.DefaultValue("-1")] int instanceCount = -1, [uei.DefaultValue("0")] int startInstance = 0) where T : unmanaged
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
else if (!rparams.material.enableInstancing)
throw new InvalidOperationException("Material needs to enable instancing for use with RenderMeshInstanced.");
else if (instanceData == null)
throw new ArgumentNullException("instanceData");
RenderInstancedDataLayout layout = GetCachedRenderInstancedDataLayout(typeof(T));
uint count = Math.Min((uint)instanceCount, (uint)Math.Max(0, instanceData.Length - startInstance));
Internal_RenderMeshInstanced(rparams, mesh, submeshIndex, (IntPtr)((T*)instanceData.GetUnsafePtr() + startInstance), layout, count);
}
public static void RenderMeshIndirect(in RenderParams rparams, Mesh mesh, GraphicsBuffer commandBuffer, [uei.DefaultValue("1")] int commandCount = 1, [uei.DefaultValue("0")] int startCommand = 0)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
Internal_RenderMeshIndirect(rparams, mesh, commandBuffer, commandCount, startCommand);
}
public static void RenderMeshPrimitives(in RenderParams rparams, Mesh mesh, int submeshIndex, [uei.DefaultValue("1")] int instanceCount = 1)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
Internal_RenderMeshPrimitives(rparams, mesh, submeshIndex, instanceCount);
}
public static void RenderPrimitives(in RenderParams rparams, MeshTopology topology, int vertexCount, [uei.DefaultValue("1")] int instanceCount = 1)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
Internal_RenderPrimitives(rparams, topology, vertexCount, instanceCount);
}
public static void RenderPrimitivesIndexed(in RenderParams rparams, MeshTopology topology, GraphicsBuffer indexBuffer, int indexCount, [uei.DefaultValue("0")] int startIndex = 0, [uei.DefaultValue("1")] int instanceCount = 1)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
Internal_RenderPrimitivesIndexed(rparams, topology, indexBuffer, indexCount, startIndex, instanceCount);
}
public static void RenderPrimitivesIndirect(in RenderParams rparams, MeshTopology topology, GraphicsBuffer commandBuffer, [uei.DefaultValue("1")] int commandCount = 1, [uei.DefaultValue("0")] int startCommand = 0)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
Internal_RenderPrimitivesIndirect(rparams, topology, commandBuffer, commandCount, startCommand);
}
public static void RenderPrimitivesIndexedIndirect(in RenderParams rparams, MeshTopology topology, GraphicsBuffer indexBuffer, GraphicsBuffer commandBuffer, [uei.DefaultValue("1")] int commandCount = 1, [uei.DefaultValue("0")] int startCommand = 0)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
Internal_RenderPrimitivesIndexedIndirect(rparams, topology, indexBuffer, commandBuffer, commandCount, startCommand);
}
public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex)
{
if (mesh == null)
throw new ArgumentNullException("mesh");
Internal_DrawMeshNow1(mesh, materialIndex, position, rotation);
}
public static void DrawMeshNow(Mesh mesh, Matrix4x4 matrix, int materialIndex)
{
if (mesh == null)
throw new ArgumentNullException("mesh");
Internal_DrawMeshNow2(mesh, materialIndex, matrix);
}
public static void DrawMeshNow(Mesh mesh, Vector3 position, Quaternion rotation) { DrawMeshNow(mesh, position, rotation, -1); }
public static void DrawMeshNow(Mesh mesh, Matrix4x4 matrix) { DrawMeshNow(mesh, matrix, -1); }
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("0")] int submeshIndex, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("true")] bool castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("true")] bool useLightProbes)
{
DrawMesh(mesh, Matrix4x4.TRS(position, rotation, Vector3.one), material, layer, camera, submeshIndex, properties, castShadows ? ShadowCastingMode.On : ShadowCastingMode.Off, receiveShadows, null, useLightProbes ? LightProbeUsage.BlendProbes : LightProbeUsage.Off, null);
}
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("null")] Transform probeAnchor, [uei.DefaultValue("true")] bool useLightProbes)
{
DrawMesh(mesh, Matrix4x4.TRS(position, rotation, Vector3.one), material, layer, camera, submeshIndex, properties, castShadows, receiveShadows, probeAnchor, useLightProbes ? LightProbeUsage.BlendProbes : LightProbeUsage.Off, null);
}
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("0")] int submeshIndex, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("true")] bool castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("true")] bool useLightProbes)
{
DrawMesh(mesh, matrix, material, layer, camera, submeshIndex, properties, castShadows ? ShadowCastingMode.On : ShadowCastingMode.Off, receiveShadows, null, useLightProbes ? LightProbeUsage.BlendProbes : LightProbeUsage.Off, null);
}
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, Transform probeAnchor, LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume)
{
if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null)
throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume");
Internal_DrawMesh(mesh, submeshIndex, matrix, material, layer, camera, properties, castShadows, receiveShadows, probeAnchor, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, Matrix4x4[] matrices, [uei.DefaultValue("matrices.Length")] int count, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
else if (mesh == null)
throw new ArgumentNullException("mesh");
else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount)
throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range.");
else if (material == null)
throw new ArgumentNullException("material");
else if (!material.enableInstancing)
throw new InvalidOperationException("Material needs to enable instancing for use with DrawMeshInstanced.");
else if (matrices == null)
throw new ArgumentNullException("matrices");
else if (count < 0 || count > Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length))
throw new ArgumentOutOfRangeException("count", String.Format("Count must be in the range of 0 to {0}.", Mathf.Min(kMaxDrawMeshInstanceCount, matrices.Length)));
else if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null)
throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume");
if (count > 0)
Internal_DrawMeshInstanced(mesh, submeshIndex, material, matrices, count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, List<Matrix4x4> matrices, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume)
{
if (matrices == null)
throw new ArgumentNullException("matrices");
DrawMeshInstanced(mesh, submeshIndex, material, NoAllocHelpers.ExtractArrayFromList(matrices), matrices.Count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawMeshInstancedProcedural(Mesh mesh, int submeshIndex, Material material, Bounds bounds, int count, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0, Camera camera = null, LightProbeUsage lightProbeUsage = LightProbeUsage.BlendProbes, LightProbeProxyVolume lightProbeProxyVolume = null)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
else if (mesh == null)
throw new ArgumentNullException("mesh");
else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount)
throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range.");
else if (material == null)
throw new ArgumentNullException("material");
else if (count <= 0)
throw new ArgumentOutOfRangeException("count");
else if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null)
throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume");
if (count > 0)
Internal_DrawMeshInstancedProcedural(mesh, submeshIndex, material, bounds, count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawMeshInstancedIndirect(Mesh mesh, int submeshIndex, Material material, Bounds bounds, ComputeBuffer bufferWithArgs, [uei.DefaultValue("0")] int argsOffset, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
else if (mesh == null)
throw new ArgumentNullException("mesh");
else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount)
throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range.");
else if (material == null)
throw new ArgumentNullException("material");
else if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null)
throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume");
Internal_DrawMeshInstancedIndirect(mesh, submeshIndex, material, bounds, bufferWithArgs, argsOffset, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawMeshInstancedIndirect(Mesh mesh, int submeshIndex, Material material, Bounds bounds, GraphicsBuffer bufferWithArgs, [uei.DefaultValue("0")] int argsOffset, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume)
{
if (!SystemInfo.supportsInstancing)
throw new InvalidOperationException("Instancing is not supported.");
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
else if (mesh == null)
throw new ArgumentNullException("mesh");
else if (submeshIndex < 0 || submeshIndex >= mesh.subMeshCount)
throw new ArgumentOutOfRangeException("submeshIndex", "submeshIndex out of range.");
else if (material == null)
throw new ArgumentNullException("material");
else if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
if (lightProbeUsage == LightProbeUsage.UseProxyVolume && lightProbeProxyVolume == null)
throw new ArgumentException("Argument lightProbeProxyVolume must not be null if lightProbeUsage is set to UseProxyVolume.", "lightProbeProxyVolume");
Internal_DrawMeshInstancedIndirectGraphicsBuffer(mesh, submeshIndex, material, bounds, bufferWithArgs, argsOffset, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume);
}
public static void DrawProceduralNow(MeshTopology topology, int vertexCount, int instanceCount = 1)
{
Internal_DrawProceduralNow(topology, vertexCount, instanceCount);
}
public static void DrawProceduralNow(MeshTopology topology, GraphicsBuffer indexBuffer, int indexCount, int instanceCount = 1)
{
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
Internal_DrawProceduralIndexedNow(topology, indexBuffer, indexCount, instanceCount);
}
public static void DrawProceduralIndirectNow(MeshTopology topology, ComputeBuffer bufferWithArgs, int argsOffset = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndirectNow(topology, bufferWithArgs, argsOffset);
}
public static void DrawProceduralIndirectNow(MeshTopology topology, GraphicsBuffer indexBuffer, ComputeBuffer bufferWithArgs, int argsOffset = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndexedIndirectNow(topology, indexBuffer, bufferWithArgs, argsOffset);
}
public static void DrawProceduralIndirectNow(MeshTopology topology, GraphicsBuffer bufferWithArgs, int argsOffset = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndirectNowGraphicsBuffer(topology, bufferWithArgs, argsOffset);
}
public static void DrawProceduralIndirectNow(MeshTopology topology, GraphicsBuffer indexBuffer, GraphicsBuffer bufferWithArgs, int argsOffset = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndexedIndirectNowGraphicsBuffer(topology, indexBuffer, bufferWithArgs, argsOffset);
}
public static void DrawProcedural(Material material, Bounds bounds, MeshTopology topology, int vertexCount, int instanceCount = 1, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
Internal_DrawProcedural(material, bounds, topology, vertexCount, instanceCount, camera, properties, castShadows, receiveShadows, layer);
}
public static void DrawProcedural(Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, int indexCount, int instanceCount = 1, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
Internal_DrawProceduralIndexed(material, bounds, topology, indexBuffer, indexCount, instanceCount, camera, properties, castShadows, receiveShadows, layer);
}
public static void DrawProceduralIndirect(Material material, Bounds bounds, MeshTopology topology, ComputeBuffer bufferWithArgs, int argsOffset = 0, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndirect(material, bounds, topology, bufferWithArgs, argsOffset, camera, properties, castShadows, receiveShadows, layer);
}
public static void DrawProceduralIndirect(Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer bufferWithArgs, int argsOffset = 0, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndirectGraphicsBuffer(material, bounds, topology, bufferWithArgs, argsOffset, camera, properties, castShadows, receiveShadows, layer);
}
public static void DrawProceduralIndirect(Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, ComputeBuffer bufferWithArgs, int argsOffset = 0, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndexedIndirect(material, bounds, topology, indexBuffer, bufferWithArgs, argsOffset, camera, properties, castShadows, receiveShadows, layer);
}
public static void DrawProceduralIndirect(Material material, Bounds bounds, MeshTopology topology, GraphicsBuffer indexBuffer, GraphicsBuffer bufferWithArgs, int argsOffset = 0, Camera camera = null, MaterialPropertyBlock properties = null, ShadowCastingMode castShadows = ShadowCastingMode.On, bool receiveShadows = true, int layer = 0)
{
if (!SystemInfo.supportsIndirectArgumentsBuffer)
throw new InvalidOperationException("Indirect argument buffers are not supported.");
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
if (bufferWithArgs == null)
throw new ArgumentNullException("bufferWithArgs");
Internal_DrawProceduralIndexedIndirectGraphicsBuffer(material, bounds, topology, indexBuffer, bufferWithArgs, argsOffset, camera, properties, castShadows, receiveShadows, layer);
}
}
}
//
// Graphics.Blit*
//
namespace UnityEngine
{
public partial class Graphics
{
public static void Blit(Texture source, RenderTexture dest)
{
Blit2(source, dest);
}
public static void Blit(Texture source, RenderTexture dest, int sourceDepthSlice, int destDepthSlice)
{
Blit3(source, dest, sourceDepthSlice, destDepthSlice);
}
public static void Blit(Texture source, RenderTexture dest, Vector2 scale, Vector2 offset)
{
Blit4(source, dest, scale, offset);
}
public static void Blit(Texture source, RenderTexture dest, Vector2 scale, Vector2 offset, int sourceDepthSlice, int destDepthSlice)
{
Blit5(source, dest, scale, offset, sourceDepthSlice, destDepthSlice);
}
public static void Blit(Texture source, RenderTexture dest, Material mat, [uei.DefaultValue("-1")] int pass)
{
Internal_BlitMaterial5(source, dest, mat, pass, true);
}
public static void Blit(Texture source, RenderTexture dest, Material mat, int pass, int destDepthSlice)
{
Internal_BlitMaterial6(source, dest, mat, pass, true, destDepthSlice);
}
public static void Blit(Texture source, RenderTexture dest, Material mat)
{
Blit(source, dest, mat, -1);
}
public static void Blit(Texture source, Material mat, [uei.DefaultValue("-1")] int pass)
{
Internal_BlitMaterial5(source, null, mat, pass, false);
}
public static void Blit(Texture source, Material mat, int pass, int destDepthSlice)
{
Internal_BlitMaterial6(source, null, mat, pass, false, destDepthSlice);
}
public static void Blit(Texture source, Material mat)
{
Blit(source, mat, -1);
}
public static void BlitMultiTap(Texture source, RenderTexture dest, Material mat, params Vector2[] offsets)
{
// in case params were not passed, we will end up with empty array (not null) but our cpp code is not ready for that.
// do explicit argument exception instead of potential nullref coming from native side
if (offsets.Length == 0)
throw new ArgumentException("empty offsets list passed.", "offsets");
Internal_BlitMultiTap4(source, dest, mat, offsets);
}
public static void BlitMultiTap(Texture source, RenderTexture dest, Material mat, int destDepthSlice, params Vector2[] offsets)
{
// in case params were not passed, we will end up with empty array (not null) but our cpp code is not ready for that.
// do explicit argument exception instead of potential nullref coming from native side
if (offsets.Length == 0)
throw new ArgumentException("empty offsets list passed.", "offsets");
Internal_BlitMultiTap5(source, dest, mat, offsets, destDepthSlice);
}
//
// Blit to GraphicsTexture
//
public static void Blit(Texture source, GraphicsTexture dest)
{
BlitGfx2(source, dest);
}
public static void Blit(Texture source, GraphicsTexture dest, int sourceDepthSlice, int destDepthSlice)
{
BlitGfx3(source, dest, sourceDepthSlice, destDepthSlice);
}
public static void Blit(Texture source, GraphicsTexture dest, Vector2 scale, Vector2 offset)
{
BlitGfx4(source, dest, scale, offset);
}
public static void Blit(Texture source, GraphicsTexture dest, Vector2 scale, Vector2 offset, int sourceDepthSlice, int destDepthSlice)
{
BlitGfx5(source, dest, scale, offset, sourceDepthSlice, destDepthSlice);
}
public static void Blit(Texture source, GraphicsTexture dest, Material mat, [uei.DefaultValue("-1")] int pass)
{
Internal_BlitMaterialGfx5(source, dest, mat, pass, true);
}
public static void Blit(Texture source, GraphicsTexture dest, Material mat, int pass, int destDepthSlice)
{
Internal_BlitMaterialGfx6(source, dest, mat, pass, true, destDepthSlice);
}
public static void Blit(Texture source, GraphicsTexture dest, Material mat)
{
Blit(source, dest, mat, -1);
}
public static void BlitMultiTap(Texture source, GraphicsTexture dest, Material mat, params Vector2[] offsets)
{
// in case params were not passed, we will end up with empty array (not null) but our cpp code is not ready for that.