gpu: implement Texture.createView
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9fae887555
commit
856c98c4c1
2 changed files with 24 additions and 2 deletions
|
|
@ -786,6 +786,25 @@ const texture_vtable = Texture.VTable{
|
|||
c.wgpuTextureDestroy(@ptrCast(c.WGPUTexture, ptr));
|
||||
}
|
||||
}).destroy,
|
||||
.createView = (struct {
|
||||
pub fn createView(ptr: *anyopaque, descriptor: *const TextureView.Descriptor) TextureView {
|
||||
const desc = c.WGPUTextureViewDescriptor{
|
||||
.nextInChain = null,
|
||||
.label = if (descriptor.label) |l| l else "",
|
||||
.format = @enumToInt(descriptor.format),
|
||||
.dimension = @enumToInt(descriptor.dimension),
|
||||
.baseMipLevel = descriptor.base_mip_level,
|
||||
.mipLevelCount = descriptor.mip_level_count,
|
||||
.baseArrayLayer = descriptor.base_array_layer,
|
||||
.arrayLayerCount = descriptor.array_layer_count,
|
||||
.aspect = @enumToInt(descriptor.aspect),
|
||||
};
|
||||
return wrapTextureView(c.wgpuTextureCreateView(
|
||||
@ptrCast(c.WGPUTexture, ptr),
|
||||
&desc,
|
||||
));
|
||||
}
|
||||
}).createView,
|
||||
};
|
||||
|
||||
fn wrapSampler(sampler: c.WGPUSampler) Sampler {
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ vtable: *const VTable,
|
|||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor);
|
||||
destroy: fn (ptr: *anyopaque) void,
|
||||
setLabel: fn (ptr: *anyopaque, label: [:0]const u8) void,
|
||||
createView: fn (ptr: *anyopaque, descriptor: *const TextureView.Descriptor) TextureView,
|
||||
};
|
||||
|
||||
pub inline fn reference(texture: Texture) void {
|
||||
|
|
@ -34,6 +33,10 @@ pub inline fn destroy(texture: Texture) void {
|
|||
texture.vtable.destroy(texture.ptr);
|
||||
}
|
||||
|
||||
pub inline fn createView(texture: Texture, descriptor: *const TextureView.Descriptor) TextureView {
|
||||
return texture.vtable.createView(texture.ptr, descriptor);
|
||||
}
|
||||
|
||||
pub const Descriptor = struct {
|
||||
label: ?[*:0]const u8 = null,
|
||||
usage: Usage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue