2
2
3
3
use core:: mem;
4
4
5
+ /// Loads an arbitrary type from the buffer. `byte_index` must be a multiple of 4, otherwise,
6
+ /// it will get silently rounded down to the nearest multiple of 4. Bounds checking is not
7
+ /// performed.
8
+ ///
9
+ /// # Safety
10
+ /// This function allows writing a type to an untyped buffer, then reading a different type
11
+ /// from the same buffer, allowing all sorts of safety guarantees to be bypassed (effectively a
12
+ /// transmute). Additionally, bounds checking is not performed.
5
13
#[ spirv( buffer_load_intrinsic) ]
6
14
// HACK(eddyb) try to prevent MIR inlining from breaking our intrinsics.
7
15
#[ inline( never) ]
8
16
#[ spirv_std_macros:: gpu_only]
9
- unsafe fn buffer_load_intrinsic < T > (
17
+ pub unsafe fn buffer_load_intrinsic < T > (
10
18
buffer : & [ u32 ] ,
11
19
// FIXME(eddyb) should be `usize`.
12
20
offset : u32 ,
@@ -22,11 +30,19 @@ unsafe fn buffer_load_intrinsic<T>(
22
30
. read ( )
23
31
}
24
32
33
+ /// Stores an arbitrary type int the buffer. `byte_index` must be a multiple of 4, otherwise,
34
+ /// it will get silently rounded down to the nearest multiple of 4. Bounds checking is not
35
+ /// performed.
36
+ ///
37
+ /// # Safety
38
+ /// This function allows writing a type to an untyped buffer, then reading a different type
39
+ /// from the same buffer, allowing all sorts of safety guarantees to be bypassed (effectively a
40
+ /// transmute). Additionally, bounds checking is not performed.
25
41
#[ spirv( buffer_store_intrinsic) ]
26
42
// HACK(eddyb) try to prevent MIR inlining from breaking our intrinsics.
27
43
#[ inline( never) ]
28
44
#[ spirv_std_macros:: gpu_only]
29
- unsafe fn buffer_store_intrinsic < T > (
45
+ pub unsafe fn buffer_store_intrinsic < T > (
30
46
buffer : & mut [ u32 ] ,
31
47
// FIXME(eddyb) should be `usize`.
32
48
offset : u32 ,
0 commit comments