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
|
/* automatically generated by rust-bindgen 0.69.0 */
pub const HIPRT_API_MAJOR_VERSION: u32 = 1;
pub const HIPRT_API_MINOR_VERSION: u32 = 2;
pub const HIPRT_API_PATCH_VERSION: u32 = 0;
pub const HIPRT_API_VERSION: u32 = 1002000;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtInt2 {
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtFloat2 {
pub x: f32,
pub y: f32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtInt3 {
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
pub z: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtFloat3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtInt4 {
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
pub z: ::std::os::raw::c_int,
pub w: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtFloat4 {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtUint2 {
pub x: ::std::os::raw::c_uint,
pub y: ::std::os::raw::c_uint,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _hiprtContext {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _hiprtCustomFuncTable {
_unused: [u8; 0],
}
pub type hiprtDevicePtr = *mut ::std::os::raw::c_void;
pub type hiprtGeometry = hiprtDevicePtr;
pub type hiprtScene = hiprtDevicePtr;
pub type hiprtBuildFlags = u32;
pub type hiprtRayMask = u32;
pub type hiprtCustomType = u32;
pub type hiprtContext = *mut _hiprtContext;
pub type hiprtCustomFuncTable = *mut _hiprtCustomFuncTable;
pub type hiprtApiDevice = ::std::os::raw::c_int;
pub type hiprtApiCtx = *mut ::std::os::raw::c_void;
pub type hiprtApiStream = *mut ::std::os::raw::c_void;
pub type hiprtApiFunction = *mut ::std::os::raw::c_void;
impl hiprtError {
pub const hiprtSuccess: hiprtError = hiprtError(0);
}
impl hiprtError {
pub const hiprtErrorNotImplemented: hiprtError = hiprtError(1);
}
impl hiprtError {
pub const hiprtErrorInternal: hiprtError = hiprtError(2);
}
impl hiprtError {
pub const hiprtErrorOutOfHostMemory: hiprtError = hiprtError(3);
}
impl hiprtError {
pub const hiprtErrorOutOfDeviceMemory: hiprtError = hiprtError(4);
}
impl hiprtError {
pub const hiprtErrorInvalidApiVersion: hiprtError = hiprtError(5);
}
impl hiprtError {
pub const hiprtErrorInvalidParameter: hiprtError = hiprtError(6);
}
#[repr(transparent)]
#[doc = " \\brief Error codes.\n"]
#[must_use]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtError(pub ::std::os::raw::c_uint);
impl hiprtBuildOperation {
pub const hiprtBuildOperationBuild: hiprtBuildOperation = hiprtBuildOperation(1);
}
impl hiprtBuildOperation {
pub const hiprtBuildOperationUpdate: hiprtBuildOperation = hiprtBuildOperation(2);
}
#[repr(transparent)]
#[doc = " \\brief Type of geometry/scene build operation.\n\n hiprtBuildGeometry/hiprtBuildScene can either build or update\n an underlying acceleration structure."]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtBuildOperation(pub ::std::os::raw::c_uint);
impl hiprtBuildFlagBits {
pub const hiprtBuildFlagBitPreferFastBuild: hiprtBuildFlagBits = hiprtBuildFlagBits(0);
}
impl hiprtBuildFlagBits {
pub const hiprtBuildFlagBitPreferBalancedBuild: hiprtBuildFlagBits = hiprtBuildFlagBits(1);
}
impl hiprtBuildFlagBits {
pub const hiprtBuildFlagBitPreferHighQualityBuild: hiprtBuildFlagBits = hiprtBuildFlagBits(2);
}
impl hiprtBuildFlagBits {
pub const hiprtBuildFlagBitCustomBvhImport: hiprtBuildFlagBits = hiprtBuildFlagBits(3);
}
impl hiprtBuildFlagBits {
pub const hiprtBuildFlagBitDisableSpatialSplits: hiprtBuildFlagBits = hiprtBuildFlagBits(4);
}
#[repr(transparent)]
#[doc = " \\brief Hint flags for geometry/scene build functions.\n\n hiprtBuildGeometry/hiprtBuildScene use these flags to choose\n an appropriate build format/algorithm."]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtBuildFlagBits(pub ::std::os::raw::c_uint);
impl hiprtPrimitiveType {
pub const hiprtPrimitiveTypeTriangleMesh: hiprtPrimitiveType = hiprtPrimitiveType(0);
}
impl hiprtPrimitiveType {
pub const hiprtPrimitiveTypeAABBList: hiprtPrimitiveType = hiprtPrimitiveType(1);
}
#[repr(transparent)]
#[doc = " \\brief Geometric primitive type.\n\n hiprtGeometry can be built from multiple primitive types,\n such as triangle meshes, AABB lists, line lists, etc. This enum\n defines primitive type for hiprtBuildGeometry function."]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtPrimitiveType(pub ::std::os::raw::c_uint);
impl hiprtTraversalState {
pub const hiprtTraversalStateInit: hiprtTraversalState = hiprtTraversalState(0);
}
impl hiprtTraversalState {
pub const hiprtTraversalStateFinished: hiprtTraversalState = hiprtTraversalState(1);
}
impl hiprtTraversalState {
pub const hiprtTraversalStateHit: hiprtTraversalState = hiprtTraversalState(2);
}
impl hiprtTraversalState {
pub const hiprtTraversalStateStackOverflow: hiprtTraversalState = hiprtTraversalState(3);
}
#[repr(transparent)]
#[doc = " \\brief Traversal state.\n\n On-device traversal can be in either hit state (and can be continued using\n hiprtNextHit) or finished state."]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtTraversalState(pub ::std::os::raw::c_uint);
impl hiprtTraversalType {
pub const hiprtTraversalTerminateAtAnyHit: hiprtTraversalType = hiprtTraversalType(1);
}
impl hiprtTraversalType {
pub const hiprtTraversalTerminateAtClosestHit: hiprtTraversalType = hiprtTraversalType(2);
}
#[repr(transparent)]
#[doc = " \\brief Ray traversal type.\n"]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtTraversalType(pub ::std::os::raw::c_uint);
impl hiprtBvhNodeType {
pub const hiprtBvhNodeTypeInternal: hiprtBvhNodeType = hiprtBvhNodeType(0);
}
impl hiprtBvhNodeType {
pub const hiprtBvhNodeTypeLeaf: hiprtBvhNodeType = hiprtBvhNodeType(1);
}
#[repr(transparent)]
#[doc = " \\brief Bvh node type.\n"]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtBvhNodeType(pub ::std::os::raw::c_uint);
#[doc = " \\brief Ray data structure.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtRay {
pub origin: hiprtFloat3,
pub time: f32,
pub direction: hiprtFloat3,
pub maxT: f32,
}
#[doc = " \\brief Ray hit data structure.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtHit {
pub instanceID: u32,
pub primID: u32,
pub uv: hiprtFloat2,
pub normal: hiprtFloat3,
pub t: f32,
}
#[doc = " \\brief Insersection function for custom primitives.\n\n \\param ray Ray.\n \\param primID Primtive ID.\n \\param data User data.\n \\param payload Payload for additional outputs.\n \\param uv Output texture coordinates.\n \\param normal Output normal.\n \\param t Output distance.\n \\return A flag indicating hit."]
pub type hiprtIntersectFunc = ::std::option::Option<
unsafe extern "C" fn(
ray: *const hiprtRay,
primID: u32,
data: *const ::std::os::raw::c_void,
payload: *mut ::std::os::raw::c_void,
uv: *mut hiprtFloat2,
normal: *mut hiprtFloat3,
t: *mut f32,
) -> bool,
>;
#[doc = " \\brief Set of functions for custom primitives.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtCustomFuncSet {
pub intersectFunc: hiprtIntersectFunc,
pub intersectFuncData: *const ::std::os::raw::c_void,
}
impl hiprtDeviceType {
pub const hiprtDeviceAMD: hiprtDeviceType = hiprtDeviceType(0);
}
impl hiprtDeviceType {
pub const hiprtDeviceNVIDIA: hiprtDeviceType = hiprtDeviceType(1);
}
#[repr(transparent)]
#[doc = " \\brief Device type.\n"]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct hiprtDeviceType(pub ::std::os::raw::c_uint);
#[doc = " \\brief Context creation input.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtContextCreationInput {
pub ctxt: hiprtApiCtx,
pub device: hiprtApiDevice,
pub deviceType: hiprtDeviceType,
}
#[doc = " \\brief Various flags controlling scene/geometry build process.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtBuildOptions {
pub buildFlags: hiprtBuildFlags,
}
#[doc = " \\brief Triangle mesh primitive.\n\n Triangle mesh primitive is represented as an indexed vertex array.\n Vertex and index arrays are defined using device pointers and strides.\n Each vertex has to have 3 components: (x, y, z) coordinates.\n Indices are organized into triples (i0, i1, i2) - one for each triangle."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtTriangleMeshPrimitive {
pub vertices: hiprtDevicePtr,
pub vertexCount: u32,
pub vertexStride: u32,
pub triangleIndices: hiprtDevicePtr,
pub triangleCount: u32,
pub triangleStride: u32,
}
#[doc = " \\brief AABB list primitive.\n\n AABB list is an array of axis aligned bounding boxes, represented\n by device memory pointer and stride between two consequetive boxes.\n Each AABB is a pair of float4 values (xmin, ymin, zmin, unused), (xmax, ymax,\n zmax, unused)."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtAABBListPrimitive {
pub aabbs: hiprtDevicePtr,
pub aabbCount: u32,
pub aabbStride: u32,
}
#[doc = " \\brief Bvh node for custom import Bvh.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtBvhNode {
pub childIndices: [u32; 4usize],
pub childNodeTypes: [hiprtBvhNodeType; 4usize],
pub boundingBoxMin: hiprtFloat3,
pub boundingBoxMax: hiprtFloat3,
pub pad: [::std::os::raw::c_int; 2usize],
}
#[doc = " \\brief Bvh node list.\n"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtBvhNodeList {
pub nodes: hiprtDevicePtr,
pub nodeCount: u32,
}
#[doc = " \\brief Input for geometry build/update operation.\n\n Build input defines concrete primitive type and a pointer to an actual\n primitive description."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtGeometryBuildInput {
pub type_: hiprtPrimitiveType,
pub __bindgen_anon_1: hiprtGeometryBuildInput__bindgen_ty_1,
pub nodes: *mut hiprtBvhNodeList,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union hiprtGeometryBuildInput__bindgen_ty_1 {
pub triangleMesh: hiprtGeometryBuildInput__bindgen_ty_1__bindgen_ty_1,
pub aabbList: hiprtGeometryBuildInput__bindgen_ty_1__bindgen_ty_2,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtGeometryBuildInput__bindgen_ty_1__bindgen_ty_1 {
pub primitive: *mut hiprtTriangleMeshPrimitive,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtGeometryBuildInput__bindgen_ty_1__bindgen_ty_2 {
pub primitive: *mut hiprtAABBListPrimitive,
pub customType: hiprtCustomType,
}
#[doc = " \\brief Build input for the scene.\n\n Scene consists of a set of instances. Each of the instances is defined by:\n - Root pointer of the corresponding geometry\n - Transformation header\n - Mask\n\n Instances can refer to the same geometry but with different transformations\n (essentially implementing instancing). Mask is used to implement ray\n masking: ray mask is bitwise &ded with an instance mask, and no intersections\n are evaluated with the primitive of corresponding instance if the result is\n 0. The transformation header defines the offset and the number of consecutive\n transformation frames in the frame array for each instance. More than one frame\n is interpreted as motion blur. If the transformation headers is NULL, it\n assumes one frame per instance. Optionally, it is possible to import a custom\n BVH by setting nodes and the corresponding build flag."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtSceneBuildInput {
pub instanceGeometries: hiprtDevicePtr,
pub instanceTransformHeaders: hiprtDevicePtr,
pub instanceFrames: hiprtDevicePtr,
pub instanceMasks: hiprtDevicePtr,
pub nodes: *mut hiprtBvhNodeList,
pub instanceCount: u32,
pub frameCount: u32,
}
#[doc = " \\brief Transformation frame.\n\n Defines scale, translation, rotation, and time."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtFrame {
pub rotation: hiprtFloat4,
pub scale: hiprtFloat3,
pub translation: hiprtFloat3,
pub time: f32,
pub pad: ::std::os::raw::c_int,
}
#[doc = " \\brief Transformation header.\n\n Defines defines the index to the array of frames and the number of frames."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct hiprtTransformHeader {
pub frameIndex: u32,
pub frameCount: u32,
}
extern crate libloading;
pub struct HipRt {
__library: ::libloading::Library,
pub hiprtCreateContext: Result<
unsafe extern "C" fn(
hiprtApiVersion: u32,
input: *mut hiprtContextCreationInput,
outContext: *mut hiprtContext,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtDestroyContext:
Result<unsafe extern "C" fn(context: hiprtContext) -> hiprtError, ::libloading::Error>,
pub hiprtCreateGeometry: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
outGeometry: *mut hiprtGeometry,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtDestroyGeometry: Result<
unsafe extern "C" fn(context: hiprtContext, outGeometry: hiprtGeometry) -> hiprtError,
::libloading::Error,
>,
pub hiprtBuildGeometry: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildOperation: hiprtBuildOperation,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
temporaryBuffer: hiprtDevicePtr,
stream: hiprtApiStream,
outGeometry: hiprtGeometry,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtGetGeometryBuildTemporaryBufferSize: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
outSize: *mut usize,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtGetGeometryTraceTemporaryBufferSize: Result<
unsafe extern "C" fn(
context: hiprtContext,
scene: hiprtGeometry,
numRays: u32,
outSize: *mut usize,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtCreateScene: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
outScene: *mut hiprtScene,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtDestroyScene: Result<
unsafe extern "C" fn(context: hiprtContext, outScene: hiprtScene) -> hiprtError,
::libloading::Error,
>,
pub hiprtBuildScene: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildOperation: hiprtBuildOperation,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
temporaryBuffer: hiprtDevicePtr,
stream: hiprtApiStream,
outScene: hiprtScene,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtGetSceneBuildTemporaryBufferSize: Result<
unsafe extern "C" fn(
context: hiprtContext,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
outSize: *mut usize,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtGetSceneTraceTemporaryBufferSize: Result<
unsafe extern "C" fn(
context: hiprtContext,
scene: hiprtScene,
numRays: u32,
outSize: *mut usize,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtCreateCustomFuncTable: Result<
unsafe extern "C" fn(
context: hiprtContext,
outFuncTable: *mut hiprtCustomFuncTable,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtSetCustomFuncTable: Result<
unsafe extern "C" fn(
context: hiprtContext,
outFuncTable: hiprtCustomFuncTable,
index: u32,
set: hiprtCustomFuncSet,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtDestroyCustomFuncTable: Result<
unsafe extern "C" fn(
context: hiprtContext,
outFuncTable: hiprtCustomFuncTable,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtSaveGeometry: Result<
unsafe extern "C" fn(
context: hiprtContext,
inGeometry: hiprtGeometry,
filename: *const ::std::os::raw::c_char,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtLoadGeometry: Result<
unsafe extern "C" fn(
context: hiprtContext,
outGeometry: *mut hiprtGeometry,
filename: *const ::std::os::raw::c_char,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtSaveScene: Result<
unsafe extern "C" fn(
context: hiprtContext,
inScene: hiprtScene,
filename: *const ::std::os::raw::c_char,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtLoadScene: Result<
unsafe extern "C" fn(
context: hiprtContext,
outScene: *mut hiprtScene,
filename: *const ::std::os::raw::c_char,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtExportGeometryAabb: Result<
unsafe extern "C" fn(
context: hiprtContext,
inGeometry: hiprtGeometry,
outAabbMin: *mut hiprtFloat3,
outAabbMax: *mut hiprtFloat3,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtExportSceneAabb: Result<
unsafe extern "C" fn(
context: hiprtContext,
inScene: hiprtScene,
outAabbMin: *mut hiprtFloat3,
outAabbMax: *mut hiprtFloat3,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtBuildTraceProgram: Result<
unsafe extern "C" fn(
context: hiprtContext,
functionName: *const ::std::os::raw::c_char,
src: *const ::std::os::raw::c_char,
name: *const ::std::os::raw::c_char,
numHeaders: ::std::os::raw::c_int,
headers: *mut *const ::std::os::raw::c_char,
includeNames: *mut *const ::std::os::raw::c_char,
options: *mut *const ::std::os::raw::c_char,
nOptions: ::std::os::raw::c_int,
progOut: *mut ::std::os::raw::c_void,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtBuildTraceGetBinary: Result<
unsafe extern "C" fn(
prog: *mut ::std::os::raw::c_void,
size: *mut usize,
binary: *mut ::std::os::raw::c_void,
) -> hiprtError,
::libloading::Error,
>,
pub hiprtSetCacheDirPath:
Result<unsafe extern "C" fn(path: *const ::std::os::raw::c_char), ::libloading::Error>,
pub hiprtSetLogLevel:
Result<unsafe extern "C" fn(level: ::std::os::raw::c_int), ::libloading::Error>,
}
impl HipRt {
pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
where
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
Self::from_library(library)
}
pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
where
L: Into<::libloading::Library>,
{
let __library = library.into();
let hiprtCreateContext = __library.get(b"hiprtCreateContext\0").map(|sym| *sym);
let hiprtDestroyContext = __library.get(b"hiprtDestroyContext\0").map(|sym| *sym);
let hiprtCreateGeometry = __library.get(b"hiprtCreateGeometry\0").map(|sym| *sym);
let hiprtDestroyGeometry = __library.get(b"hiprtDestroyGeometry\0").map(|sym| *sym);
let hiprtBuildGeometry = __library.get(b"hiprtBuildGeometry\0").map(|sym| *sym);
let hiprtGetGeometryBuildTemporaryBufferSize = __library
.get(b"hiprtGetGeometryBuildTemporaryBufferSize\0")
.map(|sym| *sym);
let hiprtGetGeometryTraceTemporaryBufferSize = __library
.get(b"hiprtGetGeometryTraceTemporaryBufferSize\0")
.map(|sym| *sym);
let hiprtCreateScene = __library.get(b"hiprtCreateScene\0").map(|sym| *sym);
let hiprtDestroyScene = __library.get(b"hiprtDestroyScene\0").map(|sym| *sym);
let hiprtBuildScene = __library.get(b"hiprtBuildScene\0").map(|sym| *sym);
let hiprtGetSceneBuildTemporaryBufferSize = __library
.get(b"hiprtGetSceneBuildTemporaryBufferSize\0")
.map(|sym| *sym);
let hiprtGetSceneTraceTemporaryBufferSize = __library
.get(b"hiprtGetSceneTraceTemporaryBufferSize\0")
.map(|sym| *sym);
let hiprtCreateCustomFuncTable = __library
.get(b"hiprtCreateCustomFuncTable\0")
.map(|sym| *sym);
let hiprtSetCustomFuncTable = __library.get(b"hiprtSetCustomFuncTable\0").map(|sym| *sym);
let hiprtDestroyCustomFuncTable = __library
.get(b"hiprtDestroyCustomFuncTable\0")
.map(|sym| *sym);
let hiprtSaveGeometry = __library.get(b"hiprtSaveGeometry\0").map(|sym| *sym);
let hiprtLoadGeometry = __library.get(b"hiprtLoadGeometry\0").map(|sym| *sym);
let hiprtSaveScene = __library.get(b"hiprtSaveScene\0").map(|sym| *sym);
let hiprtLoadScene = __library.get(b"hiprtLoadScene\0").map(|sym| *sym);
let hiprtExportGeometryAabb = __library.get(b"hiprtExportGeometryAabb\0").map(|sym| *sym);
let hiprtExportSceneAabb = __library.get(b"hiprtExportSceneAabb\0").map(|sym| *sym);
let hiprtBuildTraceProgram = __library.get(b"hiprtBuildTraceProgram\0").map(|sym| *sym);
let hiprtBuildTraceGetBinary = __library.get(b"hiprtBuildTraceGetBinary\0").map(|sym| *sym);
let hiprtSetCacheDirPath = __library.get(b"hiprtSetCacheDirPath\0").map(|sym| *sym);
let hiprtSetLogLevel = __library.get(b"hiprtSetLogLevel\0").map(|sym| *sym);
Ok(HipRt {
__library,
hiprtCreateContext,
hiprtDestroyContext,
hiprtCreateGeometry,
hiprtDestroyGeometry,
hiprtBuildGeometry,
hiprtGetGeometryBuildTemporaryBufferSize,
hiprtGetGeometryTraceTemporaryBufferSize,
hiprtCreateScene,
hiprtDestroyScene,
hiprtBuildScene,
hiprtGetSceneBuildTemporaryBufferSize,
hiprtGetSceneTraceTemporaryBufferSize,
hiprtCreateCustomFuncTable,
hiprtSetCustomFuncTable,
hiprtDestroyCustomFuncTable,
hiprtSaveGeometry,
hiprtLoadGeometry,
hiprtSaveScene,
hiprtLoadScene,
hiprtExportGeometryAabb,
hiprtExportSceneAabb,
hiprtBuildTraceProgram,
hiprtBuildTraceGetBinary,
hiprtSetCacheDirPath,
hiprtSetLogLevel,
})
}
#[must_use]
#[doc = " \\brief Create HIPRT API context.\n\n All HIPRT functions expect context as their first argument. Context\n keeps global data required by HIPRT session. Calls made from different\n threads with different HIPRT contexts are safe. Calls with the same context\n should be externally synchronized by the client.\n\n \\param hiprtApiVersion API version.\n \\param outContext Created context.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtCreateContext(
&self,
hiprtApiVersion: u32,
input: *mut hiprtContextCreationInput,
outContext: *mut hiprtContext,
) -> hiprtError {
(self
.hiprtCreateContext
.as_ref()
.expect("Expected function, got error."))(hiprtApiVersion, input, outContext)
}
#[must_use]
#[doc = " \\brief Destory HIPRT API context.\n\n Destroys all the global resources used by HIPRT session. Further calls\n with this context are prohibited.\n\n \\param context API context.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtDestroyContext(&self, context: hiprtContext) -> hiprtError {
(self
.hiprtDestroyContext
.as_ref()
.expect("Expected function, got error."))(context)
}
#[must_use]
#[doc = " \\brief Create a geometry.\n\n This function creates\n hiprtGeometry representing acceleration structure topology.\n\n \\param context HIPRT API context.\n \\param buildInput Describes input primitive to build geometry from.\n \\param buildOptions Various flags controlling build process.\n \\param outGeometry Resulting geometry.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtCreateGeometry(
&self,
context: hiprtContext,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
outGeometry: *mut hiprtGeometry,
) -> hiprtError {
(self
.hiprtCreateGeometry
.as_ref()
.expect("Expected function, got error."))(
context,
buildInput,
buildOptions,
outGeometry,
)
}
#[must_use]
#[doc = " \\brief Destroy a geometry.\n\n This function destroys\n hiprtGeometry representing acceleration structure topology.\n\n \\param context HIPRT API context.\n \\param outGeometry Resulting geometry.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtDestroyGeometry(
&self,
context: hiprtContext,
outGeometry: hiprtGeometry,
) -> hiprtError {
(self
.hiprtDestroyGeometry
.as_ref()
.expect("Expected function, got error."))(context, outGeometry)
}
#[must_use]
#[doc = " \\brief Build or update a geometry.\n\n Given geometry description from the client, this function builds\n hiprtGeometry representing acceleration structure topology (in case of a\n build) or updates acceleration structure keeping topology intact (update).\n\n \\param context HIPRT API context.\n \\param buildOperation Type of build operation.\n \\param buildInput Describes input primitive to build geometry from.\n \\param buildOptions Various flags controlling build process.\n \\param attributeOutputs Describes additional values written into vidmem.\n \\param attributeOutputCount Number of additional attributes, can be 0.\n \\param temporaryBuffer Temporary buffer for build operation.\n \\param stream to run acceleration structure build command.\n \\param outGeometry Resulting geometry.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtBuildGeometry(
&self,
context: hiprtContext,
buildOperation: hiprtBuildOperation,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
temporaryBuffer: hiprtDevicePtr,
stream: hiprtApiStream,
outGeometry: hiprtGeometry,
) -> hiprtError {
(self
.hiprtBuildGeometry
.as_ref()
.expect("Expected function, got error."))(
context,
buildOperation,
buildInput,
buildOptions,
temporaryBuffer,
stream,
outGeometry,
)
}
#[must_use]
#[doc = " \\brief Get temporary storage requirements for geometry build.\n\n \\param context HIPRT API context.\n \\param buildInput Describes input primitive to build geometry from.\n \\param buildOptions Various flags controlling build process.\n \\param outSize Pointer to write result to.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtGetGeometryBuildTemporaryBufferSize(
&self,
context: hiprtContext,
buildInput: *const hiprtGeometryBuildInput,
buildOptions: *const hiprtBuildOptions,
outSize: *mut usize,
) -> hiprtError {
(self
.hiprtGetGeometryBuildTemporaryBufferSize
.as_ref()
.expect("Expected function, got error."))(
context, buildInput, buildOptions, outSize
)
}
#[must_use]
#[doc = " \\brief Get temporary storage requirements for scene trace.\n\n \\param context HIPRT API context.\n \\param scene Built scene for trace.\n \\param numRays Rays to be issued.\n \\param outSize Pointer to write result to.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtGetGeometryTraceTemporaryBufferSize(
&self,
context: hiprtContext,
scene: hiprtGeometry,
numRays: u32,
outSize: *mut usize,
) -> hiprtError {
(self
.hiprtGetGeometryTraceTemporaryBufferSize
.as_ref()
.expect("Expected function, got error."))(context, scene, numRays, outSize)
}
#[must_use]
#[doc = " \\brief Create a scene.\n\n This function creates\n hiprtScene representing acceleration structure topology.\n\n \\param context HIPRT API context.\n \\param buildInput Decribes input geometires to build scene for.\n \\param buildOptions Various flags controlling build process.\n \\param outScene Resulting scene.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtCreateScene(
&self,
context: hiprtContext,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
outScene: *mut hiprtScene,
) -> hiprtError {
(self
.hiprtCreateScene
.as_ref()
.expect("Expected function, got error."))(
context, buildInput, buildOptions, outScene
)
}
#[must_use]
#[doc = " \\brief Destroy a scene.\n\n This function destroys\n hiprtScene representing acceleration structure topology.\n\n \\param context HIPRT API context.\n \\param outScene Resulting scene.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtDestroyScene(
&self,
context: hiprtContext,
outScene: hiprtScene,
) -> hiprtError {
(self
.hiprtDestroyScene
.as_ref()
.expect("Expected function, got error."))(context, outScene)
}
#[must_use]
#[doc = " \\brief Build or update a scene.\n\n Given a number of hiprtGeometries from the client, this function builds\n hiprtScene representing top level acceleration structure topology (in case of\n a build) or updates acceleration structure keeping topology intact (update).\n\n \\param context HIPRT API context.\n \\param buildOperation Type of build operation.\n \\param buildInput Decribes input geometires to build scene for.\n \\param buildOptions Various flags controlling build process.\n \\param temporaryBuffer Temporary buffer for build operation.\n \\param stream to run acceleration structure build command.\n \\param outScene Resulting scene.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtBuildScene(
&self,
context: hiprtContext,
buildOperation: hiprtBuildOperation,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
temporaryBuffer: hiprtDevicePtr,
stream: hiprtApiStream,
outScene: hiprtScene,
) -> hiprtError {
(self
.hiprtBuildScene
.as_ref()
.expect("Expected function, got error."))(
context,
buildOperation,
buildInput,
buildOptions,
temporaryBuffer,
stream,
outScene,
)
}
#[must_use]
#[doc = " \\brief Get temporary storage requirements for scene build.\n\n \\param context HIPRT API context.\n \\param buildInput Decribes input geometires to build scene for.\n \\param buildOptions Various flags controlling build process.\n \\param outSize Pointer to write result to.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtGetSceneBuildTemporaryBufferSize(
&self,
context: hiprtContext,
buildInput: *const hiprtSceneBuildInput,
buildOptions: *const hiprtBuildOptions,
outSize: *mut usize,
) -> hiprtError {
(self
.hiprtGetSceneBuildTemporaryBufferSize
.as_ref()
.expect("Expected function, got error."))(
context, buildInput, buildOptions, outSize
)
}
#[must_use]
#[doc = " \\brief Get temporary storage requirements for scene trace.\n\n \\param context HIPRT API context.\n \\param scene Built scene for trace.\n \\param numRays Rays to be issued.\n \\param outSize Pointer to write result to.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtGetSceneTraceTemporaryBufferSize(
&self,
context: hiprtContext,
scene: hiprtScene,
numRays: u32,
outSize: *mut usize,
) -> hiprtError {
(self
.hiprtGetSceneTraceTemporaryBufferSize
.as_ref()
.expect("Expected function, got error."))(context, scene, numRays, outSize)
}
#[must_use]
#[doc = " \\brief Creates a custom function table (for custom geometry).\n\n \\param context HIPRT API context.\n \\param outFuncTable Resulting table.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtCreateCustomFuncTable(
&self,
context: hiprtContext,
outFuncTable: *mut hiprtCustomFuncTable,
) -> hiprtError {
(self
.hiprtCreateCustomFuncTable
.as_ref()
.expect("Expected function, got error."))(context, outFuncTable)
}
#[must_use]
#[doc = " \\brief Sets a custom function table.\n\n \\param context HIPRT API context.\n \\param outFuncTable Resulting table.\n \\param index Index of the set in the table.\n \\param set Function set to be set.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtSetCustomFuncTable(
&self,
context: hiprtContext,
outFuncTable: hiprtCustomFuncTable,
index: u32,
set: hiprtCustomFuncSet,
) -> hiprtError {
(self
.hiprtSetCustomFuncTable
.as_ref()
.expect("Expected function, got error."))(context, outFuncTable, index, set)
}
#[must_use]
#[doc = " \\brief Destroys a custom function table.\n\n \\param context HIPRT API context.\n \\param outFuncTable Resulting table.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtDestroyCustomFuncTable(
&self,
context: hiprtContext,
outFuncTable: hiprtCustomFuncTable,
) -> hiprtError {
(self
.hiprtDestroyCustomFuncTable
.as_ref()
.expect("Expected function, got error."))(context, outFuncTable)
}
#[must_use]
#[doc = " \\brief Saves hiprtGeometry to a binary file.\n\n \\param context HIPRT API context.\n \\param inGeometry Geometry to be saved.\n \\param filename File name with full path.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtSaveGeometry(
&self,
context: hiprtContext,
inGeometry: hiprtGeometry,
filename: *const ::std::os::raw::c_char,
) -> hiprtError {
(self
.hiprtSaveGeometry
.as_ref()
.expect("Expected function, got error."))(context, inGeometry, filename)
}
#[must_use]
#[doc = " \\brief Loads hiprtGeometry to a binary file.\n\n \\param context HIPRT API context.\n \\param outGeometry Geometry to be loaded.\n \\param filename File name with full path.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtLoadGeometry(
&self,
context: hiprtContext,
outGeometry: *mut hiprtGeometry,
filename: *const ::std::os::raw::c_char,
) -> hiprtError {
(self
.hiprtLoadGeometry
.as_ref()
.expect("Expected function, got error."))(context, outGeometry, filename)
}
#[must_use]
#[doc = " \\brief Saves hiprtScene to a binary file.\n\n \\param context HIPRT API context.\n \\param inScene Scene to be saved.\n \\param filename File name with full path.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtSaveScene(
&self,
context: hiprtContext,
inScene: hiprtScene,
filename: *const ::std::os::raw::c_char,
) -> hiprtError {
(self
.hiprtSaveScene
.as_ref()
.expect("Expected function, got error."))(context, inScene, filename)
}
#[must_use]
#[doc = " \\brief Loads hiprtScene to a binary file.\n\n \\param context HIPRT API context.\n \\param outScene Scene to be loaded.\n \\param filename File name with full path.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtLoadScene(
&self,
context: hiprtContext,
outScene: *mut hiprtScene,
filename: *const ::std::os::raw::c_char,
) -> hiprtError {
(self
.hiprtLoadScene
.as_ref()
.expect("Expected function, got error."))(context, outScene, filename)
}
#[must_use]
#[doc = " \\brief Output scene's AABB.\n\n \\param context HIPRT API context.\n \\param inGeometry Geometry to be queried.\n \\param outAabbMin The bounding box min. bound.\n \\param outAabbMax The bounding box max. bound.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtExportGeometryAabb(
&self,
context: hiprtContext,
inGeometry: hiprtGeometry,
outAabbMin: *mut hiprtFloat3,
outAabbMax: *mut hiprtFloat3,
) -> hiprtError {
(self
.hiprtExportGeometryAabb
.as_ref()
.expect("Expected function, got error."))(
context, inGeometry, outAabbMin, outAabbMax
)
}
#[must_use]
#[doc = " \\brief Output scene's AABB.\n\n \\param context HIPRT API context.\n \\param inScene Scene to be queried.\n \\param outAabbMin The bounding box min. bound.\n \\param outAabbMax The bounding box max. bound.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtExportSceneAabb(
&self,
context: hiprtContext,
inScene: hiprtScene,
outAabbMin: *mut hiprtFloat3,
outAabbMax: *mut hiprtFloat3,
) -> hiprtError {
(self
.hiprtExportSceneAabb
.as_ref()
.expect("Expected function, got error."))(
context, inScene, outAabbMin, outAabbMax
)
}
#[must_use]
#[doc = " \\brief Get Program instance with HIPRT routines.\n \\param functionName function to which handle will be returned, cannot be NULL.\n \\param context HIPRT API context.\n \\param src HIP program source.\n \\param name Program source filename.\n \\param numHeaders Number of headers, numHeaders must be greater than or equal to 0.\n \\param headers Sources of the headers, headers can be NULL when numHeaders is 0.\n \\param includeNames Name of each header by which they can be included in the HIP program source, includeNames can be NULL\n when numHeaders is 0.\n \\param options Compiler options, can be NULL.\n \\param progOut Output build program instance.\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtBuildTraceProgram(
&self,
context: hiprtContext,
functionName: *const ::std::os::raw::c_char,
src: *const ::std::os::raw::c_char,
name: *const ::std::os::raw::c_char,
numHeaders: ::std::os::raw::c_int,
headers: *mut *const ::std::os::raw::c_char,
includeNames: *mut *const ::std::os::raw::c_char,
options: *mut *const ::std::os::raw::c_char,
nOptions: ::std::os::raw::c_int,
progOut: *mut ::std::os::raw::c_void,
) -> hiprtError {
(self
.hiprtBuildTraceProgram
.as_ref()
.expect("Expected function, got error."))(
context,
functionName,
src,
name,
numHeaders,
headers,
includeNames,
options,
nOptions,
progOut,
)
}
#[must_use]
#[doc = " \\brief Get binary with HIPRT routines.\n\n \\param prog program instance.\n \\param size Output size of binary .\n \\param binary Output if NULL function returns size of parameter else returned binary(application should allocate for binary)..\n \\return HIPRT error in case of a failure, hiprtSuccess otherwise."]
pub unsafe fn hiprtBuildTraceGetBinary(
&self,
prog: *mut ::std::os::raw::c_void,
size: *mut usize,
binary: *mut ::std::os::raw::c_void,
) -> hiprtError {
(self
.hiprtBuildTraceGetBinary
.as_ref()
.expect("Expected function, got error."))(prog, size, binary)
}
#[doc = " \\brief Setting log level.\n\n \\param path user defined path to cache kernels."]
pub unsafe fn hiprtSetCacheDirPath(&self, path: *const ::std::os::raw::c_char) {
(self
.hiprtSetCacheDirPath
.as_ref()
.expect("Expected function, got error."))(path)
}
#[doc = " \\brief Setting log level.\n\n \\param level Desired log level."]
pub unsafe fn hiprtSetLogLevel(&self, level: ::std::os::raw::c_int) {
(self
.hiprtSetLogLevel
.as_ref()
.expect("Expected function, got error."))(level)
}
}
|