gpu: fix alignment issues with getMappedRange, getConstMappedRange (#223)
fixes alignment issues with getMappedRange, getConstMappedRange
Prior to this change `getMappedRange` and `getConstMappedRange` would not handle alignment to `COPY_BUFFER_ALIGNMENT` for users, and so invocation could result in an unhelpful error message:
```
thread 254201 panic: attempt to use null value
.../mach/gpu/src/NativeInstance.zig:1721:42: 0x480747
in .gpu.NativeInstance.buffer_vtable.getMappedRange (game)
return @ptrCast([*c]u8, range.?)[0..size];
^
```
To address this:
1. Ensure we always request a 4-byte aligned buffer when `createBuffer` is called.
2. Ensure we always map 4-byte aligned buffers.
Co-authored-by: d3m1gd <mach+d3m1gd@users.noreply.github.com>
This commit is contained in:
parent
c11d818c89
commit
05853da233
2 changed files with 8 additions and 4 deletions
|
|
@ -177,7 +177,9 @@ pub inline fn destroy(device: Device) void {
|
|||
}
|
||||
|
||||
pub inline fn createBuffer(device: Device, descriptor: *const Buffer.Descriptor) Buffer {
|
||||
return device.vtable.createBuffer(device.ptr, descriptor);
|
||||
var local_descriptor = descriptor.*;
|
||||
local_descriptor.size += local_descriptor.size % 4;
|
||||
return device.vtable.createBuffer(device.ptr, &local_descriptor);
|
||||
}
|
||||
|
||||
pub inline fn createCommandEncoder(device: Device, descriptor: ?*const CommandEncoder.Descriptor) CommandEncoder {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue