-
Notifications
You must be signed in to change notification settings - Fork 2
/
WebGPU.Interfaces.pas
2412 lines (2037 loc) · 95.9 KB
/
WebGPU.Interfaces.pas
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
{**********************************************************************}
{ }
{ "The contents of this file are subject to the Mozilla Public }
{ License Version 2.0 (the "License"); you may not use this }
{ file except in compliance with the License. You may obtain }
{ a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express }
{ or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ }
{ EXPERIMENTAL interface-based reformulation of WebGPU header }
{ }
{**********************************************************************}
unit WebGPU.Interfaces;
interface
uses Classes, WebGPU;
type
IWGPUAdapter = interface;
IWGPUBindGroup = interface;
IWGPUBindGroupLayout = interface;
IWGPUBuffer = interface;
IWGPUCommandBuffer = interface;
IWGPUCommandEncoder = interface;
IWGPUComputePassEncoder = interface;
IWGPUComputePipeline = interface;
IWGPUDevice = interface;
IWGPUExternalTexture = interface;
IWGPUInstance = interface;
IWGPUPipelineLayout = interface;
IWGPUQuerySet = interface;
IWGPUQueue = interface;
IWGPURenderBundle = interface;
IWGPURenderBundleEncoder = interface;
IWGPURenderPassEncoder = interface;
IWGPURenderPipeline = interface;
IWGPUSampler = interface;
IWGPUShaderModule = interface;
IWGPUSharedBufferMemory = interface;
IWGPUSharedFence = interface;
IWGPUSharedTextureMemory = interface;
IWGPUSurface = interface;
IWGPUTexture = interface;
IWGPUTextureView = interface;
TIWGPUCommandBufferArray = TArray<IWGPUCommandBuffer>;
TWGPUFeatureNameArray = TArray<TWGPUFeatureName>;
IWGPUAdapter = interface
['{EF23B10E-8B6E-2044-D3F0-0FC89A2141C9}']
function GetHandle: TWGPUAdapter;
function CreateDevice(const aDescriptor: TWGPUDeviceDescriptor): IWGPUDevice;
function EnumerateFeatures : TWGPUFeatureNameArray; overload;
function EnumerateFeatures(const aFeatures: PWGPUFeatureName): NativeUInt; overload;
procedure GetFeatures(const aFeatures: PWGPUSupportedFeatures);
function GetFormatCapabilities(const aFormat: TWGPUTextureFormat; const aCapabilities: PWGPUFormatCapabilities): TWGPUStatus;
function GetInfo(const aInfo: PWGPUAdapterInfo): TWGPUStatus;
function GetInstance: IWGPUInstance;
function GetLimits(const aLimits: PWGPUSupportedLimits): TWGPUStatus;
function HasFeature(const aFeature: TWGPUFeatureName): TWGPUBool;
procedure RequestDevice(const aDescriptor: TWGPUDeviceDescriptor; const aCallback: TWGPURequestDeviceCallback; const aUserdata: Pointer);
function RequestDevice2(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo2): TWGPUFuture;
function RequestDeviceF(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo): TWGPUFuture;
end;
IWGPUBindGroup = interface
['{4F7692CD-D873-5E0E-D182-0165EBF70A08}']
function GetHandle: TWGPUBindGroup;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUBindGroupLayout = interface
['{9E5830F4-8237-8781-456F-06134F2ACE2C}']
function GetHandle: TWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUBuffer = interface
['{6FC46489-F0E8-72EC-11FB-7E5935592B2A}']
function GetHandle: TWGPUBuffer;
function GetLabel: TWGPUStringView;
function GetConstMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
function GetMapState: TWGPUBufferMapState;
function GetMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
function GetSize: UInt64;
function GetUsage: TWGPUBufferUsage;
procedure MapAsync(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallback: TWGPUBufferMapCallback; const aUserdata: Pointer);
function MapAsync2(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo2): TWGPUFuture;
function MapAsyncF(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Unmap;
property &Label : TWGPUStringView read GetLabel write SetLabel;
end;
IWGPUCommandBuffer = interface
['{236B7E47-CC75-9118-0CA6-FE9A9AE1F74D}']
function GetHandle: TWGPUCommandBuffer;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUCommandEncoder = interface
['{164CAC2F-76B4-7E3E-A25E-5EAE1600611F}']
function GetHandle: TWGPUCommandEncoder;
function BeginComputePass: IWGPUComputePassEncoder; overload;
function BeginComputePass(const aDescriptor: TWGPUComputePassDescriptor): IWGPUComputePassEncoder; overload;
function BeginRenderPass(const aDescriptor: TWGPURenderPassDescriptor): IWGPURenderPassEncoder;
procedure ClearBuffer(const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
procedure CopyBufferToBuffer(const aSource: IWGPUBuffer; aSourceOffset: UInt64; const aDestination: IWGPUBuffer; aDestinationOffset: UInt64; aSize: UInt64);
procedure CopyBufferToTexture(const aSource: PWGPUImageCopyBuffer; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D);
procedure CopyTextureToBuffer(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyBuffer; const aCopySize: PWGPUExtent3D);
procedure CopyTextureToTexture(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D);
function Finish(const aDescriptor: PWGPUCommandBufferDescriptor): IWGPUCommandBuffer;
procedure InjectValidationError(const aMessage: TWGPUStringView);
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure ResolveQuerySet(const aQuerySet: IWGPUQuerySet; aFirstQuery: UInt32; aQueryCount: UInt32; const aDestination: IWGPUBuffer; aDestinationOffset: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure WriteBuffer(const aBuffer: IWGPUBuffer; aBufferOffset: UInt64; const aData: PUInt8; aSize: UInt64);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
IWGPUComputePassEncoder = interface
['{5717E3EE-0FD8-7D10-DD8F-5E82183A3C20}']
function GetHandle: TWGPUComputePassEncoder;
procedure DispatchWorkgroups(aWorkgroupCountX: UInt32; aWorkgroupCountY: UInt32; aWorkgroupCountZ: UInt32);
procedure DispatchWorkgroupsIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure &End;
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPUComputePipeline);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
IWGPUComputePipeline = interface
['{D4CA07D2-FB2A-C067-A9E4-91F3403606A4}']
function GetHandle: TWGPUComputePipeline;
function GetBindGroupLayout(aGroupIndex: UInt32): IWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUDevice = interface
['{5C020B62-26AA-E9DA-55D6-93B84ECEA57A}']
function GetHandle: TWGPUDevice;
function CreateBindGroup(const aDescriptor: TWGPUBindGroupDescriptor): IWGPUBindGroup;
function CreateBindGroupLayout(const aDescriptor: TWGPUBindGroupLayoutDescriptor): IWGPUBindGroupLayout;
function CreateBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function CreateCommandEncoder(const aDescriptor: TWGPUCommandEncoderDescriptor): IWGPUCommandEncoder;
function CreateComputePipeline(const aDescriptor: TWGPUComputePipelineDescriptor): IWGPUComputePipeline;
procedure CreateComputePipelineAsync(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallback: TWGPUCreateComputePipelineAsyncCallback; const aUserdata: Pointer);
function CreateComputePipelineAsync2(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallbackInfo: TWGPUCreateComputePipelineAsyncCallbackInfo2): TWGPUFuture;
function CreateComputePipelineAsyncF(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallbackInfo: TWGPUCreateComputePipelineAsyncCallbackInfo): TWGPUFuture;
function CreateErrorBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function CreateErrorExternalTexture: IWGPUExternalTexture;
function CreateErrorShaderModule(const aDescriptor: TWGPUShaderModuleDescriptor; const aErrorMessage: TWGPUStringView): IWGPUShaderModule;
function CreateErrorTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function CreateExternalTexture(const aExternalTextureDescriptor: TWGPUExternalTextureDescriptor): IWGPUExternalTexture;
function CreatePipelineLayout(const aDescriptor: TWGPUPipelineLayoutDescriptor): IWGPUPipelineLayout;
function CreateQuerySet(const aDescriptor: TWGPUQuerySetDescriptor): IWGPUQuerySet;
function CreateRenderBundleEncoder(const aDescriptor: TWGPURenderBundleEncoderDescriptor): IWGPURenderBundleEncoder;
function CreateRenderPipeline(const aDescriptor: TWGPURenderPipelineDescriptor): IWGPURenderPipeline;
procedure CreateRenderPipelineAsync(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallback: TWGPUCreateRenderPipelineAsyncCallback; const aUserdata: Pointer);
function CreateRenderPipelineAsync2(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallbackInfo: TWGPUCreateRenderPipelineAsyncCallbackInfo2): TWGPUFuture;
function CreateRenderPipelineAsyncF(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallbackInfo: TWGPUCreateRenderPipelineAsyncCallbackInfo): TWGPUFuture;
function CreateSampler(const aDescriptor: TWGPUSamplerDescriptor): IWGPUSampler;
function CreateShaderModule(const aDescriptor: TWGPUShaderModuleDescriptor): IWGPUShaderModule;
function CreateTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function EnumerateFeatures : TWGPUFeatureNameArray; overload;
function EnumerateFeatures(const aFeatures: PWGPUFeatureName): NativeUInt; overload;
procedure ForceLoss(const aType: TWGPUDeviceLostReason; const aMessage: TWGPUStringView);
function GetAHardwareBufferProperties(const aHandle: Pointer; const aProperties: PWGPUAHardwareBufferProperties): TWGPUStatus;
function GetAdapter: IWGPUAdapter;
procedure GetFeatures(const aFeatures: PWGPUSupportedFeatures);
function GetLimits(const aLimits: PWGPUSupportedLimits): TWGPUStatus;
function GetLostFuture: TWGPUFuture;
function GetQueue: IWGPUQueue;
function HasFeature(const aFeature: TWGPUFeatureName): TWGPUBool;
function ImportSharedBufferMemory(const aDescriptor: TWGPUSharedBufferMemoryDescriptor): IWGPUSharedBufferMemory;
function ImportSharedFence(const aDescriptor: TWGPUSharedFenceDescriptor): IWGPUSharedFence;
function ImportSharedTextureMemory(const aDescriptor: TWGPUSharedTextureMemoryDescriptor): IWGPUSharedTextureMemory;
procedure InjectError(const aType: TWGPUErrorType; const aMessage: TWGPUStringView);
procedure PopErrorScope(const aOldCallback: TWGPUErrorCallback; const aUserdata: Pointer);
function PopErrorScope2(const aCallbackInfo: TWGPUPopErrorScopeCallbackInfo2): TWGPUFuture;
function PopErrorScopeF(const aCallbackInfo: TWGPUPopErrorScopeCallbackInfo): TWGPUFuture;
procedure PushErrorScope(const aFilter: TWGPUErrorFilter);
procedure SetDeviceLostCallback(const aCallback: TWGPUDeviceLostCallback; const aUserdata: Pointer);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetLoggingCallback(const aCallback: TWGPULoggingCallback; const aUserdata: Pointer);
procedure SetUncapturedErrorCallback(const aCallback: TWGPUErrorCallback; const aUserdata: Pointer);
procedure Tick;
procedure ValidateTextureDescriptor(const aDescriptor: TWGPUTextureDescriptor);
end;
IWGPUExternalTexture = interface
['{0E1115A9-86F4-5155-65D6-5F010585CDF6}']
function GetHandle: TWGPUExternalTexture;
procedure Expire;
procedure Refresh;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUInstance = interface
['{F1B8469C-6F36-DB74-B653-F2D1B7538413}']
function GetHandle: TWGPUInstance;
function CreateSurface(const aDescriptor: TWGPUSurfaceDescriptor): IWGPUSurface;
function EnumerateWGSLLanguageFeatures(const aFeatures: PWGPUWGSLFeatureName): NativeUInt;
function HasWGSLLanguageFeature(const aFeature: TWGPUWGSLFeatureName): TWGPUBool;
procedure ProcessEvents;
procedure RequestAdapter(const aOptions: TWGPURequestAdapterOptions; const aCallback: TWGPURequestAdapterCallback; const aUserdata: Pointer);
function RequestAdapter2(const aOptions: TWGPURequestAdapterOptions; const aCallbackInfo: TWGPURequestAdapterCallbackInfo2): TWGPUFuture;
function RequestAdapterF(const aOptions: TWGPURequestAdapterOptions; const aCallbackInfo: TWGPURequestAdapterCallbackInfo): TWGPUFuture;
function WaitAny(aFutureCount: NativeUInt; const aFutures: PWGPUFutureWaitInfo; aTimeoutNS: UInt64): TWGPUWaitStatus;
end;
IWGPUPipelineLayout = interface
['{0B34D626-DCF4-7857-60A4-BA3D77C942B3}']
function GetHandle: TWGPUPipelineLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUQuerySet = interface
['{EB6DCE87-D4CC-8C4C-F6A4-CDA5E4488E6C}']
function GetHandle: TWGPUQuerySet;
function GetCount: UInt32;
function GetType: TWGPUQueryType;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUQueue = interface
['{4CBE6E56-BD36-266F-EEF2-D54D52FE5869}']
function GetHandle: TWGPUQueue;
procedure CopyExternalTextureForBrowser(const aSource: PWGPUImageCopyExternalTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D; const aOptions: TWGPUCopyTextureForBrowserOptions);
procedure CopyTextureForBrowser(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D; const aOptions: TWGPUCopyTextureForBrowserOptions);
procedure OnSubmittedWorkDone(const aCallback: TWGPUQueueWorkDoneCallback; const aUserdata: Pointer);
function OnSubmittedWorkDone2(const aCallbackInfo: TWGPUQueueWorkDoneCallbackInfo2): TWGPUFuture;
function OnSubmittedWorkDoneF(const aCallbackInfo: TWGPUQueueWorkDoneCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Submit(const aCommand: IWGPUCommandBuffer); overload;
procedure Submit(const aCommands: TIWGPUCommandBufferArray); overload;
procedure WriteBuffer(const aBuffer: IWGPUBuffer; aBufferOffset: UInt64; const aData: Pointer; aSize: NativeUInt);
procedure WriteTexture(const aDestination: PWGPUImageCopyTexture; const aData: Pointer; aDataSize: NativeUInt; const aDataLayout: PWGPUTextureDataLayout; const aWriteSize: PWGPUExtent3D);
end;
IWGPURenderBundle = interface
['{62CFDD16-CFEF-9D6B-B8B8-EC7C813247D8}']
function GetHandle: TWGPURenderBundle;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPURenderBundleEncoder = interface
['{1DE4BD41-8BB4-6B2D-D0F9-5B641D6283FC}']
function GetHandle: TWGPURenderBundleEncoder;
procedure Draw(aVertexCount: UInt32; aInstanceCount: UInt32; aFirstVertex: UInt32; aFirstInstance: UInt32);
procedure DrawIndexed(aIndexCount: UInt32; aInstanceCount: UInt32; aFirstIndex: UInt32; const aBaseVertex: Int32; aFirstInstance: UInt32);
procedure DrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure DrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
function Finish(const aDescriptor: PWGPURenderBundleDescriptor): IWGPURenderBundle;
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetIndexBuffer(const aBuffer: IWGPUBuffer; const aFormat: TWGPUIndexFormat; aOffset: UInt64; aSize: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPURenderPipeline);
procedure SetVertexBuffer(aSlot: UInt32; const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
end;
IWGPURenderPassEncoder = interface
['{36C89154-C8D5-1E4C-BC9D-3D9325DFAF9B}']
function GetHandle: TWGPURenderPassEncoder;
procedure BeginOcclusionQuery(aQueryIndex: UInt32);
procedure Draw(aVertexCount: UInt32; aInstanceCount: UInt32; aFirstVertex: UInt32; aFirstInstance: UInt32);
procedure DrawIndexed(aIndexCount: UInt32; aInstanceCount: UInt32; aFirstIndex: UInt32; const aBaseVertex: Int32; aFirstInstance: UInt32);
procedure DrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure DrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure &End;
procedure EndOcclusionQuery;
procedure ExecuteBundles(aBundleCount: NativeUInt; const aBundles: PWGPURenderBundle);
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure MultiDrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64; aMaxDrawCount: UInt32; const aDrawCountBuffer: IWGPUBuffer; aDrawCountBufferOffset: UInt64);
procedure MultiDrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64; aMaxDrawCount: UInt32; const aDrawCountBuffer: IWGPUBuffer; aDrawCountBufferOffset: UInt64);
procedure PixelLocalStorageBarrier;
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetBlendConstant(const aColor: PWGPUColor);
procedure SetIndexBuffer(const aBuffer: IWGPUBuffer; const aFormat: TWGPUIndexFormat; aOffset: UInt64; aSize: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPURenderPipeline);
procedure SetScissorRect(aX: UInt32; aY: UInt32; aWidth: UInt32; aHeight: UInt32);
procedure SetStencilReference(aReference: UInt32);
procedure SetVertexBuffer(aSlot: UInt32; const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
procedure SetViewport(const aX: Single; const aY: Single; const aWidth: Single; const aHeight: Single; const aMinDepth: Single; const aMaxDepth: Single);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
IWGPURenderPipeline = interface
['{54B16051-8009-561C-74DD-9E4DB3461191}']
function GetHandle: TWGPURenderPipeline;
function GetBindGroupLayout(aGroupIndex: UInt32): IWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUSampler = interface
['{CC574ADD-E54C-F740-ECCF-8F3063233408}']
function GetHandle: TWGPUSampler;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUShaderModule = interface
['{4CD3FBBA-8F0C-7203-F991-549B9034BE77}']
function GetHandle: TWGPUShaderModule;
procedure GetCompilationInfo(const aCallback: TWGPUCompilationInfoCallback; const aUserdata: Pointer);
function GetCompilationInfo2(const aCallbackInfo: TWGPUCompilationInfoCallbackInfo2): TWGPUFuture;
function GetCompilationInfoF(const aCallbackInfo: TWGPUCompilationInfoCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUSharedBufferMemory = interface
['{E6D9BCD6-F3CC-C067-E33A-093C6D0FFBF5}']
function GetHandle: TWGPUSharedBufferMemory;
function BeginAccess(const aBuffer: IWGPUBuffer; const aDescriptor: TWGPUSharedBufferMemoryBeginAccessDescriptor): TWGPUStatus;
function CreateBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function EndAccess(const aBuffer: IWGPUBuffer; const aDescriptor: PWGPUSharedBufferMemoryEndAccessState): TWGPUStatus;
function GetProperties(const aProperties: PWGPUSharedBufferMemoryProperties): TWGPUStatus;
function IsDeviceLost: TWGPUBool;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUSharedFence = interface
['{37AF18F5-47F4-C274-5509-855D8D609392}']
function GetHandle: TWGPUSharedFence;
procedure ExportInfo(const aInfo: PWGPUSharedFenceExportInfo);
end;
IWGPUSharedTextureMemory = interface
['{B5C272BE-10AD-2E36-346D-180B924B4AC6}']
function GetHandle: TWGPUSharedTextureMemory;
function BeginAccess(const aTexture: IWGPUTexture; const aDescriptor: TWGPUSharedTextureMemoryBeginAccessDescriptor): TWGPUStatus;
function CreateTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function EndAccess(const aTexture: IWGPUTexture; const aDescriptor: PWGPUSharedTextureMemoryEndAccessState): TWGPUStatus;
function GetProperties(const aProperties: PWGPUSharedTextureMemoryProperties): TWGPUStatus;
function IsDeviceLost: TWGPUBool;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
IWGPUSurface = interface
['{8452B981-4E40-3147-AF59-71F11D12A43C}']
function GetHandle: TWGPUSurface;
procedure Configure(const aConfig: TWGPUSurfaceConfiguration);
function GetCapabilities(const aAdapter: IWGPUAdapter; const aCapabilities: PWGPUSurfaceCapabilities): TWGPUStatus;
function GetCurrentTexture : IWGPUTexture;
procedure Present;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Unconfigure;
end;
IWGPUTexture = interface
['{13DB8189-BFB9-23F7-C715-19710FB0C5B6}']
function GetHandle: TWGPUTexture;
function GetLabel: TWGPUStringView;
function CreateErrorView(const aDescriptor: TWGPUTextureViewDescriptor): IWGPUTextureView;
function CreateView(const aDescriptor: TWGPUTextureViewDescriptor): IWGPUTextureView;
function GetDepthOrArrayLayers: UInt32;
function GetDimension: TWGPUTextureDimension;
function GetFormat: TWGPUTextureFormat;
function GetHeight: UInt32;
function GetMipLevelCount: UInt32;
function GetSampleCount: UInt32;
function GetUsage: TWGPUTextureUsage;
function GetWidth: UInt32;
procedure SetLabel(const aLabel: TWGPUStringView);
property &Label : TWGPUStringView read GetLabel write SetLabel;
end;
IWGPUTextureView = interface
['{3F5BC914-7392-CA2E-12C6-C9793448F797}']
function GetHandle: TWGPUTextureView;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
WGPUFactory = class sealed
public
// To create top level instance
class function CreateInstance(const aInstanceDescriptor : TWGPUInstanceDescriptor) : IWGPUInstance; static;
// To wrap entities received in request & async callbacks
class function WrapAdapter(const aAdapter : TWGPUAdapter) : IWGPUAdapter; static;
class function WrapDevice(const aDevice : TWGPUDevice) : IWGPUDevice; static;
class function WrapComputePipeline(const aPipeLine : TWGPUComputePipeline) : IWGPUComputePipeline; static;
class function WrapRenderPipeline(const aPipeLine : TWGPURenderPipeline) : IWGPURenderPipeline; static;
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
implementation
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
type
TiwgpuAdapter = class(TInterfacedObject, IWGPUAdapter)
FHandle: TWGPUAdapter;
constructor Create(const h: TWGPUAdapter);
destructor Destroy; override;
function GetHandle: TWGPUAdapter;
function CreateDevice(const aDescriptor: TWGPUDeviceDescriptor): IWGPUDevice;
function EnumerateFeatures : TWGPUFeatureNameArray; overload;
function EnumerateFeatures(const aFeatures: PWGPUFeatureName): NativeUInt; overload;
procedure GetFeatures(const aFeatures: PWGPUSupportedFeatures);
function GetFormatCapabilities(const aFormat: TWGPUTextureFormat; const aCapabilities: PWGPUFormatCapabilities): TWGPUStatus;
function GetInfo(const aInfo: PWGPUAdapterInfo): TWGPUStatus;
function GetInstance: IWGPUInstance;
function GetLimits(const aLimits: PWGPUSupportedLimits): TWGPUStatus;
function HasFeature(const aFeature: TWGPUFeatureName): TWGPUBool;
procedure RequestDevice(const aDescriptor: TWGPUDeviceDescriptor; const aCallback: TWGPURequestDeviceCallback; const aUserdata: Pointer);
function RequestDevice2(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo2): TWGPUFuture;
function RequestDeviceF(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo): TWGPUFuture;
end;
TiwgpuBindGroup = class(TInterfacedObject, IWGPUBindGroup)
FHandle: TWGPUBindGroup;
constructor Create(const h: TWGPUBindGroup);
destructor Destroy; override;
function GetHandle: TWGPUBindGroup;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuBindGroupLayout = class(TInterfacedObject, IWGPUBindGroupLayout)
FHandle: TWGPUBindGroupLayout;
constructor Create(const h: TWGPUBindGroupLayout);
destructor Destroy; override;
function GetHandle: TWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuBuffer = class(TInterfacedObject, IWGPUBuffer)
FHandle: TWGPUBuffer;
FLabel: TWGPUStringView;
constructor Create(const h: TWGPUBuffer; const aLabel: UTF8String = '');
destructor Destroy; override;
function GetHandle: TWGPUBuffer;
function GetLabel: TWGPUStringView;
function GetConstMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
function GetMapState: TWGPUBufferMapState;
function GetMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
function GetSize: UInt64;
function GetUsage: TWGPUBufferUsage;
procedure MapAsync(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallback: TWGPUBufferMapCallback; const aUserdata: Pointer);
function MapAsync2(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo2): TWGPUFuture;
function MapAsyncF(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Unmap;
end;
TiwgpuCommandBuffer = class(TInterfacedObject, IWGPUCommandBuffer)
FHandle: TWGPUCommandBuffer;
constructor Create(const h: TWGPUCommandBuffer);
destructor Destroy; override;
function GetHandle: TWGPUCommandBuffer;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuCommandEncoder = class(TInterfacedObject, IWGPUCommandEncoder)
FHandle: TWGPUCommandEncoder;
constructor Create(const h: TWGPUCommandEncoder);
destructor Destroy; override;
function GetHandle: TWGPUCommandEncoder;
function BeginComputePass : IWGPUComputePassEncoder; overload;
function BeginComputePass(const aDescriptor: TWGPUComputePassDescriptor) : IWGPUComputePassEncoder; overload;
function BeginRenderPass(const aDescriptor: TWGPURenderPassDescriptor): IWGPURenderPassEncoder;
procedure ClearBuffer(const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
procedure CopyBufferToBuffer(const aSource: IWGPUBuffer; aSourceOffset: UInt64; const aDestination: IWGPUBuffer; aDestinationOffset: UInt64; aSize: UInt64);
procedure CopyBufferToTexture(const aSource: PWGPUImageCopyBuffer; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D);
procedure CopyTextureToBuffer(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyBuffer; const aCopySize: PWGPUExtent3D);
procedure CopyTextureToTexture(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D);
function Finish(const aDescriptor: PWGPUCommandBufferDescriptor): IWGPUCommandBuffer;
procedure InjectValidationError(const aMessage: TWGPUStringView);
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure ResolveQuerySet(const aQuerySet: IWGPUQuerySet; aFirstQuery: UInt32; aQueryCount: UInt32; const aDestination: IWGPUBuffer; aDestinationOffset: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure WriteBuffer(const aBuffer: IWGPUBuffer; aBufferOffset: UInt64; const aData: PUInt8; aSize: UInt64);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
TiwgpuComputePassEncoder = class(TInterfacedObject, IWGPUComputePassEncoder)
FHandle: TWGPUComputePassEncoder;
constructor Create(const h: TWGPUComputePassEncoder);
destructor Destroy; override;
function GetHandle: TWGPUComputePassEncoder;
procedure DispatchWorkgroups(aWorkgroupCountX: UInt32; aWorkgroupCountY: UInt32; aWorkgroupCountZ: UInt32);
procedure DispatchWorkgroupsIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure &End;
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPUComputePipeline);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
TiwgpuComputePipeline = class(TInterfacedObject, IWGPUComputePipeline)
FHandle: TWGPUComputePipeline;
constructor Create(const h: TWGPUComputePipeline);
destructor Destroy; override;
function GetHandle: TWGPUComputePipeline;
function GetBindGroupLayout(aGroupIndex: UInt32): IWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuDevice = class(TInterfacedObject, IWGPUDevice)
FHandle: TWGPUDevice;
constructor Create(const h: TWGPUDevice);
destructor Destroy; override;
function GetHandle: TWGPUDevice;
function CreateBindGroup(const aDescriptor: TWGPUBindGroupDescriptor): IWGPUBindGroup;
function CreateBindGroupLayout(const aDescriptor: TWGPUBindGroupLayoutDescriptor): IWGPUBindGroupLayout;
function CreateBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function CreateCommandEncoder(const aDescriptor: TWGPUCommandEncoderDescriptor): IWGPUCommandEncoder;
function CreateComputePipeline(const aDescriptor: TWGPUComputePipelineDescriptor): IWGPUComputePipeline;
procedure CreateComputePipelineAsync(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallback: TWGPUCreateComputePipelineAsyncCallback; const aUserdata: Pointer);
function CreateComputePipelineAsync2(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallbackInfo: TWGPUCreateComputePipelineAsyncCallbackInfo2): TWGPUFuture;
function CreateComputePipelineAsyncF(const aDescriptor: TWGPUComputePipelineDescriptor; const aCallbackInfo: TWGPUCreateComputePipelineAsyncCallbackInfo): TWGPUFuture;
function CreateErrorBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function CreateErrorExternalTexture: IWGPUExternalTexture;
function CreateErrorShaderModule(const aDescriptor: TWGPUShaderModuleDescriptor; const aErrorMessage: TWGPUStringView): IWGPUShaderModule;
function CreateErrorTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function CreateExternalTexture(const aExternalTextureDescriptor: TWGPUExternalTextureDescriptor): IWGPUExternalTexture;
function CreatePipelineLayout(const aDescriptor: TWGPUPipelineLayoutDescriptor): IWGPUPipelineLayout;
function CreateQuerySet(const aDescriptor: TWGPUQuerySetDescriptor): IWGPUQuerySet;
function CreateRenderBundleEncoder(const aDescriptor: TWGPURenderBundleEncoderDescriptor): IWGPURenderBundleEncoder;
function CreateRenderPipeline(const aDescriptor: TWGPURenderPipelineDescriptor): IWGPURenderPipeline;
procedure CreateRenderPipelineAsync(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallback: TWGPUCreateRenderPipelineAsyncCallback; const aUserdata: Pointer);
function CreateRenderPipelineAsync2(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallbackInfo: TWGPUCreateRenderPipelineAsyncCallbackInfo2): TWGPUFuture;
function CreateRenderPipelineAsyncF(const aDescriptor: TWGPURenderPipelineDescriptor; const aCallbackInfo: TWGPUCreateRenderPipelineAsyncCallbackInfo): TWGPUFuture;
function CreateSampler(const aDescriptor: TWGPUSamplerDescriptor): IWGPUSampler;
function CreateShaderModule(const aDescriptor: TWGPUShaderModuleDescriptor): IWGPUShaderModule;
function CreateTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function EnumerateFeatures : TWGPUFeatureNameArray; overload;
function EnumerateFeatures(const aFeatures: PWGPUFeatureName): NativeUInt; overload;
procedure ForceLoss(const aType: TWGPUDeviceLostReason; const aMessage: TWGPUStringView);
function GetAHardwareBufferProperties(const aHandle: Pointer; const aProperties: PWGPUAHardwareBufferProperties): TWGPUStatus;
function GetAdapter: IWGPUAdapter;
procedure GetFeatures(const aFeatures: PWGPUSupportedFeatures);
function GetLimits(const aLimits: PWGPUSupportedLimits): TWGPUStatus;
function GetLostFuture: TWGPUFuture;
function GetQueue: IWGPUQueue;
function HasFeature(const aFeature: TWGPUFeatureName): TWGPUBool;
function ImportSharedBufferMemory(const aDescriptor: TWGPUSharedBufferMemoryDescriptor): IWGPUSharedBufferMemory;
function ImportSharedFence(const aDescriptor: TWGPUSharedFenceDescriptor): IWGPUSharedFence;
function ImportSharedTextureMemory(const aDescriptor: TWGPUSharedTextureMemoryDescriptor): IWGPUSharedTextureMemory;
procedure InjectError(const aType: TWGPUErrorType; const aMessage: TWGPUStringView);
procedure PopErrorScope(const aOldCallback: TWGPUErrorCallback; const aUserdata: Pointer);
function PopErrorScope2(const aCallbackInfo: TWGPUPopErrorScopeCallbackInfo2): TWGPUFuture;
function PopErrorScopeF(const aCallbackInfo: TWGPUPopErrorScopeCallbackInfo): TWGPUFuture;
procedure PushErrorScope(const aFilter: TWGPUErrorFilter);
procedure SetDeviceLostCallback(const aCallback: TWGPUDeviceLostCallback; const aUserdata: Pointer);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetLoggingCallback(const aCallback: TWGPULoggingCallback; const aUserdata: Pointer);
procedure SetUncapturedErrorCallback(const aCallback: TWGPUErrorCallback; const aUserdata: Pointer);
procedure Tick;
procedure ValidateTextureDescriptor(const aDescriptor: TWGPUTextureDescriptor);
end;
TiwgpuExternalTexture = class(TInterfacedObject, IWGPUExternalTexture)
FHandle: TWGPUExternalTexture;
constructor Create(const h: TWGPUExternalTexture);
destructor Destroy; override;
function GetHandle: TWGPUExternalTexture;
procedure Expire;
procedure Refresh;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuInstance = class(TInterfacedObject, IWGPUInstance)
FHandle: TWGPUInstance;
constructor Create(const h: TWGPUInstance);
destructor Destroy; override;
function GetHandle: TWGPUInstance;
function CreateSurface(const aDescriptor: TWGPUSurfaceDescriptor): IWGPUSurface;
function EnumerateWGSLLanguageFeatures(const aFeatures: PWGPUWGSLFeatureName): NativeUInt;
function HasWGSLLanguageFeature(const aFeature: TWGPUWGSLFeatureName): TWGPUBool;
procedure ProcessEvents;
procedure RequestAdapter(const aOptions: TWGPURequestAdapterOptions; const aCallback: TWGPURequestAdapterCallback; const aUserdata: Pointer);
function RequestAdapter2(const aOptions: TWGPURequestAdapterOptions; const aCallbackInfo: TWGPURequestAdapterCallbackInfo2): TWGPUFuture;
function RequestAdapterF(const aOptions: TWGPURequestAdapterOptions; const aCallbackInfo: TWGPURequestAdapterCallbackInfo): TWGPUFuture;
function WaitAny(aFutureCount: NativeUInt; const aFutures: PWGPUFutureWaitInfo; aTimeoutNS: UInt64): TWGPUWaitStatus;
end;
TiwgpuPipelineLayout = class(TInterfacedObject, IWGPUPipelineLayout)
FHandle: TWGPUPipelineLayout;
constructor Create(const h: TWGPUPipelineLayout);
destructor Destroy; override;
function GetHandle: TWGPUPipelineLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuQuerySet = class(TInterfacedObject, IWGPUQuerySet)
FHandle: TWGPUQuerySet;
constructor Create(const h: TWGPUQuerySet);
destructor Destroy; override;
function GetHandle: TWGPUQuerySet;
function GetCount: UInt32;
function GetType: TWGPUQueryType;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuQueue = class(TInterfacedObject, IWGPUQueue)
FHandle: TWGPUQueue;
constructor Create(const h: TWGPUQueue);
destructor Destroy; override;
function GetHandle: TWGPUQueue;
procedure CopyExternalTextureForBrowser(const aSource: PWGPUImageCopyExternalTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D; const aOptions: TWGPUCopyTextureForBrowserOptions);
procedure CopyTextureForBrowser(const aSource: PWGPUImageCopyTexture; const aDestination: PWGPUImageCopyTexture; const aCopySize: PWGPUExtent3D; const aOptions: TWGPUCopyTextureForBrowserOptions);
procedure OnSubmittedWorkDone(const aCallback: TWGPUQueueWorkDoneCallback; const aUserdata: Pointer);
function OnSubmittedWorkDone2(const aCallbackInfo: TWGPUQueueWorkDoneCallbackInfo2): TWGPUFuture;
function OnSubmittedWorkDoneF(const aCallbackInfo: TWGPUQueueWorkDoneCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Submit(const aCommand: IWGPUCommandBuffer); overload;
procedure Submit(const aCommands: TIWGPUCommandBufferArray); overload;
procedure WriteBuffer(const aBuffer: IWGPUBuffer; aBufferOffset: UInt64; const aData: Pointer; aSize: NativeUInt);
procedure WriteTexture(const aDestination: PWGPUImageCopyTexture; const aData: Pointer; aDataSize: NativeUInt; const aDataLayout: PWGPUTextureDataLayout; const aWriteSize: PWGPUExtent3D);
end;
TiwgpuRenderBundle = class(TInterfacedObject, IWGPURenderBundle)
FHandle: TWGPURenderBundle;
constructor Create(const h: TWGPURenderBundle);
destructor Destroy; override;
function GetHandle: TWGPURenderBundle;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuRenderBundleEncoder = class(TInterfacedObject, IWGPURenderBundleEncoder)
FHandle: TWGPURenderBundleEncoder;
constructor Create(const h: TWGPURenderBundleEncoder);
destructor Destroy; override;
function GetHandle: TWGPURenderBundleEncoder;
procedure Draw(aVertexCount: UInt32; aInstanceCount: UInt32; aFirstVertex: UInt32; aFirstInstance: UInt32);
procedure DrawIndexed(aIndexCount: UInt32; aInstanceCount: UInt32; aFirstIndex: UInt32; const aBaseVertex: Int32; aFirstInstance: UInt32);
procedure DrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure DrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
function Finish(const aDescriptor: PWGPURenderBundleDescriptor): IWGPURenderBundle;
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetIndexBuffer(const aBuffer: IWGPUBuffer; const aFormat: TWGPUIndexFormat; aOffset: UInt64; aSize: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPURenderPipeline);
procedure SetVertexBuffer(aSlot: UInt32; const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
end;
TiwgpuRenderPassEncoder = class(TInterfacedObject, IWGPURenderPassEncoder)
FHandle: TWGPURenderPassEncoder;
constructor Create(const h: TWGPURenderPassEncoder);
destructor Destroy; override;
function GetHandle: TWGPURenderPassEncoder;
procedure BeginOcclusionQuery(aQueryIndex: UInt32);
procedure Draw(aVertexCount: UInt32; aInstanceCount: UInt32; aFirstVertex: UInt32; aFirstInstance: UInt32);
procedure DrawIndexed(aIndexCount: UInt32; aInstanceCount: UInt32; aFirstIndex: UInt32; const aBaseVertex: Int32; aFirstInstance: UInt32);
procedure DrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure DrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64);
procedure &End;
procedure EndOcclusionQuery;
procedure ExecuteBundles(aBundleCount: NativeUInt; const aBundles: PWGPURenderBundle);
procedure InsertDebugMarker(const aMarkerLabel: TWGPUStringView);
procedure MultiDrawIndexedIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64; aMaxDrawCount: UInt32; const aDrawCountBuffer: IWGPUBuffer; aDrawCountBufferOffset: UInt64);
procedure MultiDrawIndirect(const aIndirectBuffer: IWGPUBuffer; aIndirectOffset: UInt64; aMaxDrawCount: UInt32; const aDrawCountBuffer: IWGPUBuffer; aDrawCountBufferOffset: UInt64);
procedure PixelLocalStorageBarrier;
procedure PopDebugGroup;
procedure PushDebugGroup(const aGroupLabel: TWGPUStringView);
procedure SetBindGroup(aGroupIndex: UInt32; const aGroup: IWGPUBindGroup; aDynamicOffsetCount: NativeUInt; const aDynamicOffsets: PUInt32);
procedure SetBlendConstant(const aColor: PWGPUColor);
procedure SetIndexBuffer(const aBuffer: IWGPUBuffer; const aFormat: TWGPUIndexFormat; aOffset: UInt64; aSize: UInt64);
procedure SetLabel(const aLabel: TWGPUStringView);
procedure SetPipeline(const aPipeline: IWGPURenderPipeline);
procedure SetScissorRect(aX: UInt32; aY: UInt32; aWidth: UInt32; aHeight: UInt32);
procedure SetStencilReference(aReference: UInt32);
procedure SetVertexBuffer(aSlot: UInt32; const aBuffer: IWGPUBuffer; aOffset: UInt64; aSize: UInt64);
procedure SetViewport(const aX: Single; const aY: Single; const aWidth: Single; const aHeight: Single; const aMinDepth: Single; const aMaxDepth: Single);
procedure WriteTimestamp(const aQuerySet: IWGPUQuerySet; aQueryIndex: UInt32);
end;
TiwgpuRenderPipeline = class(TInterfacedObject, IWGPURenderPipeline)
FHandle: TWGPURenderPipeline;
constructor Create(const h: TWGPURenderPipeline);
destructor Destroy; override;
function GetHandle: TWGPURenderPipeline;
function GetBindGroupLayout(aGroupIndex: UInt32): IWGPUBindGroupLayout;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuSampler = class(TInterfacedObject, IWGPUSampler)
FHandle: TWGPUSampler;
constructor Create(const h: TWGPUSampler);
destructor Destroy; override;
function GetHandle: TWGPUSampler;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuShaderModule = class(TInterfacedObject, IWGPUShaderModule)
FHandle: TWGPUShaderModule;
constructor Create(const h: TWGPUShaderModule);
destructor Destroy; override;
function GetHandle: TWGPUShaderModule;
procedure GetCompilationInfo(const aCallback: TWGPUCompilationInfoCallback; const aUserdata: Pointer);
function GetCompilationInfo2(const aCallbackInfo: TWGPUCompilationInfoCallbackInfo2): TWGPUFuture;
function GetCompilationInfoF(const aCallbackInfo: TWGPUCompilationInfoCallbackInfo): TWGPUFuture;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuSharedBufferMemory = class(TInterfacedObject, IWGPUSharedBufferMemory)
FHandle: TWGPUSharedBufferMemory;
constructor Create(const h: TWGPUSharedBufferMemory);
destructor Destroy; override;
function GetHandle: TWGPUSharedBufferMemory;
function BeginAccess(const aBuffer: IWGPUBuffer; const aDescriptor: TWGPUSharedBufferMemoryBeginAccessDescriptor): TWGPUStatus;
function CreateBuffer(const aDescriptor: TWGPUBufferDescriptor): IWGPUBuffer;
function EndAccess(const aBuffer: IWGPUBuffer; const aDescriptor: PWGPUSharedBufferMemoryEndAccessState): TWGPUStatus;
function GetProperties(const aProperties: PWGPUSharedBufferMemoryProperties): TWGPUStatus;
function IsDeviceLost: TWGPUBool;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuSharedFence = class(TInterfacedObject, IWGPUSharedFence)
FHandle: TWGPUSharedFence;
constructor Create(const h: TWGPUSharedFence);
destructor Destroy; override;
function GetHandle: TWGPUSharedFence;
procedure ExportInfo(const aInfo: PWGPUSharedFenceExportInfo);
end;
TiwgpuSharedTextureMemory = class(TInterfacedObject, IWGPUSharedTextureMemory)
FHandle: TWGPUSharedTextureMemory;
constructor Create(const h: TWGPUSharedTextureMemory);
destructor Destroy; override;
function GetHandle: TWGPUSharedTextureMemory;
function BeginAccess(const aTexture: IWGPUTexture; const aDescriptor: TWGPUSharedTextureMemoryBeginAccessDescriptor): TWGPUStatus;
function CreateTexture(const aDescriptor: TWGPUTextureDescriptor): IWGPUTexture;
function EndAccess(const aTexture: IWGPUTexture; const aDescriptor: PWGPUSharedTextureMemoryEndAccessState): TWGPUStatus;
function GetProperties(const aProperties: PWGPUSharedTextureMemoryProperties): TWGPUStatus;
function IsDeviceLost: TWGPUBool;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuSurface = class(TInterfacedObject, IWGPUSurface)
FHandle: TWGPUSurface;
constructor Create(const h: TWGPUSurface);
destructor Destroy; override;
function GetHandle: TWGPUSurface;
procedure Configure(const aConfig: TWGPUSurfaceConfiguration);
function GetCapabilities(const aAdapter: IWGPUAdapter; const aCapabilities: PWGPUSurfaceCapabilities): TWGPUStatus;
function GetCurrentTexture : IWGPUTexture;
procedure Present;
procedure SetLabel(const aLabel: TWGPUStringView);
procedure Unconfigure;
end;
TiwgpuTexture = class(TInterfacedObject, IWGPUTexture)
FHandle: TWGPUTexture;
FLabel: TWGPUStringView;
constructor Create(const h: TWGPUTexture; const aLabel: UTF8String = '');
destructor Destroy; override;
function GetHandle: TWGPUTexture;
function GetLabel: TWGPUStringView;
function CreateErrorView(const aDescriptor: TWGPUTextureViewDescriptor): IWGPUTextureView;
function CreateView(const aDescriptor: TWGPUTextureViewDescriptor): IWGPUTextureView;
function GetDepthOrArrayLayers: UInt32;
function GetDimension: TWGPUTextureDimension;
function GetFormat: TWGPUTextureFormat;
function GetHeight: UInt32;
function GetMipLevelCount: UInt32;
function GetSampleCount: UInt32;
function GetUsage: TWGPUTextureUsage;
function GetWidth: UInt32;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
TiwgpuTextureView = class(TInterfacedObject, IWGPUTextureView)
FHandle: TWGPUTextureView;
constructor Create(const h: TWGPUTextureView);
destructor Destroy; override;
function GetHandle: TWGPUTextureView;
procedure SetLabel(const aLabel: TWGPUStringView);
end;
//
// TiwgpuAdapter
//
constructor TiwgpuAdapter.Create(const h: TWGPUAdapter);
begin
inherited Create;
FHandle := h;
end;
destructor TiwgpuAdapter.Destroy;
begin
inherited Destroy;
wgpuAdapterRelease(FHandle);
end;
function TiwgpuAdapter.GetHandle: TWGPUAdapter;
begin
Result := FHandle;
end;
function TiwgpuAdapter.CreateDevice(const aDescriptor: TWGPUDeviceDescriptor): IWGPUDevice;
begin
Result := TiwgpuDevice.Create(wgpuAdapterCreateDevice(FHandle, @aDescriptor));
end;
function TIwgpuAdapter.EnumerateFeatures : TWGPUFeatureNameArray;
begin
var n := wgpuAdapterEnumerateFeatures(FHandle, nil);
SetLength(Result, n);
wgpuAdapterEnumerateFeatures(FHandle, Pointer(Result));
end;
function TiwgpuAdapter.EnumerateFeatures(const aFeatures: PWGPUFeatureName): NativeUInt;
begin
Result := wgpuAdapterEnumerateFeatures(FHandle, aFeatures);
end;
procedure TiwgpuAdapter.GetFeatures(const aFeatures: PWGPUSupportedFeatures);
begin
wgpuAdapterGetFeatures(FHandle, aFeatures);
end;
function TiwgpuAdapter.GetFormatCapabilities(const aFormat: TWGPUTextureFormat; const aCapabilities: PWGPUFormatCapabilities): TWGPUStatus;
begin
Result := wgpuAdapterGetFormatCapabilities(FHandle, aFormat, aCapabilities);
end;
function TiwgpuAdapter.GetInfo(const aInfo: PWGPUAdapterInfo): TWGPUStatus;
begin
Result := wgpuAdapterGetInfo(FHandle, aInfo);
end;
function TiwgpuAdapter.GetInstance: IWGPUInstance;
begin
Result := TiwgpuInstance.Create(wgpuAdapterGetInstance(FHandle));
end;
function TiwgpuAdapter.GetLimits(const aLimits: PWGPUSupportedLimits): TWGPUStatus;
begin
Result := wgpuAdapterGetLimits(FHandle, aLimits);
end;
function TiwgpuAdapter.HasFeature(const aFeature: TWGPUFeatureName): TWGPUBool;
begin
Result := wgpuAdapterHasFeature(FHandle, aFeature);
end;
procedure TiwgpuAdapter.RequestDevice(const aDescriptor: TWGPUDeviceDescriptor; const aCallback: TWGPURequestDeviceCallback; const aUserdata: Pointer);
begin
wgpuAdapterRequestDevice(FHandle, @aDescriptor, aCallback, aUserdata);
end;
function TiwgpuAdapter.RequestDevice2(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo2): TWGPUFuture;
begin
Result := wgpuAdapterRequestDevice2(FHandle, @aOptions, aCallbackInfo);
end;
function TiwgpuAdapter.RequestDeviceF(const aOptions: TWGPUDeviceDescriptor; const aCallbackInfo: TWGPURequestDeviceCallbackInfo): TWGPUFuture;
begin
Result := wgpuAdapterRequestDeviceF(FHandle, @aOptions, aCallbackInfo);
end;
//
// TiwgpuBindGroup
//
constructor TiwgpuBindGroup.Create(const h: TWGPUBindGroup);
begin
inherited Create;
FHandle := h;
end;
destructor TiwgpuBindGroup.Destroy;
begin
inherited Destroy;
wgpuBindGroupRelease(FHandle);
end;
function TiwgpuBindGroup.GetHandle: TWGPUBindGroup;
begin
Result := FHandle;
end;
procedure TiwgpuBindGroup.SetLabel(const aLabel: TWGPUStringView);
begin
wgpuBindGroupSetLabel(FHandle, aLabel);
end;
//
// TiwgpuBindGroupLayout
//
constructor TiwgpuBindGroupLayout.Create(const h: TWGPUBindGroupLayout);
begin
inherited Create;
FHandle := h;
end;
destructor TiwgpuBindGroupLayout.Destroy;
begin
inherited Destroy;
wgpuBindGroupLayoutRelease(FHandle);
end;
function TiwgpuBindGroupLayout.GetHandle: TWGPUBindGroupLayout;
begin
Result := FHandle;
end;
procedure TiwgpuBindGroupLayout.SetLabel(const aLabel: TWGPUStringView);
begin
wgpuBindGroupLayoutSetLabel(FHandle, aLabel);
end;
//
// TiwgpuBuffer
//
constructor TiwgpuBuffer.Create(const h: TWGPUBuffer; const aLabel: UTF8String = '');
begin
inherited Create;
FHandle := h;
FLabel := aLabel;
end;
destructor TiwgpuBuffer.Destroy;
begin
inherited Destroy;
wgpuBufferRelease(FHandle);
end;
function TiwgpuBuffer.GetHandle: TWGPUBuffer;
begin
Result := FHandle;
end;
function TiwgpuBuffer.GetLabel: TWGPUStringView;
begin
Result := FLabel;
end;
function TiwgpuBuffer.GetConstMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
begin
Result := wgpuBufferGetConstMappedRange(FHandle, aOffset, aSize);
end;
function TiwgpuBuffer.GetMapState: TWGPUBufferMapState;
begin
Result := wgpuBufferGetMapState(FHandle);
end;
function TiwgpuBuffer.GetMappedRange(aOffset: NativeUInt; aSize: NativeUInt): Pointer;
begin
Result := wgpuBufferGetMappedRange(FHandle, aOffset, aSize);
end;
function TiwgpuBuffer.GetSize: UInt64;
begin
Result := wgpuBufferGetSize(FHandle);
end;
function TiwgpuBuffer.GetUsage: TWGPUBufferUsage;
begin
Result := wgpuBufferGetUsage(FHandle);
end;
procedure TiwgpuBuffer.MapAsync(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallback: TWGPUBufferMapCallback; const aUserdata: Pointer);
begin
wgpuBufferMapAsync(FHandle, aMode, aOffset, aSize, aCallback, aUserdata);
end;
function TiwgpuBuffer.MapAsync2(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo2): TWGPUFuture;
begin
Result := wgpuBufferMapAsync2(FHandle, aMode, aOffset, aSize, aCallbackInfo);
end;
function TiwgpuBuffer.MapAsyncF(const aMode: TWGPUMapMode; aOffset: NativeUInt; aSize: NativeUInt; const aCallbackInfo: TWGPUBufferMapCallbackInfo): TWGPUFuture;
begin
Result := wgpuBufferMapAsyncF(FHandle, aMode, aOffset, aSize, aCallbackInfo);
end;
procedure TiwgpuBuffer.SetLabel(const aLabel: TWGPUStringView);