gpu: internalize ShaderModule types

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-29 23:58:52 -07:00 committed by Stephen Gutekanst
parent b0776270d3
commit 23fb836ce8
3 changed files with 20 additions and 21 deletions

View file

@ -11,7 +11,6 @@ const RenderBundleEncoder = @import("render_bundle_encoder.zig").RenderBundleEnc
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
const Sampler = @import("sampler.zig").Sampler;
const ShaderModule = @import("shader_module.zig").ShaderModule;
const ShaderModuleDescriptor = @import("shader_module.zig").ShaderModuleDescriptor;
const Surface = @import("surface.zig").Surface;
const SwapChain = @import("swap_chain.zig").SwapChain;
const SwapChainDescriptor = @import("swap_chain.zig").SwapChainDescriptor;
@ -110,7 +109,7 @@ pub const Device = opaque {
return Impl.deviceCreateSampler(device, descriptor);
}
pub inline fn createShaderModule(device: *Device, descriptor: *const ShaderModuleDescriptor) *ShaderModule {
pub inline fn createShaderModule(device: *Device, descriptor: *const ShaderModule.Descriptor) *ShaderModule {
return Impl.deviceCreateShaderModule(device, descriptor);
}

View file

@ -94,7 +94,7 @@ pub fn Interface(comptime T: type) type {
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.Sampler.Descriptor) callconv(.Inline) *gpu.Sampler);
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) callconv(.Inline) *gpu.ShaderModule);
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModule.Descriptor) 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);
assertDecl(T, "deviceDestroy", fn (device: *gpu.Device) callconv(.Inline) void);
@ -624,7 +624,7 @@ pub fn Export(comptime T: type) type {
}
// WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor);
export fn wgpuDeviceCreateShaderModule(device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) *gpu.ShaderModule {
export fn wgpuDeviceCreateShaderModule(device: *gpu.Device, descriptor: *const gpu.ShaderModule.Descriptor) *gpu.ShaderModule {
return T.deviceCreateShaderModule(device, descriptor);
}
@ -1709,7 +1709,7 @@ pub const StubInterface = Interface(struct {
unreachable;
}
pub inline fn deviceCreateShaderModule(device: *gpu.Device, descriptor: *const gpu.ShaderModuleDescriptor) *gpu.ShaderModule {
pub inline fn deviceCreateShaderModule(device: *gpu.Device, descriptor: *const gpu.ShaderModule.Descriptor) *gpu.ShaderModule {
_ = device;
_ = descriptor;
unreachable;

View file

@ -3,6 +3,22 @@ const CompilationInfoCallback = @import("callbacks.zig").CompilationInfoCallback
const Impl = @import("interface.zig").Impl;
pub const ShaderModule = opaque {
pub const Descriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
};
pub const SPIRVDescriptor = extern struct {
chain: ChainedStruct,
code_size: u32,
code: [*]const u32,
};
pub const WGSLDescriptor = extern struct {
chain: ChainedStruct,
source: [*:0]const u8,
};
pub inline fn getCompilationInfo(shader_module: *ShaderModule, callback: CompilationInfoCallback, userdata: *anyopaque) void {
Impl.shaderModuleGetCompilationInfo(shader_module, callback, userdata);
}
@ -19,19 +35,3 @@ pub const ShaderModule = opaque {
Impl.shaderModuleRelease(shader_module);
}
};
pub const ShaderModuleDescriptor = extern struct {
next_in_chain: ?*const ChainedStruct = null,
label: ?[*:0]const u8 = null,
};
pub const ShaderModuleSPIRVDescriptor = extern struct {
chain: ChainedStruct,
code_size: u32,
code: [*]const u32,
};
pub const ShaderModuleWGSLDescriptor = extern struct {
chain: ChainedStruct,
source: [*:0]const u8,
};