gpu: implement SwapChain.present, SwapChain.getCurrentTextureView
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
cc40004a5f
commit
ef3eed7afb
2 changed files with 22 additions and 3 deletions
|
|
@ -587,6 +587,16 @@ const swap_chain_vtable = SwapChain.VTable{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}).configure,
|
}).configure,
|
||||||
|
.getCurrentTextureView = (struct {
|
||||||
|
pub fn getCurrentTextureView(ptr: *anyopaque) TextureView {
|
||||||
|
return wrapTextureView(c.wgpuSwapChainGetCurrentTextureView(@ptrCast(c.WGPUSwapChain, ptr)));
|
||||||
|
}
|
||||||
|
}).getCurrentTextureView,
|
||||||
|
.present = (struct {
|
||||||
|
pub fn present(ptr: *anyopaque) void {
|
||||||
|
c.wgpuSwapChainPresent(@ptrCast(c.WGPUSwapChain, ptr));
|
||||||
|
}
|
||||||
|
}).present,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn wrapTextureView(texture_view: c.WGPUTextureView) TextureView {
|
fn wrapTextureView(texture_view: c.WGPUTextureView) TextureView {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Texture = @import("Texture.zig");
|
const Texture = @import("Texture.zig");
|
||||||
|
const TextureView = @import("TextureView.zig");
|
||||||
const PresentMode = @import("enums.zig").PresentMode;
|
const PresentMode = @import("enums.zig").PresentMode;
|
||||||
|
|
||||||
const SwapChain = @This();
|
const SwapChain = @This();
|
||||||
|
|
@ -13,9 +14,8 @@ pub const VTable = struct {
|
||||||
reference: fn (ptr: *anyopaque) void,
|
reference: fn (ptr: *anyopaque) void,
|
||||||
release: fn (ptr: *anyopaque) void,
|
release: fn (ptr: *anyopaque) void,
|
||||||
configure: fn (ptr: *anyopaque, format: Texture.Format, allowed_usage: Texture.Usage, width: u32, height: u32) void,
|
configure: fn (ptr: *anyopaque, format: Texture.Format, allowed_usage: Texture.Usage, width: u32, height: u32) void,
|
||||||
// TODO:
|
getCurrentTextureView: fn (ptr: *anyopaque) TextureView,
|
||||||
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
present: fn (ptr: *anyopaque) void,
|
||||||
// WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn reference(swap_chain: SwapChain) void {
|
pub inline fn reference(swap_chain: SwapChain) void {
|
||||||
|
|
@ -26,6 +26,7 @@ pub inline fn release(swap_chain: SwapChain) void {
|
||||||
swap_chain.vtable.release(swap_chain.ptr);
|
swap_chain.vtable.release(swap_chain.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this and/or prefix with dawn? Seems to be deprecated / not in upstream webgpu.h
|
||||||
pub inline fn configure(
|
pub inline fn configure(
|
||||||
swap_chain: SwapChain,
|
swap_chain: SwapChain,
|
||||||
format: Texture.Format,
|
format: Texture.Format,
|
||||||
|
|
@ -36,6 +37,14 @@ pub inline fn configure(
|
||||||
swap_chain.vtable.configure(swap_chain.ptr, format, allowed_usage, width, height);
|
swap_chain.vtable.configure(swap_chain.ptr, format, allowed_usage, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn getCurrentTextureView(swap_chain: SwapChain) TextureView {
|
||||||
|
return swap_chain.vtable.getCurrentTextureView(swap_chain.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn present(swap_chain: SwapChain) void {
|
||||||
|
swap_chain.vtable.present(swap_chain.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
pub const Descriptor = struct {
|
pub const Descriptor = struct {
|
||||||
label: ?[:0]const u8 = null,
|
label: ?[:0]const u8 = null,
|
||||||
usage: Texture.Usage,
|
usage: Texture.Usage,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue