From 0b63ea0ed0ac7c9ac302c45685b5081ac0ca10fe Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 8 Mar 2022 23:45:47 -0700 Subject: [PATCH] gpu: add SwapChain.Descriptor.equal ity Signed-off-by: Stephen Gutekanst --- gpu/src/SwapChain.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gpu/src/SwapChain.zig b/gpu/src/SwapChain.zig index d1e27095..576fe3dc 100644 --- a/gpu/src/SwapChain.zig +++ b/gpu/src/SwapChain.zig @@ -1,3 +1,4 @@ +const std = @import("std"); const TextureUsage = @import("texture_usage.zig").TextureUsage; const TextureFormat = @import("texture_format.zig").TextureFormat; const PresentMode = @import("present_mode.zig").PresentMode; @@ -34,6 +35,18 @@ pub const Descriptor = struct { height: u32, present_mode: PresentMode, implementation: u64, + + pub fn equal(a: *const Descriptor, b: *const Descriptor) bool { + if ((a.label == null) != (b.label == null)) return false; + if (a.label != null and !std.mem.eql(u8, a.label.?, b.label.?)) return false; + if (a.usage != b.usage) return false; + if (a.format != b.format) return false; + if (a.width != b.width) return false; + if (a.height != b.height) return false; + if (a.present_mode != b.present_mode) return false; + if (a.implementation != b.implementation) return false; + return true; + } }; test "syntax" {