gpu: implement Device.createSampler
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
def801d8a1
commit
418d379f1c
3 changed files with 17 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ const ExternalTexture = @import("ExternalTexture.zig");
|
|||
const PipelineLayout = @import("PipelineLayout.zig");
|
||||
const QuerySet = @import("QuerySet.zig");
|
||||
const RenderBundleEncoder = @import("RenderBundleEncoder.zig");
|
||||
const Sampler = @import("Sampler.zig");
|
||||
|
||||
const Device = @This();
|
||||
|
||||
|
|
@ -55,8 +56,7 @@ pub const VTable = struct {
|
|||
descriptor: *const RenderPipeline.Descriptor,
|
||||
callback: *RenderPipeline.CreateCallback,
|
||||
) void,
|
||||
// createSampler: fn (ptr: *anyopaque, descriptor: *const Sampler.Descriptor) Sampler,
|
||||
// WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor);
|
||||
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,
|
||||
|
|
@ -113,6 +113,10 @@ pub inline fn createBindGroupLayout(device: Device, descriptor: *const BindGroup
|
|||
return device.vtable.createBindGroupLayout(device.ptr, descriptor);
|
||||
}
|
||||
|
||||
pub inline fn createSampler(device: Device, descriptor: *const Sampler.Descriptor) Sampler {
|
||||
return device.vtable.createSampler(device.ptr, descriptor);
|
||||
}
|
||||
|
||||
pub inline fn createShaderModule(device: Device, descriptor: *const ShaderModule.Descriptor) ShaderModule {
|
||||
return device.vtable.createShaderModule(device.ptr, descriptor);
|
||||
}
|
||||
|
|
@ -203,6 +207,7 @@ test {
|
|||
_ = injectError;
|
||||
_ = createBindGroup;
|
||||
_ = createBindGroupLayout;
|
||||
_ = createSampler;
|
||||
_ = createShaderModule;
|
||||
_ = nativeCreateSwapChain;
|
||||
_ = destroy;
|
||||
|
|
|
|||
|
|
@ -382,6 +382,14 @@ const device_vtable = Device.VTable{
|
|||
return wrapBindGroupLayout(c.wgpuDeviceCreateBindGroupLayout(@ptrCast(c.WGPUDevice, ptr), &desc));
|
||||
}
|
||||
}).createBindGroupLayout,
|
||||
.createSampler = (struct {
|
||||
pub fn createSampler(ptr: *anyopaque, descriptor: *const Sampler.Descriptor) Sampler {
|
||||
return wrapSampler(c.wgpuDeviceCreateSampler(
|
||||
@ptrCast(c.WGPUDevice, ptr),
|
||||
@ptrCast(*const c.WGPUSamplerDescriptor, descriptor),
|
||||
));
|
||||
}
|
||||
}).createSampler,
|
||||
.createShaderModule = (struct {
|
||||
pub fn createShaderModule(ptr: *anyopaque, descriptor: *const ShaderModule.Descriptor) ShaderModule {
|
||||
switch (descriptor.code) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ pub const BindingLayout = extern struct {
|
|||
type: BindingType,
|
||||
};
|
||||
|
||||
pub const Descriptor = struct {
|
||||
pub const Descriptor = extern struct {
|
||||
reserved: ?*anyopaque = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
address_mode_u: AddressMode,
|
||||
address_mode_v: AddressMode,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue