gpu: taked slice child type in writeTexture

This commit is contained in:
Ali Chraghi 2022-05-23 11:43:11 +04:30 committed by Stephen Gutekanst
parent 6922435110
commit b5d10fb167
4 changed files with 10 additions and 7 deletions

View file

@ -518,7 +518,7 @@ const Brick = struct {
fn texture(device: gpu.Device) Texture {
const slice: []const u8 = &data();
return Texture.fromData(device, W, H, slice);
return Texture.fromData(device, W, H, u8, slice);
}
fn data() [W * H * 4]u8 {
@ -589,7 +589,7 @@ const Texture = struct {
self.sampler.release();
}
fn fromData(device: gpu.Device, width: u32, height: u32, data: anytype) Self {
fn fromData(device: gpu.Device, width: u32, height: u32, comptime T: type, data: []const T) Self {
const extent = gpu.Extent3D{
.width = width,
.height = height,
@ -631,12 +631,13 @@ const Texture = struct {
&gpu.ImageCopyTexture{
.texture = texture,
},
data,
&gpu.Texture.DataLayout{
.bytes_per_row = 4 * width,
.rows_per_image = height,
},
&extent,
T,
data,
);
const bind_group_layout = Self.bindGroupLayout(device);