gpu: make swapChainGetCurrentTextureView() return value optional

This commit is contained in:
Răzvan C. Rădulescu 2023-06-09 09:03:25 +03:00 committed by Stephen Gutekanst
parent eefe74fc06
commit b45ad53a11
5 changed files with 8 additions and 8 deletions

View file

@ -140,7 +140,7 @@ fn frame(params: FrameParams) !void {
pl.current_desc = pl.target_desc;
}
const back_buffer_view = pl.swap_chain.?.getCurrentTextureView();
const back_buffer_view = pl.swap_chain.?.getCurrentTextureView().?;
const color_attachment = gpu.RenderPassColorAttachment{
.view = back_buffer_view,
.resolve_target = null,

View file

@ -1157,8 +1157,8 @@ pub const Interface = struct {
);
}
pub inline fn swapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) *gpu.TextureView {
return @ptrCast(*gpu.TextureView, procs.swapChainGetCurrentTextureView.?(@ptrCast(c.WGPUSwapChain, swap_chain)));
pub inline fn swapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) ?*gpu.TextureView {
return @ptrCast(?*gpu.TextureView, procs.swapChainGetCurrentTextureView.?(@ptrCast(c.WGPUSwapChain, swap_chain)));
}
pub inline fn swapChainPresent(swap_chain: *gpu.SwapChain) void {

View file

@ -196,7 +196,7 @@ pub fn Interface(comptime T: type) type {
assertDecl(T, "surfaceReference", fn (surface: *gpu.Surface) callconv(.Inline) void);
assertDecl(T, "surfaceRelease", fn (surface: *gpu.Surface) callconv(.Inline) void);
assertDecl(T, "swapChainConfigure", fn (swap_chain: *gpu.SwapChain, format: gpu.Texture.Format, allowed_usage: gpu.Texture.UsageFlags, width: u32, height: u32) callconv(.Inline) void);
assertDecl(T, "swapChainGetCurrentTextureView", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) *gpu.TextureView);
assertDecl(T, "swapChainGetCurrentTextureView", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) ?*gpu.TextureView);
assertDecl(T, "swapChainPresent", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
assertDecl(T, "swapChainReference", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
assertDecl(T, "swapChainRelease", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
@ -1118,7 +1118,7 @@ pub fn Export(comptime T: type) type {
}
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
export fn wgpuSwapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) *gpu.TextureView {
export fn wgpuSwapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) ?*gpu.TextureView {
return T.swapChainGetCurrentTextureView(swap_chain);
}
@ -2342,7 +2342,7 @@ pub const StubInterface = Interface(struct {
unreachable;
}
pub inline fn swapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) *gpu.TextureView {
pub inline fn swapChainGetCurrentTextureView(swap_chain: *gpu.SwapChain) ?*gpu.TextureView {
_ = swap_chain;
unreachable;
}

View file

@ -21,7 +21,7 @@ pub const SwapChain = opaque {
Impl.swapChainConfigure(swap_chain, format, allowed_usage, width, height);
}
pub inline fn getCurrentTextureView(swap_chain: *SwapChain) *TextureView {
pub inline fn getCurrentTextureView(swap_chain: *SwapChain) ?*TextureView {
return Impl.swapChainGetCurrentTextureView(swap_chain);
}

View file

@ -117,7 +117,7 @@ pub fn update(app: *App) !bool {
std.log.err("Something went wrong when attempting to stat file: {}\n", .{err});
}
const back_buffer_view = app.core.swapChain().getCurrentTextureView();
const back_buffer_view = app.core.swapChain().getCurrentTextureView().?;
const color_attachment = gpu.RenderPassColorAttachment{
.view = back_buffer_view,
.clear_value = std.mem.zeroes(gpu.Color),