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,
|
||||
.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 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const Texture = @import("Texture.zig");
|
||||
const TextureView = @import("TextureView.zig");
|
||||
const PresentMode = @import("enums.zig").PresentMode;
|
||||
|
||||
const SwapChain = @This();
|
||||
|
|
@ -13,9 +14,8 @@ pub const VTable = struct {
|
|||
reference: 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,
|
||||
// TODO:
|
||||
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
||||
// WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
|
||||
getCurrentTextureView: fn (ptr: *anyopaque) TextureView,
|
||||
present: fn (ptr: *anyopaque) 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);
|
||||
}
|
||||
|
||||
// TODO: remove this and/or prefix with dawn? Seems to be deprecated / not in upstream webgpu.h
|
||||
pub inline fn configure(
|
||||
swap_chain: SwapChain,
|
||||
format: Texture.Format,
|
||||
|
|
@ -36,6 +37,14 @@ pub inline fn configure(
|
|||
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 {
|
||||
label: ?[:0]const u8 = null,
|
||||
usage: Texture.Usage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue