gpu: implement Device.createTexture
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
418d379f1c
commit
85d5de1077
3 changed files with 16 additions and 2 deletions
|
|
@ -24,6 +24,7 @@ const PipelineLayout = @import("PipelineLayout.zig");
|
|||
const QuerySet = @import("QuerySet.zig");
|
||||
const RenderBundleEncoder = @import("RenderBundleEncoder.zig");
|
||||
const Sampler = @import("Sampler.zig");
|
||||
const Texture = @import("Texture.zig");
|
||||
|
||||
const Device = @This();
|
||||
|
||||
|
|
@ -59,8 +60,7 @@ pub const VTable = struct {
|
|||
createSampler: fn (ptr: *anyopaque, descriptor: *const Sampler.Descriptor) Sampler,
|
||||
createShaderModule: fn (ptr: *anyopaque, descriptor: *const ShaderModule.Descriptor) ShaderModule,
|
||||
nativeCreateSwapChain: fn (ptr: *anyopaque, surface: ?Surface, descriptor: *const SwapChain.Descriptor) SwapChain,
|
||||
// createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture,
|
||||
// WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
|
||||
createTexture: fn (ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture,
|
||||
destroy: fn (ptr: *anyopaque) void,
|
||||
// TODO: should features be exposed as static slice?
|
||||
// WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeature * features);
|
||||
|
|
@ -125,6 +125,10 @@ pub inline fn nativeCreateSwapChain(device: Device, surface: ?Surface, descripto
|
|||
return device.vtable.nativeCreateSwapChain(device.ptr, surface, descriptor);
|
||||
}
|
||||
|
||||
pub inline fn createTexture(device: Device, descriptor: *const Texture.Descriptor) Texture {
|
||||
return device.vtable.createTexture(device.ptr, descriptor);
|
||||
}
|
||||
|
||||
pub inline fn destroy(device: Device) void {
|
||||
device.vtable.destroy(device.ptr);
|
||||
}
|
||||
|
|
@ -210,6 +214,7 @@ test {
|
|||
_ = createSampler;
|
||||
_ = createShaderModule;
|
||||
_ = nativeCreateSwapChain;
|
||||
_ = createTexture;
|
||||
_ = destroy;
|
||||
_ = createBuffer;
|
||||
_ = createCommandEncoder;
|
||||
|
|
|
|||
|
|
@ -444,6 +444,14 @@ const device_vtable = Device.VTable{
|
|||
));
|
||||
}
|
||||
}).nativeCreateSwapChain,
|
||||
.createTexture = (struct {
|
||||
pub fn createTexture(ptr: *anyopaque, descriptor: *const Texture.Descriptor) Texture {
|
||||
return wrapTexture(c.wgpuDeviceCreateTexture(
|
||||
@ptrCast(c.WGPUDevice, ptr),
|
||||
@ptrCast(*const c.WGPUTextureDescriptor, descriptor),
|
||||
));
|
||||
}
|
||||
}).createTexture,
|
||||
.destroy = (struct {
|
||||
pub fn destroy(ptr: *anyopaque) void {
|
||||
c.wgpuDeviceDestroy(@ptrCast(c.WGPUDevice, ptr));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub inline fn createView(texture: Texture, descriptor: *const TextureView.Descri
|
|||
}
|
||||
|
||||
pub const Descriptor = struct {
|
||||
reserved: ?*anyopaque = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
usage: Usage,
|
||||
dimension: Dimension,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue