diff --git a/src/GLSL_std_450/opcodes.zig b/src/GLSL_std_450/opcodes.zig index 846803f..098f327 100644 --- a/src/GLSL_std_450/opcodes.zig +++ b/src/GLSL_std_450/opcodes.zig @@ -298,7 +298,7 @@ fn MathEngine(comptime T: PrimitiveType, comptime Op: MathOp) type { .Atanh => if (TT == f16) RuntimeError.UnsupportedSpirV else std.math.atanh(x), .Ceil => @ceil(x), .Cos => @cos(x), - .Cosh => if (TT == f16) RuntimeError.UnsupportedSpirV else std.math.cosh(x), + .Cosh => if (TT == f16) RuntimeError.UnsupportedSpirV else (@exp(x) + @exp(-x)) / 2, // std.math.cosh is not precise enough for Vulkan CTS .Degrees => std.math.radiansToDegrees(x), .Exp => @exp(x), .Exp2 => @exp2(x), @@ -313,7 +313,7 @@ fn MathEngine(comptime T: PrimitiveType, comptime Op: MathOp) type { .Round => @round(x), .RoundEven => roundEven(TT, x), .Sin => @sin(x), - .Sinh => if (TT == f16) RuntimeError.UnsupportedSpirV else std.math.sinh(x), + .Sinh => if (TT == f16) RuntimeError.UnsupportedSpirV else (@exp(x) - @exp(-x)) / 2, // std.math.sinh is not precise enough for Vulkan CTS .Sqrt => @sqrt(x), .Tan => @tan(x), .Tanh => if (TT == f16) RuntimeError.UnsupportedSpirV else std.math.tanh(x), diff --git a/src/Result.zig b/src/Result.zig index 32c5b5e..88affe9 100644 --- a/src/Result.zig +++ b/src/Result.zig @@ -474,13 +474,7 @@ pub fn getMemberCounts(self: *const Self) usize { return 0; } -pub fn flushPtr(self: *Self, allocator: std.mem.Allocator) RuntimeError!void { - if (self.variant) |*variant| { - switch (variant.*) { - .Constant => |*c| try c.value.flushPtr(allocator), - .Variable => |*v| try v.value.flushPtr(allocator), - .AccessChain => |*a| try a.value.flushPtr(allocator), - else => {}, - } - } +pub inline fn flushPtr(self: *Self, allocator: std.mem.Allocator) RuntimeError!void { + const value = self.getValue() catch return; + try value.flushPtr(allocator); }