gpu: internalize Sampler types
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
550c5fd55e
commit
b0776270d3
4 changed files with 38 additions and 40 deletions
|
|
@ -2,7 +2,6 @@ const ChainedStruct = @import("types.zig").ChainedStruct;
|
|||
const ShaderStageFlags = @import("types.zig").ShaderStageFlags;
|
||||
const Buffer = @import("buffer.zig").Buffer;
|
||||
const Sampler = @import("sampler.zig").Sampler;
|
||||
const SamplerBindingLayout = @import("sampler.zig").SamplerBindingLayout;
|
||||
const Texture = @import("texture.zig").Texture;
|
||||
const TextureBindingLayout = @import("texture.zig").TextureBindingLayout;
|
||||
const StorageTextureBindingLayout = @import("types.zig").StorageTextureBindingLayout;
|
||||
|
|
@ -14,7 +13,7 @@ pub const BindGroupLayout = opaque {
|
|||
binding: u32,
|
||||
visibility: ShaderStageFlags,
|
||||
buffer: Buffer.BindingLayout,
|
||||
sampler: SamplerBindingLayout,
|
||||
sampler: Sampler.BindingLayout,
|
||||
texture: TextureBindingLayout,
|
||||
storage_texture: StorageTextureBindingLayout,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ const QuerySet = @import("query_set.zig").QuerySet;
|
|||
const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEncoder;
|
||||
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
|
||||
const Sampler = @import("sampler.zig").Sampler;
|
||||
const SamplerDescriptor = @import("sampler.zig").SamplerDescriptor;
|
||||
const ShaderModule = @import("shader_module.zig").ShaderModule;
|
||||
const ShaderModuleDescriptor = @import("shader_module.zig").ShaderModuleDescriptor;
|
||||
const Surface = @import("surface.zig").Surface;
|
||||
|
|
@ -107,7 +106,7 @@ pub const Device = opaque {
|
|||
Impl.deviceCreateRenderPipelineAsync(device, descriptor, callback, userdata);
|
||||
}
|
||||
|
||||
pub inline fn createSampler(device: *Device, descriptor: ?*const SamplerDescriptor) *Sampler {
|
||||
pub inline fn createSampler(device: *Device, descriptor: ?*const Sampler.Descriptor) *Sampler {
|
||||
return Impl.deviceCreateSampler(device, descriptor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ pub fn Interface(comptime T: type) type {
|
|||
assertDecl(T, "deviceCreateRenderBundleEncoder", fn (device: *gpu.Device, descriptor: *const gpu.RenderBundleEncoder.Descriptor) callconv(.Inline) *gpu.RenderBundleEncoder);
|
||||
assertDecl(T, "deviceCreateRenderPipeline", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor) callconv(.Inline) *gpu.RenderPipeline);
|
||||
assertDecl(T, "deviceCreateRenderPipelineAsync", fn (device: *gpu.Device, descriptor: *const gpu.RenderPipeline.Descriptor, callback: gpu.CreateRenderPipelineAsyncCallback, userdata: *anyopaque) callconv(.Inline) void);
|
||||
assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) callconv(.Inline) *gpu.Sampler);
|
||||
assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.Sampler.Descriptor) callconv(.Inline) *gpu.Sampler);
|
||||
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) callconv(.Inline) *gpu.ShaderModule);
|
||||
assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChainDescriptor) callconv(.Inline) *gpu.SwapChain);
|
||||
assertDecl(T, "deviceCreateTexture", fn (device: *gpu.Device, descriptor: *const gpu.TextureDescriptor) callconv(.Inline) *gpu.Texture);
|
||||
|
|
@ -619,7 +619,7 @@ pub fn Export(comptime T: type) type {
|
|||
}
|
||||
|
||||
// WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */);
|
||||
export fn wgpuDeviceCreateSampler(device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) *gpu.Sampler {
|
||||
export fn wgpuDeviceCreateSampler(device: *gpu.Device, descriptor: ?*const gpu.Sampler.Descriptor) *gpu.Sampler {
|
||||
return T.deviceCreateSampler(device, descriptor);
|
||||
}
|
||||
|
||||
|
|
@ -1703,7 +1703,7 @@ pub const StubInterface = Interface(struct {
|
|||
unreachable;
|
||||
}
|
||||
|
||||
pub inline fn deviceCreateSampler(device: *gpu.Device, descriptor: ?*const gpu.SamplerDescriptor) *gpu.Sampler {
|
||||
pub inline fn deviceCreateSampler(device: *gpu.Device, descriptor: ?*const gpu.Sampler.Descriptor) *gpu.Sampler {
|
||||
_ = device;
|
||||
_ = descriptor;
|
||||
unreachable;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,39 @@ const CompareFunction = @import("types.zig").CompareFunction;
|
|||
const Impl = @import("interface.zig").Impl;
|
||||
|
||||
pub const Sampler = opaque {
|
||||
pub const AddressMode = enum(u32) {
|
||||
repeat = 0x00000000,
|
||||
mirror_repeat = 0x00000001,
|
||||
clamp_to_edge = 0x00000002,
|
||||
};
|
||||
|
||||
pub const BindingType = enum(u32) {
|
||||
undef = 0x00000000,
|
||||
filtering = 0x00000001,
|
||||
non_filtering = 0x00000002,
|
||||
comparison = 0x00000003,
|
||||
};
|
||||
|
||||
pub const BindingLayout = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
type: BindingType = .undef,
|
||||
};
|
||||
|
||||
pub const Descriptor = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
address_mode_u: AddressMode = .clamp_to_edge,
|
||||
address_mode_v: AddressMode = .clamp_to_edge,
|
||||
address_mode_w: AddressMode = .clamp_to_edge,
|
||||
mag_filter: FilterMode = .nearest,
|
||||
min_filter: FilterMode = .nearest,
|
||||
mipmap_filter: FilterMode = .nearest,
|
||||
lod_min_clamp: f32 = 0.0,
|
||||
lod_max_clamp: f32 = 1000.0,
|
||||
compare: CompareFunction = .undef,
|
||||
max_anisotropy: u16 = 1,
|
||||
};
|
||||
|
||||
pub inline fn setLabel(sampler: *Sampler, label: [*:0]const u8) void {
|
||||
Impl.samplerSetLabel(sampler, label);
|
||||
}
|
||||
|
|
@ -16,36 +49,3 @@ pub const Sampler = opaque {
|
|||
Impl.samplerRelease(sampler);
|
||||
}
|
||||
};
|
||||
|
||||
pub const SamplerAddressMode = enum(u32) {
|
||||
repeat = 0x00000000,
|
||||
mirror_repeat = 0x00000001,
|
||||
clamp_to_edge = 0x00000002,
|
||||
};
|
||||
|
||||
pub const SamplerBindingType = enum(u32) {
|
||||
undef = 0x00000000,
|
||||
filtering = 0x00000001,
|
||||
non_filtering = 0x00000002,
|
||||
comparison = 0x00000003,
|
||||
};
|
||||
|
||||
pub const SamplerBindingLayout = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
type: SamplerBindingType = .undef,
|
||||
};
|
||||
|
||||
pub const SamplerDescriptor = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
address_mode_u: SamplerAddressMode = .clamp_to_edge,
|
||||
address_mode_v: SamplerAddressMode = .clamp_to_edge,
|
||||
address_mode_w: SamplerAddressMode = .clamp_to_edge,
|
||||
mag_filter: FilterMode = .nearest,
|
||||
min_filter: FilterMode = .nearest,
|
||||
mipmap_filter: FilterMode = .nearest,
|
||||
lod_min_clamp: f32 = 0.0,
|
||||
lod_max_clamp: f32 = 1000.0,
|
||||
compare: CompareFunction = .undef,
|
||||
max_anisotropy: u16 = 1,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue