mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
6a4e26ef2a
Defining MEM_DEBUG in mem.h will add a size field to Alloc and enable bounds and alignment checks for every memory read and write. Notes: - Deriving an Alloc from Path.tiles is unsound, but it's more trouble to convert Path.tiles from TileRef to a variable sized Alloc. - elements.comp note that "We should be able to use an array of structs but the NV shader compiler doesn't seem to like it". If that's still relevant, does the shared arrays of Allocs work? Signed-off-by: Elias Naur <mail@eliasnaur.com>
32 lines
690 B
C
32 lines
690 B
C
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
|
|
|
|
// Code auto-generated by piet-gpu-derive
|
|
|
|
struct BinInstanceRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct BinInstance {
|
|
uint element_ix;
|
|
};
|
|
|
|
#define BinInstance_size 4
|
|
|
|
BinInstanceRef BinInstance_index(BinInstanceRef ref, uint index) {
|
|
return BinInstanceRef(ref.offset + index * BinInstance_size);
|
|
}
|
|
|
|
BinInstance BinInstance_read(Alloc a, BinInstanceRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = read_mem(a, ix + 0);
|
|
BinInstance s;
|
|
s.element_ix = raw0;
|
|
return s;
|
|
}
|
|
|
|
void BinInstance_write(Alloc a, BinInstanceRef ref, BinInstance s) {
|
|
uint ix = ref.offset >> 2;
|
|
write_mem(a, ix + 0, s.element_ix);
|
|
}
|
|
|