code
stringlengths 38
801k
| repo_path
stringlengths 6
263
|
---|---|
/// 128 bytes:
/// A 64-byte Account will not improve performance significantly, and drops too much functionality.
/// Reduces cognitive complexity by reducing the number of fields from 15 fields to 11 fields.
/// Enables referencing at least two third-party UUIDs, e.g. for tuple accounts: A Payable To B.
/// Enables referencing external entities, where multiple accounts reference the same entity.
pub const Account = extern struct {
id: u128,
user_data: u128, // Opaque, e.g. a third-party identifier to link this account (many-to-one) to an external entity.
reserved: [48]u8,
unit: u16, // This used to be 32-bits which was overkill, we've borrowed 16-bits from this to make space for a chart of accounts `code`.
code: u16, // A chart of accounts code describing the type of the account (e.g. liquidity account, settlement account, payable account etc.).
flags: u32,
debits_reserved: u64,
debits_accepted: u64,
credits_reserved: u64,
credits_accepted: u64,
timestamp: u64 = 0,
};
/// 128 bytes:
/// Reduces the number of fields from 10 fields to 9 fields.
/// No loss of any accounting policy features.
///
///
/// Adds a `code`, essential for the classic journal entry tuple (date, description, amount):
/// We would have done this with a flag and a `user_data` slot, but this way we avoid polymorphism.
///
/// We swap transfers to being auto-commit by default, so two-phase commit transfers are explicit.
pub const Transfer = extern struct {
id: u128,
debit_account_id: u128,
credit_account_id: u128,
user_data: u128, // Opaque, e.g. a third-party identifier to link this transfer (many-to-one) to an external entity.
reserved: [32]u8, // Reserved for TigerBeetle accounting primitives.
code: u32, // A chart of accounts code describing the type of the transfer (e.g. deposit, settlement etc.).
flags: u32,
amount: u64,
timeout: u64,
timestamp: u64 = 0,
};
/// 64 bytes
/// Saves 16 bytes compared to 80 byte struct we had before.
/// Reduces the number of fields from 6 fields to 5 fields.
pub const Commit = extern struct {
id: u128,
reserved: [32]u8, // Reserved for TigerBeetle accounting primitives.
code: u32, // A chart of accounts code describing the reason for the commit accept/reject.
flags: u32,
timestamp: u64 = 0,
};
test "sizeOf" {
const std = @import("std");
const assert = std.debug.assert;
std.debug.print("\n", .{});
std.debug.print("sizeOf(Account)={}\n", .{@sizeOf(Account)});
std.debug.print("sizeOf(Transfer)={}\n", .{@sizeOf(Transfer)});
std.debug.print("sizeOf(Commit)={}\n", .{@sizeOf(Commit)});
assert(@sizeOf(Account) == 128);
assert(@sizeOf(Transfer) == 128);
assert(@sizeOf(Commit) == 64);
} | docs/types_balanced.zig |
const std = @import("std");
const fs = std.fs;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const input = try fs.cwd().readFileAlloc(allocator, "data/input_06_1.txt", std.math.maxInt(usize));
{ // Solution 1
var lines = std.mem.tokenize(input, "\n");
var accum: i32 = 0;
var has_lines = true;
while (has_lines) {
var group_accum: i32 = 0;
var bitmap: u32 = 0;
while (true) {
const line_opt = lines.next();
if (line_opt == null) {
has_lines = false;
break;
}
const line = std.mem.trim(u8, line_opt.?, " \n\r");
if (line.len == 0)
break;
for (line) |c| {
const index = @intCast(u5, c - 'a');
const mask: u32 = @as(u32, 1) << index;
if ((bitmap & mask) == 0) {
group_accum += 1;
bitmap |= mask;
}
}
}
accum += group_accum;
}
std.debug.print("Day 06 - Solution 1: {}\n", .{accum});
}
{ // Solution 2
var lines = std.mem.tokenize(input, "\n");
var accum: i32 = 0;
var has_lines = true;
while (has_lines) {
var group_len: u8 = 0;
var answers = [_]u8{0} ** 26;
while (true) {
const line_opt = lines.next();
if (line_opt == null) {
has_lines = false;
break;
}
const line = std.mem.trim(u8, line_opt.?, " \n\r");
if (line.len == 0)
break;
group_len += 1;
for (line) |c| {
const index = @intCast(usize, c - 'a');
answers[index] += 1;
}
}
for (answers) |a| {
if (a == group_len) {
accum += 1;
}
}
}
std.debug.print("Day 06 - Solution : {}\n", .{accum});
}
} | 2020/src/day_06.zig |
const std = @import("std");
const painterz = @import("painterz");
/// This is the TVG magic number which recognizes the icon format.
/// Magic numbers might seem unnecessary, but they will be the first
/// guard in line against bad input and prevent unnecessary cycles
/// to detect those.
pub const magic_number = [2]u8{ 0x72, 0x56 };
/// This is the latest TVG version supported by this library.
pub const current_version = 1;
// submodules
/// A generic module that provides functions for assembling TVG graphics at comptime or
/// runtime.
pub const builder = @import("builder.zig").create;
/// Module that provides a generic purpose TVG parser. This parser exports all data as
/// pre-scaled `f32` values.
pub const parsing = @import("parsing.zig");
/// A TVG software renderer based on the parsing module. Takes a parser stream as input.
pub const rendering = @import("rendering.zig");
/// Contains common TVG constants
pub const format = @import("format.zig");
/// Returns a stream of TVG commands as well as the document header.
/// - `allocator` is used to allocate temporary data like the current set of vertices for *FillPolygon*. This can be a fixed-buffer allocator.
/// - `reader` is a generic stream that provides the TVG byte data.
pub fn parse(allocator: *std.mem.Allocator, reader: anytype) !parsing.Parser(@TypeOf(reader)) {
return try parsing.Parser(@TypeOf(reader)).init(allocator, reader);
}
pub fn renderStream(
/// Allocator for temporary allocations
allocator: *std.mem.Allocator,
/// A struct that exports a single function `setPixel(x: isize, y: isize, color: [4]u8) void` as well as two fields width and height
framebuffer: anytype,
/// The icon data
reader: anytype,
) !void {
var parser = try parse(allocator, reader);
defer parser.deinit();
while (try parser.next()) |cmd| {
try rendering.render(
framebuffer,
parser.header,
parser.color_table,
cmd,
);
}
}
pub fn render(
/// Allocator for temporary allocations
allocator: *std.mem.Allocator,
/// A struct that exports a single function `setPixel(x: isize, y: isize, color: [4]u8) void` as well as two fields width and height
framebuffer: anytype,
/// The icon data
icon: []const u8,
) !void {
var stream = std.io.fixedBufferStream(icon);
return try renderStream(allocator, framebuffer, stream.reader());
}
comptime {
if (std.builtin.is_test) {
_ = @import("builder.zig"); // import file for tests
_ = parsing;
_ = rendering;
}
}
/// A TVG scale value. Defines the scale for all units inside a graphic.
/// The scale is defined by the number of decimal bits in a `i16`, thus scaling
/// can be trivially implemented by shifting the integers right by the scale bits.
pub const Scale = enum(u4) {
const Self = @This();
@"1/1" = 0,
@"1/2" = 1,
@"1/4" = 2,
@"1/8" = 3,
@"1/16" = 4,
@"1/32" = 5,
@"1/64" = 6,
@"1/128" = 7,
@"1/256" = 8,
pub fn map(self: Self, value: f32) Unit {
return Unit.init(self, value);
}
pub fn getShiftBits(self: Self) u4 {
return @enumToInt(self);
}
pub fn getScaleFactor(self: Self) u15 {
return @as(u15, 1) << self.getShiftBits();
}
};
/// A scalable fixed-point number.
pub const Unit = enum(i16) {
const Self = @This();
_,
pub fn init(scale: Scale, value: f32) Self {
return @intToEnum(Self, @floatToInt(i16, value * @intToFloat(f32, scale.getScaleFactor()) + 0.5));
}
pub fn raw(self: Self) i16 {
return @enumToInt(self);
}
pub fn toFloat(self: Self, scale: Scale) f32 {
return @intToFloat(f32, @enumToInt(self)) / @intToFloat(f32, scale.getScaleFactor());
}
pub fn toInt(self: Self, scale: Scale) i16 {
const factor = scale.getScaleFactor();
return @divFloor(@enumToInt(self) + (@divExact(factor, 2)), factor);
}
pub fn toUnsignedInt(self: Self, scale: Scale) !u15 {
const i = toInt(self, scale);
if (i < 0)
return error.InvalidData;
return @intCast(u15, i);
}
};
pub const Color = extern struct {
const Self = @This();
r: u8,
g: u8,
b: u8,
a: u8,
pub fn toArray(self: Self) [4]u8 {
return [4]u8{
self.r,
self.g,
self.b,
self.a,
};
}
pub fn lerp(lhs: Self, rhs: Self, factor: f32) Self {
const l = struct {
fn l(a: u8, b: u8, c: f32) u8 {
return @floatToInt(u8, @intToFloat(f32, a) + (@intToFloat(b) - @intToFloat(a)) * std.math.clamp(c, 0, 1));
}
}.l;
return Self{
.r = l(lhs.r, rhs.r, factor),
.g = l(lhs.g, rhs.g, factor),
.b = l(lhs.b, rhs.b, factor),
.a = l(lhs.a, rhs.a, factor),
};
}
pub fn fromString(str: []const u8) !Self {
return switch (str.len) {
6 => Self{
.r = try std.fmt.parseInt(u8, str[0..2], 16),
.g = try std.fmt.parseInt(u8, str[2..4], 16),
.b = try std.fmt.parseInt(u8, str[4..6], 16),
.a = 0xFF,
},
else => error.InvalidFormat,
};
}
};
pub const Point = struct {
x: f32,
y: f32,
};
pub const Rectangle = struct {
x: f32,
y: f32,
width: f32,
height: f32,
};
pub const Line = struct {
start: Point,
end: Point,
};
// brainstorming
// path nodes (u3)
// line x,y
// horiz x
// vert y
// bezier c0x,c0y,c1x,c1y,x,y
// arc_circ r,x,y
// arc_ellipse rx,ry,x,y
// close
// flags:
// [ ] has line width (prepend)
// primitive types (both fill and outline)
// - rectangle
// - circle
// - circle sector
// - polygon
// - path
// primitive types (other)
// - line strip
// - lines | src/lib/tvg.zig |
const concepts = @import("../../lib.zig").concepts;
/// A data format that can deserialize any data type supported by Getty.
///
/// This interface is generic over the following:
///
/// - An `E` type representing the error set in the return type of
/// all of `Deserializer`'s required methods.
///
/// Data model:
///
/// - bool
/// - enum
/// - float
/// - int
/// - map
/// - optional
/// - sequence
/// - string
/// - struct
/// - void
pub fn Deserializer(
comptime Context: type,
comptime Error: type,
comptime deserializeBool: Fn(Context, Error),
comptime deserializeEnum: Fn(Context, Error),
comptime deserializeFloat: Fn(Context, Error),
comptime deserializeInt: Fn(Context, Error),
comptime deserializeMap: Fn(Context, Error),
comptime deserializeOptional: Fn(Context, Error),
comptime deserializeSequence: Fn(Context, Error),
comptime deserializeString: Fn(Context, Error),
comptime deserializeStruct: Fn(Context, Error),
comptime deserializeVoid: Fn(Context, Error),
) type {
return struct {
pub const @"getty.Deserializer" = struct {
context: Context,
const Self = @This();
pub const Error = Error;
pub fn deserializeBool(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeBool(self.context, visitor);
}
pub fn deserializeEnum(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeEnum(self.context, visitor);
}
pub fn deserializeFloat(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeFloat(self.context, visitor);
}
pub fn deserializeInt(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeInt(self.context, visitor);
}
pub fn deserializeMap(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeMap(self.context, visitor);
}
pub fn deserializeOptional(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeOptional(self.context, visitor);
}
pub fn deserializeSequence(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeSequence(self.context, visitor);
}
pub fn deserializeString(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeString(self.context, visitor);
}
pub fn deserializeStruct(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeStruct(self.context, visitor);
}
pub fn deserializeVoid(self: Self, visitor: anytype) Return(@TypeOf(visitor)) {
return try deserializeVoid(self.context, visitor);
}
};
pub fn deserializer(self: Context) @"getty.Deserializer" {
return .{ .context = self };
}
fn Return(comptime Visitor: type) type {
comptime concepts.@"getty.de.Visitor"(Visitor);
return Error!Visitor.Value;
}
};
}
fn Fn(comptime Context: type, comptime Error: type) type {
const S = struct {
fn f(_: Context, visitor: anytype) Error!@TypeOf(visitor).Value {
unreachable;
}
};
return @TypeOf(S.f);
} | src/de/interface/deserializer.zig |
const std = @import("std");
const hzzp = @import("hzzp");
fn read_timer() u64 {
return asm volatile (
\\rdtsc
\\shlq $32, %%rdx
\\orq %%rdx, %%rax
: [ret] "={rax}" (-> u64),
:
: "rax", "rdx"
);
}
const tests = .{
"response1.http",
"response2.http",
"response3.http",
};
const BenchmarkTime = struct {
lowest: u64 = std.math.maxInt(u64),
highest: u64 = std.math.minInt(u64),
total: u64 = 0,
count: usize = 0,
bytes: usize = 0,
fn add(self: *BenchmarkTime, time: u64, bytes: usize) void {
if (time > self.highest) {
self.highest = time;
}
if (time < self.lowest) {
self.lowest = time;
}
self.total += time;
self.count += 1;
// this shouldn't change, but we take it from the first response
self.bytes = bytes;
}
fn average(self: BenchmarkTime) f64 {
return @intToFloat(f64, self.total) / @intToFloat(f64, self.count);
}
pub fn format(self: BenchmarkTime, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
try writer.print("Lo-Hi {d: >6} -> {d: <6} | Avg {d: <9.3} | {d:.6} B/C | {d} entries", .{
self.lowest,
self.highest,
self.average(),
@intToFloat(f64, self.bytes) / self.average(),
self.count,
});
}
};
const Benchmark = struct {
initialization: BenchmarkTime,
status_line: BenchmarkTime,
headers: BenchmarkTime,
payload: BenchmarkTime,
};
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = &gpa.allocator;
inline for (tests) |name| {
const response_content = try std.fs.cwd().readFileAlloc(allocator, name, 2048);
defer allocator.free(response_content);
var initialization = BenchmarkTime{};
var status_line = BenchmarkTime{};
var headers = BenchmarkTime{};
var payload = BenchmarkTime{};
var other = BenchmarkTime{};
var trial: u32 = 0;
while (trial < 1_000_000) : (trial += 1) {
var response = std.io.fixedBufferStream(response_content);
const reader = response.reader();
var start: u64 = undefined;
var stop: u64 = undefined;
var pos_start: usize = undefined;
var pos_stop: usize = undefined;
start = read_timer();
var buffer: [256]u8 = undefined;
var client = hzzp.base.client.create(&buffer, reader, std.io.null_writer);
stop = read_timer();
initialization.add(stop - start, 0);
pos_start = response.pos;
start = read_timer();
while (try client.next()) |event| {
stop = read_timer();
pos_stop = response.pos;
switch (event) {
.status => status_line.add(stop - start, pos_stop - pos_start),
.header => headers.add(stop - start, pos_stop - pos_start),
.payload => payload.add(stop - start, pos_stop - pos_start),
else => other.add(stop - start, pos_stop - pos_start),
}
pos_start = response.pos;
start = read_timer();
}
}
std.debug.print("Test {s}\n", .{name});
std.debug.print("Initialization: {d}\n", .{initialization});
std.debug.print("Status Line: {d}\n", .{status_line});
std.debug.print("Headers: {d}\n", .{headers});
std.debug.print("Payload: {d}\n", .{payload});
std.debug.print("Other: {d}\n", .{other});
}
}
// zig run benchmark.zig --pkg-begin hzzp ../src/main.zig --pkg-end | .gyro/hzzp-truemedian-github.com-91ab8e74/pkg/test/benchmark.zig |
const std = @import("std");
const zig_builtin = @import("builtin");
const build_options = @import("build_options");
const Config = @import("./Config.zig");
const DocumentStore = @import("./DocumentStore.zig");
const readRequestHeader = @import("./header.zig").readRequestHeader;
const requests = @import("./requests.zig");
const types = @import("./types.zig");
const analysis = @import("./analysis.zig");
const ast = @import("./ast.zig");
const references = @import("./references.zig");
const rename = @import("./rename.zig");
const offsets = @import("./offsets.zig");
const setup = @import("./setup.zig");
const semantic_tokens = @import("./semantic_tokens.zig");
const shared = @import("./shared.zig");
const Ast = std.zig.Ast;
const known_folders = @import("known-folders");
const data = switch (build_options.data_version) {
.master => @import("data/master.zig"),
.@"0.7.0" => @import("data/0.7.0.zig"),
.@"0.7.1" => @import("data/0.7.1.zig"),
.@"0.8.0" => @import("data/0.8.0.zig"),
.@"0.8.1" => @import("data/0.8.1.zig"),
.@"0.9.0" => @import("data/0.9.0.zig"),
};
const logger = std.log.scoped(.main);
// Always set this to debug to make std.log call into our handler, then control the runtime
// value in the definition below.
pub const log_level = .debug;
var actual_log_level: std.log.Level = switch (zig_builtin.mode) {
.Debug => .debug,
else => @intToEnum(std.log.Level, @enumToInt(build_options.log_level)), //temporary fix to build failing on release-safe due to a Zig bug
};
pub fn log(comptime message_level: std.log.Level, comptime scope: @Type(.EnumLiteral), comptime format: []const u8, args: anytype) void {
if (@enumToInt(message_level) > @enumToInt(actual_log_level)) {
return;
}
// After shutdown, pipe output to stderr
if (!keep_running) {
std.debug.print("[{s}-{s}] " ++ format ++ "\n", .{ @tagName(message_level), @tagName(scope) } ++ args);
return;
}
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
var message = std.fmt.allocPrint(arena.allocator(), "[{s}-{s}] " ++ format, .{ @tagName(message_level), @tagName(scope) } ++ args) catch {
std.debug.print("Failed to allocPrint message.\n", .{});
return;
};
const message_type: types.MessageType = switch (message_level) {
.debug => .Log,
.info => .Info,
.warn => .Warning,
.err => .Error,
};
send(&arena, types.Notification{
.method = "window/logMessage",
.params = types.Notification.Params{
.LogMessage = .{
.type = message_type,
.message = message,
},
},
}) catch |err| {
std.debug.print("Failed to send show message notification (error: {}).\n", .{err});
};
}
// Code is largely based off of https://github.com/andersfr/zig-lsp/blob/master/server.zig
var stdout: std.io.BufferedWriter(4096, std.fs.File.Writer) = undefined;
var allocator: std.mem.Allocator = undefined;
var document_store: DocumentStore = undefined;
const ClientCapabilities = struct {
supports_snippets: bool = false,
supports_semantic_tokens: bool = false,
hover_supports_md: bool = false,
completion_doc_supports_md: bool = false,
};
var client_capabilities = ClientCapabilities{};
var offset_encoding = offsets.Encoding.utf16;
const not_implemented_response =
\\,"error":{"code":-32601,"message":"NotImplemented"}}
;
const null_result_response =
\\,"result":null}
;
const empty_result_response =
\\,"result":{}}
;
const empty_array_response =
\\,"result":[]}
;
const edit_not_applied_response =
\\,"result":{"applied":false,"failureReason":"feature not implemented"}}
;
const no_completions_response =
\\,"result":{"isIncomplete":false,"items":[]}}
;
const no_signatures_response =
\\,"result":{"signatures":[]}}
;
const no_semantic_tokens_response =
\\,"result":{"data":[]}}
;
/// Sends a request or response
fn send(arena: *std.heap.ArenaAllocator, reqOrRes: anytype) !void {
var arr = std.ArrayList(u8).init(arena.allocator());
try std.json.stringify(reqOrRes, .{}, arr.writer());
const stdout_stream = stdout.writer();
try stdout_stream.print("Content-Length: {}\r\n\r\n", .{arr.items.len});
try stdout_stream.writeAll(arr.items);
try stdout.flush();
}
fn truncateCompletions(list: []types.CompletionItem, max_detail_length: usize) void {
for (list) |*item| {
if (item.detail) |det| {
if (det.len > max_detail_length) {
item.detail = det[0..max_detail_length];
}
}
}
}
fn respondGeneric(id: types.RequestId, response: []const u8) !void {
const id_len = switch (id) {
.Integer => |id_val| blk: {
if (id_val == 0) break :blk 1;
var digits: usize = 1;
var value = @divTrunc(id_val, 10);
while (value != 0) : (value = @divTrunc(value, 10)) {
digits += 1;
}
break :blk digits;
},
.String => |str_val| str_val.len + 2,
else => unreachable,
};
// Numbers of character that will be printed from this string: len - 1 brackets
const json_fmt = "{{\"jsonrpc\":\"2.0\",\"id\":";
const stdout_stream = stdout.writer();
try stdout_stream.print("Content-Length: {}\r\n\r\n" ++ json_fmt, .{response.len + id_len + json_fmt.len - 1});
switch (id) {
.Integer => |int| try stdout_stream.print("{}", .{int}),
.String => |str| try stdout_stream.print("\"{s}\"", .{str}),
else => unreachable,
}
try stdout_stream.writeAll(response);
try stdout.flush();
}
fn showMessage(message_type: types.MessageType, message: []const u8) !void {
try send(types.Notification{
.method = "window/showMessage",
.params = .{
.ShowMessageParams = .{
.type = message_type,
.message = message,
},
},
});
}
// TODO: Is this correct or can we get a better end?
fn astLocationToRange(loc: Ast.Location) types.Range {
return .{
.start = .{
.line = @intCast(i64, loc.line),
.character = @intCast(i64, loc.column),
},
.end = .{
.line = @intCast(i64, loc.line),
.character = @intCast(i64, loc.column),
},
};
}
fn publishDiagnostics(arena: *std.heap.ArenaAllocator, handle: DocumentStore.Handle, config: Config) !void {
const tree = handle.tree;
var diagnostics = std.ArrayList(types.Diagnostic).init(arena.allocator());
for (tree.errors) |err| {
const loc = tree.tokenLocation(0, err.token);
var mem_buffer: [256]u8 = undefined;
var fbs = std.io.fixedBufferStream(&mem_buffer);
try tree.renderError(err, fbs.writer());
try diagnostics.append(.{
.range = astLocationToRange(loc),
.severity = .Error,
.code = @tagName(err.tag),
.source = "zls",
.message = try arena.allocator().dupe(u8, fbs.getWritten()),
// .relatedInformation = undefined
});
}
// TODO: style warnings for types, values and declarations below root scope
if (tree.errors.len == 0) {
for (tree.rootDecls()) |decl_idx| {
const decl = tree.nodes.items(.tag)[decl_idx];
switch (decl) {
.fn_proto,
.fn_proto_multi,
.fn_proto_one,
.fn_proto_simple,
.fn_decl,
=> blk: {
var buf: [1]Ast.Node.Index = undefined;
const func = ast.fnProto(tree, decl_idx, &buf).?;
if (func.extern_export_inline_token != null) break :blk;
if (config.warn_style) {
if (func.name_token) |name_token| {
const loc = tree.tokenLocation(0, name_token);
const is_type_function = analysis.isTypeFunction(tree, func);
const func_name = tree.tokenSlice(name_token);
if (!is_type_function and !analysis.isCamelCase(func_name)) {
try diagnostics.append(.{
.range = astLocationToRange(loc),
.severity = .Information,
.code = "BadStyle",
.source = "zls",
.message = "Functions should be camelCase",
});
} else if (is_type_function and !analysis.isPascalCase(func_name)) {
try diagnostics.append(.{
.range = astLocationToRange(loc),
.severity = .Information,
.code = "BadStyle",
.source = "zls",
.message = "Type functions should be PascalCase",
});
}
}
}
},
else => {},
}
}
}
try send(arena, types.Notification{
.method = "textDocument/publishDiagnostics",
.params = .{
.PublishDiagnostics = .{
.uri = handle.uri(),
.diagnostics = diagnostics.items,
},
},
});
}
fn typeToCompletion(arena: *std.heap.ArenaAllocator, list: *std.ArrayList(types.CompletionItem), field_access: analysis.FieldAccessReturn, orig_handle: *DocumentStore.Handle, config: Config) error{OutOfMemory}!void {
const type_handle = field_access.original;
switch (type_handle.type.data) {
.slice => {
if (!type_handle.type.is_type_val) {
try list.append(.{
.label = "len",
.kind = .Field,
.insertText = "len",
.insertTextFormat = .PlainText,
});
try list.append(.{
.label = "ptr",
.kind = .Field,
.insertText = "ptr",
.insertTextFormat = .PlainText,
});
}
},
.error_union => {},
.pointer => |n| {
if (config.operator_completions) {
try list.append(.{
.label = "*",
.kind = .Operator,
.insertText = "*",
.insertTextFormat = .PlainText,
});
}
try nodeToCompletion(
arena,
list,
.{ .node = n, .handle = type_handle.handle },
null,
orig_handle,
type_handle.type.is_type_val,
null,
config,
);
},
.other => |n| try nodeToCompletion(
arena,
list,
.{ .node = n, .handle = type_handle.handle },
field_access.unwrapped,
orig_handle,
type_handle.type.is_type_val,
null,
config,
),
.primitive => {},
}
}
fn nodeToCompletion(arena: *std.heap.ArenaAllocator, list: *std.ArrayList(types.CompletionItem), node_handle: analysis.NodeWithHandle, unwrapped: ?analysis.TypeWithHandle, orig_handle: *DocumentStore.Handle, is_type_val: bool, parent_is_type_val: ?bool, config: Config) error{OutOfMemory}!void {
const node = node_handle.node;
const handle = node_handle.handle;
const tree = handle.tree;
const node_tags = tree.nodes.items(.tag);
const token_tags = tree.tokens.items(.tag);
const doc_kind: types.MarkupContent.Kind = if (client_capabilities.completion_doc_supports_md)
.Markdown
else
.PlainText;
const doc = if (try analysis.getDocComments(
list.allocator,
handle.tree,
node,
doc_kind,
)) |doc_comments|
types.MarkupContent{
.kind = doc_kind,
.value = doc_comments,
}
else
null;
if (ast.isContainer(handle.tree, node)) {
const context = DeclToCompletionContext{
.completions = list,
.config = &config,
.arena = arena,
.orig_handle = orig_handle,
.parent_is_type_val = is_type_val,
};
try analysis.iterateSymbolsContainer(
&document_store,
arena,
node_handle,
orig_handle,
declToCompletion,
context,
!is_type_val,
);
}
if (is_type_val) return;
switch (node_tags[node]) {
.fn_proto,
.fn_proto_multi,
.fn_proto_one,
.fn_proto_simple,
.fn_decl,
=> {
var buf: [1]Ast.Node.Index = undefined;
const func = ast.fnProto(tree, node, &buf).?;
if (func.name_token) |name_token| {
const use_snippets = config.enable_snippets and client_capabilities.supports_snippets;
const insert_text = if (use_snippets) blk: {
const skip_self_param = !(parent_is_type_val orelse true) and
try analysis.hasSelfParam(arena, &document_store, handle, func);
break :blk try analysis.getFunctionSnippet(arena.allocator(), tree, func, skip_self_param);
} else tree.tokenSlice(func.name_token.?);
const is_type_function = analysis.isTypeFunction(handle.tree, func);
try list.append(.{
.label = handle.tree.tokenSlice(name_token),
.kind = if (is_type_function) .Struct else .Function,
.documentation = doc,
.detail = analysis.getFunctionSignature(handle.tree, func),
.insertText = insert_text,
.insertTextFormat = if (use_snippets) .Snippet else .PlainText,
});
}
},
.global_var_decl,
.local_var_decl,
.aligned_var_decl,
.simple_var_decl,
=> {
const var_decl = ast.varDecl(tree, node).?;
const is_const = token_tags[var_decl.ast.mut_token] == .keyword_const;
if (try analysis.resolveVarDeclAlias(&document_store, arena, node_handle)) |result| {
const context = DeclToCompletionContext{
.completions = list,
.config = &config,
.arena = arena,
.orig_handle = orig_handle,
};
return try declToCompletion(context, result);
}
try list.append(.{
.label = handle.tree.tokenSlice(var_decl.ast.mut_token + 1),
.kind = if (is_const) .Constant else .Variable,
.documentation = doc,
.detail = analysis.getVariableSignature(tree, var_decl),
.insertText = tree.tokenSlice(var_decl.ast.mut_token + 1),
.insertTextFormat = .PlainText,
});
},
.container_field,
.container_field_align,
.container_field_init,
=> {
const field = ast.containerField(tree, node).?;
try list.append(.{
.label = handle.tree.tokenSlice(field.ast.name_token),
.kind = .Field,
.documentation = doc,
.detail = analysis.getContainerFieldSignature(handle.tree, field),
.insertText = tree.tokenSlice(field.ast.name_token),
.insertTextFormat = .PlainText,
});
},
.array_type,
.array_type_sentinel,
=> {
try list.append(.{
.label = "len",
.kind = .Field,
.insertText = "len",
.insertTextFormat = .PlainText,
});
},
.ptr_type,
.ptr_type_aligned,
.ptr_type_bit_range,
.ptr_type_sentinel,
=> {
const ptr_type = ast.ptrType(tree, node).?;
switch (ptr_type.size) {
.One, .C, .Many => if (config.operator_completions) {
try list.append(.{
.label = "*",
.kind = .Operator,
.insertText = "*",
.insertTextFormat = .PlainText,
});
},
.Slice => {
try list.append(.{
.label = "ptr",
.kind = .Field,
.insertText = "ptr",
.insertTextFormat = .PlainText,
});
try list.append(.{
.label = "len",
.kind = .Field,
.insertText = "len",
.insertTextFormat = .PlainText,
});
return;
},
}
if (unwrapped) |actual_type| {
try typeToCompletion(arena, list, .{ .original = actual_type }, orig_handle, config);
}
return;
},
.optional_type => {
if (config.operator_completions) {
try list.append(.{
.label = "?",
.kind = .Operator,
.insertText = "?",
.insertTextFormat = .PlainText,
});
}
return;
},
.string_literal => {
try list.append(.{
.label = "len",
.kind = .Field,
.insertText = "len",
.insertTextFormat = .PlainText,
});
},
else => if (analysis.nodeToString(tree, node)) |string| {
try list.append(.{
.label = string,
.kind = .Field,
.documentation = doc,
.detail = tree.getNodeSource(node),
.insertText = string,
.insertTextFormat = .PlainText,
});
},
}
}
pub fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []const u8 {
const text = handle.document.text;
if (pos_index + 1 >= text.len) return "";
var start_idx = pos_index;
while (start_idx > 0 and isSymbolChar(text[start_idx - 1])) {
start_idx -= 1;
}
var end_idx = pos_index;
while (end_idx < handle.document.text.len and isSymbolChar(text[end_idx])) {
end_idx += 1;
}
if (end_idx <= start_idx) return "";
return text[start_idx..end_idx];
}
fn isSymbolChar(char: u8) bool {
return std.ascii.isAlNum(char) or char == '_';
}
fn gotoDefinitionSymbol(id: types.RequestId, arena: *std.heap.ArenaAllocator, decl_handle: analysis.DeclWithHandle, resolve_alias: bool) !void {
var handle = decl_handle.handle;
const location = switch (decl_handle.decl.*) {
.ast_node => |node| block: {
if (resolve_alias) {
if (try analysis.resolveVarDeclAlias(&document_store, arena, .{ .node = node, .handle = handle })) |result| {
handle = result.handle;
break :block result.location(offset_encoding) catch return;
}
}
const name_token = analysis.getDeclNameToken(handle.tree, node) orelse
return try respondGeneric(id, null_result_response);
break :block offsets.tokenRelativeLocation(handle.tree, 0, handle.tree.tokens.items(.start)[name_token], offset_encoding) catch return;
},
else => decl_handle.location(offset_encoding) catch return,
};
try send(arena, types.Response{
.id = id,
.result = .{
.Location = .{
.uri = handle.document.uri,
.range = .{
.start = .{
.line = @intCast(i64, location.line),
.character = @intCast(i64, location.column),
},
.end = .{
.line = @intCast(i64, location.line),
.character = @intCast(i64, location.column),
},
},
},
},
});
}
fn hoverSymbol(id: types.RequestId, arena: *std.heap.ArenaAllocator, decl_handle: analysis.DeclWithHandle) (std.os.WriteError || error{OutOfMemory})!void {
const handle = decl_handle.handle;
const tree = handle.tree;
const hover_kind: types.MarkupContent.Kind = if (client_capabilities.hover_supports_md) .Markdown else .PlainText;
var doc_str: ?[]const u8 = null;
const def_str = switch (decl_handle.decl.*) {
.ast_node => |node| def: {
if (try analysis.resolveVarDeclAlias(&document_store, arena, .{ .node = node, .handle = handle })) |result| {
return try hoverSymbol(id, arena, result);
}
doc_str = try analysis.getDocComments(arena.allocator(), tree, node, hover_kind);
var buf: [1]Ast.Node.Index = undefined;
if (ast.varDecl(tree, node)) |var_decl| {
break :def analysis.getVariableSignature(tree, var_decl);
} else if (ast.fnProto(tree, node, &buf)) |fn_proto| {
break :def analysis.getFunctionSignature(tree, fn_proto);
} else if (ast.containerField(tree, node)) |field| {
break :def analysis.getContainerFieldSignature(tree, field);
} else {
break :def analysis.nodeToString(tree, node) orelse
return try respondGeneric(id, null_result_response);
}
},
.param_decl => |param| def: {
if (param.first_doc_comment) |doc_comments| {
doc_str = try analysis.collectDocComments(arena.allocator(), handle.tree, doc_comments, hover_kind, false);
}
const first_token = param.first_doc_comment orelse
param.comptime_noalias orelse
param.name_token orelse
tree.firstToken(param.type_expr); // extern fn
const last_token = param.anytype_ellipsis3 orelse tree.lastToken(param.type_expr);
const start = offsets.tokenLocation(tree, first_token).start;
const end = offsets.tokenLocation(tree, last_token).end;
break :def tree.source[start..end];
},
.pointer_payload => |payload| tree.tokenSlice(payload.name),
.array_payload => |payload| handle.tree.tokenSlice(payload.identifier),
.array_index => |payload| handle.tree.tokenSlice(payload),
.switch_payload => |payload| tree.tokenSlice(payload.node),
.label_decl => |label_decl| tree.tokenSlice(label_decl),
};
var hover_text: []const u8 = undefined;
if (hover_kind == .Markdown) {
hover_text =
if (doc_str) |doc|
try std.fmt.allocPrint(arena.allocator(), "```zig\n{s}\n```\n{s}", .{ def_str, doc })
else
try std.fmt.allocPrint(arena.allocator(), "```zig\n{s}\n```", .{def_str});
} else {
hover_text =
if (doc_str) |doc|
try std.fmt.allocPrint(arena.allocator(), "{s}\n{s}", .{ def_str, doc })
else
def_str;
}
try send(arena, types.Response{
.id = id,
.result = .{
.Hover = .{
.contents = .{ .value = hover_text },
},
},
});
}
fn getLabelGlobal(pos_index: usize, handle: *DocumentStore.Handle) !?analysis.DeclWithHandle {
const name = identifierFromPosition(pos_index, handle.*);
if (name.len == 0) return null;
return try analysis.lookupLabel(handle, name, pos_index);
}
fn getSymbolGlobal(arena: *std.heap.ArenaAllocator, pos_index: usize, handle: *DocumentStore.Handle) !?analysis.DeclWithHandle {
const name = identifierFromPosition(pos_index, handle.*);
if (name.len == 0) return null;
return try analysis.lookupSymbolGlobal(&document_store, arena, handle, name, pos_index);
}
fn gotoDefinitionLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
_ = config;
const decl = (try getLabelGlobal(pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
return try gotoDefinitionSymbol(id, arena, decl, false);
}
fn gotoDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config, resolve_alias: bool) !void {
_ = config;
const decl = (try getSymbolGlobal(arena, pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
return try gotoDefinitionSymbol(id, arena, decl, resolve_alias);
}
fn hoverDefinitionLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
_ = config;
const decl = (try getLabelGlobal(pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
return try hoverSymbol(id, arena, decl);
}
fn hoverDefinitionBuiltin(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle) !void {
const name = identifierFromPosition(pos_index, handle.*);
if (name.len == 0) return try respondGeneric(id, null_result_response);
inline for (data.builtins) |builtin| {
if (std.mem.eql(u8, builtin.name[1..], name)) {
try send(arena, types.Response{
.id = id,
.result = .{
.Hover = .{
.contents = .{
.value = try std.fmt.allocPrint(
arena.allocator(),
"```zig\n{s}\n```\n{s}",
.{ builtin.signature, builtin.documentation },
),
},
},
},
});
}
}
}
fn hoverDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
_ = config;
const decl = (try getSymbolGlobal(arena, pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
return try hoverSymbol(id, arena, decl);
}
fn getSymbolFieldAccess(handle: *DocumentStore.Handle, arena: *std.heap.ArenaAllocator, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !?analysis.DeclWithHandle {
_ = config;
const name = identifierFromPosition(position.absolute_index, handle.*);
if (name.len == 0) return null;
const line_mem_start = @ptrToInt(position.line.ptr) - @ptrToInt(handle.document.mem.ptr);
var held_range = handle.document.borrowNullTerminatedSlice(line_mem_start + range.start, line_mem_start + range.end);
var tokenizer = std.zig.Tokenizer.init(held_range.data());
errdefer held_range.release();
if (try analysis.getFieldAccessType(&document_store, arena, handle, position.absolute_index, &tokenizer)) |result| {
held_range.release();
const container_handle = result.unwrapped orelse result.original;
const container_handle_node = switch (container_handle.type.data) {
.other => |n| n,
else => return null,
};
return try analysis.lookupSymbolContainer(
&document_store,
arena,
.{ .node = container_handle_node, .handle = container_handle.handle },
name,
true,
);
}
return null;
}
fn gotoDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config, resolve_alias: bool) !void {
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
return try gotoDefinitionSymbol(id, arena, decl, resolve_alias);
}
fn hoverDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !void {
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
return try hoverSymbol(id, arena, decl);
}
fn gotoDefinitionString(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
_ = config;
const tree = handle.tree;
const import_str = analysis.getImportStr(tree, 0, pos_index) orelse return try respondGeneric(id, null_result_response);
const uri = (try document_store.uriFromImportStr(
arena.allocator(),
handle.*,
import_str,
)) orelse return try respondGeneric(id, null_result_response);
try send(arena, types.Response{
.id = id,
.result = .{
.Location = .{
.uri = uri,
.range = .{
.start = .{ .line = 0, .character = 0 },
.end = .{ .line = 0, .character = 0 },
},
},
},
});
}
fn renameDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, pos_index: usize, new_name: []const u8) !void {
const decl = (try getSymbolGlobal(arena, pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
var workspace_edit = types.WorkspaceEdit{
.changes = std.StringHashMap([]types.TextEdit).init(arena.allocator()),
};
try rename.renameSymbol(arena, &document_store, decl, new_name, &workspace_edit.changes.?, offset_encoding);
try send(arena, types.Response{
.id = id,
.result = .{ .WorkspaceEdit = workspace_edit },
});
}
fn renameDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, new_name: []const u8, config: Config) !void {
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
var workspace_edit = types.WorkspaceEdit{
.changes = std.StringHashMap([]types.TextEdit).init(arena.allocator()),
};
try rename.renameSymbol(arena, &document_store, decl, new_name, &workspace_edit.changes.?, offset_encoding);
try send(arena, types.Response{
.id = id,
.result = .{ .WorkspaceEdit = workspace_edit },
});
}
fn renameDefinitionLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, pos_index: usize, new_name: []const u8) !void {
const decl = (try getLabelGlobal(pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
var workspace_edit = types.WorkspaceEdit{
.changes = std.StringHashMap([]types.TextEdit).init(arena.allocator()),
};
try rename.renameLabel(arena, decl, new_name, &workspace_edit.changes.?, offset_encoding);
try send(arena, types.Response{
.id = id,
.result = .{ .WorkspaceEdit = workspace_edit },
});
}
fn referencesDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, pos_index: usize, include_decl: bool, skip_std_references: bool) !void {
const decl = (try getSymbolGlobal(arena, pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
var locs = std.ArrayList(types.Location).init(arena.allocator());
try references.symbolReferences(
arena,
&document_store,
decl,
offset_encoding,
include_decl,
&locs,
std.ArrayList(types.Location).append,
skip_std_references,
);
try send(arena, types.Response{
.id = id,
.result = .{ .Locations = locs.items },
});
}
fn referencesDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, include_decl: bool, config: Config) !void {
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
var locs = std.ArrayList(types.Location).init(arena.allocator());
try references.symbolReferences(arena, &document_store, decl, offset_encoding, include_decl, &locs, std.ArrayList(types.Location).append, config.skip_std_references);
try send(arena, types.Response{
.id = id,
.result = .{ .Locations = locs.items },
});
}
fn referencesDefinitionLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, pos_index: usize, include_decl: bool) !void {
const decl = (try getLabelGlobal(pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
var locs = std.ArrayList(types.Location).init(arena.allocator());
try references.labelReferences(arena, decl, offset_encoding, include_decl, &locs, std.ArrayList(types.Location).append);
try send(arena, types.Response{
.id = id,
.result = .{ .Locations = locs.items },
});
}
fn hasComment(tree: Ast.Tree, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
const token_starts = tree.tokens.items(.start);
const start = token_starts[start_token];
const end = token_starts[end_token];
return std.mem.indexOf(u8, tree.source[start..end], "//") != null;
}
const DeclToCompletionContext = struct {
completions: *std.ArrayList(types.CompletionItem),
config: *const Config,
arena: *std.heap.ArenaAllocator,
orig_handle: *DocumentStore.Handle,
parent_is_type_val: ?bool = null,
};
fn declToCompletion(context: DeclToCompletionContext, decl_handle: analysis.DeclWithHandle) !void {
const tree = decl_handle.handle.tree;
switch (decl_handle.decl.*) {
.ast_node => |node| try nodeToCompletion(
context.arena,
context.completions,
.{ .node = node, .handle = decl_handle.handle },
null,
context.orig_handle,
false,
context.parent_is_type_val,
context.config.*,
),
.param_decl => |param| {
const doc_kind: types.MarkupContent.Kind = if (client_capabilities.completion_doc_supports_md) .Markdown else .PlainText;
const doc = if (param.first_doc_comment) |doc_comments|
types.MarkupContent{
.kind = doc_kind,
.value = try analysis.collectDocComments(context.arena.allocator(), tree, doc_comments, doc_kind, false),
}
else
null;
const first_token = param.first_doc_comment orelse
param.comptime_noalias orelse
param.name_token orelse
tree.firstToken(param.type_expr);
const last_token = param.anytype_ellipsis3 orelse tree.lastToken(param.type_expr);
try context.completions.append(.{
.label = tree.tokenSlice(param.name_token.?),
.kind = .Constant,
.documentation = doc,
.detail = tree.source[offsets.tokenLocation(tree, first_token).start..offsets.tokenLocation(tree, last_token).end],
.insertText = tree.tokenSlice(param.name_token.?),
.insertTextFormat = .PlainText,
});
},
.pointer_payload => |payload| {
try context.completions.append(.{
.label = tree.tokenSlice(payload.name),
.kind = .Variable,
.insertText = tree.tokenSlice(payload.name),
.insertTextFormat = .PlainText,
});
},
.array_payload => |payload| {
try context.completions.append(.{
.label = tree.tokenSlice(payload.identifier),
.kind = .Variable,
.insertText = tree.tokenSlice(payload.identifier),
.insertTextFormat = .PlainText,
});
},
.array_index => |payload| {
try context.completions.append(.{
.label = tree.tokenSlice(payload),
.kind = .Variable,
.insertText = tree.tokenSlice(payload),
.insertTextFormat = .PlainText,
});
},
.switch_payload => |payload| {
try context.completions.append(.{
.label = tree.tokenSlice(payload.node),
.kind = .Variable,
.insertText = tree.tokenSlice(payload.node),
.insertTextFormat = .PlainText,
});
},
.label_decl => |label_decl| {
try context.completions.append(.{
.label = tree.tokenSlice(label_decl),
.kind = .Variable,
.insertText = tree.tokenSlice(label_decl),
.insertTextFormat = .PlainText,
});
},
}
}
fn completeLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
var completions = std.ArrayList(types.CompletionItem).init(arena.allocator());
const context = DeclToCompletionContext{
.completions = &completions,
.config = &config,
.arena = arena,
.orig_handle = handle,
};
try analysis.iterateLabels(handle, pos_index, declToCompletion, context);
truncateCompletions(completions.items, config.max_detail_length);
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = completions.items,
},
},
});
}
var builtin_completions: ?[]types.CompletionItem = null;
fn completeBuiltin(arena: *std.heap.ArenaAllocator, id: types.RequestId, config: Config) !void {
if (builtin_completions == null) {
builtin_completions = try allocator.alloc(types.CompletionItem, data.builtins.len);
for (data.builtins) |builtin, idx| {
builtin_completions.?[idx] = types.CompletionItem{
.label = builtin.name,
.kind = .Function,
.filterText = builtin.name[1..],
.detail = builtin.signature,
.documentation = .{
.kind = .Markdown,
.value = builtin.documentation,
},
};
var insert_text: []const u8 = undefined;
if (config.enable_snippets) {
insert_text = builtin.snippet;
builtin_completions.?[idx].insertTextFormat = .Snippet;
} else {
insert_text = builtin.name;
}
builtin_completions.?[idx].insertText =
if (config.include_at_in_builtins)
insert_text
else
insert_text[1..];
}
truncateCompletions(builtin_completions.?, config.max_detail_length);
}
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = builtin_completions.?,
},
},
});
}
fn completeGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
var completions = std.ArrayList(types.CompletionItem).init(arena.allocator());
const context = DeclToCompletionContext{
.completions = &completions,
.config = &config,
.arena = arena,
.orig_handle = handle,
};
try analysis.iterateSymbolsGlobal(&document_store, arena, handle, pos_index, declToCompletion, context);
truncateCompletions(completions.items, config.max_detail_length);
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = completions.items,
},
},
});
}
fn completeFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !void {
var completions = std.ArrayList(types.CompletionItem).init(arena.allocator());
const line_mem_start = @ptrToInt(position.line.ptr) - @ptrToInt(handle.document.mem.ptr);
var held_range = handle.document.borrowNullTerminatedSlice(line_mem_start + range.start, line_mem_start + range.end);
errdefer held_range.release();
var tokenizer = std.zig.Tokenizer.init(held_range.data());
if (try analysis.getFieldAccessType(&document_store, arena, handle, position.absolute_index, &tokenizer)) |result| {
held_range.release();
try typeToCompletion(arena, &completions, result, handle, config);
truncateCompletions(completions.items, config.max_detail_length);
}
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = completions.items,
},
},
});
}
fn completeError(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, config: Config) !void {
const completions = try document_store.errorCompletionItems(arena, handle);
truncateCompletions(completions, config.max_detail_length);
logger.debug("Completing error:", .{});
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = completions,
},
},
});
}
fn completeDot(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, config: Config) !void {
var completions = try document_store.enumCompletionItems(arena, handle);
truncateCompletions(completions, config.max_detail_length);
try send(arena, types.Response{
.id = id,
.result = .{
.CompletionList = .{
.isIncomplete = false,
.items = completions,
},
},
});
}
fn documentSymbol(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle) !void {
try send(arena, types.Response{
.id = id,
.result = .{ .DocumentSymbols = try analysis.getDocumentSymbols(arena.allocator(), handle.tree, offset_encoding) },
});
}
fn loadConfigFile(file_path: []const u8) ?Config {
var file = std.fs.cwd().openFile(file_path, .{}) catch |err| {
if (err != error.FileNotFound)
logger.warn("Error while reading configuration file: {}", .{err});
return null;
};
defer file.close();
const file_buf = file.readToEndAlloc(allocator, 0x1000000) catch return null;
defer allocator.free(file_buf);
@setEvalBranchQuota(3000);
// TODO: Better errors? Doesn't seem like std.json can provide us positions or context.
var config = std.json.parse(Config, &std.json.TokenStream.init(file_buf), std.json.ParseOptions{ .allocator = allocator }) catch |err| {
logger.warn("Error while parsing configuration file: {}", .{err});
return null;
};
if (config.zig_lib_path) |zig_lib_path| {
if (!std.fs.path.isAbsolute(zig_lib_path)) {
logger.warn("zig library path is not absolute, defaulting to null.", .{});
allocator.free(zig_lib_path);
config.zig_lib_path = null;
}
}
return config;
}
fn loadConfigInFolder(folder_path: []const u8) ?Config {
const full_path = std.fs.path.resolve(allocator, &.{ folder_path, "zls.json" }) catch return null;
defer allocator.free(full_path);
return loadConfigFile(full_path);
}
fn initializeHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Initialize, config: Config) !void {
_ = config;
for (req.params.capabilities.offsetEncoding.value) |encoding| {
if (std.mem.eql(u8, encoding, "utf-8")) {
offset_encoding = .utf8;
}
}
if (req.params.capabilities.textDocument) |textDocument| {
client_capabilities.supports_semantic_tokens = textDocument.semanticTokens.exists;
if (textDocument.hover) |hover| {
for (hover.contentFormat.value) |format| {
if (std.mem.eql(u8, "markdown", format)) {
client_capabilities.hover_supports_md = true;
}
}
}
if (textDocument.completion) |completion| {
if (completion.completionItem) |completionItem| {
client_capabilities.supports_snippets = completionItem.snippetSupport.value;
for (completionItem.documentationFormat.value) |documentationFormat| {
if (std.mem.eql(u8, "markdown", documentationFormat)) {
client_capabilities.completion_doc_supports_md = true;
}
}
}
}
}
try send(arena, types.Response{
.id = id,
.result = .{
.InitializeResult = .{
.offsetEncoding = if (offset_encoding == .utf8)
@as([]const u8, "utf-8")
else
"utf-16",
.serverInfo = .{
.name = "zls",
.version = "0.1.0",
},
.capabilities = .{
.signatureHelpProvider = .{
.triggerCharacters = &.{"("},
.retriggerCharacters = &.{","},
},
.textDocumentSync = .Full,
.renameProvider = true,
.completionProvider = .{
.resolveProvider = false,
.triggerCharacters = &[_][]const u8{ ".", ":", "@" },
},
.documentHighlightProvider = false,
.hoverProvider = true,
.codeActionProvider = false,
.declarationProvider = true,
.definitionProvider = true,
.typeDefinitionProvider = true,
.implementationProvider = false,
.referencesProvider = true,
.documentSymbolProvider = true,
.colorProvider = false,
.documentFormattingProvider = true,
.documentRangeFormattingProvider = false,
.foldingRangeProvider = false,
.selectionRangeProvider = false,
.workspaceSymbolProvider = false,
.rangeProvider = false,
.documentProvider = true,
.workspace = .{
.workspaceFolders = .{
.supported = false,
.changeNotifications = false,
},
},
.semanticTokensProvider = .{
.full = true,
.range = false,
.legend = .{
.tokenTypes = comptime block: {
const tokTypeFields = std.meta.fields(semantic_tokens.TokenType);
var names: [tokTypeFields.len][]const u8 = undefined;
for (tokTypeFields) |field, i| {
names[i] = field.name;
}
break :block &names;
},
.tokenModifiers = comptime block: {
const tokModFields = std.meta.fields(semantic_tokens.TokenModifiers);
var names: [tokModFields.len][]const u8 = undefined;
for (tokModFields) |field, i| {
names[i] = field.name;
}
break :block &names;
},
},
},
},
},
},
});
logger.info("zls initialized", .{});
logger.info("{}", .{client_capabilities});
logger.info("Using offset encoding: {s}", .{std.meta.tagName(offset_encoding)});
}
var keep_running = true;
fn shutdownHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, config: Config) !void {
_ = config;
_ = arena;
logger.info("Server closing...", .{});
keep_running = false;
// Technically we should deinitialize first and send possible errors to the client
try respondGeneric(id, null_result_response);
}
fn openDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.OpenDocument, config: Config) !void {
const handle = try document_store.openDocument(req.params.textDocument.uri, req.params.textDocument.text);
try publishDiagnostics(arena, handle.*, config);
if (client_capabilities.supports_semantic_tokens)
try semanticTokensFullHandler(arena, id, .{ .params = .{ .textDocument = .{ .uri = req.params.textDocument.uri } } }, config);
}
fn changeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.ChangeDocument, config: Config) !void {
_ = id;
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.debug("Trying to change non existent document {s}", .{req.params.textDocument.uri});
return;
};
try document_store.applyChanges(handle, req.params.contentChanges.Array, offset_encoding);
try publishDiagnostics(arena, handle.*, config);
}
fn saveDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SaveDocument, config: Config) error{OutOfMemory}!void {
_ = config;
_ = id;
_ = arena;
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to save non existent document {s}", .{req.params.textDocument.uri});
return;
};
try document_store.applySave(handle);
}
fn closeDocumentHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.CloseDocument, config: Config) error{}!void {
_ = config;
_ = id;
_ = arena;
document_store.closeDocument(req.params.textDocument.uri);
}
fn semanticTokensFullHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SemanticTokensFull, config: Config) !void {
if (config.enable_semantic_tokens) blk: {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to get semantic tokens of non existent document {s}", .{req.params.textDocument.uri});
break :blk;
};
const token_array = try semantic_tokens.writeAllSemanticTokens(arena, &document_store, handle, offset_encoding);
defer allocator.free(token_array);
return try send(arena, types.Response{
.id = id,
.result = .{ .SemanticTokensFull = .{ .data = token_array } },
});
}
return try respondGeneric(id, no_semantic_tokens_response);
}
fn completionHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Completion, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to complete in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, no_completions_response);
};
if (req.params.position.character == 0)
return try respondGeneric(id, no_completions_response);
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
const pos_context = try analysis.documentPositionContext(arena, handle.document, doc_position);
switch (pos_context) {
.builtin => try completeBuiltin(arena, id, config),
.var_access, .empty => try completeGlobal(arena, id, doc_position.absolute_index, handle, config),
.field_access => |range| try completeFieldAccess(arena, id, handle, doc_position, range, config),
.global_error_set => try completeError(arena, id, handle, config),
.enum_literal => try completeDot(arena, id, handle, config),
.label => try completeLabel(arena, id, doc_position.absolute_index, handle, config),
else => try respondGeneric(id, no_completions_response),
}
}
fn signatureHelpHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SignatureHelp, config: Config) !void {
_ = config;
const getSignatureInfo = @import("signature_help.zig").getSignatureInfo;
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to get signature help in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, no_signatures_response);
};
if (req.params.position.character == 0)
return try respondGeneric(id, no_signatures_response);
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
if (try getSignatureInfo(
&document_store,
arena,
handle,
doc_position.absolute_index,
data,
)) |sig_info| {
return try send(arena, types.Response{
.id = id,
.result = .{
.SignatureHelp = .{
.signatures = &[1]types.SignatureInformation{sig_info},
.activeSignature = 0,
.activeParameter = sig_info.activeParameter,
},
},
});
}
return try respondGeneric(id, no_signatures_response);
}
fn gotoHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.GotoDefinition, config: Config, resolve_alias: bool) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to go to definition in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
if (req.params.position.character >= 0) {
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
const pos_context = try analysis.documentPositionContext(arena, handle.document, doc_position);
switch (pos_context) {
.var_access => try gotoDefinitionGlobal(arena, id, doc_position.absolute_index, handle, config, resolve_alias),
.field_access => |range| try gotoDefinitionFieldAccess(arena, id, handle, doc_position, range, config, resolve_alias),
.string_literal => try gotoDefinitionString(arena, id, doc_position.absolute_index, handle, config),
.label => try gotoDefinitionLabel(arena, id, doc_position.absolute_index, handle, config),
else => try respondGeneric(id, null_result_response),
}
} else {
try respondGeneric(id, null_result_response);
}
}
fn gotoDefinitionHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.GotoDefinition, config: Config) !void {
try gotoHandler(arena, id, req, config, true);
}
fn gotoDeclarationHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.GotoDeclaration, config: Config) !void {
try gotoHandler(arena, id, req, config, false);
}
fn hoverHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Hover, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to get hover in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
if (req.params.position.character >= 0) {
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
const pos_context = try analysis.documentPositionContext(arena, handle.document, doc_position);
switch (pos_context) {
.builtin => try hoverDefinitionBuiltin(arena, id, doc_position.absolute_index, handle),
.var_access => try hoverDefinitionGlobal(arena, id, doc_position.absolute_index, handle, config),
.field_access => |range| try hoverDefinitionFieldAccess(arena, id, handle, doc_position, range, config),
.label => try hoverDefinitionLabel(arena, id, doc_position.absolute_index, handle, config),
else => try respondGeneric(id, null_result_response),
}
} else {
try respondGeneric(id, null_result_response);
}
}
fn documentSymbolsHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.DocumentSymbols, config: Config) !void {
_ = config;
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to get document symbols in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
try documentSymbol(arena, id, handle);
}
fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Formatting, config: Config) !void {
if (config.zig_exe_path) |zig_exe_path| {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to got to definition in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
var process = try std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
defer process.deinit();
process.stdin_behavior = .Pipe;
process.stdout_behavior = .Pipe;
process.spawn() catch |err| {
logger.warn("Failed to spawn zig fmt process, error: {}", .{err});
return try respondGeneric(id, null_result_response);
};
try process.stdin.?.writeAll(handle.document.text);
process.stdin.?.close();
process.stdin = null;
const stdout_bytes = try process.stdout.?.reader().readAllAlloc(allocator, std.math.maxInt(usize));
defer allocator.free(stdout_bytes);
switch (try process.wait()) {
.Exited => |code| if (code == 0) {
return try send(arena, types.Response{
.id = id,
.result = .{
.TextEdits = &[1]types.TextEdit{
.{
.range = try offsets.documentRange(handle.document, offset_encoding),
.newText = stdout_bytes,
},
},
},
});
},
else => {},
}
}
return try respondGeneric(id, null_result_response);
}
fn renameHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Rename, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to rename in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
if (req.params.position.character >= 0) {
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
const pos_context = try analysis.documentPositionContext(arena, handle.document, doc_position);
switch (pos_context) {
.var_access => try renameDefinitionGlobal(arena, id, handle, doc_position.absolute_index, req.params.newName),
.field_access => |range| try renameDefinitionFieldAccess(arena, id, handle, doc_position, range, req.params.newName, config),
.label => try renameDefinitionLabel(arena, id, handle, doc_position.absolute_index, req.params.newName),
else => try respondGeneric(id, null_result_response),
}
} else {
try respondGeneric(id, null_result_response);
}
}
fn referencesHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.References, config: Config) !void {
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
logger.warn("Trying to get references in non existent document {s}", .{req.params.textDocument.uri});
return try respondGeneric(id, null_result_response);
};
if (req.params.position.character >= 0) {
const doc_position = try offsets.documentPosition(handle.document, req.params.position, offset_encoding);
const pos_context = try analysis.documentPositionContext(arena, handle.document, doc_position);
const include_decl = req.params.context.includeDeclaration;
switch (pos_context) {
.var_access => try referencesDefinitionGlobal(arena, id, handle, doc_position.absolute_index, include_decl, config.skip_std_references),
.field_access => |range| try referencesDefinitionFieldAccess(arena, id, handle, doc_position, range, include_decl, config),
.label => try referencesDefinitionLabel(arena, id, handle, doc_position.absolute_index, include_decl),
else => try respondGeneric(id, null_result_response),
}
} else {
try respondGeneric(id, null_result_response);
}
}
// Needed for the hack seen below.
fn extractErr(val: anytype) anyerror {
val catch |e| return e;
return error.HackDone;
}
fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, json: []const u8, config: Config) !void {
var tree = try parser.parse(json);
defer tree.deinit();
const id = if (tree.root.Object.get("id")) |id| switch (id) {
.Integer => |int| types.RequestId{ .Integer = int },
.String => |str| types.RequestId{ .String = str },
else => types.RequestId{ .Integer = 0 },
} else types.RequestId{ .Integer = 0 };
std.debug.assert(tree.root.Object.get("method") != null);
const method = tree.root.Object.get("method").?.String;
const start_time = std.time.milliTimestamp();
defer {
const end_time = std.time.milliTimestamp();
logger.debug("Took {}ms to process method {s}", .{ end_time - start_time, method });
}
const method_map = .{
.{"initialized"},
.{"$/cancelRequest"},
.{"textDocument/willSave"},
.{ "initialize", requests.Initialize, initializeHandler },
.{ "shutdown", void, shutdownHandler },
.{ "textDocument/didOpen", requests.OpenDocument, openDocumentHandler },
.{ "textDocument/didChange", requests.ChangeDocument, changeDocumentHandler },
.{ "textDocument/didSave", requests.SaveDocument, saveDocumentHandler },
.{ "textDocument/didClose", requests.CloseDocument, closeDocumentHandler },
.{ "textDocument/semanticTokens/full", requests.SemanticTokensFull, semanticTokensFullHandler },
.{ "textDocument/completion", requests.Completion, completionHandler },
.{ "textDocument/signatureHelp", requests.SignatureHelp, signatureHelpHandler },
.{ "textDocument/definition", requests.GotoDefinition, gotoDefinitionHandler },
.{ "textDocument/typeDefinition", requests.GotoDefinition, gotoDefinitionHandler },
.{ "textDocument/implementation", requests.GotoDefinition, gotoDefinitionHandler },
.{ "textDocument/declaration", requests.GotoDeclaration, gotoDeclarationHandler },
.{ "textDocument/hover", requests.Hover, hoverHandler },
.{ "textDocument/documentSymbol", requests.DocumentSymbols, documentSymbolsHandler },
.{ "textDocument/formatting", requests.Formatting, formattingHandler },
.{ "textDocument/rename", requests.Rename, renameHandler },
.{ "textDocument/references", requests.References, referencesHandler },
};
// Hack to avoid `return`ing in the inline for, which causes bugs.
var done: ?anyerror = null;
inline for (method_map) |method_info| {
if (done == null and std.mem.eql(u8, method, method_info[0])) {
if (method_info.len == 1) {
done = error.HackDone;
} else if (method_info[1] != void) {
const ReqT = method_info[1];
if (requests.fromDynamicTree(arena, ReqT, tree.root)) |request_obj| {
done = error.HackDone;
done = extractErr(method_info[2](arena, id, request_obj, config));
} else |err| {
if (err == error.MalformedJson) {
logger.warn("Could not create request type {s} from JSON {s}", .{ @typeName(ReqT), json });
}
done = err;
}
} else {
done = error.HackDone;
(method_info[2])(arena, id, config) catch |err| {
done = err;
};
}
}
}
if (done) |err| switch (err) {
error.MalformedJson => return try respondGeneric(id, null_result_response),
error.HackDone => return,
else => return err,
};
const unimplemented_map = std.ComptimeStringMap(void, .{
.{"textDocument/documentHighlight"},
.{"textDocument/codeAction"},
.{"textDocument/codeLens"},
.{"textDocument/documentLink"},
.{"textDocument/rangeFormatting"},
.{"textDocument/onTypeFormatting"},
.{"textDocument/prepareRename"},
.{"textDocument/foldingRange"},
.{"textDocument/selectionRange"},
.{"textDocument/semanticTokens/range"},
.{"workspace/didChangeWorkspaceFolders"},
});
if (unimplemented_map.has(method)) {
// TODO: Unimplemented methods, implement them and add them to server capabilities.
return try respondGeneric(id, null_result_response);
}
if (tree.root.Object.get("id")) |_| {
return try respondGeneric(id, not_implemented_response);
}
logger.debug("Method without return value not implemented: {s}", .{method});
}
const stack_frames = switch (zig_builtin.mode) {
.Debug => 10,
else => 0,
};
var gpa_state = std.heap.GeneralPurposeAllocator(.{ .stack_trace_frames = stack_frames }){};
pub fn main() anyerror!void {
defer _ = gpa_state.deinit();
defer keep_running = false;
// allocator = &gpa_state.allocator;
// @TODO Using the GPA here, realloc calls hang currently for some reason
allocator = std.heap.page_allocator;
analysis.init(allocator);
defer analysis.deinit();
// Check arguments.
var args_it = std.process.args();
defer args_it.deinit();
const prog_name = (try args_it.next(allocator)) orelse @panic("Could not find self argument");
allocator.free(prog_name);
var config_path: ?[]const u8 = null;
var next_arg_config_path = false;
while (try args_it.next(allocator)) |arg| {
defer allocator.free(arg);
if (next_arg_config_path) {
config_path = try allocator.dupe(u8, arg);
next_arg_config_path = false;
continue;
}
if (std.mem.eql(u8, arg, "--debug-log")) {
actual_log_level = .debug;
std.debug.print("Enabled debug logging\n", .{});
} else if (std.mem.eql(u8, arg, "--config-path")) {
next_arg_config_path = true;
continue;
} else if (std.mem.eql(u8, arg, "config") or std.mem.eql(u8, arg, "configure")) {
try setup.wizard(allocator);
return;
} else {
std.debug.print("Unrecognized argument {s}\n", .{arg});
std.os.exit(1);
}
}
if (next_arg_config_path) {
std.debug.print("Expected configuration file path after --config-path argument\n", .{});
return;
}
// Init global vars
const reader = std.io.getStdIn().reader();
stdout = std.io.bufferedWriter(std.io.getStdOut().writer());
// Read the configuration, if any.
const config_parse_options = std.json.ParseOptions{ .allocator = allocator };
var config = Config{};
defer std.json.parseFree(Config, config, config_parse_options);
config_read: {
if (config_path) |path| {
defer allocator.free(path);
if (loadConfigFile(path)) |conf| {
config = conf;
break :config_read;
}
std.debug.print("Could not open configuration file '{s}'\n", .{path});
std.debug.print("Falling back to a lookup in the local and global configuration folders\n", .{});
}
if (try known_folders.getPath(allocator, .local_configuration)) |path| {
config_path = path;
if (loadConfigInFolder(path)) |conf| {
config = conf;
break :config_read;
}
}
if (try known_folders.getPath(allocator, .global_configuration)) |path| {
config_path = path;
if (loadConfigInFolder(path)) |conf| {
config = conf;
break :config_read;
}
}
logger.info("No config file zls.json found.", .{});
}
// Find the zig executable in PATH
find_zig: {
if (config.zig_exe_path) |exe_path| {
if (std.fs.path.isAbsolute(exe_path)) not_valid: {
std.fs.cwd().access(exe_path, .{}) catch break :not_valid;
break :find_zig;
}
logger.debug("zig path `{s}` is not absolute, will look in path", .{exe_path});
allocator.free(exe_path);
}
config.zig_exe_path = try setup.findZig(allocator);
}
if (config.zig_exe_path) |exe_path| {
logger.info("Using zig executable {s}", .{exe_path});
if (config.zig_lib_path == null) find_lib_path: {
// Use `zig env` to find the lib path
const zig_env_result = try std.ChildProcess.exec(.{
.allocator = allocator,
.argv = &[_][]const u8{ exe_path, "env" },
});
defer {
allocator.free(zig_env_result.stdout);
allocator.free(zig_env_result.stderr);
}
switch (zig_env_result.term) {
.Exited => |exit_code| {
if (exit_code == 0) {
const Env = struct {
zig_exe: []const u8,
lib_dir: ?[]const u8,
std_dir: []const u8,
global_cache_dir: []const u8,
version: []const u8,
};
var json_env = std.json.parse(
Env,
&std.json.TokenStream.init(zig_env_result.stdout),
.{ .allocator = allocator },
) catch {
logger.err("Failed to parse zig env JSON result", .{});
break :find_lib_path;
};
defer std.json.parseFree(Env, json_env, .{ .allocator = allocator });
// We know this is allocated with `allocator`, we just steal it!
config.zig_lib_path = json_env.lib_dir.?;
json_env.lib_dir = null;
logger.info("Using zig lib path '{s}'", .{config.zig_lib_path});
}
},
else => logger.err("zig env invocation failed", .{}),
}
}
} else {
logger.warn("Zig executable path not specified in zls.json and could not be found in PATH", .{});
}
if (config.zig_lib_path == null) {
logger.warn("Zig standard library path not specified in zls.json and could not be resolved from the zig executable", .{});
}
if (config.builtin_path == null and config.zig_exe_path != null and config_path != null) blk: {
const result = try std.ChildProcess.exec(.{
.allocator = allocator,
.argv = &.{
config.zig_exe_path.?,
"build-exe",
"--show-builtin",
},
.max_output_bytes = 1024 * 1024 * 50,
});
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);
var d = try std.fs.cwd().openDir(config_path.?, .{});
defer d.close();
const f = d.createFile("builtin.zig", .{}) catch |err| switch (err) {
error.AccessDenied => break :blk,
else => |e| return e,
};
defer f.close();
try f.writer().writeAll(result.stdout);
config.builtin_path = try std.fs.path.join(allocator, &.{ config_path.?, "builtin.zig" });
}
const build_runner_path = if (config.build_runner_path) |p|
try allocator.dupe(u8, p)
else blk: {
var exe_dir_bytes: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const exe_dir_path = try std.fs.selfExeDirPath(&exe_dir_bytes);
break :blk try std.fs.path.resolve(allocator, &[_][]const u8{ exe_dir_path, "build_runner.zig" });
};
const build_runner_cache_path = if (config.build_runner_cache_path) |p|
try allocator.dupe(u8, p)
else blk: {
const cache_dir_path = (try known_folders.getPath(allocator, .cache)) orelse {
logger.warn("Known-folders could not fetch the cache path", .{});
return;
};
defer allocator.free(cache_dir_path);
break :blk try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "zls" });
};
try document_store.init(
allocator,
config.zig_exe_path,
build_runner_path,
build_runner_cache_path,
config.zig_lib_path,
// TODO make this configurable
// We can't figure it out ourselves since we don't know what arguments
// the user will use to run "zig build"
"zig-cache",
// Since we don't compile anything and no packages should put their
// files there this path can be ignored
"ZLS_DONT_CARE",
config.builtin_path,
);
defer document_store.deinit();
// This JSON parser is passed to processJsonRpc and reset.
var json_parser = std.json.Parser.init(allocator, false);
defer json_parser.deinit();
// Arena used for temporary allocations while handling a request
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
while (keep_running) {
const headers = readRequestHeader(arena.allocator(), reader) catch |err| {
logger.err("{s}; exiting!", .{@errorName(err)});
return;
};
const buf = try arena.allocator().alloc(u8, headers.content_length);
try reader.readNoEof(buf);
try processJsonRpc(&arena, &json_parser, buf, config);
json_parser.reset();
arena.deinit();
arena.state = .{};
}
if (builtin_completions) |compls| {
allocator.free(compls);
}
} | src/main.zig |
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
pub fn atan2(comptime T: type, y: T, x: T) T {
return switch (T) {
f32 => atan2_32(y, x),
f64 => atan2_64(y, x),
else => @compileError("atan2 not implemented for " ++ @typeName(T)),
};
}
fn atan2_32(y: f32, x: f32) f32 {
const pi: f32 = 3.1415927410e+00;
const pi_lo: f32 = -8.7422776573e-08;
if (math.isNan(x) or math.isNan(y)) {
return x + y;
}
var ix = @bitCast(u32, x);
var iy = @bitCast(u32, y);
// x = 1.0
if (ix == 0x3F800000) {
return math.atan(y);
}
// 2 * sign(x) + sign(y)
const m = ((iy >> 31) & 1) | ((ix >> 30) & 2);
ix &= 0x7FFFFFFF;
iy &= 0x7FFFFFFF;
if (iy == 0) {
switch (m) {
0, 1 => return y, // atan(+-0, +...)
2 => return pi, // atan(+0, -...)
3 => return -pi, // atan(-0, -...)
else => unreachable,
}
}
if (ix == 0) {
if (m & 1 != 0) {
return -pi / 2;
} else {
return pi / 2;
}
}
if (ix == 0x7F800000) {
if (iy == 0x7F800000) {
switch (m) {
0 => return pi / 4, // atan(+inf, +inf)
1 => return -pi / 4, // atan(-inf, +inf)
2 => return 3 * pi / 4, // atan(+inf, -inf)
3 => return -3 * pi / 4, // atan(-inf, -inf)
else => unreachable,
}
} else {
switch (m) {
0 => return 0.0, // atan(+..., +inf)
1 => return -0.0, // atan(-..., +inf)
2 => return pi, // atan(+..., -inf)
3 => return -pi, // atan(-...f, -inf)
else => unreachable,
}
}
}
// |y / x| > 0x1p26
if (ix + (26 << 23) < iy or iy == 0x7F800000) {
if (m & 1 != 0) {
return -pi / 2;
} else {
return pi / 2;
}
}
// z = atan(|y / x|) with correct underflow
var z = z: {
if ((m & 2) != 0 and iy + (26 << 23) < ix) {
break :z 0.0;
} else {
break :z math.atan(math.fabs(y / x));
}
};
switch (m) {
0 => return z, // atan(+, +)
1 => return -z, // atan(-, +)
2 => return pi - (z - pi_lo), // atan(+, -)
3 => return (z - pi_lo) - pi, // atan(-, -)
else => unreachable,
}
}
fn atan2_64(y: f64, x: f64) f64 {
const pi: f64 = 3.1415926535897931160E+00;
const pi_lo: f64 = 1.2246467991473531772E-16;
if (math.isNan(x) or math.isNan(y)) {
return x + y;
}
var ux = @bitCast(u64, x);
var ix = @intCast(u32, ux >> 32);
var lx = @intCast(u32, ux & 0xFFFFFFFF);
var uy = @bitCast(u64, y);
var iy = @intCast(u32, uy >> 32);
var ly = @intCast(u32, uy & 0xFFFFFFFF);
// x = 1.0
if ((ix -% 0x3FF00000) | lx == 0) {
return math.atan(y);
}
// 2 * sign(x) + sign(y)
const m = ((iy >> 31) & 1) | ((ix >> 30) & 2);
ix &= 0x7FFFFFFF;
iy &= 0x7FFFFFFF;
if (iy | ly == 0) {
switch (m) {
0, 1 => return y, // atan(+-0, +...)
2 => return pi, // atan(+0, -...)
3 => return -pi, // atan(-0, -...)
else => unreachable,
}
}
if (ix | lx == 0) {
if (m & 1 != 0) {
return -pi / 2;
} else {
return pi / 2;
}
}
if (ix == 0x7FF00000) {
if (iy == 0x7FF00000) {
switch (m) {
0 => return pi / 4, // atan(+inf, +inf)
1 => return -pi / 4, // atan(-inf, +inf)
2 => return 3 * pi / 4, // atan(+inf, -inf)
3 => return -3 * pi / 4, // atan(-inf, -inf)
else => unreachable,
}
} else {
switch (m) {
0 => return 0.0, // atan(+..., +inf)
1 => return -0.0, // atan(-..., +inf)
2 => return pi, // atan(+..., -inf)
3 => return -pi, // atan(-...f, -inf)
else => unreachable,
}
}
}
// |y / x| > 0x1p64
if (ix +% (64 << 20) < iy or iy == 0x7FF00000) {
if (m & 1 != 0) {
return -pi / 2;
} else {
return pi / 2;
}
}
// z = atan(|y / x|) with correct underflow
var z = z: {
if ((m & 2) != 0 and iy +% (64 << 20) < ix) {
break :z 0.0;
} else {
break :z math.atan(math.fabs(y / x));
}
};
switch (m) {
0 => return z, // atan(+, +)
1 => return -z, // atan(-, +)
2 => return pi - (z - pi_lo), // atan(+, -)
3 => return (z - pi_lo) - pi, // atan(-, -)
else => unreachable,
}
}
test "math.atan2" {
expect(atan2(f32, 0.2, 0.21) == atan2_32(0.2, 0.21));
expect(atan2(f64, 0.2, 0.21) == atan2_64(0.2, 0.21));
}
test "math.atan2_32" {
const epsilon = 0.000001;
expect(math.approxEq(f32, atan2_32(0.0, 0.0), 0.0, epsilon));
expect(math.approxEq(f32, atan2_32(0.2, 0.2), 0.785398, epsilon));
expect(math.approxEq(f32, atan2_32(-0.2, 0.2), -0.785398, epsilon));
expect(math.approxEq(f32, atan2_32(0.2, -0.2), 2.356194, epsilon));
expect(math.approxEq(f32, atan2_32(-0.2, -0.2), -2.356194, epsilon));
expect(math.approxEq(f32, atan2_32(0.34, -0.4), 2.437099, epsilon));
expect(math.approxEq(f32, atan2_32(0.34, 1.243), 0.267001, epsilon));
}
test "math.atan2_64" {
const epsilon = 0.000001;
expect(math.approxEq(f64, atan2_64(0.0, 0.0), 0.0, epsilon));
expect(math.approxEq(f64, atan2_64(0.2, 0.2), 0.785398, epsilon));
expect(math.approxEq(f64, atan2_64(-0.2, 0.2), -0.785398, epsilon));
expect(math.approxEq(f64, atan2_64(0.2, -0.2), 2.356194, epsilon));
expect(math.approxEq(f64, atan2_64(-0.2, -0.2), -2.356194, epsilon));
expect(math.approxEq(f64, atan2_64(0.34, -0.4), 2.437099, epsilon));
expect(math.approxEq(f64, atan2_64(0.34, 1.243), 0.267001, epsilon));
}
test "math.atan2_32.special" {
const epsilon = 0.000001;
expect(math.isNan(atan2_32(1.0, math.nan(f32))));
expect(math.isNan(atan2_32(math.nan(f32), 1.0)));
expect(atan2_32(0.0, 5.0) == 0.0);
expect(atan2_32(-0.0, 5.0) == -0.0);
expect(math.approxEq(f32, atan2_32(0.0, -5.0), math.pi, epsilon));
//expect(math.approxEq(f32, atan2_32(-0.0, -5.0), -math.pi, epsilon)); TODO support negative zero?
expect(math.approxEq(f32, atan2_32(1.0, 0.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f32, atan2_32(1.0, -0.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f32, atan2_32(-1.0, 0.0), -math.pi / 2.0, epsilon));
expect(math.approxEq(f32, atan2_32(-1.0, -0.0), -math.pi / 2.0, epsilon));
expect(math.approxEq(f32, atan2_32(math.inf(f32), math.inf(f32)), math.pi / 4.0, epsilon));
expect(math.approxEq(f32, atan2_32(-math.inf(f32), math.inf(f32)), -math.pi / 4.0, epsilon));
expect(math.approxEq(f32, atan2_32(math.inf(f32), -math.inf(f32)), 3.0 * math.pi / 4.0, epsilon));
expect(math.approxEq(f32, atan2_32(-math.inf(f32), -math.inf(f32)), -3.0 * math.pi / 4.0, epsilon));
expect(atan2_32(1.0, math.inf(f32)) == 0.0);
expect(math.approxEq(f32, atan2_32(1.0, -math.inf(f32)), math.pi, epsilon));
expect(math.approxEq(f32, atan2_32(-1.0, -math.inf(f32)), -math.pi, epsilon));
expect(math.approxEq(f32, atan2_32(math.inf(f32), 1.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f32, atan2_32(-math.inf(f32), 1.0), -math.pi / 2.0, epsilon));
}
test "math.atan2_64.special" {
const epsilon = 0.000001;
expect(math.isNan(atan2_64(1.0, math.nan(f64))));
expect(math.isNan(atan2_64(math.nan(f64), 1.0)));
expect(atan2_64(0.0, 5.0) == 0.0);
expect(atan2_64(-0.0, 5.0) == -0.0);
expect(math.approxEq(f64, atan2_64(0.0, -5.0), math.pi, epsilon));
//expect(math.approxEq(f64, atan2_64(-0.0, -5.0), -math.pi, epsilon)); TODO support negative zero?
expect(math.approxEq(f64, atan2_64(1.0, 0.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f64, atan2_64(1.0, -0.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f64, atan2_64(-1.0, 0.0), -math.pi / 2.0, epsilon));
expect(math.approxEq(f64, atan2_64(-1.0, -0.0), -math.pi / 2.0, epsilon));
expect(math.approxEq(f64, atan2_64(math.inf(f64), math.inf(f64)), math.pi / 4.0, epsilon));
expect(math.approxEq(f64, atan2_64(-math.inf(f64), math.inf(f64)), -math.pi / 4.0, epsilon));
expect(math.approxEq(f64, atan2_64(math.inf(f64), -math.inf(f64)), 3.0 * math.pi / 4.0, epsilon));
expect(math.approxEq(f64, atan2_64(-math.inf(f64), -math.inf(f64)), -3.0 * math.pi / 4.0, epsilon));
expect(atan2_64(1.0, math.inf(f64)) == 0.0);
expect(math.approxEq(f64, atan2_64(1.0, -math.inf(f64)), math.pi, epsilon));
expect(math.approxEq(f64, atan2_64(-1.0, -math.inf(f64)), -math.pi, epsilon));
expect(math.approxEq(f64, atan2_64(math.inf(f64), 1.0), math.pi / 2.0, epsilon));
expect(math.approxEq(f64, atan2_64(-math.inf(f64), 1.0), -math.pi / 2.0, epsilon));
} | std/math/atan2.zig |
const arm_m = @import("arm_m");
const Pl011 = @import("pl011.zig").Pl011;
const TzMpc = @import("tz_mpc.zig").TzMpc;
const CmsdkTimer = @import("cmsdk_timer.zig").CmsdkTimer;
/// UART 0 (secure) - J10 port
pub const uart0 = Pl011.withBase(0x40200000);
pub const uart0_s = Pl011.withBase(0x50200000); // Secure alias
// CMSDK timer
pub const timer0 = CmsdkTimer.withBase(0x40000000);
pub const timer0_s = CmsdkTimer.withBase(0x50000000); // Secure alias
pub const timer1 = CmsdkTimer.withBase(0x40001000);
pub const timer1_s = CmsdkTimer.withBase(0x50001000); // Secure alias
pub const ssram1_mpc = TzMpc.withBase(0x58007000);
pub const ssram2_mpc = TzMpc.withBase(0x58008000);
pub const ssram3_mpc = TzMpc.withBase(0x58009000);
/// Security Privilege Control Block.
///
/// This is a part of Arm CoreLink SSE-200 Subsystem for Embedded.
pub const Spcb = struct {
base: usize,
const Self = @This();
/// Construct a `Spcb` object using the specified MMIO base address.
pub fn withBase(base: usize) Self {
return Self{ .base = base };
}
/// Secure Privilege Controller Secure Configuration Control register.
pub fn regSpcsecctrl(self: Self) *volatile u32 {
return @intToPtr(*volatile u32, self.base + 0x000);
}
/// Bus Access wait control after reset.
pub fn regBuswait(self: Self) *volatile u32 {
return @intToPtr(*volatile u32, self.base + 0x004);
}
/// Security Violation Response Configuration register.
pub fn regSecrespcfg(self: Self) *volatile u32 {
return @intToPtr(*volatile u32, self.base + 0x010);
}
/// Non Secure Callable Configuration for IDAU.
pub fn regNsccfg(self: Self) *volatile u32 {
return @intToPtr(*volatile u32, self.base + 0x014);
}
pub const NSCCFG_RAMNSC: u32 = 1 << 1;
pub const NSCCFG_CODENSC: u32 = 1 << 0;
/// Non-secure Access AHB slave Peripheral Protection Control #0.
pub fn regAhbnsppcN(self: Self) *volatile [1]u32 {
return @intToPtr(*volatile [1]u32, self.base + 0x050);
}
/// Expansion 0–3 Non-Secure Access AHB slave Peripheral Protection Control.
pub fn regAhbnsppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x060);
}
/// Non-secure Access APB slave Peripheral Protection Control #0–1.
pub fn regApbnsppcN(self: Self) *volatile [2]u32 {
return @intToPtr(*volatile [2]u32, self.base + 0x070);
}
/// Expansion 0–3 Non-Secure Access APB slave Peripheral Protection Control.
pub fn regApbnsppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x080);
}
/// Secure Unprivileged Access AHB slave Peripheral Protection Control #0.
pub fn regAhbsppcN(self: Self) *volatile [1]u32 {
return @intToPtr(*volatile [1]u32, self.base + 0x090);
}
/// Expansion 0–3 Secure Unprivileged Access AHB slave Peripheral Protection Control.
pub fn regAhbsppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x0a0);
}
/// Secure Unprivileged Access APB slave Peripheral Protection Control #0–1.
pub fn regApbsppcN(self: Self) *volatile [2]u32 {
return @intToPtr(*volatile [2]u32, self.base + 0x0b0);
}
/// Expansion 0–3 Secure Unprivileged Access APB slave Peripheral Protection Control.
pub fn regApbsppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x0c0);
}
pub const Bus = enum {
Ahb,
AhbExp,
Apb,
ApbExp,
};
pub const PpcIface = struct {
bus: Bus,
group: usize,
num: usize,
};
pub const PpcAccess = enum {
NonSecure,
SecureUnprivileged,
};
pub fn setPpcAccess(self: Self, iface: PpcIface, access: PpcAccess, allow: bool) void {
const reg = switch (access) {
.NonSecure => switch (iface.bus) {
.Ahb => &self.regAhbnsppcN()[iface.group],
.AhbExp => &self.regAhbnsppcexpN()[iface.group],
.Apb => &self.regApbnsppcN()[iface.group],
.ApbExp => &self.regApbnsppcexpN()[iface.group],
},
.SecureUnprivileged => switch (iface.bus) {
.Ahb => &self.regAhbsppcN()[iface.group],
.AhbExp => &self.regAhbsppcexpN()[iface.group],
.Apb => &self.regApbsppcN()[iface.group],
.ApbExp => &self.regApbsppcexpN()[iface.group],
},
};
if (allow) {
reg.* |= @as(u32, 1) << @intCast(u5, iface.num);
} else {
reg.* &= ~(@as(u32, 1) << @intCast(u5, iface.num));
}
}
};
/// Represents an instance of Security Privilege Control Block.
pub const spcb = Spcb.withBase(0x50080000);
/// Non-Secure Privilege Control Block.
///
/// This is a part of Arm CoreLink SSE-200 Subsystem for Embedded.
pub const Nspcb = struct {
base: usize,
const Self = @This();
/// Construct a `Spcb` object using the specified MMIO base address.
pub fn withBase(base: usize) Self {
return Self{ .base = base };
}
/// Non-secure Access AHB slave Peripheral Protection Control #0.
pub fn regAhbnsppcN(self: Self) *volatile [1]u32 {
return @intToPtr(*volatile [1]u32, self.base + 0x050);
}
/// Non-Secure Unprivileged Access AHB slave Peripheral Protection Control #0.
pub fn regAhbnspppcN(self: Self) *volatile [1]u32 {
return @intToPtr(*volatile [1]u32, self.base + 0x090);
}
/// Expansion 0–3 Non-Secure Unprivileged Access AHB slave Peripheral Protection Control.
pub fn regAhbnspppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x0a0);
}
/// Non-Secure Unprivileged Access APB slave Peripheral Protection Control #0–1.
pub fn regApbnspppcN(self: Self) *volatile [2]u32 {
return @intToPtr(*volatile [2]u32, self.base + 0x0b0);
}
/// Expansion 0–3 Non-Secure Unprivileged Access APB slave Peripheral Protection Control.
pub fn regApbnspppcexpN(self: Self) *volatile [4]u32 {
return @intToPtr(*volatile [4]u32, self.base + 0x0c0);
}
pub const Bus = Spcb.Bus;
pub const PpcIface = Spcb.PpcIface;
pub fn setPpcAccess(self: Self, iface: PpcIface, allow: bool) void {
const reg = switch (iface.bus) {
.Ahb => &self.regAhbnspppcN()[iface.group],
.AhbExp => &self.regAhbnspppcexpN()[iface.group],
.Apb => &self.regApbnspppcN()[iface.group],
.ApbExp => &self.regApbnspppcexpN()[iface.group],
};
if (allow) {
reg.* |= @as(u32, 1) << @intCast(u5, iface.num);
} else {
reg.* &= ~(@as(u32, 1) << @intCast(u5, iface.num));
}
}
};
/// Represents an instance of Non-Secure Privilege Control Block.
pub const nspcb = Nspcb.withBase(0x40080000);
/// Represents peripherals controlled by PPC.
///
/// Each constant is of type `Spcb.PpcIface` and can be passed to
/// `spcb.setPpcAccess` to allow or disallow Non-Secure or Secure unprivileged
/// access to the connected peripheral.
pub const ppc = struct {
fn iface(bus: Spcb.Bus, group: usize, num: usize) Spcb.PpcIface {
return Spcb.PpcIface{ .bus = bus, .group = group, .num = num };
}
pub const timer0_ = iface(.Apb, 0, 0);
pub const timer1_ = iface(.Apb, 0, 1);
pub const dual_timer_ = iface(.Apb, 0, 2);
pub const mhu0 = iface(.Apb, 0, 3);
pub const mhu1 = iface(.Apb, 0, 4);
pub const s32k_timer = iface(.Apb, 1, 0);
};
/// Represents expansion peripherals controlled by PPC.
///
/// Each constant is of type `Spcb.PpcIface` and can be passed to
/// `spcb.setPpcAccess` to allow or disallow Non-Secure or Secure unprivileged
/// access to the connected peripheral.
pub const ppc_exp = struct {
fn iface(bus: Spcb.Bus, group: usize, num: usize) Spcb.PpcIface {
return Spcb.PpcIface{ .bus = bus, .group = group, .num = num };
}
pub const ssram1_mpc = iface(.ApbExp, 0, 0);
pub const ssram2_mpc = iface(.ApbExp, 0, 1);
pub const ssram3_mpc = iface(.ApbExp, 0, 2);
pub const spi0 = iface(.ApbExp, 1, 0);
pub const spi1 = iface(.ApbExp, 1, 1);
pub const spi2 = iface(.ApbExp, 1, 2);
pub const spi3 = iface(.ApbExp, 1, 3);
pub const spi4 = iface(.ApbExp, 1, 4);
pub const uart0 = iface(.ApbExp, 1, 5);
pub const uart1 = iface(.ApbExp, 1, 6);
pub const uart2 = iface(.ApbExp, 1, 7);
pub const uart3 = iface(.ApbExp, 1, 8);
pub const uart4 = iface(.ApbExp, 1, 9);
pub const i2c0 = iface(.ApbExp, 1, 10);
pub const i2c1 = iface(.ApbExp, 1, 11);
pub const i2c2 = iface(.ApbExp, 1, 12);
pub const i2c3 = iface(.ApbExp, 1, 13);
pub const scc = iface(.ApbExp, 2, 0);
pub const audio = iface(.ApbExp, 2, 1);
pub const fpgaio = iface(.ApbExp, 2, 2);
pub const vga = iface(.AhbExp, 0, 0);
pub const gpio0 = iface(.AhbExp, 0, 1);
pub const gpio1 = iface(.AhbExp, 0, 2);
pub const gpio2 = iface(.AhbExp, 0, 3);
pub const gpio3 = iface(.AhbExp, 0, 4);
pub const dma0 = iface(.AhbExp, 1, 0);
pub const dma1 = iface(.AhbExp, 1, 1);
pub const dma2 = iface(.AhbExp, 1, 2);
pub const dma3 = iface(.AhbExp, 1, 3);
};
/// The number of hardware interrupt lines.
pub const num_irqs = 124;
pub const irqs = struct {
pub const Timer0_IRQn = arm_m.irqs.interruptIRQn(3);
pub const Timer1_IRQn = arm_m.irqs.interruptIRQn(4);
pub const DualTimer_IRQn = arm_m.irqs.interruptIRQn(5);
/// Get the descriptive name of an exception number. Returns `null` if
/// the exception number is not known by this module.
pub fn getName(comptime i: usize) ?[]const u8 {
switch (i) {
Timer0_IRQn => return "Timer0",
Timer1_IRQn => return "Timer1",
DualTimer_IRQn => return "DualTimer",
else => return arm_m.irqs.getName(i),
}
}
}; | examples/drivers/an505.zig |
const std = @import("std");
const zang = @import("zang");
const common = @import("common.zig");
const c = @import("common/c.zig");
pub const AUDIO_FORMAT: zang.AudioFormat = .signed16_lsb;
pub const AUDIO_SAMPLE_RATE = 48000;
pub const AUDIO_BUFFER_SIZE = 1024;
pub const DESCRIPTION =
\\example_two
\\
\\A single instrument triggered by two input sources.
\\Play the lower half of the keyboard to control the
\\note frequency. Press the number keys to change the
\\"colour" of the oscillator - from triangle to
\\sawtooth. Both input sources trigger the envelope.
;
const a4 = 880.0;
pub const MainModule = struct {
pub const num_outputs = 2;
pub const num_temps = 2;
pub const output_audio = common.AudioOut{ .mono = 0 };
pub const output_visualize = 0;
pub const output_sync_oscilloscope = 1;
pub const Params0 = struct { freq: f32, note_on: bool };
pub const Params1 = struct { color: f32, note_on: bool };
first: bool,
osc: zang.TriSawOsc,
env: zang.Envelope,
key0: ?i32,
iq0: zang.Notes(Params0).ImpulseQueue,
idgen0: zang.IdGenerator,
trig0: zang.Trigger(Params0),
key1: ?i32,
iq1: zang.Notes(Params1).ImpulseQueue,
idgen1: zang.IdGenerator,
trig1: zang.Trigger(Params1),
pub fn init() MainModule {
return .{
.first = true,
.osc = zang.TriSawOsc.init(),
.env = zang.Envelope.init(),
.key0 = null,
.iq0 = zang.Notes(Params0).ImpulseQueue.init(),
.idgen0 = zang.IdGenerator.init(),
.trig0 = zang.Trigger(Params0).init(),
.key1 = null,
.iq1 = zang.Notes(Params1).ImpulseQueue.init(),
.idgen1 = zang.IdGenerator.init(),
.trig1 = zang.Trigger(Params1).init(),
};
}
pub fn paint(
self: *MainModule,
span: zang.Span,
outputs: [num_outputs][]f32,
temps: [num_temps][]f32,
) void {
if (self.first) {
self.first = false;
self.iq0.push(0, self.idgen0.nextId(), .{
.freq = a4 * 0.5,
.note_on = false,
});
self.iq1.push(0, self.idgen1.nextId(), .{
.color = 0.5,
.note_on = false,
});
}
zang.zero(span, temps[0]);
zang.zero(span, temps[1]);
// note: this can be promoted to a library feature if i ever find a
// non-dubious use for it.
// as a library feature it would probably take the form of a new
// iterator that consumes two source iterators (ctr0 and ctr1).
// it could probably be made general to any number of source iterators.
// what to do with note_on and note_id_changed is not obvious...
var ctr0 = self.trig0.counter(span, self.iq0.consume());
var ctr1 = self.trig1.counter(span, self.iq1.consume());
var maybe_result0 = self.trig0.next(&ctr0);
var maybe_result1 = self.trig1.next(&ctr1);
var start = span.start;
while (start < span.end) {
// only paint if both impulse queues are active
if (maybe_result0) |result0| {
if (maybe_result1) |result1| {
const inner_span: zang.Span = .{
.start = start,
.end = std.math.min(result0.span.end, result1.span.end),
};
zang.addScalarInto(inner_span, outputs[1], result0.params.freq);
self.osc.paint(
inner_span,
.{temps[0]},
.{},
false,
.{
.sample_rate = AUDIO_SAMPLE_RATE,
.freq = zang.constant(result0.params.freq),
.color = result1.params.color,
},
);
self.env.paint(
inner_span,
.{temps[1]},
.{},
// only reset the envelope when a button is depressed when
// no buttons were previous depressed
(result0.note_id_changed and result0.params.note_on and
!result1.note_id_changed) or (result1.note_id_changed and result1.params.note_on and
!result0.note_id_changed),
.{
.sample_rate = AUDIO_SAMPLE_RATE,
.attack = .{ .cubed = 0.025 },
.decay = .{ .cubed = 0.1 },
.release = .{ .cubed = 1.0 },
.sustain_volume = 0.5,
.note_on = result0.params.note_on or result1.params.note_on,
},
);
if (result0.span.end == inner_span.end) {
maybe_result0 = self.trig0.next(&ctr0);
}
if (result1.span.end == inner_span.end) {
maybe_result1 = self.trig1.next(&ctr1);
}
start = inner_span.end;
continue;
}
}
break;
}
zang.multiply(span, outputs[0], temps[0], temps[1]);
}
pub fn keyEvent(self: *MainModule, key: i32, down: bool, impulse_frame: usize) bool {
if (common.getKeyRelFreqFromRow(0, key)) |rel_freq| {
if (down or (if (self.key0) |nh| nh == key else false)) {
self.key0 = if (down) key else null;
self.iq0.push(impulse_frame, self.idgen0.nextId(), .{
.freq = a4 * rel_freq,
.note_on = down,
});
}
}
if (key >= c.SDLK_1 and key <= c.SDLK_9) {
const f = @intToFloat(f32, key - c.SDLK_1) /
@intToFloat(f32, c.SDLK_9 - c.SDLK_1);
if (down or (if (self.key1) |nh| nh == key else false)) {
self.key1 = if (down) key else null;
self.iq1.push(impulse_frame, self.idgen1.nextId(), .{
.color = 0.5 + std.math.sqrt(f) * 0.5,
.note_on = down,
});
}
}
return true;
}
}; | examples/example_two.zig |
const PortIO = @import("io.zig").PortIO;
/// Programmable Interrupt Controller 8259
pub const IRQ_TIMER = 0x01;
pub const IRQ_KBD = 0x02;
pub const IRQ_CASCADE = 0x04;
pub const IRQ_COM2 = 0x08;
pub const IRQ_COM1 = 0x10;
pub const IRQ_LPT2 = 0x20;
pub const IRQ_FLOPPY = 0x40;
pub const IRQ_LPT1 = 0x80;
pub const PICChip = enum {
master,
slave,
pub fn command(pic: PICChip) u16 {
return switch (pic) {
.master => 0x20,
.slave => 0xA0,
};
}
pub fn data(pic: PICChip) u16 {
return switch (pic) {
.master => 0x21,
.slave => 0xA1,
};
}
};
const ICW1_ICW4 = 0x01; // ICW4 (not) needed
const ICW1_SINGLE = 0x02; // Single (cascade) mode
const ICW1_INTERVAL4 = 0x04; // Call address interval 4 (8)
const ICW1_LEVEL = 0x08; // Level triggered (edge) mode
const ICW1_INIT = 0x10; // Initialization - required!
const ICW4_8086 = 0x01; // 8086/88 (MCS-80/85) mode
const ICW4_AUTO = 0x02; // Auto (normal) EOI
const ICW4_BUF_SLAVE = 0x08; // Buffered mode/slave
const ICW4_BUF_MASTER = 0x0C; // Buffered mode/master
const ICW4_SFNM = 0x10; // Special fully nested (not)
// vector offset
pub var offset = [2]u8 {0x08, 0x70};
pub fn remap(pic: PICChip, new_offset: u8) void {
const mask = PortIO.in(u8, pic.data());
// starts the initialization sequence (in cascade mode)
PortIO.out(u8, pic.command(), ICW1_INIT | ICW1_ICW4);
some_delay();
PortIO.out(u8, pic.data(), new_offset);
some_delay();
switch (pic) {
.master => PortIO.out(u8, pic.data(), 4),
.slave => PortIO.out(u8, pic.data(), 2),
}
some_delay();
PortIO.out(u8, pic.data(), ICW4_AUTO);
some_delay();
// restore saved mask
PortIO.out(u8, pic.data(), mask);
// set vector offset
switch (pic) {
.master => offset[0] = new_offset,
.slave => offset[1] = new_offset,
}
}
pub fn get_mask(pic: PICChip) u8 {
return PortIO.in(u8, pic.data());
}
pub fn set_mask(pic: PICChip, mask: u8) void {
PortIO.out(u8, pic.data(), mask);
some_delay();
}
pub fn eoi(pic: PICChip) void {
const master = PICChip.master;
const slave = PICChip.slave;
switch (pic) {
.master => PortIO.out(u8, master.command(), 0x20),
.slave => {
PortIO.out(u8, master.command(), 0x20);
PortIO.out(u8, slave.command(), 0x20);
},
}
some_delay();
}
fn some_delay() void {
var i: usize = 60000;
while (i != 0) : (i -= 1) {
asm volatile ("nop");
}
} | src/pic.zig |
pub const MS_SHOWMAGNIFIEDCURSOR = @as(i32, 1);
pub const MS_CLIPAROUNDCURSOR = @as(i32, 2);
pub const MS_INVERTCOLORS = @as(i32, 4);
pub const MW_FILTERMODE_EXCLUDE = @as(u32, 0);
pub const MW_FILTERMODE_INCLUDE = @as(u32, 1);
//--------------------------------------------------------------------------------
// Section: Types (4)
//--------------------------------------------------------------------------------
pub const MAGTRANSFORM = extern struct {
v: [9]f32,
};
pub const MAGIMAGEHEADER = extern struct {
width: u32,
height: u32,
format: Guid,
stride: u32,
offset: u32,
cbSize: usize,
};
pub const MAGCOLOREFFECT = extern struct {
transform: [25]f32,
};
pub const MagImageScalingCallback = fn(
hwnd: ?HWND,
srcdata: ?*anyopaque,
srcheader: MAGIMAGEHEADER,
destdata: ?*anyopaque,
destheader: MAGIMAGEHEADER,
unclipped: RECT,
clipped: RECT,
dirty: ?HRGN,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Functions (19)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagInitialize(
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagUninitialize(
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagSetWindowSource(
hwnd: ?HWND,
rect: RECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagGetWindowSource(
hwnd: ?HWND,
pRect: ?*RECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagSetWindowTransform(
hwnd: ?HWND,
pTransform: ?*MAGTRANSFORM,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagGetWindowTransform(
hwnd: ?HWND,
pTransform: ?*MAGTRANSFORM,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagSetWindowFilterList(
hwnd: ?HWND,
dwFilterMode: u32,
count: i32,
pHWND: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagGetWindowFilterList(
hwnd: ?HWND,
pdwFilterMode: ?*u32,
count: i32,
pHWND: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) i32;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagSetImageScalingCallback(
hwnd: ?HWND,
callback: ?MagImageScalingCallback,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagGetImageScalingCallback(
hwnd: ?HWND,
) callconv(@import("std").os.windows.WINAPI) ?MagImageScalingCallback;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagSetColorEffect(
hwnd: ?HWND,
pEffect: ?*MAGCOLOREFFECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "MAGNIFICATION" fn MagGetColorEffect(
hwnd: ?HWND,
pEffect: ?*MAGCOLOREFFECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagSetFullscreenTransform(
magLevel: f32,
xOffset: i32,
yOffset: i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagGetFullscreenTransform(
pMagLevel: ?*f32,
pxOffset: ?*i32,
pyOffset: ?*i32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagSetFullscreenColorEffect(
pEffect: ?*MAGCOLOREFFECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagGetFullscreenColorEffect(
pEffect: ?*MAGCOLOREFFECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagSetInputTransform(
fEnabled: BOOL,
pRectSource: ?*const RECT,
pRectDest: ?*const RECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagGetInputTransform(
pfEnabled: ?*BOOL,
pRectSource: ?*RECT,
pRectDest: ?*RECT,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "MAGNIFICATION" fn MagShowSystemCursor(
fShowCursor: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (5)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOL = @import("../foundation.zig").BOOL;
const HRGN = @import("../graphics/gdi.zig").HRGN;
const HWND = @import("../foundation.zig").HWND;
const RECT = @import("../foundation.zig").RECT;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "MagImageScalingCallback")) { _ = MagImageScalingCallback; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/ui/magnification.zig |
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const log = std.log;
const testing = std.testing;
const Allocator = mem.Allocator;
const AutoHashMap = std.AutoHashMap;
const StaticBitSet = std.StaticBitSet;
const readInput = @import("parser.zig").readInput;
const grid = @import("grid.zig");
const Grid = grid.Grid;
const Empty = struct {};
pub fn part1() !usize {
var fixed_buffer_mem: [10 * 1024]u8 = undefined;
var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
var old: Grid = readInput();
var seen = AutoHashMap(Grid, Empty).init(fixed_allocator.allocator());
try seen.put(old, Empty{});
while (true) {
var new = old;
var i: usize = 0;
while (i < grid.row_count) : (i += 1) {
var j: usize = 0;
while (j < grid.col_count) : (j += 1) {
const neighbor_bugs = countNeighborBugs(old, i, j);
if (new.isBug(i, j)) {
// A bug *dies* (becoming an empty space) unless there is *exactly one* bug adjacent to it.
if (neighbor_bugs != 1) {
new.clearBug(i, j);
}
} else {
// An empty space *becomes infested* with a bug if *exactly one or two* bugs are adjacent to it.
if (neighbor_bugs == 1 or neighbor_bugs == 2) {
new.setBug(i, j);
}
}
}
}
var gop = try seen.getOrPut(new);
if (gop.found_existing) {
// watch for the first time a layout of bugs and empty spaces *matches any previous layout*
return biodiversityRating(new);
}
gop.value_ptr.* = Empty{};
old = new;
}
unreachable;
}
inline fn countNeighborBugs(g: Grid, row: usize, col: usize) usize {
var count: usize = 0;
// Tiles on the edges of the grid have fewer than four adjacent tiles; the missing tiles count as empty space.
// east
if (col + 1 < grid.col_count and g.isBug(row, col + 1)) {
count += 1;
}
// south
if (row + 1 < grid.row_count and g.isBug(row + 1, col)) {
count += 1;
}
// west
if (col > 0 and g.isBug(row, col - 1)) {
count += 1;
}
// north
if (row > 0 and g.isBug(row - 1, col)) {
count += 1;
}
return count;
}
inline fn biodiversityRating(g: Grid) u64 {
var sum: u64 = 0;
var i: u6 = 0;
while (i < @intCast(u6, grid.row_count * grid.col_count)) : (i += 1) {
if (g.bs.isSet(i)) {
sum += @as(u64, 1) << i;
}
}
return sum;
}
pub fn part2() !usize {
const maxRounds = 200;
// in each round, we can grow by at most one dimension in both directions because new Grids can only arise from Grids with bugs
var grids_alpha: [2 * maxRounds]Grid = undefined;
var grids_beta: [2 * maxRounds]Grid = undefined;
const base_level = maxRounds; // level 0
// if true, then grids_alpha contains the most recent version of all grids
var active_alpha = true;
var min_level: usize = base_level; // the minimum level at which bugs exist
var max_level: usize = base_level; // the maximum level at which bugs exist
{
// init grids
var i: usize = 0;
while (i < grids_alpha.len) : (i += 1) {
// Initially, no other levels contain bugs.
grids_alpha[i] = Grid.init();
}
grids_alpha[base_level] = readInput();
}
var round: usize = 1;
while (round <= @as(usize, maxRounds)) : (round += 1) {
log.debug("round {d} starts. min_level: {d}, max_level: {d}", .{ round, min_level, max_level });
var active_grids: []Grid = undefined;
var inactive_grids: []Grid = undefined;
if (active_alpha) {
active_grids = grids_alpha[0..];
inactive_grids = grids_beta[0..];
} else {
active_grids = grids_beta[0..];
inactive_grids = grids_alpha[0..];
}
// create copy
// TODO: only copy from min to max
mem.copy(Grid, inactive_grids, active_grids);
var new_min_level = if (min_level > 0) min_level - 1 else 0;
var new_max_level = std.math.min(max_level + 1, active_grids.len - 1);
var lvl: usize = new_min_level;
while (lvl <= new_max_level) : (lvl += 1) {
// process each grid in each dimension
var i: usize = 0;
while (i < grid.row_count) : (i += 1) {
var j: usize = 0;
while (j < grid.col_count) : (j += 1) {
if (i == grid.center and j == grid.center) {
continue;
}
const neighbor_bugs = try countNeighborBugsRec(active_grids, lvl, i, j);
log.debug("layer {d}: ({d}, {d}) has {d} neighbors", .{ @intCast(i64, lvl) - @intCast(i64, base_level), i, j, neighbor_bugs });
if (active_grids[lvl].isBug(i, j)) {
// A bug *dies* (becoming an empty space) unless there is *exactly one* bug adjacent to it.
if (neighbor_bugs != 1) {
log.debug("lvl {d}: bug at ({d}, {d}) dies", .{ lvl, i, j });
inactive_grids[lvl].clearBug(i, j);
}
} else {
// An empty space *becomes infested* with a bug if *exactly one or two* bugs are adjacent to it.
if (neighbor_bugs == 1 or neighbor_bugs == 2) {
log.debug("lvl {d}: creating bug at ({d}, {d})", .{ lvl, i, j });
inactive_grids[lvl].setBug(i, j);
}
}
}
// The middle tile of your scan is empty to accommodate the recursive grids within it. I
debug.assert(inactive_grids[lvl].isBug(grid.center, grid.center) == false);
}
}
// update min_level
if (inactive_grids[new_min_level].countBugs() > 0) {
min_level = new_min_level;
}
// update max_level
if (inactive_grids[new_max_level].countBugs() > 0) {
max_level = new_max_level;
}
active_alpha = !active_alpha;
}
const active_grids = if (active_alpha) grids_alpha[0..] else grids_beta[0..];
return countBugsRec(active_grids, base_level, min_level, max_level);
}
fn countNeighborBugsRec(grids: []const Grid, lvl: usize, row: usize, col: usize) !usize {
const irow = @intCast(i64, row);
const icol = @intCast(i64, col);
const neighbors = [_][2]i64{
[_]i64{ irow - 1, icol }, // north
[_]i64{ irow, icol + 1 }, // east
[_]i64{ irow + 1, icol }, // south
[_]i64{ irow, icol - 1 }, // west
};
const center = grid.center;
var sum: usize = 0;
const myself = grids[lvl];
log.debug("checking neighbors: lvl: {d}, row: {d}, col: {d}", .{ lvl, row, col });
for (neighbors) |nb| {
const nb_row = nb[0];
const nb_col = nb[1];
if (nb_row < 0) {
// has neighbors in lvl-1
if (lvl == 0) {
return error.ParentMissing;
}
const parent_grid = grids[lvl - 1];
if (parent_grid.isBug(center - 1, center)) {
sum += 1;
}
} else if (nb_row >= grid.row_count) {
// has neighbors in lvl-1
if (lvl == 0) {
return error.ParentMissing;
}
const parent_grid = grids[lvl - 1];
if (parent_grid.isBug(center + 1, center)) {
sum += 1;
}
} else if (nb_col < 0) {
// has neighbors in lvl-1
if (lvl == 0) {
return error.ParentMissing;
}
const parent_grid = grids[lvl - 1];
if (parent_grid.isBug(center, center - 1)) {
sum += 1;
}
} else if (nb_col >= grid.col_count) {
// has neighbors in lvl-1
if (lvl == 0) {
return error.ParentMissing;
}
const parent_grid = grids[lvl - 1];
if (parent_grid.isBug(center, center + 1)) {
sum += 1;
}
} else if (nb_row == center and nb_col == center) {
// has neighbors in lvl+1
if (lvl + 1 >= grids.len) {
return error.ChildMissing;
}
const child_grid = grids[lvl + 1];
// which row or column do we have to check in child grid?
if (row == center - 1 and col == center) {
log.debug("lvl {d} checking child grid north row", .{lvl});
sum += child_grid.countBugsRow(0);
} else if (row == center + 1 and col == center) {
log.debug("lvl {d} checking child grid south row", .{lvl});
sum += child_grid.countBugsRow(grid.row_count - 1);
} else if (row == center and col == center - 1) {
log.debug("lvl {d} checking child grid west col", .{lvl});
sum += child_grid.countBugsCol(0);
} else if (row == center and col == center + 1) {
log.debug("lvl {d} checking child grid east col", .{lvl});
sum += child_grid.countBugsCol(grid.col_count - 1);
}
} else {
// neighbor is in our grid
if (myself.isBug(@intCast(usize, nb_row), @intCast(usize, nb_col))) {
sum += 1;
}
}
}
return sum;
}
fn countBugsRec(grids: []const Grid, center: usize, min_level: usize, max_level: usize) usize {
var sum: usize = 0;
// count bugs
var i: usize = min_level;
while (i <= max_level) : (i += 1) {
const bugs = grids[i].countBugs();
const level: i64 = @intCast(i64, i) - @intCast(i64, center);
log.debug("level {d} has bugs: {d}", .{ level, bugs });
sum += bugs;
}
return sum;
}
test "2019 Day 24, Part 1" {
const answer = try part1();
try testing.expectEqual(@as(usize, 19923473), answer);
}
test "2019 Day 24, Part 2" {
const answer = try part2();
try testing.expectEqual(@as(usize, 1902), answer);
}
test "countNeighborBugsRec" {
// ....#
// #..#.
// #..##
// ..#..
// #....
var g = Grid.init();
g.setBug(0, 4);
g.setBug(1, 0);
g.setBug(1, 3);
g.setBug(2, 0);
g.setBug(2, 3);
g.setBug(2, 4);
g.setBug(3, 2);
g.setBug(4, 0);
const grids = [_]Grid{
Grid.init(),
Grid.init(),
g,
Grid.init(),
Grid.init(),
};
const center = 2;
const test_cases = [_][4]usize{
// lvl, row, col, expected
[_]usize{ center - 1, 1, 2, 1 },
[_]usize{ center - 1, 2, 1, 3 },
[_]usize{ center - 1, 3, 2, 1 },
[_]usize{ center, 0, 0, 1 },
[_]usize{ center, 0, 3, 2 },
[_]usize{ center, 1, 0, 1 },
[_]usize{ center, 1, 1, 1 },
[_]usize{ center, 1, 2, 1 },
[_]usize{ center, 1, 3, 1 },
[_]usize{ center, 1, 4, 3 },
[_]usize{ center, 2, 0, 1 },
[_]usize{ center, 2, 1, 1 },
[_]usize{ center, 2, 3, 2 },
[_]usize{ center, 2, 4, 1 },
[_]usize{ center, 3, 0, 2 },
[_]usize{ center, 3, 1, 1 },
[_]usize{ center, 3, 3, 2 },
[_]usize{ center, 3, 4, 1 },
[_]usize{ center, 4, 1, 1 },
[_]usize{ center, 4, 2, 1 },
[_]usize{ center + 1, 0, 4, 1 },
[_]usize{ center + 1, 1, 4, 1 },
[_]usize{ center + 1, 2, 4, 1 },
[_]usize{ center + 1, 3, 4, 1 },
[_]usize{ center + 1, 4, 0, 1 },
[_]usize{ center + 1, 4, 1, 1 },
[_]usize{ center + 1, 4, 2, 1 },
[_]usize{ center + 1, 4, 3, 1 },
[_]usize{ center + 1, 4, 4, 2 },
};
for (test_cases) |tc| {
log.debug("tc {d}", .{tc});
try testing.expectEqual(tc[3], try countNeighborBugsRec(grids[0..], tc[0], tc[1], tc[2]));
}
} | day24/src/solve.zig |
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
const linux = std.os.linux;
const SYS = linux.SYS;
const socklen_t = linux.socklen_t;
const iovec = std.os.iovec;
const iovec_const = std.os.iovec_const;
const uid_t = linux.uid_t;
const gid_t = linux.gid_t;
const pid_t = linux.pid_t;
const stack_t = linux.stack_t;
const sigset_t = linux.sigset_t;
const sockaddr = linux.sockaddr;
const timespec = linux.timespec;
pub fn syscall0(number: SYS) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
: "memory"
);
}
pub fn syscall1(number: SYS, arg1: usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
: "memory"
);
}
pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
: "memory"
);
}
pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3),
: "memory"
);
}
pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4),
: "memory"
);
}
pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4),
[arg5] "{edi}" (arg5),
: "memory"
);
}
pub fn syscall6(
number: SYS,
arg1: usize,
arg2: usize,
arg3: usize,
arg4: usize,
arg5: usize,
arg6: usize,
) usize {
// The 6th argument is passed via memory as we're out of registers if ebp is
// used as frame pointer. We push arg6 value on the stack before changing
// ebp or esp as the compiler may reference it as an offset relative to one
// of those two registers.
return asm volatile (
\\ push %[arg6]
\\ push %%ebp
\\ mov 4(%%esp), %%ebp
\\ int $0x80
\\ pop %%ebp
\\ add $4, %%esp
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
[arg3] "{edx}" (arg3),
[arg4] "{esi}" (arg4),
[arg5] "{edi}" (arg5),
[arg6] "rm" (arg6),
: "memory"
);
}
pub fn socketcall(call: usize, args: [*]usize) usize {
return asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize),
: [number] "{eax}" (@enumToInt(SYS.socketcall)),
[arg1] "{ebx}" (call),
[arg2] "{ecx}" (@ptrToInt(args)),
: "memory"
);
}
/// This matches the libc clone function.
pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
pub fn restore() callconv(.Naked) void {
return asm volatile ("int $0x80"
:
: [number] "{eax}" (@enumToInt(SYS.sigreturn)),
: "memory"
);
}
pub fn restore_rt() callconv(.Naked) void {
return asm volatile ("int $0x80"
:
: [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)),
: "memory"
);
}
pub const O = struct {
pub const CREAT = 0o100;
pub const EXCL = 0o200;
pub const NOCTTY = 0o400;
pub const TRUNC = 0o1000;
pub const APPEND = 0o2000;
pub const NONBLOCK = 0o4000;
pub const DSYNC = 0o10000;
pub const SYNC = 0o4010000;
pub const RSYNC = 0o4010000;
pub const DIRECTORY = 0o200000;
pub const NOFOLLOW = 0o400000;
pub const CLOEXEC = 0o2000000;
pub const ASYNC = 0o20000;
pub const DIRECT = 0o40000;
pub const LARGEFILE = 0o100000;
pub const NOATIME = 0o1000000;
pub const PATH = 0o10000000;
pub const TMPFILE = 0o20200000;
pub const NDELAY = NONBLOCK;
};
pub const F = struct {
pub const DUPFD = 0;
pub const GETFD = 1;
pub const SETFD = 2;
pub const GETFL = 3;
pub const SETFL = 4;
pub const SETOWN = 8;
pub const GETOWN = 9;
pub const SETSIG = 10;
pub const GETSIG = 11;
pub const GETLK = 12;
pub const SETLK = 13;
pub const SETLKW = 14;
pub const SETOWN_EX = 15;
pub const GETOWN_EX = 16;
pub const GETOWNER_UIDS = 17;
pub const RDLCK = 0;
pub const WRLCK = 1;
pub const UNLCK = 2;
};
pub const LOCK = struct {
pub const SH = 1;
pub const EX = 2;
pub const NB = 4;
pub const UN = 8;
};
pub const MAP = struct {
pub const NORESERVE = 0x4000;
pub const GROWSDOWN = 0x0100;
pub const DENYWRITE = 0x0800;
pub const EXECUTABLE = 0x1000;
pub const LOCKED = 0x2000;
pub const @"32BIT" = 0x40;
};
pub const MMAP2_UNIT = 4096;
pub const VDSO = struct {
pub const CGT_SYM = "__vdso_clock_gettime";
pub const CGT_VER = "LINUX_2.6";
};
pub const ARCH = struct {};
pub const Flock = extern struct {
type: i16,
whence: i16,
start: off_t,
len: off_t,
pid: pid_t,
};
pub const msghdr = extern struct {
name: ?*sockaddr,
namelen: socklen_t,
iov: [*]iovec,
iovlen: i32,
control: ?*anyopaque,
controllen: socklen_t,
flags: i32,
};
pub const msghdr_const = extern struct {
name: ?*const sockaddr,
namelen: socklen_t,
iov: [*]iovec_const,
iovlen: i32,
control: ?*anyopaque,
controllen: socklen_t,
flags: i32,
};
pub const blksize_t = i32;
pub const nlink_t = u32;
pub const time_t = isize;
pub const mode_t = u32;
pub const off_t = i64;
pub const ino_t = u64;
pub const dev_t = u64;
pub const blkcnt_t = i64;
// The `stat` definition used by the Linux kernel.
pub const Stat = extern struct {
dev: dev_t,
__dev_padding: u32,
__ino_truncated: u32,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__rdev_padding: u32,
size: off_t,
blksize: blksize_t,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
ino: ino_t,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
};
pub const timeval = extern struct {
tv_sec: i32,
tv_usec: i32,
};
pub const timezone = extern struct {
tz_minuteswest: i32,
tz_dsttime: i32,
};
pub const mcontext_t = extern struct {
gregs: [19]usize,
fpregs: [*]u8,
oldmask: usize,
cr2: usize,
};
pub const REG = struct {
pub const GS = 0;
pub const FS = 1;
pub const ES = 2;
pub const DS = 3;
pub const EDI = 4;
pub const ESI = 5;
pub const EBP = 6;
pub const ESP = 7;
pub const EBX = 8;
pub const EDX = 9;
pub const ECX = 10;
pub const EAX = 11;
pub const TRAPNO = 12;
pub const ERR = 13;
pub const EIP = 14;
pub const CS = 15;
pub const EFL = 16;
pub const UESP = 17;
pub const SS = 18;
};
pub const ucontext_t = extern struct {
flags: usize,
link: ?*ucontext_t,
stack: stack_t,
mcontext: mcontext_t,
sigmask: sigset_t,
regspace: [64]u64,
};
pub const Elf_Symndx = u32;
pub const user_desc = packed struct {
entry_number: u32,
base_addr: u32,
limit: u32,
seg_32bit: u1,
contents: u2,
read_exec_only: u1,
limit_in_pages: u1,
seg_not_present: u1,
useable: u1,
};
/// socketcall() call numbers
pub const SC = struct {
pub const socket = 1;
pub const bind = 2;
pub const connect = 3;
pub const listen = 4;
pub const accept = 5;
pub const getsockname = 6;
pub const getpeername = 7;
pub const socketpair = 8;
pub const send = 9;
pub const recv = 10;
pub const sendto = 11;
pub const recvfrom = 12;
pub const shutdown = 13;
pub const setsockopt = 14;
pub const getsockopt = 15;
pub const sendmsg = 16;
pub const recvmsg = 17;
pub const accept4 = 18;
pub const recvmmsg = 19;
pub const sendmmsg = 20;
}; | lib/std/os/linux/i386.zig |
const std = @import("std");
const math = std.math;
const common = @import("common.zig");
const FloatStream = @import("FloatStream.zig");
const isEightDigits = @import("common.zig").isEightDigits;
const mantissaType = common.mantissaType;
// Arbitrary-precision decimal class for fallback algorithms.
//
// This is only used if the fast-path (native floats) and
// the Eisel-Lemire algorithm are unable to unambiguously
// determine the float.
//
// The technique used is "Simple Decimal Conversion", developed
// by <NAME> and <NAME>. A detailed description of the
// algorithm can be found in "ParseNumberF64 by Simple Decimal Conversion",
// available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.
//
// Big-decimal implementation. We do not use the big.Int routines since we only require a maximum
// fixed region of memory. Further, we require only a small subset of operations.
//
// This accepts a floating point parameter and will generate a Decimal which can correctly parse
// the input with sufficient accuracy. Internally this means either a u64 mantissa (f16, f32 or f64)
// or a u128 mantissa (f128).
pub fn Decimal(comptime T: type) type {
const MantissaT = mantissaType(T);
std.debug.assert(MantissaT == u64 or MantissaT == u128);
return struct {
const Self = @This();
/// The maximum number of digits required to unambiguously round a float.
///
/// For a double-precision IEEE-754 float, this required 767 digits,
/// so we store the max digits + 1.
///
/// We can exactly represent a float in radix `b` from radix 2 if
/// `b` is divisible by 2. This function calculates the exact number of
/// digits required to exactly represent that float.
///
/// According to the "Handbook of Floating Point Arithmetic",
/// for IEEE754, with emin being the min exponent, p2 being the
/// precision, and b being the radix, the number of digits follows as:
///
/// `−emin + p2 + ⌊(emin + 1) log(2, b) − log(1 − 2^(−p2), b)⌋`
///
/// For f32, this follows as:
/// emin = -126
/// p2 = 24
///
/// For f64, this follows as:
/// emin = -1022
/// p2 = 53
///
/// For f128, this follows as:
/// emin = -16383
/// p2 = 112
///
/// In Python:
/// `-emin + p2 + math.floor((emin+ 1)*math.log(2, b)-math.log(1-2**(-p2), b))`
pub const max_digits = if (MantissaT == u64) 768 else 11564;
/// The max digits that can be exactly represented in a 64-bit integer.
pub const max_digits_without_overflow = if (MantissaT == u64) 19 else 38;
pub const decimal_point_range = if (MantissaT == u64) 2047 else 32767;
pub const min_exponent = if (MantissaT == u64) -324 else -4966;
pub const max_exponent = if (MantissaT == u64) 310 else 4933;
pub const max_decimal_digits = if (MantissaT == u64) 18 else 37;
/// The number of significant digits in the decimal.
num_digits: usize,
/// The offset of the decimal point in the significant digits.
decimal_point: i32,
/// If the number of significant digits stored in the decimal is truncated.
truncated: bool,
/// buffer of the raw digits, in the range [0, 9].
digits: [max_digits]u8,
pub fn new() Self {
return .{
.num_digits = 0,
.decimal_point = 0,
.truncated = false,
.digits = [_]u8{0} ** max_digits,
};
}
/// Append a digit to the buffer
pub fn tryAddDigit(self: *Self, digit: u8) void {
if (self.num_digits < max_digits) {
self.digits[self.num_digits] = digit;
}
self.num_digits += 1;
}
/// Trim trailing zeroes from the buffer
pub fn trim(self: *Self) void {
// All of the following calls to `Self::trim` can't panic because:
//
// 1. `parse_decimal` sets `num_digits` to a max of `max_digits`.
// 2. `right_shift` sets `num_digits` to `write_index`, which is bounded by `num_digits`.
// 3. `left_shift` `num_digits` to a max of `max_digits`.
//
// Trim is only called in `right_shift` and `left_shift`.
std.debug.assert(self.num_digits <= max_digits);
while (self.num_digits != 0 and self.digits[self.num_digits - 1] == 0) {
self.num_digits -= 1;
}
}
pub fn round(self: *Self) MantissaT {
if (self.num_digits == 0 or self.decimal_point < 0) {
return 0;
} else if (self.decimal_point > max_decimal_digits) {
return math.maxInt(MantissaT);
}
const dp = @intCast(usize, self.decimal_point);
var n: MantissaT = 0;
var i: usize = 0;
while (i < dp) : (i += 1) {
n *= 10;
if (i < self.num_digits) {
n += @as(MantissaT, self.digits[i]);
}
}
var round_up = false;
if (dp < self.num_digits) {
round_up = self.digits[dp] >= 5;
if (self.digits[dp] == 5 and dp + 1 == self.num_digits) {
round_up = self.truncated or ((dp != 0) and (1 & self.digits[dp - 1] != 0));
}
}
if (round_up) {
n += 1;
}
return n;
}
/// Computes decimal * 2^shift.
pub fn leftShift(self: *Self, shift: usize) void {
if (self.num_digits == 0) {
return;
}
const num_new_digits = self.numberOfDigitsLeftShift(shift);
var read_index = self.num_digits;
var write_index = self.num_digits + num_new_digits;
var n: MantissaT = 0;
while (read_index != 0) {
read_index -= 1;
write_index -= 1;
n += math.shl(MantissaT, self.digits[read_index], shift);
const quotient = n / 10;
const remainder = n - (10 * quotient);
if (write_index < max_digits) {
self.digits[write_index] = @intCast(u8, remainder);
} else if (remainder > 0) {
self.truncated = true;
}
n = quotient;
}
while (n > 0) {
write_index -= 1;
const quotient = n / 10;
const remainder = n - (10 * quotient);
if (write_index < max_digits) {
self.digits[write_index] = @intCast(u8, remainder);
} else if (remainder > 0) {
self.truncated = true;
}
n = quotient;
}
self.num_digits += num_new_digits;
if (self.num_digits > max_digits) {
self.num_digits = max_digits;
}
self.decimal_point += @intCast(i32, num_new_digits);
self.trim();
}
/// Computes decimal * 2^-shift.
pub fn rightShift(self: *Self, shift: usize) void {
var read_index: usize = 0;
var write_index: usize = 0;
var n: MantissaT = 0;
while (math.shr(MantissaT, n, shift) == 0) {
if (read_index < self.num_digits) {
n = (10 * n) + self.digits[read_index];
read_index += 1;
} else if (n == 0) {
return;
} else {
while (math.shr(MantissaT, n, shift) == 0) {
n *= 10;
read_index += 1;
}
break;
}
}
self.decimal_point -= @intCast(i32, read_index) - 1;
if (self.decimal_point < -decimal_point_range) {
self.num_digits = 0;
self.decimal_point = 0;
self.truncated = false;
return;
}
const mask = math.shl(MantissaT, 1, shift) - 1;
while (read_index < self.num_digits) {
const new_digit = @intCast(u8, math.shr(MantissaT, n, shift));
n = (10 * (n & mask)) + self.digits[read_index];
read_index += 1;
self.digits[write_index] = new_digit;
write_index += 1;
}
while (n > 0) {
const new_digit = @intCast(u8, math.shr(MantissaT, n, shift));
n = 10 * (n & mask);
if (write_index < max_digits) {
self.digits[write_index] = new_digit;
write_index += 1;
} else if (new_digit > 0) {
self.truncated = true;
}
}
self.num_digits = write_index;
self.trim();
}
/// Parse a bit integer representation of the float as a decimal.
// We do not verify underscores in this path since these will have been verified
// via parse.parseNumber so can assume the number is well-formed.
// This code-path does not have to handle hex-floats since these will always be handled via another
// function prior to this.
pub fn parse(s: []const u8) Self {
var d = Self.new();
var stream = FloatStream.init(s);
stream.skipChars2('0', '_');
while (stream.scanDigit(10)) |digit| {
d.tryAddDigit(digit);
}
if (stream.firstIs('.')) {
stream.advance(1);
const marker = stream.offsetTrue();
// Skip leading zeroes
if (d.num_digits == 0) {
stream.skipChars('0');
}
while (stream.hasLen(8) and d.num_digits + 8 < max_digits) {
const v = stream.readU64Unchecked();
if (!isEightDigits(v)) {
break;
}
std.mem.writeIntSliceLittle(u64, d.digits[d.num_digits..], v - 0x3030_3030_3030_3030);
d.num_digits += 8;
stream.advance(8);
}
while (stream.scanDigit(10)) |digit| {
d.tryAddDigit(digit);
}
d.decimal_point = @intCast(i32, marker) - @intCast(i32, stream.offsetTrue());
}
if (d.num_digits != 0) {
// Ignore trailing zeros if any
var n_trailing_zeros: usize = 0;
var i = stream.offsetTrue() - 1;
while (true) {
if (s[i] == '0') {
n_trailing_zeros += 1;
} else if (s[i] != '.') {
break;
}
i -= 1;
if (i == 0) break;
}
d.decimal_point += @intCast(i32, n_trailing_zeros);
d.num_digits -= n_trailing_zeros;
d.decimal_point += @intCast(i32, d.num_digits);
if (d.num_digits > max_digits) {
d.truncated = true;
d.num_digits = max_digits;
}
}
if (stream.firstIsLower('e')) {
stream.advance(1);
var neg_exp = false;
if (stream.firstIs('-')) {
neg_exp = true;
stream.advance(1);
} else if (stream.firstIs('+')) {
stream.advance(1);
}
var exp_num: i32 = 0;
while (stream.scanDigit(10)) |digit| {
if (exp_num < 0x10000) {
exp_num = 10 * exp_num + digit;
}
}
d.decimal_point += if (neg_exp) -exp_num else exp_num;
}
var i = d.num_digits;
while (i < max_digits_without_overflow) : (i += 1) {
d.digits[i] = 0;
}
return d;
}
// Compute the number decimal digits introduced by a base-2 shift. This is performed
// by storing the leading digits of 1/2^i = 5^i and using these along with the cut-off
// value to quickly determine the decimal shift from binary.
//
// See also https://github.com/golang/go/blob/go1.15.3/src/strconv/decimal.go#L163 for
// another description of the method.
pub fn numberOfDigitsLeftShift(self: *Self, shift: usize) usize {
const ShiftCutoff = struct {
delta: u8,
cutoff: []const u8,
};
// Leading digits of 1/2^i = 5^i.
//
// ```
// import math
//
// bits = 128
// for i in range(bits):
// log2 = math.log(2)/math.log(10)
// print(f'.{{ .delta = {int(log2*i+1)}, .cutoff = "{5**i}" }}, // {2**i}')
// ```
const pow2_to_pow5_table = [_]ShiftCutoff{
.{ .delta = 0, .cutoff = "" },
.{ .delta = 1, .cutoff = "5" }, // 2
.{ .delta = 1, .cutoff = "25" }, // 4
.{ .delta = 1, .cutoff = "125" }, // 8
.{ .delta = 2, .cutoff = "625" }, // 16
.{ .delta = 2, .cutoff = "3125" }, // 32
.{ .delta = 2, .cutoff = "15625" }, // 64
.{ .delta = 3, .cutoff = "78125" }, // 128
.{ .delta = 3, .cutoff = "390625" }, // 256
.{ .delta = 3, .cutoff = "1953125" }, // 512
.{ .delta = 4, .cutoff = "9765625" }, // 1024
.{ .delta = 4, .cutoff = "48828125" }, // 2048
.{ .delta = 4, .cutoff = "244140625" }, // 4096
.{ .delta = 4, .cutoff = "1220703125" }, // 8192
.{ .delta = 5, .cutoff = "6103515625" }, // 16384
.{ .delta = 5, .cutoff = "30517578125" }, // 32768
.{ .delta = 5, .cutoff = "152587890625" }, // 65536
.{ .delta = 6, .cutoff = "762939453125" }, // 131072
.{ .delta = 6, .cutoff = "3814697265625" }, // 262144
.{ .delta = 6, .cutoff = "19073486328125" }, // 524288
.{ .delta = 7, .cutoff = "95367431640625" }, // 1048576
.{ .delta = 7, .cutoff = "476837158203125" }, // 2097152
.{ .delta = 7, .cutoff = "2384185791015625" }, // 4194304
.{ .delta = 7, .cutoff = "11920928955078125" }, // 8388608
.{ .delta = 8, .cutoff = "59604644775390625" }, // 16777216
.{ .delta = 8, .cutoff = "298023223876953125" }, // 33554432
.{ .delta = 8, .cutoff = "1490116119384765625" }, // 67108864
.{ .delta = 9, .cutoff = "7450580596923828125" }, // 134217728
.{ .delta = 9, .cutoff = "37252902984619140625" }, // 268435456
.{ .delta = 9, .cutoff = "186264514923095703125" }, // 536870912
.{ .delta = 10, .cutoff = "931322574615478515625" }, // 1073741824
.{ .delta = 10, .cutoff = "4656612873077392578125" }, // 2147483648
.{ .delta = 10, .cutoff = "23283064365386962890625" }, // 4294967296
.{ .delta = 10, .cutoff = "116415321826934814453125" }, // 8589934592
.{ .delta = 11, .cutoff = "582076609134674072265625" }, // 17179869184
.{ .delta = 11, .cutoff = "2910383045673370361328125" }, // 34359738368
.{ .delta = 11, .cutoff = "14551915228366851806640625" }, // 68719476736
.{ .delta = 12, .cutoff = "72759576141834259033203125" }, // 137438953472
.{ .delta = 12, .cutoff = "363797880709171295166015625" }, // 274877906944
.{ .delta = 12, .cutoff = "1818989403545856475830078125" }, // 549755813888
.{ .delta = 13, .cutoff = "9094947017729282379150390625" }, // 1099511627776
.{ .delta = 13, .cutoff = "45474735088646411895751953125" }, // 2199023255552
.{ .delta = 13, .cutoff = "227373675443232059478759765625" }, // 4398046511104
.{ .delta = 13, .cutoff = "1136868377216160297393798828125" }, // 8796093022208
.{ .delta = 14, .cutoff = "5684341886080801486968994140625" }, // 17592186044416
.{ .delta = 14, .cutoff = "28421709430404007434844970703125" }, // 35184372088832
.{ .delta = 14, .cutoff = "142108547152020037174224853515625" }, // 70368744177664
.{ .delta = 15, .cutoff = "710542735760100185871124267578125" }, // 140737488355328
.{ .delta = 15, .cutoff = "3552713678800500929355621337890625" }, // 281474976710656
.{ .delta = 15, .cutoff = "17763568394002504646778106689453125" }, // 562949953421312
.{ .delta = 16, .cutoff = "88817841970012523233890533447265625" }, // 1125899906842624
.{ .delta = 16, .cutoff = "444089209850062616169452667236328125" }, // 2251799813685248
.{ .delta = 16, .cutoff = "2220446049250313080847263336181640625" }, // 4503599627370496
.{ .delta = 16, .cutoff = "11102230246251565404236316680908203125" }, // 9007199254740992
.{ .delta = 17, .cutoff = "55511151231257827021181583404541015625" }, // 18014398509481984
.{ .delta = 17, .cutoff = "277555756156289135105907917022705078125" }, // 36028797018963968
.{ .delta = 17, .cutoff = "1387778780781445675529539585113525390625" }, // 72057594037927936
.{ .delta = 18, .cutoff = "6938893903907228377647697925567626953125" }, // 144115188075855872
.{ .delta = 18, .cutoff = "34694469519536141888238489627838134765625" }, // 288230376151711744
.{ .delta = 18, .cutoff = "173472347597680709441192448139190673828125" }, // 576460752303423488
.{ .delta = 19, .cutoff = "867361737988403547205962240695953369140625" }, // 1152921504606846976
.{ .delta = 19, .cutoff = "4336808689942017736029811203479766845703125" }, // 2305843009213693952
.{ .delta = 19, .cutoff = "21684043449710088680149056017398834228515625" }, // 4611686018427387904
.{ .delta = 19, .cutoff = "108420217248550443400745280086994171142578125" }, // 9223372036854775808
.{ .delta = 20, .cutoff = "542101086242752217003726400434970855712890625" }, // 18446744073709551616
.{ .delta = 20, .cutoff = "2710505431213761085018632002174854278564453125" }, // 36893488147419103232
.{ .delta = 20, .cutoff = "13552527156068805425093160010874271392822265625" }, // 73786976294838206464
.{ .delta = 21, .cutoff = "67762635780344027125465800054371356964111328125" }, // 147573952589676412928
.{ .delta = 21, .cutoff = "338813178901720135627329000271856784820556640625" }, // 295147905179352825856
.{ .delta = 21, .cutoff = "1694065894508600678136645001359283924102783203125" }, // 590295810358705651712
.{ .delta = 22, .cutoff = "8470329472543003390683225006796419620513916015625" }, // 1180591620717411303424
.{ .delta = 22, .cutoff = "42351647362715016953416125033982098102569580078125" }, // 2361183241434822606848
.{ .delta = 22, .cutoff = "211758236813575084767080625169910490512847900390625" }, // 4722366482869645213696
.{ .delta = 22, .cutoff = "1058791184067875423835403125849552452564239501953125" }, // 9444732965739290427392
.{ .delta = 23, .cutoff = "5293955920339377119177015629247762262821197509765625" }, // 18889465931478580854784
.{ .delta = 23, .cutoff = "26469779601696885595885078146238811314105987548828125" }, // 37778931862957161709568
.{ .delta = 23, .cutoff = "132348898008484427979425390731194056570529937744140625" }, // 75557863725914323419136
.{ .delta = 24, .cutoff = "661744490042422139897126953655970282852649688720703125" }, // 151115727451828646838272
.{ .delta = 24, .cutoff = "3308722450212110699485634768279851414263248443603515625" }, // 302231454903657293676544
.{ .delta = 24, .cutoff = "16543612251060553497428173841399257071316242218017578125" }, // 604462909807314587353088
.{ .delta = 25, .cutoff = "82718061255302767487140869206996285356581211090087890625" }, // 1208925819614629174706176
.{ .delta = 25, .cutoff = "413590306276513837435704346034981426782906055450439453125" }, // 2417851639229258349412352
.{ .delta = 25, .cutoff = "2067951531382569187178521730174907133914530277252197265625" }, // 4835703278458516698824704
.{ .delta = 25, .cutoff = "10339757656912845935892608650874535669572651386260986328125" }, // 9671406556917033397649408
.{ .delta = 26, .cutoff = "51698788284564229679463043254372678347863256931304931640625" }, // 19342813113834066795298816
.{ .delta = 26, .cutoff = "258493941422821148397315216271863391739316284656524658203125" }, // 38685626227668133590597632
.{ .delta = 26, .cutoff = "1292469707114105741986576081359316958696581423282623291015625" }, // 77371252455336267181195264
.{ .delta = 27, .cutoff = "6462348535570528709932880406796584793482907116413116455078125" }, // 154742504910672534362390528
.{ .delta = 27, .cutoff = "32311742677852643549664402033982923967414535582065582275390625" }, // 309485009821345068724781056
.{ .delta = 27, .cutoff = "161558713389263217748322010169914619837072677910327911376953125" }, // 618970019642690137449562112
.{ .delta = 28, .cutoff = "807793566946316088741610050849573099185363389551639556884765625" }, // 1237940039285380274899124224
.{ .delta = 28, .cutoff = "4038967834731580443708050254247865495926816947758197784423828125" }, // 2475880078570760549798248448
.{ .delta = 28, .cutoff = "20194839173657902218540251271239327479634084738790988922119140625" }, // 4951760157141521099596496896
.{ .delta = 28, .cutoff = "100974195868289511092701256356196637398170423693954944610595703125" }, // 9903520314283042199192993792
.{ .delta = 29, .cutoff = "504870979341447555463506281780983186990852118469774723052978515625" }, // 19807040628566084398385987584
.{ .delta = 29, .cutoff = "2524354896707237777317531408904915934954260592348873615264892578125" }, // 39614081257132168796771975168
.{ .delta = 29, .cutoff = "12621774483536188886587657044524579674771302961744368076324462890625" }, // 79228162514264337593543950336
.{ .delta = 30, .cutoff = "63108872417680944432938285222622898373856514808721840381622314453125" }, // 158456325028528675187087900672
.{ .delta = 30, .cutoff = "315544362088404722164691426113114491869282574043609201908111572265625" }, // 316912650057057350374175801344
.{ .delta = 30, .cutoff = "1577721810442023610823457130565572459346412870218046009540557861328125" }, // 633825300114114700748351602688
.{ .delta = 31, .cutoff = "7888609052210118054117285652827862296732064351090230047702789306640625" }, // 1267650600228229401496703205376
.{ .delta = 31, .cutoff = "39443045261050590270586428264139311483660321755451150238513946533203125" }, // 2535301200456458802993406410752
.{ .delta = 31, .cutoff = "197215226305252951352932141320696557418301608777255751192569732666015625" }, // 5070602400912917605986812821504
.{ .delta = 32, .cutoff = "986076131526264756764660706603482787091508043886278755962848663330078125" }, // 10141204801825835211973625643008
.{ .delta = 32, .cutoff = "4930380657631323783823303533017413935457540219431393779814243316650390625" }, // 20282409603651670423947251286016
.{ .delta = 32, .cutoff = "24651903288156618919116517665087069677287701097156968899071216583251953125" }, // 40564819207303340847894502572032
.{ .delta = 32, .cutoff = "123259516440783094595582588325435348386438505485784844495356082916259765625" }, // 81129638414606681695789005144064
.{ .delta = 33, .cutoff = "616297582203915472977912941627176741932192527428924222476780414581298828125" }, // 162259276829213363391578010288128
.{ .delta = 33, .cutoff = "3081487911019577364889564708135883709660962637144621112383902072906494140625" }, // 324518553658426726783156020576256
.{ .delta = 33, .cutoff = "15407439555097886824447823540679418548304813185723105561919510364532470703125" }, // 649037107316853453566312041152512
.{ .delta = 34, .cutoff = "77037197775489434122239117703397092741524065928615527809597551822662353515625" }, // 1298074214633706907132624082305024
.{ .delta = 34, .cutoff = "385185988877447170611195588516985463707620329643077639047987759113311767578125" }, // 2596148429267413814265248164610048
.{ .delta = 34, .cutoff = "1925929944387235853055977942584927318538101648215388195239938795566558837890625" }, // 5192296858534827628530496329220096
.{ .delta = 35, .cutoff = "9629649721936179265279889712924636592690508241076940976199693977832794189453125" }, // 10384593717069655257060992658440192
.{ .delta = 35, .cutoff = "48148248609680896326399448564623182963452541205384704880998469889163970947265625" }, // 20769187434139310514121985316880384
.{ .delta = 35, .cutoff = "240741243048404481631997242823115914817262706026923524404992349445819854736328125" }, // 41538374868278621028243970633760768
.{ .delta = 35, .cutoff = "1203706215242022408159986214115579574086313530134617622024961747229099273681640625" }, // 83076749736557242056487941267521536
.{ .delta = 36, .cutoff = "6018531076210112040799931070577897870431567650673088110124808736145496368408203125" }, // 166153499473114484112975882535043072
.{ .delta = 36, .cutoff = "30092655381050560203999655352889489352157838253365440550624043680727481842041015625" }, // 332306998946228968225951765070086144
.{ .delta = 36, .cutoff = "150463276905252801019998276764447446760789191266827202753120218403637409210205078125" }, // 664613997892457936451903530140172288
.{ .delta = 37, .cutoff = "752316384526264005099991383822237233803945956334136013765601092018187046051025390625" }, // 1329227995784915872903807060280344576
.{ .delta = 37, .cutoff = "3761581922631320025499956919111186169019729781670680068828005460090935230255126953125" }, // 2658455991569831745807614120560689152
.{ .delta = 37, .cutoff = "18807909613156600127499784595555930845098648908353400344140027300454676151275634765625" }, // 5316911983139663491615228241121378304
.{ .delta = 38, .cutoff = "94039548065783000637498922977779654225493244541767001720700136502273380756378173828125" }, // 10633823966279326983230456482242756608
.{ .delta = 38, .cutoff = "470197740328915003187494614888898271127466222708835008603500682511366903781890869140625" }, // 21267647932558653966460912964485513216
.{ .delta = 38, .cutoff = "2350988701644575015937473074444491355637331113544175043017503412556834518909454345703125" }, // 42535295865117307932921825928971026432
.{ .delta = 38, .cutoff = "11754943508222875079687365372222456778186655567720875215087517062784172594547271728515625" }, // 85070591730234615865843651857942052864
.{ .delta = 39, .cutoff = "58774717541114375398436826861112283890933277838604376075437585313920862972736358642578125" }, // 170141183460469231731687303715884105728
};
std.debug.assert(shift < pow2_to_pow5_table.len);
const x = pow2_to_pow5_table[shift];
// Compare leading digits of current to check if lexicographically less than cutoff.
for (x.cutoff) |p5, i| {
if (i >= self.num_digits) {
return x.delta - 1;
} else if (self.digits[i] == p5 - '0') { // digits are stored as integers
continue;
} else if (self.digits[i] < p5 - '0') {
return x.delta - 1;
} else {
return x.delta;
}
return x.delta;
}
return x.delta;
}
};
} | lib/std/fmt/parse_float/decimal.zig |
const std = @import("std");
const builtin = @import("builtin");
const Compilation = @import("compilation.zig").Compilation;
const Scope = @import("scope.zig").Scope;
const ast = std.zig.ast;
const Allocator = std.mem.Allocator;
const Value = @import("value.zig").Value;
const Type = Value.Type;
const assert = std.debug.assert;
const Token = std.zig.Token;
const Span = @import("errmsg.zig").Span;
const llvm = @import("llvm.zig");
const codegen = @import("codegen.zig");
const ObjectFile = codegen.ObjectFile;
const Decl = @import("decl.zig").Decl;
const mem = std.mem;
pub const LVal = enum {
None,
Ptr,
};
pub const IrVal = union(enum) {
Unknown,
KnownType: *Type,
KnownValue: *Value,
const Init = enum {
Unknown,
NoReturn,
Void,
};
pub fn dump(self: IrVal) void {
switch (self) {
IrVal.Unknown => std.debug.warn("Unknown"),
IrVal.KnownType => |typ| {
std.debug.warn("KnownType(");
typ.dump();
std.debug.warn(")");
},
IrVal.KnownValue => |value| {
std.debug.warn("KnownValue(");
value.dump();
std.debug.warn(")");
},
}
}
};
pub const Inst = struct {
id: Id,
scope: *Scope,
debug_id: usize,
val: IrVal,
ref_count: usize,
span: Span,
owner_bb: *BasicBlock,
/// true if this instruction was generated by zig and not from user code
is_generated: bool,
/// the instruction that is derived from this one in analysis
child: ?*Inst,
/// the instruction that this one derives from in analysis
parent: ?*Inst,
/// populated durign codegen
llvm_value: ?*llvm.Value,
pub fn cast(base: *Inst, comptime T: type) ?*T {
if (base.id == comptime typeToId(T)) {
return @fieldParentPtr(T, "base", base);
}
return null;
}
pub fn typeToId(comptime T: type) Id {
comptime var i = 0;
inline while (i < @memberCount(Id)) : (i += 1) {
if (T == @field(Inst, @memberName(Id, i))) {
return @field(Id, @memberName(Id, i));
}
}
unreachable;
}
pub fn dump(base: *const Inst) void {
comptime var i = 0;
inline while (i < @memberCount(Id)) : (i += 1) {
if (base.id == @field(Id, @memberName(Id, i))) {
const T = @field(Inst, @memberName(Id, i));
std.debug.warn("#{} = {}(", base.debug_id, @tagName(base.id));
@fieldParentPtr(T, "base", base).dump();
std.debug.warn(")");
return;
}
}
unreachable;
}
pub fn hasSideEffects(base: *const Inst) bool {
comptime var i = 0;
inline while (i < @memberCount(Id)) : (i += 1) {
if (base.id == @field(Id, @memberName(Id, i))) {
const T = @field(Inst, @memberName(Id, i));
return @fieldParentPtr(T, "base", base).hasSideEffects();
}
}
unreachable;
}
pub async fn analyze(base: *Inst, ira: *Analyze) Analyze.Error!*Inst {
switch (base.id) {
Id.Return => return @fieldParentPtr(Return, "base", base).analyze(ira),
Id.Const => return @fieldParentPtr(Const, "base", base).analyze(ira),
Id.Call => return @fieldParentPtr(Call, "base", base).analyze(ira),
Id.DeclRef => return await (async @fieldParentPtr(DeclRef, "base", base).analyze(ira) catch unreachable),
Id.Ref => return await (async @fieldParentPtr(Ref, "base", base).analyze(ira) catch unreachable),
Id.DeclVar => return @fieldParentPtr(DeclVar, "base", base).analyze(ira),
Id.CheckVoidStmt => return @fieldParentPtr(CheckVoidStmt, "base", base).analyze(ira),
Id.Phi => return @fieldParentPtr(Phi, "base", base).analyze(ira),
Id.Br => return @fieldParentPtr(Br, "base", base).analyze(ira),
Id.AddImplicitReturnType => return @fieldParentPtr(AddImplicitReturnType, "base", base).analyze(ira),
Id.PtrType => return await (async @fieldParentPtr(PtrType, "base", base).analyze(ira) catch unreachable),
Id.VarPtr => return await (async @fieldParentPtr(VarPtr, "base", base).analyze(ira) catch unreachable),
Id.LoadPtr => return await (async @fieldParentPtr(LoadPtr, "base", base).analyze(ira) catch unreachable),
}
}
pub fn render(base: *Inst, ofile: *ObjectFile, fn_val: *Value.Fn) (error{OutOfMemory}!?*llvm.Value) {
switch (base.id) {
Id.Return => return @fieldParentPtr(Return, "base", base).render(ofile, fn_val),
Id.Const => return @fieldParentPtr(Const, "base", base).render(ofile, fn_val),
Id.Call => return @fieldParentPtr(Call, "base", base).render(ofile, fn_val),
Id.VarPtr => return @fieldParentPtr(VarPtr, "base", base).render(ofile, fn_val),
Id.LoadPtr => return @fieldParentPtr(LoadPtr, "base", base).render(ofile, fn_val),
Id.DeclRef => unreachable,
Id.PtrType => unreachable,
Id.Ref => @panic("TODO"),
Id.DeclVar => @panic("TODO"),
Id.CheckVoidStmt => @panic("TODO"),
Id.Phi => @panic("TODO"),
Id.Br => @panic("TODO"),
Id.AddImplicitReturnType => @panic("TODO"),
}
}
fn ref(base: *Inst, builder: *Builder) void {
base.ref_count += 1;
if (base.owner_bb != builder.current_basic_block and !base.isCompTime()) {
base.owner_bb.ref(builder);
}
}
fn copyVal(base: *Inst, comp: *Compilation) !*Value {
if (base.parent.?.ref_count == 0) {
return base.val.KnownValue.derefAndCopy(comp);
}
return base.val.KnownValue.copy(comp);
}
fn getAsParam(param: *Inst) !*Inst {
param.ref_count -= 1;
const child = param.child orelse return error.SemanticAnalysisFailed;
switch (child.val) {
IrVal.Unknown => return error.SemanticAnalysisFailed,
else => return child,
}
}
fn getConstVal(self: *Inst, ira: *Analyze) !*Value {
if (self.isCompTime()) {
return self.val.KnownValue;
} else {
try ira.addCompileError(self.span, "unable to evaluate constant expression");
return error.SemanticAnalysisFailed;
}
}
fn getAsConstType(param: *Inst, ira: *Analyze) !*Type {
const meta_type = Type.MetaType.get(ira.irb.comp);
meta_type.base.base.deref(ira.irb.comp);
const inst = try param.getAsParam();
const casted = try ira.implicitCast(inst, &meta_type.base);
const val = try casted.getConstVal(ira);
return val.cast(Value.Type).?;
}
fn getAsConstAlign(param: *Inst, ira: *Analyze) !u32 {
return error.Unimplemented;
//const align_type = Type.Int.get_align(ira.irb.comp);
//align_type.base.base.deref(ira.irb.comp);
//const inst = try param.getAsParam();
//const casted = try ira.implicitCast(inst, align_type);
//const val = try casted.getConstVal(ira);
//uint32_t align_bytes = bigint_as_unsigned(&const_val->data.x_bigint);
//if (align_bytes == 0) {
// ir_add_error(ira, value, buf_sprintf("alignment must be >= 1"));
// return false;
//}
//if (!is_power_of_2(align_bytes)) {
// ir_add_error(ira, value, buf_sprintf("alignment value %" PRIu32 " is not a power of 2", align_bytes));
// return false;
//}
}
/// asserts that the type is known
fn getKnownType(self: *Inst) *Type {
switch (self.val) {
IrVal.KnownType => |typ| return typ,
IrVal.KnownValue => |value| return value.typ,
IrVal.Unknown => unreachable,
}
}
pub fn setGenerated(base: *Inst) void {
base.is_generated = true;
}
pub fn isNoReturn(base: *const Inst) bool {
switch (base.val) {
IrVal.Unknown => return false,
IrVal.KnownValue => |x| return x.typ.id == Type.Id.NoReturn,
IrVal.KnownType => |typ| return typ.id == Type.Id.NoReturn,
}
}
pub fn isCompTime(base: *const Inst) bool {
return base.val == IrVal.KnownValue;
}
pub fn linkToParent(self: *Inst, parent: *Inst) void {
assert(self.parent == null);
assert(parent.child == null);
self.parent = parent;
parent.child = self;
}
pub const Id = enum {
Return,
Const,
Ref,
DeclVar,
CheckVoidStmt,
Phi,
Br,
AddImplicitReturnType,
Call,
DeclRef,
PtrType,
VarPtr,
LoadPtr,
};
pub const Call = struct {
base: Inst,
params: Params,
const Params = struct {
fn_ref: *Inst,
args: []*Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(self: *const Call) void {
std.debug.warn("#{}(", self.params.fn_ref.debug_id);
for (self.params.args) |arg| {
std.debug.warn("#{},", arg.debug_id);
}
std.debug.warn(")");
}
pub fn hasSideEffects(self: *const Call) bool {
return true;
}
pub fn analyze(self: *const Call, ira: *Analyze) !*Inst {
const fn_ref = try self.params.fn_ref.getAsParam();
const fn_ref_type = fn_ref.getKnownType();
const fn_type = fn_ref_type.cast(Type.Fn) orelse {
try ira.addCompileError(fn_ref.span, "type '{}' not a function", fn_ref_type.name);
return error.SemanticAnalysisFailed;
};
const fn_type_param_count = fn_type.paramCount();
if (fn_type_param_count != self.params.args.len) {
try ira.addCompileError(
self.base.span,
"expected {} arguments, found {}",
fn_type_param_count,
self.params.args.len,
);
return error.SemanticAnalysisFailed;
}
const args = try ira.irb.arena().alloc(*Inst, self.params.args.len);
for (self.params.args) |arg, i| {
args[i] = try arg.getAsParam();
}
const new_inst = try ira.irb.build(Call, self.base.scope, self.base.span, Params{
.fn_ref = fn_ref,
.args = args,
});
new_inst.val = IrVal{ .KnownType = fn_type.key.data.Normal.return_type };
return new_inst;
}
pub fn render(self: *Call, ofile: *ObjectFile, fn_val: *Value.Fn) !?*llvm.Value {
const fn_ref = self.params.fn_ref.llvm_value.?;
const args = try ofile.arena.alloc(*llvm.Value, self.params.args.len);
for (self.params.args) |arg, i| {
args[i] = arg.llvm_value.?;
}
const llvm_cc = llvm.CCallConv;
const fn_inline = llvm.FnInline.Auto;
return llvm.BuildCall(
ofile.builder,
fn_ref,
args.ptr,
@intCast(c_uint, args.len),
llvm_cc,
fn_inline,
c"",
) orelse error.OutOfMemory;
}
};
pub const Const = struct {
base: Inst,
params: Params,
const Params = struct {};
// Use Builder.buildConst* methods, or, after building a Const instruction,
// manually set the ir_val field.
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(self: *const Const) void {
self.base.val.KnownValue.dump();
}
pub fn hasSideEffects(self: *const Const) bool {
return false;
}
pub fn analyze(self: *const Const, ira: *Analyze) !*Inst {
const new_inst = try ira.irb.build(Const, self.base.scope, self.base.span, Params{});
new_inst.val = IrVal{ .KnownValue = self.base.val.KnownValue.getRef() };
return new_inst;
}
pub fn render(self: *Const, ofile: *ObjectFile, fn_val: *Value.Fn) !?*llvm.Value {
return self.base.val.KnownValue.getLlvmConst(ofile);
}
};
pub const Return = struct {
base: Inst,
params: Params,
const Params = struct {
return_value: *Inst,
};
const ir_val_init = IrVal.Init.NoReturn;
pub fn dump(self: *const Return) void {
std.debug.warn("#{}", self.params.return_value.debug_id);
}
pub fn hasSideEffects(self: *const Return) bool {
return true;
}
pub fn analyze(self: *const Return, ira: *Analyze) !*Inst {
const value = try self.params.return_value.getAsParam();
const casted_value = try ira.implicitCast(value, ira.explicit_return_type);
// TODO detect returning local variable address
return ira.irb.build(Return, self.base.scope, self.base.span, Params{ .return_value = casted_value });
}
pub fn render(self: *Return, ofile: *ObjectFile, fn_val: *Value.Fn) !?*llvm.Value {
const value = self.params.return_value.llvm_value;
const return_type = self.params.return_value.getKnownType();
if (return_type.handleIsPtr()) {
@panic("TODO");
} else {
_ = llvm.BuildRet(ofile.builder, value) orelse return error.OutOfMemory;
}
return null;
}
};
pub const Ref = struct {
base: Inst,
params: Params,
const Params = struct {
target: *Inst,
mut: Type.Pointer.Mut,
volatility: Type.Pointer.Vol,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const Ref) void {}
pub fn hasSideEffects(inst: *const Ref) bool {
return false;
}
pub async fn analyze(self: *const Ref, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
if (ira.getCompTimeValOrNullUndefOk(target)) |val| {
return ira.getCompTimeRef(
val,
Value.Ptr.Mut.CompTimeConst,
self.params.mut,
self.params.volatility,
);
}
const new_inst = try ira.irb.build(Ref, self.base.scope, self.base.span, Params{
.target = target,
.mut = self.params.mut,
.volatility = self.params.volatility,
});
const elem_type = target.getKnownType();
const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
.child_type = elem_type,
.mut = self.params.mut,
.vol = self.params.volatility,
.size = Type.Pointer.Size.One,
.alignment = Type.Pointer.Align.Abi,
}) catch unreachable);
// TODO: potentially set the hint that this is a stack pointer. But it might not be - this
// could be a ref of a global, for example
new_inst.val = IrVal{ .KnownType = &ptr_type.base };
// TODO potentially add an alloca entry here
return new_inst;
}
};
pub const DeclRef = struct {
base: Inst,
params: Params,
const Params = struct {
decl: *Decl,
lval: LVal,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const DeclRef) void {}
pub fn hasSideEffects(inst: *const DeclRef) bool {
return false;
}
pub async fn analyze(self: *const DeclRef, ira: *Analyze) !*Inst {
(await (async ira.irb.comp.resolveDecl(self.params.decl) catch unreachable)) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
else => return error.SemanticAnalysisFailed,
};
switch (self.params.decl.id) {
Decl.Id.CompTime => unreachable,
Decl.Id.Var => return error.Unimplemented,
Decl.Id.Fn => {
const fn_decl = @fieldParentPtr(Decl.Fn, "base", self.params.decl);
const decl_val = switch (fn_decl.value) {
Decl.Fn.Val.Unresolved => unreachable,
Decl.Fn.Val.Fn => |fn_val| &fn_val.base,
Decl.Fn.Val.FnProto => |fn_proto| &fn_proto.base,
};
switch (self.params.lval) {
LVal.None => {
return ira.irb.buildConstValue(self.base.scope, self.base.span, decl_val);
},
LVal.Ptr => return error.Unimplemented,
}
},
}
}
};
pub const VarPtr = struct {
base: Inst,
params: Params,
const Params = struct {
var_scope: *Scope.Var,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const VarPtr) void {
std.debug.warn("{}", inst.params.var_scope.name);
}
pub fn hasSideEffects(inst: *const VarPtr) bool {
return false;
}
pub async fn analyze(self: *const VarPtr, ira: *Analyze) !*Inst {
switch (self.params.var_scope.data) {
Scope.Var.Data.Const => @panic("TODO"),
Scope.Var.Data.Param => |param| {
const new_inst = try ira.irb.build(
Inst.VarPtr,
self.base.scope,
self.base.span,
Inst.VarPtr.Params{ .var_scope = self.params.var_scope },
);
const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
.child_type = param.typ,
.mut = Type.Pointer.Mut.Const,
.vol = Type.Pointer.Vol.Non,
.size = Type.Pointer.Size.One,
.alignment = Type.Pointer.Align.Abi,
}) catch unreachable);
new_inst.val = IrVal{ .KnownType = &ptr_type.base };
return new_inst;
},
}
}
pub fn render(self: *VarPtr, ofile: *ObjectFile, fn_val: *Value.Fn) *llvm.Value {
switch (self.params.var_scope.data) {
Scope.Var.Data.Const => unreachable, // turned into Inst.Const in analyze pass
Scope.Var.Data.Param => |param| return param.llvm_value,
}
}
};
pub const LoadPtr = struct {
base: Inst,
params: Params,
const Params = struct {
target: *Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const LoadPtr) void {}
pub fn hasSideEffects(inst: *const LoadPtr) bool {
return false;
}
pub async fn analyze(self: *const LoadPtr, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
const target_type = target.getKnownType();
if (target_type.id != Type.Id.Pointer) {
try ira.addCompileError(self.base.span, "dereference of non pointer type '{}'", target_type.name);
return error.SemanticAnalysisFailed;
}
const ptr_type = @fieldParentPtr(Type.Pointer, "base", target_type);
// if (instr_is_comptime(ptr)) {
// if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst ||
// ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar)
// {
// ConstExprValue *pointee = const_ptr_pointee(ira->codegen, &ptr->value);
// if (pointee->special != ConstValSpecialRuntime) {
// IrInstruction *result = ir_create_const(&ira->new_irb, source_instruction->scope,
// source_instruction->source_node, child_type);
// copy_const_val(&result->value, pointee, ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst);
// result->value.type = child_type;
// return result;
// }
// }
// }
const new_inst = try ira.irb.build(
Inst.LoadPtr,
self.base.scope,
self.base.span,
Inst.LoadPtr.Params{ .target = target },
);
new_inst.val = IrVal{ .KnownType = ptr_type.key.child_type };
return new_inst;
}
pub fn render(self: *LoadPtr, ofile: *ObjectFile, fn_val: *Value.Fn) !?*llvm.Value {
const child_type = self.base.getKnownType();
if (!child_type.hasBits()) {
return null;
}
const ptr = self.params.target.llvm_value.?;
const ptr_type = self.params.target.getKnownType().cast(Type.Pointer).?;
return try codegen.getHandleValue(ofile, ptr, ptr_type);
//uint32_t unaligned_bit_count = ptr_type->data.pointer.unaligned_bit_count;
//if (unaligned_bit_count == 0)
// return get_handle_value(g, ptr, child_type, ptr_type);
//bool big_endian = g->is_big_endian;
//assert(!handle_is_ptr(child_type));
//LLVMValueRef containing_int = gen_load(g, ptr, ptr_type, "");
//uint32_t bit_offset = ptr_type->data.pointer.bit_offset;
//uint32_t host_bit_count = LLVMGetIntTypeWidth(LLVMTypeOf(containing_int));
//uint32_t shift_amt = big_endian ? host_bit_count - bit_offset - unaligned_bit_count : bit_offset;
//LLVMValueRef shift_amt_val = LLVMConstInt(LLVMTypeOf(containing_int), shift_amt, false);
//LLVMValueRef shifted_value = LLVMBuildLShr(g->builder, containing_int, shift_amt_val, "");
//return LLVMBuildTrunc(g->builder, shifted_value, child_type->type_ref, "");
}
};
pub const PtrType = struct {
base: Inst,
params: Params,
const Params = struct {
child_type: *Inst,
mut: Type.Pointer.Mut,
vol: Type.Pointer.Vol,
size: Type.Pointer.Size,
alignment: ?*Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const PtrType) void {}
pub fn hasSideEffects(inst: *const PtrType) bool {
return false;
}
pub async fn analyze(self: *const PtrType, ira: *Analyze) !*Inst {
const child_type = try self.params.child_type.getAsConstType(ira);
// if (child_type->id == TypeTableEntryIdUnreachable) {
// ir_add_error(ira, &instruction->base, buf_sprintf("pointer to noreturn not allowed"));
// return ira->codegen->builtin_types.entry_invalid;
// } else if (child_type->id == TypeTableEntryIdOpaque && instruction->ptr_len == PtrLenUnknown) {
// ir_add_error(ira, &instruction->base, buf_sprintf("unknown-length pointer to opaque"));
// return ira->codegen->builtin_types.entry_invalid;
// }
const alignment = if (self.params.alignment) |align_inst| blk: {
const amt = try align_inst.getAsConstAlign(ira);
break :blk Type.Pointer.Align{ .Override = amt };
} else blk: {
break :blk Type.Pointer.Align{ .Abi = {} };
};
const ptr_type = try await (async Type.Pointer.get(ira.irb.comp, Type.Pointer.Key{
.child_type = child_type,
.mut = self.params.mut,
.vol = self.params.vol,
.size = self.params.size,
.alignment = alignment,
}) catch unreachable);
ptr_type.base.base.deref(ira.irb.comp);
return ira.irb.buildConstValue(self.base.scope, self.base.span, &ptr_type.base.base);
}
};
pub const DeclVar = struct {
base: Inst,
params: Params,
const Params = struct {
variable: *Variable,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const DeclVar) void {}
pub fn hasSideEffects(inst: *const DeclVar) bool {
return true;
}
pub fn analyze(self: *const DeclVar, ira: *Analyze) !*Inst {
return error.Unimplemented; // TODO
}
};
pub const CheckVoidStmt = struct {
base: Inst,
params: Params,
const Params = struct {
target: *Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(self: *const CheckVoidStmt) void {
std.debug.warn("#{}", self.params.target.debug_id);
}
pub fn hasSideEffects(inst: *const CheckVoidStmt) bool {
return true;
}
pub fn analyze(self: *const CheckVoidStmt, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
if (target.getKnownType().id != Type.Id.Void) {
try ira.addCompileError(self.base.span, "expression value is ignored");
return error.SemanticAnalysisFailed;
}
return ira.irb.buildConstVoid(self.base.scope, self.base.span, true);
}
};
pub const Phi = struct {
base: Inst,
params: Params,
const Params = struct {
incoming_blocks: []*BasicBlock,
incoming_values: []*Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const Phi) void {}
pub fn hasSideEffects(inst: *const Phi) bool {
return false;
}
pub fn analyze(self: *const Phi, ira: *Analyze) !*Inst {
return error.Unimplemented; // TODO
}
};
pub const Br = struct {
base: Inst,
params: Params,
const Params = struct {
dest_block: *BasicBlock,
is_comptime: *Inst,
};
const ir_val_init = IrVal.Init.NoReturn;
pub fn dump(inst: *const Br) void {}
pub fn hasSideEffects(inst: *const Br) bool {
return true;
}
pub fn analyze(self: *const Br, ira: *Analyze) !*Inst {
return error.Unimplemented; // TODO
}
};
pub const CondBr = struct {
base: Inst,
params: Params,
const Params = struct {
condition: *Inst,
then_block: *BasicBlock,
else_block: *BasicBlock,
is_comptime: *Inst,
};
const ir_val_init = IrVal.Init.NoReturn;
pub fn dump(inst: *const CondBr) void {}
pub fn hasSideEffects(inst: *const CondBr) bool {
return true;
}
pub fn analyze(self: *const CondBr, ira: *Analyze) !*Inst {
return error.Unimplemented; // TODO
}
};
pub const AddImplicitReturnType = struct {
base: Inst,
params: Params,
pub const Params = struct {
target: *Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const AddImplicitReturnType) void {
std.debug.warn("#{}", inst.params.target.debug_id);
}
pub fn hasSideEffects(inst: *const AddImplicitReturnType) bool {
return true;
}
pub fn analyze(self: *const AddImplicitReturnType, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
try ira.src_implicit_return_type_list.append(target);
return ira.irb.buildConstVoid(self.base.scope, self.base.span, true);
}
};
pub const TestErr = struct {
base: Inst,
params: Params,
pub const Params = struct {
target: *Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const TestErr) void {
std.debug.warn("#{}", inst.params.target.debug_id);
}
pub fn hasSideEffects(inst: *const TestErr) bool {
return false;
}
pub fn analyze(self: *const TestErr, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
const target_type = target.getKnownType();
switch (target_type.id) {
Type.Id.ErrorUnion => {
return error.Unimplemented;
// if (instr_is_comptime(value)) {
// ConstExprValue *err_union_val = ir_resolve_const(ira, value, UndefBad);
// if (!err_union_val)
// return ira->codegen->builtin_types.entry_invalid;
// if (err_union_val->special != ConstValSpecialRuntime) {
// ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
// out_val->data.x_bool = (err_union_val->data.x_err_union.err != nullptr);
// return ira->codegen->builtin_types.entry_bool;
// }
// }
// TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;
// if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {
// return ira->codegen->builtin_types.entry_invalid;
// }
// if (!type_is_global_error_set(err_set_type) &&
// err_set_type->data.error_set.err_count == 0)
// {
// assert(err_set_type->data.error_set.infer_fn == nullptr);
// ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
// out_val->data.x_bool = false;
// return ira->codegen->builtin_types.entry_bool;
// }
// ir_build_test_err_from(&ira->new_irb, &instruction->base, value);
// return ira->codegen->builtin_types.entry_bool;
},
Type.Id.ErrorSet => {
return ira.irb.buildConstBool(self.base.scope, self.base.span, true);
},
else => {
return ira.irb.buildConstBool(self.base.scope, self.base.span, false);
},
}
}
};
pub const TestCompTime = struct {
base: Inst,
params: Params,
pub const Params = struct {
target: *Inst,
};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const TestCompTime) void {
std.debug.warn("#{}", inst.params.target.debug_id);
}
pub fn hasSideEffects(inst: *const TestCompTime) bool {
return false;
}
pub fn analyze(self: *const TestCompTime, ira: *Analyze) !*Inst {
const target = try self.params.target.getAsParam();
return ira.irb.buildConstBool(self.base.scope, self.base.span, target.isCompTime());
}
};
pub const SaveErrRetAddr = struct {
base: Inst,
params: Params,
const Params = struct {};
const ir_val_init = IrVal.Init.Unknown;
pub fn dump(inst: *const SaveErrRetAddr) void {}
pub fn hasSideEffects(inst: *const SaveErrRetAddr) bool {
return true;
}
pub fn analyze(self: *const SaveErrRetAddr, ira: *Analyze) !*Inst {
return ira.irb.build(Inst.SaveErrRetAddr, self.base.scope, self.base.span, Params{});
}
};
};
pub const Variable = struct {
child_scope: *Scope,
};
pub const BasicBlock = struct {
ref_count: usize,
name_hint: [*]const u8, // must be a C string literal
debug_id: usize,
scope: *Scope,
instruction_list: std.ArrayList(*Inst),
ref_instruction: ?*Inst,
/// for codegen
llvm_block: *llvm.BasicBlock,
llvm_exit_block: *llvm.BasicBlock,
/// the basic block that is derived from this one in analysis
child: ?*BasicBlock,
/// the basic block that this one derives from in analysis
parent: ?*BasicBlock,
pub fn ref(self: *BasicBlock, builder: *Builder) void {
self.ref_count += 1;
}
pub fn linkToParent(self: *BasicBlock, parent: *BasicBlock) void {
assert(self.parent == null);
assert(parent.child == null);
self.parent = parent;
parent.child = self;
}
};
/// Stuff that survives longer than Builder
pub const Code = struct {
basic_block_list: std.ArrayList(*BasicBlock),
arena: std.heap.ArenaAllocator,
return_type: ?*Type,
tree_scope: *Scope.AstTree,
/// allocator is comp.gpa()
pub fn destroy(self: *Code, allocator: *Allocator) void {
self.arena.deinit();
allocator.destroy(self);
}
pub fn dump(self: *Code) void {
var bb_i: usize = 0;
for (self.basic_block_list.toSliceConst()) |bb| {
std.debug.warn("{s}_{}:\n", bb.name_hint, bb.debug_id);
for (bb.instruction_list.toSliceConst()) |instr| {
std.debug.warn(" ");
instr.dump();
std.debug.warn("\n");
}
}
}
/// returns a ref-incremented value, or adds a compile error
pub fn getCompTimeResult(self: *Code, comp: *Compilation) !*Value {
const bb = self.basic_block_list.at(0);
for (bb.instruction_list.toSliceConst()) |inst| {
if (inst.cast(Inst.Return)) |ret_inst| {
const ret_value = ret_inst.params.return_value;
if (ret_value.isCompTime()) {
return ret_value.val.KnownValue.getRef();
}
try comp.addCompileError(
self.tree_scope,
ret_value.span,
"unable to evaluate constant expression",
);
return error.SemanticAnalysisFailed;
} else if (inst.hasSideEffects()) {
try comp.addCompileError(
self.tree_scope,
inst.span,
"unable to evaluate constant expression",
);
return error.SemanticAnalysisFailed;
}
}
unreachable;
}
};
pub const Builder = struct {
comp: *Compilation,
code: *Code,
current_basic_block: *BasicBlock,
next_debug_id: usize,
is_comptime: bool,
is_async: bool,
begin_scope: ?*Scope,
pub const Error = Analyze.Error;
pub fn init(comp: *Compilation, tree_scope: *Scope.AstTree, begin_scope: ?*Scope) !Builder {
const code = try comp.gpa().create(Code);
code.* = Code{
.basic_block_list = undefined,
.arena = std.heap.ArenaAllocator.init(comp.gpa()),
.return_type = null,
.tree_scope = tree_scope,
};
code.basic_block_list = std.ArrayList(*BasicBlock).init(&code.arena.allocator);
errdefer code.destroy(comp.gpa());
return Builder{
.comp = comp,
.current_basic_block = undefined,
.code = code,
.next_debug_id = 0,
.is_comptime = false,
.is_async = false,
.begin_scope = begin_scope,
};
}
pub fn abort(self: *Builder) void {
self.code.destroy(self.comp.gpa());
}
/// Call code.destroy() when done
pub fn finish(self: *Builder) *Code {
return self.code;
}
/// No need to clean up resources thanks to the arena allocator.
pub fn createBasicBlock(self: *Builder, scope: *Scope, name_hint: [*]const u8) !*BasicBlock {
const basic_block = try self.arena().create(BasicBlock);
basic_block.* = BasicBlock{
.ref_count = 0,
.name_hint = name_hint,
.debug_id = self.next_debug_id,
.scope = scope,
.instruction_list = std.ArrayList(*Inst).init(self.arena()),
.child = null,
.parent = null,
.ref_instruction = null,
.llvm_block = undefined,
.llvm_exit_block = undefined,
};
self.next_debug_id += 1;
return basic_block;
}
pub fn setCursorAtEndAndAppendBlock(self: *Builder, basic_block: *BasicBlock) !void {
try self.code.basic_block_list.append(basic_block);
self.setCursorAtEnd(basic_block);
}
pub fn setCursorAtEnd(self: *Builder, basic_block: *BasicBlock) void {
self.current_basic_block = basic_block;
}
pub async fn genNode(irb: *Builder, node: *ast.Node, scope: *Scope, lval: LVal) Error!*Inst {
switch (node.id) {
ast.Node.Id.Root => unreachable,
ast.Node.Id.Use => unreachable,
ast.Node.Id.TestDecl => unreachable,
ast.Node.Id.VarDecl => return error.Unimplemented,
ast.Node.Id.Defer => return error.Unimplemented,
ast.Node.Id.InfixOp => return error.Unimplemented,
ast.Node.Id.PrefixOp => {
const prefix_op = @fieldParentPtr(ast.Node.PrefixOp, "base", node);
switch (prefix_op.op) {
ast.Node.PrefixOp.Op.AddressOf => return error.Unimplemented,
ast.Node.PrefixOp.Op.ArrayType => |n| return error.Unimplemented,
ast.Node.PrefixOp.Op.Await => return error.Unimplemented,
ast.Node.PrefixOp.Op.BitNot => return error.Unimplemented,
ast.Node.PrefixOp.Op.BoolNot => return error.Unimplemented,
ast.Node.PrefixOp.Op.Cancel => return error.Unimplemented,
ast.Node.PrefixOp.Op.OptionalType => return error.Unimplemented,
ast.Node.PrefixOp.Op.Negation => return error.Unimplemented,
ast.Node.PrefixOp.Op.NegationWrap => return error.Unimplemented,
ast.Node.PrefixOp.Op.Resume => return error.Unimplemented,
ast.Node.PrefixOp.Op.PtrType => |ptr_info| {
const inst = try await (async irb.genPtrType(prefix_op, ptr_info, scope) catch unreachable);
return irb.lvalWrap(scope, inst, lval);
},
ast.Node.PrefixOp.Op.SliceType => |ptr_info| return error.Unimplemented,
ast.Node.PrefixOp.Op.Try => return error.Unimplemented,
}
},
ast.Node.Id.SuffixOp => {
const suffix_op = @fieldParentPtr(ast.Node.SuffixOp, "base", node);
switch (suffix_op.op) {
@TagType(ast.Node.SuffixOp.Op).Call => |*call| {
const inst = try await (async irb.genCall(suffix_op, call, scope) catch unreachable);
return irb.lvalWrap(scope, inst, lval);
},
@TagType(ast.Node.SuffixOp.Op).ArrayAccess => |n| return error.Unimplemented,
@TagType(ast.Node.SuffixOp.Op).Slice => |slice| return error.Unimplemented,
@TagType(ast.Node.SuffixOp.Op).ArrayInitializer => |init_list| return error.Unimplemented,
@TagType(ast.Node.SuffixOp.Op).StructInitializer => |init_list| return error.Unimplemented,
@TagType(ast.Node.SuffixOp.Op).Deref => return error.Unimplemented,
@TagType(ast.Node.SuffixOp.Op).UnwrapOptional => return error.Unimplemented,
}
},
ast.Node.Id.Switch => return error.Unimplemented,
ast.Node.Id.While => return error.Unimplemented,
ast.Node.Id.For => return error.Unimplemented,
ast.Node.Id.If => return error.Unimplemented,
ast.Node.Id.ControlFlowExpression => {
const control_flow_expr = @fieldParentPtr(ast.Node.ControlFlowExpression, "base", node);
return await (async irb.genControlFlowExpr(control_flow_expr, scope, lval) catch unreachable);
},
ast.Node.Id.Suspend => return error.Unimplemented,
ast.Node.Id.VarType => return error.Unimplemented,
ast.Node.Id.ErrorType => return error.Unimplemented,
ast.Node.Id.FnProto => return error.Unimplemented,
ast.Node.Id.PromiseType => return error.Unimplemented,
ast.Node.Id.IntegerLiteral => {
const int_lit = @fieldParentPtr(ast.Node.IntegerLiteral, "base", node);
return irb.lvalWrap(scope, try irb.genIntLit(int_lit, scope), lval);
},
ast.Node.Id.FloatLiteral => return error.Unimplemented,
ast.Node.Id.StringLiteral => {
const str_lit = @fieldParentPtr(ast.Node.StringLiteral, "base", node);
const inst = try await (async irb.genStrLit(str_lit, scope) catch unreachable);
return irb.lvalWrap(scope, inst, lval);
},
ast.Node.Id.MultilineStringLiteral => return error.Unimplemented,
ast.Node.Id.CharLiteral => return error.Unimplemented,
ast.Node.Id.BoolLiteral => return error.Unimplemented,
ast.Node.Id.NullLiteral => return error.Unimplemented,
ast.Node.Id.UndefinedLiteral => return error.Unimplemented,
ast.Node.Id.Unreachable => return error.Unimplemented,
ast.Node.Id.Identifier => {
const identifier = @fieldParentPtr(ast.Node.Identifier, "base", node);
return await (async irb.genIdentifier(identifier, scope, lval) catch unreachable);
},
ast.Node.Id.GroupedExpression => {
const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", node);
return await (async irb.genNode(grouped_expr.expr, scope, lval) catch unreachable);
},
ast.Node.Id.BuiltinCall => return error.Unimplemented,
ast.Node.Id.ErrorSetDecl => return error.Unimplemented,
ast.Node.Id.ContainerDecl => return error.Unimplemented,
ast.Node.Id.Asm => return error.Unimplemented,
ast.Node.Id.Comptime => return error.Unimplemented,
ast.Node.Id.Block => {
const block = @fieldParentPtr(ast.Node.Block, "base", node);
const inst = try await (async irb.genBlock(block, scope) catch unreachable);
return irb.lvalWrap(scope, inst, lval);
},
ast.Node.Id.DocComment => return error.Unimplemented,
ast.Node.Id.SwitchCase => return error.Unimplemented,
ast.Node.Id.SwitchElse => return error.Unimplemented,
ast.Node.Id.Else => return error.Unimplemented,
ast.Node.Id.Payload => return error.Unimplemented,
ast.Node.Id.PointerPayload => return error.Unimplemented,
ast.Node.Id.PointerIndexPayload => return error.Unimplemented,
ast.Node.Id.ContainerField => return error.Unimplemented,
ast.Node.Id.ErrorTag => return error.Unimplemented,
ast.Node.Id.AsmInput => return error.Unimplemented,
ast.Node.Id.AsmOutput => return error.Unimplemented,
ast.Node.Id.ParamDecl => return error.Unimplemented,
ast.Node.Id.FieldInitializer => return error.Unimplemented,
ast.Node.Id.EnumLiteral => return error.Unimplemented,
}
}
async fn genCall(irb: *Builder, suffix_op: *ast.Node.SuffixOp, call: *ast.Node.SuffixOp.Op.Call, scope: *Scope) !*Inst {
const fn_ref = try await (async irb.genNode(suffix_op.lhs, scope, LVal.None) catch unreachable);
const args = try irb.arena().alloc(*Inst, call.params.len);
var it = call.params.iterator(0);
var i: usize = 0;
while (it.next()) |arg_node_ptr| : (i += 1) {
args[i] = try await (async irb.genNode(arg_node_ptr.*, scope, LVal.None) catch unreachable);
}
//bool is_async = node->data.fn_call_expr.is_async;
//IrInstruction *async_allocator = nullptr;
//if (is_async) {
// if (node->data.fn_call_expr.async_allocator) {
// async_allocator = ir_gen_node(irb, node->data.fn_call_expr.async_allocator, scope);
// if (async_allocator == irb->codegen->invalid_instruction)
// return async_allocator;
// }
//}
return irb.build(Inst.Call, scope, Span.token(suffix_op.rtoken), Inst.Call.Params{
.fn_ref = fn_ref,
.args = args,
});
//IrInstruction *fn_call = ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false, FnInlineAuto, is_async, async_allocator, nullptr);
//return ir_lval_wrap(irb, scope, fn_call, lval);
}
async fn genPtrType(
irb: *Builder,
prefix_op: *ast.Node.PrefixOp,
ptr_info: ast.Node.PrefixOp.PtrInfo,
scope: *Scope,
) !*Inst {
// TODO port more logic
//assert(node->type == NodeTypePointerType);
//PtrLen ptr_len = (node->data.pointer_type.star_token->id == TokenIdStar ||
// node->data.pointer_type.star_token->id == TokenIdStarStar) ? PtrLenSingle : PtrLenUnknown;
//bool is_const = node->data.pointer_type.is_const;
//bool is_volatile = node->data.pointer_type.is_volatile;
//AstNode *expr_node = node->data.pointer_type.op_expr;
//AstNode *align_expr = node->data.pointer_type.align_expr;
//IrInstruction *align_value;
//if (align_expr != nullptr) {
// align_value = ir_gen_node(irb, align_expr, scope);
// if (align_value == irb->codegen->invalid_instruction)
// return align_value;
//} else {
// align_value = nullptr;
//}
const child_type = try await (async irb.genNode(prefix_op.rhs, scope, LVal.None) catch unreachable);
//uint32_t bit_offset_start = 0;
//if (node->data.pointer_type.bit_offset_start != nullptr) {
// if (!bigint_fits_in_bits(node->data.pointer_type.bit_offset_start, 32, false)) {
// Buf *val_buf = buf_alloc();
// bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10);
// exec_add_error_node(irb->codegen, irb->exec, node,
// buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf)));
// return irb->codegen->invalid_instruction;
// }
// bit_offset_start = bigint_as_unsigned(node->data.pointer_type.bit_offset_start);
//}
//uint32_t bit_offset_end = 0;
//if (node->data.pointer_type.bit_offset_end != nullptr) {
// if (!bigint_fits_in_bits(node->data.pointer_type.bit_offset_end, 32, false)) {
// Buf *val_buf = buf_alloc();
// bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_end, 10);
// exec_add_error_node(irb->codegen, irb->exec, node,
// buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf)));
// return irb->codegen->invalid_instruction;
// }
// bit_offset_end = bigint_as_unsigned(node->data.pointer_type.bit_offset_end);
//}
//if ((bit_offset_start != 0 || bit_offset_end != 0) && bit_offset_start >= bit_offset_end) {
// exec_add_error_node(irb->codegen, irb->exec, node,
// buf_sprintf("bit offset start must be less than bit offset end"));
// return irb->codegen->invalid_instruction;
//}
return irb.build(Inst.PtrType, scope, Span.node(&prefix_op.base), Inst.PtrType.Params{
.child_type = child_type,
.mut = Type.Pointer.Mut.Mut,
.vol = Type.Pointer.Vol.Non,
.size = Type.Pointer.Size.Many,
.alignment = null,
});
}
fn isCompTime(irb: *Builder, target_scope: *Scope) bool {
if (irb.is_comptime)
return true;
var scope = target_scope;
while (true) {
switch (scope.id) {
Scope.Id.CompTime => return true,
Scope.Id.FnDef => return false,
Scope.Id.Decls => unreachable,
Scope.Id.Root => unreachable,
Scope.Id.AstTree => unreachable,
Scope.Id.Block,
Scope.Id.Defer,
Scope.Id.DeferExpr,
Scope.Id.Var,
=> scope = scope.parent.?,
}
}
}
pub fn genIntLit(irb: *Builder, int_lit: *ast.Node.IntegerLiteral, scope: *Scope) !*Inst {
const int_token = irb.code.tree_scope.tree.tokenSlice(int_lit.token);
var base: u8 = undefined;
var rest: []const u8 = undefined;
if (int_token.len >= 3 and int_token[0] == '0') {
base = switch (int_token[1]) {
'b' => u8(2),
'o' => u8(8),
'x' => u8(16),
else => unreachable,
};
rest = int_token[2..];
} else {
base = 10;
rest = int_token;
}
const comptime_int_type = Type.ComptimeInt.get(irb.comp);
defer comptime_int_type.base.base.deref(irb.comp);
const int_val = Value.Int.createFromString(
irb.comp,
&comptime_int_type.base,
base,
rest,
) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.InvalidBase => unreachable,
error.InvalidCharForDigit => unreachable,
error.DigitTooLargeForBase => unreachable,
};
errdefer int_val.base.deref(irb.comp);
const inst = try irb.build(Inst.Const, scope, Span.token(int_lit.token), Inst.Const.Params{});
inst.val = IrVal{ .KnownValue = &int_val.base };
return inst;
}
pub async fn genStrLit(irb: *Builder, str_lit: *ast.Node.StringLiteral, scope: *Scope) !*Inst {
const str_token = irb.code.tree_scope.tree.tokenSlice(str_lit.token);
const src_span = Span.token(str_lit.token);
var bad_index: usize = undefined;
var buf = std.zig.parseStringLiteral(irb.comp.gpa(), str_token, &bad_index) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.InvalidCharacter => {
try irb.comp.addCompileError(
irb.code.tree_scope,
src_span,
"invalid character in string literal: '{c}'",
str_token[bad_index],
);
return error.SemanticAnalysisFailed;
},
};
var buf_cleaned = false;
errdefer if (!buf_cleaned) irb.comp.gpa().free(buf);
if (str_token[0] == 'c') {
// first we add a null
buf = try irb.comp.gpa().realloc(buf, buf.len + 1);
buf[buf.len - 1] = 0;
// next make an array value
const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable);
buf_cleaned = true;
defer array_val.base.deref(irb.comp);
// then make a pointer value pointing at the first element
const ptr_val = try await (async Value.Ptr.createArrayElemPtr(
irb.comp,
array_val,
Type.Pointer.Mut.Const,
Type.Pointer.Size.Many,
0,
) catch unreachable);
defer ptr_val.base.deref(irb.comp);
return irb.buildConstValue(scope, src_span, &ptr_val.base);
} else {
const array_val = try await (async Value.Array.createOwnedBuffer(irb.comp, buf) catch unreachable);
buf_cleaned = true;
defer array_val.base.deref(irb.comp);
return irb.buildConstValue(scope, src_span, &array_val.base);
}
}
pub async fn genBlock(irb: *Builder, block: *ast.Node.Block, parent_scope: *Scope) !*Inst {
const block_scope = try Scope.Block.create(irb.comp, parent_scope);
const outer_block_scope = &block_scope.base;
var child_scope = outer_block_scope;
if (parent_scope.findFnDef()) |fndef_scope| {
if (fndef_scope.fn_val.?.block_scope == null) {
fndef_scope.fn_val.?.block_scope = block_scope;
}
}
if (block.statements.len == 0) {
// {}
return irb.buildConstVoid(child_scope, Span.token(block.lbrace), false);
}
if (block.label) |label| {
block_scope.incoming_values = std.ArrayList(*Inst).init(irb.arena());
block_scope.incoming_blocks = std.ArrayList(*BasicBlock).init(irb.arena());
block_scope.end_block = try irb.createBasicBlock(parent_scope, c"BlockEnd");
block_scope.is_comptime = try irb.buildConstBool(
parent_scope,
Span.token(block.lbrace),
irb.isCompTime(parent_scope),
);
}
var is_continuation_unreachable = false;
var noreturn_return_value: ?*Inst = null;
var stmt_it = block.statements.iterator(0);
while (stmt_it.next()) |statement_node_ptr| {
const statement_node = statement_node_ptr.*;
if (statement_node.cast(ast.Node.Defer)) |defer_node| {
// defer starts a new scope
const defer_token = irb.code.tree_scope.tree.tokens.at(defer_node.defer_token);
const kind = switch (defer_token.id) {
Token.Id.Keyword_defer => Scope.Defer.Kind.ScopeExit,
Token.Id.Keyword_errdefer => Scope.Defer.Kind.ErrorExit,
else => unreachable,
};
const defer_expr_scope = try Scope.DeferExpr.create(irb.comp, parent_scope, defer_node.expr);
const defer_child_scope = try Scope.Defer.create(irb.comp, parent_scope, kind, defer_expr_scope);
child_scope = &defer_child_scope.base;
continue;
}
const statement_value = try await (async irb.genNode(statement_node, child_scope, LVal.None) catch unreachable);
is_continuation_unreachable = statement_value.isNoReturn();
if (is_continuation_unreachable) {
// keep the last noreturn statement value around in case we need to return it
noreturn_return_value = statement_value;
}
if (statement_value.cast(Inst.DeclVar)) |decl_var| {
// variable declarations start a new scope
child_scope = decl_var.params.variable.child_scope;
} else if (!is_continuation_unreachable) {
// this statement's value must be void
_ = try irb.build(
Inst.CheckVoidStmt,
child_scope,
Span{
.first = statement_node.firstToken(),
.last = statement_node.lastToken(),
},
Inst.CheckVoidStmt.Params{ .target = statement_value },
);
}
}
if (is_continuation_unreachable) {
assert(noreturn_return_value != null);
if (block.label == null or block_scope.incoming_blocks.len == 0) {
return noreturn_return_value.?;
}
try irb.setCursorAtEndAndAppendBlock(block_scope.end_block);
return irb.build(Inst.Phi, parent_scope, Span.token(block.rbrace), Inst.Phi.Params{
.incoming_blocks = block_scope.incoming_blocks.toOwnedSlice(),
.incoming_values = block_scope.incoming_values.toOwnedSlice(),
});
}
if (block.label) |label| {
try block_scope.incoming_blocks.append(irb.current_basic_block);
try block_scope.incoming_values.append(
try irb.buildConstVoid(parent_scope, Span.token(block.rbrace), true),
);
_ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
_ = try irb.buildGen(Inst.Br, parent_scope, Span.token(block.rbrace), Inst.Br.Params{
.dest_block = block_scope.end_block,
.is_comptime = block_scope.is_comptime,
});
try irb.setCursorAtEndAndAppendBlock(block_scope.end_block);
return irb.build(Inst.Phi, parent_scope, Span.token(block.rbrace), Inst.Phi.Params{
.incoming_blocks = block_scope.incoming_blocks.toOwnedSlice(),
.incoming_values = block_scope.incoming_values.toOwnedSlice(),
});
}
_ = try await (async irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
return irb.buildConstVoid(child_scope, Span.token(block.rbrace), true);
}
pub async fn genControlFlowExpr(
irb: *Builder,
control_flow_expr: *ast.Node.ControlFlowExpression,
scope: *Scope,
lval: LVal,
) !*Inst {
switch (control_flow_expr.kind) {
ast.Node.ControlFlowExpression.Kind.Break => |arg| return error.Unimplemented,
ast.Node.ControlFlowExpression.Kind.Continue => |arg| return error.Unimplemented,
ast.Node.ControlFlowExpression.Kind.Return => {
const src_span = Span.token(control_flow_expr.ltoken);
if (scope.findFnDef() == null) {
try irb.comp.addCompileError(
irb.code.tree_scope,
src_span,
"return expression outside function definition",
);
return error.SemanticAnalysisFailed;
}
if (scope.findDeferExpr()) |scope_defer_expr| {
if (!scope_defer_expr.reported_err) {
try irb.comp.addCompileError(
irb.code.tree_scope,
src_span,
"cannot return from defer expression",
);
scope_defer_expr.reported_err = true;
}
return error.SemanticAnalysisFailed;
}
const outer_scope = irb.begin_scope.?;
const return_value = if (control_flow_expr.rhs) |rhs| blk: {
break :blk try await (async irb.genNode(rhs, scope, LVal.None) catch unreachable);
} else blk: {
break :blk try irb.buildConstVoid(scope, src_span, true);
};
const defer_counts = irb.countDefers(scope, outer_scope);
const have_err_defers = defer_counts.error_exit != 0;
if (have_err_defers or irb.comp.have_err_ret_tracing) {
const err_block = try irb.createBasicBlock(scope, c"ErrRetErr");
const ok_block = try irb.createBasicBlock(scope, c"ErrRetOk");
if (!have_err_defers) {
_ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
}
const is_err = try irb.build(
Inst.TestErr,
scope,
src_span,
Inst.TestErr.Params{ .target = return_value },
);
const err_is_comptime = try irb.buildTestCompTime(scope, src_span, is_err);
_ = try irb.buildGen(Inst.CondBr, scope, src_span, Inst.CondBr.Params{
.condition = is_err,
.then_block = err_block,
.else_block = ok_block,
.is_comptime = err_is_comptime,
});
const ret_stmt_block = try irb.createBasicBlock(scope, c"RetStmt");
try irb.setCursorAtEndAndAppendBlock(err_block);
if (have_err_defers) {
_ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ErrorExit) catch unreachable);
}
if (irb.comp.have_err_ret_tracing and !irb.isCompTime(scope)) {
_ = try irb.build(Inst.SaveErrRetAddr, scope, src_span, Inst.SaveErrRetAddr.Params{});
}
_ = try irb.build(Inst.Br, scope, src_span, Inst.Br.Params{
.dest_block = ret_stmt_block,
.is_comptime = err_is_comptime,
});
try irb.setCursorAtEndAndAppendBlock(ok_block);
if (have_err_defers) {
_ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
}
_ = try irb.build(Inst.Br, scope, src_span, Inst.Br.Params{
.dest_block = ret_stmt_block,
.is_comptime = err_is_comptime,
});
try irb.setCursorAtEndAndAppendBlock(ret_stmt_block);
return irb.genAsyncReturn(scope, src_span, return_value, false);
} else {
_ = try await (async irb.genDefersForBlock(scope, outer_scope, Scope.Defer.Kind.ScopeExit) catch unreachable);
return irb.genAsyncReturn(scope, src_span, return_value, false);
}
},
}
}
pub async fn genIdentifier(irb: *Builder, identifier: *ast.Node.Identifier, scope: *Scope, lval: LVal) !*Inst {
const src_span = Span.token(identifier.token);
const name = irb.code.tree_scope.tree.tokenSlice(identifier.token);
//if (buf_eql_str(variable_name, "_") && lval == LValPtr) {
// IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node);
// const_instruction->base.value.type = get_pointer_to_type(irb->codegen,
// irb->codegen->builtin_types.entry_void, false);
// const_instruction->base.value.special = ConstValSpecialStatic;
// const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialDiscard;
// return &const_instruction->base;
//}
if (await (async irb.comp.getPrimitiveType(name) catch unreachable)) |result| {
if (result) |primitive_type| {
defer primitive_type.base.deref(irb.comp);
switch (lval) {
// if (lval == LValPtr) {
// return ir_build_ref(irb, scope, node, value, false, false);
LVal.Ptr => return error.Unimplemented,
LVal.None => return irb.buildConstValue(scope, src_span, &primitive_type.base),
}
}
} else |err| switch (err) {
error.Overflow => {
try irb.comp.addCompileError(irb.code.tree_scope, src_span, "integer too large");
return error.SemanticAnalysisFailed;
},
error.OutOfMemory => return error.OutOfMemory,
}
switch (await (async irb.findIdent(scope, name) catch unreachable)) {
Ident.Decl => |decl| {
return irb.build(Inst.DeclRef, scope, src_span, Inst.DeclRef.Params{
.decl = decl,
.lval = lval,
});
},
Ident.VarScope => |var_scope| {
const var_ptr = try irb.build(Inst.VarPtr, scope, src_span, Inst.VarPtr.Params{ .var_scope = var_scope });
switch (lval) {
LVal.Ptr => return var_ptr,
LVal.None => {
return irb.build(Inst.LoadPtr, scope, src_span, Inst.LoadPtr.Params{ .target = var_ptr });
},
}
},
Ident.NotFound => {},
}
//if (node->owner->any_imports_failed) {
// // skip the error message since we had a failing import in this file
// // if an import breaks we don't need redundant undeclared identifier errors
// return irb->codegen->invalid_instruction;
//}
// TODO put a variable of same name with invalid type in global scope
// so that future references to this same name will find a variable with an invalid type
try irb.comp.addCompileError(irb.code.tree_scope, src_span, "unknown identifier '{}'", name);
return error.SemanticAnalysisFailed;
}
const DeferCounts = struct {
scope_exit: usize,
error_exit: usize,
};
fn countDefers(irb: *Builder, inner_scope: *Scope, outer_scope: *Scope) DeferCounts {
var result = DeferCounts{ .scope_exit = 0, .error_exit = 0 };
var scope = inner_scope;
while (scope != outer_scope) {
switch (scope.id) {
Scope.Id.Defer => {
const defer_scope = @fieldParentPtr(Scope.Defer, "base", scope);
switch (defer_scope.kind) {
Scope.Defer.Kind.ScopeExit => result.scope_exit += 1,
Scope.Defer.Kind.ErrorExit => result.error_exit += 1,
}
scope = scope.parent orelse break;
},
Scope.Id.FnDef => break,
Scope.Id.CompTime,
Scope.Id.Block,
Scope.Id.Decls,
Scope.Id.Root,
Scope.Id.Var,
=> scope = scope.parent orelse break,
Scope.Id.DeferExpr => unreachable,
Scope.Id.AstTree => unreachable,
}
}
return result;
}
async fn genDefersForBlock(
irb: *Builder,
inner_scope: *Scope,
outer_scope: *Scope,
gen_kind: Scope.Defer.Kind,
) !bool {
var scope = inner_scope;
var is_noreturn = false;
while (true) {
switch (scope.id) {
Scope.Id.Defer => {
const defer_scope = @fieldParentPtr(Scope.Defer, "base", scope);
const generate = switch (defer_scope.kind) {
Scope.Defer.Kind.ScopeExit => true,
Scope.Defer.Kind.ErrorExit => gen_kind == Scope.Defer.Kind.ErrorExit,
};
if (generate) {
const defer_expr_scope = defer_scope.defer_expr_scope;
const instruction = try await (async irb.genNode(
defer_expr_scope.expr_node,
&defer_expr_scope.base,
LVal.None,
) catch unreachable);
if (instruction.isNoReturn()) {
is_noreturn = true;
} else {
_ = try irb.build(
Inst.CheckVoidStmt,
&defer_expr_scope.base,
Span.token(defer_expr_scope.expr_node.lastToken()),
Inst.CheckVoidStmt.Params{ .target = instruction },
);
}
}
},
Scope.Id.FnDef,
Scope.Id.Decls,
Scope.Id.Root,
=> return is_noreturn,
Scope.Id.CompTime,
Scope.Id.Block,
Scope.Id.Var,
=> scope = scope.parent orelse return is_noreturn,
Scope.Id.DeferExpr => unreachable,
Scope.Id.AstTree => unreachable,
}
}
}
pub fn lvalWrap(irb: *Builder, scope: *Scope, instruction: *Inst, lval: LVal) !*Inst {
switch (lval) {
LVal.None => return instruction,
LVal.Ptr => {
// We needed a pointer to a value, but we got a value. So we create
// an instruction which just makes a const pointer of it.
return irb.build(Inst.Ref, scope, instruction.span, Inst.Ref.Params{
.target = instruction,
.mut = Type.Pointer.Mut.Const,
.volatility = Type.Pointer.Vol.Non,
});
},
}
}
fn arena(self: *Builder) *Allocator {
return &self.code.arena.allocator;
}
fn buildExtra(
self: *Builder,
comptime I: type,
scope: *Scope,
span: Span,
params: I.Params,
is_generated: bool,
) !*Inst {
const inst = try self.arena().create(I);
inst.* = I{
.base = Inst{
.id = Inst.typeToId(I),
.is_generated = is_generated,
.scope = scope,
.debug_id = self.next_debug_id,
.val = switch (I.ir_val_init) {
IrVal.Init.Unknown => IrVal.Unknown,
IrVal.Init.NoReturn => IrVal{ .KnownValue = &Value.NoReturn.get(self.comp).base },
IrVal.Init.Void => IrVal{ .KnownValue = &Value.Void.get(self.comp).base },
},
.ref_count = 0,
.span = span,
.child = null,
.parent = null,
.llvm_value = undefined,
.owner_bb = self.current_basic_block,
},
.params = params,
};
// Look at the params and ref() other instructions
comptime var i = 0;
inline while (i < @memberCount(I.Params)) : (i += 1) {
const FieldType = comptime @typeOf(@field(I.Params(undefined), @memberName(I.Params, i)));
switch (FieldType) {
*Inst => @field(inst.params, @memberName(I.Params, i)).ref(self),
*BasicBlock => @field(inst.params, @memberName(I.Params, i)).ref(self),
?*Inst => if (@field(inst.params, @memberName(I.Params, i))) |other| other.ref(self),
[]*Inst => {
// TODO https://github.com/ziglang/zig/issues/1269
for (@field(inst.params, @memberName(I.Params, i))) |other|
other.ref(self);
},
[]*BasicBlock => {
// TODO https://github.com/ziglang/zig/issues/1269
for (@field(inst.params, @memberName(I.Params, i))) |other|
other.ref(self);
},
Type.Pointer.Mut,
Type.Pointer.Vol,
Type.Pointer.Size,
LVal,
*Decl,
*Scope.Var,
=> {},
// it's ok to add more types here, just make sure that
// any instructions and basic blocks are ref'd appropriately
else => @compileError("unrecognized type in Params: " ++ @typeName(FieldType)),
}
}
self.next_debug_id += 1;
try self.current_basic_block.instruction_list.append(&inst.base);
return &inst.base;
}
fn build(
self: *Builder,
comptime I: type,
scope: *Scope,
span: Span,
params: I.Params,
) !*Inst {
return self.buildExtra(I, scope, span, params, false);
}
fn buildGen(
self: *Builder,
comptime I: type,
scope: *Scope,
span: Span,
params: I.Params,
) !*Inst {
return self.buildExtra(I, scope, span, params, true);
}
fn buildConstBool(self: *Builder, scope: *Scope, span: Span, x: bool) !*Inst {
const inst = try self.build(Inst.Const, scope, span, Inst.Const.Params{});
inst.val = IrVal{ .KnownValue = &Value.Bool.get(self.comp, x).base };
return inst;
}
fn buildConstVoid(self: *Builder, scope: *Scope, span: Span, is_generated: bool) !*Inst {
const inst = try self.buildExtra(Inst.Const, scope, span, Inst.Const.Params{}, is_generated);
inst.val = IrVal{ .KnownValue = &Value.Void.get(self.comp).base };
return inst;
}
fn buildConstValue(self: *Builder, scope: *Scope, span: Span, v: *Value) !*Inst {
const inst = try self.build(Inst.Const, scope, span, Inst.Const.Params{});
inst.val = IrVal{ .KnownValue = v.getRef() };
return inst;
}
/// If the code is explicitly set to be comptime, then builds a const bool,
/// otherwise builds a TestCompTime instruction.
fn buildTestCompTime(self: *Builder, scope: *Scope, span: Span, target: *Inst) !*Inst {
if (self.isCompTime(scope)) {
return self.buildConstBool(scope, span, true);
} else {
return self.build(
Inst.TestCompTime,
scope,
span,
Inst.TestCompTime.Params{ .target = target },
);
}
}
fn genAsyncReturn(irb: *Builder, scope: *Scope, span: Span, result: *Inst, is_gen: bool) !*Inst {
_ = try irb.buildGen(
Inst.AddImplicitReturnType,
scope,
span,
Inst.AddImplicitReturnType.Params{ .target = result },
);
if (!irb.is_async) {
return irb.buildExtra(
Inst.Return,
scope,
span,
Inst.Return.Params{ .return_value = result },
is_gen,
);
}
return error.Unimplemented;
}
const Ident = union(enum) {
NotFound,
Decl: *Decl,
VarScope: *Scope.Var,
};
async fn findIdent(irb: *Builder, scope: *Scope, name: []const u8) Ident {
var s = scope;
while (true) {
switch (s.id) {
Scope.Id.Root => return Ident.NotFound,
Scope.Id.Decls => {
const decls = @fieldParentPtr(Scope.Decls, "base", s);
const locked_table = await (async decls.table.acquireRead() catch unreachable);
defer locked_table.release();
if (locked_table.value.get(name)) |entry| {
return Ident{ .Decl = entry.value };
}
},
Scope.Id.Var => {
const var_scope = @fieldParentPtr(Scope.Var, "base", s);
if (mem.eql(u8, var_scope.name, name)) {
return Ident{ .VarScope = var_scope };
}
},
else => {},
}
s = s.parent.?;
}
}
};
const Analyze = struct {
irb: Builder,
old_bb_index: usize,
const_predecessor_bb: ?*BasicBlock,
parent_basic_block: *BasicBlock,
instruction_index: usize,
src_implicit_return_type_list: std.ArrayList(*Inst),
explicit_return_type: ?*Type,
pub const Error = error{
/// This is only for when we have already reported a compile error. It is the poison value.
SemanticAnalysisFailed,
/// This is a placeholder - it is useful to use instead of panicking but once the compiler is
/// done this error code will be removed.
Unimplemented,
OutOfMemory,
};
pub fn init(comp: *Compilation, tree_scope: *Scope.AstTree, explicit_return_type: ?*Type) !Analyze {
var irb = try Builder.init(comp, tree_scope, null);
errdefer irb.abort();
return Analyze{
.irb = irb,
.old_bb_index = 0,
.const_predecessor_bb = null,
.parent_basic_block = undefined, // initialized with startBasicBlock
.instruction_index = undefined, // initialized with startBasicBlock
.src_implicit_return_type_list = std.ArrayList(*Inst).init(irb.arena()),
.explicit_return_type = explicit_return_type,
};
}
pub fn abort(self: *Analyze) void {
self.irb.abort();
}
pub fn getNewBasicBlock(self: *Analyze, old_bb: *BasicBlock, ref_old_instruction: ?*Inst) !*BasicBlock {
if (old_bb.child) |child| {
if (ref_old_instruction == null or child.ref_instruction != ref_old_instruction)
return child;
}
const new_bb = try self.irb.createBasicBlock(old_bb.scope, old_bb.name_hint);
new_bb.linkToParent(old_bb);
new_bb.ref_instruction = ref_old_instruction;
return new_bb;
}
pub fn startBasicBlock(self: *Analyze, old_bb: *BasicBlock, const_predecessor_bb: ?*BasicBlock) void {
self.instruction_index = 0;
self.parent_basic_block = old_bb;
self.const_predecessor_bb = const_predecessor_bb;
}
pub fn finishBasicBlock(ira: *Analyze, old_code: *Code) !void {
try ira.irb.code.basic_block_list.append(ira.irb.current_basic_block);
ira.instruction_index += 1;
while (ira.instruction_index < ira.parent_basic_block.instruction_list.len) {
const next_instruction = ira.parent_basic_block.instruction_list.at(ira.instruction_index);
if (!next_instruction.is_generated) {
try ira.addCompileError(next_instruction.span, "unreachable code");
break;
}
ira.instruction_index += 1;
}
ira.old_bb_index += 1;
var need_repeat = true;
while (true) {
while (ira.old_bb_index < old_code.basic_block_list.len) {
const old_bb = old_code.basic_block_list.at(ira.old_bb_index);
const new_bb = old_bb.child orelse {
ira.old_bb_index += 1;
continue;
};
if (new_bb.instruction_list.len != 0) {
ira.old_bb_index += 1;
continue;
}
ira.irb.current_basic_block = new_bb;
ira.startBasicBlock(old_bb, null);
return;
}
if (!need_repeat)
return;
need_repeat = false;
ira.old_bb_index = 0;
continue;
}
}
fn addCompileError(self: *Analyze, span: Span, comptime fmt: []const u8, args: ...) !void {
return self.irb.comp.addCompileError(self.irb.code.tree_scope, span, fmt, args);
}
fn resolvePeerTypes(self: *Analyze, expected_type: ?*Type, peers: []const *Inst) Analyze.Error!*Type {
// TODO actual implementation
return &Type.Void.get(self.irb.comp).base;
}
fn implicitCast(self: *Analyze, target: *Inst, optional_dest_type: ?*Type) Analyze.Error!*Inst {
const dest_type = optional_dest_type orelse return target;
const from_type = target.getKnownType();
if (from_type == dest_type or from_type.id == Type.Id.NoReturn) return target;
return self.analyzeCast(target, target, dest_type);
}
fn analyzeCast(ira: *Analyze, source_instr: *Inst, target: *Inst, dest_type: *Type) !*Inst {
const from_type = target.getKnownType();
//if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) {
// return ira->codegen->invalid_instruction;
//}
//// perfect match or non-const to const
//ConstCastOnly const_cast_result = types_match_const_cast_only(ira, wanted_type, actual_type,
// source_node, false);
//if (const_cast_result.id == ConstCastResultIdOk) {
// return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop, false);
//}
//// widening conversion
//if (wanted_type->id == TypeTableEntryIdInt &&
// actual_type->id == TypeTableEntryIdInt &&
// wanted_type->data.integral.is_signed == actual_type->data.integral.is_signed &&
// wanted_type->data.integral.bit_count >= actual_type->data.integral.bit_count)
//{
// return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type);
//}
//// small enough unsigned ints can get casted to large enough signed ints
//if (wanted_type->id == TypeTableEntryIdInt && wanted_type->data.integral.is_signed &&
// actual_type->id == TypeTableEntryIdInt && !actual_type->data.integral.is_signed &&
// wanted_type->data.integral.bit_count > actual_type->data.integral.bit_count)
//{
// return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type);
//}
//// float widening conversion
//if (wanted_type->id == TypeTableEntryIdFloat &&
// actual_type->id == TypeTableEntryIdFloat &&
// wanted_type->data.floating.bit_count >= actual_type->data.floating.bit_count)
//{
// return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type);
//}
//// cast from [N]T to []const T
//if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdArray) {
// TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
// types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type);
// }
//}
//// cast from *const [N]T to []const T
//if (is_slice(wanted_type) &&
// actual_type->id == TypeTableEntryIdPointer &&
// actual_type->data.pointer.is_const &&
// actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// TypeTableEntry *array_type = actual_type->data.pointer.child_type;
// if ((ptr_type->data.pointer.is_const || array_type->data.array.len == 0) &&
// types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, array_type->data.array.child_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type);
// }
//}
//// cast from [N]T to *const []const T
//if (wanted_type->id == TypeTableEntryIdPointer &&
// wanted_type->data.pointer.is_const &&
// is_slice(wanted_type->data.pointer.child_type) &&
// actual_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *ptr_type =
// wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
// types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
//}
//// cast from [N]T to ?[]const T
//if (wanted_type->id == TypeTableEntryIdOptional &&
// is_slice(wanted_type->data.maybe.child_type) &&
// actual_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *ptr_type =
// wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
// types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
//}
//// *[N]T to [*]T
//if (wanted_type->id == TypeTableEntryIdPointer &&
// wanted_type->data.pointer.ptr_len == PtrLenUnknown &&
// actual_type->id == TypeTableEntryIdPointer &&
// actual_type->data.pointer.ptr_len == PtrLenSingle &&
// actual_type->data.pointer.child_type->id == TypeTableEntryIdArray &&
// actual_type->data.pointer.alignment >= wanted_type->data.pointer.alignment &&
// types_match_const_cast_only(ira, wanted_type->data.pointer.child_type,
// actual_type->data.pointer.child_type->data.array.child_type, source_node,
// !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk)
//{
// return ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, wanted_type);
//}
//// *[N]T to []T
//if (is_slice(wanted_type) &&
// actual_type->id == TypeTableEntryIdPointer &&
// actual_type->data.pointer.ptr_len == PtrLenSingle &&
// actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(slice_ptr_type->id == TypeTableEntryIdPointer);
// if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type,
// actual_type->data.pointer.child_type->data.array.child_type, source_node,
// !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk)
// {
// return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, wanted_type);
// }
//}
//// cast from T to ?T
//// note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism
//if (wanted_type->id == TypeTableEntryIdOptional) {
// TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;
// if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node,
// false).id == ConstCastResultIdOk)
// {
// return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
// } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
// actual_type->id == TypeTableEntryIdComptimeFloat)
// {
// if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) {
// return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
// } else {
// return ira->codegen->invalid_instruction;
// }
// } else if (wanted_child_type->id == TypeTableEntryIdPointer &&
// wanted_child_type->data.pointer.is_const &&
// (actual_type->id == TypeTableEntryIdPointer || is_container(actual_type)))
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_child_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
//}
//// cast from null literal to maybe type
//if (wanted_type->id == TypeTableEntryIdOptional &&
// actual_type->id == TypeTableEntryIdNull)
//{
// return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type);
//}
//// cast from child type of error type to error type
//if (wanted_type->id == TypeTableEntryIdErrorUnion) {
// if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
// } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
// actual_type->id == TypeTableEntryIdComptimeFloat)
// {
// if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) {
// return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
// } else {
// return ira->codegen->invalid_instruction;
// }
// }
//}
//// cast from [N]T to E![]const T
//if (wanted_type->id == TypeTableEntryIdErrorUnion &&
// is_slice(wanted_type->data.error_union.payload_type) &&
// actual_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *ptr_type =
// wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
// types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
// source_node, false).id == ConstCastResultIdOk)
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
//}
//// cast from error set to error union type
//if (wanted_type->id == TypeTableEntryIdErrorUnion &&
// actual_type->id == TypeTableEntryIdErrorSet)
//{
// return ir_analyze_err_wrap_code(ira, source_instr, value, wanted_type);
//}
//// cast from T to E!?T
//if (wanted_type->id == TypeTableEntryIdErrorUnion &&
// wanted_type->data.error_union.payload_type->id == TypeTableEntryIdOptional &&
// actual_type->id != TypeTableEntryIdOptional)
//{
// TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
// if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk ||
// actual_type->id == TypeTableEntryIdNull ||
// actual_type->id == TypeTableEntryIdComptimeInt ||
// actual_type->id == TypeTableEntryIdComptimeFloat)
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
//}
// cast from comptime-known integer to another integer where the value fits
if (target.isCompTime() and (from_type.id == Type.Id.Int or from_type.id == Type.Id.ComptimeInt)) cast: {
const target_val = target.val.KnownValue;
const from_int = &target_val.cast(Value.Int).?.big_int;
const fits = fits: {
if (dest_type.cast(Type.ComptimeInt)) |ctint| {
break :fits true;
}
if (dest_type.cast(Type.Int)) |int| {
break :fits from_int.fitsInTwosComp(int.key.is_signed, int.key.bit_count);
}
break :cast;
};
if (!fits) {
try ira.addCompileError(
source_instr.span,
"integer value '{}' cannot be stored in type '{}'",
from_int,
dest_type.name,
);
return error.SemanticAnalysisFailed;
}
const new_val = try target.copyVal(ira.irb.comp);
new_val.setType(dest_type, ira.irb.comp);
return ira.irb.buildConstValue(source_instr.scope, source_instr.span, new_val);
}
// cast from number literal to another type
// cast from number literal to *const integer
//if (actual_type->id == TypeTableEntryIdComptimeFloat ||
// actual_type->id == TypeTableEntryIdComptimeInt)
//{
// ensure_complete_type(ira->codegen, wanted_type);
// if (type_is_invalid(wanted_type))
// return ira->codegen->invalid_instruction;
// if (wanted_type->id == TypeTableEntryIdEnum) {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.enumeration.tag_int_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// } else if (wanted_type->id == TypeTableEntryIdPointer &&
// wanted_type->data.pointer.is_const)
// {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) {
// CastOp op;
// if ((actual_type->id == TypeTableEntryIdComptimeFloat &&
// wanted_type->id == TypeTableEntryIdFloat) ||
// (actual_type->id == TypeTableEntryIdComptimeInt &&
// wanted_type->id == TypeTableEntryIdInt))
// {
// op = CastOpNumLitToConcrete;
// } else if (wanted_type->id == TypeTableEntryIdInt) {
// op = CastOpFloatToInt;
// } else if (wanted_type->id == TypeTableEntryIdFloat) {
// op = CastOpIntToFloat;
// } else {
// zig_unreachable();
// }
// return ir_resolve_cast(ira, source_instr, value, wanted_type, op, false);
// } else {
// return ira->codegen->invalid_instruction;
// }
//}
//// cast from typed number to integer or float literal.
//// works when the number is known at compile time
//if (instr_is_comptime(value) &&
// ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdComptimeInt) ||
// (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdComptimeFloat)))
//{
// return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type);
//}
//// cast from union to the enum type of the union
//if (actual_type->id == TypeTableEntryIdUnion && wanted_type->id == TypeTableEntryIdEnum) {
// type_ensure_zero_bits_known(ira->codegen, actual_type);
// if (type_is_invalid(actual_type))
// return ira->codegen->invalid_instruction;
// if (actual_type->data.unionation.tag_type == wanted_type) {
// return ir_analyze_union_to_tag(ira, source_instr, value, wanted_type);
// }
//}
//// enum to union which has the enum as the tag type
//if (wanted_type->id == TypeTableEntryIdUnion && actual_type->id == TypeTableEntryIdEnum &&
// (wanted_type->data.unionation.decl_node->data.container_decl.auto_enum ||
// wanted_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr))
//{
// type_ensure_zero_bits_known(ira->codegen, wanted_type);
// if (wanted_type->data.unionation.tag_type == actual_type) {
// return ir_analyze_enum_to_union(ira, source_instr, value, wanted_type);
// }
//}
//// enum to &const union which has the enum as the tag type
//if (actual_type->id == TypeTableEntryIdEnum && wanted_type->id == TypeTableEntryIdPointer) {
// TypeTableEntry *union_type = wanted_type->data.pointer.child_type;
// if (union_type->data.unionation.decl_node->data.container_decl.auto_enum ||
// union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)
// {
// type_ensure_zero_bits_known(ira->codegen, union_type);
// if (union_type->data.unionation.tag_type == actual_type) {
// IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, union_type, value);
// if (type_is_invalid(cast1->value.type))
// return ira->codegen->invalid_instruction;
// IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
// if (type_is_invalid(cast2->value.type))
// return ira->codegen->invalid_instruction;
// return cast2;
// }
// }
//}
//// cast from *T to *[1]T
//if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle &&
// actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle)
//{
// TypeTableEntry *array_type = wanted_type->data.pointer.child_type;
// if (array_type->id == TypeTableEntryIdArray && array_type->data.array.len == 1 &&
// types_match_const_cast_only(ira, array_type->data.array.child_type,
// actual_type->data.pointer.child_type, source_node,
// !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk)
// {
// if (wanted_type->data.pointer.alignment > actual_type->data.pointer.alignment) {
// ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment"));
// add_error_note(ira->codegen, msg, value->source_node,
// buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&actual_type->name),
// actual_type->data.pointer.alignment));
// add_error_note(ira->codegen, msg, source_instr->source_node,
// buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&wanted_type->name),
// wanted_type->data.pointer.alignment));
// return ira->codegen->invalid_instruction;
// }
// return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type);
// }
//}
//// cast from T to *T where T is zero bits
//if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle &&
// types_match_const_cast_only(ira, wanted_type->data.pointer.child_type,
// actual_type, source_node, !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk)
//{
// type_ensure_zero_bits_known(ira->codegen, actual_type);
// if (type_is_invalid(actual_type)) {
// return ira->codegen->invalid_instruction;
// }
// if (!type_has_bits(actual_type)) {
// return ir_get_ref(ira, source_instr, value, false, false);
// }
//}
//// cast from undefined to anything
//if (actual_type->id == TypeTableEntryIdUndefined) {
// return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type);
//}
//// cast from something to const pointer of it
//if (!type_requires_comptime(actual_type)) {
// TypeTableEntry *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);
// if (types_match_const_cast_only(ira, wanted_type, const_ptr_actual, source_node, false).id == ConstCastResultIdOk) {
// return ir_analyze_cast_ref(ira, source_instr, value, wanted_type);
// }
//}
try ira.addCompileError(
source_instr.span,
"expected type '{}', found '{}'",
dest_type.name,
from_type.name,
);
//ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node,
// buf_sprintf("expected type '%s', found '%s'",
// buf_ptr(&wanted_type->name),
// buf_ptr(&actual_type->name)));
//report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg);
return error.SemanticAnalysisFailed;
}
fn getCompTimeValOrNullUndefOk(self: *Analyze, target: *Inst) ?*Value {
@panic("TODO");
}
fn getCompTimeRef(
self: *Analyze,
value: *Value,
ptr_mut: Value.Ptr.Mut,
mut: Type.Pointer.Mut,
volatility: Type.Pointer.Vol,
) Analyze.Error!*Inst {
return error.Unimplemented;
}
};
pub async fn gen(
comp: *Compilation,
body_node: *ast.Node,
tree_scope: *Scope.AstTree,
scope: *Scope,
) !*Code {
var irb = try Builder.init(comp, tree_scope, scope);
errdefer irb.abort();
const entry_block = try irb.createBasicBlock(scope, c"Entry");
entry_block.ref(&irb); // Entry block gets a reference because we enter it to begin.
try irb.setCursorAtEndAndAppendBlock(entry_block);
const result = try await (async irb.genNode(body_node, scope, LVal.None) catch unreachable);
if (!result.isNoReturn()) {
// no need for save_err_ret_addr because this cannot return error
_ = try irb.genAsyncReturn(scope, Span.token(body_node.lastToken()), result, true);
}
return irb.finish();
}
pub async fn analyze(comp: *Compilation, old_code: *Code, expected_type: ?*Type) !*Code {
const old_entry_bb = old_code.basic_block_list.at(0);
var ira = try Analyze.init(comp, old_code.tree_scope, expected_type);
errdefer ira.abort();
const new_entry_bb = try ira.getNewBasicBlock(old_entry_bb, null);
new_entry_bb.ref(&ira.irb);
ira.irb.current_basic_block = new_entry_bb;
ira.startBasicBlock(old_entry_bb, null);
while (ira.old_bb_index < old_code.basic_block_list.len) {
const old_instruction = ira.parent_basic_block.instruction_list.at(ira.instruction_index);
if (old_instruction.ref_count == 0 and !old_instruction.hasSideEffects()) {
ira.instruction_index += 1;
continue;
}
const return_inst = try await (async old_instruction.analyze(&ira) catch unreachable);
assert(return_inst.val != IrVal.Unknown); // at least the type should be known at this point
return_inst.linkToParent(old_instruction);
// Note: if we ever modify the above to handle error.CompileError by continuing analysis,
// then here we want to check if ira.isCompTime() and return early if true
if (return_inst.isNoReturn()) {
try ira.finishBasicBlock(old_code);
continue;
}
ira.instruction_index += 1;
}
if (ira.src_implicit_return_type_list.len == 0) {
ira.irb.code.return_type = &Type.NoReturn.get(comp).base;
return ira.irb.finish();
}
ira.irb.code.return_type = try ira.resolvePeerTypes(expected_type, ira.src_implicit_return_type_list.toSliceConst());
return ira.irb.finish();
} | src-self-hosted/ir.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
// const Batch = std.event.Batch;
// const Group = std.event.Group;
// const Locked = std.event.Locked;
const regex = @import("regex");
const clap = @import("clap");
const lscolors = @import("lscolors");
const LsColors = lscolors.LsColors;
const walkdir = @import("walkdir");
const Entry = walkdir.Entry;
const DepthFirstWalker = walkdir.DepthFirstWalker;
const BreadthFirstWalker = walkdir.BreadthFirstWalker;
const actions = @import("actions.zig");
const Action = actions.Action;
const ColorOption = actions.ColorOption;
const PrintOptions = actions.PrintOptions;
const filters = @import("filter.zig");
const Filter = filters.Filter;
const TypeFilter = filters.TypeFilter;
const cli = @import("cli.zig");
const BufferedWriter = std.io.BufferedWriter(4096, std.fs.File.Writer);
// pub const io_mode = .evented;
inline fn handleEntry(
e: Entry,
f: Filter,
action: *Action,
print_options: actions.PrintOptions,
writer: *BufferedWriter,
) void {
const matches = f.matches(e) catch false;
defer switch (action.*) {
.ExecuteBatch => if (!matches) e.deinit(),
else => e.deinit(),
};
if (!matches) return;
// const held_action = locked_action.acquire();
// defer held_action.release();
switch (action.*) {
.Print => {
// const held = locked_writer.acquire();
// defer held.release();
// const out = held.value.writer();
actions.printEntry(e, writer.writer(), print_options) catch return;
},
.Execute => |*a| a.do(e) catch return,
.ExecuteBatch => |*a| a.do(e) catch return,
}
}
pub fn main() !void {
// Set up allocators
// var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
// defer arena.deinit();
// const allocator = &arena.allocator;
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Set up stdout
const stdout_file = std.io.getStdOut();
const stdout = stdout_file.writer();
var buffered_stdout = std.io.bufferedWriter(stdout);
defer buffered_stdout.flush() catch {};
// var buffered_stdout_locked = Locked(BufferedOut).init(buffered_stdout);
// defer buffered_stdout_locked.deinit();
// defer {
// const held = buffered_stdout_locked.acquire();
// defer held.release();
// held.value.flush() catch {};
// }
var lsc: ?LsColors = null;
defer if (lsc) |*x| x.deinit();
var cli_options = cli.parseCliOptions(allocator) catch |err| switch (err) {
error.Help, error.ParseCliError => std.process.exit(1),
else => return err,
};
defer cli_options.deinit();
// Set up colored output
if (cli_options.color == .Always or cli_options.color == .Auto and stdout_file.isTty()) {
lsc = try LsColors.fromEnv(allocator);
cli_options.print.color = &lsc.?;
}
// If no search paths were given, default to the current
// working directory.
const search_paths = if (cli_options.paths.len == 0) &[_][]const u8{"."} else cli_options.paths;
outer: for (search_paths) |search_path| {
var walker = try DepthFirstWalker.init(allocator, search_path, cli_options.walkdir);
// var walker = try BreadthFirstWalker.init(allocator, search_path, cli_options.walkdir);
defer walker.deinit();
while (true) {
if (walker.next()) |entry| {
if (entry) |e| {
handleEntry(
e,
cli_options.filter,
&cli_options.action,
cli_options.print,
&buffered_stdout,
);
} else {
continue :outer;
}
} else |err| {
std.log.err("Error encountered: {}", .{err});
}
}
}
// Complete async group
// batch.wait();
// If the action ExecuteBatch is chosen, we have to execute the action after
// all entries have been found
switch (cli_options.action) {
.ExecuteBatch => |*a| try a.finalize(),
else => {},
}
} | src/main.zig |
//
// This header is generated from the Khronos Vulkan XML API Registry.
//
//
const assert = @import("std").debug.assert;
pub const CString = [*:0]const u8;
pub fn FlagsMixin(comptime FlagType: type) type {
comptime assert(@sizeOf(FlagType) == 4);
return struct {
pub const IntType = Flags;
pub fn toInt(self: FlagType) Flags {
return @bitCast(Flags, self);
}
pub fn fromInt(value: Flags) FlagType {
return @bitCast(FlagType, value);
}
pub fn with(a: FlagType, b: FlagType) FlagType {
return fromInt(toInt(a) | toInt(b));
}
pub fn only(a: FlagType, b: FlagType) FlagType {
return fromInt(toInt(a) & toInt(b));
}
pub fn without(a: FlagType, b: FlagType) FlagType {
return fromInt(toInt(a) & ~toInt(b));
}
pub fn hasAllSet(a: FlagType, b: FlagType) bool {
return (toInt(a) & toInt(b)) == toInt(b);
}
pub fn hasAnySet(a: FlagType, b: FlagType) bool {
return (toInt(a) & toInt(b)) != 0;
}
pub fn isEmpty(a: FlagType) bool {
return toInt(a) == 0;
}
};
}
const builtin = @import("builtin");
pub const CallConv = if (builtin.os.tag == .windows)
builtin.CallingConvention.Stdcall
else if (builtin.abi == .android and (builtin.cpu.arch.isARM() or builtin.cpu.arch.isThumb()) and builtin.Target.arm.featureSetHas(builtin.cpu.features, .has_v7) and builtin.cpu.arch.ptrBitWidth() == 32)
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
// is true even if the rest of the application passes floats on the stack,
// as it does by default when compiling for the armeabi-v7a NDK ABI.
builtin.CallingConvention.AAPCSVFP
else
builtin.CallingConvention.C;
pub const VERSION_1_0 = 1;
pub fn MAKE_VERSION(major: u32, minor: u32, patch: u32) u32 { return @shlExact(major, 22) | @shlExact(minor, 12) | patch; }
// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead.
//pub const API_VERSION = MAKE_VERSION(1, 0, 0); // Patch version should always be set to 0
// Vulkan 1.0 version number
pub const API_VERSION_1_0 = MAKE_VERSION(1, 0, 0);// Patch version should always be set to 0
pub fn VERSION_MAJOR(version: u32) u32 { return version >> 22; }
pub fn VERSION_MINOR(version: u32) u32 { return (version >> 12) & 0x3ff; }
pub fn VERSION_PATCH(version: u32) u32 { return version & 0xfff; }
// Version of this file
pub const HEADER_VERSION = 132;
pub const Flags = u32;
pub const Bool32 = u32;
pub const DeviceSize = u64;
pub const SampleMask = u32;
pub const Instance = *@OpaqueType();
pub const PhysicalDevice = *@OpaqueType();
pub const Device = *@OpaqueType();
pub const Queue = *@OpaqueType();
pub const Semaphore = *@OpaqueType();
pub const CommandBuffer = *@OpaqueType();
pub const Fence = *@OpaqueType();
pub const DeviceMemory = *@OpaqueType();
pub const Buffer = *@OpaqueType();
pub const Image = *@OpaqueType();
pub const Event = *@OpaqueType();
pub const QueryPool = *@OpaqueType();
pub const BufferView = *@OpaqueType();
pub const ImageView = *@OpaqueType();
pub const ShaderModule = *@OpaqueType();
pub const PipelineCache = *@OpaqueType();
pub const PipelineLayout = *@OpaqueType();
pub const RenderPass = *@OpaqueType();
pub const Pipeline = *@OpaqueType();
pub const DescriptorSetLayout = *@OpaqueType();
pub const Sampler = *@OpaqueType();
pub const DescriptorPool = *@OpaqueType();
pub const DescriptorSet = *@OpaqueType();
pub const Framebuffer = *@OpaqueType();
pub const CommandPool = *@OpaqueType();
pub const LOD_CLAMP_NONE = @as(f32, 1000.0);
pub const REMAINING_MIP_LEVELS = (~@as(u32, 0));
pub const REMAINING_ARRAY_LAYERS = (~@as(u32, 0));
pub const WHOLE_SIZE = (~@as(u64, 0));
pub const ATTACHMENT_UNUSED = (~@as(u32, 0));
pub const TRUE = 1;
pub const FALSE = 0;
pub const QUEUE_FAMILY_IGNORED = (~@as(u32, 0));
pub const SUBPASS_EXTERNAL = (~@as(u32, 0));
pub const MAX_PHYSICAL_DEVICE_NAME_SIZE = 256;
pub const UUID_SIZE = 16;
pub const MAX_MEMORY_TYPES = 32;
pub const MAX_MEMORY_HEAPS = 16;
pub const MAX_EXTENSION_NAME_SIZE = 256;
pub const MAX_DESCRIPTION_SIZE = 256;
pub const PipelineCacheHeaderVersion = extern enum(i32) {
ONE = 1,
_,
};
pub const Result = extern enum(i32) {
SUCCESS = 0,
NOT_READY = 1,
TIMEOUT = 2,
EVENT_SET = 3,
EVENT_RESET = 4,
INCOMPLETE = 5,
ERROR_OUT_OF_HOST_MEMORY = -1,
ERROR_OUT_OF_DEVICE_MEMORY = -2,
ERROR_INITIALIZATION_FAILED = -3,
ERROR_DEVICE_LOST = -4,
ERROR_MEMORY_MAP_FAILED = -5,
ERROR_LAYER_NOT_PRESENT = -6,
ERROR_EXTENSION_NOT_PRESENT = -7,
ERROR_FEATURE_NOT_PRESENT = -8,
ERROR_INCOMPATIBLE_DRIVER = -9,
ERROR_TOO_MANY_OBJECTS = -10,
ERROR_FORMAT_NOT_SUPPORTED = -11,
ERROR_FRAGMENTED_POOL = -12,
ERROR_UNKNOWN = -13,
ERROR_OUT_OF_POOL_MEMORY = -1000069000,
ERROR_INVALID_EXTERNAL_HANDLE = -1000072003,
ERROR_FRAGMENTATION = -1000161000,
ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000,
ERROR_SURFACE_LOST_KHR = -1000000000,
ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
SUBOPTIMAL_KHR = 1000001003,
ERROR_OUT_OF_DATE_KHR = -1000001004,
ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
ERROR_VALIDATION_FAILED_EXT = -1000011001,
ERROR_INVALID_SHADER_NV = -1000012000,
ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000,
ERROR_NOT_PERMITTED_EXT = -1000174001,
ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000,
_,
const Self = @This();
pub const ERROR_OUT_OF_POOL_MEMORY_KHR = Self.ERROR_OUT_OF_POOL_MEMORY;
pub const ERROR_INVALID_EXTERNAL_HANDLE_KHR = Self.ERROR_INVALID_EXTERNAL_HANDLE;
pub const ERROR_FRAGMENTATION_EXT = Self.ERROR_FRAGMENTATION;
pub const ERROR_INVALID_DEVICE_ADDRESS_EXT = Self.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS;
pub const ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = Self.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS;
};
pub const StructureType = extern enum(i32) {
APPLICATION_INFO = 0,
INSTANCE_CREATE_INFO = 1,
DEVICE_QUEUE_CREATE_INFO = 2,
DEVICE_CREATE_INFO = 3,
SUBMIT_INFO = 4,
MEMORY_ALLOCATE_INFO = 5,
MAPPED_MEMORY_RANGE = 6,
BIND_SPARSE_INFO = 7,
FENCE_CREATE_INFO = 8,
SEMAPHORE_CREATE_INFO = 9,
EVENT_CREATE_INFO = 10,
QUERY_POOL_CREATE_INFO = 11,
BUFFER_CREATE_INFO = 12,
BUFFER_VIEW_CREATE_INFO = 13,
IMAGE_CREATE_INFO = 14,
IMAGE_VIEW_CREATE_INFO = 15,
SHADER_MODULE_CREATE_INFO = 16,
PIPELINE_CACHE_CREATE_INFO = 17,
PIPELINE_SHADER_STAGE_CREATE_INFO = 18,
PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19,
PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21,
PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22,
PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23,
PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24,
PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25,
PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26,
PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27,
GRAPHICS_PIPELINE_CREATE_INFO = 28,
COMPUTE_PIPELINE_CREATE_INFO = 29,
PIPELINE_LAYOUT_CREATE_INFO = 30,
SAMPLER_CREATE_INFO = 31,
DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32,
DESCRIPTOR_POOL_CREATE_INFO = 33,
DESCRIPTOR_SET_ALLOCATE_INFO = 34,
WRITE_DESCRIPTOR_SET = 35,
COPY_DESCRIPTOR_SET = 36,
FRAMEBUFFER_CREATE_INFO = 37,
RENDER_PASS_CREATE_INFO = 38,
COMMAND_POOL_CREATE_INFO = 39,
COMMAND_BUFFER_ALLOCATE_INFO = 40,
COMMAND_BUFFER_INHERITANCE_INFO = 41,
COMMAND_BUFFER_BEGIN_INFO = 42,
RENDER_PASS_BEGIN_INFO = 43,
BUFFER_MEMORY_BARRIER = 44,
IMAGE_MEMORY_BARRIER = 45,
MEMORY_BARRIER = 46,
LOADER_INSTANCE_CREATE_INFO = 47,
LOADER_DEVICE_CREATE_INFO = 48,
PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000,
BIND_BUFFER_MEMORY_INFO = 1000157000,
BIND_IMAGE_MEMORY_INFO = 1000157001,
PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000,
MEMORY_DEDICATED_REQUIREMENTS = 1000127000,
MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001,
MEMORY_ALLOCATE_FLAGS_INFO = 1000060000,
DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003,
DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004,
DEVICE_GROUP_SUBMIT_INFO = 1000060005,
DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006,
BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013,
BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014,
PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000,
DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001,
BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000,
IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001,
IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002,
MEMORY_REQUIREMENTS_2 = 1000146003,
SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004,
PHYSICAL_DEVICE_FEATURES_2 = 1000059000,
PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001,
FORMAT_PROPERTIES_2 = 1000059002,
IMAGE_FORMAT_PROPERTIES_2 = 1000059003,
PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004,
QUEUE_FAMILY_PROPERTIES_2 = 1000059005,
PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006,
SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007,
PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008,
PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000,
RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001,
IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002,
PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003,
RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000,
PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001,
PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002,
PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000,
PROTECTED_SUBMIT_INFO = 1000145000,
PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001,
PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002,
DEVICE_QUEUE_INFO_2 = 1000145003,
SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000,
SAMPLER_YCBCR_CONVERSION_INFO = 1000156001,
BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002,
IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003,
PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004,
SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005,
DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000,
PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000,
EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001,
PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002,
EXTERNAL_BUFFER_PROPERTIES = 1000071003,
PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004,
EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000,
EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001,
EXPORT_MEMORY_ALLOCATE_INFO = 1000072002,
PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000,
EXTERNAL_FENCE_PROPERTIES = 1000112001,
EXPORT_FENCE_CREATE_INFO = 1000113000,
EXPORT_SEMAPHORE_CREATE_INFO = 1000077000,
PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000,
EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001,
PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000,
DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001,
PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000,
PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49,
PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50,
PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51,
PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52,
IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000,
ATTACHMENT_DESCRIPTION_2 = 1000109000,
ATTACHMENT_REFERENCE_2 = 1000109001,
SUBPASS_DESCRIPTION_2 = 1000109002,
SUBPASS_DEPENDENCY_2 = 1000109003,
RENDER_PASS_CREATE_INFO_2 = 1000109004,
SUBPASS_BEGIN_INFO = 1000109005,
SUBPASS_END_INFO = 1000109006,
PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000,
PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000,
PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000,
PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000,
PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000,
DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000,
PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001,
PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002,
DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003,
DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004,
PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000,
SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001,
PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000,
IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000,
PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000,
SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001,
PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000,
PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000,
FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001,
FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002,
RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003,
PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000,
PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000,
PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000,
ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001,
ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002,
PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000,
PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000,
PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001,
SEMAPHORE_TYPE_CREATE_INFO = 1000207002,
TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003,
SEMAPHORE_WAIT_INFO = 1000207004,
SEMAPHORE_SIGNAL_INFO = 1000207005,
PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000,
BUFFER_DEVICE_ADDRESS_INFO = 1000244001,
BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002,
MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003,
DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004,
SWAPCHAIN_CREATE_INFO_KHR = 1000001000,
PRESENT_INFO_KHR = 1000001001,
DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007,
IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008,
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009,
ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010,
DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011,
DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012,
DISPLAY_MODE_CREATE_INFO_KHR = 1000002000,
DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001,
DISPLAY_PRESENT_INFO_KHR = 1000003000,
XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000,
WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000,
DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000,
DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001,
DEBUG_MARKER_MARKER_INFO_EXT = 1000022002,
DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000,
DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001,
DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002,
PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT = 1000028000,
PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT = 1000028001,
PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT = 1000028002,
IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000,
TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000,
STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP = 1000049000,
PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV = 1000050000,
EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000,
EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001,
IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000,
EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001,
WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000,
VALIDATION_FLAGS_EXT = 1000061000,
VI_SURFACE_CREATE_INFO_NN = 1000062000,
PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT = 1000066000,
IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000,
PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001,
IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000,
EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001,
MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002,
MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003,
IMPORT_MEMORY_FD_INFO_KHR = 1000074000,
MEMORY_FD_PROPERTIES_KHR = 1000074001,
MEMORY_GET_FD_INFO_KHR = 1000074002,
WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000,
IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000,
EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001,
D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002,
SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003,
IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000,
SEMAPHORE_GET_FD_INFO_KHR = 1000079001,
PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000,
COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT = 1000081000,
PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT = 1000081001,
CONDITIONAL_RENDERING_BEGIN_INFO_EXT = 1000081002,
PRESENT_REGIONS_KHR = 1000084000,
OBJECT_TABLE_CREATE_INFO_NVX = 1000086000,
INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NVX = 1000086001,
CMD_PROCESS_COMMANDS_INFO_NVX = 1000086002,
CMD_RESERVE_SPACE_FOR_COMMANDS_INFO_NVX = 1000086003,
DEVICE_GENERATED_COMMANDS_LIMITS_NVX = 1000086004,
DEVICE_GENERATED_COMMANDS_FEATURES_NVX = 1000086005,
PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000,
SURFACE_CAPABILITIES_2_EXT = 1000090000,
DISPLAY_POWER_INFO_EXT = 1000091000,
DEVICE_EVENT_INFO_EXT = 1000091001,
DISPLAY_EVENT_INFO_EXT = 1000091002,
SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003,
PRESENT_TIMES_INFO_GOOGLE = 1000092000,
PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000,
PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000,
PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000,
PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001,
PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT = 1000101000,
PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT = 1000101001,
PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000,
PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001,
HDR_METADATA_EXT = 1000105000,
SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000,
IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000,
EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001,
FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002,
IMPORT_FENCE_FD_INFO_KHR = 1000115000,
FENCE_GET_FD_INFO_KHR = 1000115001,
PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR = 1000116000,
PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR = 1000116001,
QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR = 1000116002,
PERFORMANCE_QUERY_SUBMIT_INFO_KHR = 1000116003,
ACQUIRE_PROFILING_LOCK_INFO_KHR = 1000116004,
PERFORMANCE_COUNTER_KHR = 1000116005,
PERFORMANCE_COUNTER_DESCRIPTION_KHR = 1000116006,
PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000,
SURFACE_CAPABILITIES_2_KHR = 1000119001,
SURFACE_FORMAT_2_KHR = 1000119002,
DISPLAY_PROPERTIES_2_KHR = 1000121000,
DISPLAY_PLANE_PROPERTIES_2_KHR = 1000121001,
DISPLAY_MODE_PROPERTIES_2_KHR = 1000121002,
DISPLAY_PLANE_INFO_2_KHR = 1000121003,
DISPLAY_PLANE_CAPABILITIES_2_KHR = 1000121004,
IOS_SURFACE_CREATE_INFO_MVK = 1000122000,
MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000,
DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001,
DEBUG_UTILS_LABEL_EXT = 1000128002,
DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = 1000128003,
DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = 1000128004,
ANDROID_HARDWARE_BUFFER_USAGE_ANDROID = 1000129000,
ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID = 1000129001,
ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID = 1000129002,
IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129003,
MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004,
EXTERNAL_FORMAT_ANDROID = 1000129005,
PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT = 1000138000,
PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT = 1000138001,
WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT = 1000138002,
DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT = 1000138003,
SAMPLE_LOCATIONS_INFO_EXT = 1000143000,
RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001,
PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002,
PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003,
MULTISAMPLE_PROPERTIES_EXT = 1000143004,
PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000,
PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001,
PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002,
PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000,
PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000,
PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV = 1000154000,
PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV = 1000154001,
DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT = 1000158000,
DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158001,
PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT = 1000158002,
IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT = 1000158003,
IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT = 1000158004,
IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158005,
VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000,
SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001,
PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV = 1000164000,
PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV = 1000164001,
PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV = 1000164002,
PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV = 1000164005,
RAY_TRACING_PIPELINE_CREATE_INFO_NV = 1000165000,
ACCELERATION_STRUCTURE_CREATE_INFO_NV = 1000165001,
GEOMETRY_NV = 1000165003,
GEOMETRY_TRIANGLES_NV = 1000165004,
GEOMETRY_AABB_NV = 1000165005,
BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV = 1000165006,
WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV = 1000165007,
ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV = 1000165008,
PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV = 1000165009,
RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV = 1000165011,
ACCELERATION_STRUCTURE_INFO_NV = 1000165012,
PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV = 1000166000,
PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV = 1000166001,
PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT = 1000170000,
FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT = 1000170001,
DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = 1000174000,
IMPORT_MEMORY_HOST_POINTER_INFO_EXT = 1000178000,
MEMORY_HOST_POINTER_PROPERTIES_EXT = 1000178001,
PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002,
PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000,
PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000,
CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000,
PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000,
DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000,
PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000,
PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = 1000190001,
PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = 1000190002,
PRESENT_FRAME_TOKEN_GGP = 1000191000,
PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000192000,
PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000,
PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000,
PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001,
PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = 1000203000,
PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000,
PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000,
PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002,
CHECKPOINT_DATA_NV = 1000206000,
QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV = 1000206001,
PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL = 1000209000,
QUERY_POOL_CREATE_INFO_INTEL = 1000210000,
INITIALIZE_PERFORMANCE_API_INFO_INTEL = 1000210001,
PERFORMANCE_MARKER_INFO_INTEL = 1000210002,
PERFORMANCE_STREAM_MARKER_INFO_INTEL = 1000210003,
PERFORMANCE_OVERRIDE_INFO_INTEL = 1000210004,
PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL = 1000210005,
PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000,
DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD = 1000213000,
SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD = 1000213001,
IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA = 1000214000,
METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT = 1000218000,
PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT = 1000218001,
RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT = 1000218002,
PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT = 1000225000,
PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = 1000225001,
PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT = 1000225002,
PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD = 1000227000,
PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD = 1000229000,
PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT = 1000237000,
PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT = 1000238000,
MEMORY_PRIORITY_ALLOCATE_INFO_EXT = 1000238001,
SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000,
PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV = 1000240000,
PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000,
BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT = 1000244002,
PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT = 1000245000,
VALIDATION_FEATURES_EXT = 1000247000,
PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV = 1000249000,
COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249001,
PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249002,
PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000,
PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001,
FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002,
PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT = 1000251000,
PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT = 1000252000,
SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT = 1000255000,
SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT = 1000255002,
SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT = 1000255001,
HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000,
PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT = 1000259000,
PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT = 1000259001,
PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT = 1000259002,
PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT = 1000265000,
PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR = 1000269000,
PIPELINE_INFO_KHR = 1000269001,
PIPELINE_EXECUTABLE_PROPERTIES_KHR = 1000269002,
PIPELINE_EXECUTABLE_INFO_KHR = 1000269003,
PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004,
PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005,
PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT = 1000276000,
PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000,
PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT = 1000281001,
_,
const Self = @This();
pub const PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = Self.PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES;
pub const PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = Self.PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES;
pub const DEBUG_REPORT_CREATE_INFO_EXT = Self.DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
pub const RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR = Self.RENDER_PASS_MULTIVIEW_CREATE_INFO;
pub const PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR = Self.PHYSICAL_DEVICE_MULTIVIEW_FEATURES;
pub const PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES;
pub const PHYSICAL_DEVICE_FEATURES_2_KHR = Self.PHYSICAL_DEVICE_FEATURES_2;
pub const PHYSICAL_DEVICE_PROPERTIES_2_KHR = Self.PHYSICAL_DEVICE_PROPERTIES_2;
pub const FORMAT_PROPERTIES_2_KHR = Self.FORMAT_PROPERTIES_2;
pub const IMAGE_FORMAT_PROPERTIES_2_KHR = Self.IMAGE_FORMAT_PROPERTIES_2;
pub const PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = Self.PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
pub const QUEUE_FAMILY_PROPERTIES_2_KHR = Self.QUEUE_FAMILY_PROPERTIES_2;
pub const PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = Self.PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
pub const SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = Self.SPARSE_IMAGE_FORMAT_PROPERTIES_2;
pub const PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = Self.PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2;
pub const MEMORY_ALLOCATE_FLAGS_INFO_KHR = Self.MEMORY_ALLOCATE_FLAGS_INFO;
pub const DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHR = Self.DEVICE_GROUP_RENDER_PASS_BEGIN_INFO;
pub const DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR = Self.DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO;
pub const DEVICE_GROUP_SUBMIT_INFO_KHR = Self.DEVICE_GROUP_SUBMIT_INFO;
pub const DEVICE_GROUP_BIND_SPARSE_INFO_KHR = Self.DEVICE_GROUP_BIND_SPARSE_INFO;
pub const BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR = Self.BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO;
pub const BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR = Self.BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO;
pub const PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_GROUP_PROPERTIES;
pub const DEVICE_GROUP_DEVICE_CREATE_INFO_KHR = Self.DEVICE_GROUP_DEVICE_CREATE_INFO;
pub const PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = Self.PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO;
pub const EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = Self.EXTERNAL_IMAGE_FORMAT_PROPERTIES;
pub const PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = Self.PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO;
pub const EXTERNAL_BUFFER_PROPERTIES_KHR = Self.EXTERNAL_BUFFER_PROPERTIES;
pub const PHYSICAL_DEVICE_ID_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_ID_PROPERTIES;
pub const EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = Self.EXTERNAL_MEMORY_BUFFER_CREATE_INFO;
pub const EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = Self.EXTERNAL_MEMORY_IMAGE_CREATE_INFO;
pub const EXPORT_MEMORY_ALLOCATE_INFO_KHR = Self.EXPORT_MEMORY_ALLOCATE_INFO;
pub const PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = Self.PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO;
pub const EXTERNAL_SEMAPHORE_PROPERTIES_KHR = Self.EXTERNAL_SEMAPHORE_PROPERTIES;
pub const EXPORT_SEMAPHORE_CREATE_INFO_KHR = Self.EXPORT_SEMAPHORE_CREATE_INFO;
pub const PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR = Self.PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
pub const PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR = Self.PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
pub const PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = Self.PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
pub const DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = Self.DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO;
pub const SURFACE_CAPABILITIES2_EXT = Self.SURFACE_CAPABILITIES_2_EXT;
pub const PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR = Self.PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES;
pub const FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR = Self.FRAMEBUFFER_ATTACHMENTS_CREATE_INFO;
pub const FRAMEBUFFER_ATTACHMENT_IMAGE_INFO_KHR = Self.FRAMEBUFFER_ATTACHMENT_IMAGE_INFO;
pub const RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR = Self.RENDER_PASS_ATTACHMENT_BEGIN_INFO;
pub const ATTACHMENT_DESCRIPTION_2_KHR = Self.ATTACHMENT_DESCRIPTION_2;
pub const ATTACHMENT_REFERENCE_2_KHR = Self.ATTACHMENT_REFERENCE_2;
pub const SUBPASS_DESCRIPTION_2_KHR = Self.SUBPASS_DESCRIPTION_2;
pub const SUBPASS_DEPENDENCY_2_KHR = Self.SUBPASS_DEPENDENCY_2;
pub const RENDER_PASS_CREATE_INFO_2_KHR = Self.RENDER_PASS_CREATE_INFO_2;
pub const SUBPASS_BEGIN_INFO_KHR = Self.SUBPASS_BEGIN_INFO;
pub const SUBPASS_END_INFO_KHR = Self.SUBPASS_END_INFO;
pub const PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = Self.PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO;
pub const EXTERNAL_FENCE_PROPERTIES_KHR = Self.EXTERNAL_FENCE_PROPERTIES;
pub const EXPORT_FENCE_CREATE_INFO_KHR = Self.EXPORT_FENCE_CREATE_INFO;
pub const PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES;
pub const RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = Self.RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO;
pub const IMAGE_VIEW_USAGE_CREATE_INFO_KHR = Self.IMAGE_VIEW_USAGE_CREATE_INFO;
pub const PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = Self.PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
pub const PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = Self.PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES;
pub const PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR = Self.PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES;
pub const MEMORY_DEDICATED_REQUIREMENTS_KHR = Self.MEMORY_DEDICATED_REQUIREMENTS;
pub const MEMORY_DEDICATED_ALLOCATE_INFO_KHR = Self.MEMORY_DEDICATED_ALLOCATE_INFO;
pub const PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = Self.PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES;
pub const SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = Self.SAMPLER_REDUCTION_MODE_CREATE_INFO;
pub const BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = Self.BUFFER_MEMORY_REQUIREMENTS_INFO_2;
pub const IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = Self.IMAGE_MEMORY_REQUIREMENTS_INFO_2;
pub const IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = Self.IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2;
pub const MEMORY_REQUIREMENTS_2_KHR = Self.MEMORY_REQUIREMENTS_2;
pub const SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = Self.SPARSE_IMAGE_MEMORY_REQUIREMENTS_2;
pub const IMAGE_FORMAT_LIST_CREATE_INFO_KHR = Self.IMAGE_FORMAT_LIST_CREATE_INFO;
pub const SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = Self.SAMPLER_YCBCR_CONVERSION_CREATE_INFO;
pub const SAMPLER_YCBCR_CONVERSION_INFO_KHR = Self.SAMPLER_YCBCR_CONVERSION_INFO;
pub const BIND_IMAGE_PLANE_MEMORY_INFO_KHR = Self.BIND_IMAGE_PLANE_MEMORY_INFO;
pub const IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = Self.IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO;
pub const PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = Self.PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
pub const SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = Self.SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES;
pub const BIND_BUFFER_MEMORY_INFO_KHR = Self.BIND_BUFFER_MEMORY_INFO;
pub const BIND_IMAGE_MEMORY_INFO_KHR = Self.BIND_IMAGE_MEMORY_INFO;
pub const DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT = Self.DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO;
pub const PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT = Self.PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
pub const PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT = Self.PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES;
pub const DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT = Self.DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO;
pub const DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT = Self.DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT;
pub const PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES;
pub const DESCRIPTOR_SET_LAYOUT_SUPPORT_KHR = Self.DESCRIPTOR_SET_LAYOUT_SUPPORT;
pub const PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = Self.PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES;
pub const PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = Self.PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
pub const PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = Self.PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES;
pub const PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_DRIVER_PROPERTIES;
pub const PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES;
pub const PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES;
pub const SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = Self.SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE;
pub const PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = Self.PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES;
pub const PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = Self.PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES;
pub const SEMAPHORE_TYPE_CREATE_INFO_KHR = Self.SEMAPHORE_TYPE_CREATE_INFO;
pub const TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR = Self.TIMELINE_SEMAPHORE_SUBMIT_INFO;
pub const SEMAPHORE_WAIT_INFO_KHR = Self.SEMAPHORE_WAIT_INFO;
pub const SEMAPHORE_SIGNAL_INFO_KHR = Self.SEMAPHORE_SIGNAL_INFO;
pub const PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = Self.PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES;
pub const PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = Self.PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES;
pub const PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR = Self.PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES;
pub const ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR = Self.ATTACHMENT_REFERENCE_STENCIL_LAYOUT;
pub const ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR = Self.ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT;
pub const PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT = Self.PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT;
pub const BUFFER_DEVICE_ADDRESS_INFO_EXT = Self.BUFFER_DEVICE_ADDRESS_INFO;
pub const IMAGE_STENCIL_USAGE_CREATE_INFO_EXT = Self.IMAGE_STENCIL_USAGE_CREATE_INFO;
pub const PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR = Self.PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES;
pub const PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR = Self.PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES;
pub const BUFFER_DEVICE_ADDRESS_INFO_KHR = Self.BUFFER_DEVICE_ADDRESS_INFO;
pub const BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO_KHR = Self.BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO;
pub const MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO_KHR = Self.MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO;
pub const DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO_KHR = Self.DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO;
pub const PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT = Self.PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES;
};
pub const SystemAllocationScope = extern enum(i32) {
COMMAND = 0,
OBJECT = 1,
CACHE = 2,
DEVICE = 3,
INSTANCE = 4,
_,
};
pub const InternalAllocationType = extern enum(i32) {
EXECUTABLE = 0,
_,
};
pub const Format = extern enum(i32) {
UNDEFINED = 0,
R4G4_UNORM_PACK8 = 1,
R4G4B4A4_UNORM_PACK16 = 2,
B4G4R4A4_UNORM_PACK16 = 3,
R5G6B5_UNORM_PACK16 = 4,
B5G6R5_UNORM_PACK16 = 5,
R5G5B5A1_UNORM_PACK16 = 6,
B5G5R5A1_UNORM_PACK16 = 7,
A1R5G5B5_UNORM_PACK16 = 8,
R8_UNORM = 9,
R8_SNORM = 10,
R8_USCALED = 11,
R8_SSCALED = 12,
R8_UINT = 13,
R8_SINT = 14,
R8_SRGB = 15,
R8G8_UNORM = 16,
R8G8_SNORM = 17,
R8G8_USCALED = 18,
R8G8_SSCALED = 19,
R8G8_UINT = 20,
R8G8_SINT = 21,
R8G8_SRGB = 22,
R8G8B8_UNORM = 23,
R8G8B8_SNORM = 24,
R8G8B8_USCALED = 25,
R8G8B8_SSCALED = 26,
R8G8B8_UINT = 27,
R8G8B8_SINT = 28,
R8G8B8_SRGB = 29,
B8G8R8_UNORM = 30,
B8G8R8_SNORM = 31,
B8G8R8_USCALED = 32,
B8G8R8_SSCALED = 33,
B8G8R8_UINT = 34,
B8G8R8_SINT = 35,
B8G8R8_SRGB = 36,
R8G8B8A8_UNORM = 37,
R8G8B8A8_SNORM = 38,
R8G8B8A8_USCALED = 39,
R8G8B8A8_SSCALED = 40,
R8G8B8A8_UINT = 41,
R8G8B8A8_SINT = 42,
R8G8B8A8_SRGB = 43,
B8G8R8A8_UNORM = 44,
B8G8R8A8_SNORM = 45,
B8G8R8A8_USCALED = 46,
B8G8R8A8_SSCALED = 47,
B8G8R8A8_UINT = 48,
B8G8R8A8_SINT = 49,
B8G8R8A8_SRGB = 50,
A8B8G8R8_UNORM_PACK32 = 51,
A8B8G8R8_SNORM_PACK32 = 52,
A8B8G8R8_USCALED_PACK32 = 53,
A8B8G8R8_SSCALED_PACK32 = 54,
A8B8G8R8_UINT_PACK32 = 55,
A8B8G8R8_SINT_PACK32 = 56,
A8B8G8R8_SRGB_PACK32 = 57,
A2R10G10B10_UNORM_PACK32 = 58,
A2R10G10B10_SNORM_PACK32 = 59,
A2R10G10B10_USCALED_PACK32 = 60,
A2R10G10B10_SSCALED_PACK32 = 61,
A2R10G10B10_UINT_PACK32 = 62,
A2R10G10B10_SINT_PACK32 = 63,
A2B10G10R10_UNORM_PACK32 = 64,
A2B10G10R10_SNORM_PACK32 = 65,
A2B10G10R10_USCALED_PACK32 = 66,
A2B10G10R10_SSCALED_PACK32 = 67,
A2B10G10R10_UINT_PACK32 = 68,
A2B10G10R10_SINT_PACK32 = 69,
R16_UNORM = 70,
R16_SNORM = 71,
R16_USCALED = 72,
R16_SSCALED = 73,
R16_UINT = 74,
R16_SINT = 75,
R16_SFLOAT = 76,
R16G16_UNORM = 77,
R16G16_SNORM = 78,
R16G16_USCALED = 79,
R16G16_SSCALED = 80,
R16G16_UINT = 81,
R16G16_SINT = 82,
R16G16_SFLOAT = 83,
R16G16B16_UNORM = 84,
R16G16B16_SNORM = 85,
R16G16B16_USCALED = 86,
R16G16B16_SSCALED = 87,
R16G16B16_UINT = 88,
R16G16B16_SINT = 89,
R16G16B16_SFLOAT = 90,
R16G16B16A16_UNORM = 91,
R16G16B16A16_SNORM = 92,
R16G16B16A16_USCALED = 93,
R16G16B16A16_SSCALED = 94,
R16G16B16A16_UINT = 95,
R16G16B16A16_SINT = 96,
R16G16B16A16_SFLOAT = 97,
R32_UINT = 98,
R32_SINT = 99,
R32_SFLOAT = 100,
R32G32_UINT = 101,
R32G32_SINT = 102,
R32G32_SFLOAT = 103,
R32G32B32_UINT = 104,
R32G32B32_SINT = 105,
R32G32B32_SFLOAT = 106,
R32G32B32A32_UINT = 107,
R32G32B32A32_SINT = 108,
R32G32B32A32_SFLOAT = 109,
R64_UINT = 110,
R64_SINT = 111,
R64_SFLOAT = 112,
R64G64_UINT = 113,
R64G64_SINT = 114,
R64G64_SFLOAT = 115,
R64G64B64_UINT = 116,
R64G64B64_SINT = 117,
R64G64B64_SFLOAT = 118,
R64G64B64A64_UINT = 119,
R64G64B64A64_SINT = 120,
R64G64B64A64_SFLOAT = 121,
B10G11R11_UFLOAT_PACK32 = 122,
E5B9G9R9_UFLOAT_PACK32 = 123,
D16_UNORM = 124,
X8_D24_UNORM_PACK32 = 125,
D32_SFLOAT = 126,
S8_UINT = 127,
D16_UNORM_S8_UINT = 128,
D24_UNORM_S8_UINT = 129,
D32_SFLOAT_S8_UINT = 130,
BC1_RGB_UNORM_BLOCK = 131,
BC1_RGB_SRGB_BLOCK = 132,
BC1_RGBA_UNORM_BLOCK = 133,
BC1_RGBA_SRGB_BLOCK = 134,
BC2_UNORM_BLOCK = 135,
BC2_SRGB_BLOCK = 136,
BC3_UNORM_BLOCK = 137,
BC3_SRGB_BLOCK = 138,
BC4_UNORM_BLOCK = 139,
BC4_SNORM_BLOCK = 140,
BC5_UNORM_BLOCK = 141,
BC5_SNORM_BLOCK = 142,
BC6H_UFLOAT_BLOCK = 143,
BC6H_SFLOAT_BLOCK = 144,
BC7_UNORM_BLOCK = 145,
BC7_SRGB_BLOCK = 146,
ETC2_R8G8B8_UNORM_BLOCK = 147,
ETC2_R8G8B8_SRGB_BLOCK = 148,
ETC2_R8G8B8A1_UNORM_BLOCK = 149,
ETC2_R8G8B8A1_SRGB_BLOCK = 150,
ETC2_R8G8B8A8_UNORM_BLOCK = 151,
ETC2_R8G8B8A8_SRGB_BLOCK = 152,
EAC_R11_UNORM_BLOCK = 153,
EAC_R11_SNORM_BLOCK = 154,
EAC_R11G11_UNORM_BLOCK = 155,
EAC_R11G11_SNORM_BLOCK = 156,
ASTC_4x4_UNORM_BLOCK = 157,
ASTC_4x4_SRGB_BLOCK = 158,
ASTC_5x4_UNORM_BLOCK = 159,
ASTC_5x4_SRGB_BLOCK = 160,
ASTC_5x5_UNORM_BLOCK = 161,
ASTC_5x5_SRGB_BLOCK = 162,
ASTC_6x5_UNORM_BLOCK = 163,
ASTC_6x5_SRGB_BLOCK = 164,
ASTC_6x6_UNORM_BLOCK = 165,
ASTC_6x6_SRGB_BLOCK = 166,
ASTC_8x5_UNORM_BLOCK = 167,
ASTC_8x5_SRGB_BLOCK = 168,
ASTC_8x6_UNORM_BLOCK = 169,
ASTC_8x6_SRGB_BLOCK = 170,
ASTC_8x8_UNORM_BLOCK = 171,
ASTC_8x8_SRGB_BLOCK = 172,
ASTC_10x5_UNORM_BLOCK = 173,
ASTC_10x5_SRGB_BLOCK = 174,
ASTC_10x6_UNORM_BLOCK = 175,
ASTC_10x6_SRGB_BLOCK = 176,
ASTC_10x8_UNORM_BLOCK = 177,
ASTC_10x8_SRGB_BLOCK = 178,
ASTC_10x10_UNORM_BLOCK = 179,
ASTC_10x10_SRGB_BLOCK = 180,
ASTC_12x10_UNORM_BLOCK = 181,
ASTC_12x10_SRGB_BLOCK = 182,
ASTC_12x12_UNORM_BLOCK = 183,
ASTC_12x12_SRGB_BLOCK = 184,
G8B8G8R8_422_UNORM = 1000156000,
B8G8R8G8_422_UNORM = 1000156001,
G8_B8_R8_3PLANE_420_UNORM = 1000156002,
G8_B8R8_2PLANE_420_UNORM = 1000156003,
G8_B8_R8_3PLANE_422_UNORM = 1000156004,
G8_B8R8_2PLANE_422_UNORM = 1000156005,
G8_B8_R8_3PLANE_444_UNORM = 1000156006,
R10X6_UNORM_PACK16 = 1000156007,
R10X6G10X6_UNORM_2PACK16 = 1000156008,
R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009,
G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010,
B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011,
G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012,
G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013,
G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014,
G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015,
G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016,
R12X4_UNORM_PACK16 = 1000156017,
R12X4G12X4_UNORM_2PACK16 = 1000156018,
R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019,
G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020,
B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021,
G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022,
G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023,
G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024,
G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025,
G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026,
G16B16G16R16_422_UNORM = 1000156027,
B16G16R16G16_422_UNORM = 1000156028,
G16_B16_R16_3PLANE_420_UNORM = 1000156029,
G16_B16R16_2PLANE_420_UNORM = 1000156030,
G16_B16_R16_3PLANE_422_UNORM = 1000156031,
G16_B16R16_2PLANE_422_UNORM = 1000156032,
G16_B16_R16_3PLANE_444_UNORM = 1000156033,
PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000,
PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001,
PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002,
PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003,
PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004,
PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005,
PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006,
PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007,
ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000,
ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001,
ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002,
ASTC_6x5_SFLOAT_BLOCK_EXT = 1000066003,
ASTC_6x6_SFLOAT_BLOCK_EXT = 1000066004,
ASTC_8x5_SFLOAT_BLOCK_EXT = 1000066005,
ASTC_8x6_SFLOAT_BLOCK_EXT = 1000066006,
ASTC_8x8_SFLOAT_BLOCK_EXT = 1000066007,
ASTC_10x5_SFLOAT_BLOCK_EXT = 1000066008,
ASTC_10x6_SFLOAT_BLOCK_EXT = 1000066009,
ASTC_10x8_SFLOAT_BLOCK_EXT = 1000066010,
ASTC_10x10_SFLOAT_BLOCK_EXT = 1000066011,
ASTC_12x10_SFLOAT_BLOCK_EXT = 1000066012,
ASTC_12x12_SFLOAT_BLOCK_EXT = 1000066013,
_,
const Self = @This();
pub const G8B8G8R8_422_UNORM_KHR = Self.G8B8G8R8_422_UNORM;
pub const B8G8R8G8_422_UNORM_KHR = Self.B8G8R8G8_422_UNORM;
pub const G8_B8_R8_3PLANE_420_UNORM_KHR = Self.G8_B8_R8_3PLANE_420_UNORM;
pub const G8_B8R8_2PLANE_420_UNORM_KHR = Self.G8_B8R8_2PLANE_420_UNORM;
pub const G8_B8_R8_3PLANE_422_UNORM_KHR = Self.G8_B8_R8_3PLANE_422_UNORM;
pub const G8_B8R8_2PLANE_422_UNORM_KHR = Self.G8_B8R8_2PLANE_422_UNORM;
pub const G8_B8_R8_3PLANE_444_UNORM_KHR = Self.G8_B8_R8_3PLANE_444_UNORM;
pub const R10X6_UNORM_PACK16_KHR = Self.R10X6_UNORM_PACK16;
pub const R10X6G10X6_UNORM_2PACK16_KHR = Self.R10X6G10X6_UNORM_2PACK16;
pub const R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = Self.R10X6G10X6B10X6A10X6_UNORM_4PACK16;
pub const G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = Self.G10X6B10X6G10X6R10X6_422_UNORM_4PACK16;
pub const B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = Self.B10X6G10X6R10X6G10X6_422_UNORM_4PACK16;
pub const G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = Self.G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16;
pub const G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = Self.G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
pub const G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = Self.G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16;
pub const G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = Self.G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16;
pub const G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = Self.G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16;
pub const R12X4_UNORM_PACK16_KHR = Self.R12X4_UNORM_PACK16;
pub const R12X4G12X4_UNORM_2PACK16_KHR = Self.R12X4G12X4_UNORM_2PACK16;
pub const R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = Self.R12X4G12X4B12X4A12X4_UNORM_4PACK16;
pub const G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = Self.G12X4B12X4G12X4R12X4_422_UNORM_4PACK16;
pub const B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = Self.B12X4G12X4R12X4G12X4_422_UNORM_4PACK16;
pub const G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = Self.G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16;
pub const G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = Self.G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16;
pub const G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = Self.G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16;
pub const G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = Self.G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16;
pub const G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = Self.G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16;
pub const G16B16G16R16_422_UNORM_KHR = Self.G16B16G16R16_422_UNORM;
pub const B16G16R16G16_422_UNORM_KHR = Self.B16G16R16G16_422_UNORM;
pub const G16_B16_R16_3PLANE_420_UNORM_KHR = Self.G16_B16_R16_3PLANE_420_UNORM;
pub const G16_B16R16_2PLANE_420_UNORM_KHR = Self.G16_B16R16_2PLANE_420_UNORM;
pub const G16_B16_R16_3PLANE_422_UNORM_KHR = Self.G16_B16_R16_3PLANE_422_UNORM;
pub const G16_B16R16_2PLANE_422_UNORM_KHR = Self.G16_B16R16_2PLANE_422_UNORM;
pub const G16_B16_R16_3PLANE_444_UNORM_KHR = Self.G16_B16_R16_3PLANE_444_UNORM;
};
pub const ImageType = extern enum(i32) {
T_1D = 0,
T_2D = 1,
T_3D = 2,
_,
};
pub const ImageTiling = extern enum(i32) {
OPTIMAL = 0,
LINEAR = 1,
DRM_FORMAT_MODIFIER_EXT = 1000158000,
_,
};
pub const PhysicalDeviceType = extern enum(i32) {
OTHER = 0,
INTEGRATED_GPU = 1,
DISCRETE_GPU = 2,
VIRTUAL_GPU = 3,
CPU = 4,
_,
};
pub const QueryType = extern enum(i32) {
OCCLUSION = 0,
PIPELINE_STATISTICS = 1,
TIMESTAMP = 2,
TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004,
PERFORMANCE_QUERY_KHR = 1000116000,
ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000,
PERFORMANCE_QUERY_INTEL = 1000210000,
_,
};
pub const SharingMode = extern enum(i32) {
EXCLUSIVE = 0,
CONCURRENT = 1,
_,
};
pub const ImageLayout = extern enum(i32) {
UNDEFINED = 0,
GENERAL = 1,
COLOR_ATTACHMENT_OPTIMAL = 2,
DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3,
DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4,
SHADER_READ_ONLY_OPTIMAL = 5,
TRANSFER_SRC_OPTIMAL = 6,
TRANSFER_DST_OPTIMAL = 7,
PREINITIALIZED = 8,
DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000,
DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001,
DEPTH_ATTACHMENT_OPTIMAL = 1000241000,
DEPTH_READ_ONLY_OPTIMAL = 1000241001,
STENCIL_ATTACHMENT_OPTIMAL = 1000241002,
STENCIL_READ_ONLY_OPTIMAL = 1000241003,
PRESENT_SRC_KHR = 1000001002,
SHARED_PRESENT_KHR = 1000111000,
SHADING_RATE_OPTIMAL_NV = 1000164003,
FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000,
_,
const Self = @This();
pub const DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = Self.DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
pub const DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = Self.DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
pub const DEPTH_ATTACHMENT_OPTIMAL_KHR = Self.DEPTH_ATTACHMENT_OPTIMAL;
pub const DEPTH_READ_ONLY_OPTIMAL_KHR = Self.DEPTH_READ_ONLY_OPTIMAL;
pub const STENCIL_ATTACHMENT_OPTIMAL_KHR = Self.STENCIL_ATTACHMENT_OPTIMAL;
pub const STENCIL_READ_ONLY_OPTIMAL_KHR = Self.STENCIL_READ_ONLY_OPTIMAL;
};
pub const ImageViewType = extern enum(i32) {
T_1D = 0,
T_2D = 1,
T_3D = 2,
CUBE = 3,
T_1D_ARRAY = 4,
T_2D_ARRAY = 5,
CUBE_ARRAY = 6,
_,
};
pub const ComponentSwizzle = extern enum(i32) {
IDENTITY = 0,
ZERO = 1,
ONE = 2,
R = 3,
G = 4,
B = 5,
A = 6,
_,
};
pub const VertexInputRate = extern enum(i32) {
VERTEX = 0,
INSTANCE = 1,
_,
};
pub const PrimitiveTopology = extern enum(i32) {
POINT_LIST = 0,
LINE_LIST = 1,
LINE_STRIP = 2,
TRIANGLE_LIST = 3,
TRIANGLE_STRIP = 4,
TRIANGLE_FAN = 5,
LINE_LIST_WITH_ADJACENCY = 6,
LINE_STRIP_WITH_ADJACENCY = 7,
TRIANGLE_LIST_WITH_ADJACENCY = 8,
TRIANGLE_STRIP_WITH_ADJACENCY = 9,
PATCH_LIST = 10,
_,
};
pub const PolygonMode = extern enum(i32) {
FILL = 0,
LINE = 1,
POINT = 2,
FILL_RECTANGLE_NV = 1000153000,
_,
};
pub const FrontFace = extern enum(i32) {
COUNTER_CLOCKWISE = 0,
CLOCKWISE = 1,
_,
};
pub const CompareOp = extern enum(i32) {
NEVER = 0,
LESS = 1,
EQUAL = 2,
LESS_OR_EQUAL = 3,
GREATER = 4,
NOT_EQUAL = 5,
GREATER_OR_EQUAL = 6,
ALWAYS = 7,
_,
};
pub const StencilOp = extern enum(i32) {
KEEP = 0,
ZERO = 1,
REPLACE = 2,
INCREMENT_AND_CLAMP = 3,
DECREMENT_AND_CLAMP = 4,
INVERT = 5,
INCREMENT_AND_WRAP = 6,
DECREMENT_AND_WRAP = 7,
_,
};
pub const LogicOp = extern enum(i32) {
CLEAR = 0,
AND = 1,
AND_REVERSE = 2,
COPY = 3,
AND_INVERTED = 4,
NO_OP = 5,
XOR = 6,
OR = 7,
NOR = 8,
EQUIVALENT = 9,
INVERT = 10,
OR_REVERSE = 11,
COPY_INVERTED = 12,
OR_INVERTED = 13,
NAND = 14,
SET = 15,
_,
};
pub const BlendFactor = extern enum(i32) {
ZERO = 0,
ONE = 1,
SRC_COLOR = 2,
ONE_MINUS_SRC_COLOR = 3,
DST_COLOR = 4,
ONE_MINUS_DST_COLOR = 5,
SRC_ALPHA = 6,
ONE_MINUS_SRC_ALPHA = 7,
DST_ALPHA = 8,
ONE_MINUS_DST_ALPHA = 9,
CONSTANT_COLOR = 10,
ONE_MINUS_CONSTANT_COLOR = 11,
CONSTANT_ALPHA = 12,
ONE_MINUS_CONSTANT_ALPHA = 13,
SRC_ALPHA_SATURATE = 14,
SRC1_COLOR = 15,
ONE_MINUS_SRC1_COLOR = 16,
SRC1_ALPHA = 17,
ONE_MINUS_SRC1_ALPHA = 18,
_,
};
pub const BlendOp = extern enum(i32) {
ADD = 0,
SUBTRACT = 1,
REVERSE_SUBTRACT = 2,
MIN = 3,
MAX = 4,
ZERO_EXT = 1000148000,
SRC_EXT = 1000148001,
DST_EXT = 1000148002,
SRC_OVER_EXT = 1000148003,
DST_OVER_EXT = 1000148004,
SRC_IN_EXT = 1000148005,
DST_IN_EXT = 1000148006,
SRC_OUT_EXT = 1000148007,
DST_OUT_EXT = 1000148008,
SRC_ATOP_EXT = 1000148009,
DST_ATOP_EXT = 1000148010,
XOR_EXT = 1000148011,
MULTIPLY_EXT = 1000148012,
SCREEN_EXT = 1000148013,
OVERLAY_EXT = 1000148014,
DARKEN_EXT = 1000148015,
LIGHTEN_EXT = 1000148016,
COLORDODGE_EXT = 1000148017,
COLORBURN_EXT = 1000148018,
HARDLIGHT_EXT = 1000148019,
SOFTLIGHT_EXT = 1000148020,
DIFFERENCE_EXT = 1000148021,
EXCLUSION_EXT = 1000148022,
INVERT_EXT = 1000148023,
INVERT_RGB_EXT = 1000148024,
LINEARDODGE_EXT = 1000148025,
LINEARBURN_EXT = 1000148026,
VIVIDLIGHT_EXT = 1000148027,
LINEARLIGHT_EXT = 1000148028,
PINLIGHT_EXT = 1000148029,
HARDMIX_EXT = 1000148030,
HSL_HUE_EXT = 1000148031,
HSL_SATURATION_EXT = 1000148032,
HSL_COLOR_EXT = 1000148033,
HSL_LUMINOSITY_EXT = 1000148034,
PLUS_EXT = 1000148035,
PLUS_CLAMPED_EXT = 1000148036,
PLUS_CLAMPED_ALPHA_EXT = 1000148037,
PLUS_DARKER_EXT = 1000148038,
MINUS_EXT = 1000148039,
MINUS_CLAMPED_EXT = 1000148040,
CONTRAST_EXT = 1000148041,
INVERT_OVG_EXT = 1000148042,
RED_EXT = 1000148043,
GREEN_EXT = 1000148044,
BLUE_EXT = 1000148045,
_,
};
pub const DynamicState = extern enum(i32) {
VIEWPORT = 0,
SCISSOR = 1,
LINE_WIDTH = 2,
DEPTH_BIAS = 3,
BLEND_CONSTANTS = 4,
DEPTH_BOUNDS = 5,
STENCIL_COMPARE_MASK = 6,
STENCIL_WRITE_MASK = 7,
STENCIL_REFERENCE = 8,
VIEWPORT_W_SCALING_NV = 1000087000,
DISCARD_RECTANGLE_EXT = 1000099000,
SAMPLE_LOCATIONS_EXT = 1000143000,
VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004,
VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006,
EXCLUSIVE_SCISSOR_NV = 1000205001,
LINE_STIPPLE_EXT = 1000259000,
_,
};
pub const Filter = extern enum(i32) {
NEAREST = 0,
LINEAR = 1,
CUBIC_IMG = 1000015000,
_,
const Self = @This();
pub const CUBIC_EXT = Self.CUBIC_IMG;
};
pub const SamplerMipmapMode = extern enum(i32) {
NEAREST = 0,
LINEAR = 1,
_,
};
pub const SamplerAddressMode = extern enum(i32) {
REPEAT = 0,
MIRRORED_REPEAT = 1,
CLAMP_TO_EDGE = 2,
CLAMP_TO_BORDER = 3,
MIRROR_CLAMP_TO_EDGE = 4,
_,
const Self = @This();
pub const MIRROR_CLAMP_TO_EDGE_KHR = Self.MIRROR_CLAMP_TO_EDGE;
};
pub const BorderColor = extern enum(i32) {
FLOAT_TRANSPARENT_BLACK = 0,
INT_TRANSPARENT_BLACK = 1,
FLOAT_OPAQUE_BLACK = 2,
INT_OPAQUE_BLACK = 3,
FLOAT_OPAQUE_WHITE = 4,
INT_OPAQUE_WHITE = 5,
_,
};
pub const DescriptorType = extern enum(i32) {
SAMPLER = 0,
COMBINED_IMAGE_SAMPLER = 1,
SAMPLED_IMAGE = 2,
STORAGE_IMAGE = 3,
UNIFORM_TEXEL_BUFFER = 4,
STORAGE_TEXEL_BUFFER = 5,
UNIFORM_BUFFER = 6,
STORAGE_BUFFER = 7,
UNIFORM_BUFFER_DYNAMIC = 8,
STORAGE_BUFFER_DYNAMIC = 9,
INPUT_ATTACHMENT = 10,
INLINE_UNIFORM_BLOCK_EXT = 1000138000,
ACCELERATION_STRUCTURE_NV = 1000165000,
_,
};
pub const AttachmentLoadOp = extern enum(i32) {
LOAD = 0,
CLEAR = 1,
DONT_CARE = 2,
_,
};
pub const AttachmentStoreOp = extern enum(i32) {
STORE = 0,
DONT_CARE = 1,
_,
};
pub const PipelineBindPoint = extern enum(i32) {
GRAPHICS = 0,
COMPUTE = 1,
RAY_TRACING_NV = 1000165000,
_,
};
pub const CommandBufferLevel = extern enum(i32) {
PRIMARY = 0,
SECONDARY = 1,
_,
};
pub const IndexType = extern enum(i32) {
UINT16 = 0,
UINT32 = 1,
NONE_NV = 1000165000,
UINT8_EXT = 1000265000,
_,
};
pub const SubpassContents = extern enum(i32) {
INLINE = 0,
SECONDARY_COMMAND_BUFFERS = 1,
_,
};
pub const ObjectType = extern enum(i32) {
UNKNOWN = 0,
INSTANCE = 1,
PHYSICAL_DEVICE = 2,
DEVICE = 3,
QUEUE = 4,
SEMAPHORE = 5,
COMMAND_BUFFER = 6,
FENCE = 7,
DEVICE_MEMORY = 8,
BUFFER = 9,
IMAGE = 10,
EVENT = 11,
QUERY_POOL = 12,
BUFFER_VIEW = 13,
IMAGE_VIEW = 14,
SHADER_MODULE = 15,
PIPELINE_CACHE = 16,
PIPELINE_LAYOUT = 17,
RENDER_PASS = 18,
PIPELINE = 19,
DESCRIPTOR_SET_LAYOUT = 20,
SAMPLER = 21,
DESCRIPTOR_POOL = 22,
DESCRIPTOR_SET = 23,
FRAMEBUFFER = 24,
COMMAND_POOL = 25,
SAMPLER_YCBCR_CONVERSION = 1000156000,
DESCRIPTOR_UPDATE_TEMPLATE = 1000085000,
SURFACE_KHR = 1000000000,
SWAPCHAIN_KHR = 1000001000,
DISPLAY_KHR = 1000002000,
DISPLAY_MODE_KHR = 1000002001,
DEBUG_REPORT_CALLBACK_EXT = 1000011000,
OBJECT_TABLE_NVX = 1000086000,
INDIRECT_COMMANDS_LAYOUT_NVX = 1000086001,
DEBUG_UTILS_MESSENGER_EXT = 1000128000,
VALIDATION_CACHE_EXT = 1000160000,
ACCELERATION_STRUCTURE_NV = 1000165000,
PERFORMANCE_CONFIGURATION_INTEL = 1000210000,
_,
const Self = @This();
pub const DESCRIPTOR_UPDATE_TEMPLATE_KHR = Self.DESCRIPTOR_UPDATE_TEMPLATE;
pub const SAMPLER_YCBCR_CONVERSION_KHR = Self.SAMPLER_YCBCR_CONVERSION;
};
pub const VendorId = extern enum(i32) {
VIV = 0x10001,
VSI = 0x10002,
KAZAN = 0x10003,
_,
};
pub const InstanceCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const FormatFeatureFlags = packed struct {
sampledImage: bool = false,
storageImage: bool = false,
storageImageAtomic: bool = false,
uniformTexelBuffer: bool = false,
storageTexelBuffer: bool = false,
storageTexelBufferAtomic: bool = false,
vertexBuffer: bool = false,
colorAttachment: bool = false,
colorAttachmentBlend: bool = false,
depthStencilAttachment: bool = false,
blitSrc: bool = false,
blitDst: bool = false,
sampledImageFilterLinear: bool = false,
sampledImageFilterCubicIMG: bool = false,
transferSrc: bool = false,
transferDst: bool = false,
sampledImageFilterMinmax: bool = false,
midpointChromaSamples: bool = false,
sampledImageYcbcrConversionLinearFilter: bool = false,
sampledImageYcbcrConversionSeparateReconstructionFilter: bool = false,
sampledImageYcbcrConversionChromaReconstructionExplicit: bool = false,
sampledImageYcbcrConversionChromaReconstructionExplicitForceable: bool = false,
disjoint: bool = false,
cositedChromaSamples: bool = false,
fragmentDensityMapEXT: bool = false,
reserved25KHR: bool = false,
reserved26KHR: bool = false,
reserved27KHR: bool = false,
reserved28KHR: bool = false,
reserved29NV: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const transferSrcKHR = Self{ .transferSrc = true };
pub const transferDstKHR = Self{ .transferDst = true };
pub const sampledImageFilterMinmaxEXT = Self{ .sampledImageFilterMinmax = true };
pub const midpointChromaSamplesKHR = Self{ .midpointChromaSamples = true };
pub const sampledImageYcbcrConversionLinearFilterKHR = Self{ .sampledImageYcbcrConversionLinearFilter = true };
pub const sampledImageYcbcrConversionSeparateReconstructionFilterKHR = Self{ .sampledImageYcbcrConversionSeparateReconstructionFilter = true };
pub const sampledImageYcbcrConversionChromaReconstructionExplicitKHR = Self{ .sampledImageYcbcrConversionChromaReconstructionExplicit = true };
pub const sampledImageYcbcrConversionChromaReconstructionExplicitForceableKHR = Self{ .sampledImageYcbcrConversionChromaReconstructionExplicitForceable = true };
pub const disjointKHR = Self{ .disjoint = true };
pub const cositedChromaSamplesKHR = Self{ .cositedChromaSamples = true };
pub const sampledImageFilterCubicEXT = Self{ .sampledImageFilterCubicIMG = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ImageUsageFlags = packed struct {
transferSrc: bool = false,
transferDst: bool = false,
sampled: bool = false,
storage: bool = false,
colorAttachment: bool = false,
depthStencilAttachment: bool = false,
transientAttachment: bool = false,
inputAttachment: bool = false,
shadingRateImageNV: bool = false,
fragmentDensityMapEXT: bool = false,
reserved10KHR: bool = false,
reserved11KHR: bool = false,
reserved12KHR: bool = false,
reserved13KHR: bool = false,
reserved14KHR: bool = false,
reserved15KHR: bool = false,
reserved16QCOM: bool = false,
reserved17QCOM: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ImageCreateFlags = packed struct {
sparseBinding: bool = false,
sparseResidency: bool = false,
sparseAliased: bool = false,
mutableFormat: bool = false,
cubeCompatible: bool = false,
t2DArrayCompatible: bool = false,
splitInstanceBindRegions: bool = false,
blockTexelViewCompatible: bool = false,
extendedUsage: bool = false,
disjoint: bool = false,
alias: bool = false,
protected: bool = false,
sampleLocationsCompatibleDepthEXT: bool = false,
cornerSampledNV: bool = false,
subsampledEXT: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const splitInstanceBindRegionsKHR = Self{ .splitInstanceBindRegions = true };
pub const t2DArrayCompatibleKHR = Self{ .t2DArrayCompatible = true };
pub const blockTexelViewCompatibleKHR = Self{ .blockTexelViewCompatible = true };
pub const extendedUsageKHR = Self{ .extendedUsage = true };
pub const disjointKHR = Self{ .disjoint = true };
pub const aliasKHR = Self{ .alias = true };
pub usingnamespace FlagsMixin(Self);
};
pub const SampleCountFlags = packed struct {
t1: bool = false,
t2: bool = false,
t4: bool = false,
t8: bool = false,
t16: bool = false,
t32: bool = false,
t64: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const QueueFlags = packed struct {
graphics: bool = false,
compute: bool = false,
transfer: bool = false,
sparseBinding: bool = false,
protected: bool = false,
reserved5KHR: bool = false,
reserved6KHR: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const MemoryPropertyFlags = packed struct {
deviceLocal: bool = false,
hostVisible: bool = false,
hostCoherent: bool = false,
hostCached: bool = false,
lazilyAllocated: bool = false,
protected: bool = false,
deviceCoherentAMD: bool = false,
deviceUncachedAMD: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const MemoryHeapFlags = packed struct {
deviceLocal: bool = false,
multiInstance: bool = false,
reserved2KHR: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const multiInstanceKHR = Self{ .multiInstance = true };
pub usingnamespace FlagsMixin(Self);
};
pub const DeviceCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DeviceQueueCreateFlags = packed struct {
protected: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineStageFlags = packed struct {
topOfPipe: bool = false,
drawIndirect: bool = false,
vertexInput: bool = false,
vertexShader: bool = false,
tessellationControlShader: bool = false,
tessellationEvaluationShader: bool = false,
geometryShader: bool = false,
fragmentShader: bool = false,
earlyFragmentTests: bool = false,
lateFragmentTests: bool = false,
colorAttachmentOutput: bool = false,
computeShader: bool = false,
transfer: bool = false,
bottomOfPipe: bool = false,
host: bool = false,
allGraphics: bool = false,
allCommands: bool = false,
commandProcessNVX: bool = false,
conditionalRenderingEXT: bool = false,
taskShaderNV: bool = false,
meshShaderNV: bool = false,
rayTracingShaderNV: bool = false,
shadingRateImageNV: bool = false,
fragmentDensityProcessEXT: bool = false,
transformFeedbackEXT: bool = false,
accelerationStructureBuildNV: bool = false,
reserved26KHR: bool = false,
reserved27KHR: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const MemoryMapFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ImageAspectFlags = packed struct {
color: bool = false,
depth: bool = false,
stencil: bool = false,
metadata: bool = false,
plane0: bool = false,
plane1: bool = false,
plane2: bool = false,
memoryPlane0EXT: bool = false,
memoryPlane1EXT: bool = false,
memoryPlane2EXT: bool = false,
memoryPlane3EXT: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const plane0KHR = Self{ .plane0 = true };
pub const plane1KHR = Self{ .plane1 = true };
pub const plane2KHR = Self{ .plane2 = true };
pub usingnamespace FlagsMixin(Self);
};
pub const SparseImageFormatFlags = packed struct {
singleMiptail: bool = false,
alignedMipSize: bool = false,
nonstandardBlockSize: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SparseMemoryBindFlags = packed struct {
metadata: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const FenceCreateFlags = packed struct {
signaled: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SemaphoreCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const EventCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const QueryPoolCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const QueryPipelineStatisticFlags = packed struct {
inputAssemblyVertices: bool = false,
inputAssemblyPrimitives: bool = false,
vertexShaderInvocations: bool = false,
geometryShaderInvocations: bool = false,
geometryShaderPrimitives: bool = false,
clippingInvocations: bool = false,
clippingPrimitives: bool = false,
fragmentShaderInvocations: bool = false,
tessellationControlShaderPatches: bool = false,
tessellationEvaluationShaderInvocations: bool = false,
computeShaderInvocations: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const QueryResultFlags = packed struct {
t64: bool = false,
wait: bool = false,
withAvailability: bool = false,
partial: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const BufferCreateFlags = packed struct {
sparseBinding: bool = false,
sparseResidency: bool = false,
sparseAliased: bool = false,
protected: bool = false,
deviceAddressCaptureReplay: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const deviceAddressCaptureReplayEXT = Self{ .deviceAddressCaptureReplay = true };
pub const deviceAddressCaptureReplayKHR = Self{ .deviceAddressCaptureReplay = true };
pub usingnamespace FlagsMixin(Self);
};
pub const BufferUsageFlags = packed struct {
transferSrc: bool = false,
transferDst: bool = false,
uniformTexelBuffer: bool = false,
storageTexelBuffer: bool = false,
uniformBuffer: bool = false,
storageBuffer: bool = false,
indexBuffer: bool = false,
vertexBuffer: bool = false,
indirectBuffer: bool = false,
conditionalRenderingEXT: bool = false,
rayTracingNV: bool = false,
transformFeedbackBufferEXT: bool = false,
transformFeedbackCounterBufferEXT: bool = false,
reserved13KHR: bool = false,
reserved14KHR: bool = false,
reserved15KHR: bool = false,
reserved16KHR: bool = false,
shaderDeviceAddress: bool = false,
reserved18QCOM: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const shaderDeviceAddressEXT = Self{ .shaderDeviceAddress = true };
pub const shaderDeviceAddressKHR = Self{ .shaderDeviceAddress = true };
pub usingnamespace FlagsMixin(Self);
};
pub const BufferViewCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ImageViewCreateFlags = packed struct {
fragmentDensityMapDynamicEXT: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ShaderModuleCreateFlags = packed struct {
reserved0NV: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCacheCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCreateFlags = packed struct {
disableOptimization: bool = false,
allowDerivatives: bool = false,
derivative: bool = false,
viewIndexFromDeviceIndex: bool = false,
dispatchBase: bool = false,
deferCompileNV: bool = false,
captureStatisticsKHR: bool = false,
captureInternalRepresentationsKHR: bool = false,
reserved8EXT: bool = false,
reserved9EXT: bool = false,
reserved10EXT: bool = false,
extension1510_NV: bool = false,
extension2910_NV: bool = false,
extension2911_NV: bool = false,
extension1511_NV: bool = false,
extension1512_NV: bool = false,
extension1513_NV: bool = false,
extension1514_NV: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const viewIndexFromDeviceIndexKHR = Self{ .viewIndexFromDeviceIndex = true };
pub const dispatchBaseKhr = Self{ .dispatchBase = true };
pub usingnamespace FlagsMixin(Self);
};
pub const PipelineShaderStageCreateFlags = packed struct {
allowVaryingSubgroupSizeEXT: bool = false,
requireFullSubgroupsEXT: bool = false,
reserved2NV: bool = false,
reserved3KHR: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ShaderStageFlags = packed struct {
vertex: bool = false,
tessellationControl: bool = false,
tessellationEvaluation: bool = false,
geometry: bool = false,
fragment: bool = false,
compute: bool = false,
taskNV: bool = false,
meshNV: bool = false,
raygenNV: bool = false,
anyHitNV: bool = false,
closestHitNV: bool = false,
missNV: bool = false,
intersectionNV: bool = false,
callableNV: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub const allGraphics = fromInt(0x0000001F);
pub const all = fromInt(0x7FFFFFFF);
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineVertexInputStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineInputAssemblyStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineTessellationStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineViewportStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineRasterizationStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const CullModeFlags = packed struct {
front: bool = false,
back: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub const none = fromInt(0);
pub const frontAndBack = fromInt(0x00000003);
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineMultisampleStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineDepthStencilStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineColorBlendStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ColorComponentFlags = packed struct {
r: bool = false,
g: bool = false,
b: bool = false,
a: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineDynamicStateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineLayoutCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const SamplerCreateFlags = packed struct {
subsampledEXT: bool = false,
subsampledCoarseReconstructionEXT: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DescriptorSetLayoutCreateFlags = packed struct {
pushDescriptorKHR: bool = false,
updateAfterBindPool: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const updateAfterBindPoolEXT = Self{ .updateAfterBindPool = true };
pub usingnamespace FlagsMixin(Self);
};
pub const DescriptorPoolCreateFlags = packed struct {
freeDescriptorSet: bool = false,
updateAfterBind: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const updateAfterBindEXT = Self{ .updateAfterBind = true };
pub usingnamespace FlagsMixin(Self);
};
pub const DescriptorPoolResetFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const FramebufferCreateFlags = packed struct {
imageless: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const imagelessKHR = Self{ .imageless = true };
pub usingnamespace FlagsMixin(Self);
};
pub const RenderPassCreateFlags = packed struct {
reserved0KHR: bool = false,
renderPassReserved1_QCOM: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const AttachmentDescriptionFlags = packed struct {
mayAlias: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SubpassDescriptionFlags = packed struct {
perViewAttributesNVX: bool = false,
perViewPositionXOnlyNVX: bool = false,
reserved2QCOM: bool = false,
reserved3QCOM: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const AccessFlags = packed struct {
indirectCommandRead: bool = false,
indexRead: bool = false,
vertexAttributeRead: bool = false,
uniformRead: bool = false,
inputAttachmentRead: bool = false,
shaderRead: bool = false,
shaderWrite: bool = false,
colorAttachmentRead: bool = false,
colorAttachmentWrite: bool = false,
depthStencilAttachmentRead: bool = false,
depthStencilAttachmentWrite: bool = false,
transferRead: bool = false,
transferWrite: bool = false,
hostRead: bool = false,
hostWrite: bool = false,
memoryRead: bool = false,
memoryWrite: bool = false,
commandProcessReadNVX: bool = false,
commandProcessWriteNVX: bool = false,
colorAttachmentReadNoncoherentEXT: bool = false,
conditionalRenderingReadEXT: bool = false,
accelerationStructureReadNV: bool = false,
accelerationStructureWriteNV: bool = false,
shadingRateImageReadNV: bool = false,
fragmentDensityMapReadEXT: bool = false,
transformFeedbackWriteEXT: bool = false,
transformFeedbackCounterReadEXT: bool = false,
transformFeedbackCounterWriteEXT: bool = false,
reserved28KHR: bool = false,
reserved29KHR: bool = false,
reserved30KHR: bool = false,
reserved31KHR: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DependencyFlags = packed struct {
byRegion: bool = false,
viewLocal: bool = false,
deviceGroup: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const viewLocalKHR = Self{ .viewLocal = true };
pub const deviceGroupKHR = Self{ .deviceGroup = true };
pub usingnamespace FlagsMixin(Self);
};
pub const CommandPoolCreateFlags = packed struct {
transient: bool = false,
resetCommandBuffer: bool = false,
protected: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const CommandPoolResetFlags = packed struct {
releaseResources: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const CommandBufferUsageFlags = packed struct {
oneTimeSubmit: bool = false,
renderPassContinue: bool = false,
simultaneousUse: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const QueryControlFlags = packed struct {
precise: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const CommandBufferResetFlags = packed struct {
releaseResources: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const StencilFaceFlags = packed struct {
front: bool = false,
back: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const frontAndBack = fromInt(0x00000003);
pub const stencilFrontAndBack = Self{ .frontAndBack = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ApplicationInfo = extern struct {
sType: StructureType = .APPLICATION_INFO,
pNext: ?*const c_void = null,
pApplicationName: ?CString = null,
applicationVersion: u32,
pEngineName: ?CString = null,
engineVersion: u32,
apiVersion: u32,
};
pub const InstanceCreateInfo = extern struct {
sType: StructureType = .INSTANCE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: InstanceCreateFlags align(4) = InstanceCreateFlags{},
pApplicationInfo: ?*const ApplicationInfo = null,
enabledLayerCount: u32 = 0,
ppEnabledLayerNames: [*]const CString = undefined,
enabledExtensionCount: u32 = 0,
ppEnabledExtensionNames: [*]const CString = undefined,
};
pub const PFN_AllocationFunction = fn (
?*c_void,
usize,
usize,
SystemAllocationScope,
) callconv(CallConv) ?*c_void;
pub const PFN_ReallocationFunction = fn (
?*c_void,
?*c_void,
usize,
usize,
SystemAllocationScope,
) callconv(CallConv) ?*c_void;
pub const PFN_FreeFunction = fn (
?*c_void,
?*c_void,
) callconv(CallConv) void;
pub const PFN_InternalAllocationNotification = fn (
?*c_void,
usize,
InternalAllocationType,
SystemAllocationScope,
) callconv(CallConv) void;
pub const PFN_InternalFreeNotification = fn (
?*c_void,
usize,
InternalAllocationType,
SystemAllocationScope,
) callconv(CallConv) void;
pub const AllocationCallbacks = extern struct {
pUserData: ?*c_void = null,
pfnAllocation: PFN_AllocationFunction,
pfnReallocation: PFN_ReallocationFunction,
pfnFree: PFN_FreeFunction,
pfnInternalAllocation: ?PFN_InternalAllocationNotification = null,
pfnInternalFree: ?PFN_InternalFreeNotification = null,
};
pub const PhysicalDeviceFeatures = extern struct {
robustBufferAccess: Bool32,
fullDrawIndexUint32: Bool32,
imageCubeArray: Bool32,
independentBlend: Bool32,
geometryShader: Bool32,
tessellationShader: Bool32,
sampleRateShading: Bool32,
dualSrcBlend: Bool32,
logicOp: Bool32,
multiDrawIndirect: Bool32,
drawIndirectFirstInstance: Bool32,
depthClamp: Bool32,
depthBiasClamp: Bool32,
fillModeNonSolid: Bool32,
depthBounds: Bool32,
wideLines: Bool32,
largePoints: Bool32,
alphaToOne: Bool32,
multiViewport: Bool32,
samplerAnisotropy: Bool32,
textureCompressionETC2: Bool32,
textureCompressionASTC_LDR: Bool32,
textureCompressionBC: Bool32,
occlusionQueryPrecise: Bool32,
pipelineStatisticsQuery: Bool32,
vertexPipelineStoresAndAtomics: Bool32,
fragmentStoresAndAtomics: Bool32,
shaderTessellationAndGeometryPointSize: Bool32,
shaderImageGatherExtended: Bool32,
shaderStorageImageExtendedFormats: Bool32,
shaderStorageImageMultisample: Bool32,
shaderStorageImageReadWithoutFormat: Bool32,
shaderStorageImageWriteWithoutFormat: Bool32,
shaderUniformBufferArrayDynamicIndexing: Bool32,
shaderSampledImageArrayDynamicIndexing: Bool32,
shaderStorageBufferArrayDynamicIndexing: Bool32,
shaderStorageImageArrayDynamicIndexing: Bool32,
shaderClipDistance: Bool32,
shaderCullDistance: Bool32,
shaderFloat64: Bool32,
shaderInt64: Bool32,
shaderInt16: Bool32,
shaderResourceResidency: Bool32,
shaderResourceMinLod: Bool32,
sparseBinding: Bool32,
sparseResidencyBuffer: Bool32,
sparseResidencyImage2D: Bool32,
sparseResidencyImage3D: Bool32,
sparseResidency2Samples: Bool32,
sparseResidency4Samples: Bool32,
sparseResidency8Samples: Bool32,
sparseResidency16Samples: Bool32,
sparseResidencyAliased: Bool32,
variableMultisampleRate: Bool32,
inheritedQueries: Bool32,
};
pub const FormatProperties = extern struct {
linearTilingFeatures: FormatFeatureFlags align(4) = FormatFeatureFlags{},
optimalTilingFeatures: FormatFeatureFlags align(4) = FormatFeatureFlags{},
bufferFeatures: FormatFeatureFlags align(4) = FormatFeatureFlags{},
};
pub const Extent3D = extern struct {
width: u32,
height: u32,
depth: u32,
};
pub const ImageFormatProperties = extern struct {
maxExtent: Extent3D,
maxMipLevels: u32,
maxArrayLayers: u32,
sampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
maxResourceSize: DeviceSize,
};
pub const PhysicalDeviceLimits = extern struct {
maxImageDimension1D: u32,
maxImageDimension2D: u32,
maxImageDimension3D: u32,
maxImageDimensionCube: u32,
maxImageArrayLayers: u32,
maxTexelBufferElements: u32,
maxUniformBufferRange: u32,
maxStorageBufferRange: u32,
maxPushConstantsSize: u32,
maxMemoryAllocationCount: u32,
maxSamplerAllocationCount: u32,
bufferImageGranularity: DeviceSize,
sparseAddressSpaceSize: DeviceSize,
maxBoundDescriptorSets: u32,
maxPerStageDescriptorSamplers: u32,
maxPerStageDescriptorUniformBuffers: u32,
maxPerStageDescriptorStorageBuffers: u32,
maxPerStageDescriptorSampledImages: u32,
maxPerStageDescriptorStorageImages: u32,
maxPerStageDescriptorInputAttachments: u32,
maxPerStageResources: u32,
maxDescriptorSetSamplers: u32,
maxDescriptorSetUniformBuffers: u32,
maxDescriptorSetUniformBuffersDynamic: u32,
maxDescriptorSetStorageBuffers: u32,
maxDescriptorSetStorageBuffersDynamic: u32,
maxDescriptorSetSampledImages: u32,
maxDescriptorSetStorageImages: u32,
maxDescriptorSetInputAttachments: u32,
maxVertexInputAttributes: u32,
maxVertexInputBindings: u32,
maxVertexInputAttributeOffset: u32,
maxVertexInputBindingStride: u32,
maxVertexOutputComponents: u32,
maxTessellationGenerationLevel: u32,
maxTessellationPatchSize: u32,
maxTessellationControlPerVertexInputComponents: u32,
maxTessellationControlPerVertexOutputComponents: u32,
maxTessellationControlPerPatchOutputComponents: u32,
maxTessellationControlTotalOutputComponents: u32,
maxTessellationEvaluationInputComponents: u32,
maxTessellationEvaluationOutputComponents: u32,
maxGeometryShaderInvocations: u32,
maxGeometryInputComponents: u32,
maxGeometryOutputComponents: u32,
maxGeometryOutputVertices: u32,
maxGeometryTotalOutputComponents: u32,
maxFragmentInputComponents: u32,
maxFragmentOutputAttachments: u32,
maxFragmentDualSrcAttachments: u32,
maxFragmentCombinedOutputResources: u32,
maxComputeSharedMemorySize: u32,
maxComputeWorkGroupCount: [3]u32,
maxComputeWorkGroupInvocations: u32,
maxComputeWorkGroupSize: [3]u32,
subPixelPrecisionBits: u32,
subTexelPrecisionBits: u32,
mipmapPrecisionBits: u32,
maxDrawIndexedIndexValue: u32,
maxDrawIndirectCount: u32,
maxSamplerLodBias: f32,
maxSamplerAnisotropy: f32,
maxViewports: u32,
maxViewportDimensions: [2]u32,
viewportBoundsRange: [2]f32,
viewportSubPixelBits: u32,
minMemoryMapAlignment: usize,
minTexelBufferOffsetAlignment: DeviceSize,
minUniformBufferOffsetAlignment: DeviceSize,
minStorageBufferOffsetAlignment: DeviceSize,
minTexelOffset: i32,
maxTexelOffset: u32,
minTexelGatherOffset: i32,
maxTexelGatherOffset: u32,
minInterpolationOffset: f32,
maxInterpolationOffset: f32,
subPixelInterpolationOffsetBits: u32,
maxFramebufferWidth: u32,
maxFramebufferHeight: u32,
maxFramebufferLayers: u32,
framebufferColorSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
framebufferDepthSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
framebufferStencilSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
framebufferNoAttachmentsSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
maxColorAttachments: u32,
sampledImageColorSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
sampledImageIntegerSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
sampledImageDepthSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
sampledImageStencilSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
storageImageSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
maxSampleMaskWords: u32,
timestampComputeAndGraphics: Bool32,
timestampPeriod: f32,
maxClipDistances: u32,
maxCullDistances: u32,
maxCombinedClipAndCullDistances: u32,
discreteQueuePriorities: u32,
pointSizeRange: [2]f32,
lineWidthRange: [2]f32,
pointSizeGranularity: f32,
lineWidthGranularity: f32,
strictLines: Bool32,
standardSampleLocations: Bool32,
optimalBufferCopyOffsetAlignment: DeviceSize,
optimalBufferCopyRowPitchAlignment: DeviceSize,
nonCoherentAtomSize: DeviceSize,
};
pub const PhysicalDeviceSparseProperties = extern struct {
residencyStandard2DBlockShape: Bool32,
residencyStandard2DMultisampleBlockShape: Bool32,
residencyStandard3DBlockShape: Bool32,
residencyAlignedMipSize: Bool32,
residencyNonResidentStrict: Bool32,
};
pub const PhysicalDeviceProperties = extern struct {
apiVersion: u32,
driverVersion: u32,
vendorID: u32,
deviceID: u32,
deviceType: PhysicalDeviceType,
deviceName: [MAX_PHYSICAL_DEVICE_NAME_SIZE-1:0]u8,
pipelineCacheUUID: [UUID_SIZE]u8,
limits: PhysicalDeviceLimits,
sparseProperties: PhysicalDeviceSparseProperties,
};
pub const QueueFamilyProperties = extern struct {
queueFlags: QueueFlags align(4) = QueueFlags{},
queueCount: u32,
timestampValidBits: u32,
minImageTransferGranularity: Extent3D,
};
pub const MemoryType = extern struct {
propertyFlags: MemoryPropertyFlags align(4) = MemoryPropertyFlags{},
heapIndex: u32,
};
pub const MemoryHeap = extern struct {
size: DeviceSize,
flags: MemoryHeapFlags align(4) = MemoryHeapFlags{},
};
pub const PhysicalDeviceMemoryProperties = extern struct {
memoryTypeCount: u32,
memoryTypes: [MAX_MEMORY_TYPES]MemoryType,
memoryHeapCount: u32,
memoryHeaps: [MAX_MEMORY_HEAPS]MemoryHeap,
};
pub const PFN_VoidFunction = fn () callconv(CallConv) void;
pub const DeviceQueueCreateInfo = extern struct {
sType: StructureType = .DEVICE_QUEUE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: DeviceQueueCreateFlags align(4) = DeviceQueueCreateFlags{},
queueFamilyIndex: u32,
queueCount: u32,
pQueuePriorities: [*]const f32,
};
pub const DeviceCreateInfo = extern struct {
sType: StructureType = .DEVICE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: DeviceCreateFlags align(4) = DeviceCreateFlags{},
queueCreateInfoCount: u32,
pQueueCreateInfos: [*]const DeviceQueueCreateInfo,
enabledLayerCount: u32 = 0,
ppEnabledLayerNames: [*]const CString = undefined,
enabledExtensionCount: u32 = 0,
ppEnabledExtensionNames: [*]const CString = undefined,
pEnabledFeatures: ?*const PhysicalDeviceFeatures = null,
};
pub const ExtensionProperties = extern struct {
extensionName: [MAX_EXTENSION_NAME_SIZE-1:0]u8,
specVersion: u32,
};
pub const LayerProperties = extern struct {
layerName: [MAX_EXTENSION_NAME_SIZE-1:0]u8,
specVersion: u32,
implementationVersion: u32,
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
};
pub const SubmitInfo = extern struct {
sType: StructureType = .SUBMIT_INFO,
pNext: ?*const c_void = null,
waitSemaphoreCount: u32 = 0,
pWaitSemaphores: [*]const Semaphore = undefined,
pWaitDstStageMask: [*]align(4) const PipelineStageFlags = undefined,
commandBufferCount: u32 = 0,
pCommandBuffers: [*]const CommandBuffer = undefined,
signalSemaphoreCount: u32 = 0,
pSignalSemaphores: [*]const Semaphore = undefined,
};
pub const MemoryAllocateInfo = extern struct {
sType: StructureType = .MEMORY_ALLOCATE_INFO,
pNext: ?*const c_void = null,
allocationSize: DeviceSize,
memoryTypeIndex: u32,
};
pub const MappedMemoryRange = extern struct {
sType: StructureType = .MAPPED_MEMORY_RANGE,
pNext: ?*const c_void = null,
memory: DeviceMemory,
offset: DeviceSize,
size: DeviceSize,
};
pub const MemoryRequirements = extern struct {
size: DeviceSize,
alignment: DeviceSize,
memoryTypeBits: u32,
};
pub const SparseImageFormatProperties = extern struct {
aspectMask: ImageAspectFlags align(4) = ImageAspectFlags{},
imageGranularity: Extent3D,
flags: SparseImageFormatFlags align(4) = SparseImageFormatFlags{},
};
pub const SparseImageMemoryRequirements = extern struct {
formatProperties: SparseImageFormatProperties,
imageMipTailFirstLod: u32,
imageMipTailSize: DeviceSize,
imageMipTailOffset: DeviceSize,
imageMipTailStride: DeviceSize,
};
pub const SparseMemoryBind = extern struct {
resourceOffset: DeviceSize,
size: DeviceSize,
memory: ?DeviceMemory = null,
memoryOffset: DeviceSize,
flags: SparseMemoryBindFlags align(4) = SparseMemoryBindFlags{},
};
pub const SparseBufferMemoryBindInfo = extern struct {
buffer: Buffer,
bindCount: u32,
pBinds: [*]const SparseMemoryBind,
};
pub const SparseImageOpaqueMemoryBindInfo = extern struct {
image: Image,
bindCount: u32,
pBinds: [*]const SparseMemoryBind,
};
pub const ImageSubresource = extern struct {
aspectMask: ImageAspectFlags align(4),
mipLevel: u32,
arrayLayer: u32,
};
pub const Offset3D = extern struct {
x: i32,
y: i32,
z: i32,
};
pub const SparseImageMemoryBind = extern struct {
subresource: ImageSubresource,
offset: Offset3D,
extent: Extent3D,
memory: ?DeviceMemory = null,
memoryOffset: DeviceSize,
flags: SparseMemoryBindFlags align(4) = SparseMemoryBindFlags{},
};
pub const SparseImageMemoryBindInfo = extern struct {
image: Image,
bindCount: u32,
pBinds: [*]const SparseImageMemoryBind,
};
pub const BindSparseInfo = extern struct {
sType: StructureType = .BIND_SPARSE_INFO,
pNext: ?*const c_void = null,
waitSemaphoreCount: u32 = 0,
pWaitSemaphores: [*]const Semaphore = undefined,
bufferBindCount: u32 = 0,
pBufferBinds: [*]const SparseBufferMemoryBindInfo = undefined,
imageOpaqueBindCount: u32 = 0,
pImageOpaqueBinds: [*]const SparseImageOpaqueMemoryBindInfo = undefined,
imageBindCount: u32 = 0,
pImageBinds: [*]const SparseImageMemoryBindInfo = undefined,
signalSemaphoreCount: u32 = 0,
pSignalSemaphores: [*]const Semaphore = undefined,
};
pub const FenceCreateInfo = extern struct {
sType: StructureType = .FENCE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: FenceCreateFlags align(4) = FenceCreateFlags{},
};
pub const SemaphoreCreateInfo = extern struct {
sType: StructureType = .SEMAPHORE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: SemaphoreCreateFlags align(4) = SemaphoreCreateFlags{},
};
pub const EventCreateInfo = extern struct {
sType: StructureType = .EVENT_CREATE_INFO,
pNext: ?*const c_void = null,
flags: EventCreateFlags align(4) = EventCreateFlags{},
};
pub const QueryPoolCreateInfo = extern struct {
sType: StructureType = .QUERY_POOL_CREATE_INFO,
pNext: ?*const c_void = null,
flags: QueryPoolCreateFlags align(4) = QueryPoolCreateFlags{},
queryType: QueryType,
queryCount: u32,
pipelineStatistics: QueryPipelineStatisticFlags align(4) = QueryPipelineStatisticFlags{},
};
pub const BufferCreateInfo = extern struct {
sType: StructureType = .BUFFER_CREATE_INFO,
pNext: ?*const c_void = null,
flags: BufferCreateFlags align(4) = BufferCreateFlags{},
size: DeviceSize,
usage: BufferUsageFlags align(4),
sharingMode: SharingMode,
queueFamilyIndexCount: u32 = 0,
pQueueFamilyIndices: [*]const u32 = undefined,
};
pub const BufferViewCreateInfo = extern struct {
sType: StructureType = .BUFFER_VIEW_CREATE_INFO,
pNext: ?*const c_void = null,
flags: BufferViewCreateFlags align(4) = BufferViewCreateFlags{},
buffer: Buffer,
format: Format,
offset: DeviceSize,
range: DeviceSize,
};
pub const ImageCreateInfo = extern struct {
sType: StructureType = .IMAGE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: ImageCreateFlags align(4) = ImageCreateFlags{},
imageType: ImageType,
format: Format,
extent: Extent3D,
mipLevels: u32,
arrayLayers: u32,
samples: SampleCountFlags align(4),
tiling: ImageTiling,
usage: ImageUsageFlags align(4),
sharingMode: SharingMode,
queueFamilyIndexCount: u32 = 0,
pQueueFamilyIndices: [*]const u32 = undefined,
initialLayout: ImageLayout,
};
pub const SubresourceLayout = extern struct {
offset: DeviceSize,
size: DeviceSize,
rowPitch: DeviceSize,
arrayPitch: DeviceSize,
depthPitch: DeviceSize,
};
pub const ComponentMapping = extern struct {
r: ComponentSwizzle,
g: ComponentSwizzle,
b: ComponentSwizzle,
a: ComponentSwizzle,
};
pub const ImageSubresourceRange = extern struct {
aspectMask: ImageAspectFlags align(4),
baseMipLevel: u32,
levelCount: u32,
baseArrayLayer: u32,
layerCount: u32,
};
pub const ImageViewCreateInfo = extern struct {
sType: StructureType = .IMAGE_VIEW_CREATE_INFO,
pNext: ?*const c_void = null,
flags: ImageViewCreateFlags align(4) = ImageViewCreateFlags{},
image: Image,
viewType: ImageViewType,
format: Format,
components: ComponentMapping,
subresourceRange: ImageSubresourceRange,
};
pub const ShaderModuleCreateInfo = extern struct {
sType: StructureType = .SHADER_MODULE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: ShaderModuleCreateFlags align(4) = ShaderModuleCreateFlags{},
codeSize: usize,
pCode: [*]const u32,
};
pub const PipelineCacheCreateInfo = extern struct {
sType: StructureType = .PIPELINE_CACHE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineCacheCreateFlags align(4) = PipelineCacheCreateFlags{},
initialDataSize: usize = 0,
pInitialData: ?*const c_void = undefined,
};
pub const SpecializationMapEntry = extern struct {
constantID: u32,
offset: u32,
size: usize,
};
pub const SpecializationInfo = extern struct {
mapEntryCount: u32 = 0,
pMapEntries: [*]const SpecializationMapEntry = undefined,
dataSize: usize = 0,
pData: ?*const c_void = undefined,
};
pub const PipelineShaderStageCreateInfo = extern struct {
sType: StructureType = .PIPELINE_SHADER_STAGE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineShaderStageCreateFlags align(4) = PipelineShaderStageCreateFlags{},
stage: ShaderStageFlags align(4),
module: ShaderModule,
pName: CString,
pSpecializationInfo: ?*const SpecializationInfo = null,
};
pub const VertexInputBindingDescription = extern struct {
binding: u32,
stride: u32,
inputRate: VertexInputRate,
};
pub const VertexInputAttributeDescription = extern struct {
location: u32,
binding: u32,
format: Format,
offset: u32,
};
pub const PipelineVertexInputStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineVertexInputStateCreateFlags align(4) = PipelineVertexInputStateCreateFlags{},
vertexBindingDescriptionCount: u32 = 0,
pVertexBindingDescriptions: [*]const VertexInputBindingDescription = undefined,
vertexAttributeDescriptionCount: u32 = 0,
pVertexAttributeDescriptions: [*]const VertexInputAttributeDescription = undefined,
};
pub const PipelineInputAssemblyStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineInputAssemblyStateCreateFlags align(4) = PipelineInputAssemblyStateCreateFlags{},
topology: PrimitiveTopology,
primitiveRestartEnable: Bool32,
};
pub const PipelineTessellationStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_TESSELLATION_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineTessellationStateCreateFlags align(4) = PipelineTessellationStateCreateFlags{},
patchControlPoints: u32,
};
pub const Viewport = extern struct {
x: f32,
y: f32,
width: f32,
height: f32,
minDepth: f32,
maxDepth: f32,
};
pub const Offset2D = extern struct {
x: i32,
y: i32,
};
pub const Extent2D = extern struct {
width: u32,
height: u32,
};
pub const Rect2D = extern struct {
offset: Offset2D,
extent: Extent2D,
};
pub const PipelineViewportStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineViewportStateCreateFlags align(4) = PipelineViewportStateCreateFlags{},
viewportCount: u32,
pViewports: ?[*]const Viewport = null,
scissorCount: u32,
pScissors: ?[*]const Rect2D = null,
};
pub const PipelineRasterizationStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineRasterizationStateCreateFlags align(4) = PipelineRasterizationStateCreateFlags{},
depthClampEnable: Bool32,
rasterizerDiscardEnable: Bool32,
polygonMode: PolygonMode,
cullMode: CullModeFlags align(4) = CullModeFlags{},
frontFace: FrontFace,
depthBiasEnable: Bool32,
depthBiasConstantFactor: f32,
depthBiasClamp: f32,
depthBiasSlopeFactor: f32,
lineWidth: f32,
};
pub const PipelineMultisampleStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineMultisampleStateCreateFlags align(4) = PipelineMultisampleStateCreateFlags{},
rasterizationSamples: SampleCountFlags align(4),
sampleShadingEnable: Bool32,
minSampleShading: f32,
pSampleMask: ?[*]const SampleMask = null,
alphaToCoverageEnable: Bool32,
alphaToOneEnable: Bool32,
};
pub const StencilOpState = extern struct {
failOp: StencilOp,
passOp: StencilOp,
depthFailOp: StencilOp,
compareOp: CompareOp,
compareMask: u32,
writeMask: u32,
reference: u32,
};
pub const PipelineDepthStencilStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineDepthStencilStateCreateFlags align(4) = PipelineDepthStencilStateCreateFlags{},
depthTestEnable: Bool32,
depthWriteEnable: Bool32,
depthCompareOp: CompareOp,
depthBoundsTestEnable: Bool32,
stencilTestEnable: Bool32,
front: StencilOpState,
back: StencilOpState,
minDepthBounds: f32,
maxDepthBounds: f32,
};
pub const PipelineColorBlendAttachmentState = extern struct {
blendEnable: Bool32,
srcColorBlendFactor: BlendFactor,
dstColorBlendFactor: BlendFactor,
colorBlendOp: BlendOp,
srcAlphaBlendFactor: BlendFactor,
dstAlphaBlendFactor: BlendFactor,
alphaBlendOp: BlendOp,
colorWriteMask: ColorComponentFlags align(4) = ColorComponentFlags{},
};
pub const PipelineColorBlendStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineColorBlendStateCreateFlags align(4) = PipelineColorBlendStateCreateFlags{},
logicOpEnable: Bool32,
logicOp: LogicOp,
attachmentCount: u32 = 0,
pAttachments: [*]const PipelineColorBlendAttachmentState = undefined,
blendConstants: [4]f32,
};
pub const PipelineDynamicStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_DYNAMIC_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineDynamicStateCreateFlags align(4) = PipelineDynamicStateCreateFlags{},
dynamicStateCount: u32 = 0,
pDynamicStates: [*]const DynamicState = undefined,
};
pub const GraphicsPipelineCreateInfo = extern struct {
sType: StructureType = .GRAPHICS_PIPELINE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineCreateFlags align(4) = PipelineCreateFlags{},
stageCount: u32,
pStages: [*]const PipelineShaderStageCreateInfo,
pVertexInputState: ?*const PipelineVertexInputStateCreateInfo = null,
pInputAssemblyState: ?*const PipelineInputAssemblyStateCreateInfo = null,
pTessellationState: ?*const PipelineTessellationStateCreateInfo = null,
pViewportState: ?*const PipelineViewportStateCreateInfo = null,
pRasterizationState: *const PipelineRasterizationStateCreateInfo,
pMultisampleState: ?*const PipelineMultisampleStateCreateInfo = null,
pDepthStencilState: ?*const PipelineDepthStencilStateCreateInfo = null,
pColorBlendState: ?*const PipelineColorBlendStateCreateInfo = null,
pDynamicState: ?*const PipelineDynamicStateCreateInfo = null,
layout: PipelineLayout,
renderPass: RenderPass,
subpass: u32,
basePipelineHandle: ?Pipeline = null,
basePipelineIndex: i32,
};
pub const ComputePipelineCreateInfo = extern struct {
sType: StructureType = .COMPUTE_PIPELINE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineCreateFlags align(4) = PipelineCreateFlags{},
stage: PipelineShaderStageCreateInfo,
layout: PipelineLayout,
basePipelineHandle: ?Pipeline = null,
basePipelineIndex: i32,
};
pub const PushConstantRange = extern struct {
stageFlags: ShaderStageFlags align(4),
offset: u32,
size: u32,
};
pub const PipelineLayoutCreateInfo = extern struct {
sType: StructureType = .PIPELINE_LAYOUT_CREATE_INFO,
pNext: ?*const c_void = null,
flags: PipelineLayoutCreateFlags align(4) = PipelineLayoutCreateFlags{},
setLayoutCount: u32 = 0,
pSetLayouts: [*]const DescriptorSetLayout = undefined,
pushConstantRangeCount: u32 = 0,
pPushConstantRanges: [*]const PushConstantRange = undefined,
};
pub const SamplerCreateInfo = extern struct {
sType: StructureType = .SAMPLER_CREATE_INFO,
pNext: ?*const c_void = null,
flags: SamplerCreateFlags align(4) = SamplerCreateFlags{},
magFilter: Filter,
minFilter: Filter,
mipmapMode: SamplerMipmapMode,
addressModeU: SamplerAddressMode,
addressModeV: SamplerAddressMode,
addressModeW: SamplerAddressMode,
mipLodBias: f32,
anisotropyEnable: Bool32,
maxAnisotropy: f32,
compareEnable: Bool32,
compareOp: CompareOp,
minLod: f32,
maxLod: f32,
borderColor: BorderColor,
unnormalizedCoordinates: Bool32,
};
pub const DescriptorSetLayoutBinding = extern struct {
binding: u32,
descriptorType: DescriptorType,
descriptorCount: u32 = 0,
stageFlags: ShaderStageFlags align(4),
pImmutableSamplers: ?[*]const Sampler = null,
};
pub const DescriptorSetLayoutCreateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
pNext: ?*const c_void = null,
flags: DescriptorSetLayoutCreateFlags align(4) = DescriptorSetLayoutCreateFlags{},
bindingCount: u32 = 0,
pBindings: [*]const DescriptorSetLayoutBinding = undefined,
};
pub const DescriptorPoolSize = extern struct {
inType: DescriptorType,
descriptorCount: u32,
};
pub const DescriptorPoolCreateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_POOL_CREATE_INFO,
pNext: ?*const c_void = null,
flags: DescriptorPoolCreateFlags align(4) = DescriptorPoolCreateFlags{},
maxSets: u32,
poolSizeCount: u32,
pPoolSizes: [*]const DescriptorPoolSize,
};
pub const DescriptorSetAllocateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_SET_ALLOCATE_INFO,
pNext: ?*const c_void = null,
descriptorPool: DescriptorPool,
descriptorSetCount: u32,
pSetLayouts: [*]const DescriptorSetLayout,
};
pub const DescriptorImageInfo = extern struct {
sampler: Sampler,
imageView: ImageView,
imageLayout: ImageLayout,
};
pub const DescriptorBufferInfo = extern struct {
buffer: Buffer,
offset: DeviceSize,
range: DeviceSize,
};
pub const WriteDescriptorSet = extern struct {
sType: StructureType = .WRITE_DESCRIPTOR_SET,
pNext: ?*const c_void = null,
dstSet: DescriptorSet,
dstBinding: u32,
dstArrayElement: u32,
descriptorCount: u32,
descriptorType: DescriptorType,
pImageInfo: [*]const DescriptorImageInfo,
pBufferInfo: [*]const DescriptorBufferInfo,
pTexelBufferView: [*]const BufferView,
};
pub const CopyDescriptorSet = extern struct {
sType: StructureType = .COPY_DESCRIPTOR_SET,
pNext: ?*const c_void = null,
srcSet: DescriptorSet,
srcBinding: u32,
srcArrayElement: u32,
dstSet: DescriptorSet,
dstBinding: u32,
dstArrayElement: u32,
descriptorCount: u32,
};
pub const FramebufferCreateInfo = extern struct {
sType: StructureType = .FRAMEBUFFER_CREATE_INFO,
pNext: ?*const c_void = null,
flags: FramebufferCreateFlags align(4) = FramebufferCreateFlags{},
renderPass: RenderPass,
attachmentCount: u32 = 0,
pAttachments: [*]const ImageView = undefined,
width: u32,
height: u32,
layers: u32,
};
pub const AttachmentDescription = extern struct {
flags: AttachmentDescriptionFlags align(4) = AttachmentDescriptionFlags{},
format: Format,
samples: SampleCountFlags align(4),
loadOp: AttachmentLoadOp,
storeOp: AttachmentStoreOp,
stencilLoadOp: AttachmentLoadOp,
stencilStoreOp: AttachmentStoreOp,
initialLayout: ImageLayout,
finalLayout: ImageLayout,
};
pub const AttachmentReference = extern struct {
attachment: u32,
layout: ImageLayout,
};
pub const SubpassDescription = extern struct {
flags: SubpassDescriptionFlags align(4) = SubpassDescriptionFlags{},
pipelineBindPoint: PipelineBindPoint,
inputAttachmentCount: u32 = 0,
pInputAttachments: [*]const AttachmentReference = undefined,
colorAttachmentCount: u32 = 0,
pColorAttachments: [*]const AttachmentReference = undefined,
pResolveAttachments: ?[*]const AttachmentReference = null,
pDepthStencilAttachment: ?*const AttachmentReference = null,
preserveAttachmentCount: u32 = 0,
pPreserveAttachments: [*]const u32 = undefined,
};
pub const SubpassDependency = extern struct {
srcSubpass: u32,
dstSubpass: u32,
srcStageMask: PipelineStageFlags align(4),
dstStageMask: PipelineStageFlags align(4),
srcAccessMask: AccessFlags align(4) = AccessFlags{},
dstAccessMask: AccessFlags align(4) = AccessFlags{},
dependencyFlags: DependencyFlags align(4) = DependencyFlags{},
};
pub const RenderPassCreateInfo = extern struct {
sType: StructureType = .RENDER_PASS_CREATE_INFO,
pNext: ?*const c_void = null,
flags: RenderPassCreateFlags align(4) = RenderPassCreateFlags{},
attachmentCount: u32 = 0,
pAttachments: [*]const AttachmentDescription = undefined,
subpassCount: u32,
pSubpasses: [*]const SubpassDescription,
dependencyCount: u32 = 0,
pDependencies: [*]const SubpassDependency = undefined,
};
pub const CommandPoolCreateInfo = extern struct {
sType: StructureType = .COMMAND_POOL_CREATE_INFO,
pNext: ?*const c_void = null,
flags: CommandPoolCreateFlags align(4) = CommandPoolCreateFlags{},
queueFamilyIndex: u32,
};
pub const CommandBufferAllocateInfo = extern struct {
sType: StructureType = .COMMAND_BUFFER_ALLOCATE_INFO,
pNext: ?*const c_void = null,
commandPool: CommandPool,
level: CommandBufferLevel,
commandBufferCount: u32,
};
pub const CommandBufferInheritanceInfo = extern struct {
sType: StructureType = .COMMAND_BUFFER_INHERITANCE_INFO,
pNext: ?*const c_void = null,
renderPass: ?RenderPass = null,
subpass: u32,
framebuffer: ?Framebuffer = null,
occlusionQueryEnable: Bool32,
queryFlags: QueryControlFlags align(4) = QueryControlFlags{},
pipelineStatistics: QueryPipelineStatisticFlags align(4) = QueryPipelineStatisticFlags{},
};
pub const CommandBufferBeginInfo = extern struct {
sType: StructureType = .COMMAND_BUFFER_BEGIN_INFO,
pNext: ?*const c_void = null,
flags: CommandBufferUsageFlags align(4) = CommandBufferUsageFlags{},
pInheritanceInfo: ?*const CommandBufferInheritanceInfo = null,
};
pub const BufferCopy = extern struct {
srcOffset: DeviceSize,
dstOffset: DeviceSize,
size: DeviceSize,
};
pub const ImageSubresourceLayers = extern struct {
aspectMask: ImageAspectFlags align(4),
mipLevel: u32,
baseArrayLayer: u32,
layerCount: u32,
};
pub const ImageCopy = extern struct {
srcSubresource: ImageSubresourceLayers,
srcOffset: Offset3D,
dstSubresource: ImageSubresourceLayers,
dstOffset: Offset3D,
extent: Extent3D,
};
pub const ImageBlit = extern struct {
srcSubresource: ImageSubresourceLayers,
srcOffsets: [2]Offset3D,
dstSubresource: ImageSubresourceLayers,
dstOffsets: [2]Offset3D,
};
pub const BufferImageCopy = extern struct {
bufferOffset: DeviceSize,
bufferRowLength: u32,
bufferImageHeight: u32,
imageSubresource: ImageSubresourceLayers,
imageOffset: Offset3D,
imageExtent: Extent3D,
};
pub const ClearColorValue = extern union {
float32: [4]f32,
int32: [4]i32,
uint32: [4]u32,
};
pub const ClearDepthStencilValue = extern struct {
depth: f32,
stencil: u32,
};
pub const ClearValue = extern union {
color: ClearColorValue,
depthStencil: ClearDepthStencilValue,
};
pub const ClearAttachment = extern struct {
aspectMask: ImageAspectFlags align(4),
colorAttachment: u32,
clearValue: ClearValue,
};
pub const ClearRect = extern struct {
rect: Rect2D,
baseArrayLayer: u32,
layerCount: u32,
};
pub const ImageResolve = extern struct {
srcSubresource: ImageSubresourceLayers,
srcOffset: Offset3D,
dstSubresource: ImageSubresourceLayers,
dstOffset: Offset3D,
extent: Extent3D,
};
pub const MemoryBarrier = extern struct {
sType: StructureType = .MEMORY_BARRIER,
pNext: ?*const c_void = null,
srcAccessMask: AccessFlags align(4) = AccessFlags{},
dstAccessMask: AccessFlags align(4) = AccessFlags{},
};
pub const BufferMemoryBarrier = extern struct {
sType: StructureType = .BUFFER_MEMORY_BARRIER,
pNext: ?*const c_void = null,
srcAccessMask: AccessFlags align(4),
dstAccessMask: AccessFlags align(4),
srcQueueFamilyIndex: u32,
dstQueueFamilyIndex: u32,
buffer: Buffer,
offset: DeviceSize,
size: DeviceSize,
};
pub const ImageMemoryBarrier = extern struct {
sType: StructureType = .IMAGE_MEMORY_BARRIER,
pNext: ?*const c_void = null,
srcAccessMask: AccessFlags align(4),
dstAccessMask: AccessFlags align(4),
oldLayout: ImageLayout,
newLayout: ImageLayout,
srcQueueFamilyIndex: u32,
dstQueueFamilyIndex: u32,
image: Image,
subresourceRange: ImageSubresourceRange,
};
pub const RenderPassBeginInfo = extern struct {
sType: StructureType = .RENDER_PASS_BEGIN_INFO,
pNext: ?*const c_void = null,
renderPass: RenderPass,
framebuffer: Framebuffer,
renderArea: Rect2D,
clearValueCount: u32 = 0,
pClearValues: [*]const ClearValue = undefined,
};
pub const DispatchIndirectCommand = extern struct {
x: u32,
y: u32,
z: u32,
};
pub const DrawIndexedIndirectCommand = extern struct {
indexCount: u32,
instanceCount: u32,
firstIndex: u32,
vertexOffset: i32,
firstInstance: u32,
};
pub const DrawIndirectCommand = extern struct {
vertexCount: u32,
instanceCount: u32,
firstVertex: u32,
firstInstance: u32,
};
pub const BaseOutStructure = extern struct {
sType: StructureType,
pNext: *@This(),
};
pub const BaseInStructure = extern struct {
sType: StructureType,
pNext: *const @This(),
};
pub extern fn vkCreateInstance(
pCreateInfo: *const InstanceCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pInstance: *Instance,
) callconv(CallConv) Result;
pub extern fn vkDestroyInstance(
instance: ?Instance,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkEnumeratePhysicalDevices(
instance: Instance,
pPhysicalDeviceCount: *u32,
pPhysicalDevices: ?[*]PhysicalDevice,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceFeatures(
physicalDevice: PhysicalDevice,
pFeatures: *PhysicalDeviceFeatures,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceFormatProperties(
physicalDevice: PhysicalDevice,
format: Format,
pFormatProperties: *FormatProperties,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceImageFormatProperties(
physicalDevice: PhysicalDevice,
format: Format,
inType: ImageType,
tiling: ImageTiling,
usage: ImageUsageFlags.IntType,
flags: ImageCreateFlags.IntType,
pImageFormatProperties: *ImageFormatProperties,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceProperties(
physicalDevice: PhysicalDevice,
pProperties: *PhysicalDeviceProperties,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceQueueFamilyProperties(
physicalDevice: PhysicalDevice,
pQueueFamilyPropertyCount: *u32,
pQueueFamilyProperties: ?[*]QueueFamilyProperties,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceMemoryProperties(
physicalDevice: PhysicalDevice,
pMemoryProperties: *PhysicalDeviceMemoryProperties,
) callconv(CallConv) void;
pub extern fn vkGetInstanceProcAddr(
instance: ?Instance,
pName: CString,
) callconv(CallConv) PFN_VoidFunction;
pub extern fn vkGetDeviceProcAddr(
device: Device,
pName: CString,
) callconv(CallConv) PFN_VoidFunction;
pub extern fn vkCreateDevice(
physicalDevice: PhysicalDevice,
pCreateInfo: *const DeviceCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pDevice: *Device,
) callconv(CallConv) Result;
pub extern fn vkDestroyDevice(
device: ?Device,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkEnumerateInstanceExtensionProperties(
pLayerName: ?CString,
pPropertyCount: *u32,
pProperties: ?[*]ExtensionProperties,
) callconv(CallConv) Result;
pub extern fn vkEnumerateDeviceExtensionProperties(
physicalDevice: PhysicalDevice,
pLayerName: ?CString,
pPropertyCount: *u32,
pProperties: ?[*]ExtensionProperties,
) callconv(CallConv) Result;
pub extern fn vkEnumerateInstanceLayerProperties(
pPropertyCount: *u32,
pProperties: ?[*]LayerProperties,
) callconv(CallConv) Result;
pub extern fn vkEnumerateDeviceLayerProperties(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]LayerProperties,
) callconv(CallConv) Result;
pub extern fn vkGetDeviceQueue(
device: Device,
queueFamilyIndex: u32,
queueIndex: u32,
pQueue: *Queue,
) callconv(CallConv) void;
pub extern fn vkQueueSubmit(
queue: Queue,
submitCount: u32,
pSubmits: [*]const SubmitInfo,
fence: ?Fence,
) callconv(CallConv) Result;
pub extern fn vkQueueWaitIdle(queue: Queue) callconv(CallConv) Result;
pub extern fn vkDeviceWaitIdle(device: Device) callconv(CallConv) Result;
pub extern fn vkAllocateMemory(
device: Device,
pAllocateInfo: *const MemoryAllocateInfo,
pAllocator: ?*const AllocationCallbacks,
pMemory: *DeviceMemory,
) callconv(CallConv) Result;
pub extern fn vkFreeMemory(
device: Device,
memory: ?DeviceMemory,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkMapMemory(
device: Device,
memory: DeviceMemory,
offset: DeviceSize,
size: DeviceSize,
flags: MemoryMapFlags.IntType,
ppData: ?**c_void,
) callconv(CallConv) Result;
pub extern fn vkUnmapMemory(
device: Device,
memory: DeviceMemory,
) callconv(CallConv) void;
pub extern fn vkFlushMappedMemoryRanges(
device: Device,
memoryRangeCount: u32,
pMemoryRanges: [*]const MappedMemoryRange,
) callconv(CallConv) Result;
pub extern fn vkInvalidateMappedMemoryRanges(
device: Device,
memoryRangeCount: u32,
pMemoryRanges: [*]const MappedMemoryRange,
) callconv(CallConv) Result;
pub extern fn vkGetDeviceMemoryCommitment(
device: Device,
memory: DeviceMemory,
pCommittedMemoryInBytes: *DeviceSize,
) callconv(CallConv) void;
pub extern fn vkBindBufferMemory(
device: Device,
buffer: Buffer,
memory: DeviceMemory,
memoryOffset: DeviceSize,
) callconv(CallConv) Result;
pub extern fn vkBindImageMemory(
device: Device,
image: Image,
memory: DeviceMemory,
memoryOffset: DeviceSize,
) callconv(CallConv) Result;
pub extern fn vkGetBufferMemoryRequirements(
device: Device,
buffer: Buffer,
pMemoryRequirements: *MemoryRequirements,
) callconv(CallConv) void;
pub extern fn vkGetImageMemoryRequirements(
device: Device,
image: Image,
pMemoryRequirements: *MemoryRequirements,
) callconv(CallConv) void;
pub extern fn vkGetImageSparseMemoryRequirements(
device: Device,
image: Image,
pSparseMemoryRequirementCount: *u32,
pSparseMemoryRequirements: ?[*]SparseImageMemoryRequirements,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceSparseImageFormatProperties(
physicalDevice: PhysicalDevice,
format: Format,
inType: ImageType,
samples: SampleCountFlags.IntType,
usage: ImageUsageFlags.IntType,
tiling: ImageTiling,
pPropertyCount: *u32,
pProperties: ?[*]SparseImageFormatProperties,
) callconv(CallConv) void;
pub extern fn vkQueueBindSparse(
queue: Queue,
bindInfoCount: u32,
pBindInfo: [*]const BindSparseInfo,
fence: ?Fence,
) callconv(CallConv) Result;
pub extern fn vkCreateFence(
device: Device,
pCreateInfo: *const FenceCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pFence: *Fence,
) callconv(CallConv) Result;
pub extern fn vkDestroyFence(
device: Device,
fence: ?Fence,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkResetFences(
device: Device,
fenceCount: u32,
pFences: [*]const Fence,
) callconv(CallConv) Result;
pub extern fn vkGetFenceStatus(
device: Device,
fence: Fence,
) callconv(CallConv) Result;
pub extern fn vkWaitForFences(
device: Device,
fenceCount: u32,
pFences: [*]const Fence,
waitAll: Bool32,
timeout: u64,
) callconv(CallConv) Result;
pub extern fn vkCreateSemaphore(
device: Device,
pCreateInfo: *const SemaphoreCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pSemaphore: *Semaphore,
) callconv(CallConv) Result;
pub extern fn vkDestroySemaphore(
device: Device,
semaphore: ?Semaphore,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateEvent(
device: Device,
pCreateInfo: *const EventCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pEvent: *Event,
) callconv(CallConv) Result;
pub extern fn vkDestroyEvent(
device: Device,
event: ?Event,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetEventStatus(
device: Device,
event: Event,
) callconv(CallConv) Result;
pub extern fn vkSetEvent(
device: Device,
event: Event,
) callconv(CallConv) Result;
pub extern fn vkResetEvent(
device: Device,
event: Event,
) callconv(CallConv) Result;
pub extern fn vkCreateQueryPool(
device: Device,
pCreateInfo: *const QueryPoolCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pQueryPool: *QueryPool,
) callconv(CallConv) Result;
pub extern fn vkDestroyQueryPool(
device: Device,
queryPool: ?QueryPool,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetQueryPoolResults(
device: Device,
queryPool: QueryPool,
firstQuery: u32,
queryCount: u32,
dataSize: usize,
pData: ?*c_void,
stride: DeviceSize,
flags: QueryResultFlags.IntType,
) callconv(CallConv) Result;
pub extern fn vkCreateBuffer(
device: Device,
pCreateInfo: *const BufferCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pBuffer: *Buffer,
) callconv(CallConv) Result;
pub extern fn vkDestroyBuffer(
device: Device,
buffer: ?Buffer,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateBufferView(
device: Device,
pCreateInfo: *const BufferViewCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pView: *BufferView,
) callconv(CallConv) Result;
pub extern fn vkDestroyBufferView(
device: Device,
bufferView: ?BufferView,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateImage(
device: Device,
pCreateInfo: *const ImageCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pImage: *Image,
) callconv(CallConv) Result;
pub extern fn vkDestroyImage(
device: Device,
image: ?Image,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetImageSubresourceLayout(
device: Device,
image: Image,
pSubresource: *const ImageSubresource,
pLayout: *SubresourceLayout,
) callconv(CallConv) void;
pub extern fn vkCreateImageView(
device: Device,
pCreateInfo: *const ImageViewCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pView: *ImageView,
) callconv(CallConv) Result;
pub extern fn vkDestroyImageView(
device: Device,
imageView: ?ImageView,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateShaderModule(
device: Device,
pCreateInfo: *const ShaderModuleCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pShaderModule: *ShaderModule,
) callconv(CallConv) Result;
pub extern fn vkDestroyShaderModule(
device: Device,
shaderModule: ?ShaderModule,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreatePipelineCache(
device: Device,
pCreateInfo: *const PipelineCacheCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pPipelineCache: *PipelineCache,
) callconv(CallConv) Result;
pub extern fn vkDestroyPipelineCache(
device: Device,
pipelineCache: ?PipelineCache,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetPipelineCacheData(
device: Device,
pipelineCache: PipelineCache,
pDataSize: *usize,
pData: ?*c_void,
) callconv(CallConv) Result;
pub extern fn vkMergePipelineCaches(
device: Device,
dstCache: PipelineCache,
srcCacheCount: u32,
pSrcCaches: [*]const PipelineCache,
) callconv(CallConv) Result;
pub extern fn vkCreateGraphicsPipelines(
device: Device,
pipelineCache: ?PipelineCache,
createInfoCount: u32,
pCreateInfos: [*]const GraphicsPipelineCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pPipelines: [*]Pipeline,
) callconv(CallConv) Result;
pub extern fn vkCreateComputePipelines(
device: Device,
pipelineCache: ?PipelineCache,
createInfoCount: u32,
pCreateInfos: [*]const ComputePipelineCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pPipelines: [*]Pipeline,
) callconv(CallConv) Result;
pub extern fn vkDestroyPipeline(
device: Device,
pipeline: ?Pipeline,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreatePipelineLayout(
device: Device,
pCreateInfo: *const PipelineLayoutCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pPipelineLayout: *PipelineLayout,
) callconv(CallConv) Result;
pub extern fn vkDestroyPipelineLayout(
device: Device,
pipelineLayout: ?PipelineLayout,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateSampler(
device: Device,
pCreateInfo: *const SamplerCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pSampler: *Sampler,
) callconv(CallConv) Result;
pub extern fn vkDestroySampler(
device: Device,
sampler: ?Sampler,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateDescriptorSetLayout(
device: Device,
pCreateInfo: *const DescriptorSetLayoutCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pSetLayout: *DescriptorSetLayout,
) callconv(CallConv) Result;
pub extern fn vkDestroyDescriptorSetLayout(
device: Device,
descriptorSetLayout: ?DescriptorSetLayout,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateDescriptorPool(
device: Device,
pCreateInfo: *const DescriptorPoolCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pDescriptorPool: *DescriptorPool,
) callconv(CallConv) Result;
pub extern fn vkDestroyDescriptorPool(
device: Device,
descriptorPool: ?DescriptorPool,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkResetDescriptorPool(
device: Device,
descriptorPool: DescriptorPool,
flags: DescriptorPoolResetFlags.IntType,
) callconv(CallConv) Result;
pub extern fn vkAllocateDescriptorSets(
device: Device,
pAllocateInfo: *const DescriptorSetAllocateInfo,
pDescriptorSets: [*]DescriptorSet,
) callconv(CallConv) Result;
pub extern fn vkFreeDescriptorSets(
device: Device,
descriptorPool: DescriptorPool,
descriptorSetCount: u32,
pDescriptorSets: [*]const DescriptorSet,
) callconv(CallConv) Result;
pub extern fn vkUpdateDescriptorSets(
device: Device,
descriptorWriteCount: u32,
pDescriptorWrites: [*]const WriteDescriptorSet,
descriptorCopyCount: u32,
pDescriptorCopies: [*]const CopyDescriptorSet,
) callconv(CallConv) void;
pub extern fn vkCreateFramebuffer(
device: Device,
pCreateInfo: *const FramebufferCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pFramebuffer: *Framebuffer,
) callconv(CallConv) Result;
pub extern fn vkDestroyFramebuffer(
device: Device,
framebuffer: ?Framebuffer,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateRenderPass(
device: Device,
pCreateInfo: *const RenderPassCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pRenderPass: *RenderPass,
) callconv(CallConv) Result;
pub extern fn vkDestroyRenderPass(
device: Device,
renderPass: ?RenderPass,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetRenderAreaGranularity(
device: Device,
renderPass: RenderPass,
pGranularity: *Extent2D,
) callconv(CallConv) void;
pub extern fn vkCreateCommandPool(
device: Device,
pCreateInfo: *const CommandPoolCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pCommandPool: *CommandPool,
) callconv(CallConv) Result;
pub extern fn vkDestroyCommandPool(
device: Device,
commandPool: ?CommandPool,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkResetCommandPool(
device: Device,
commandPool: CommandPool,
flags: CommandPoolResetFlags.IntType,
) callconv(CallConv) Result;
pub extern fn vkAllocateCommandBuffers(
device: Device,
pAllocateInfo: *const CommandBufferAllocateInfo,
pCommandBuffers: [*]CommandBuffer,
) callconv(CallConv) Result;
pub extern fn vkFreeCommandBuffers(
device: Device,
commandPool: CommandPool,
commandBufferCount: u32,
pCommandBuffers: [*]const CommandBuffer,
) callconv(CallConv) void;
pub extern fn vkBeginCommandBuffer(
commandBuffer: CommandBuffer,
pBeginInfo: *const CommandBufferBeginInfo,
) callconv(CallConv) Result;
pub extern fn vkEndCommandBuffer(commandBuffer: CommandBuffer) callconv(CallConv) Result;
pub extern fn vkResetCommandBuffer(
commandBuffer: CommandBuffer,
flags: CommandBufferResetFlags.IntType,
) callconv(CallConv) Result;
pub extern fn vkCmdBindPipeline(
commandBuffer: CommandBuffer,
pipelineBindPoint: PipelineBindPoint,
pipeline: Pipeline,
) callconv(CallConv) void;
pub extern fn vkCmdSetViewport(
commandBuffer: CommandBuffer,
firstViewport: u32,
viewportCount: u32,
pViewports: [*]const Viewport,
) callconv(CallConv) void;
pub extern fn vkCmdSetScissor(
commandBuffer: CommandBuffer,
firstScissor: u32,
scissorCount: u32,
pScissors: [*]const Rect2D,
) callconv(CallConv) void;
pub extern fn vkCmdSetLineWidth(
commandBuffer: CommandBuffer,
lineWidth: f32,
) callconv(CallConv) void;
pub extern fn vkCmdSetDepthBias(
commandBuffer: CommandBuffer,
depthBiasConstantFactor: f32,
depthBiasClamp: f32,
depthBiasSlopeFactor: f32,
) callconv(CallConv) void;
pub extern fn vkCmdSetBlendConstants(
commandBuffer: CommandBuffer,
blendConstants: *const[4]f32,
) callconv(CallConv) void;
pub extern fn vkCmdSetDepthBounds(
commandBuffer: CommandBuffer,
minDepthBounds: f32,
maxDepthBounds: f32,
) callconv(CallConv) void;
pub extern fn vkCmdSetStencilCompareMask(
commandBuffer: CommandBuffer,
faceMask: StencilFaceFlags.IntType,
compareMask: u32,
) callconv(CallConv) void;
pub extern fn vkCmdSetStencilWriteMask(
commandBuffer: CommandBuffer,
faceMask: StencilFaceFlags.IntType,
writeMask: u32,
) callconv(CallConv) void;
pub extern fn vkCmdSetStencilReference(
commandBuffer: CommandBuffer,
faceMask: StencilFaceFlags.IntType,
reference: u32,
) callconv(CallConv) void;
pub extern fn vkCmdBindDescriptorSets(
commandBuffer: CommandBuffer,
pipelineBindPoint: PipelineBindPoint,
layout: PipelineLayout,
firstSet: u32,
descriptorSetCount: u32,
pDescriptorSets: [*]const DescriptorSet,
dynamicOffsetCount: u32,
pDynamicOffsets: [*]const u32,
) callconv(CallConv) void;
pub extern fn vkCmdBindIndexBuffer(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
indexType: IndexType,
) callconv(CallConv) void;
pub extern fn vkCmdBindVertexBuffers(
commandBuffer: CommandBuffer,
firstBinding: u32,
bindingCount: u32,
pBuffers: [*]const Buffer,
pOffsets: [*]const DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdDraw(
commandBuffer: CommandBuffer,
vertexCount: u32,
instanceCount: u32,
firstVertex: u32,
firstInstance: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndexed(
commandBuffer: CommandBuffer,
indexCount: u32,
instanceCount: u32,
firstIndex: u32,
vertexOffset: i32,
firstInstance: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndirect(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
drawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndexedIndirect(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
drawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDispatch(
commandBuffer: CommandBuffer,
groupCountX: u32,
groupCountY: u32,
groupCountZ: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDispatchIndirect(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdCopyBuffer(
commandBuffer: CommandBuffer,
srcBuffer: Buffer,
dstBuffer: Buffer,
regionCount: u32,
pRegions: [*]const BufferCopy,
) callconv(CallConv) void;
pub extern fn vkCmdCopyImage(
commandBuffer: CommandBuffer,
srcImage: Image,
srcImageLayout: ImageLayout,
dstImage: Image,
dstImageLayout: ImageLayout,
regionCount: u32,
pRegions: [*]const ImageCopy,
) callconv(CallConv) void;
pub extern fn vkCmdBlitImage(
commandBuffer: CommandBuffer,
srcImage: Image,
srcImageLayout: ImageLayout,
dstImage: Image,
dstImageLayout: ImageLayout,
regionCount: u32,
pRegions: [*]const ImageBlit,
filter: Filter,
) callconv(CallConv) void;
pub extern fn vkCmdCopyBufferToImage(
commandBuffer: CommandBuffer,
srcBuffer: Buffer,
dstImage: Image,
dstImageLayout: ImageLayout,
regionCount: u32,
pRegions: [*]const BufferImageCopy,
) callconv(CallConv) void;
pub extern fn vkCmdCopyImageToBuffer(
commandBuffer: CommandBuffer,
srcImage: Image,
srcImageLayout: ImageLayout,
dstBuffer: Buffer,
regionCount: u32,
pRegions: [*]const BufferImageCopy,
) callconv(CallConv) void;
pub extern fn vkCmdUpdateBuffer(
commandBuffer: CommandBuffer,
dstBuffer: Buffer,
dstOffset: DeviceSize,
dataSize: DeviceSize,
pData: ?*const c_void,
) callconv(CallConv) void;
pub extern fn vkCmdFillBuffer(
commandBuffer: CommandBuffer,
dstBuffer: Buffer,
dstOffset: DeviceSize,
size: DeviceSize,
data: u32,
) callconv(CallConv) void;
pub extern fn vkCmdClearColorImage(
commandBuffer: CommandBuffer,
image: Image,
imageLayout: ImageLayout,
pColor: *const ClearColorValue,
rangeCount: u32,
pRanges: [*]const ImageSubresourceRange,
) callconv(CallConv) void;
pub extern fn vkCmdClearDepthStencilImage(
commandBuffer: CommandBuffer,
image: Image,
imageLayout: ImageLayout,
pDepthStencil: *const ClearDepthStencilValue,
rangeCount: u32,
pRanges: [*]const ImageSubresourceRange,
) callconv(CallConv) void;
pub extern fn vkCmdClearAttachments(
commandBuffer: CommandBuffer,
attachmentCount: u32,
pAttachments: [*]const ClearAttachment,
rectCount: u32,
pRects: [*]const ClearRect,
) callconv(CallConv) void;
pub extern fn vkCmdResolveImage(
commandBuffer: CommandBuffer,
srcImage: Image,
srcImageLayout: ImageLayout,
dstImage: Image,
dstImageLayout: ImageLayout,
regionCount: u32,
pRegions: [*]const ImageResolve,
) callconv(CallConv) void;
pub extern fn vkCmdSetEvent(
commandBuffer: CommandBuffer,
event: Event,
stageMask: PipelineStageFlags.IntType,
) callconv(CallConv) void;
pub extern fn vkCmdResetEvent(
commandBuffer: CommandBuffer,
event: Event,
stageMask: PipelineStageFlags.IntType,
) callconv(CallConv) void;
pub extern fn vkCmdWaitEvents(
commandBuffer: CommandBuffer,
eventCount: u32,
pEvents: [*]const Event,
srcStageMask: PipelineStageFlags.IntType,
dstStageMask: PipelineStageFlags.IntType,
memoryBarrierCount: u32,
pMemoryBarriers: [*]const MemoryBarrier,
bufferMemoryBarrierCount: u32,
pBufferMemoryBarriers: [*]const BufferMemoryBarrier,
imageMemoryBarrierCount: u32,
pImageMemoryBarriers: [*]const ImageMemoryBarrier,
) callconv(CallConv) void;
pub extern fn vkCmdPipelineBarrier(
commandBuffer: CommandBuffer,
srcStageMask: PipelineStageFlags.IntType,
dstStageMask: PipelineStageFlags.IntType,
dependencyFlags: DependencyFlags.IntType,
memoryBarrierCount: u32,
pMemoryBarriers: [*]const MemoryBarrier,
bufferMemoryBarrierCount: u32,
pBufferMemoryBarriers: [*]const BufferMemoryBarrier,
imageMemoryBarrierCount: u32,
pImageMemoryBarriers: [*]const ImageMemoryBarrier,
) callconv(CallConv) void;
pub extern fn vkCmdBeginQuery(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
query: u32,
flags: QueryControlFlags.IntType,
) callconv(CallConv) void;
pub extern fn vkCmdEndQuery(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
query: u32,
) callconv(CallConv) void;
pub extern fn vkCmdResetQueryPool(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
firstQuery: u32,
queryCount: u32,
) callconv(CallConv) void;
pub extern fn vkCmdWriteTimestamp(
commandBuffer: CommandBuffer,
pipelineStage: PipelineStageFlags.IntType,
queryPool: QueryPool,
query: u32,
) callconv(CallConv) void;
pub extern fn vkCmdCopyQueryPoolResults(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
firstQuery: u32,
queryCount: u32,
dstBuffer: Buffer,
dstOffset: DeviceSize,
stride: DeviceSize,
flags: QueryResultFlags.IntType,
) callconv(CallConv) void;
pub extern fn vkCmdPushConstants(
commandBuffer: CommandBuffer,
layout: PipelineLayout,
stageFlags: ShaderStageFlags.IntType,
offset: u32,
size: u32,
pValues: ?*const c_void,
) callconv(CallConv) void;
pub extern fn vkCmdBeginRenderPass(
commandBuffer: CommandBuffer,
pRenderPassBegin: *const RenderPassBeginInfo,
contents: SubpassContents,
) callconv(CallConv) void;
pub extern fn vkCmdNextSubpass(
commandBuffer: CommandBuffer,
contents: SubpassContents,
) callconv(CallConv) void;
pub extern fn vkCmdEndRenderPass(commandBuffer: CommandBuffer) callconv(CallConv) void;
pub extern fn vkCmdExecuteCommands(
commandBuffer: CommandBuffer,
commandBufferCount: u32,
pCommandBuffers: [*]const CommandBuffer,
) callconv(CallConv) void;
pub inline fn CreateInstance(createInfo: InstanceCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_LAYER_NOT_PRESENT,VK_EXTENSION_NOT_PRESENT,VK_INCOMPATIBLE_DRIVER,VK_UNDOCUMENTED_ERROR}!Instance {
var out_instance: Instance = undefined;
const result = vkCreateInstance(&createInfo, pAllocator, &out_instance);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
.ERROR_LAYER_NOT_PRESENT => error.VK_LAYER_NOT_PRESENT,
.ERROR_EXTENSION_NOT_PRESENT => error.VK_EXTENSION_NOT_PRESENT,
.ERROR_INCOMPATIBLE_DRIVER => error.VK_INCOMPATIBLE_DRIVER,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_instance;
}
pub const DestroyInstance = vkDestroyInstance;
pub const EnumeratePhysicalDevicesResult = struct {
result: Result,
physicalDevices: []PhysicalDevice,
};
pub inline fn EnumeratePhysicalDevices(instance: Instance, physicalDevices: []PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!EnumeratePhysicalDevicesResult {
var returnValues: EnumeratePhysicalDevicesResult = undefined;
var physicalDeviceCount: u32 = @intCast(u32, physicalDevices.len);
const result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.physicalDevices = physicalDevices[0..physicalDeviceCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumeratePhysicalDevicesCount(instance: Instance) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!u32 {
var out_physicalDeviceCount: u32 = undefined;
const result = vkEnumeratePhysicalDevices(instance, &out_physicalDeviceCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_physicalDeviceCount;
}
pub inline fn GetPhysicalDeviceFeatures(physicalDevice: PhysicalDevice) PhysicalDeviceFeatures {
var out_features: PhysicalDeviceFeatures = undefined;
vkGetPhysicalDeviceFeatures(physicalDevice, &out_features);
return out_features;
}
pub inline fn GetPhysicalDeviceFormatProperties(physicalDevice: PhysicalDevice, format: Format) FormatProperties {
var out_formatProperties: FormatProperties = undefined;
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &out_formatProperties);
return out_formatProperties;
}
pub inline fn GetPhysicalDeviceImageFormatProperties(physicalDevice: PhysicalDevice, format: Format, inType: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FORMAT_NOT_SUPPORTED,VK_UNDOCUMENTED_ERROR}!ImageFormatProperties {
var out_imageFormatProperties: ImageFormatProperties = undefined;
const result = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, inType, tiling, usage.toInt(), flags.toInt(), &out_imageFormatProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FORMAT_NOT_SUPPORTED => error.VK_FORMAT_NOT_SUPPORTED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_imageFormatProperties;
}
pub inline fn GetPhysicalDeviceProperties(physicalDevice: PhysicalDevice) PhysicalDeviceProperties {
var out_properties: PhysicalDeviceProperties = undefined;
vkGetPhysicalDeviceProperties(physicalDevice, &out_properties);
return out_properties;
}
pub inline fn GetPhysicalDeviceQueueFamilyProperties(physicalDevice: PhysicalDevice, queueFamilyProperties: []QueueFamilyProperties) []QueueFamilyProperties {
var out_queueFamilyProperties: []QueueFamilyProperties = undefined;
var queueFamilyPropertyCount: u32 = @intCast(u32, queueFamilyProperties.len);
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyPropertyCount, queueFamilyProperties.ptr);
out_queueFamilyProperties = queueFamilyProperties[0..queueFamilyPropertyCount];
return out_queueFamilyProperties;
}
pub inline fn GetPhysicalDeviceQueueFamilyPropertiesCount(physicalDevice: PhysicalDevice) u32 {
var out_queueFamilyPropertyCount: u32 = undefined;
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &out_queueFamilyPropertyCount, null);
return out_queueFamilyPropertyCount;
}
pub inline fn GetPhysicalDeviceMemoryProperties(physicalDevice: PhysicalDevice) PhysicalDeviceMemoryProperties {
var out_memoryProperties: PhysicalDeviceMemoryProperties = undefined;
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &out_memoryProperties);
return out_memoryProperties;
}
pub const GetInstanceProcAddr = vkGetInstanceProcAddr;
pub const GetDeviceProcAddr = vkGetDeviceProcAddr;
pub inline fn CreateDevice(physicalDevice: PhysicalDevice, createInfo: DeviceCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_EXTENSION_NOT_PRESENT,VK_FEATURE_NOT_PRESENT,VK_TOO_MANY_OBJECTS,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Device {
var out_device: Device = undefined;
const result = vkCreateDevice(physicalDevice, &createInfo, pAllocator, &out_device);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
.ERROR_EXTENSION_NOT_PRESENT => error.VK_EXTENSION_NOT_PRESENT,
.ERROR_FEATURE_NOT_PRESENT => error.VK_FEATURE_NOT_PRESENT,
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_device;
}
pub const DestroyDevice = vkDestroyDevice;
pub const EnumerateInstanceExtensionPropertiesResult = struct {
result: Result,
properties: []ExtensionProperties,
};
pub inline fn EnumerateInstanceExtensionProperties(pLayerName: ?CString, properties: []ExtensionProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_LAYER_NOT_PRESENT,VK_UNDOCUMENTED_ERROR}!EnumerateInstanceExtensionPropertiesResult {
var returnValues: EnumerateInstanceExtensionPropertiesResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkEnumerateInstanceExtensionProperties(pLayerName, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_LAYER_NOT_PRESENT => error.VK_LAYER_NOT_PRESENT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumerateInstanceExtensionPropertiesCount(pLayerName: ?CString) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_LAYER_NOT_PRESENT,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkEnumerateInstanceExtensionProperties(pLayerName, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_LAYER_NOT_PRESENT => error.VK_LAYER_NOT_PRESENT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const EnumerateDeviceExtensionPropertiesResult = struct {
result: Result,
properties: []ExtensionProperties,
};
pub inline fn EnumerateDeviceExtensionProperties(physicalDevice: PhysicalDevice, pLayerName: ?CString, properties: []ExtensionProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_LAYER_NOT_PRESENT,VK_UNDOCUMENTED_ERROR}!EnumerateDeviceExtensionPropertiesResult {
var returnValues: EnumerateDeviceExtensionPropertiesResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkEnumerateDeviceExtensionProperties(physicalDevice, pLayerName, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_LAYER_NOT_PRESENT => error.VK_LAYER_NOT_PRESENT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumerateDeviceExtensionPropertiesCount(physicalDevice: PhysicalDevice, pLayerName: ?CString) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_LAYER_NOT_PRESENT,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkEnumerateDeviceExtensionProperties(physicalDevice, pLayerName, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_LAYER_NOT_PRESENT => error.VK_LAYER_NOT_PRESENT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const EnumerateInstanceLayerPropertiesResult = struct {
result: Result,
properties: []LayerProperties,
};
pub inline fn EnumerateInstanceLayerProperties(properties: []LayerProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!EnumerateInstanceLayerPropertiesResult {
var returnValues: EnumerateInstanceLayerPropertiesResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkEnumerateInstanceLayerProperties(&propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumerateInstanceLayerPropertiesCount() error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkEnumerateInstanceLayerProperties(&out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const EnumerateDeviceLayerPropertiesResult = struct {
result: Result,
properties: []LayerProperties,
};
pub inline fn EnumerateDeviceLayerProperties(physicalDevice: PhysicalDevice, properties: []LayerProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!EnumerateDeviceLayerPropertiesResult {
var returnValues: EnumerateDeviceLayerPropertiesResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkEnumerateDeviceLayerProperties(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumerateDeviceLayerPropertiesCount(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkEnumerateDeviceLayerProperties(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub inline fn GetDeviceQueue(device: Device, queueFamilyIndex: u32, queueIndex: u32) Queue {
var out_queue: Queue = undefined;
vkGetDeviceQueue(device, queueFamilyIndex, queueIndex, &out_queue);
return out_queue;
}
pub inline fn QueueSubmit(queue: Queue, submits: []const SubmitInfo, fence: ?Fence) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!void {
const result = vkQueueSubmit(queue, @intCast(u32, submits.len), submits.ptr, fence);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn QueueWaitIdle(queue: Queue) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!void {
const result = vkQueueWaitIdle(queue);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn DeviceWaitIdle(device: Device) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!void {
const result = vkDeviceWaitIdle(device);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn AllocateMemory(device: Device, allocateInfo: MemoryAllocateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_TOO_MANY_OBJECTS,VK_INVALID_EXTERNAL_HANDLE,VK_INVALID_OPAQUE_CAPTURE_ADDRESS,VK_UNDOCUMENTED_ERROR}!DeviceMemory {
var out_memory: DeviceMemory = undefined;
const result = vkAllocateMemory(device, &allocateInfo, pAllocator, &out_memory);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_INVALID_EXTERNAL_HANDLE => error.VK_INVALID_EXTERNAL_HANDLE,
.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => error.VK_INVALID_OPAQUE_CAPTURE_ADDRESS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_memory;
}
pub const FreeMemory = vkFreeMemory;
pub inline fn MapMemory(device: Device, memory: DeviceMemory, offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags, ppData: ?**c_void) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_MEMORY_MAP_FAILED,VK_UNDOCUMENTED_ERROR}!void {
const result = vkMapMemory(device, memory, offset, size, flags.toInt(), ppData);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_MEMORY_MAP_FAILED => error.VK_MEMORY_MAP_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const UnmapMemory = vkUnmapMemory;
pub inline fn FlushMappedMemoryRanges(device: Device, memoryRanges: []const MappedMemoryRange) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkFlushMappedMemoryRanges(device, @intCast(u32, memoryRanges.len), memoryRanges.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn InvalidateMappedMemoryRanges(device: Device, memoryRanges: []const MappedMemoryRange) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkInvalidateMappedMemoryRanges(device, @intCast(u32, memoryRanges.len), memoryRanges.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetDeviceMemoryCommitment(device: Device, memory: DeviceMemory) DeviceSize {
var out_committedMemoryInBytes: DeviceSize = undefined;
vkGetDeviceMemoryCommitment(device, memory, &out_committedMemoryInBytes);
return out_committedMemoryInBytes;
}
pub inline fn BindBufferMemory(device: Device, buffer: Buffer, memory: DeviceMemory, memoryOffset: DeviceSize) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_OPAQUE_CAPTURE_ADDRESS,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindBufferMemory(device, buffer, memory, memoryOffset);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => error.VK_INVALID_OPAQUE_CAPTURE_ADDRESS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn BindImageMemory(device: Device, image: Image, memory: DeviceMemory, memoryOffset: DeviceSize) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindImageMemory(device, image, memory, memoryOffset);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetBufferMemoryRequirements(device: Device, buffer: Buffer) MemoryRequirements {
var out_memoryRequirements: MemoryRequirements = undefined;
vkGetBufferMemoryRequirements(device, buffer, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetImageMemoryRequirements(device: Device, image: Image) MemoryRequirements {
var out_memoryRequirements: MemoryRequirements = undefined;
vkGetImageMemoryRequirements(device, image, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirements(device: Device, image: Image, sparseMemoryRequirements: []SparseImageMemoryRequirements) []SparseImageMemoryRequirements {
var out_sparseMemoryRequirements: []SparseImageMemoryRequirements = undefined;
var sparseMemoryRequirementCount: u32 = @intCast(u32, sparseMemoryRequirements.len);
vkGetImageSparseMemoryRequirements(device, image, &sparseMemoryRequirementCount, sparseMemoryRequirements.ptr);
out_sparseMemoryRequirements = sparseMemoryRequirements[0..sparseMemoryRequirementCount];
return out_sparseMemoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirementsCount(device: Device, image: Image) u32 {
var out_sparseMemoryRequirementCount: u32 = undefined;
vkGetImageSparseMemoryRequirements(device, image, &out_sparseMemoryRequirementCount, null);
return out_sparseMemoryRequirementCount;
}
pub inline fn GetPhysicalDeviceSparseImageFormatProperties(physicalDevice: PhysicalDevice, format: Format, inType: ImageType, samples: SampleCountFlags, usage: ImageUsageFlags, tiling: ImageTiling, properties: []SparseImageFormatProperties) []SparseImageFormatProperties {
var out_properties: []SparseImageFormatProperties = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, inType, samples.toInt(), usage.toInt(), tiling, &propertyCount, properties.ptr);
out_properties = properties[0..propertyCount];
return out_properties;
}
pub inline fn GetPhysicalDeviceSparseImageFormatPropertiesCount(physicalDevice: PhysicalDevice, format: Format, inType: ImageType, samples: SampleCountFlags, usage: ImageUsageFlags, tiling: ImageTiling) u32 {
var out_propertyCount: u32 = undefined;
vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, inType, samples.toInt(), usage.toInt(), tiling, &out_propertyCount, null);
return out_propertyCount;
}
pub inline fn QueueBindSparse(queue: Queue, bindInfo: []const BindSparseInfo, fence: ?Fence) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!void {
const result = vkQueueBindSparse(queue, @intCast(u32, bindInfo.len), bindInfo.ptr, fence);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CreateFence(device: Device, createInfo: FenceCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!Fence {
var out_fence: Fence = undefined;
const result = vkCreateFence(device, &createInfo, pAllocator, &out_fence);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_fence;
}
pub const DestroyFence = vkDestroyFence;
pub inline fn ResetFences(device: Device, fences: []const Fence) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkResetFences(device, @intCast(u32, fences.len), fences.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetFenceStatus(device: Device, fence: Fence) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkGetFenceStatus(device, fence);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn WaitForFences(device: Device, fences: []const Fence, waitAll: Bool32, timeout: u64) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkWaitForFences(device, @intCast(u32, fences.len), fences.ptr, waitAll, timeout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn CreateSemaphore(device: Device, createInfo: SemaphoreCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!Semaphore {
var out_semaphore: Semaphore = undefined;
const result = vkCreateSemaphore(device, &createInfo, pAllocator, &out_semaphore);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_semaphore;
}
pub const DestroySemaphore = vkDestroySemaphore;
pub inline fn CreateEvent(device: Device, createInfo: EventCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!Event {
var out_event: Event = undefined;
const result = vkCreateEvent(device, &createInfo, pAllocator, &out_event);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_event;
}
pub const DestroyEvent = vkDestroyEvent;
pub inline fn GetEventStatus(device: Device, event: Event) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkGetEventStatus(device, event);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn SetEvent(device: Device, event: Event) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkSetEvent(device, event);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn ResetEvent(device: Device, event: Event) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkResetEvent(device, event);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CreateQueryPool(device: Device, createInfo: QueryPoolCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!QueryPool {
var out_queryPool: QueryPool = undefined;
const result = vkCreateQueryPool(device, &createInfo, pAllocator, &out_queryPool);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_queryPool;
}
pub const DestroyQueryPool = vkDestroyQueryPool;
pub inline fn GetQueryPoolResults(device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32, data: []u8, stride: DeviceSize, flags: QueryResultFlags) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkGetQueryPoolResults(device, queryPool, firstQuery, queryCount, @intCast(usize, data.len), data.ptr, stride, flags.toInt());
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn CreateBuffer(device: Device, createInfo: BufferCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_OPAQUE_CAPTURE_ADDRESS,VK_UNDOCUMENTED_ERROR}!Buffer {
var out_buffer: Buffer = undefined;
const result = vkCreateBuffer(device, &createInfo, pAllocator, &out_buffer);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => error.VK_INVALID_OPAQUE_CAPTURE_ADDRESS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_buffer;
}
pub const DestroyBuffer = vkDestroyBuffer;
pub inline fn CreateBufferView(device: Device, createInfo: BufferViewCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!BufferView {
var out_view: BufferView = undefined;
const result = vkCreateBufferView(device, &createInfo, pAllocator, &out_view);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_view;
}
pub const DestroyBufferView = vkDestroyBufferView;
pub inline fn CreateImage(device: Device, createInfo: ImageCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!Image {
var out_image: Image = undefined;
const result = vkCreateImage(device, &createInfo, pAllocator, &out_image);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_image;
}
pub const DestroyImage = vkDestroyImage;
pub inline fn GetImageSubresourceLayout(device: Device, image: Image, subresource: ImageSubresource) SubresourceLayout {
var out_layout: SubresourceLayout = undefined;
vkGetImageSubresourceLayout(device, image, &subresource, &out_layout);
return out_layout;
}
pub inline fn CreateImageView(device: Device, createInfo: ImageViewCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!ImageView {
var out_view: ImageView = undefined;
const result = vkCreateImageView(device, &createInfo, pAllocator, &out_view);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_view;
}
pub const DestroyImageView = vkDestroyImageView;
pub inline fn CreateShaderModule(device: Device, createInfo: ShaderModuleCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_SHADER_NV,VK_UNDOCUMENTED_ERROR}!ShaderModule {
var out_shaderModule: ShaderModule = undefined;
const result = vkCreateShaderModule(device, &createInfo, pAllocator, &out_shaderModule);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_SHADER_NV => error.VK_INVALID_SHADER_NV,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_shaderModule;
}
pub const DestroyShaderModule = vkDestroyShaderModule;
pub inline fn CreatePipelineCache(device: Device, createInfo: PipelineCacheCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!PipelineCache {
var out_pipelineCache: PipelineCache = undefined;
const result = vkCreatePipelineCache(device, &createInfo, pAllocator, &out_pipelineCache);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_pipelineCache;
}
pub const DestroyPipelineCache = vkDestroyPipelineCache;
pub const GetPipelineCacheDataResult = struct {
result: Result,
data: []u8,
};
pub inline fn GetPipelineCacheData(device: Device, pipelineCache: PipelineCache, data: []u8) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPipelineCacheDataResult {
var returnValues: GetPipelineCacheDataResult = undefined;
var dataSize: usize = @intCast(usize, data.len);
const result = vkGetPipelineCacheData(device, pipelineCache, &dataSize, data.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.data = data[0..dataSize];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPipelineCacheDataCount(device: Device, pipelineCache: PipelineCache) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!usize {
var out_dataSize: usize = undefined;
const result = vkGetPipelineCacheData(device, pipelineCache, &out_dataSize, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_dataSize;
}
pub inline fn MergePipelineCaches(device: Device, dstCache: PipelineCache, srcCaches: []const PipelineCache) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkMergePipelineCaches(device, dstCache, @intCast(u32, srcCaches.len), srcCaches.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CreateGraphicsPipelines(device: Device, pipelineCache: ?PipelineCache, createInfos: []const GraphicsPipelineCreateInfo, pAllocator: ?*const AllocationCallbacks, pipelines: []Pipeline) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_SHADER_NV,VK_UNDOCUMENTED_ERROR}!void {
assert(pipelines.len >= createInfos.len);
const result = vkCreateGraphicsPipelines(device, pipelineCache, @intCast(u32, createInfos.len), createInfos.ptr, pAllocator, pipelines.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_SHADER_NV => error.VK_INVALID_SHADER_NV,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CreateComputePipelines(device: Device, pipelineCache: ?PipelineCache, createInfos: []const ComputePipelineCreateInfo, pAllocator: ?*const AllocationCallbacks, pipelines: []Pipeline) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_SHADER_NV,VK_UNDOCUMENTED_ERROR}!void {
assert(pipelines.len >= createInfos.len);
const result = vkCreateComputePipelines(device, pipelineCache, @intCast(u32, createInfos.len), createInfos.ptr, pAllocator, pipelines.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_SHADER_NV => error.VK_INVALID_SHADER_NV,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const DestroyPipeline = vkDestroyPipeline;
pub inline fn CreatePipelineLayout(device: Device, createInfo: PipelineLayoutCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!PipelineLayout {
var out_pipelineLayout: PipelineLayout = undefined;
const result = vkCreatePipelineLayout(device, &createInfo, pAllocator, &out_pipelineLayout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_pipelineLayout;
}
pub const DestroyPipelineLayout = vkDestroyPipelineLayout;
pub inline fn CreateSampler(device: Device, createInfo: SamplerCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_TOO_MANY_OBJECTS,VK_UNDOCUMENTED_ERROR}!Sampler {
var out_sampler: Sampler = undefined;
const result = vkCreateSampler(device, &createInfo, pAllocator, &out_sampler);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_sampler;
}
pub const DestroySampler = vkDestroySampler;
pub inline fn CreateDescriptorSetLayout(device: Device, createInfo: DescriptorSetLayoutCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DescriptorSetLayout {
var out_setLayout: DescriptorSetLayout = undefined;
const result = vkCreateDescriptorSetLayout(device, &createInfo, pAllocator, &out_setLayout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_setLayout;
}
pub const DestroyDescriptorSetLayout = vkDestroyDescriptorSetLayout;
pub inline fn CreateDescriptorPool(device: Device, createInfo: DescriptorPoolCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FRAGMENTATION,VK_UNDOCUMENTED_ERROR}!DescriptorPool {
var out_descriptorPool: DescriptorPool = undefined;
const result = vkCreateDescriptorPool(device, &createInfo, pAllocator, &out_descriptorPool);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FRAGMENTATION => error.VK_FRAGMENTATION,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_descriptorPool;
}
pub const DestroyDescriptorPool = vkDestroyDescriptorPool;
pub inline fn ResetDescriptorPool(device: Device, descriptorPool: DescriptorPool, flags: DescriptorPoolResetFlags) error{VK_UNDOCUMENTED_ERROR}!void {
const result = vkResetDescriptorPool(device, descriptorPool, flags.toInt());
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
}
pub inline fn AllocateDescriptorSets(device: Device, allocateInfo: DescriptorSetAllocateInfo, descriptorSets: []DescriptorSet) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FRAGMENTED_POOL,VK_OUT_OF_POOL_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
assert(descriptorSets.len >= allocateInfo.descriptorSetCount);
const result = vkAllocateDescriptorSets(device, &allocateInfo, descriptorSets.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FRAGMENTED_POOL => error.VK_FRAGMENTED_POOL,
.ERROR_OUT_OF_POOL_MEMORY => error.VK_OUT_OF_POOL_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn FreeDescriptorSets(device: Device, descriptorPool: DescriptorPool, descriptorSets: []const DescriptorSet) error{VK_UNDOCUMENTED_ERROR}!void {
const result = vkFreeDescriptorSets(device, descriptorPool, @intCast(u32, descriptorSets.len), descriptorSets.ptr);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
}
pub inline fn UpdateDescriptorSets(device: Device, descriptorWrites: []const WriteDescriptorSet, descriptorCopies: []const CopyDescriptorSet) void {
vkUpdateDescriptorSets(device, @intCast(u32, descriptorWrites.len), descriptorWrites.ptr, @intCast(u32, descriptorCopies.len), descriptorCopies.ptr);
}
pub inline fn CreateFramebuffer(device: Device, createInfo: FramebufferCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!Framebuffer {
var out_framebuffer: Framebuffer = undefined;
const result = vkCreateFramebuffer(device, &createInfo, pAllocator, &out_framebuffer);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_framebuffer;
}
pub const DestroyFramebuffer = vkDestroyFramebuffer;
pub inline fn CreateRenderPass(device: Device, createInfo: RenderPassCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!RenderPass {
var out_renderPass: RenderPass = undefined;
const result = vkCreateRenderPass(device, &createInfo, pAllocator, &out_renderPass);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_renderPass;
}
pub const DestroyRenderPass = vkDestroyRenderPass;
pub inline fn GetRenderAreaGranularity(device: Device, renderPass: RenderPass) Extent2D {
var out_granularity: Extent2D = undefined;
vkGetRenderAreaGranularity(device, renderPass, &out_granularity);
return out_granularity;
}
pub inline fn CreateCommandPool(device: Device, createInfo: CommandPoolCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!CommandPool {
var out_commandPool: CommandPool = undefined;
const result = vkCreateCommandPool(device, &createInfo, pAllocator, &out_commandPool);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_commandPool;
}
pub const DestroyCommandPool = vkDestroyCommandPool;
pub inline fn ResetCommandPool(device: Device, commandPool: CommandPool, flags: CommandPoolResetFlags) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkResetCommandPool(device, commandPool, flags.toInt());
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn AllocateCommandBuffers(device: Device, allocateInfo: CommandBufferAllocateInfo, commandBuffers: []CommandBuffer) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
assert(commandBuffers.len >= allocateInfo.commandBufferCount);
const result = vkAllocateCommandBuffers(device, &allocateInfo, commandBuffers.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn FreeCommandBuffers(device: Device, commandPool: CommandPool, commandBuffers: []const CommandBuffer) void {
vkFreeCommandBuffers(device, commandPool, @intCast(u32, commandBuffers.len), commandBuffers.ptr);
}
pub inline fn BeginCommandBuffer(commandBuffer: CommandBuffer, beginInfo: CommandBufferBeginInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBeginCommandBuffer(commandBuffer, &beginInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn EndCommandBuffer(commandBuffer: CommandBuffer) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkEndCommandBuffer(commandBuffer);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn ResetCommandBuffer(commandBuffer: CommandBuffer, flags: CommandBufferResetFlags) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkResetCommandBuffer(commandBuffer, flags.toInt());
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const CmdBindPipeline = vkCmdBindPipeline;
pub inline fn CmdSetViewport(commandBuffer: CommandBuffer, firstViewport: u32, viewports: []const Viewport) void {
vkCmdSetViewport(commandBuffer, firstViewport, @intCast(u32, viewports.len), viewports.ptr);
}
pub inline fn CmdSetScissor(commandBuffer: CommandBuffer, firstScissor: u32, scissors: []const Rect2D) void {
vkCmdSetScissor(commandBuffer, firstScissor, @intCast(u32, scissors.len), scissors.ptr);
}
pub const CmdSetLineWidth = vkCmdSetLineWidth;
pub const CmdSetDepthBias = vkCmdSetDepthBias;
pub inline fn CmdSetBlendConstants(commandBuffer: CommandBuffer, blendConstants: [4]f32) void {
vkCmdSetBlendConstants(commandBuffer, &blendConstants);
}
pub const CmdSetDepthBounds = vkCmdSetDepthBounds;
pub inline fn CmdSetStencilCompareMask(commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, compareMask: u32) void {
vkCmdSetStencilCompareMask(commandBuffer, faceMask.toInt(), compareMask);
}
pub inline fn CmdSetStencilWriteMask(commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, writeMask: u32) void {
vkCmdSetStencilWriteMask(commandBuffer, faceMask.toInt(), writeMask);
}
pub inline fn CmdSetStencilReference(commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, reference: u32) void {
vkCmdSetStencilReference(commandBuffer, faceMask.toInt(), reference);
}
pub inline fn CmdBindDescriptorSets(commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, firstSet: u32, descriptorSets: []const DescriptorSet, dynamicOffsets: []const u32) void {
vkCmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, @intCast(u32, descriptorSets.len), descriptorSets.ptr, @intCast(u32, dynamicOffsets.len), dynamicOffsets.ptr);
}
pub const CmdBindIndexBuffer = vkCmdBindIndexBuffer;
pub inline fn CmdBindVertexBuffers(commandBuffer: CommandBuffer, firstBinding: u32, buffers: []const Buffer, offsets: []const DeviceSize) void {
assert(offsets.len >= buffers.len);
vkCmdBindVertexBuffers(commandBuffer, firstBinding, @intCast(u32, buffers.len), buffers.ptr, offsets.ptr);
}
pub const CmdDraw = vkCmdDraw;
pub const CmdDrawIndexed = vkCmdDrawIndexed;
pub const CmdDrawIndirect = vkCmdDrawIndirect;
pub const CmdDrawIndexedIndirect = vkCmdDrawIndexedIndirect;
pub const CmdDispatch = vkCmdDispatch;
pub const CmdDispatchIndirect = vkCmdDispatchIndirect;
pub inline fn CmdCopyBuffer(commandBuffer: CommandBuffer, srcBuffer: Buffer, dstBuffer: Buffer, regions: []const BufferCopy) void {
vkCmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, @intCast(u32, regions.len), regions.ptr);
}
pub inline fn CmdCopyImage(commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regions: []const ImageCopy) void {
vkCmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, @intCast(u32, regions.len), regions.ptr);
}
pub inline fn CmdBlitImage(commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regions: []const ImageBlit, filter: Filter) void {
vkCmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, @intCast(u32, regions.len), regions.ptr, filter);
}
pub inline fn CmdCopyBufferToImage(commandBuffer: CommandBuffer, srcBuffer: Buffer, dstImage: Image, dstImageLayout: ImageLayout, regions: []const BufferImageCopy) void {
vkCmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, @intCast(u32, regions.len), regions.ptr);
}
pub inline fn CmdCopyImageToBuffer(commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstBuffer: Buffer, regions: []const BufferImageCopy) void {
vkCmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, @intCast(u32, regions.len), regions.ptr);
}
pub inline fn CmdUpdateBuffer(commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, data: []const u8) void {
vkCmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, @intCast(DeviceSize, data.len), data.ptr);
}
pub const CmdFillBuffer = vkCmdFillBuffer;
pub inline fn CmdClearColorImage(commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, color: ClearColorValue, ranges: []const ImageSubresourceRange) void {
vkCmdClearColorImage(commandBuffer, image, imageLayout, &color, @intCast(u32, ranges.len), ranges.ptr);
}
pub inline fn CmdClearDepthStencilImage(commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, depthStencil: ClearDepthStencilValue, ranges: []const ImageSubresourceRange) void {
vkCmdClearDepthStencilImage(commandBuffer, image, imageLayout, &depthStencil, @intCast(u32, ranges.len), ranges.ptr);
}
pub inline fn CmdClearAttachments(commandBuffer: CommandBuffer, attachments: []const ClearAttachment, rects: []const ClearRect) void {
vkCmdClearAttachments(commandBuffer, @intCast(u32, attachments.len), attachments.ptr, @intCast(u32, rects.len), rects.ptr);
}
pub inline fn CmdResolveImage(commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regions: []const ImageResolve) void {
vkCmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, @intCast(u32, regions.len), regions.ptr);
}
pub inline fn CmdSetEvent(commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) void {
vkCmdSetEvent(commandBuffer, event, stageMask.toInt());
}
pub inline fn CmdResetEvent(commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) void {
vkCmdResetEvent(commandBuffer, event, stageMask.toInt());
}
pub inline fn CmdWaitEvents(commandBuffer: CommandBuffer, events: []const Event, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, memoryBarriers: []const MemoryBarrier, bufferMemoryBarriers: []const BufferMemoryBarrier, imageMemoryBarriers: []const ImageMemoryBarrier) void {
vkCmdWaitEvents(commandBuffer, @intCast(u32, events.len), events.ptr, srcStageMask.toInt(), dstStageMask.toInt(), @intCast(u32, memoryBarriers.len), memoryBarriers.ptr, @intCast(u32, bufferMemoryBarriers.len), bufferMemoryBarriers.ptr, @intCast(u32, imageMemoryBarriers.len), imageMemoryBarriers.ptr);
}
pub inline fn CmdPipelineBarrier(commandBuffer: CommandBuffer, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, dependencyFlags: DependencyFlags, memoryBarriers: []const MemoryBarrier, bufferMemoryBarriers: []const BufferMemoryBarrier, imageMemoryBarriers: []const ImageMemoryBarrier) void {
vkCmdPipelineBarrier(commandBuffer, srcStageMask.toInt(), dstStageMask.toInt(), dependencyFlags.toInt(), @intCast(u32, memoryBarriers.len), memoryBarriers.ptr, @intCast(u32, bufferMemoryBarriers.len), bufferMemoryBarriers.ptr, @intCast(u32, imageMemoryBarriers.len), imageMemoryBarriers.ptr);
}
pub inline fn CmdBeginQuery(commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags) void {
vkCmdBeginQuery(commandBuffer, queryPool, query, flags.toInt());
}
pub const CmdEndQuery = vkCmdEndQuery;
pub const CmdResetQueryPool = vkCmdResetQueryPool;
pub inline fn CmdWriteTimestamp(commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, queryPool: QueryPool, query: u32) void {
vkCmdWriteTimestamp(commandBuffer, pipelineStage.toInt(), queryPool, query);
}
pub inline fn CmdCopyQueryPoolResults(commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dstBuffer: Buffer, dstOffset: DeviceSize, stride: DeviceSize, flags: QueryResultFlags) void {
vkCmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags.toInt());
}
pub inline fn CmdPushConstants(commandBuffer: CommandBuffer, layout: PipelineLayout, stageFlags: ShaderStageFlags, offset: u32, values: []const u8) void {
vkCmdPushConstants(commandBuffer, layout, stageFlags.toInt(), offset, @intCast(u32, values.len), values.ptr);
}
pub inline fn CmdBeginRenderPass(commandBuffer: CommandBuffer, renderPassBegin: RenderPassBeginInfo, contents: SubpassContents) void {
vkCmdBeginRenderPass(commandBuffer, &renderPassBegin, contents);
}
pub const CmdNextSubpass = vkCmdNextSubpass;
pub const CmdEndRenderPass = vkCmdEndRenderPass;
pub inline fn CmdExecuteCommands(commandBuffer: CommandBuffer, commandBuffers: []const CommandBuffer) void {
vkCmdExecuteCommands(commandBuffer, @intCast(u32, commandBuffers.len), commandBuffers.ptr);
}
pub const VERSION_1_1 = 1;
// Vulkan 1.1 version number
pub const API_VERSION_1_1 = MAKE_VERSION(1, 1, 0);// Patch version should always be set to 0
pub const SamplerYcbcrConversion = *@OpaqueType();
pub const DescriptorUpdateTemplate = *@OpaqueType();
pub const MAX_DEVICE_GROUP_SIZE = 32;
pub const LUID_SIZE = 8;
pub const QUEUE_FAMILY_EXTERNAL = (~@as(u32, 0)-1);
pub const PointClippingBehavior = extern enum(i32) {
ALL_CLIP_PLANES = 0,
USER_CLIP_PLANES_ONLY = 1,
_,
const Self = @This();
pub const ALL_CLIP_PLANES_KHR = Self.ALL_CLIP_PLANES;
pub const USER_CLIP_PLANES_ONLY_KHR = Self.USER_CLIP_PLANES_ONLY;
};
pub const TessellationDomainOrigin = extern enum(i32) {
UPPER_LEFT = 0,
LOWER_LEFT = 1,
_,
const Self = @This();
pub const UPPER_LEFT_KHR = Self.UPPER_LEFT;
pub const LOWER_LEFT_KHR = Self.LOWER_LEFT;
};
pub const SamplerYcbcrModelConversion = extern enum(i32) {
RGB_IDENTITY = 0,
YCBCR_IDENTITY = 1,
YCBCR_709 = 2,
YCBCR_601 = 3,
YCBCR_2020 = 4,
_,
const Self = @This();
pub const RGB_IDENTITY_KHR = Self.RGB_IDENTITY;
pub const YCBCR_IDENTITY_KHR = Self.YCBCR_IDENTITY;
pub const YCBCR_709_KHR = Self.YCBCR_709;
pub const YCBCR_601_KHR = Self.YCBCR_601;
pub const YCBCR_2020_KHR = Self.YCBCR_2020;
};
pub const SamplerYcbcrRange = extern enum(i32) {
ITU_FULL = 0,
ITU_NARROW = 1,
_,
const Self = @This();
pub const ITU_FULL_KHR = Self.ITU_FULL;
pub const ITU_NARROW_KHR = Self.ITU_NARROW;
};
pub const ChromaLocation = extern enum(i32) {
COSITED_EVEN = 0,
MIDPOINT = 1,
_,
const Self = @This();
pub const COSITED_EVEN_KHR = Self.COSITED_EVEN;
pub const MIDPOINT_KHR = Self.MIDPOINT;
};
pub const DescriptorUpdateTemplateType = extern enum(i32) {
DESCRIPTOR_SET = 0,
PUSH_DESCRIPTORS_KHR = 1,
_,
const Self = @This();
pub const DESCRIPTOR_SET_KHR = Self.DESCRIPTOR_SET;
};
pub const SubgroupFeatureFlags = packed struct {
basic: bool = false,
vote: bool = false,
arithmetic: bool = false,
ballot: bool = false,
shuffle: bool = false,
shuffleRelative: bool = false,
clustered: bool = false,
quad: bool = false,
partitionedNV: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PeerMemoryFeatureFlags = packed struct {
copySrc: bool = false,
copyDst: bool = false,
genericSrc: bool = false,
genericDst: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const copySrcKHR = Self{ .copySrc = true };
pub const copyDstKHR = Self{ .copyDst = true };
pub const genericSrcKHR = Self{ .genericSrc = true };
pub const genericDstKHR = Self{ .genericDst = true };
pub usingnamespace FlagsMixin(Self);
};
pub const MemoryAllocateFlags = packed struct {
deviceMask: bool = false,
deviceAddress: bool = false,
deviceAddressCaptureReplay: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const deviceMaskKHR = Self{ .deviceMask = true };
pub const deviceAddressKHR = Self{ .deviceAddress = true };
pub const deviceAddressCaptureReplayKHR = Self{ .deviceAddressCaptureReplay = true };
pub usingnamespace FlagsMixin(Self);
};
pub const CommandPoolTrimFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DescriptorUpdateTemplateCreateFlags = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ExternalMemoryHandleTypeFlags = packed struct {
opaqueFd: bool = false,
opaqueWin32: bool = false,
opaqueWin32Kmt: bool = false,
d3D11Texture: bool = false,
d3D11TextureKmt: bool = false,
d3D12Heap: bool = false,
d3D12Resource: bool = false,
hostAllocationEXT: bool = false,
hostMappedForeignMemoryEXT: bool = false,
dmaBufEXT: bool = false,
androidHardwareBufferANDROID: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const opaqueFdKHR = Self{ .opaqueFd = true };
pub const opaqueWin32KHR = Self{ .opaqueWin32 = true };
pub const opaqueWin32KmtKHR = Self{ .opaqueWin32Kmt = true };
pub const d3D11TextureKHR = Self{ .d3D11Texture = true };
pub const d3D11TextureKmtKHR = Self{ .d3D11TextureKmt = true };
pub const d3D12HeapKHR = Self{ .d3D12Heap = true };
pub const d3D12ResourceKHR = Self{ .d3D12Resource = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ExternalMemoryFeatureFlags = packed struct {
dedicatedOnly: bool = false,
exportable: bool = false,
importable: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const dedicatedOnlyKHR = Self{ .dedicatedOnly = true };
pub const exportableKHR = Self{ .exportable = true };
pub const importableKHR = Self{ .importable = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ExternalFenceHandleTypeFlags = packed struct {
opaqueFd: bool = false,
opaqueWin32: bool = false,
opaqueWin32Kmt: bool = false,
syncFd: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const opaqueFdKHR = Self{ .opaqueFd = true };
pub const opaqueWin32KHR = Self{ .opaqueWin32 = true };
pub const opaqueWin32KmtKHR = Self{ .opaqueWin32Kmt = true };
pub const syncFdKHR = Self{ .syncFd = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ExternalFenceFeatureFlags = packed struct {
exportable: bool = false,
importable: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const exportableKHR = Self{ .exportable = true };
pub const importableKHR = Self{ .importable = true };
pub usingnamespace FlagsMixin(Self);
};
pub const FenceImportFlags = packed struct {
temporary: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const temporaryKHR = Self{ .temporary = true };
pub usingnamespace FlagsMixin(Self);
};
pub const SemaphoreImportFlags = packed struct {
temporary: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const temporaryKHR = Self{ .temporary = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ExternalSemaphoreHandleTypeFlags = packed struct {
opaqueFd: bool = false,
opaqueWin32: bool = false,
opaqueWin32Kmt: bool = false,
d3D12Fence: bool = false,
syncFd: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const opaqueFdKHR = Self{ .opaqueFd = true };
pub const opaqueWin32KHR = Self{ .opaqueWin32 = true };
pub const opaqueWin32KmtKHR = Self{ .opaqueWin32Kmt = true };
pub const d3D12FenceKHR = Self{ .d3D12Fence = true };
pub const syncFdKHR = Self{ .syncFd = true };
pub usingnamespace FlagsMixin(Self);
};
pub const ExternalSemaphoreFeatureFlags = packed struct {
exportable: bool = false,
importable: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const exportableKHR = Self{ .exportable = true };
pub const importableKHR = Self{ .importable = true };
pub usingnamespace FlagsMixin(Self);
};
pub const PhysicalDeviceSubgroupProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SUBGROUP_PROPERTIES,
pNext: ?*c_void = null,
subgroupSize: u32,
supportedStages: ShaderStageFlags align(4),
supportedOperations: SubgroupFeatureFlags align(4),
quadOperationsInAllStages: Bool32,
};
pub const BindBufferMemoryInfo = extern struct {
sType: StructureType = .BIND_BUFFER_MEMORY_INFO,
pNext: ?*const c_void = null,
buffer: Buffer,
memory: DeviceMemory,
memoryOffset: DeviceSize,
};
pub const BindImageMemoryInfo = extern struct {
sType: StructureType = .BIND_IMAGE_MEMORY_INFO,
pNext: ?*const c_void = null,
image: Image,
memory: DeviceMemory,
memoryOffset: DeviceSize,
};
pub const PhysicalDevice16BitStorageFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES,
pNext: ?*c_void = null,
storageBuffer16BitAccess: Bool32,
uniformAndStorageBuffer16BitAccess: Bool32,
storagePushConstant16: Bool32,
storageInputOutput16: Bool32,
};
pub const MemoryDedicatedRequirements = extern struct {
sType: StructureType = .MEMORY_DEDICATED_REQUIREMENTS,
pNext: ?*c_void = null,
prefersDedicatedAllocation: Bool32,
requiresDedicatedAllocation: Bool32,
};
pub const MemoryDedicatedAllocateInfo = extern struct {
sType: StructureType = .MEMORY_DEDICATED_ALLOCATE_INFO,
pNext: ?*const c_void = null,
image: ?Image = null,
buffer: ?Buffer = null,
};
pub const MemoryAllocateFlagsInfo = extern struct {
sType: StructureType = .MEMORY_ALLOCATE_FLAGS_INFO,
pNext: ?*const c_void = null,
flags: MemoryAllocateFlags align(4) = MemoryAllocateFlags{},
deviceMask: u32,
};
pub const DeviceGroupRenderPassBeginInfo = extern struct {
sType: StructureType = .DEVICE_GROUP_RENDER_PASS_BEGIN_INFO,
pNext: ?*const c_void = null,
deviceMask: u32,
deviceRenderAreaCount: u32 = 0,
pDeviceRenderAreas: [*]const Rect2D = undefined,
};
pub const DeviceGroupCommandBufferBeginInfo = extern struct {
sType: StructureType = .DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO,
pNext: ?*const c_void = null,
deviceMask: u32,
};
pub const DeviceGroupSubmitInfo = extern struct {
sType: StructureType = .DEVICE_GROUP_SUBMIT_INFO,
pNext: ?*const c_void = null,
waitSemaphoreCount: u32 = 0,
pWaitSemaphoreDeviceIndices: [*]const u32 = undefined,
commandBufferCount: u32 = 0,
pCommandBufferDeviceMasks: [*]const u32 = undefined,
signalSemaphoreCount: u32 = 0,
pSignalSemaphoreDeviceIndices: [*]const u32 = undefined,
};
pub const DeviceGroupBindSparseInfo = extern struct {
sType: StructureType = .DEVICE_GROUP_BIND_SPARSE_INFO,
pNext: ?*const c_void = null,
resourceDeviceIndex: u32,
memoryDeviceIndex: u32,
};
pub const BindBufferMemoryDeviceGroupInfo = extern struct {
sType: StructureType = .BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO,
pNext: ?*const c_void = null,
deviceIndexCount: u32 = 0,
pDeviceIndices: [*]const u32 = undefined,
};
pub const BindImageMemoryDeviceGroupInfo = extern struct {
sType: StructureType = .BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO,
pNext: ?*const c_void = null,
deviceIndexCount: u32 = 0,
pDeviceIndices: [*]const u32 = undefined,
splitInstanceBindRegionCount: u32 = 0,
pSplitInstanceBindRegions: [*]const Rect2D = undefined,
};
pub const PhysicalDeviceGroupProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_GROUP_PROPERTIES,
pNext: ?*c_void = null,
physicalDeviceCount: u32,
physicalDevices: [MAX_DEVICE_GROUP_SIZE]PhysicalDevice,
subsetAllocation: Bool32,
};
pub const DeviceGroupDeviceCreateInfo = extern struct {
sType: StructureType = .DEVICE_GROUP_DEVICE_CREATE_INFO,
pNext: ?*const c_void = null,
physicalDeviceCount: u32 = 0,
pPhysicalDevices: [*]const PhysicalDevice = undefined,
};
pub const BufferMemoryRequirementsInfo2 = extern struct {
sType: StructureType = .BUFFER_MEMORY_REQUIREMENTS_INFO_2,
pNext: ?*const c_void = null,
buffer: Buffer,
};
pub const ImageMemoryRequirementsInfo2 = extern struct {
sType: StructureType = .IMAGE_MEMORY_REQUIREMENTS_INFO_2,
pNext: ?*const c_void = null,
image: Image,
};
pub const ImageSparseMemoryRequirementsInfo2 = extern struct {
sType: StructureType = .IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2,
pNext: ?*const c_void = null,
image: Image,
};
pub const MemoryRequirements2 = extern struct {
sType: StructureType = .MEMORY_REQUIREMENTS_2,
pNext: ?*c_void = null,
memoryRequirements: MemoryRequirements,
};
pub const MemoryRequirements2KHR = MemoryRequirements2;
pub const SparseImageMemoryRequirements2 = extern struct {
sType: StructureType = .SPARSE_IMAGE_MEMORY_REQUIREMENTS_2,
pNext: ?*c_void = null,
memoryRequirements: SparseImageMemoryRequirements,
};
pub const PhysicalDeviceFeatures2 = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FEATURES_2,
pNext: ?*c_void = null,
features: PhysicalDeviceFeatures,
};
pub const PhysicalDeviceProperties2 = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PROPERTIES_2,
pNext: ?*c_void = null,
properties: PhysicalDeviceProperties,
};
pub const FormatProperties2 = extern struct {
sType: StructureType = .FORMAT_PROPERTIES_2,
pNext: ?*c_void = null,
formatProperties: FormatProperties,
};
pub const ImageFormatProperties2 = extern struct {
sType: StructureType = .IMAGE_FORMAT_PROPERTIES_2,
pNext: ?*c_void = null,
imageFormatProperties: ImageFormatProperties,
};
pub const PhysicalDeviceImageFormatInfo2 = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
pNext: ?*const c_void = null,
format: Format,
inType: ImageType,
tiling: ImageTiling,
usage: ImageUsageFlags align(4),
flags: ImageCreateFlags align(4) = ImageCreateFlags{},
};
pub const QueueFamilyProperties2 = extern struct {
sType: StructureType = .QUEUE_FAMILY_PROPERTIES_2,
pNext: ?*c_void = null,
queueFamilyProperties: QueueFamilyProperties,
};
pub const PhysicalDeviceMemoryProperties2 = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MEMORY_PROPERTIES_2,
pNext: ?*c_void = null,
memoryProperties: PhysicalDeviceMemoryProperties,
};
pub const SparseImageFormatProperties2 = extern struct {
sType: StructureType = .SPARSE_IMAGE_FORMAT_PROPERTIES_2,
pNext: ?*c_void = null,
properties: SparseImageFormatProperties,
};
pub const PhysicalDeviceSparseImageFormatInfo2 = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2,
pNext: ?*const c_void = null,
format: Format,
inType: ImageType,
samples: SampleCountFlags align(4),
usage: ImageUsageFlags align(4),
tiling: ImageTiling,
};
pub const PhysicalDevicePointClippingProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES,
pNext: ?*c_void = null,
pointClippingBehavior: PointClippingBehavior,
};
pub const InputAttachmentAspectReference = extern struct {
subpass: u32,
inputAttachmentIndex: u32,
aspectMask: ImageAspectFlags align(4),
};
pub const RenderPassInputAttachmentAspectCreateInfo = extern struct {
sType: StructureType = .RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO,
pNext: ?*const c_void = null,
aspectReferenceCount: u32,
pAspectReferences: [*]const InputAttachmentAspectReference,
};
pub const ImageViewUsageCreateInfo = extern struct {
sType: StructureType = .IMAGE_VIEW_USAGE_CREATE_INFO,
pNext: ?*const c_void = null,
usage: ImageUsageFlags align(4),
};
pub const PipelineTessellationDomainOriginStateCreateInfo = extern struct {
sType: StructureType = .PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO,
pNext: ?*const c_void = null,
domainOrigin: TessellationDomainOrigin,
};
pub const RenderPassMultiviewCreateInfo = extern struct {
sType: StructureType = .RENDER_PASS_MULTIVIEW_CREATE_INFO,
pNext: ?*const c_void = null,
subpassCount: u32 = 0,
pViewMasks: [*]const u32 = undefined,
dependencyCount: u32 = 0,
pViewOffsets: [*]const i32 = undefined,
correlationMaskCount: u32 = 0,
pCorrelationMasks: [*]const u32 = undefined,
};
pub const PhysicalDeviceMultiviewFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MULTIVIEW_FEATURES,
pNext: ?*c_void = null,
multiview: Bool32,
multiviewGeometryShader: Bool32,
multiviewTessellationShader: Bool32,
};
pub const PhysicalDeviceMultiviewProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,
pNext: ?*c_void = null,
maxMultiviewViewCount: u32,
maxMultiviewInstanceIndex: u32,
};
pub const PhysicalDeviceVariablePointersFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES,
pNext: ?*c_void = null,
variablePointersStorageBuffer: Bool32,
variablePointers: Bool32,
};
pub const PhysicalDeviceVariablePointerFeatures = PhysicalDeviceVariablePointersFeatures;
pub const PhysicalDeviceProtectedMemoryFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES,
pNext: ?*c_void = null,
protectedMemory: Bool32,
};
pub const PhysicalDeviceProtectedMemoryProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES,
pNext: ?*c_void = null,
protectedNoFault: Bool32,
};
pub const DeviceQueueInfo2 = extern struct {
sType: StructureType = .DEVICE_QUEUE_INFO_2,
pNext: ?*const c_void = null,
flags: DeviceQueueCreateFlags align(4) = DeviceQueueCreateFlags{},
queueFamilyIndex: u32,
queueIndex: u32,
};
pub const ProtectedSubmitInfo = extern struct {
sType: StructureType = .PROTECTED_SUBMIT_INFO,
pNext: ?*const c_void = null,
protectedSubmit: Bool32,
};
pub const SamplerYcbcrConversionCreateInfo = extern struct {
sType: StructureType = .SAMPLER_YCBCR_CONVERSION_CREATE_INFO,
pNext: ?*const c_void = null,
format: Format,
ycbcrModel: SamplerYcbcrModelConversion,
ycbcrRange: SamplerYcbcrRange,
components: ComponentMapping,
xChromaOffset: ChromaLocation,
yChromaOffset: ChromaLocation,
chromaFilter: Filter,
forceExplicitReconstruction: Bool32,
};
pub const SamplerYcbcrConversionInfo = extern struct {
sType: StructureType = .SAMPLER_YCBCR_CONVERSION_INFO,
pNext: ?*const c_void = null,
conversion: SamplerYcbcrConversion,
};
pub const BindImagePlaneMemoryInfo = extern struct {
sType: StructureType = .BIND_IMAGE_PLANE_MEMORY_INFO,
pNext: ?*const c_void = null,
planeAspect: ImageAspectFlags align(4),
};
pub const ImagePlaneMemoryRequirementsInfo = extern struct {
sType: StructureType = .IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO,
pNext: ?*const c_void = null,
planeAspect: ImageAspectFlags align(4),
};
pub const PhysicalDeviceSamplerYcbcrConversionFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES,
pNext: ?*c_void = null,
samplerYcbcrConversion: Bool32,
};
pub const SamplerYcbcrConversionImageFormatProperties = extern struct {
sType: StructureType = .SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES,
pNext: ?*c_void = null,
combinedImageSamplerDescriptorCount: u32,
};
pub const DescriptorUpdateTemplateEntry = extern struct {
dstBinding: u32,
dstArrayElement: u32,
descriptorCount: u32,
descriptorType: DescriptorType,
offset: usize,
stride: usize,
};
pub const DescriptorUpdateTemplateCreateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO,
pNext: ?*const c_void = null,
flags: DescriptorUpdateTemplateCreateFlags align(4) = DescriptorUpdateTemplateCreateFlags{},
descriptorUpdateEntryCount: u32,
pDescriptorUpdateEntries: [*]const DescriptorUpdateTemplateEntry,
templateType: DescriptorUpdateTemplateType,
descriptorSetLayout: DescriptorSetLayout,
pipelineBindPoint: PipelineBindPoint,
pipelineLayout: PipelineLayout,
set: u32,
};
pub const ExternalMemoryProperties = extern struct {
externalMemoryFeatures: ExternalMemoryFeatureFlags align(4),
exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlags align(4) = ExternalMemoryHandleTypeFlags{},
compatibleHandleTypes: ExternalMemoryHandleTypeFlags align(4),
};
pub const PhysicalDeviceExternalImageFormatInfo = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO,
pNext: ?*const c_void = null,
handleType: ExternalMemoryHandleTypeFlags align(4) = ExternalMemoryHandleTypeFlags{},
};
pub const ExternalImageFormatProperties = extern struct {
sType: StructureType = .EXTERNAL_IMAGE_FORMAT_PROPERTIES,
pNext: ?*c_void = null,
externalMemoryProperties: ExternalMemoryProperties,
};
pub const PhysicalDeviceExternalBufferInfo = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO,
pNext: ?*const c_void = null,
flags: BufferCreateFlags align(4) = BufferCreateFlags{},
usage: BufferUsageFlags align(4),
handleType: ExternalMemoryHandleTypeFlags align(4),
};
pub const ExternalBufferProperties = extern struct {
sType: StructureType = .EXTERNAL_BUFFER_PROPERTIES,
pNext: ?*c_void = null,
externalMemoryProperties: ExternalMemoryProperties,
};
pub const PhysicalDeviceIDProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_ID_PROPERTIES,
pNext: ?*c_void = null,
deviceUUID: [UUID_SIZE]u8,
driverUUID: [UUID_SIZE]u8,
deviceLUID: [LUID_SIZE]u8,
deviceNodeMask: u32,
deviceLUIDValid: Bool32,
};
pub const ExternalMemoryImageCreateInfo = extern struct {
sType: StructureType = .EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
pNext: ?*const c_void = null,
handleTypes: ExternalMemoryHandleTypeFlags align(4),
};
pub const ExternalMemoryBufferCreateInfo = extern struct {
sType: StructureType = .EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
pNext: ?*const c_void = null,
handleTypes: ExternalMemoryHandleTypeFlags align(4) = ExternalMemoryHandleTypeFlags{},
};
pub const ExportMemoryAllocateInfo = extern struct {
sType: StructureType = .EXPORT_MEMORY_ALLOCATE_INFO,
pNext: ?*const c_void = null,
handleTypes: ExternalMemoryHandleTypeFlags align(4) = ExternalMemoryHandleTypeFlags{},
};
pub const PhysicalDeviceExternalFenceInfo = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO,
pNext: ?*const c_void = null,
handleType: ExternalFenceHandleTypeFlags align(4),
};
pub const ExternalFenceProperties = extern struct {
sType: StructureType = .EXTERNAL_FENCE_PROPERTIES,
pNext: ?*c_void = null,
exportFromImportedHandleTypes: ExternalFenceHandleTypeFlags align(4),
compatibleHandleTypes: ExternalFenceHandleTypeFlags align(4),
externalFenceFeatures: ExternalFenceFeatureFlags align(4) = ExternalFenceFeatureFlags{},
};
pub const ExportFenceCreateInfo = extern struct {
sType: StructureType = .EXPORT_FENCE_CREATE_INFO,
pNext: ?*const c_void = null,
handleTypes: ExternalFenceHandleTypeFlags align(4) = ExternalFenceHandleTypeFlags{},
};
pub const ExportSemaphoreCreateInfo = extern struct {
sType: StructureType = .EXPORT_SEMAPHORE_CREATE_INFO,
pNext: ?*const c_void = null,
handleTypes: ExternalSemaphoreHandleTypeFlags align(4) = ExternalSemaphoreHandleTypeFlags{},
};
pub const PhysicalDeviceExternalSemaphoreInfo = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
pNext: ?*const c_void = null,
handleType: ExternalSemaphoreHandleTypeFlags align(4),
};
pub const ExternalSemaphoreProperties = extern struct {
sType: StructureType = .EXTERNAL_SEMAPHORE_PROPERTIES,
pNext: ?*c_void = null,
exportFromImportedHandleTypes: ExternalSemaphoreHandleTypeFlags align(4),
compatibleHandleTypes: ExternalSemaphoreHandleTypeFlags align(4),
externalSemaphoreFeatures: ExternalSemaphoreFeatureFlags align(4) = ExternalSemaphoreFeatureFlags{},
};
pub const PhysicalDeviceMaintenance3Properties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES,
pNext: ?*c_void = null,
maxPerSetDescriptors: u32,
maxMemoryAllocationSize: DeviceSize,
};
pub const DescriptorSetLayoutSupport = extern struct {
sType: StructureType = .DESCRIPTOR_SET_LAYOUT_SUPPORT,
pNext: ?*c_void = null,
supported: Bool32,
};
pub const PhysicalDeviceShaderDrawParametersFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES,
pNext: ?*c_void = null,
shaderDrawParameters: Bool32,
};
pub const PhysicalDeviceShaderDrawParameterFeatures = PhysicalDeviceShaderDrawParametersFeatures;
pub extern fn vkEnumerateInstanceVersion(pApiVersion: *u32) callconv(CallConv) Result;
pub extern fn vkBindBufferMemory2(
device: Device,
bindInfoCount: u32,
pBindInfos: [*]const BindBufferMemoryInfo,
) callconv(CallConv) Result;
pub extern fn vkBindImageMemory2(
device: Device,
bindInfoCount: u32,
pBindInfos: [*]const BindImageMemoryInfo,
) callconv(CallConv) Result;
pub extern fn vkGetDeviceGroupPeerMemoryFeatures(
device: Device,
heapIndex: u32,
localDeviceIndex: u32,
remoteDeviceIndex: u32,
pPeerMemoryFeatures: *align(4) PeerMemoryFeatureFlags,
) callconv(CallConv) void;
pub extern fn vkCmdSetDeviceMask(
commandBuffer: CommandBuffer,
deviceMask: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDispatchBase(
commandBuffer: CommandBuffer,
baseGroupX: u32,
baseGroupY: u32,
baseGroupZ: u32,
groupCountX: u32,
groupCountY: u32,
groupCountZ: u32,
) callconv(CallConv) void;
pub extern fn vkEnumeratePhysicalDeviceGroups(
instance: Instance,
pPhysicalDeviceGroupCount: *u32,
pPhysicalDeviceGroupProperties: ?[*]PhysicalDeviceGroupProperties,
) callconv(CallConv) Result;
pub extern fn vkGetImageMemoryRequirements2(
device: Device,
pInfo: *const ImageMemoryRequirementsInfo2,
pMemoryRequirements: *MemoryRequirements2,
) callconv(CallConv) void;
pub extern fn vkGetBufferMemoryRequirements2(
device: Device,
pInfo: *const BufferMemoryRequirementsInfo2,
pMemoryRequirements: *MemoryRequirements2,
) callconv(CallConv) void;
pub extern fn vkGetImageSparseMemoryRequirements2(
device: Device,
pInfo: *const ImageSparseMemoryRequirementsInfo2,
pSparseMemoryRequirementCount: *u32,
pSparseMemoryRequirements: ?[*]SparseImageMemoryRequirements2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceFeatures2(
physicalDevice: PhysicalDevice,
pFeatures: *PhysicalDeviceFeatures2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceProperties2(
physicalDevice: PhysicalDevice,
pProperties: *PhysicalDeviceProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceFormatProperties2(
physicalDevice: PhysicalDevice,
format: Format,
pFormatProperties: *FormatProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceImageFormatProperties2(
physicalDevice: PhysicalDevice,
pImageFormatInfo: *const PhysicalDeviceImageFormatInfo2,
pImageFormatProperties: *ImageFormatProperties2,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceQueueFamilyProperties2(
physicalDevice: PhysicalDevice,
pQueueFamilyPropertyCount: *u32,
pQueueFamilyProperties: ?[*]QueueFamilyProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceMemoryProperties2(
physicalDevice: PhysicalDevice,
pMemoryProperties: *PhysicalDeviceMemoryProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceSparseImageFormatProperties2(
physicalDevice: PhysicalDevice,
pFormatInfo: *const PhysicalDeviceSparseImageFormatInfo2,
pPropertyCount: *u32,
pProperties: ?[*]SparseImageFormatProperties2,
) callconv(CallConv) void;
pub extern fn vkTrimCommandPool(
device: Device,
commandPool: CommandPool,
flags: CommandPoolTrimFlags.IntType,
) callconv(CallConv) void;
pub extern fn vkGetDeviceQueue2(
device: Device,
pQueueInfo: *const DeviceQueueInfo2,
pQueue: *Queue,
) callconv(CallConv) void;
pub extern fn vkCreateSamplerYcbcrConversion(
device: Device,
pCreateInfo: *const SamplerYcbcrConversionCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pYcbcrConversion: *SamplerYcbcrConversion,
) callconv(CallConv) Result;
pub extern fn vkDestroySamplerYcbcrConversion(
device: Device,
ycbcrConversion: ?SamplerYcbcrConversion,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateDescriptorUpdateTemplate(
device: Device,
pCreateInfo: *const DescriptorUpdateTemplateCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pDescriptorUpdateTemplate: *DescriptorUpdateTemplate,
) callconv(CallConv) Result;
pub extern fn vkDestroyDescriptorUpdateTemplate(
device: Device,
descriptorUpdateTemplate: ?DescriptorUpdateTemplate,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkUpdateDescriptorSetWithTemplate(
device: Device,
descriptorSet: DescriptorSet,
descriptorUpdateTemplate: DescriptorUpdateTemplate,
pData: ?*const c_void,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceExternalBufferProperties(
physicalDevice: PhysicalDevice,
pExternalBufferInfo: *const PhysicalDeviceExternalBufferInfo,
pExternalBufferProperties: *ExternalBufferProperties,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceExternalFenceProperties(
physicalDevice: PhysicalDevice,
pExternalFenceInfo: *const PhysicalDeviceExternalFenceInfo,
pExternalFenceProperties: *ExternalFenceProperties,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceExternalSemaphoreProperties(
physicalDevice: PhysicalDevice,
pExternalSemaphoreInfo: *const PhysicalDeviceExternalSemaphoreInfo,
pExternalSemaphoreProperties: *ExternalSemaphoreProperties,
) callconv(CallConv) void;
pub extern fn vkGetDescriptorSetLayoutSupport(
device: Device,
pCreateInfo: *const DescriptorSetLayoutCreateInfo,
pSupport: *DescriptorSetLayoutSupport,
) callconv(CallConv) void;
pub inline fn EnumerateInstanceVersion() error{VK_UNDOCUMENTED_ERROR}!u32 {
var out_apiVersion: u32 = undefined;
const result = vkEnumerateInstanceVersion(&out_apiVersion);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
return out_apiVersion;
}
pub inline fn BindBufferMemory2(device: Device, bindInfos: []const BindBufferMemoryInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_OPAQUE_CAPTURE_ADDRESS,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindBufferMemory2(device, @intCast(u32, bindInfos.len), bindInfos.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => error.VK_INVALID_OPAQUE_CAPTURE_ADDRESS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn BindImageMemory2(device: Device, bindInfos: []const BindImageMemoryInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindImageMemory2(device, @intCast(u32, bindInfos.len), bindInfos.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetDeviceGroupPeerMemoryFeatures(device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32) PeerMemoryFeatureFlags {
var out_peerMemoryFeatures: PeerMemoryFeatureFlags align(4) = undefined;
vkGetDeviceGroupPeerMemoryFeatures(device, heapIndex, localDeviceIndex, remoteDeviceIndex, &out_peerMemoryFeatures);
return out_peerMemoryFeatures;
}
pub const CmdSetDeviceMask = vkCmdSetDeviceMask;
pub const CmdDispatchBase = vkCmdDispatchBase;
pub const EnumeratePhysicalDeviceGroupsResult = struct {
result: Result,
physicalDeviceGroupProperties: []PhysicalDeviceGroupProperties,
};
pub inline fn EnumeratePhysicalDeviceGroups(instance: Instance, physicalDeviceGroupProperties: []PhysicalDeviceGroupProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!EnumeratePhysicalDeviceGroupsResult {
var returnValues: EnumeratePhysicalDeviceGroupsResult = undefined;
var physicalDeviceGroupCount: u32 = @intCast(u32, physicalDeviceGroupProperties.len);
const result = vkEnumeratePhysicalDeviceGroups(instance, &physicalDeviceGroupCount, physicalDeviceGroupProperties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.physicalDeviceGroupProperties = physicalDeviceGroupProperties[0..physicalDeviceGroupCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumeratePhysicalDeviceGroupsCount(instance: Instance) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!u32 {
var out_physicalDeviceGroupCount: u32 = undefined;
const result = vkEnumeratePhysicalDeviceGroups(instance, &out_physicalDeviceGroupCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_physicalDeviceGroupCount;
}
pub inline fn GetImageMemoryRequirements2(device: Device, info: ImageMemoryRequirementsInfo2) MemoryRequirements2 {
var out_memoryRequirements: MemoryRequirements2 = undefined;
vkGetImageMemoryRequirements2(device, &info, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetBufferMemoryRequirements2(device: Device, info: BufferMemoryRequirementsInfo2) MemoryRequirements2 {
var out_memoryRequirements: MemoryRequirements2 = undefined;
vkGetBufferMemoryRequirements2(device, &info, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirements2(device: Device, info: ImageSparseMemoryRequirementsInfo2, sparseMemoryRequirements: []SparseImageMemoryRequirements2) []SparseImageMemoryRequirements2 {
var out_sparseMemoryRequirements: []SparseImageMemoryRequirements2 = undefined;
var sparseMemoryRequirementCount: u32 = @intCast(u32, sparseMemoryRequirements.len);
vkGetImageSparseMemoryRequirements2(device, &info, &sparseMemoryRequirementCount, sparseMemoryRequirements.ptr);
out_sparseMemoryRequirements = sparseMemoryRequirements[0..sparseMemoryRequirementCount];
return out_sparseMemoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirements2Count(device: Device, info: ImageSparseMemoryRequirementsInfo2) u32 {
var out_sparseMemoryRequirementCount: u32 = undefined;
vkGetImageSparseMemoryRequirements2(device, &info, &out_sparseMemoryRequirementCount, null);
return out_sparseMemoryRequirementCount;
}
pub inline fn GetPhysicalDeviceFeatures2(physicalDevice: PhysicalDevice) PhysicalDeviceFeatures2 {
var out_features: PhysicalDeviceFeatures2 = undefined;
vkGetPhysicalDeviceFeatures2(physicalDevice, &out_features);
return out_features;
}
pub inline fn GetPhysicalDeviceProperties2(physicalDevice: PhysicalDevice) PhysicalDeviceProperties2 {
var out_properties: PhysicalDeviceProperties2 = undefined;
vkGetPhysicalDeviceProperties2(physicalDevice, &out_properties);
return out_properties;
}
pub inline fn GetPhysicalDeviceFormatProperties2(physicalDevice: PhysicalDevice, format: Format) FormatProperties2 {
var out_formatProperties: FormatProperties2 = undefined;
vkGetPhysicalDeviceFormatProperties2(physicalDevice, format, &out_formatProperties);
return out_formatProperties;
}
pub inline fn GetPhysicalDeviceImageFormatProperties2(physicalDevice: PhysicalDevice, imageFormatInfo: PhysicalDeviceImageFormatInfo2) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FORMAT_NOT_SUPPORTED,VK_UNDOCUMENTED_ERROR}!ImageFormatProperties2 {
var out_imageFormatProperties: ImageFormatProperties2 = undefined;
const result = vkGetPhysicalDeviceImageFormatProperties2(physicalDevice, &imageFormatInfo, &out_imageFormatProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FORMAT_NOT_SUPPORTED => error.VK_FORMAT_NOT_SUPPORTED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_imageFormatProperties;
}
pub inline fn GetPhysicalDeviceQueueFamilyProperties2(physicalDevice: PhysicalDevice, queueFamilyProperties: []QueueFamilyProperties2) []QueueFamilyProperties2 {
var out_queueFamilyProperties: []QueueFamilyProperties2 = undefined;
var queueFamilyPropertyCount: u32 = @intCast(u32, queueFamilyProperties.len);
vkGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, &queueFamilyPropertyCount, queueFamilyProperties.ptr);
out_queueFamilyProperties = queueFamilyProperties[0..queueFamilyPropertyCount];
return out_queueFamilyProperties;
}
pub inline fn GetPhysicalDeviceQueueFamilyProperties2Count(physicalDevice: PhysicalDevice) u32 {
var out_queueFamilyPropertyCount: u32 = undefined;
vkGetPhysicalDeviceQueueFamilyProperties2(physicalDevice, &out_queueFamilyPropertyCount, null);
return out_queueFamilyPropertyCount;
}
pub inline fn GetPhysicalDeviceMemoryProperties2(physicalDevice: PhysicalDevice) PhysicalDeviceMemoryProperties2 {
var out_memoryProperties: PhysicalDeviceMemoryProperties2 = undefined;
vkGetPhysicalDeviceMemoryProperties2(physicalDevice, &out_memoryProperties);
return out_memoryProperties;
}
pub inline fn GetPhysicalDeviceSparseImageFormatProperties2(physicalDevice: PhysicalDevice, formatInfo: PhysicalDeviceSparseImageFormatInfo2, properties: []SparseImageFormatProperties2) []SparseImageFormatProperties2 {
var out_properties: []SparseImageFormatProperties2 = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
vkGetPhysicalDeviceSparseImageFormatProperties2(physicalDevice, &formatInfo, &propertyCount, properties.ptr);
out_properties = properties[0..propertyCount];
return out_properties;
}
pub inline fn GetPhysicalDeviceSparseImageFormatProperties2Count(physicalDevice: PhysicalDevice, formatInfo: PhysicalDeviceSparseImageFormatInfo2) u32 {
var out_propertyCount: u32 = undefined;
vkGetPhysicalDeviceSparseImageFormatProperties2(physicalDevice, &formatInfo, &out_propertyCount, null);
return out_propertyCount;
}
pub inline fn TrimCommandPool(device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) void {
vkTrimCommandPool(device, commandPool, flags.toInt());
}
pub inline fn GetDeviceQueue2(device: Device, queueInfo: DeviceQueueInfo2) Queue {
var out_queue: Queue = undefined;
vkGetDeviceQueue2(device, &queueInfo, &out_queue);
return out_queue;
}
pub inline fn CreateSamplerYcbcrConversion(device: Device, createInfo: SamplerYcbcrConversionCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!SamplerYcbcrConversion {
var out_ycbcrConversion: SamplerYcbcrConversion = undefined;
const result = vkCreateSamplerYcbcrConversion(device, &createInfo, pAllocator, &out_ycbcrConversion);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_ycbcrConversion;
}
pub const DestroySamplerYcbcrConversion = vkDestroySamplerYcbcrConversion;
pub inline fn CreateDescriptorUpdateTemplate(device: Device, createInfo: DescriptorUpdateTemplateCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DescriptorUpdateTemplate {
var out_descriptorUpdateTemplate: DescriptorUpdateTemplate = undefined;
const result = vkCreateDescriptorUpdateTemplate(device, &createInfo, pAllocator, &out_descriptorUpdateTemplate);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_descriptorUpdateTemplate;
}
pub const DestroyDescriptorUpdateTemplate = vkDestroyDescriptorUpdateTemplate;
pub const UpdateDescriptorSetWithTemplate = vkUpdateDescriptorSetWithTemplate;
pub inline fn GetPhysicalDeviceExternalBufferProperties(physicalDevice: PhysicalDevice, externalBufferInfo: PhysicalDeviceExternalBufferInfo) ExternalBufferProperties {
var out_externalBufferProperties: ExternalBufferProperties = undefined;
vkGetPhysicalDeviceExternalBufferProperties(physicalDevice, &externalBufferInfo, &out_externalBufferProperties);
return out_externalBufferProperties;
}
pub inline fn GetPhysicalDeviceExternalFenceProperties(physicalDevice: PhysicalDevice, externalFenceInfo: PhysicalDeviceExternalFenceInfo) ExternalFenceProperties {
var out_externalFenceProperties: ExternalFenceProperties = undefined;
vkGetPhysicalDeviceExternalFenceProperties(physicalDevice, &externalFenceInfo, &out_externalFenceProperties);
return out_externalFenceProperties;
}
pub inline fn GetPhysicalDeviceExternalSemaphoreProperties(physicalDevice: PhysicalDevice, externalSemaphoreInfo: PhysicalDeviceExternalSemaphoreInfo) ExternalSemaphoreProperties {
var out_externalSemaphoreProperties: ExternalSemaphoreProperties = undefined;
vkGetPhysicalDeviceExternalSemaphoreProperties(physicalDevice, &externalSemaphoreInfo, &out_externalSemaphoreProperties);
return out_externalSemaphoreProperties;
}
pub inline fn GetDescriptorSetLayoutSupport(device: Device, createInfo: DescriptorSetLayoutCreateInfo) DescriptorSetLayoutSupport {
var out_support: DescriptorSetLayoutSupport = undefined;
vkGetDescriptorSetLayoutSupport(device, &createInfo, &out_support);
return out_support;
}
pub const VERSION_1_2 = 1;
// Vulkan 1.2 version number
pub const API_VERSION_1_2 = MAKE_VERSION(1, 2, 0);// Patch version should always be set to 0
pub const DeviceAddress = u64;
pub const MAX_DRIVER_NAME_SIZE = 256;
pub const MAX_DRIVER_INFO_SIZE = 256;
pub const DriverId = extern enum(i32) {
AMD_PROPRIETARY = 1,
AMD_OPEN_SOURCE = 2,
MESA_RADV = 3,
NVIDIA_PROPRIETARY = 4,
INTEL_PROPRIETARY_WINDOWS = 5,
INTEL_OPEN_SOURCE_MESA = 6,
IMAGINATION_PROPRIETARY = 7,
QUALCOMM_PROPRIETARY = 8,
ARM_PROPRIETARY = 9,
GOOGLE_SWIFTSHADER = 10,
GGP_PROPRIETARY = 11,
BROADCOM_PROPRIETARY = 12,
_,
const Self = @This();
pub const AMD_PROPRIETARY_KHR = Self.AMD_PROPRIETARY;
pub const AMD_OPEN_SOURCE_KHR = Self.AMD_OPEN_SOURCE;
pub const MESA_RADV_KHR = Self.MESA_RADV;
pub const NVIDIA_PROPRIETARY_KHR = Self.NVIDIA_PROPRIETARY;
pub const INTEL_PROPRIETARY_WINDOWS_KHR = Self.INTEL_PROPRIETARY_WINDOWS;
pub const INTEL_OPEN_SOURCE_MESA_KHR = Self.INTEL_OPEN_SOURCE_MESA;
pub const IMAGINATION_PROPRIETARY_KHR = Self.IMAGINATION_PROPRIETARY;
pub const QUALCOMM_PROPRIETARY_KHR = Self.QUALCOMM_PROPRIETARY;
pub const ARM_PROPRIETARY_KHR = Self.ARM_PROPRIETARY;
pub const GOOGLE_SWIFTSHADER_KHR = Self.GOOGLE_SWIFTSHADER;
pub const GGP_PROPRIETARY_KHR = Self.GGP_PROPRIETARY;
pub const BROADCOM_PROPRIETARY_KHR = Self.BROADCOM_PROPRIETARY;
};
pub const ShaderFloatControlsIndependence = extern enum(i32) {
T_32_BIT_ONLY = 0,
ALL = 1,
NONE = 2,
_,
const Self = @This();
pub const T_32_BIT_ONLY_KHR = Self.T_32_BIT_ONLY;
pub const ALL_KHR = Self.ALL;
pub const NONE_KHR = Self.NONE;
};
pub const SamplerReductionMode = extern enum(i32) {
WEIGHTED_AVERAGE = 0,
MIN = 1,
MAX = 2,
_,
const Self = @This();
pub const WEIGHTED_AVERAGE_EXT = Self.WEIGHTED_AVERAGE;
pub const MIN_EXT = Self.MIN;
pub const MAX_EXT = Self.MAX;
};
pub const SemaphoreType = extern enum(i32) {
BINARY = 0,
TIMELINE = 1,
_,
const Self = @This();
pub const BINARY_KHR = Self.BINARY;
pub const TIMELINE_KHR = Self.TIMELINE;
};
pub const ResolveModeFlags = packed struct {
sampleZero: bool = false,
average: bool = false,
min: bool = false,
max: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const none = fromInt(0);
pub const noneKhr = Self{ .none = true };
pub const sampleZeroKHR = Self{ .sampleZero = true };
pub const averageKHR = Self{ .average = true };
pub const minKHR = Self{ .min = true };
pub const maxKHR = Self{ .max = true };
pub usingnamespace FlagsMixin(Self);
};
pub const DescriptorBindingFlags = packed struct {
updateAfterBind: bool = false,
updateUnusedWhilePending: bool = false,
partiallyBound: bool = false,
variableDescriptorCount: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const updateAfterBindEXT = Self{ .updateAfterBind = true };
pub const updateUnusedWhilePendingEXT = Self{ .updateUnusedWhilePending = true };
pub const partiallyBoundEXT = Self{ .partiallyBound = true };
pub const variableDescriptorCountEXT = Self{ .variableDescriptorCount = true };
pub usingnamespace FlagsMixin(Self);
};
pub const SemaphoreWaitFlags = packed struct {
any: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
const Self = @This();
pub const anyKHR = Self{ .any = true };
pub usingnamespace FlagsMixin(Self);
};
pub const PhysicalDeviceVulkan11Features = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
pNext: ?*c_void = null,
storageBuffer16BitAccess: Bool32,
uniformAndStorageBuffer16BitAccess: Bool32,
storagePushConstant16: Bool32,
storageInputOutput16: Bool32,
multiview: Bool32,
multiviewGeometryShader: Bool32,
multiviewTessellationShader: Bool32,
variablePointersStorageBuffer: Bool32,
variablePointers: Bool32,
protectedMemory: Bool32,
samplerYcbcrConversion: Bool32,
shaderDrawParameters: Bool32,
};
pub const PhysicalDeviceVulkan11Properties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES,
pNext: ?*c_void = null,
deviceUUID: [UUID_SIZE]u8,
driverUUID: [UUID_SIZE]u8,
deviceLUID: [LUID_SIZE]u8,
deviceNodeMask: u32,
deviceLUIDValid: Bool32,
subgroupSize: u32,
subgroupSupportedStages: ShaderStageFlags align(4),
subgroupSupportedOperations: SubgroupFeatureFlags align(4),
subgroupQuadOperationsInAllStages: Bool32,
pointClippingBehavior: PointClippingBehavior,
maxMultiviewViewCount: u32,
maxMultiviewInstanceIndex: u32,
protectedNoFault: Bool32,
maxPerSetDescriptors: u32,
maxMemoryAllocationSize: DeviceSize,
};
pub const PhysicalDeviceVulkan12Features = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
pNext: ?*c_void = null,
samplerMirrorClampToEdge: Bool32,
drawIndirectCount: Bool32,
storageBuffer8BitAccess: Bool32,
uniformAndStorageBuffer8BitAccess: Bool32,
storagePushConstant8: Bool32,
shaderBufferInt64Atomics: Bool32,
shaderSharedInt64Atomics: Bool32,
shaderFloat16: Bool32,
shaderInt8: Bool32,
descriptorIndexing: Bool32,
shaderInputAttachmentArrayDynamicIndexing: Bool32,
shaderUniformTexelBufferArrayDynamicIndexing: Bool32,
shaderStorageTexelBufferArrayDynamicIndexing: Bool32,
shaderUniformBufferArrayNonUniformIndexing: Bool32,
shaderSampledImageArrayNonUniformIndexing: Bool32,
shaderStorageBufferArrayNonUniformIndexing: Bool32,
shaderStorageImageArrayNonUniformIndexing: Bool32,
shaderInputAttachmentArrayNonUniformIndexing: Bool32,
shaderUniformTexelBufferArrayNonUniformIndexing: Bool32,
shaderStorageTexelBufferArrayNonUniformIndexing: Bool32,
descriptorBindingUniformBufferUpdateAfterBind: Bool32,
descriptorBindingSampledImageUpdateAfterBind: Bool32,
descriptorBindingStorageImageUpdateAfterBind: Bool32,
descriptorBindingStorageBufferUpdateAfterBind: Bool32,
descriptorBindingUniformTexelBufferUpdateAfterBind: Bool32,
descriptorBindingStorageTexelBufferUpdateAfterBind: Bool32,
descriptorBindingUpdateUnusedWhilePending: Bool32,
descriptorBindingPartiallyBound: Bool32,
descriptorBindingVariableDescriptorCount: Bool32,
runtimeDescriptorArray: Bool32,
samplerFilterMinmax: Bool32,
scalarBlockLayout: Bool32,
imagelessFramebuffer: Bool32,
uniformBufferStandardLayout: Bool32,
shaderSubgroupExtendedTypes: Bool32,
separateDepthStencilLayouts: Bool32,
hostQueryReset: Bool32,
timelineSemaphore: Bool32,
bufferDeviceAddress: Bool32,
bufferDeviceAddressCaptureReplay: Bool32,
bufferDeviceAddressMultiDevice: Bool32,
vulkanMemoryModel: Bool32,
vulkanMemoryModelDeviceScope: Bool32,
vulkanMemoryModelAvailabilityVisibilityChains: Bool32,
shaderOutputViewportIndex: Bool32,
shaderOutputLayer: Bool32,
subgroupBroadcastDynamicId: Bool32,
};
pub const ConformanceVersion = extern struct {
major: u8,
minor: u8,
subminor: u8,
patch: u8,
};
pub const PhysicalDeviceVulkan12Properties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES,
pNext: ?*c_void = null,
driverID: DriverId,
driverName: [MAX_DRIVER_NAME_SIZE-1:0]u8,
driverInfo: [MAX_DRIVER_INFO_SIZE-1:0]u8,
conformanceVersion: ConformanceVersion,
denormBehaviorIndependence: ShaderFloatControlsIndependence,
roundingModeIndependence: ShaderFloatControlsIndependence,
shaderSignedZeroInfNanPreserveFloat16: Bool32,
shaderSignedZeroInfNanPreserveFloat32: Bool32,
shaderSignedZeroInfNanPreserveFloat64: Bool32,
shaderDenormPreserveFloat16: Bool32,
shaderDenormPreserveFloat32: Bool32,
shaderDenormPreserveFloat64: Bool32,
shaderDenormFlushToZeroFloat16: Bool32,
shaderDenormFlushToZeroFloat32: Bool32,
shaderDenormFlushToZeroFloat64: Bool32,
shaderRoundingModeRTEFloat16: Bool32,
shaderRoundingModeRTEFloat32: Bool32,
shaderRoundingModeRTEFloat64: Bool32,
shaderRoundingModeRTZFloat16: Bool32,
shaderRoundingModeRTZFloat32: Bool32,
shaderRoundingModeRTZFloat64: Bool32,
maxUpdateAfterBindDescriptorsInAllPools: u32,
shaderUniformBufferArrayNonUniformIndexingNative: Bool32,
shaderSampledImageArrayNonUniformIndexingNative: Bool32,
shaderStorageBufferArrayNonUniformIndexingNative: Bool32,
shaderStorageImageArrayNonUniformIndexingNative: Bool32,
shaderInputAttachmentArrayNonUniformIndexingNative: Bool32,
robustBufferAccessUpdateAfterBind: Bool32,
quadDivergentImplicitLod: Bool32,
maxPerStageDescriptorUpdateAfterBindSamplers: u32,
maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32,
maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32,
maxPerStageDescriptorUpdateAfterBindSampledImages: u32,
maxPerStageDescriptorUpdateAfterBindStorageImages: u32,
maxPerStageDescriptorUpdateAfterBindInputAttachments: u32,
maxPerStageUpdateAfterBindResources: u32,
maxDescriptorSetUpdateAfterBindSamplers: u32,
maxDescriptorSetUpdateAfterBindUniformBuffers: u32,
maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32,
maxDescriptorSetUpdateAfterBindStorageBuffers: u32,
maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32,
maxDescriptorSetUpdateAfterBindSampledImages: u32,
maxDescriptorSetUpdateAfterBindStorageImages: u32,
maxDescriptorSetUpdateAfterBindInputAttachments: u32,
supportedDepthResolveModes: ResolveModeFlags align(4),
supportedStencilResolveModes: ResolveModeFlags align(4),
independentResolveNone: Bool32,
independentResolve: Bool32,
filterMinmaxSingleComponentFormats: Bool32,
filterMinmaxImageComponentMapping: Bool32,
maxTimelineSemaphoreValueDifference: u64,
framebufferIntegerColorSampleCounts: SampleCountFlags align(4) = SampleCountFlags{},
};
pub const ImageFormatListCreateInfo = extern struct {
sType: StructureType = .IMAGE_FORMAT_LIST_CREATE_INFO,
pNext: ?*const c_void = null,
viewFormatCount: u32 = 0,
pViewFormats: [*]const Format = undefined,
};
pub const AttachmentDescription2 = extern struct {
sType: StructureType = .ATTACHMENT_DESCRIPTION_2,
pNext: ?*const c_void = null,
flags: AttachmentDescriptionFlags align(4) = AttachmentDescriptionFlags{},
format: Format,
samples: SampleCountFlags align(4),
loadOp: AttachmentLoadOp,
storeOp: AttachmentStoreOp,
stencilLoadOp: AttachmentLoadOp,
stencilStoreOp: AttachmentStoreOp,
initialLayout: ImageLayout,
finalLayout: ImageLayout,
};
pub const AttachmentReference2 = extern struct {
sType: StructureType = .ATTACHMENT_REFERENCE_2,
pNext: ?*const c_void = null,
attachment: u32,
layout: ImageLayout,
aspectMask: ImageAspectFlags align(4),
};
pub const SubpassDescription2 = extern struct {
sType: StructureType = .SUBPASS_DESCRIPTION_2,
pNext: ?*const c_void = null,
flags: SubpassDescriptionFlags align(4) = SubpassDescriptionFlags{},
pipelineBindPoint: PipelineBindPoint,
viewMask: u32,
inputAttachmentCount: u32 = 0,
pInputAttachments: [*]const AttachmentReference2 = undefined,
colorAttachmentCount: u32 = 0,
pColorAttachments: [*]const AttachmentReference2 = undefined,
pResolveAttachments: ?[*]const AttachmentReference2 = null,
pDepthStencilAttachment: ?*const AttachmentReference2 = null,
preserveAttachmentCount: u32 = 0,
pPreserveAttachments: [*]const u32 = undefined,
};
pub const SubpassDependency2 = extern struct {
sType: StructureType = .SUBPASS_DEPENDENCY_2,
pNext: ?*const c_void = null,
srcSubpass: u32,
dstSubpass: u32,
srcStageMask: PipelineStageFlags align(4),
dstStageMask: PipelineStageFlags align(4),
srcAccessMask: AccessFlags align(4) = AccessFlags{},
dstAccessMask: AccessFlags align(4) = AccessFlags{},
dependencyFlags: DependencyFlags align(4) = DependencyFlags{},
viewOffset: i32 = 0,
};
pub const RenderPassCreateInfo2 = extern struct {
sType: StructureType = .RENDER_PASS_CREATE_INFO_2,
pNext: ?*const c_void = null,
flags: RenderPassCreateFlags align(4) = RenderPassCreateFlags{},
attachmentCount: u32 = 0,
pAttachments: [*]const AttachmentDescription2 = undefined,
subpassCount: u32,
pSubpasses: [*]const SubpassDescription2,
dependencyCount: u32 = 0,
pDependencies: [*]const SubpassDependency2 = undefined,
correlatedViewMaskCount: u32 = 0,
pCorrelatedViewMasks: [*]const u32 = undefined,
};
pub const SubpassBeginInfo = extern struct {
sType: StructureType = .SUBPASS_BEGIN_INFO,
pNext: ?*const c_void = null,
contents: SubpassContents,
};
pub const SubpassEndInfo = extern struct {
sType: StructureType = .SUBPASS_END_INFO,
pNext: ?*const c_void = null,
};
pub const PhysicalDevice8BitStorageFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES,
pNext: ?*c_void = null,
storageBuffer8BitAccess: Bool32,
uniformAndStorageBuffer8BitAccess: Bool32,
storagePushConstant8: Bool32,
};
pub const PhysicalDeviceDriverProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DRIVER_PROPERTIES,
pNext: ?*c_void = null,
driverID: DriverId,
driverName: [MAX_DRIVER_NAME_SIZE-1:0]u8,
driverInfo: [MAX_DRIVER_INFO_SIZE-1:0]u8,
conformanceVersion: ConformanceVersion,
};
pub const PhysicalDeviceShaderAtomicInt64Features = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES,
pNext: ?*c_void = null,
shaderBufferInt64Atomics: Bool32,
shaderSharedInt64Atomics: Bool32,
};
pub const PhysicalDeviceShaderFloat16Int8Features = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES,
pNext: ?*c_void = null,
shaderFloat16: Bool32,
shaderInt8: Bool32,
};
pub const PhysicalDeviceFloatControlsProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES,
pNext: ?*c_void = null,
denormBehaviorIndependence: ShaderFloatControlsIndependence,
roundingModeIndependence: ShaderFloatControlsIndependence,
shaderSignedZeroInfNanPreserveFloat16: Bool32,
shaderSignedZeroInfNanPreserveFloat32: Bool32,
shaderSignedZeroInfNanPreserveFloat64: Bool32,
shaderDenormPreserveFloat16: Bool32,
shaderDenormPreserveFloat32: Bool32,
shaderDenormPreserveFloat64: Bool32,
shaderDenormFlushToZeroFloat16: Bool32,
shaderDenormFlushToZeroFloat32: Bool32,
shaderDenormFlushToZeroFloat64: Bool32,
shaderRoundingModeRTEFloat16: Bool32,
shaderRoundingModeRTEFloat32: Bool32,
shaderRoundingModeRTEFloat64: Bool32,
shaderRoundingModeRTZFloat16: Bool32,
shaderRoundingModeRTZFloat32: Bool32,
shaderRoundingModeRTZFloat64: Bool32,
};
pub const DescriptorSetLayoutBindingFlagsCreateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
pNext: ?*const c_void = null,
bindingCount: u32 = 0,
pBindingFlags: ?[*]align(4) const DescriptorBindingFlags = null,
};
pub const PhysicalDeviceDescriptorIndexingFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES,
pNext: ?*c_void = null,
shaderInputAttachmentArrayDynamicIndexing: Bool32,
shaderUniformTexelBufferArrayDynamicIndexing: Bool32,
shaderStorageTexelBufferArrayDynamicIndexing: Bool32,
shaderUniformBufferArrayNonUniformIndexing: Bool32,
shaderSampledImageArrayNonUniformIndexing: Bool32,
shaderStorageBufferArrayNonUniformIndexing: Bool32,
shaderStorageImageArrayNonUniformIndexing: Bool32,
shaderInputAttachmentArrayNonUniformIndexing: Bool32,
shaderUniformTexelBufferArrayNonUniformIndexing: Bool32,
shaderStorageTexelBufferArrayNonUniformIndexing: Bool32,
descriptorBindingUniformBufferUpdateAfterBind: Bool32,
descriptorBindingSampledImageUpdateAfterBind: Bool32,
descriptorBindingStorageImageUpdateAfterBind: Bool32,
descriptorBindingStorageBufferUpdateAfterBind: Bool32,
descriptorBindingUniformTexelBufferUpdateAfterBind: Bool32,
descriptorBindingStorageTexelBufferUpdateAfterBind: Bool32,
descriptorBindingUpdateUnusedWhilePending: Bool32,
descriptorBindingPartiallyBound: Bool32,
descriptorBindingVariableDescriptorCount: Bool32,
runtimeDescriptorArray: Bool32,
};
pub const PhysicalDeviceDescriptorIndexingProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES,
pNext: ?*c_void = null,
maxUpdateAfterBindDescriptorsInAllPools: u32,
shaderUniformBufferArrayNonUniformIndexingNative: Bool32,
shaderSampledImageArrayNonUniformIndexingNative: Bool32,
shaderStorageBufferArrayNonUniformIndexingNative: Bool32,
shaderStorageImageArrayNonUniformIndexingNative: Bool32,
shaderInputAttachmentArrayNonUniformIndexingNative: Bool32,
robustBufferAccessUpdateAfterBind: Bool32,
quadDivergentImplicitLod: Bool32,
maxPerStageDescriptorUpdateAfterBindSamplers: u32,
maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32,
maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32,
maxPerStageDescriptorUpdateAfterBindSampledImages: u32,
maxPerStageDescriptorUpdateAfterBindStorageImages: u32,
maxPerStageDescriptorUpdateAfterBindInputAttachments: u32,
maxPerStageUpdateAfterBindResources: u32,
maxDescriptorSetUpdateAfterBindSamplers: u32,
maxDescriptorSetUpdateAfterBindUniformBuffers: u32,
maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32,
maxDescriptorSetUpdateAfterBindStorageBuffers: u32,
maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32,
maxDescriptorSetUpdateAfterBindSampledImages: u32,
maxDescriptorSetUpdateAfterBindStorageImages: u32,
maxDescriptorSetUpdateAfterBindInputAttachments: u32,
};
pub const DescriptorSetVariableDescriptorCountAllocateInfo = extern struct {
sType: StructureType = .DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO,
pNext: ?*const c_void = null,
descriptorSetCount: u32 = 0,
pDescriptorCounts: [*]const u32 = undefined,
};
pub const DescriptorSetVariableDescriptorCountLayoutSupport = extern struct {
sType: StructureType = .DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT,
pNext: ?*c_void = null,
maxVariableDescriptorCount: u32,
};
pub const SubpassDescriptionDepthStencilResolve = extern struct {
sType: StructureType = .SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE,
pNext: ?*const c_void = null,
depthResolveMode: ResolveModeFlags align(4),
stencilResolveMode: ResolveModeFlags align(4),
pDepthStencilResolveAttachment: ?*const AttachmentReference2 = null,
};
pub const PhysicalDeviceDepthStencilResolveProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES,
pNext: ?*c_void = null,
supportedDepthResolveModes: ResolveModeFlags align(4),
supportedStencilResolveModes: ResolveModeFlags align(4),
independentResolveNone: Bool32,
independentResolve: Bool32,
};
pub const PhysicalDeviceScalarBlockLayoutFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES,
pNext: ?*c_void = null,
scalarBlockLayout: Bool32,
};
pub const ImageStencilUsageCreateInfo = extern struct {
sType: StructureType = .IMAGE_STENCIL_USAGE_CREATE_INFO,
pNext: ?*const c_void = null,
stencilUsage: ImageUsageFlags align(4),
};
pub const SamplerReductionModeCreateInfo = extern struct {
sType: StructureType = .SAMPLER_REDUCTION_MODE_CREATE_INFO,
pNext: ?*const c_void = null,
reductionMode: SamplerReductionMode,
};
pub const PhysicalDeviceSamplerFilterMinmaxProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES,
pNext: ?*c_void = null,
filterMinmaxSingleComponentFormats: Bool32,
filterMinmaxImageComponentMapping: Bool32,
};
pub const PhysicalDeviceVulkanMemoryModelFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES,
pNext: ?*c_void = null,
vulkanMemoryModel: Bool32,
vulkanMemoryModelDeviceScope: Bool32,
vulkanMemoryModelAvailabilityVisibilityChains: Bool32,
};
pub const PhysicalDeviceImagelessFramebufferFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES,
pNext: ?*c_void = null,
imagelessFramebuffer: Bool32,
};
pub const FramebufferAttachmentImageInfo = extern struct {
sType: StructureType = .FRAMEBUFFER_ATTACHMENT_IMAGE_INFO,
pNext: ?*const c_void = null,
flags: ImageCreateFlags align(4) = ImageCreateFlags{},
usage: ImageUsageFlags align(4),
width: u32,
height: u32,
layerCount: u32,
viewFormatCount: u32 = 0,
pViewFormats: [*]const Format = undefined,
};
pub const FramebufferAttachmentsCreateInfo = extern struct {
sType: StructureType = .FRAMEBUFFER_ATTACHMENTS_CREATE_INFO,
pNext: ?*const c_void = null,
attachmentImageInfoCount: u32 = 0,
pAttachmentImageInfos: [*]const FramebufferAttachmentImageInfo = undefined,
};
pub const RenderPassAttachmentBeginInfo = extern struct {
sType: StructureType = .RENDER_PASS_ATTACHMENT_BEGIN_INFO,
pNext: ?*const c_void = null,
attachmentCount: u32 = 0,
pAttachments: [*]const ImageView = undefined,
};
pub const PhysicalDeviceUniformBufferStandardLayoutFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES,
pNext: ?*c_void = null,
uniformBufferStandardLayout: Bool32,
};
pub const PhysicalDeviceShaderSubgroupExtendedTypesFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES,
pNext: ?*c_void = null,
shaderSubgroupExtendedTypes: Bool32,
};
pub const PhysicalDeviceSeparateDepthStencilLayoutsFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES,
pNext: ?*c_void = null,
separateDepthStencilLayouts: Bool32,
};
pub const AttachmentReferenceStencilLayout = extern struct {
sType: StructureType = .ATTACHMENT_REFERENCE_STENCIL_LAYOUT,
pNext: ?*c_void = null,
stencilLayout: ImageLayout,
};
pub const AttachmentDescriptionStencilLayout = extern struct {
sType: StructureType = .ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT,
pNext: ?*c_void = null,
stencilInitialLayout: ImageLayout,
stencilFinalLayout: ImageLayout,
};
pub const PhysicalDeviceHostQueryResetFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES,
pNext: ?*c_void = null,
hostQueryReset: Bool32,
};
pub const PhysicalDeviceTimelineSemaphoreFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES,
pNext: ?*c_void = null,
timelineSemaphore: Bool32,
};
pub const PhysicalDeviceTimelineSemaphoreProperties = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES,
pNext: ?*c_void = null,
maxTimelineSemaphoreValueDifference: u64,
};
pub const SemaphoreTypeCreateInfo = extern struct {
sType: StructureType = .SEMAPHORE_TYPE_CREATE_INFO,
pNext: ?*const c_void = null,
semaphoreType: SemaphoreType,
initialValue: u64,
};
pub const TimelineSemaphoreSubmitInfo = extern struct {
sType: StructureType = .TIMELINE_SEMAPHORE_SUBMIT_INFO,
pNext: ?*const c_void = null,
waitSemaphoreValueCount: u32 = 0,
pWaitSemaphoreValues: ?[*]const u64 = null,
signalSemaphoreValueCount: u32 = 0,
pSignalSemaphoreValues: ?[*]const u64 = null,
};
pub const SemaphoreWaitInfo = extern struct {
sType: StructureType = .SEMAPHORE_WAIT_INFO,
pNext: ?*const c_void = null,
flags: SemaphoreWaitFlags align(4) = SemaphoreWaitFlags{},
semaphoreCount: u32,
pSemaphores: [*]const Semaphore,
pValues: [*]const u64,
};
pub const SemaphoreSignalInfo = extern struct {
sType: StructureType = .SEMAPHORE_SIGNAL_INFO,
pNext: ?*const c_void = null,
semaphore: Semaphore,
value: u64,
};
pub const PhysicalDeviceBufferDeviceAddressFeatures = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES,
pNext: ?*c_void = null,
bufferDeviceAddress: Bool32,
bufferDeviceAddressCaptureReplay: Bool32,
bufferDeviceAddressMultiDevice: Bool32,
};
pub const BufferDeviceAddressInfo = extern struct {
sType: StructureType = .BUFFER_DEVICE_ADDRESS_INFO,
pNext: ?*const c_void = null,
buffer: Buffer,
};
pub const BufferOpaqueCaptureAddressCreateInfo = extern struct {
sType: StructureType = .BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO,
pNext: ?*const c_void = null,
opaqueCaptureAddress: u64,
};
pub const MemoryOpaqueCaptureAddressAllocateInfo = extern struct {
sType: StructureType = .MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO,
pNext: ?*const c_void = null,
opaqueCaptureAddress: u64,
};
pub const DeviceMemoryOpaqueCaptureAddressInfo = extern struct {
sType: StructureType = .DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO,
pNext: ?*const c_void = null,
memory: DeviceMemory,
};
pub extern fn vkCmdDrawIndirectCount(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndexedIndirectCount(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCreateRenderPass2(
device: Device,
pCreateInfo: *const RenderPassCreateInfo2,
pAllocator: ?*const AllocationCallbacks,
pRenderPass: *RenderPass,
) callconv(CallConv) Result;
pub extern fn vkCmdBeginRenderPass2(
commandBuffer: CommandBuffer,
pRenderPassBegin: *const RenderPassBeginInfo,
pSubpassBeginInfo: *const SubpassBeginInfo,
) callconv(CallConv) void;
pub extern fn vkCmdNextSubpass2(
commandBuffer: CommandBuffer,
pSubpassBeginInfo: *const SubpassBeginInfo,
pSubpassEndInfo: *const SubpassEndInfo,
) callconv(CallConv) void;
pub extern fn vkCmdEndRenderPass2(
commandBuffer: CommandBuffer,
pSubpassEndInfo: *const SubpassEndInfo,
) callconv(CallConv) void;
pub extern fn vkResetQueryPool(
device: Device,
queryPool: QueryPool,
firstQuery: u32,
queryCount: u32,
) callconv(CallConv) void;
pub extern fn vkGetSemaphoreCounterValue(
device: Device,
semaphore: Semaphore,
pValue: *u64,
) callconv(CallConv) Result;
pub extern fn vkWaitSemaphores(
device: Device,
pWaitInfo: *const SemaphoreWaitInfo,
timeout: u64,
) callconv(CallConv) Result;
pub extern fn vkSignalSemaphore(
device: Device,
pSignalInfo: *const SemaphoreSignalInfo,
) callconv(CallConv) Result;
pub extern fn vkGetBufferDeviceAddress(
device: Device,
pInfo: *const BufferDeviceAddressInfo,
) callconv(CallConv) DeviceAddress;
pub extern fn vkGetBufferOpaqueCaptureAddress(
device: Device,
pInfo: *const BufferDeviceAddressInfo,
) callconv(CallConv) u64;
pub extern fn vkGetDeviceMemoryOpaqueCaptureAddress(
device: Device,
pInfo: *const DeviceMemoryOpaqueCaptureAddressInfo,
) callconv(CallConv) u64;
pub const CmdDrawIndirectCount = vkCmdDrawIndirectCount;
pub const CmdDrawIndexedIndirectCount = vkCmdDrawIndexedIndirectCount;
pub inline fn CreateRenderPass2(device: Device, createInfo: RenderPassCreateInfo2, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!RenderPass {
var out_renderPass: RenderPass = undefined;
const result = vkCreateRenderPass2(device, &createInfo, pAllocator, &out_renderPass);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_renderPass;
}
pub inline fn CmdBeginRenderPass2(commandBuffer: CommandBuffer, renderPassBegin: RenderPassBeginInfo, subpassBeginInfo: SubpassBeginInfo) void {
vkCmdBeginRenderPass2(commandBuffer, &renderPassBegin, &subpassBeginInfo);
}
pub inline fn CmdNextSubpass2(commandBuffer: CommandBuffer, subpassBeginInfo: SubpassBeginInfo, subpassEndInfo: SubpassEndInfo) void {
vkCmdNextSubpass2(commandBuffer, &subpassBeginInfo, &subpassEndInfo);
}
pub inline fn CmdEndRenderPass2(commandBuffer: CommandBuffer, subpassEndInfo: SubpassEndInfo) void {
vkCmdEndRenderPass2(commandBuffer, &subpassEndInfo);
}
pub const ResetQueryPool = vkResetQueryPool;
pub inline fn GetSemaphoreCounterValue(device: Device, semaphore: Semaphore) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!u64 {
var out_value: u64 = undefined;
const result = vkGetSemaphoreCounterValue(device, semaphore, &out_value);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_value;
}
pub inline fn WaitSemaphores(device: Device, waitInfo: SemaphoreWaitInfo, timeout: u64) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkWaitSemaphores(device, &waitInfo, timeout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn SignalSemaphore(device: Device, signalInfo: SemaphoreSignalInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkSignalSemaphore(device, &signalInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetBufferDeviceAddress(device: Device, info: BufferDeviceAddressInfo) DeviceAddress {
const result = vkGetBufferDeviceAddress(device, &info);
return result;
}
pub inline fn GetBufferOpaqueCaptureAddress(device: Device, info: BufferDeviceAddressInfo) u64 {
const result = vkGetBufferOpaqueCaptureAddress(device, &info);
return result;
}
pub inline fn GetDeviceMemoryOpaqueCaptureAddress(device: Device, info: DeviceMemoryOpaqueCaptureAddressInfo) u64 {
const result = vkGetDeviceMemoryOpaqueCaptureAddress(device, &info);
return result;
}
pub const KHR_surface = 1;
pub const SurfaceKHR = *@OpaqueType();
pub const KHR_SURFACE_SPEC_VERSION = 25;
pub const KHR_SURFACE_EXTENSION_NAME = "VK_KHR_surface";
pub const ColorSpaceKHR = extern enum(i32) {
SRGB_NONLINEAR = 0,
DISPLAY_P3_NONLINEAR_EXT = 1000104001,
EXTENDED_SRGB_LINEAR_EXT = 1000104002,
DISPLAY_P3_LINEAR_EXT = 1000104003,
DCI_P3_NONLINEAR_EXT = 1000104004,
BT709_LINEAR_EXT = 1000104005,
BT709_NONLINEAR_EXT = 1000104006,
BT2020_LINEAR_EXT = 1000104007,
HDR10_ST2084_EXT = 1000104008,
DOLBYVISION_EXT = 1000104009,
HDR10_HLG_EXT = 1000104010,
ADOBERGB_LINEAR_EXT = 1000104011,
ADOBERGB_NONLINEAR_EXT = 1000104012,
PASS_THROUGH_EXT = 1000104013,
EXTENDED_SRGB_NONLINEAR_EXT = 1000104014,
DISPLAY_NATIVE_AMD = 1000213000,
_,
const Self = @This();
pub const COLORSPACE_SRGB_NONLINEAR = Self.SRGB_NONLINEAR;
pub const DCI_P3_LINEAR_EXT = Self.DISPLAY_P3_LINEAR_EXT;
};
pub const PresentModeKHR = extern enum(i32) {
IMMEDIATE = 0,
MAILBOX = 1,
FIFO = 2,
FIFO_RELAXED = 3,
SHARED_DEMAND_REFRESH = 1000111000,
SHARED_CONTINUOUS_REFRESH = 1000111001,
_,
};
pub const SurfaceTransformFlagsKHR = packed struct {
identity: bool = false,
rotate90: bool = false,
rotate180: bool = false,
rotate270: bool = false,
horizontalMirror: bool = false,
horizontalMirrorRotate90: bool = false,
horizontalMirrorRotate180: bool = false,
horizontalMirrorRotate270: bool = false,
inherit: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const CompositeAlphaFlagsKHR = packed struct {
opaque: bool = false,
preMultiplied: bool = false,
postMultiplied: bool = false,
inherit: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SurfaceCapabilitiesKHR = extern struct {
minImageCount: u32,
maxImageCount: u32,
currentExtent: Extent2D,
minImageExtent: Extent2D,
maxImageExtent: Extent2D,
maxImageArrayLayers: u32,
supportedTransforms: SurfaceTransformFlagsKHR align(4) = SurfaceTransformFlagsKHR{},
currentTransform: SurfaceTransformFlagsKHR align(4),
supportedCompositeAlpha: CompositeAlphaFlagsKHR align(4) = CompositeAlphaFlagsKHR{},
supportedUsageFlags: ImageUsageFlags align(4) = ImageUsageFlags{},
};
pub const SurfaceFormatKHR = extern struct {
format: Format,
colorSpace: ColorSpaceKHR,
};
pub extern fn vkDestroySurfaceKHR(
instance: Instance,
surface: ?SurfaceKHR,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceSurfaceSupportKHR(
physicalDevice: PhysicalDevice,
queueFamilyIndex: u32,
surface: SurfaceKHR,
pSupported: *Bool32,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
physicalDevice: PhysicalDevice,
surface: SurfaceKHR,
pSurfaceCapabilities: *SurfaceCapabilitiesKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceSurfaceFormatsKHR(
physicalDevice: PhysicalDevice,
surface: SurfaceKHR,
pSurfaceFormatCount: *u32,
pSurfaceFormats: ?[*]SurfaceFormatKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceSurfacePresentModesKHR(
physicalDevice: PhysicalDevice,
surface: SurfaceKHR,
pPresentModeCount: *u32,
pPresentModes: ?[*]PresentModeKHR,
) callconv(CallConv) Result;
pub const DestroySurfaceKHR = vkDestroySurfaceKHR;
pub inline fn GetPhysicalDeviceSurfaceSupportKHR(physicalDevice: PhysicalDevice, queueFamilyIndex: u32, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!Bool32 {
var out_supported: Bool32 = undefined;
const result = vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, &out_supported);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_supported;
}
pub inline fn GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!SurfaceCapabilitiesKHR {
var out_surfaceCapabilities: SurfaceCapabilitiesKHR = undefined;
const result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, &out_surfaceCapabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surfaceCapabilities;
}
pub const GetPhysicalDeviceSurfaceFormatsKHRResult = struct {
result: Result,
surfaceFormats: []SurfaceFormatKHR,
};
pub inline fn GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR, surfaceFormats: []SurfaceFormatKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceSurfaceFormatsKHRResult {
var returnValues: GetPhysicalDeviceSurfaceFormatsKHRResult = undefined;
var surfaceFormatCount: u32 = @intCast(u32, surfaceFormats.len);
const result = vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &surfaceFormatCount, surfaceFormats.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.surfaceFormats = surfaceFormats[0..surfaceFormatCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceSurfaceFormatsCountKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!u32 {
var out_surfaceFormatCount: u32 = undefined;
const result = vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &out_surfaceFormatCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surfaceFormatCount;
}
pub const GetPhysicalDeviceSurfacePresentModesKHRResult = struct {
result: Result,
presentModes: []PresentModeKHR,
};
pub inline fn GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR, presentModes: []PresentModeKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceSurfacePresentModesKHRResult {
var returnValues: GetPhysicalDeviceSurfacePresentModesKHRResult = undefined;
var presentModeCount: u32 = @intCast(u32, presentModes.len);
const result = vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, presentModes.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.presentModes = presentModes[0..presentModeCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceSurfacePresentModesCountKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!u32 {
var out_presentModeCount: u32 = undefined;
const result = vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &out_presentModeCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_presentModeCount;
}
pub const KHR_swapchain = 1;
pub const SwapchainKHR = *@OpaqueType();
pub const KHR_SWAPCHAIN_SPEC_VERSION = 70;
pub const KHR_SWAPCHAIN_EXTENSION_NAME = "VK_KHR_swapchain";
pub const SwapchainCreateFlagsKHR = packed struct {
splitInstanceBindRegions: bool = false,
protected: bool = false,
mutableFormat: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DeviceGroupPresentModeFlagsKHR = packed struct {
local: bool = false,
remote: bool = false,
sum: bool = false,
localMultiDevice: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SwapchainCreateInfoKHR = extern struct {
sType: StructureType = .SWAPCHAIN_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
flags: SwapchainCreateFlagsKHR align(4) = SwapchainCreateFlagsKHR{},
surface: SurfaceKHR,
minImageCount: u32,
imageFormat: Format,
imageColorSpace: ColorSpaceKHR,
imageExtent: Extent2D,
imageArrayLayers: u32,
imageUsage: ImageUsageFlags align(4),
imageSharingMode: SharingMode,
queueFamilyIndexCount: u32 = 0,
pQueueFamilyIndices: [*]const u32 = undefined,
preTransform: SurfaceTransformFlagsKHR align(4),
compositeAlpha: CompositeAlphaFlagsKHR align(4),
presentMode: PresentModeKHR,
clipped: Bool32,
oldSwapchain: ?SwapchainKHR = null,
};
pub const PresentInfoKHR = extern struct {
sType: StructureType = .PRESENT_INFO_KHR,
pNext: ?*const c_void = null,
waitSemaphoreCount: u32 = 0,
pWaitSemaphores: [*]const Semaphore = undefined,
swapchainCount: u32,
pSwapchains: [*]const SwapchainKHR,
pImageIndices: [*]const u32,
pResults: ?[*]Result = null,
};
pub const ImageSwapchainCreateInfoKHR = extern struct {
sType: StructureType = .IMAGE_SWAPCHAIN_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
swapchain: ?SwapchainKHR = null,
};
pub const BindImageMemorySwapchainInfoKHR = extern struct {
sType: StructureType = .BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR,
pNext: ?*const c_void = null,
swapchain: SwapchainKHR,
imageIndex: u32,
};
pub const AcquireNextImageInfoKHR = extern struct {
sType: StructureType = .ACQUIRE_NEXT_IMAGE_INFO_KHR,
pNext: ?*const c_void = null,
swapchain: SwapchainKHR,
timeout: u64,
semaphore: ?Semaphore = null,
fence: ?Fence = null,
deviceMask: u32,
};
pub const DeviceGroupPresentCapabilitiesKHR = extern struct {
sType: StructureType = .DEVICE_GROUP_PRESENT_CAPABILITIES_KHR,
pNext: ?*const c_void = null,
presentMask: [MAX_DEVICE_GROUP_SIZE]u32,
modes: DeviceGroupPresentModeFlagsKHR align(4),
};
pub const DeviceGroupPresentInfoKHR = extern struct {
sType: StructureType = .DEVICE_GROUP_PRESENT_INFO_KHR,
pNext: ?*const c_void = null,
swapchainCount: u32 = 0,
pDeviceMasks: [*]const u32 = undefined,
mode: DeviceGroupPresentModeFlagsKHR align(4),
};
pub const DeviceGroupSwapchainCreateInfoKHR = extern struct {
sType: StructureType = .DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
modes: DeviceGroupPresentModeFlagsKHR align(4),
};
pub extern fn vkCreateSwapchainKHR(
device: Device,
pCreateInfo: *const SwapchainCreateInfoKHR,
pAllocator: ?*const AllocationCallbacks,
pSwapchain: *SwapchainKHR,
) callconv(CallConv) Result;
pub extern fn vkDestroySwapchainKHR(
device: Device,
swapchain: ?SwapchainKHR,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetSwapchainImagesKHR(
device: Device,
swapchain: SwapchainKHR,
pSwapchainImageCount: *u32,
pSwapchainImages: ?[*]Image,
) callconv(CallConv) Result;
pub extern fn vkAcquireNextImageKHR(
device: Device,
swapchain: SwapchainKHR,
timeout: u64,
semaphore: ?Semaphore,
fence: ?Fence,
pImageIndex: *u32,
) callconv(CallConv) Result;
pub extern fn vkQueuePresentKHR(
queue: Queue,
pPresentInfo: *const PresentInfoKHR,
) callconv(CallConv) Result;
pub extern fn vkGetDeviceGroupPresentCapabilitiesKHR(
device: Device,
pDeviceGroupPresentCapabilities: *DeviceGroupPresentCapabilitiesKHR,
) callconv(CallConv) Result;
pub extern fn vkGetDeviceGroupSurfacePresentModesKHR(
device: Device,
surface: SurfaceKHR,
pModes: *align(4) DeviceGroupPresentModeFlagsKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDevicePresentRectanglesKHR(
physicalDevice: PhysicalDevice,
surface: SurfaceKHR,
pRectCount: *u32,
pRects: ?[*]Rect2D,
) callconv(CallConv) Result;
pub extern fn vkAcquireNextImage2KHR(
device: Device,
pAcquireInfo: *const AcquireNextImageInfoKHR,
pImageIndex: *u32,
) callconv(CallConv) Result;
pub inline fn CreateSwapchainKHR(device: Device, createInfo: SwapchainCreateInfoKHR, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_SURFACE_LOST_KHR,VK_NATIVE_WINDOW_IN_USE_KHR,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!SwapchainKHR {
var out_swapchain: SwapchainKHR = undefined;
const result = vkCreateSwapchainKHR(device, &createInfo, pAllocator, &out_swapchain);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
.ERROR_NATIVE_WINDOW_IN_USE_KHR => error.VK_NATIVE_WINDOW_IN_USE_KHR,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_swapchain;
}
pub const DestroySwapchainKHR = vkDestroySwapchainKHR;
pub const GetSwapchainImagesKHRResult = struct {
result: Result,
swapchainImages: []Image,
};
pub inline fn GetSwapchainImagesKHR(device: Device, swapchain: SwapchainKHR, swapchainImages: []Image) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetSwapchainImagesKHRResult {
var returnValues: GetSwapchainImagesKHRResult = undefined;
var swapchainImageCount: u32 = @intCast(u32, swapchainImages.len);
const result = vkGetSwapchainImagesKHR(device, swapchain, &swapchainImageCount, swapchainImages.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.swapchainImages = swapchainImages[0..swapchainImageCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetSwapchainImagesCountKHR(device: Device, swapchain: SwapchainKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_swapchainImageCount: u32 = undefined;
const result = vkGetSwapchainImagesKHR(device, swapchain, &out_swapchainImageCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_swapchainImageCount;
}
pub const AcquireNextImageKHRResult = struct {
result: Result,
imageIndex: u32,
};
pub inline fn AcquireNextImageKHR(device: Device, swapchain: SwapchainKHR, timeout: u64, semaphore: ?Semaphore, fence: ?Fence) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,VK_UNDOCUMENTED_ERROR}!AcquireNextImageKHRResult {
var returnValues: AcquireNextImageKHRResult = undefined;
const result = vkAcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, &returnValues.imageIndex);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
.ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => error.VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.result = result;
return returnValues;
}
pub inline fn QueuePresentKHR(queue: Queue, presentInfo: PresentInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkQueuePresentKHR(queue, &presentInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
.ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => error.VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn GetDeviceGroupPresentCapabilitiesKHR(device: Device) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DeviceGroupPresentCapabilitiesKHR {
var out_deviceGroupPresentCapabilities: DeviceGroupPresentCapabilitiesKHR = undefined;
const result = vkGetDeviceGroupPresentCapabilitiesKHR(device, &out_deviceGroupPresentCapabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_deviceGroupPresentCapabilities;
}
pub inline fn GetDeviceGroupSurfacePresentModesKHR(device: Device, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!DeviceGroupPresentModeFlagsKHR {
var out_modes: DeviceGroupPresentModeFlagsKHR align(4) = undefined;
const result = vkGetDeviceGroupSurfacePresentModesKHR(device, surface, &out_modes);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_modes;
}
pub const GetPhysicalDevicePresentRectanglesKHRResult = struct {
result: Result,
rects: []Rect2D,
};
pub inline fn GetPhysicalDevicePresentRectanglesKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR, rects: []Rect2D) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDevicePresentRectanglesKHRResult {
var returnValues: GetPhysicalDevicePresentRectanglesKHRResult = undefined;
var rectCount: u32 = @intCast(u32, rects.len);
const result = vkGetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, &rectCount, rects.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.rects = rects[0..rectCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDevicePresentRectanglesCountKHR(physicalDevice: PhysicalDevice, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_rectCount: u32 = undefined;
const result = vkGetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, &out_rectCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_rectCount;
}
pub const AcquireNextImage2KHRResult = struct {
result: Result,
imageIndex: u32,
};
pub inline fn AcquireNextImage2KHR(device: Device, acquireInfo: AcquireNextImageInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,VK_UNDOCUMENTED_ERROR}!AcquireNextImage2KHRResult {
var returnValues: AcquireNextImage2KHRResult = undefined;
const result = vkAcquireNextImage2KHR(device, &acquireInfo, &returnValues.imageIndex);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
.ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => error.VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.result = result;
return returnValues;
}
pub const KHR_display = 1;
pub const DisplayKHR = *@OpaqueType();
pub const DisplayModeKHR = *@OpaqueType();
pub const KHR_DISPLAY_SPEC_VERSION = 23;
pub const KHR_DISPLAY_EXTENSION_NAME = "VK_KHR_display";
pub const DisplayPlaneAlphaFlagsKHR = packed struct {
opaque: bool = false,
global: bool = false,
perPixel: bool = false,
perPixelPremultiplied: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DisplayModeCreateFlagsKHR = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DisplaySurfaceCreateFlagsKHR = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DisplayPropertiesKHR = extern struct {
display: DisplayKHR,
displayName: CString,
physicalDimensions: Extent2D,
physicalResolution: Extent2D,
supportedTransforms: SurfaceTransformFlagsKHR align(4) = SurfaceTransformFlagsKHR{},
planeReorderPossible: Bool32,
persistentContent: Bool32,
};
pub const DisplayModeParametersKHR = extern struct {
visibleRegion: Extent2D,
refreshRate: u32,
};
pub const DisplayModePropertiesKHR = extern struct {
displayMode: DisplayModeKHR,
parameters: DisplayModeParametersKHR,
};
pub const DisplayModeCreateInfoKHR = extern struct {
sType: StructureType = .DISPLAY_MODE_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
flags: DisplayModeCreateFlagsKHR align(4) = DisplayModeCreateFlagsKHR{},
parameters: DisplayModeParametersKHR,
};
pub const DisplayPlaneCapabilitiesKHR = extern struct {
supportedAlpha: DisplayPlaneAlphaFlagsKHR align(4) = DisplayPlaneAlphaFlagsKHR{},
minSrcPosition: Offset2D,
maxSrcPosition: Offset2D,
minSrcExtent: Extent2D,
maxSrcExtent: Extent2D,
minDstPosition: Offset2D,
maxDstPosition: Offset2D,
minDstExtent: Extent2D,
maxDstExtent: Extent2D,
};
pub const DisplayPlanePropertiesKHR = extern struct {
currentDisplay: DisplayKHR,
currentStackIndex: u32,
};
pub const DisplaySurfaceCreateInfoKHR = extern struct {
sType: StructureType = .DISPLAY_SURFACE_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
flags: DisplaySurfaceCreateFlagsKHR align(4) = DisplaySurfaceCreateFlagsKHR{},
displayMode: DisplayModeKHR,
planeIndex: u32,
planeStackIndex: u32,
transform: SurfaceTransformFlagsKHR align(4),
globalAlpha: f32,
alphaMode: DisplayPlaneAlphaFlagsKHR align(4),
imageExtent: Extent2D,
};
pub extern fn vkGetPhysicalDeviceDisplayPropertiesKHR(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]DisplayPropertiesKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]DisplayPlanePropertiesKHR,
) callconv(CallConv) Result;
pub extern fn vkGetDisplayPlaneSupportedDisplaysKHR(
physicalDevice: PhysicalDevice,
planeIndex: u32,
pDisplayCount: *u32,
pDisplays: ?[*]DisplayKHR,
) callconv(CallConv) Result;
pub extern fn vkGetDisplayModePropertiesKHR(
physicalDevice: PhysicalDevice,
display: DisplayKHR,
pPropertyCount: *u32,
pProperties: ?[*]DisplayModePropertiesKHR,
) callconv(CallConv) Result;
pub extern fn vkCreateDisplayModeKHR(
physicalDevice: PhysicalDevice,
display: DisplayKHR,
pCreateInfo: *const DisplayModeCreateInfoKHR,
pAllocator: ?*const AllocationCallbacks,
pMode: *DisplayModeKHR,
) callconv(CallConv) Result;
pub extern fn vkGetDisplayPlaneCapabilitiesKHR(
physicalDevice: PhysicalDevice,
mode: DisplayModeKHR,
planeIndex: u32,
pCapabilities: *DisplayPlaneCapabilitiesKHR,
) callconv(CallConv) Result;
pub extern fn vkCreateDisplayPlaneSurfaceKHR(
instance: Instance,
pCreateInfo: *const DisplaySurfaceCreateInfoKHR,
pAllocator: ?*const AllocationCallbacks,
pSurface: *SurfaceKHR,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceDisplayPropertiesKHRResult = struct {
result: Result,
properties: []DisplayPropertiesKHR,
};
pub inline fn GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice: PhysicalDevice, properties: []DisplayPropertiesKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceDisplayPropertiesKHRResult {
var returnValues: GetPhysicalDeviceDisplayPropertiesKHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceDisplayPropertiesCountKHR(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const GetPhysicalDeviceDisplayPlanePropertiesKHRResult = struct {
result: Result,
properties: []DisplayPlanePropertiesKHR,
};
pub inline fn GetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice: PhysicalDevice, properties: []DisplayPlanePropertiesKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceDisplayPlanePropertiesKHRResult {
var returnValues: GetPhysicalDeviceDisplayPlanePropertiesKHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceDisplayPlanePropertiesCountKHR(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const GetDisplayPlaneSupportedDisplaysKHRResult = struct {
result: Result,
displays: []DisplayKHR,
};
pub inline fn GetDisplayPlaneSupportedDisplaysKHR(physicalDevice: PhysicalDevice, planeIndex: u32, displays: []DisplayKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetDisplayPlaneSupportedDisplaysKHRResult {
var returnValues: GetDisplayPlaneSupportedDisplaysKHRResult = undefined;
var displayCount: u32 = @intCast(u32, displays.len);
const result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, &displayCount, displays.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.displays = displays[0..displayCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetDisplayPlaneSupportedDisplaysCountKHR(physicalDevice: PhysicalDevice, planeIndex: u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_displayCount: u32 = undefined;
const result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, &out_displayCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_displayCount;
}
pub const GetDisplayModePropertiesKHRResult = struct {
result: Result,
properties: []DisplayModePropertiesKHR,
};
pub inline fn GetDisplayModePropertiesKHR(physicalDevice: PhysicalDevice, display: DisplayKHR, properties: []DisplayModePropertiesKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetDisplayModePropertiesKHRResult {
var returnValues: GetDisplayModePropertiesKHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetDisplayModePropertiesCountKHR(physicalDevice: PhysicalDevice, display: DisplayKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub inline fn CreateDisplayModeKHR(physicalDevice: PhysicalDevice, display: DisplayKHR, createInfo: DisplayModeCreateInfoKHR, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!DisplayModeKHR {
var out_mode: DisplayModeKHR = undefined;
const result = vkCreateDisplayModeKHR(physicalDevice, display, &createInfo, pAllocator, &out_mode);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_mode;
}
pub inline fn GetDisplayPlaneCapabilitiesKHR(physicalDevice: PhysicalDevice, mode: DisplayModeKHR, planeIndex: u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DisplayPlaneCapabilitiesKHR {
var out_capabilities: DisplayPlaneCapabilitiesKHR = undefined;
const result = vkGetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, &out_capabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_capabilities;
}
pub inline fn CreateDisplayPlaneSurfaceKHR(instance: Instance, createInfo: DisplaySurfaceCreateInfoKHR, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!SurfaceKHR {
var out_surface: SurfaceKHR = undefined;
const result = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo, pAllocator, &out_surface);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surface;
}
pub const KHR_display_swapchain = 1;
pub const KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION = 10;
pub const KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME = "VK_KHR_display_swapchain";
pub const DisplayPresentInfoKHR = extern struct {
sType: StructureType = .DISPLAY_PRESENT_INFO_KHR,
pNext: ?*const c_void = null,
srcRect: Rect2D,
dstRect: Rect2D,
persistent: Bool32,
};
pub extern fn vkCreateSharedSwapchainsKHR(
device: Device,
swapchainCount: u32,
pCreateInfos: [*]const SwapchainCreateInfoKHR,
pAllocator: ?*const AllocationCallbacks,
pSwapchains: [*]SwapchainKHR,
) callconv(CallConv) Result;
pub inline fn CreateSharedSwapchainsKHR(device: Device, createInfos: []const SwapchainCreateInfoKHR, pAllocator: ?*const AllocationCallbacks, swapchains: []SwapchainKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INCOMPATIBLE_DISPLAY_KHR,VK_DEVICE_LOST,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!void {
assert(swapchains.len >= createInfos.len);
const result = vkCreateSharedSwapchainsKHR(device, @intCast(u32, createInfos.len), createInfos.ptr, pAllocator, swapchains.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INCOMPATIBLE_DISPLAY_KHR => error.VK_INCOMPATIBLE_DISPLAY_KHR,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const KHR_sampler_mirror_clamp_to_edge = 1;
pub const KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION = 3;
pub const KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME = "VK_KHR_sampler_mirror_clamp_to_edge";
pub const KHR_multiview = 1;
pub const KHR_MULTIVIEW_SPEC_VERSION = 1;
pub const KHR_MULTIVIEW_EXTENSION_NAME = "VK_KHR_multiview";
pub const RenderPassMultiviewCreateInfoKHR = RenderPassMultiviewCreateInfo;
pub const PhysicalDeviceMultiviewFeaturesKHR = PhysicalDeviceMultiviewFeatures;
pub const PhysicalDeviceMultiviewPropertiesKHR = PhysicalDeviceMultiviewProperties;
pub const KHR_get_physical_device_properties2 = 1;
pub const KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION = 2;
pub const KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME = "VK_KHR_get_physical_device_properties2";
pub const PhysicalDeviceFeatures2KHR = PhysicalDeviceFeatures2;
pub const PhysicalDeviceProperties2KHR = PhysicalDeviceProperties2;
pub const FormatProperties2KHR = FormatProperties2;
pub const ImageFormatProperties2KHR = ImageFormatProperties2;
pub const PhysicalDeviceImageFormatInfo2KHR = PhysicalDeviceImageFormatInfo2;
pub const QueueFamilyProperties2KHR = QueueFamilyProperties2;
pub const PhysicalDeviceMemoryProperties2KHR = PhysicalDeviceMemoryProperties2;
pub const SparseImageFormatProperties2KHR = SparseImageFormatProperties2;
pub const PhysicalDeviceSparseImageFormatInfo2KHR = PhysicalDeviceSparseImageFormatInfo2;
pub extern fn vkGetPhysicalDeviceFeatures2KHR(
physicalDevice: PhysicalDevice,
pFeatures: *PhysicalDeviceFeatures2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceProperties2KHR(
physicalDevice: PhysicalDevice,
pProperties: *PhysicalDeviceProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceFormatProperties2KHR(
physicalDevice: PhysicalDevice,
format: Format,
pFormatProperties: *FormatProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceImageFormatProperties2KHR(
physicalDevice: PhysicalDevice,
pImageFormatInfo: *const PhysicalDeviceImageFormatInfo2,
pImageFormatProperties: *ImageFormatProperties2,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceQueueFamilyProperties2KHR(
physicalDevice: PhysicalDevice,
pQueueFamilyPropertyCount: *u32,
pQueueFamilyProperties: ?[*]QueueFamilyProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceMemoryProperties2KHR(
physicalDevice: PhysicalDevice,
pMemoryProperties: *PhysicalDeviceMemoryProperties2,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceSparseImageFormatProperties2KHR(
physicalDevice: PhysicalDevice,
pFormatInfo: *const PhysicalDeviceSparseImageFormatInfo2,
pPropertyCount: *u32,
pProperties: ?[*]SparseImageFormatProperties2,
) callconv(CallConv) void;
pub inline fn GetPhysicalDeviceFeatures2KHR(physicalDevice: PhysicalDevice) PhysicalDeviceFeatures2 {
var out_features: PhysicalDeviceFeatures2 = undefined;
vkGetPhysicalDeviceFeatures2KHR(physicalDevice, &out_features);
return out_features;
}
pub inline fn GetPhysicalDeviceProperties2KHR(physicalDevice: PhysicalDevice) PhysicalDeviceProperties2 {
var out_properties: PhysicalDeviceProperties2 = undefined;
vkGetPhysicalDeviceProperties2KHR(physicalDevice, &out_properties);
return out_properties;
}
pub inline fn GetPhysicalDeviceFormatProperties2KHR(physicalDevice: PhysicalDevice, format: Format) FormatProperties2 {
var out_formatProperties: FormatProperties2 = undefined;
vkGetPhysicalDeviceFormatProperties2KHR(physicalDevice, format, &out_formatProperties);
return out_formatProperties;
}
pub inline fn GetPhysicalDeviceImageFormatProperties2KHR(physicalDevice: PhysicalDevice, imageFormatInfo: PhysicalDeviceImageFormatInfo2) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FORMAT_NOT_SUPPORTED,VK_UNDOCUMENTED_ERROR}!ImageFormatProperties2 {
var out_imageFormatProperties: ImageFormatProperties2 = undefined;
const result = vkGetPhysicalDeviceImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &out_imageFormatProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FORMAT_NOT_SUPPORTED => error.VK_FORMAT_NOT_SUPPORTED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_imageFormatProperties;
}
pub inline fn GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice: PhysicalDevice, queueFamilyProperties: []QueueFamilyProperties2) []QueueFamilyProperties2 {
var out_queueFamilyProperties: []QueueFamilyProperties2 = undefined;
var queueFamilyPropertyCount: u32 = @intCast(u32, queueFamilyProperties.len);
vkGetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &queueFamilyPropertyCount, queueFamilyProperties.ptr);
out_queueFamilyProperties = queueFamilyProperties[0..queueFamilyPropertyCount];
return out_queueFamilyProperties;
}
pub inline fn GetPhysicalDeviceQueueFamilyProperties2CountKHR(physicalDevice: PhysicalDevice) u32 {
var out_queueFamilyPropertyCount: u32 = undefined;
vkGetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &out_queueFamilyPropertyCount, null);
return out_queueFamilyPropertyCount;
}
pub inline fn GetPhysicalDeviceMemoryProperties2KHR(physicalDevice: PhysicalDevice) PhysicalDeviceMemoryProperties2 {
var out_memoryProperties: PhysicalDeviceMemoryProperties2 = undefined;
vkGetPhysicalDeviceMemoryProperties2KHR(physicalDevice, &out_memoryProperties);
return out_memoryProperties;
}
pub inline fn GetPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice: PhysicalDevice, formatInfo: PhysicalDeviceSparseImageFormatInfo2, properties: []SparseImageFormatProperties2) []SparseImageFormatProperties2 {
var out_properties: []SparseImageFormatProperties2 = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
vkGetPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &formatInfo, &propertyCount, properties.ptr);
out_properties = properties[0..propertyCount];
return out_properties;
}
pub inline fn GetPhysicalDeviceSparseImageFormatProperties2CountKHR(physicalDevice: PhysicalDevice, formatInfo: PhysicalDeviceSparseImageFormatInfo2) u32 {
var out_propertyCount: u32 = undefined;
vkGetPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &formatInfo, &out_propertyCount, null);
return out_propertyCount;
}
pub const KHR_device_group = 1;
pub const KHR_DEVICE_GROUP_SPEC_VERSION = 4;
pub const KHR_DEVICE_GROUP_EXTENSION_NAME = "VK_KHR_device_group";
pub const PeerMemoryFeatureFlagsKHR = PeerMemoryFeatureFlags;
pub const MemoryAllocateFlagsKHR = MemoryAllocateFlags;
pub const MemoryAllocateFlagsInfoKHR = MemoryAllocateFlagsInfo;
pub const DeviceGroupRenderPassBeginInfoKHR = DeviceGroupRenderPassBeginInfo;
pub const DeviceGroupCommandBufferBeginInfoKHR = DeviceGroupCommandBufferBeginInfo;
pub const DeviceGroupSubmitInfoKHR = DeviceGroupSubmitInfo;
pub const DeviceGroupBindSparseInfoKHR = DeviceGroupBindSparseInfo;
pub const BindBufferMemoryDeviceGroupInfoKHR = BindBufferMemoryDeviceGroupInfo;
pub const BindImageMemoryDeviceGroupInfoKHR = BindImageMemoryDeviceGroupInfo;
pub extern fn vkGetDeviceGroupPeerMemoryFeaturesKHR(
device: Device,
heapIndex: u32,
localDeviceIndex: u32,
remoteDeviceIndex: u32,
pPeerMemoryFeatures: *align(4) PeerMemoryFeatureFlags,
) callconv(CallConv) void;
pub extern fn vkCmdSetDeviceMaskKHR(
commandBuffer: CommandBuffer,
deviceMask: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDispatchBaseKHR(
commandBuffer: CommandBuffer,
baseGroupX: u32,
baseGroupY: u32,
baseGroupZ: u32,
groupCountX: u32,
groupCountY: u32,
groupCountZ: u32,
) callconv(CallConv) void;
pub inline fn GetDeviceGroupPeerMemoryFeaturesKHR(device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32) PeerMemoryFeatureFlags {
var out_peerMemoryFeatures: PeerMemoryFeatureFlags align(4) = undefined;
vkGetDeviceGroupPeerMemoryFeaturesKHR(device, heapIndex, localDeviceIndex, remoteDeviceIndex, &out_peerMemoryFeatures);
return out_peerMemoryFeatures;
}
pub const CmdSetDeviceMaskKHR = vkCmdSetDeviceMaskKHR;
pub const CmdDispatchBaseKHR = vkCmdDispatchBaseKHR;
pub const KHR_shader_draw_parameters = 1;
pub const KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION = 1;
pub const KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME = "VK_KHR_shader_draw_parameters";
pub const KHR_maintenance1 = 1;
pub const KHR_MAINTENANCE1_SPEC_VERSION = 2;
pub const KHR_MAINTENANCE1_EXTENSION_NAME = "VK_KHR_maintenance1";
pub const CommandPoolTrimFlagsKHR = CommandPoolTrimFlags;
pub extern fn vkTrimCommandPoolKHR(
device: Device,
commandPool: CommandPool,
flags: CommandPoolTrimFlags.IntType,
) callconv(CallConv) void;
pub inline fn TrimCommandPoolKHR(device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) void {
vkTrimCommandPoolKHR(device, commandPool, flags.toInt());
}
pub const KHR_device_group_creation = 1;
pub const KHR_DEVICE_GROUP_CREATION_SPEC_VERSION = 1;
pub const KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME = "VK_KHR_device_group_creation";
pub const MAX_DEVICE_GROUP_SIZE_KHR = MAX_DEVICE_GROUP_SIZE;
pub const PhysicalDeviceGroupPropertiesKHR = PhysicalDeviceGroupProperties;
pub const DeviceGroupDeviceCreateInfoKHR = DeviceGroupDeviceCreateInfo;
pub extern fn vkEnumeratePhysicalDeviceGroupsKHR(
instance: Instance,
pPhysicalDeviceGroupCount: *u32,
pPhysicalDeviceGroupProperties: ?[*]PhysicalDeviceGroupProperties,
) callconv(CallConv) Result;
pub const EnumeratePhysicalDeviceGroupsKHRResult = struct {
result: Result,
physicalDeviceGroupProperties: []PhysicalDeviceGroupProperties,
};
pub inline fn EnumeratePhysicalDeviceGroupsKHR(instance: Instance, physicalDeviceGroupProperties: []PhysicalDeviceGroupProperties) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!EnumeratePhysicalDeviceGroupsKHRResult {
var returnValues: EnumeratePhysicalDeviceGroupsKHRResult = undefined;
var physicalDeviceGroupCount: u32 = @intCast(u32, physicalDeviceGroupProperties.len);
const result = vkEnumeratePhysicalDeviceGroupsKHR(instance, &physicalDeviceGroupCount, physicalDeviceGroupProperties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.physicalDeviceGroupProperties = physicalDeviceGroupProperties[0..physicalDeviceGroupCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumeratePhysicalDeviceGroupsCountKHR(instance: Instance) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!u32 {
var out_physicalDeviceGroupCount: u32 = undefined;
const result = vkEnumeratePhysicalDeviceGroupsKHR(instance, &out_physicalDeviceGroupCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_physicalDeviceGroupCount;
}
pub const KHR_external_memory_capabilities = 1;
pub const KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME = "VK_KHR_external_memory_capabilities";
pub const LUID_SIZE_KHR = LUID_SIZE;
pub const ExternalMemoryHandleTypeFlagsKHR = ExternalMemoryHandleTypeFlags;
pub const ExternalMemoryFeatureFlagsKHR = ExternalMemoryFeatureFlags;
pub const ExternalMemoryPropertiesKHR = ExternalMemoryProperties;
pub const PhysicalDeviceExternalImageFormatInfoKHR = PhysicalDeviceExternalImageFormatInfo;
pub const ExternalImageFormatPropertiesKHR = ExternalImageFormatProperties;
pub const PhysicalDeviceExternalBufferInfoKHR = PhysicalDeviceExternalBufferInfo;
pub const ExternalBufferPropertiesKHR = ExternalBufferProperties;
pub const PhysicalDeviceIDPropertiesKHR = PhysicalDeviceIDProperties;
pub extern fn vkGetPhysicalDeviceExternalBufferPropertiesKHR(
physicalDevice: PhysicalDevice,
pExternalBufferInfo: *const PhysicalDeviceExternalBufferInfo,
pExternalBufferProperties: *ExternalBufferProperties,
) callconv(CallConv) void;
pub inline fn GetPhysicalDeviceExternalBufferPropertiesKHR(physicalDevice: PhysicalDevice, externalBufferInfo: PhysicalDeviceExternalBufferInfo) ExternalBufferProperties {
var out_externalBufferProperties: ExternalBufferProperties = undefined;
vkGetPhysicalDeviceExternalBufferPropertiesKHR(physicalDevice, &externalBufferInfo, &out_externalBufferProperties);
return out_externalBufferProperties;
}
pub const KHR_external_memory = 1;
pub const KHR_EXTERNAL_MEMORY_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_MEMORY_EXTENSION_NAME = "VK_KHR_external_memory";
pub const QUEUE_FAMILY_EXTERNAL_KHR = QUEUE_FAMILY_EXTERNAL;
pub const ExternalMemoryImageCreateInfoKHR = ExternalMemoryImageCreateInfo;
pub const ExternalMemoryBufferCreateInfoKHR = ExternalMemoryBufferCreateInfo;
pub const ExportMemoryAllocateInfoKHR = ExportMemoryAllocateInfo;
pub const KHR_external_memory_fd = 1;
pub const KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME = "VK_KHR_external_memory_fd";
pub const ImportMemoryFdInfoKHR = extern struct {
sType: StructureType = .IMPORT_MEMORY_FD_INFO_KHR,
pNext: ?*const c_void = null,
handleType: ExternalMemoryHandleTypeFlags align(4) = ExternalMemoryHandleTypeFlags{},
fd: c_int,
};
pub const MemoryFdPropertiesKHR = extern struct {
sType: StructureType = .MEMORY_FD_PROPERTIES_KHR,
pNext: ?*c_void = null,
memoryTypeBits: u32,
};
pub const MemoryGetFdInfoKHR = extern struct {
sType: StructureType = .MEMORY_GET_FD_INFO_KHR,
pNext: ?*const c_void = null,
memory: DeviceMemory,
handleType: ExternalMemoryHandleTypeFlags align(4),
};
pub extern fn vkGetMemoryFdKHR(
device: Device,
pGetFdInfo: *const MemoryGetFdInfoKHR,
pFd: *c_int,
) callconv(CallConv) Result;
pub extern fn vkGetMemoryFdPropertiesKHR(
device: Device,
handleType: ExternalMemoryHandleTypeFlags.IntType,
fd: c_int,
pMemoryFdProperties: *MemoryFdPropertiesKHR,
) callconv(CallConv) Result;
pub inline fn GetMemoryFdKHR(device: Device, getFdInfo: MemoryGetFdInfoKHR) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!c_int {
var out_fd: c_int = undefined;
const result = vkGetMemoryFdKHR(device, &getFdInfo, &out_fd);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_fd;
}
pub inline fn GetMemoryFdPropertiesKHR(device: Device, handleType: ExternalMemoryHandleTypeFlags, fd: c_int) error{VK_INVALID_EXTERNAL_HANDLE,VK_UNDOCUMENTED_ERROR}!MemoryFdPropertiesKHR {
var out_memoryFdProperties: MemoryFdPropertiesKHR = undefined;
const result = vkGetMemoryFdPropertiesKHR(device, handleType.toInt(), fd, &out_memoryFdProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_INVALID_EXTERNAL_HANDLE => error.VK_INVALID_EXTERNAL_HANDLE,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_memoryFdProperties;
}
pub const KHR_external_semaphore_capabilities = 1;
pub const KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME = "VK_KHR_external_semaphore_capabilities";
pub const ExternalSemaphoreHandleTypeFlagsKHR = ExternalSemaphoreHandleTypeFlags;
pub const ExternalSemaphoreFeatureFlagsKHR = ExternalSemaphoreFeatureFlags;
pub const PhysicalDeviceExternalSemaphoreInfoKHR = PhysicalDeviceExternalSemaphoreInfo;
pub const ExternalSemaphorePropertiesKHR = ExternalSemaphoreProperties;
pub extern fn vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(
physicalDevice: PhysicalDevice,
pExternalSemaphoreInfo: *const PhysicalDeviceExternalSemaphoreInfo,
pExternalSemaphoreProperties: *ExternalSemaphoreProperties,
) callconv(CallConv) void;
pub inline fn GetPhysicalDeviceExternalSemaphorePropertiesKHR(physicalDevice: PhysicalDevice, externalSemaphoreInfo: PhysicalDeviceExternalSemaphoreInfo) ExternalSemaphoreProperties {
var out_externalSemaphoreProperties: ExternalSemaphoreProperties = undefined;
vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(physicalDevice, &externalSemaphoreInfo, &out_externalSemaphoreProperties);
return out_externalSemaphoreProperties;
}
pub const KHR_external_semaphore = 1;
pub const KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME = "VK_KHR_external_semaphore";
pub const SemaphoreImportFlagsKHR = SemaphoreImportFlags;
pub const ExportSemaphoreCreateInfoKHR = ExportSemaphoreCreateInfo;
pub const KHR_external_semaphore_fd = 1;
pub const KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME = "VK_KHR_external_semaphore_fd";
pub const ImportSemaphoreFdInfoKHR = extern struct {
sType: StructureType = .IMPORT_SEMAPHORE_FD_INFO_KHR,
pNext: ?*const c_void = null,
semaphore: Semaphore,
flags: SemaphoreImportFlags align(4) = SemaphoreImportFlags{},
handleType: ExternalSemaphoreHandleTypeFlags align(4),
fd: c_int,
};
pub const SemaphoreGetFdInfoKHR = extern struct {
sType: StructureType = .SEMAPHORE_GET_FD_INFO_KHR,
pNext: ?*const c_void = null,
semaphore: Semaphore,
handleType: ExternalSemaphoreHandleTypeFlags align(4),
};
pub extern fn vkImportSemaphoreFdKHR(
device: Device,
pImportSemaphoreFdInfo: *const ImportSemaphoreFdInfoKHR,
) callconv(CallConv) Result;
pub extern fn vkGetSemaphoreFdKHR(
device: Device,
pGetFdInfo: *const SemaphoreGetFdInfoKHR,
pFd: *c_int,
) callconv(CallConv) Result;
pub inline fn ImportSemaphoreFdKHR(device: Device, importSemaphoreFdInfo: ImportSemaphoreFdInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_INVALID_EXTERNAL_HANDLE,VK_UNDOCUMENTED_ERROR}!void {
const result = vkImportSemaphoreFdKHR(device, &importSemaphoreFdInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_INVALID_EXTERNAL_HANDLE => error.VK_INVALID_EXTERNAL_HANDLE,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetSemaphoreFdKHR(device: Device, getFdInfo: SemaphoreGetFdInfoKHR) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!c_int {
var out_fd: c_int = undefined;
const result = vkGetSemaphoreFdKHR(device, &getFdInfo, &out_fd);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_fd;
}
pub const KHR_push_descriptor = 1;
pub const KHR_PUSH_DESCRIPTOR_SPEC_VERSION = 2;
pub const KHR_PUSH_DESCRIPTOR_EXTENSION_NAME = "VK_KHR_push_descriptor";
pub const PhysicalDevicePushDescriptorPropertiesKHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR,
pNext: ?*c_void = null,
maxPushDescriptors: u32,
};
pub extern fn vkCmdPushDescriptorSetKHR(
commandBuffer: CommandBuffer,
pipelineBindPoint: PipelineBindPoint,
layout: PipelineLayout,
set: u32,
descriptorWriteCount: u32,
pDescriptorWrites: [*]const WriteDescriptorSet,
) callconv(CallConv) void;
pub extern fn vkCmdPushDescriptorSetWithTemplateKHR(
commandBuffer: CommandBuffer,
descriptorUpdateTemplate: DescriptorUpdateTemplate,
layout: PipelineLayout,
set: u32,
pData: ?*const c_void,
) callconv(CallConv) void;
pub inline fn CmdPushDescriptorSetKHR(commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, set: u32, descriptorWrites: []const WriteDescriptorSet) void {
vkCmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, @intCast(u32, descriptorWrites.len), descriptorWrites.ptr);
}
pub const CmdPushDescriptorSetWithTemplateKHR = vkCmdPushDescriptorSetWithTemplateKHR;
pub const KHR_shader_float16_int8 = 1;
pub const KHR_SHADER_FLOAT16_INT8_SPEC_VERSION = 1;
pub const KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME = "VK_KHR_shader_float16_int8";
pub const PhysicalDeviceShaderFloat16Int8FeaturesKHR = PhysicalDeviceShaderFloat16Int8Features;
pub const PhysicalDeviceFloat16Int8FeaturesKHR = PhysicalDeviceShaderFloat16Int8Features;
pub const KHR_16bit_storage = 1;
pub const KHR_16BIT_STORAGE_SPEC_VERSION = 1;
pub const KHR_16BIT_STORAGE_EXTENSION_NAME = "VK_KHR_16bit_storage";
pub const PhysicalDevice16BitStorageFeaturesKHR = PhysicalDevice16BitStorageFeatures;
pub const KHR_incremental_present = 1;
pub const KHR_INCREMENTAL_PRESENT_SPEC_VERSION = 1;
pub const KHR_INCREMENTAL_PRESENT_EXTENSION_NAME = "VK_KHR_incremental_present";
pub const RectLayerKHR = extern struct {
offset: Offset2D,
extent: Extent2D,
layer: u32,
};
pub const PresentRegionKHR = extern struct {
rectangleCount: u32 = 0,
pRectangles: ?[*]const RectLayerKHR = null,
};
pub const PresentRegionsKHR = extern struct {
sType: StructureType = .PRESENT_REGIONS_KHR,
pNext: ?*const c_void = null,
swapchainCount: u32,
pRegions: ?[*]const PresentRegionKHR = null,
};
pub const KHR_descriptor_update_template = 1;
pub const DescriptorUpdateTemplateKHR = DescriptorUpdateTemplate;
pub const KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION = 1;
pub const KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME = "VK_KHR_descriptor_update_template";
pub const DescriptorUpdateTemplateTypeKHR = DescriptorUpdateTemplateType;
pub const DescriptorUpdateTemplateCreateFlagsKHR = DescriptorUpdateTemplateCreateFlags;
pub const DescriptorUpdateTemplateEntryKHR = DescriptorUpdateTemplateEntry;
pub const DescriptorUpdateTemplateCreateInfoKHR = DescriptorUpdateTemplateCreateInfo;
pub extern fn vkCreateDescriptorUpdateTemplateKHR(
device: Device,
pCreateInfo: *const DescriptorUpdateTemplateCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pDescriptorUpdateTemplate: *DescriptorUpdateTemplate,
) callconv(CallConv) Result;
pub extern fn vkDestroyDescriptorUpdateTemplateKHR(
device: Device,
descriptorUpdateTemplate: ?DescriptorUpdateTemplate,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkUpdateDescriptorSetWithTemplateKHR(
device: Device,
descriptorSet: DescriptorSet,
descriptorUpdateTemplate: DescriptorUpdateTemplate,
pData: ?*const c_void,
) callconv(CallConv) void;
pub inline fn CreateDescriptorUpdateTemplateKHR(device: Device, createInfo: DescriptorUpdateTemplateCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DescriptorUpdateTemplate {
var out_descriptorUpdateTemplate: DescriptorUpdateTemplate = undefined;
const result = vkCreateDescriptorUpdateTemplateKHR(device, &createInfo, pAllocator, &out_descriptorUpdateTemplate);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_descriptorUpdateTemplate;
}
pub const DestroyDescriptorUpdateTemplateKHR = vkDestroyDescriptorUpdateTemplateKHR;
pub const UpdateDescriptorSetWithTemplateKHR = vkUpdateDescriptorSetWithTemplateKHR;
pub const KHR_imageless_framebuffer = 1;
pub const KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION = 1;
pub const KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME = "VK_KHR_imageless_framebuffer";
pub const PhysicalDeviceImagelessFramebufferFeaturesKHR = PhysicalDeviceImagelessFramebufferFeatures;
pub const FramebufferAttachmentsCreateInfoKHR = FramebufferAttachmentsCreateInfo;
pub const FramebufferAttachmentImageInfoKHR = FramebufferAttachmentImageInfo;
pub const RenderPassAttachmentBeginInfoKHR = RenderPassAttachmentBeginInfo;
pub const KHR_create_renderpass2 = 1;
pub const KHR_CREATE_RENDERPASS_2_SPEC_VERSION = 1;
pub const KHR_CREATE_RENDERPASS_2_EXTENSION_NAME = "VK_KHR_create_renderpass2";
pub const RenderPassCreateInfo2KHR = RenderPassCreateInfo2;
pub const AttachmentDescription2KHR = AttachmentDescription2;
pub const AttachmentReference2KHR = AttachmentReference2;
pub const SubpassDescription2KHR = SubpassDescription2;
pub const SubpassDependency2KHR = SubpassDependency2;
pub const SubpassBeginInfoKHR = SubpassBeginInfo;
pub const SubpassEndInfoKHR = SubpassEndInfo;
pub extern fn vkCreateRenderPass2KHR(
device: Device,
pCreateInfo: *const RenderPassCreateInfo2,
pAllocator: ?*const AllocationCallbacks,
pRenderPass: *RenderPass,
) callconv(CallConv) Result;
pub extern fn vkCmdBeginRenderPass2KHR(
commandBuffer: CommandBuffer,
pRenderPassBegin: *const RenderPassBeginInfo,
pSubpassBeginInfo: *const SubpassBeginInfo,
) callconv(CallConv) void;
pub extern fn vkCmdNextSubpass2KHR(
commandBuffer: CommandBuffer,
pSubpassBeginInfo: *const SubpassBeginInfo,
pSubpassEndInfo: *const SubpassEndInfo,
) callconv(CallConv) void;
pub extern fn vkCmdEndRenderPass2KHR(
commandBuffer: CommandBuffer,
pSubpassEndInfo: *const SubpassEndInfo,
) callconv(CallConv) void;
pub inline fn CreateRenderPass2KHR(device: Device, createInfo: RenderPassCreateInfo2, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!RenderPass {
var out_renderPass: RenderPass = undefined;
const result = vkCreateRenderPass2KHR(device, &createInfo, pAllocator, &out_renderPass);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_renderPass;
}
pub inline fn CmdBeginRenderPass2KHR(commandBuffer: CommandBuffer, renderPassBegin: RenderPassBeginInfo, subpassBeginInfo: SubpassBeginInfo) void {
vkCmdBeginRenderPass2KHR(commandBuffer, &renderPassBegin, &subpassBeginInfo);
}
pub inline fn CmdNextSubpass2KHR(commandBuffer: CommandBuffer, subpassBeginInfo: SubpassBeginInfo, subpassEndInfo: SubpassEndInfo) void {
vkCmdNextSubpass2KHR(commandBuffer, &subpassBeginInfo, &subpassEndInfo);
}
pub inline fn CmdEndRenderPass2KHR(commandBuffer: CommandBuffer, subpassEndInfo: SubpassEndInfo) void {
vkCmdEndRenderPass2KHR(commandBuffer, &subpassEndInfo);
}
pub const KHR_shared_presentable_image = 1;
pub const KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION = 1;
pub const KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME = "VK_KHR_shared_presentable_image";
pub const SharedPresentSurfaceCapabilitiesKHR = extern struct {
sType: StructureType = .SHARED_PRESENT_SURFACE_CAPABILITIES_KHR,
pNext: ?*c_void = null,
sharedPresentSupportedUsageFlags: ImageUsageFlags align(4) = ImageUsageFlags{},
};
pub extern fn vkGetSwapchainStatusKHR(
device: Device,
swapchain: SwapchainKHR,
) callconv(CallConv) Result;
pub inline fn GetSwapchainStatusKHR(device: Device, swapchain: SwapchainKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkGetSwapchainStatusKHR(device, swapchain);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
.ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => error.VK_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub const KHR_external_fence_capabilities = 1;
pub const KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME = "VK_KHR_external_fence_capabilities";
pub const ExternalFenceHandleTypeFlagsKHR = ExternalFenceHandleTypeFlags;
pub const ExternalFenceFeatureFlagsKHR = ExternalFenceFeatureFlags;
pub const PhysicalDeviceExternalFenceInfoKHR = PhysicalDeviceExternalFenceInfo;
pub const ExternalFencePropertiesKHR = ExternalFenceProperties;
pub extern fn vkGetPhysicalDeviceExternalFencePropertiesKHR(
physicalDevice: PhysicalDevice,
pExternalFenceInfo: *const PhysicalDeviceExternalFenceInfo,
pExternalFenceProperties: *ExternalFenceProperties,
) callconv(CallConv) void;
pub inline fn GetPhysicalDeviceExternalFencePropertiesKHR(physicalDevice: PhysicalDevice, externalFenceInfo: PhysicalDeviceExternalFenceInfo) ExternalFenceProperties {
var out_externalFenceProperties: ExternalFenceProperties = undefined;
vkGetPhysicalDeviceExternalFencePropertiesKHR(physicalDevice, &externalFenceInfo, &out_externalFenceProperties);
return out_externalFenceProperties;
}
pub const KHR_external_fence = 1;
pub const KHR_EXTERNAL_FENCE_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_FENCE_EXTENSION_NAME = "VK_KHR_external_fence";
pub const FenceImportFlagsKHR = FenceImportFlags;
pub const ExportFenceCreateInfoKHR = ExportFenceCreateInfo;
pub const KHR_external_fence_fd = 1;
pub const KHR_EXTERNAL_FENCE_FD_SPEC_VERSION = 1;
pub const KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME = "VK_KHR_external_fence_fd";
pub const ImportFenceFdInfoKHR = extern struct {
sType: StructureType = .IMPORT_FENCE_FD_INFO_KHR,
pNext: ?*const c_void = null,
fence: Fence,
flags: FenceImportFlags align(4) = FenceImportFlags{},
handleType: ExternalFenceHandleTypeFlags align(4),
fd: c_int,
};
pub const FenceGetFdInfoKHR = extern struct {
sType: StructureType = .FENCE_GET_FD_INFO_KHR,
pNext: ?*const c_void = null,
fence: Fence,
handleType: ExternalFenceHandleTypeFlags align(4),
};
pub extern fn vkImportFenceFdKHR(
device: Device,
pImportFenceFdInfo: *const ImportFenceFdInfoKHR,
) callconv(CallConv) Result;
pub extern fn vkGetFenceFdKHR(
device: Device,
pGetFdInfo: *const FenceGetFdInfoKHR,
pFd: *c_int,
) callconv(CallConv) Result;
pub inline fn ImportFenceFdKHR(device: Device, importFenceFdInfo: ImportFenceFdInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_INVALID_EXTERNAL_HANDLE,VK_UNDOCUMENTED_ERROR}!void {
const result = vkImportFenceFdKHR(device, &importFenceFdInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_INVALID_EXTERNAL_HANDLE => error.VK_INVALID_EXTERNAL_HANDLE,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetFenceFdKHR(device: Device, getFdInfo: FenceGetFdInfoKHR) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!c_int {
var out_fd: c_int = undefined;
const result = vkGetFenceFdKHR(device, &getFdInfo, &out_fd);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_fd;
}
pub const KHR_performance_query = 1;
pub const KHR_PERFORMANCE_QUERY_SPEC_VERSION = 1;
pub const KHR_PERFORMANCE_QUERY_EXTENSION_NAME = "VK_KHR_performance_query";
pub const PerformanceCounterUnitKHR = extern enum(i32) {
GENERIC = 0,
PERCENTAGE = 1,
NANOSECONDS = 2,
BYTES = 3,
BYTES_PER_SECOND = 4,
KELVIN = 5,
WATTS = 6,
VOLTS = 7,
AMPS = 8,
HERTZ = 9,
CYCLES = 10,
_,
};
pub const PerformanceCounterScopeKHR = extern enum(i32) {
COMMAND_BUFFER = 0,
RENDER_PASS = 1,
COMMAND = 2,
_,
const Self = @This();
pub const QUERY_SCOPE_COMMAND_BUFFER = Self.COMMAND_BUFFER;
pub const QUERY_SCOPE_RENDER_PASS = Self.RENDER_PASS;
pub const QUERY_SCOPE_COMMAND = Self.COMMAND;
};
pub const PerformanceCounterStorageKHR = extern enum(i32) {
INT32 = 0,
INT64 = 1,
UINT32 = 2,
UINT64 = 3,
FLOAT32 = 4,
FLOAT64 = 5,
_,
};
pub const PerformanceCounterDescriptionFlagsKHR = packed struct {
performanceImpacting: bool = false,
concurrentlyImpacted: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const AcquireProfilingLockFlagsKHR = packed struct {
__reserved_bit_00: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDevicePerformanceQueryFeaturesKHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR,
pNext: ?*c_void = null,
performanceCounterQueryPools: Bool32,
performanceCounterMultipleQueryPools: Bool32,
};
pub const PhysicalDevicePerformanceQueryPropertiesKHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR,
pNext: ?*c_void = null,
allowCommandBufferQueryCopies: Bool32,
};
pub const PerformanceCounterKHR = extern struct {
sType: StructureType = .PERFORMANCE_COUNTER_KHR,
pNext: ?*const c_void = null,
unit: PerformanceCounterUnitKHR,
scope: PerformanceCounterScopeKHR,
storage: PerformanceCounterStorageKHR,
uuid: [UUID_SIZE]u8,
};
pub const PerformanceCounterDescriptionKHR = extern struct {
sType: StructureType = .PERFORMANCE_COUNTER_DESCRIPTION_KHR,
pNext: ?*const c_void = null,
flags: PerformanceCounterDescriptionFlagsKHR align(4) = PerformanceCounterDescriptionFlagsKHR{},
name: [MAX_DESCRIPTION_SIZE-1:0]u8,
category: [MAX_DESCRIPTION_SIZE-1:0]u8,
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
};
pub const QueryPoolPerformanceCreateInfoKHR = extern struct {
sType: StructureType = .QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR,
pNext: ?*const c_void = null,
queueFamilyIndex: u32,
counterIndexCount: u32,
pCounterIndices: [*]const u32,
};
pub const PerformanceCounterResultKHR = extern union {
int32: i32,
int64: i64,
uint32: u32,
uint64: u64,
float32: f32,
float64: f64,
};
pub const AcquireProfilingLockInfoKHR = extern struct {
sType: StructureType = .ACQUIRE_PROFILING_LOCK_INFO_KHR,
pNext: ?*const c_void = null,
flags: AcquireProfilingLockFlagsKHR align(4) = AcquireProfilingLockFlagsKHR{},
timeout: u64,
};
pub const PerformanceQuerySubmitInfoKHR = extern struct {
sType: StructureType = .PERFORMANCE_QUERY_SUBMIT_INFO_KHR,
pNext: ?*const c_void = null,
counterPassIndex: u32,
};
pub extern fn vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(
physicalDevice: PhysicalDevice,
queueFamilyIndex: u32,
pCounterCount: *u32,
pCounters: ?[*]PerformanceCounterKHR,
pCounterDescriptions: ?[*]PerformanceCounterDescriptionKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(
physicalDevice: PhysicalDevice,
pPerformanceQueryCreateInfo: *const QueryPoolPerformanceCreateInfoKHR,
pNumPasses: *u32,
) callconv(CallConv) void;
pub extern fn vkAcquireProfilingLockKHR(
device: Device,
pInfo: *const AcquireProfilingLockInfoKHR,
) callconv(CallConv) Result;
pub extern fn vkReleaseProfilingLockKHR(device: Device) callconv(CallConv) void;
pub const EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHRResult = struct {
result: Result,
counters: []PerformanceCounterKHR,
counterDescriptions: []PerformanceCounterDescriptionKHR,
};
pub inline fn EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(physicalDevice: PhysicalDevice, queueFamilyIndex: u32, counters: []PerformanceCounterKHR, counterDescriptions: []PerformanceCounterDescriptionKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHRResult {
var returnValues: EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHRResult = undefined;
var counterCount: u32 = @intCast(u32, counters.len);
assert(counterDescriptions.len >= counters.len);
const result = vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(physicalDevice, queueFamilyIndex, &counterCount, counters.ptr, counterDescriptions.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.counters = counters[0..counterCount];
returnValues.counterDescriptions = counterDescriptions[0..counterCount];
returnValues.result = result;
return returnValues;
}
pub inline fn EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersCountKHR(physicalDevice: PhysicalDevice, queueFamilyIndex: u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INITIALIZATION_FAILED,VK_UNDOCUMENTED_ERROR}!u32 {
var out_counterCount: u32 = undefined;
const result = vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR(physicalDevice, queueFamilyIndex, &out_counterCount, null, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INITIALIZATION_FAILED => error.VK_INITIALIZATION_FAILED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_counterCount;
}
pub inline fn GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(physicalDevice: PhysicalDevice, performanceQueryCreateInfo: QueryPoolPerformanceCreateInfoKHR) u32 {
var out_numPasses: u32 = undefined;
vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(physicalDevice, &performanceQueryCreateInfo, &out_numPasses);
return out_numPasses;
}
pub inline fn AcquireProfilingLockKHR(device: Device, info: AcquireProfilingLockInfoKHR) error{VK_TIMEOUT,VK_UNDOCUMENTED_ERROR}!void {
const result = vkAcquireProfilingLockKHR(device, &info);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.TIMEOUT => error.VK_TIMEOUT,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const ReleaseProfilingLockKHR = vkReleaseProfilingLockKHR;
pub const KHR_maintenance2 = 1;
pub const KHR_MAINTENANCE2_SPEC_VERSION = 1;
pub const KHR_MAINTENANCE2_EXTENSION_NAME = "VK_KHR_maintenance2";
pub const PointClippingBehaviorKHR = PointClippingBehavior;
pub const TessellationDomainOriginKHR = TessellationDomainOrigin;
pub const PhysicalDevicePointClippingPropertiesKHR = PhysicalDevicePointClippingProperties;
pub const RenderPassInputAttachmentAspectCreateInfoKHR = RenderPassInputAttachmentAspectCreateInfo;
pub const InputAttachmentAspectReferenceKHR = InputAttachmentAspectReference;
pub const ImageViewUsageCreateInfoKHR = ImageViewUsageCreateInfo;
pub const PipelineTessellationDomainOriginStateCreateInfoKHR = PipelineTessellationDomainOriginStateCreateInfo;
pub const KHR_get_surface_capabilities2 = 1;
pub const KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION = 1;
pub const KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME = "VK_KHR_get_surface_capabilities2";
pub const PhysicalDeviceSurfaceInfo2KHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SURFACE_INFO_2_KHR,
pNext: ?*const c_void = null,
surface: SurfaceKHR,
};
pub const SurfaceCapabilities2KHR = extern struct {
sType: StructureType = .SURFACE_CAPABILITIES_2_KHR,
pNext: ?*c_void = null,
surfaceCapabilities: SurfaceCapabilitiesKHR,
};
pub const SurfaceFormat2KHR = extern struct {
sType: StructureType = .SURFACE_FORMAT_2_KHR,
pNext: ?*c_void = null,
surfaceFormat: SurfaceFormatKHR,
};
pub extern fn vkGetPhysicalDeviceSurfaceCapabilities2KHR(
physicalDevice: PhysicalDevice,
pSurfaceInfo: *const PhysicalDeviceSurfaceInfo2KHR,
pSurfaceCapabilities: *SurfaceCapabilities2KHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceSurfaceFormats2KHR(
physicalDevice: PhysicalDevice,
pSurfaceInfo: *const PhysicalDeviceSurfaceInfo2KHR,
pSurfaceFormatCount: *u32,
pSurfaceFormats: ?[*]SurfaceFormat2KHR,
) callconv(CallConv) Result;
pub inline fn GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice: PhysicalDevice, surfaceInfo: PhysicalDeviceSurfaceInfo2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!SurfaceCapabilities2KHR {
var out_surfaceCapabilities: SurfaceCapabilities2KHR = undefined;
const result = vkGetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, &surfaceInfo, &out_surfaceCapabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surfaceCapabilities;
}
pub const GetPhysicalDeviceSurfaceFormats2KHRResult = struct {
result: Result,
surfaceFormats: []SurfaceFormat2KHR,
};
pub inline fn GetPhysicalDeviceSurfaceFormats2KHR(physicalDevice: PhysicalDevice, surfaceInfo: PhysicalDeviceSurfaceInfo2KHR, surfaceFormats: []SurfaceFormat2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceSurfaceFormats2KHRResult {
var returnValues: GetPhysicalDeviceSurfaceFormats2KHRResult = undefined;
var surfaceFormatCount: u32 = @intCast(u32, surfaceFormats.len);
const result = vkGetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, &surfaceInfo, &surfaceFormatCount, surfaceFormats.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.surfaceFormats = surfaceFormats[0..surfaceFormatCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceSurfaceFormats2CountKHR(physicalDevice: PhysicalDevice, surfaceInfo: PhysicalDeviceSurfaceInfo2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!u32 {
var out_surfaceFormatCount: u32 = undefined;
const result = vkGetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, &surfaceInfo, &out_surfaceFormatCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surfaceFormatCount;
}
pub const KHR_variable_pointers = 1;
pub const KHR_VARIABLE_POINTERS_SPEC_VERSION = 1;
pub const KHR_VARIABLE_POINTERS_EXTENSION_NAME = "VK_KHR_variable_pointers";
pub const PhysicalDeviceVariablePointerFeaturesKHR = PhysicalDeviceVariablePointersFeatures;
pub const PhysicalDeviceVariablePointersFeaturesKHR = PhysicalDeviceVariablePointersFeatures;
pub const KHR_get_display_properties2 = 1;
pub const KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION = 1;
pub const KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME = "VK_KHR_get_display_properties2";
pub const DisplayProperties2KHR = extern struct {
sType: StructureType = .DISPLAY_PROPERTIES_2_KHR,
pNext: ?*c_void = null,
displayProperties: DisplayPropertiesKHR,
};
pub const DisplayPlaneProperties2KHR = extern struct {
sType: StructureType = .DISPLAY_PLANE_PROPERTIES_2_KHR,
pNext: ?*c_void = null,
displayPlaneProperties: DisplayPlanePropertiesKHR,
};
pub const DisplayModeProperties2KHR = extern struct {
sType: StructureType = .DISPLAY_MODE_PROPERTIES_2_KHR,
pNext: ?*c_void = null,
displayModeProperties: DisplayModePropertiesKHR,
};
pub const DisplayPlaneInfo2KHR = extern struct {
sType: StructureType = .DISPLAY_PLANE_INFO_2_KHR,
pNext: ?*const c_void = null,
mode: DisplayModeKHR,
planeIndex: u32,
};
pub const DisplayPlaneCapabilities2KHR = extern struct {
sType: StructureType = .DISPLAY_PLANE_CAPABILITIES_2_KHR,
pNext: ?*c_void = null,
capabilities: DisplayPlaneCapabilitiesKHR,
};
pub extern fn vkGetPhysicalDeviceDisplayProperties2KHR(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]DisplayProperties2KHR,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceDisplayPlaneProperties2KHR(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]DisplayPlaneProperties2KHR,
) callconv(CallConv) Result;
pub extern fn vkGetDisplayModeProperties2KHR(
physicalDevice: PhysicalDevice,
display: DisplayKHR,
pPropertyCount: *u32,
pProperties: ?[*]DisplayModeProperties2KHR,
) callconv(CallConv) Result;
pub extern fn vkGetDisplayPlaneCapabilities2KHR(
physicalDevice: PhysicalDevice,
pDisplayPlaneInfo: *const DisplayPlaneInfo2KHR,
pCapabilities: *DisplayPlaneCapabilities2KHR,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceDisplayProperties2KHRResult = struct {
result: Result,
properties: []DisplayProperties2KHR,
};
pub inline fn GetPhysicalDeviceDisplayProperties2KHR(physicalDevice: PhysicalDevice, properties: []DisplayProperties2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceDisplayProperties2KHRResult {
var returnValues: GetPhysicalDeviceDisplayProperties2KHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetPhysicalDeviceDisplayProperties2KHR(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceDisplayProperties2CountKHR(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetPhysicalDeviceDisplayProperties2KHR(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const GetPhysicalDeviceDisplayPlaneProperties2KHRResult = struct {
result: Result,
properties: []DisplayPlaneProperties2KHR,
};
pub inline fn GetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice: PhysicalDevice, properties: []DisplayPlaneProperties2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceDisplayPlaneProperties2KHRResult {
var returnValues: GetPhysicalDeviceDisplayPlaneProperties2KHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceDisplayPlaneProperties2CountKHR(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const GetDisplayModeProperties2KHRResult = struct {
result: Result,
properties: []DisplayModeProperties2KHR,
};
pub inline fn GetDisplayModeProperties2KHR(physicalDevice: PhysicalDevice, display: DisplayKHR, properties: []DisplayModeProperties2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetDisplayModeProperties2KHRResult {
var returnValues: GetDisplayModeProperties2KHRResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetDisplayModeProperties2KHR(physicalDevice, display, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetDisplayModeProperties2CountKHR(physicalDevice: PhysicalDevice, display: DisplayKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetDisplayModeProperties2KHR(physicalDevice, display, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub inline fn GetDisplayPlaneCapabilities2KHR(physicalDevice: PhysicalDevice, displayPlaneInfo: DisplayPlaneInfo2KHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!DisplayPlaneCapabilities2KHR {
var out_capabilities: DisplayPlaneCapabilities2KHR = undefined;
const result = vkGetDisplayPlaneCapabilities2KHR(physicalDevice, &displayPlaneInfo, &out_capabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_capabilities;
}
pub const KHR_dedicated_allocation = 1;
pub const KHR_DEDICATED_ALLOCATION_SPEC_VERSION = 3;
pub const KHR_DEDICATED_ALLOCATION_EXTENSION_NAME = "VK_KHR_dedicated_allocation";
pub const MemoryDedicatedRequirementsKHR = MemoryDedicatedRequirements;
pub const MemoryDedicatedAllocateInfoKHR = MemoryDedicatedAllocateInfo;
pub const KHR_storage_buffer_storage_class = 1;
pub const KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION = 1;
pub const KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME = "VK_KHR_storage_buffer_storage_class";
pub const KHR_relaxed_block_layout = 1;
pub const KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION = 1;
pub const KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME = "VK_KHR_relaxed_block_layout";
pub const KHR_get_memory_requirements2 = 1;
pub const KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION = 1;
pub const KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME = "VK_KHR_get_memory_requirements2";
pub const BufferMemoryRequirementsInfo2KHR = BufferMemoryRequirementsInfo2;
pub const ImageMemoryRequirementsInfo2KHR = ImageMemoryRequirementsInfo2;
pub const ImageSparseMemoryRequirementsInfo2KHR = ImageSparseMemoryRequirementsInfo2;
pub const SparseImageMemoryRequirements2KHR = SparseImageMemoryRequirements2;
pub extern fn vkGetImageMemoryRequirements2KHR(
device: Device,
pInfo: *const ImageMemoryRequirementsInfo2,
pMemoryRequirements: *MemoryRequirements2,
) callconv(CallConv) void;
pub extern fn vkGetBufferMemoryRequirements2KHR(
device: Device,
pInfo: *const BufferMemoryRequirementsInfo2,
pMemoryRequirements: *MemoryRequirements2,
) callconv(CallConv) void;
pub extern fn vkGetImageSparseMemoryRequirements2KHR(
device: Device,
pInfo: *const ImageSparseMemoryRequirementsInfo2,
pSparseMemoryRequirementCount: *u32,
pSparseMemoryRequirements: ?[*]SparseImageMemoryRequirements2,
) callconv(CallConv) void;
pub inline fn GetImageMemoryRequirements2KHR(device: Device, info: ImageMemoryRequirementsInfo2) MemoryRequirements2 {
var out_memoryRequirements: MemoryRequirements2 = undefined;
vkGetImageMemoryRequirements2KHR(device, &info, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetBufferMemoryRequirements2KHR(device: Device, info: BufferMemoryRequirementsInfo2) MemoryRequirements2 {
var out_memoryRequirements: MemoryRequirements2 = undefined;
vkGetBufferMemoryRequirements2KHR(device, &info, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirements2KHR(device: Device, info: ImageSparseMemoryRequirementsInfo2, sparseMemoryRequirements: []SparseImageMemoryRequirements2) []SparseImageMemoryRequirements2 {
var out_sparseMemoryRequirements: []SparseImageMemoryRequirements2 = undefined;
var sparseMemoryRequirementCount: u32 = @intCast(u32, sparseMemoryRequirements.len);
vkGetImageSparseMemoryRequirements2KHR(device, &info, &sparseMemoryRequirementCount, sparseMemoryRequirements.ptr);
out_sparseMemoryRequirements = sparseMemoryRequirements[0..sparseMemoryRequirementCount];
return out_sparseMemoryRequirements;
}
pub inline fn GetImageSparseMemoryRequirements2CountKHR(device: Device, info: ImageSparseMemoryRequirementsInfo2) u32 {
var out_sparseMemoryRequirementCount: u32 = undefined;
vkGetImageSparseMemoryRequirements2KHR(device, &info, &out_sparseMemoryRequirementCount, null);
return out_sparseMemoryRequirementCount;
}
pub const KHR_image_format_list = 1;
pub const KHR_IMAGE_FORMAT_LIST_SPEC_VERSION = 1;
pub const KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME = "VK_KHR_image_format_list";
pub const ImageFormatListCreateInfoKHR = ImageFormatListCreateInfo;
pub const KHR_sampler_ycbcr_conversion = 1;
pub const SamplerYcbcrConversionKHR = SamplerYcbcrConversion;
pub const KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION = 14;
pub const KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME = "VK_KHR_sampler_ycbcr_conversion";
pub const SamplerYcbcrModelConversionKHR = SamplerYcbcrModelConversion;
pub const SamplerYcbcrRangeKHR = SamplerYcbcrRange;
pub const ChromaLocationKHR = ChromaLocation;
pub const SamplerYcbcrConversionCreateInfoKHR = SamplerYcbcrConversionCreateInfo;
pub const SamplerYcbcrConversionInfoKHR = SamplerYcbcrConversionInfo;
pub const BindImagePlaneMemoryInfoKHR = BindImagePlaneMemoryInfo;
pub const ImagePlaneMemoryRequirementsInfoKHR = ImagePlaneMemoryRequirementsInfo;
pub const PhysicalDeviceSamplerYcbcrConversionFeaturesKHR = PhysicalDeviceSamplerYcbcrConversionFeatures;
pub const SamplerYcbcrConversionImageFormatPropertiesKHR = SamplerYcbcrConversionImageFormatProperties;
pub extern fn vkCreateSamplerYcbcrConversionKHR(
device: Device,
pCreateInfo: *const SamplerYcbcrConversionCreateInfo,
pAllocator: ?*const AllocationCallbacks,
pYcbcrConversion: *SamplerYcbcrConversion,
) callconv(CallConv) Result;
pub extern fn vkDestroySamplerYcbcrConversionKHR(
device: Device,
ycbcrConversion: ?SamplerYcbcrConversion,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub inline fn CreateSamplerYcbcrConversionKHR(device: Device, createInfo: SamplerYcbcrConversionCreateInfo, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!SamplerYcbcrConversion {
var out_ycbcrConversion: SamplerYcbcrConversion = undefined;
const result = vkCreateSamplerYcbcrConversionKHR(device, &createInfo, pAllocator, &out_ycbcrConversion);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_ycbcrConversion;
}
pub const DestroySamplerYcbcrConversionKHR = vkDestroySamplerYcbcrConversionKHR;
pub const KHR_bind_memory2 = 1;
pub const KHR_BIND_MEMORY_2_SPEC_VERSION = 1;
pub const KHR_BIND_MEMORY_2_EXTENSION_NAME = "VK_KHR_bind_memory2";
pub const BindBufferMemoryInfoKHR = BindBufferMemoryInfo;
pub const BindImageMemoryInfoKHR = BindImageMemoryInfo;
pub extern fn vkBindBufferMemory2KHR(
device: Device,
bindInfoCount: u32,
pBindInfos: [*]const BindBufferMemoryInfo,
) callconv(CallConv) Result;
pub extern fn vkBindImageMemory2KHR(
device: Device,
bindInfoCount: u32,
pBindInfos: [*]const BindImageMemoryInfo,
) callconv(CallConv) Result;
pub inline fn BindBufferMemory2KHR(device: Device, bindInfos: []const BindBufferMemoryInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_OPAQUE_CAPTURE_ADDRESS,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindBufferMemory2KHR(device, @intCast(u32, bindInfos.len), bindInfos.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => error.VK_INVALID_OPAQUE_CAPTURE_ADDRESS,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn BindImageMemory2KHR(device: Device, bindInfos: []const BindImageMemoryInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindImageMemory2KHR(device, @intCast(u32, bindInfos.len), bindInfos.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const KHR_maintenance3 = 1;
pub const KHR_MAINTENANCE3_SPEC_VERSION = 1;
pub const KHR_MAINTENANCE3_EXTENSION_NAME = "VK_KHR_maintenance3";
pub const PhysicalDeviceMaintenance3PropertiesKHR = PhysicalDeviceMaintenance3Properties;
pub const DescriptorSetLayoutSupportKHR = DescriptorSetLayoutSupport;
pub extern fn vkGetDescriptorSetLayoutSupportKHR(
device: Device,
pCreateInfo: *const DescriptorSetLayoutCreateInfo,
pSupport: *DescriptorSetLayoutSupport,
) callconv(CallConv) void;
pub inline fn GetDescriptorSetLayoutSupportKHR(device: Device, createInfo: DescriptorSetLayoutCreateInfo) DescriptorSetLayoutSupport {
var out_support: DescriptorSetLayoutSupport = undefined;
vkGetDescriptorSetLayoutSupportKHR(device, &createInfo, &out_support);
return out_support;
}
pub const KHR_draw_indirect_count = 1;
pub const KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION = 1;
pub const KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME = "VK_KHR_draw_indirect_count";
pub extern fn vkCmdDrawIndirectCountKHR(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndexedIndirectCountKHR(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub const CmdDrawIndirectCountKHR = vkCmdDrawIndirectCountKHR;
pub const CmdDrawIndexedIndirectCountKHR = vkCmdDrawIndexedIndirectCountKHR;
pub const KHR_shader_subgroup_extended_types = 1;
pub const KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION = 1;
pub const KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME = "VK_KHR_shader_subgroup_extended_types";
pub const PhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR = PhysicalDeviceShaderSubgroupExtendedTypesFeatures;
pub const KHR_8bit_storage = 1;
pub const KHR_8BIT_STORAGE_SPEC_VERSION = 1;
pub const KHR_8BIT_STORAGE_EXTENSION_NAME = "VK_KHR_8bit_storage";
pub const PhysicalDevice8BitStorageFeaturesKHR = PhysicalDevice8BitStorageFeatures;
pub const KHR_shader_atomic_int64 = 1;
pub const KHR_SHADER_ATOMIC_INT64_SPEC_VERSION = 1;
pub const KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME = "VK_KHR_shader_atomic_int64";
pub const PhysicalDeviceShaderAtomicInt64FeaturesKHR = PhysicalDeviceShaderAtomicInt64Features;
pub const KHR_shader_clock = 1;
pub const KHR_SHADER_CLOCK_SPEC_VERSION = 1;
pub const KHR_SHADER_CLOCK_EXTENSION_NAME = "VK_KHR_shader_clock";
pub const PhysicalDeviceShaderClockFeaturesKHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR,
pNext: ?*c_void = null,
shaderSubgroupClock: Bool32,
shaderDeviceClock: Bool32,
};
pub const KHR_driver_properties = 1;
pub const KHR_DRIVER_PROPERTIES_SPEC_VERSION = 1;
pub const KHR_DRIVER_PROPERTIES_EXTENSION_NAME = "VK_KHR_driver_properties";
pub const MAX_DRIVER_NAME_SIZE_KHR = MAX_DRIVER_NAME_SIZE;
pub const MAX_DRIVER_INFO_SIZE_KHR = MAX_DRIVER_INFO_SIZE;
pub const DriverIdKHR = DriverId;
pub const ConformanceVersionKHR = ConformanceVersion;
pub const PhysicalDeviceDriverPropertiesKHR = PhysicalDeviceDriverProperties;
pub const KHR_shader_float_controls = 1;
pub const KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION = 4;
pub const KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME = "VK_KHR_shader_float_controls";
pub const ShaderFloatControlsIndependenceKHR = ShaderFloatControlsIndependence;
pub const PhysicalDeviceFloatControlsPropertiesKHR = PhysicalDeviceFloatControlsProperties;
pub const KHR_depth_stencil_resolve = 1;
pub const KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION = 1;
pub const KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME = "VK_KHR_depth_stencil_resolve";
pub const ResolveModeFlagsKHR = ResolveModeFlags;
pub const SubpassDescriptionDepthStencilResolveKHR = SubpassDescriptionDepthStencilResolve;
pub const PhysicalDeviceDepthStencilResolvePropertiesKHR = PhysicalDeviceDepthStencilResolveProperties;
pub const KHR_swapchain_mutable_format = 1;
pub const KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION = 1;
pub const KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME = "VK_KHR_swapchain_mutable_format";
pub const KHR_timeline_semaphore = 1;
pub const KHR_TIMELINE_SEMAPHORE_SPEC_VERSION = 2;
pub const KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME = "VK_KHR_timeline_semaphore";
pub const SemaphoreTypeKHR = SemaphoreType;
pub const SemaphoreWaitFlagsKHR = SemaphoreWaitFlags;
pub const PhysicalDeviceTimelineSemaphoreFeaturesKHR = PhysicalDeviceTimelineSemaphoreFeatures;
pub const PhysicalDeviceTimelineSemaphorePropertiesKHR = PhysicalDeviceTimelineSemaphoreProperties;
pub const SemaphoreTypeCreateInfoKHR = SemaphoreTypeCreateInfo;
pub const TimelineSemaphoreSubmitInfoKHR = TimelineSemaphoreSubmitInfo;
pub const SemaphoreWaitInfoKHR = SemaphoreWaitInfo;
pub const SemaphoreSignalInfoKHR = SemaphoreSignalInfo;
pub extern fn vkGetSemaphoreCounterValueKHR(
device: Device,
semaphore: Semaphore,
pValue: *u64,
) callconv(CallConv) Result;
pub extern fn vkWaitSemaphoresKHR(
device: Device,
pWaitInfo: *const SemaphoreWaitInfo,
timeout: u64,
) callconv(CallConv) Result;
pub extern fn vkSignalSemaphoreKHR(
device: Device,
pSignalInfo: *const SemaphoreSignalInfo,
) callconv(CallConv) Result;
pub inline fn GetSemaphoreCounterValueKHR(device: Device, semaphore: Semaphore) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!u64 {
var out_value: u64 = undefined;
const result = vkGetSemaphoreCounterValueKHR(device, semaphore, &out_value);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_value;
}
pub inline fn WaitSemaphoresKHR(device: Device, waitInfo: SemaphoreWaitInfo, timeout: u64) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_DEVICE_LOST,VK_UNDOCUMENTED_ERROR}!Result {
const result = vkWaitSemaphoresKHR(device, &waitInfo, timeout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return result;
}
pub inline fn SignalSemaphoreKHR(device: Device, signalInfo: SemaphoreSignalInfo) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkSignalSemaphoreKHR(device, &signalInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const KHR_vulkan_memory_model = 1;
pub const KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION = 3;
pub const KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME = "VK_KHR_vulkan_memory_model";
pub const PhysicalDeviceVulkanMemoryModelFeaturesKHR = PhysicalDeviceVulkanMemoryModelFeatures;
pub const KHR_spirv_1_4 = 1;
pub const KHR_SPIRV_1_4_SPEC_VERSION = 1;
pub const KHR_SPIRV_1_4_EXTENSION_NAME = "VK_KHR_spirv_1_4";
pub const KHR_surface_protected_capabilities = 1;
pub const KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION = 1;
pub const KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME = "VK_KHR_surface_protected_capabilities";
pub const SurfaceProtectedCapabilitiesKHR = extern struct {
sType: StructureType = .SURFACE_PROTECTED_CAPABILITIES_KHR,
pNext: ?*const c_void = null,
supportsProtected: Bool32,
};
pub const KHR_separate_depth_stencil_layouts = 1;
pub const KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION = 1;
pub const KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME = "VK_KHR_separate_depth_stencil_layouts";
pub const PhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR = PhysicalDeviceSeparateDepthStencilLayoutsFeatures;
pub const AttachmentReferenceStencilLayoutKHR = AttachmentReferenceStencilLayout;
pub const AttachmentDescriptionStencilLayoutKHR = AttachmentDescriptionStencilLayout;
pub const KHR_uniform_buffer_standard_layout = 1;
pub const KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION = 1;
pub const KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME = "VK_KHR_uniform_buffer_standard_layout";
pub const PhysicalDeviceUniformBufferStandardLayoutFeaturesKHR = PhysicalDeviceUniformBufferStandardLayoutFeatures;
pub const KHR_buffer_device_address = 1;
pub const KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION = 1;
pub const KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME = "VK_KHR_buffer_device_address";
pub const PhysicalDeviceBufferDeviceAddressFeaturesKHR = PhysicalDeviceBufferDeviceAddressFeatures;
pub const BufferDeviceAddressInfoKHR = BufferDeviceAddressInfo;
pub const BufferOpaqueCaptureAddressCreateInfoKHR = BufferOpaqueCaptureAddressCreateInfo;
pub const MemoryOpaqueCaptureAddressAllocateInfoKHR = MemoryOpaqueCaptureAddressAllocateInfo;
pub const DeviceMemoryOpaqueCaptureAddressInfoKHR = DeviceMemoryOpaqueCaptureAddressInfo;
pub extern fn vkGetBufferDeviceAddressKHR(
device: Device,
pInfo: *const BufferDeviceAddressInfo,
) callconv(CallConv) DeviceAddress;
pub extern fn vkGetBufferOpaqueCaptureAddressKHR(
device: Device,
pInfo: *const BufferDeviceAddressInfo,
) callconv(CallConv) u64;
pub extern fn vkGetDeviceMemoryOpaqueCaptureAddressKHR(
device: Device,
pInfo: *const DeviceMemoryOpaqueCaptureAddressInfo,
) callconv(CallConv) u64;
pub inline fn GetBufferDeviceAddressKHR(device: Device, info: BufferDeviceAddressInfo) DeviceAddress {
const result = vkGetBufferDeviceAddressKHR(device, &info);
return result;
}
pub inline fn GetBufferOpaqueCaptureAddressKHR(device: Device, info: BufferDeviceAddressInfo) u64 {
const result = vkGetBufferOpaqueCaptureAddressKHR(device, &info);
return result;
}
pub inline fn GetDeviceMemoryOpaqueCaptureAddressKHR(device: Device, info: DeviceMemoryOpaqueCaptureAddressInfo) u64 {
const result = vkGetDeviceMemoryOpaqueCaptureAddressKHR(device, &info);
return result;
}
pub const KHR_pipeline_executable_properties = 1;
pub const KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION = 1;
pub const KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME = "VK_KHR_pipeline_executable_properties";
pub const PipelineExecutableStatisticFormatKHR = extern enum(i32) {
BOOL32 = 0,
INT64 = 1,
UINT64 = 2,
FLOAT64 = 3,
_,
};
pub const PhysicalDevicePipelineExecutablePropertiesFeaturesKHR = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR,
pNext: ?*c_void = null,
pipelineExecutableInfo: Bool32,
};
pub const PipelineInfoKHR = extern struct {
sType: StructureType = .PIPELINE_INFO_KHR,
pNext: ?*const c_void = null,
pipeline: Pipeline,
};
pub const PipelineExecutablePropertiesKHR = extern struct {
sType: StructureType = .PIPELINE_EXECUTABLE_PROPERTIES_KHR,
pNext: ?*c_void = null,
stages: ShaderStageFlags align(4),
name: [MAX_DESCRIPTION_SIZE-1:0]u8,
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
subgroupSize: u32,
};
pub const PipelineExecutableInfoKHR = extern struct {
sType: StructureType = .PIPELINE_EXECUTABLE_INFO_KHR,
pNext: ?*const c_void = null,
pipeline: Pipeline,
executableIndex: u32,
};
pub const PipelineExecutableStatisticValueKHR = extern union {
b32: Bool32,
i64: i64,
u64: u64,
f64: f64,
};
pub const PipelineExecutableStatisticKHR = extern struct {
sType: StructureType = .PIPELINE_EXECUTABLE_STATISTIC_KHR,
pNext: ?*c_void = null,
name: [MAX_DESCRIPTION_SIZE-1:0]u8,
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
format: PipelineExecutableStatisticFormatKHR,
value: PipelineExecutableStatisticValueKHR,
};
pub const PipelineExecutableInternalRepresentationKHR = extern struct {
sType: StructureType = .PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR,
pNext: ?*c_void = null,
name: [MAX_DESCRIPTION_SIZE-1:0]u8,
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
isText: Bool32,
dataSize: usize = 0,
pData: ?*c_void = null,
};
pub extern fn vkGetPipelineExecutablePropertiesKHR(
device: Device,
pPipelineInfo: *const PipelineInfoKHR,
pExecutableCount: *u32,
pProperties: ?[*]PipelineExecutablePropertiesKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPipelineExecutableStatisticsKHR(
device: Device,
pExecutableInfo: *const PipelineExecutableInfoKHR,
pStatisticCount: *u32,
pStatistics: ?[*]PipelineExecutableStatisticKHR,
) callconv(CallConv) Result;
pub extern fn vkGetPipelineExecutableInternalRepresentationsKHR(
device: Device,
pExecutableInfo: *const PipelineExecutableInfoKHR,
pInternalRepresentationCount: *u32,
pInternalRepresentations: ?[*]PipelineExecutableInternalRepresentationKHR,
) callconv(CallConv) Result;
pub const GetPipelineExecutablePropertiesKHRResult = struct {
result: Result,
properties: []PipelineExecutablePropertiesKHR,
};
pub inline fn GetPipelineExecutablePropertiesKHR(device: Device, pipelineInfo: PipelineInfoKHR, properties: []PipelineExecutablePropertiesKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPipelineExecutablePropertiesKHRResult {
var returnValues: GetPipelineExecutablePropertiesKHRResult = undefined;
var executableCount: u32 = @intCast(u32, properties.len);
const result = vkGetPipelineExecutablePropertiesKHR(device, &pipelineInfo, &executableCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..executableCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPipelineExecutablePropertiesCountKHR(device: Device, pipelineInfo: PipelineInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_executableCount: u32 = undefined;
const result = vkGetPipelineExecutablePropertiesKHR(device, &pipelineInfo, &out_executableCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_executableCount;
}
pub const GetPipelineExecutableStatisticsKHRResult = struct {
result: Result,
statistics: []PipelineExecutableStatisticKHR,
};
pub inline fn GetPipelineExecutableStatisticsKHR(device: Device, executableInfo: PipelineExecutableInfoKHR, statistics: []PipelineExecutableStatisticKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPipelineExecutableStatisticsKHRResult {
var returnValues: GetPipelineExecutableStatisticsKHRResult = undefined;
var statisticCount: u32 = @intCast(u32, statistics.len);
const result = vkGetPipelineExecutableStatisticsKHR(device, &executableInfo, &statisticCount, statistics.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.statistics = statistics[0..statisticCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPipelineExecutableStatisticsCountKHR(device: Device, executableInfo: PipelineExecutableInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_statisticCount: u32 = undefined;
const result = vkGetPipelineExecutableStatisticsKHR(device, &executableInfo, &out_statisticCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_statisticCount;
}
pub const GetPipelineExecutableInternalRepresentationsKHRResult = struct {
result: Result,
internalRepresentations: []PipelineExecutableInternalRepresentationKHR,
};
pub inline fn GetPipelineExecutableInternalRepresentationsKHR(device: Device, executableInfo: PipelineExecutableInfoKHR, internalRepresentations: []PipelineExecutableInternalRepresentationKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPipelineExecutableInternalRepresentationsKHRResult {
var returnValues: GetPipelineExecutableInternalRepresentationsKHRResult = undefined;
var internalRepresentationCount: u32 = @intCast(u32, internalRepresentations.len);
const result = vkGetPipelineExecutableInternalRepresentationsKHR(device, &executableInfo, &internalRepresentationCount, internalRepresentations.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.internalRepresentations = internalRepresentations[0..internalRepresentationCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPipelineExecutableInternalRepresentationsCountKHR(device: Device, executableInfo: PipelineExecutableInfoKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_internalRepresentationCount: u32 = undefined;
const result = vkGetPipelineExecutableInternalRepresentationsKHR(device, &executableInfo, &out_internalRepresentationCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_internalRepresentationCount;
}
pub const EXT_debug_report = 1;
pub const DebugReportCallbackEXT = *@OpaqueType();
pub const EXT_DEBUG_REPORT_SPEC_VERSION = 9;
pub const EXT_DEBUG_REPORT_EXTENSION_NAME = "VK_EXT_debug_report";
pub const DebugReportObjectTypeEXT = extern enum(i32) {
UNKNOWN = 0,
INSTANCE = 1,
PHYSICAL_DEVICE = 2,
DEVICE = 3,
QUEUE = 4,
SEMAPHORE = 5,
COMMAND_BUFFER = 6,
FENCE = 7,
DEVICE_MEMORY = 8,
BUFFER = 9,
IMAGE = 10,
EVENT = 11,
QUERY_POOL = 12,
BUFFER_VIEW = 13,
IMAGE_VIEW = 14,
SHADER_MODULE = 15,
PIPELINE_CACHE = 16,
PIPELINE_LAYOUT = 17,
RENDER_PASS = 18,
PIPELINE = 19,
DESCRIPTOR_SET_LAYOUT = 20,
SAMPLER = 21,
DESCRIPTOR_POOL = 22,
DESCRIPTOR_SET = 23,
FRAMEBUFFER = 24,
COMMAND_POOL = 25,
SURFACE_KHR = 26,
SWAPCHAIN_KHR = 27,
DEBUG_REPORT_CALLBACK_EXT = 28,
DISPLAY_KHR = 29,
DISPLAY_MODE_KHR = 30,
OBJECT_TABLE_NVX = 31,
INDIRECT_COMMANDS_LAYOUT_NVX = 32,
VALIDATION_CACHE_EXT = 33,
SAMPLER_YCBCR_CONVERSION = 1000156000,
DESCRIPTOR_UPDATE_TEMPLATE = 1000085000,
ACCELERATION_STRUCTURE_NV = 1000165000,
_,
const Self = @This();
pub const DEBUG_REPORT = Self.DEBUG_REPORT_CALLBACK_EXT;
pub const VALIDATION_CACHE = Self.VALIDATION_CACHE_EXT;
pub const DESCRIPTOR_UPDATE_TEMPLATE_KHR = Self.DESCRIPTOR_UPDATE_TEMPLATE;
pub const SAMPLER_YCBCR_CONVERSION_KHR = Self.SAMPLER_YCBCR_CONVERSION;
};
pub const DebugReportFlagsEXT = packed struct {
information: bool = false,
warning: bool = false,
performanceWarning: bool = false,
errorBit: bool = false,
debug: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PFN_DebugReportCallbackEXT = fn (
DebugReportFlagsEXT.IntType,
DebugReportObjectTypeEXT,
u64,
usize,
i32,
?CString,
?CString,
?*c_void,
) callconv(CallConv) Bool32;
pub const DebugReportCallbackCreateInfoEXT = extern struct {
sType: StructureType = .DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: DebugReportFlagsEXT align(4) = DebugReportFlagsEXT{},
pfnCallback: PFN_DebugReportCallbackEXT,
pUserData: ?*c_void = null,
};
pub extern fn vkCreateDebugReportCallbackEXT(
instance: Instance,
pCreateInfo: *const DebugReportCallbackCreateInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pCallback: *DebugReportCallbackEXT,
) callconv(CallConv) Result;
pub extern fn vkDestroyDebugReportCallbackEXT(
instance: Instance,
callback: DebugReportCallbackEXT,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkDebugReportMessageEXT(
instance: Instance,
flags: DebugReportFlagsEXT.IntType,
objectType: DebugReportObjectTypeEXT,
object: u64,
location: usize,
messageCode: i32,
pLayerPrefix: CString,
pMessage: CString,
) callconv(CallConv) void;
pub inline fn CreateDebugReportCallbackEXT(instance: Instance, createInfo: DebugReportCallbackCreateInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!DebugReportCallbackEXT {
var out_callback: DebugReportCallbackEXT = undefined;
const result = vkCreateDebugReportCallbackEXT(instance, &createInfo, pAllocator, &out_callback);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_callback;
}
pub const DestroyDebugReportCallbackEXT = vkDestroyDebugReportCallbackEXT;
pub inline fn DebugReportMessageEXT(instance: Instance, flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: usize, messageCode: i32, pLayerPrefix: CString, pMessage: CString) void {
vkDebugReportMessageEXT(instance, flags.toInt(), objectType, object, location, messageCode, pLayerPrefix, pMessage);
}
pub const NV_glsl_shader = 1;
pub const NV_GLSL_SHADER_SPEC_VERSION = 1;
pub const NV_GLSL_SHADER_EXTENSION_NAME = "VK_NV_glsl_shader";
pub const EXT_depth_range_unrestricted = 1;
pub const EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION = 1;
pub const EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME = "VK_EXT_depth_range_unrestricted";
pub const IMG_filter_cubic = 1;
pub const IMG_FILTER_CUBIC_SPEC_VERSION = 1;
pub const IMG_FILTER_CUBIC_EXTENSION_NAME = "VK_IMG_filter_cubic";
pub const AMD_rasterization_order = 1;
pub const AMD_RASTERIZATION_ORDER_SPEC_VERSION = 1;
pub const AMD_RASTERIZATION_ORDER_EXTENSION_NAME = "VK_AMD_rasterization_order";
pub const RasterizationOrderAMD = extern enum(i32) {
STRICT = 0,
RELAXED = 1,
_,
};
pub const PipelineRasterizationStateRasterizationOrderAMD = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD,
pNext: ?*const c_void = null,
rasterizationOrder: RasterizationOrderAMD,
};
pub const AMD_shader_trinary_minmax = 1;
pub const AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION = 1;
pub const AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME = "VK_AMD_shader_trinary_minmax";
pub const AMD_shader_explicit_vertex_parameter = 1;
pub const AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION = 1;
pub const AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME = "VK_AMD_shader_explicit_vertex_parameter";
pub const EXT_debug_marker = 1;
pub const EXT_DEBUG_MARKER_SPEC_VERSION = 4;
pub const EXT_DEBUG_MARKER_EXTENSION_NAME = "VK_EXT_debug_marker";
pub const DebugMarkerObjectNameInfoEXT = extern struct {
sType: StructureType = .DEBUG_MARKER_OBJECT_NAME_INFO_EXT,
pNext: ?*const c_void = null,
objectType: DebugReportObjectTypeEXT,
object: u64,
pObjectName: CString,
};
pub const DebugMarkerObjectTagInfoEXT = extern struct {
sType: StructureType = .DEBUG_MARKER_OBJECT_TAG_INFO_EXT,
pNext: ?*const c_void = null,
objectType: DebugReportObjectTypeEXT,
object: u64,
tagName: u64,
tagSize: usize,
pTag: ?*const c_void,
};
pub const DebugMarkerMarkerInfoEXT = extern struct {
sType: StructureType = .DEBUG_MARKER_MARKER_INFO_EXT,
pNext: ?*const c_void = null,
pMarkerName: CString,
color: [4]f32 = 0,
};
pub extern fn vkDebugMarkerSetObjectTagEXT(
device: Device,
pTagInfo: *const DebugMarkerObjectTagInfoEXT,
) callconv(CallConv) Result;
pub extern fn vkDebugMarkerSetObjectNameEXT(
device: Device,
pNameInfo: *const DebugMarkerObjectNameInfoEXT,
) callconv(CallConv) Result;
pub extern fn vkCmdDebugMarkerBeginEXT(
commandBuffer: CommandBuffer,
pMarkerInfo: *const DebugMarkerMarkerInfoEXT,
) callconv(CallConv) void;
pub extern fn vkCmdDebugMarkerEndEXT(commandBuffer: CommandBuffer) callconv(CallConv) void;
pub extern fn vkCmdDebugMarkerInsertEXT(
commandBuffer: CommandBuffer,
pMarkerInfo: *const DebugMarkerMarkerInfoEXT,
) callconv(CallConv) void;
pub inline fn DebugMarkerSetObjectTagEXT(device: Device, tagInfo: DebugMarkerObjectTagInfoEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkDebugMarkerSetObjectTagEXT(device, &tagInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn DebugMarkerSetObjectNameEXT(device: Device, nameInfo: DebugMarkerObjectNameInfoEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkDebugMarkerSetObjectNameEXT(device, &nameInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CmdDebugMarkerBeginEXT(commandBuffer: CommandBuffer, markerInfo: DebugMarkerMarkerInfoEXT) void {
vkCmdDebugMarkerBeginEXT(commandBuffer, &markerInfo);
}
pub const CmdDebugMarkerEndEXT = vkCmdDebugMarkerEndEXT;
pub inline fn CmdDebugMarkerInsertEXT(commandBuffer: CommandBuffer, markerInfo: DebugMarkerMarkerInfoEXT) void {
vkCmdDebugMarkerInsertEXT(commandBuffer, &markerInfo);
}
pub const AMD_gcn_shader = 1;
pub const AMD_GCN_SHADER_SPEC_VERSION = 1;
pub const AMD_GCN_SHADER_EXTENSION_NAME = "VK_AMD_gcn_shader";
pub const NV_dedicated_allocation = 1;
pub const NV_DEDICATED_ALLOCATION_SPEC_VERSION = 1;
pub const NV_DEDICATED_ALLOCATION_EXTENSION_NAME = "VK_NV_dedicated_allocation";
pub const DedicatedAllocationImageCreateInfoNV = extern struct {
sType: StructureType = .DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
dedicatedAllocation: Bool32,
};
pub const DedicatedAllocationBufferCreateInfoNV = extern struct {
sType: StructureType = .DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV,
pNext: ?*const c_void = null,
dedicatedAllocation: Bool32,
};
pub const DedicatedAllocationMemoryAllocateInfoNV = extern struct {
sType: StructureType = .DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV,
pNext: ?*const c_void = null,
image: ?Image = null,
buffer: ?Buffer = null,
};
pub const EXT_transform_feedback = 1;
pub const EXT_TRANSFORM_FEEDBACK_SPEC_VERSION = 1;
pub const EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME = "VK_EXT_transform_feedback";
pub const PipelineRasterizationStateStreamCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceTransformFeedbackFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT,
pNext: ?*c_void = null,
transformFeedback: Bool32,
geometryStreams: Bool32,
};
pub const PhysicalDeviceTransformFeedbackPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT,
pNext: ?*c_void = null,
maxTransformFeedbackStreams: u32,
maxTransformFeedbackBuffers: u32,
maxTransformFeedbackBufferSize: DeviceSize,
maxTransformFeedbackStreamDataSize: u32,
maxTransformFeedbackBufferDataSize: u32,
maxTransformFeedbackBufferDataStride: u32,
transformFeedbackQueries: Bool32,
transformFeedbackStreamsLinesTriangles: Bool32,
transformFeedbackRasterizationStreamSelect: Bool32,
transformFeedbackDraw: Bool32,
};
pub const PipelineRasterizationStateStreamCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: PipelineRasterizationStateStreamCreateFlagsEXT align(4) = PipelineRasterizationStateStreamCreateFlagsEXT{},
rasterizationStream: u32,
};
pub extern fn vkCmdBindTransformFeedbackBuffersEXT(
commandBuffer: CommandBuffer,
firstBinding: u32,
bindingCount: u32,
pBuffers: [*]const Buffer,
pOffsets: [*]const DeviceSize,
pSizes: ?[*]const DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdBeginTransformFeedbackEXT(
commandBuffer: CommandBuffer,
firstCounterBuffer: u32,
counterBufferCount: u32,
pCounterBuffers: [*]const Buffer,
pCounterBufferOffsets: ?[*]const DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdEndTransformFeedbackEXT(
commandBuffer: CommandBuffer,
firstCounterBuffer: u32,
counterBufferCount: u32,
pCounterBuffers: [*]const Buffer,
pCounterBufferOffsets: ?[*]const DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdBeginQueryIndexedEXT(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
query: u32,
flags: QueryControlFlags.IntType,
index: u32,
) callconv(CallConv) void;
pub extern fn vkCmdEndQueryIndexedEXT(
commandBuffer: CommandBuffer,
queryPool: QueryPool,
query: u32,
index: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndirectByteCountEXT(
commandBuffer: CommandBuffer,
instanceCount: u32,
firstInstance: u32,
counterBuffer: Buffer,
counterBufferOffset: DeviceSize,
counterOffset: u32,
vertexStride: u32,
) callconv(CallConv) void;
pub inline fn CmdBindTransformFeedbackBuffersEXT(commandBuffer: CommandBuffer, firstBinding: u32, buffers: []const Buffer, offsets: []const DeviceSize, sizes: []const DeviceSize) void {
assert(offsets.len >= buffers.len);
assert(sizes.len >= buffers.len);
vkCmdBindTransformFeedbackBuffersEXT(commandBuffer, firstBinding, @intCast(u32, buffers.len), buffers.ptr, offsets.ptr, sizes.ptr);
}
pub inline fn CmdBeginTransformFeedbackEXT(commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBuffers: []const Buffer, counterBufferOffsets: []const DeviceSize) void {
assert(counterBufferOffsets.len >= counterBuffers.len);
vkCmdBeginTransformFeedbackEXT(commandBuffer, firstCounterBuffer, @intCast(u32, counterBuffers.len), counterBuffers.ptr, counterBufferOffsets.ptr);
}
pub inline fn CmdEndTransformFeedbackEXT(commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBuffers: []const Buffer, counterBufferOffsets: []const DeviceSize) void {
assert(counterBufferOffsets.len >= counterBuffers.len);
vkCmdEndTransformFeedbackEXT(commandBuffer, firstCounterBuffer, @intCast(u32, counterBuffers.len), counterBuffers.ptr, counterBufferOffsets.ptr);
}
pub inline fn CmdBeginQueryIndexedEXT(commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags, index: u32) void {
vkCmdBeginQueryIndexedEXT(commandBuffer, queryPool, query, flags.toInt(), index);
}
pub const CmdEndQueryIndexedEXT = vkCmdEndQueryIndexedEXT;
pub const CmdDrawIndirectByteCountEXT = vkCmdDrawIndirectByteCountEXT;
pub const NVX_image_view_handle = 1;
pub const NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION = 1;
pub const NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME = "VK_NVX_image_view_handle";
pub const ImageViewHandleInfoNVX = extern struct {
sType: StructureType = .IMAGE_VIEW_HANDLE_INFO_NVX,
pNext: ?*const c_void = null,
imageView: ImageView,
descriptorType: DescriptorType,
sampler: ?Sampler = null,
};
pub extern fn vkGetImageViewHandleNVX(
device: Device,
pInfo: *const ImageViewHandleInfoNVX,
) callconv(CallConv) u32;
pub inline fn GetImageViewHandleNVX(device: Device, info: ImageViewHandleInfoNVX) u32 {
const result = vkGetImageViewHandleNVX(device, &info);
return result;
}
pub const AMD_draw_indirect_count = 1;
pub const AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION = 2;
pub const AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME = "VK_AMD_draw_indirect_count";
pub extern fn vkCmdDrawIndirectCountAMD(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawIndexedIndirectCountAMD(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub const CmdDrawIndirectCountAMD = vkCmdDrawIndirectCountAMD;
pub const CmdDrawIndexedIndirectCountAMD = vkCmdDrawIndexedIndirectCountAMD;
pub const AMD_negative_viewport_height = 1;
pub const AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION = 1;
pub const AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME = "VK_AMD_negative_viewport_height";
pub const AMD_gpu_shader_half_float = 1;
pub const AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION = 2;
pub const AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME = "VK_AMD_gpu_shader_half_float";
pub const AMD_shader_ballot = 1;
pub const AMD_SHADER_BALLOT_SPEC_VERSION = 1;
pub const AMD_SHADER_BALLOT_EXTENSION_NAME = "VK_AMD_shader_ballot";
pub const AMD_texture_gather_bias_lod = 1;
pub const AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION = 1;
pub const AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME = "VK_AMD_texture_gather_bias_lod";
pub const TextureLODGatherFormatPropertiesAMD = extern struct {
sType: StructureType = .TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD,
pNext: ?*c_void = null,
supportsTextureGatherLODBiasAMD: Bool32,
};
pub const AMD_shader_info = 1;
pub const AMD_SHADER_INFO_SPEC_VERSION = 1;
pub const AMD_SHADER_INFO_EXTENSION_NAME = "VK_AMD_shader_info";
pub const ShaderInfoTypeAMD = extern enum(i32) {
STATISTICS = 0,
BINARY = 1,
DISASSEMBLY = 2,
_,
};
pub const ShaderResourceUsageAMD = extern struct {
numUsedVgprs: u32,
numUsedSgprs: u32,
ldsSizePerLocalWorkGroup: u32,
ldsUsageSizeInBytes: usize,
scratchMemUsageInBytes: usize,
};
pub const ShaderStatisticsInfoAMD = extern struct {
shaderStageMask: ShaderStageFlags align(4),
resourceUsage: ShaderResourceUsageAMD,
numPhysicalVgprs: u32,
numPhysicalSgprs: u32,
numAvailableVgprs: u32,
numAvailableSgprs: u32,
computeWorkGroupSize: [3]u32,
};
pub extern fn vkGetShaderInfoAMD(
device: Device,
pipeline: Pipeline,
shaderStage: ShaderStageFlags.IntType,
infoType: ShaderInfoTypeAMD,
pInfoSize: *usize,
pInfo: ?*c_void,
) callconv(CallConv) Result;
pub const GetShaderInfoAMDResult = struct {
result: Result,
info: []u8,
};
pub inline fn GetShaderInfoAMD(device: Device, pipeline: Pipeline, shaderStage: ShaderStageFlags, infoType: ShaderInfoTypeAMD, info: []u8) error{VK_FEATURE_NOT_PRESENT,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!GetShaderInfoAMDResult {
var returnValues: GetShaderInfoAMDResult = undefined;
var infoSize: usize = @intCast(usize, info.len);
const result = vkGetShaderInfoAMD(device, pipeline, shaderStage.toInt(), infoType, &infoSize, info.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_FEATURE_NOT_PRESENT => error.VK_FEATURE_NOT_PRESENT,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.info = info[0..infoSize];
returnValues.result = result;
return returnValues;
}
pub inline fn GetShaderInfoCountAMD(device: Device, pipeline: Pipeline, shaderStage: ShaderStageFlags, infoType: ShaderInfoTypeAMD) error{VK_FEATURE_NOT_PRESENT,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!usize {
var out_infoSize: usize = undefined;
const result = vkGetShaderInfoAMD(device, pipeline, shaderStage.toInt(), infoType, &out_infoSize, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_FEATURE_NOT_PRESENT => error.VK_FEATURE_NOT_PRESENT,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_infoSize;
}
pub const AMD_shader_image_load_store_lod = 1;
pub const AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION = 1;
pub const AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME = "VK_AMD_shader_image_load_store_lod";
pub const NV_corner_sampled_image = 1;
pub const NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION = 2;
pub const NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME = "VK_NV_corner_sampled_image";
pub const PhysicalDeviceCornerSampledImageFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV,
pNext: ?*c_void = null,
cornerSampledImage: Bool32,
};
pub const IMG_format_pvrtc = 1;
pub const IMG_FORMAT_PVRTC_SPEC_VERSION = 1;
pub const IMG_FORMAT_PVRTC_EXTENSION_NAME = "VK_IMG_format_pvrtc";
pub const NV_external_memory_capabilities = 1;
pub const NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION = 1;
pub const NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME = "VK_NV_external_memory_capabilities";
pub const ExternalMemoryHandleTypeFlagsNV = packed struct {
opaqueWin32: bool = false,
opaqueWin32Kmt: bool = false,
d3D11Image: bool = false,
d3D11ImageKmt: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ExternalMemoryFeatureFlagsNV = packed struct {
dedicatedOnly: bool = false,
exportable: bool = false,
importable: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ExternalImageFormatPropertiesNV = extern struct {
imageFormatProperties: ImageFormatProperties,
externalMemoryFeatures: ExternalMemoryFeatureFlagsNV align(4) = ExternalMemoryFeatureFlagsNV{},
exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlagsNV align(4) = ExternalMemoryHandleTypeFlagsNV{},
compatibleHandleTypes: ExternalMemoryHandleTypeFlagsNV align(4) = ExternalMemoryHandleTypeFlagsNV{},
};
pub extern fn vkGetPhysicalDeviceExternalImageFormatPropertiesNV(
physicalDevice: PhysicalDevice,
format: Format,
inType: ImageType,
tiling: ImageTiling,
usage: ImageUsageFlags.IntType,
flags: ImageCreateFlags.IntType,
externalHandleType: ExternalMemoryHandleTypeFlagsNV.IntType,
pExternalImageFormatProperties: *ExternalImageFormatPropertiesNV,
) callconv(CallConv) Result;
pub inline fn GetPhysicalDeviceExternalImageFormatPropertiesNV(physicalDevice: PhysicalDevice, format: Format, inType: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, externalHandleType: ExternalMemoryHandleTypeFlagsNV) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_FORMAT_NOT_SUPPORTED,VK_UNDOCUMENTED_ERROR}!ExternalImageFormatPropertiesNV {
var out_externalImageFormatProperties: ExternalImageFormatPropertiesNV = undefined;
const result = vkGetPhysicalDeviceExternalImageFormatPropertiesNV(physicalDevice, format, inType, tiling, usage.toInt(), flags.toInt(), externalHandleType.toInt(), &out_externalImageFormatProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_FORMAT_NOT_SUPPORTED => error.VK_FORMAT_NOT_SUPPORTED,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_externalImageFormatProperties;
}
pub const NV_external_memory = 1;
pub const NV_EXTERNAL_MEMORY_SPEC_VERSION = 1;
pub const NV_EXTERNAL_MEMORY_EXTENSION_NAME = "VK_NV_external_memory";
pub const ExternalMemoryImageCreateInfoNV = extern struct {
sType: StructureType = .EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
handleTypes: ExternalMemoryHandleTypeFlagsNV align(4) = ExternalMemoryHandleTypeFlagsNV{},
};
pub const ExportMemoryAllocateInfoNV = extern struct {
sType: StructureType = .EXPORT_MEMORY_ALLOCATE_INFO_NV,
pNext: ?*const c_void = null,
handleTypes: ExternalMemoryHandleTypeFlagsNV align(4) = ExternalMemoryHandleTypeFlagsNV{},
};
pub const EXT_validation_flags = 1;
pub const EXT_VALIDATION_FLAGS_SPEC_VERSION = 2;
pub const EXT_VALIDATION_FLAGS_EXTENSION_NAME = "VK_EXT_validation_flags";
pub const ValidationCheckEXT = extern enum(i32) {
ALL = 0,
SHADERS = 1,
_,
};
pub const ValidationFlagsEXT = extern struct {
sType: StructureType = .VALIDATION_FLAGS_EXT,
pNext: ?*const c_void = null,
disabledValidationCheckCount: u32,
pDisabledValidationChecks: [*]const ValidationCheckEXT,
};
pub const EXT_shader_subgroup_ballot = 1;
pub const EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION = 1;
pub const EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME = "VK_EXT_shader_subgroup_ballot";
pub const EXT_shader_subgroup_vote = 1;
pub const EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION = 1;
pub const EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME = "VK_EXT_shader_subgroup_vote";
pub const EXT_texture_compression_astc_hdr = 1;
pub const EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION = 1;
pub const EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME = "VK_EXT_texture_compression_astc_hdr";
pub const PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT,
pNext: ?*c_void = null,
textureCompressionASTC_HDR: Bool32,
};
pub const EXT_astc_decode_mode = 1;
pub const EXT_ASTC_DECODE_MODE_SPEC_VERSION = 1;
pub const EXT_ASTC_DECODE_MODE_EXTENSION_NAME = "VK_EXT_astc_decode_mode";
pub const ImageViewASTCDecodeModeEXT = extern struct {
sType: StructureType = .IMAGE_VIEW_ASTC_DECODE_MODE_EXT,
pNext: ?*const c_void = null,
decodeMode: Format,
};
pub const PhysicalDeviceASTCDecodeFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT,
pNext: ?*c_void = null,
decodeModeSharedExponent: Bool32,
};
pub const EXT_conditional_rendering = 1;
pub const EXT_CONDITIONAL_RENDERING_SPEC_VERSION = 2;
pub const EXT_CONDITIONAL_RENDERING_EXTENSION_NAME = "VK_EXT_conditional_rendering";
pub const ConditionalRenderingFlagsEXT = packed struct {
inverted: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ConditionalRenderingBeginInfoEXT = extern struct {
sType: StructureType = .CONDITIONAL_RENDERING_BEGIN_INFO_EXT,
pNext: ?*const c_void = null,
buffer: Buffer,
offset: DeviceSize,
flags: ConditionalRenderingFlagsEXT align(4) = ConditionalRenderingFlagsEXT{},
};
pub const PhysicalDeviceConditionalRenderingFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT,
pNext: ?*c_void = null,
conditionalRendering: Bool32,
inheritedConditionalRendering: Bool32,
};
pub const CommandBufferInheritanceConditionalRenderingInfoEXT = extern struct {
sType: StructureType = .COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
pNext: ?*const c_void = null,
conditionalRenderingEnable: Bool32,
};
pub extern fn vkCmdBeginConditionalRenderingEXT(
commandBuffer: CommandBuffer,
pConditionalRenderingBegin: *const ConditionalRenderingBeginInfoEXT,
) callconv(CallConv) void;
pub extern fn vkCmdEndConditionalRenderingEXT(commandBuffer: CommandBuffer) callconv(CallConv) void;
pub inline fn CmdBeginConditionalRenderingEXT(commandBuffer: CommandBuffer, conditionalRenderingBegin: ConditionalRenderingBeginInfoEXT) void {
vkCmdBeginConditionalRenderingEXT(commandBuffer, &conditionalRenderingBegin);
}
pub const CmdEndConditionalRenderingEXT = vkCmdEndConditionalRenderingEXT;
pub const NVX_device_generated_commands = 1;
pub const ObjectTableNVX = *@OpaqueType();
pub const IndirectCommandsLayoutNVX = *@OpaqueType();
pub const NVX_DEVICE_GENERATED_COMMANDS_SPEC_VERSION = 3;
pub const NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME = "VK_NVX_device_generated_commands";
pub const IndirectCommandsTokenTypeNVX = extern enum(i32) {
PIPELINE = 0,
DESCRIPTOR_SET = 1,
INDEX_BUFFER = 2,
VERTEX_BUFFER = 3,
PUSH_CONSTANT = 4,
DRAW_INDEXED = 5,
DRAW = 6,
DISPATCH = 7,
_,
};
pub const ObjectEntryTypeNVX = extern enum(i32) {
DESCRIPTOR_SET = 0,
PIPELINE = 1,
INDEX_BUFFER = 2,
VERTEX_BUFFER = 3,
PUSH_CONSTANT = 4,
_,
};
pub const IndirectCommandsLayoutUsageFlagsNVX = packed struct {
unorderedSequences: bool = false,
sparseSequences: bool = false,
emptyExecutions: bool = false,
indexedSequences: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const ObjectEntryUsageFlagsNVX = packed struct {
graphics: bool = false,
compute: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DeviceGeneratedCommandsFeaturesNVX = extern struct {
sType: StructureType = .DEVICE_GENERATED_COMMANDS_FEATURES_NVX,
pNext: ?*const c_void = null,
computeBindingPointSupport: Bool32,
};
pub const DeviceGeneratedCommandsLimitsNVX = extern struct {
sType: StructureType = .DEVICE_GENERATED_COMMANDS_LIMITS_NVX,
pNext: ?*const c_void = null,
maxIndirectCommandsLayoutTokenCount: u32,
maxObjectEntryCounts: u32,
minSequenceCountBufferOffsetAlignment: u32,
minSequenceIndexBufferOffsetAlignment: u32,
minCommandsTokenBufferOffsetAlignment: u32,
};
pub const IndirectCommandsTokenNVX = extern struct {
tokenType: IndirectCommandsTokenTypeNVX,
buffer: Buffer,
offset: DeviceSize,
};
pub const IndirectCommandsLayoutTokenNVX = extern struct {
tokenType: IndirectCommandsTokenTypeNVX,
bindingUnit: u32,
dynamicCount: u32,
divisor: u32,
};
pub const IndirectCommandsLayoutCreateInfoNVX = extern struct {
sType: StructureType = .INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NVX,
pNext: ?*const c_void = null,
pipelineBindPoint: PipelineBindPoint,
flags: IndirectCommandsLayoutUsageFlagsNVX align(4),
tokenCount: u32,
pTokens: [*]const IndirectCommandsLayoutTokenNVX,
};
pub const CmdProcessCommandsInfoNVX = extern struct {
sType: StructureType = .CMD_PROCESS_COMMANDS_INFO_NVX,
pNext: ?*const c_void = null,
objectTable: ObjectTableNVX,
indirectCommandsLayout: IndirectCommandsLayoutNVX,
indirectCommandsTokenCount: u32,
pIndirectCommandsTokens: [*]const IndirectCommandsTokenNVX,
maxSequencesCount: u32,
targetCommandBuffer: ?CommandBuffer = null,
sequencesCountBuffer: ?Buffer = null,
sequencesCountOffset: DeviceSize = 0,
sequencesIndexBuffer: ?Buffer = null,
sequencesIndexOffset: DeviceSize = 0,
};
pub const CmdReserveSpaceForCommandsInfoNVX = extern struct {
sType: StructureType = .CMD_RESERVE_SPACE_FOR_COMMANDS_INFO_NVX,
pNext: ?*const c_void = null,
objectTable: ObjectTableNVX,
indirectCommandsLayout: IndirectCommandsLayoutNVX,
maxSequencesCount: u32,
};
pub const ObjectTableCreateInfoNVX = extern struct {
sType: StructureType = .OBJECT_TABLE_CREATE_INFO_NVX,
pNext: ?*const c_void = null,
objectCount: u32,
pObjectEntryTypes: [*]const ObjectEntryTypeNVX,
pObjectEntryCounts: [*]const u32,
pObjectEntryUsageFlags: [*]align(4) const ObjectEntryUsageFlagsNVX,
maxUniformBuffersPerDescriptor: u32,
maxStorageBuffersPerDescriptor: u32,
maxStorageImagesPerDescriptor: u32,
maxSampledImagesPerDescriptor: u32,
maxPipelineLayouts: u32,
};
pub const ObjectTableEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
};
pub const ObjectTablePipelineEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
pipeline: Pipeline,
};
pub const ObjectTableDescriptorSetEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
pipelineLayout: PipelineLayout,
descriptorSet: DescriptorSet,
};
pub const ObjectTableVertexBufferEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
buffer: Buffer,
};
pub const ObjectTableIndexBufferEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
buffer: Buffer,
indexType: IndexType,
};
pub const ObjectTablePushConstantEntryNVX = extern struct {
inType: ObjectEntryTypeNVX,
flags: ObjectEntryUsageFlagsNVX align(4),
pipelineLayout: PipelineLayout,
stageFlags: ShaderStageFlags align(4),
};
pub extern fn vkCmdProcessCommandsNVX(
commandBuffer: CommandBuffer,
pProcessCommandsInfo: *const CmdProcessCommandsInfoNVX,
) callconv(CallConv) void;
pub extern fn vkCmdReserveSpaceForCommandsNVX(
commandBuffer: CommandBuffer,
pReserveSpaceInfo: *const CmdReserveSpaceForCommandsInfoNVX,
) callconv(CallConv) void;
pub extern fn vkCreateIndirectCommandsLayoutNVX(
device: Device,
pCreateInfo: *const IndirectCommandsLayoutCreateInfoNVX,
pAllocator: ?*const AllocationCallbacks,
pIndirectCommandsLayout: *IndirectCommandsLayoutNVX,
) callconv(CallConv) Result;
pub extern fn vkDestroyIndirectCommandsLayoutNVX(
device: Device,
indirectCommandsLayout: IndirectCommandsLayoutNVX,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkCreateObjectTableNVX(
device: Device,
pCreateInfo: *const ObjectTableCreateInfoNVX,
pAllocator: ?*const AllocationCallbacks,
pObjectTable: *ObjectTableNVX,
) callconv(CallConv) Result;
pub extern fn vkDestroyObjectTableNVX(
device: Device,
objectTable: ObjectTableNVX,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkRegisterObjectsNVX(
device: Device,
objectTable: ObjectTableNVX,
objectCount: u32,
ppObjectTableEntries: [*]const*const ObjectTableEntryNVX,
pObjectIndices: [*]const u32,
) callconv(CallConv) Result;
pub extern fn vkUnregisterObjectsNVX(
device: Device,
objectTable: ObjectTableNVX,
objectCount: u32,
pObjectEntryTypes: [*]const ObjectEntryTypeNVX,
pObjectIndices: [*]const u32,
) callconv(CallConv) Result;
pub extern fn vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(
physicalDevice: PhysicalDevice,
pFeatures: *DeviceGeneratedCommandsFeaturesNVX,
pLimits: *DeviceGeneratedCommandsLimitsNVX,
) callconv(CallConv) void;
pub inline fn CmdProcessCommandsNVX(commandBuffer: CommandBuffer, processCommandsInfo: CmdProcessCommandsInfoNVX) void {
vkCmdProcessCommandsNVX(commandBuffer, &processCommandsInfo);
}
pub inline fn CmdReserveSpaceForCommandsNVX(commandBuffer: CommandBuffer, reserveSpaceInfo: CmdReserveSpaceForCommandsInfoNVX) void {
vkCmdReserveSpaceForCommandsNVX(commandBuffer, &reserveSpaceInfo);
}
pub inline fn CreateIndirectCommandsLayoutNVX(device: Device, createInfo: IndirectCommandsLayoutCreateInfoNVX, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!IndirectCommandsLayoutNVX {
var out_indirectCommandsLayout: IndirectCommandsLayoutNVX = undefined;
const result = vkCreateIndirectCommandsLayoutNVX(device, &createInfo, pAllocator, &out_indirectCommandsLayout);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_indirectCommandsLayout;
}
pub const DestroyIndirectCommandsLayoutNVX = vkDestroyIndirectCommandsLayoutNVX;
pub inline fn CreateObjectTableNVX(device: Device, createInfo: ObjectTableCreateInfoNVX, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!ObjectTableNVX {
var out_objectTable: ObjectTableNVX = undefined;
const result = vkCreateObjectTableNVX(device, &createInfo, pAllocator, &out_objectTable);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_objectTable;
}
pub const DestroyObjectTableNVX = vkDestroyObjectTableNVX;
pub inline fn RegisterObjectsNVX(device: Device, objectTable: ObjectTableNVX, pObjectTableEntries: []const*const ObjectTableEntryNVX, objectIndices: []const u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
assert(objectIndices.len >= pObjectTableEntries.len);
const result = vkRegisterObjectsNVX(device, objectTable, @intCast(u32, pObjectTableEntries.len), pObjectTableEntries.ptr, objectIndices.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn UnregisterObjectsNVX(device: Device, objectTable: ObjectTableNVX, objectEntryTypes: []const ObjectEntryTypeNVX, objectIndices: []const u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
assert(objectIndices.len >= objectEntryTypes.len);
const result = vkUnregisterObjectsNVX(device, objectTable, @intCast(u32, objectEntryTypes.len), objectEntryTypes.ptr, objectIndices.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const GetPhysicalDeviceGeneratedCommandsPropertiesNVXResult = struct {
features: DeviceGeneratedCommandsFeaturesNVX,
limits: DeviceGeneratedCommandsLimitsNVX,
};
pub inline fn GetPhysicalDeviceGeneratedCommandsPropertiesNVX(physicalDevice: PhysicalDevice) GetPhysicalDeviceGeneratedCommandsPropertiesNVXResult {
var returnValues: GetPhysicalDeviceGeneratedCommandsPropertiesNVXResult = undefined;
vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(physicalDevice, &returnValues.features, &returnValues.limits);
return returnValues;
}
pub const NV_clip_space_w_scaling = 1;
pub const NV_CLIP_SPACE_W_SCALING_SPEC_VERSION = 1;
pub const NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME = "VK_NV_clip_space_w_scaling";
pub const ViewportWScalingNV = extern struct {
xcoeff: f32,
ycoeff: f32,
};
pub const PipelineViewportWScalingStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
viewportWScalingEnable: Bool32,
viewportCount: u32,
pViewportWScalings: ?[*]const ViewportWScalingNV = null,
};
pub extern fn vkCmdSetViewportWScalingNV(
commandBuffer: CommandBuffer,
firstViewport: u32,
viewportCount: u32,
pViewportWScalings: [*]const ViewportWScalingNV,
) callconv(CallConv) void;
pub inline fn CmdSetViewportWScalingNV(commandBuffer: CommandBuffer, firstViewport: u32, viewportWScalings: []const ViewportWScalingNV) void {
vkCmdSetViewportWScalingNV(commandBuffer, firstViewport, @intCast(u32, viewportWScalings.len), viewportWScalings.ptr);
}
pub const EXT_direct_mode_display = 1;
pub const EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION = 1;
pub const EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME = "VK_EXT_direct_mode_display";
pub extern fn vkReleaseDisplayEXT(
physicalDevice: PhysicalDevice,
display: DisplayKHR,
) callconv(CallConv) Result;
pub inline fn ReleaseDisplayEXT(physicalDevice: PhysicalDevice, display: DisplayKHR) error{VK_UNDOCUMENTED_ERROR}!void {
const result = vkReleaseDisplayEXT(physicalDevice, display);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
}
pub const EXT_display_surface_counter = 1;
pub const EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION = 1;
pub const EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME = "VK_EXT_display_surface_counter";
pub const SurfaceCounterFlagsEXT = packed struct {
vblank: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const SurfaceCapabilities2EXT = extern struct {
sType: StructureType = .SURFACE_CAPABILITIES_2_EXT,
pNext: ?*c_void = null,
minImageCount: u32,
maxImageCount: u32,
currentExtent: Extent2D,
minImageExtent: Extent2D,
maxImageExtent: Extent2D,
maxImageArrayLayers: u32,
supportedTransforms: SurfaceTransformFlagsKHR align(4) = SurfaceTransformFlagsKHR{},
currentTransform: SurfaceTransformFlagsKHR align(4),
supportedCompositeAlpha: CompositeAlphaFlagsKHR align(4) = CompositeAlphaFlagsKHR{},
supportedUsageFlags: ImageUsageFlags align(4) = ImageUsageFlags{},
supportedSurfaceCounters: SurfaceCounterFlagsEXT align(4) = SurfaceCounterFlagsEXT{},
};
pub extern fn vkGetPhysicalDeviceSurfaceCapabilities2EXT(
physicalDevice: PhysicalDevice,
surface: SurfaceKHR,
pSurfaceCapabilities: *SurfaceCapabilities2EXT,
) callconv(CallConv) Result;
pub inline fn GetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice: PhysicalDevice, surface: SurfaceKHR) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!SurfaceCapabilities2EXT {
var out_surfaceCapabilities: SurfaceCapabilities2EXT = undefined;
const result = vkGetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice, surface, &out_surfaceCapabilities);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surfaceCapabilities;
}
pub const EXT_display_control = 1;
pub const EXT_DISPLAY_CONTROL_SPEC_VERSION = 1;
pub const EXT_DISPLAY_CONTROL_EXTENSION_NAME = "VK_EXT_display_control";
pub const DisplayPowerStateEXT = extern enum(i32) {
OFF = 0,
SUSPEND = 1,
ON = 2,
_,
};
pub const DeviceEventTypeEXT = extern enum(i32) {
DISPLAY_HOTPLUG = 0,
_,
};
pub const DisplayEventTypeEXT = extern enum(i32) {
FIRST_PIXEL_OUT = 0,
_,
};
pub const DisplayPowerInfoEXT = extern struct {
sType: StructureType = .DISPLAY_POWER_INFO_EXT,
pNext: ?*const c_void = null,
powerState: DisplayPowerStateEXT,
};
pub const DeviceEventInfoEXT = extern struct {
sType: StructureType = .DEVICE_EVENT_INFO_EXT,
pNext: ?*const c_void = null,
deviceEvent: DeviceEventTypeEXT,
};
pub const DisplayEventInfoEXT = extern struct {
sType: StructureType = .DISPLAY_EVENT_INFO_EXT,
pNext: ?*const c_void = null,
displayEvent: DisplayEventTypeEXT,
};
pub const SwapchainCounterCreateInfoEXT = extern struct {
sType: StructureType = .SWAPCHAIN_COUNTER_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
surfaceCounters: SurfaceCounterFlagsEXT align(4) = SurfaceCounterFlagsEXT{},
};
pub extern fn vkDisplayPowerControlEXT(
device: Device,
display: DisplayKHR,
pDisplayPowerInfo: *const DisplayPowerInfoEXT,
) callconv(CallConv) Result;
pub extern fn vkRegisterDeviceEventEXT(
device: Device,
pDeviceEventInfo: *const DeviceEventInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pFence: *Fence,
) callconv(CallConv) Result;
pub extern fn vkRegisterDisplayEventEXT(
device: Device,
display: DisplayKHR,
pDisplayEventInfo: *const DisplayEventInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pFence: *Fence,
) callconv(CallConv) Result;
pub extern fn vkGetSwapchainCounterEXT(
device: Device,
swapchain: SwapchainKHR,
counter: SurfaceCounterFlagsEXT.IntType,
pCounterValue: *u64,
) callconv(CallConv) Result;
pub inline fn DisplayPowerControlEXT(device: Device, display: DisplayKHR, displayPowerInfo: DisplayPowerInfoEXT) error{VK_UNDOCUMENTED_ERROR}!void {
const result = vkDisplayPowerControlEXT(device, display, &displayPowerInfo);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
}
pub inline fn RegisterDeviceEventEXT(device: Device, deviceEventInfo: DeviceEventInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_UNDOCUMENTED_ERROR}!Fence {
var out_fence: Fence = undefined;
const result = vkRegisterDeviceEventEXT(device, &deviceEventInfo, pAllocator, &out_fence);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
return out_fence;
}
pub inline fn RegisterDisplayEventEXT(device: Device, display: DisplayKHR, displayEventInfo: DisplayEventInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_UNDOCUMENTED_ERROR}!Fence {
var out_fence: Fence = undefined;
const result = vkRegisterDisplayEventEXT(device, display, &displayEventInfo, pAllocator, &out_fence);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
return out_fence;
}
pub inline fn GetSwapchainCounterEXT(device: Device, swapchain: SwapchainKHR, counter: SurfaceCounterFlagsEXT) error{VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_UNDOCUMENTED_ERROR}!u64 {
var out_counterValue: u64 = undefined;
const result = vkGetSwapchainCounterEXT(device, swapchain, counter.toInt(), &out_counterValue);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_counterValue;
}
pub const GOOGLE_display_timing = 1;
pub const GOOGLE_DISPLAY_TIMING_SPEC_VERSION = 1;
pub const GOOGLE_DISPLAY_TIMING_EXTENSION_NAME = "VK_GOOGLE_display_timing";
pub const RefreshCycleDurationGOOGLE = extern struct {
refreshDuration: u64,
};
pub const PastPresentationTimingGOOGLE = extern struct {
presentID: u32,
desiredPresentTime: u64,
actualPresentTime: u64,
earliestPresentTime: u64,
presentMargin: u64,
};
pub const PresentTimeGOOGLE = extern struct {
presentID: u32,
desiredPresentTime: u64,
};
pub const PresentTimesInfoGOOGLE = extern struct {
sType: StructureType = .PRESENT_TIMES_INFO_GOOGLE,
pNext: ?*const c_void = null,
swapchainCount: u32,
pTimes: ?[*]const PresentTimeGOOGLE = null,
};
pub extern fn vkGetRefreshCycleDurationGOOGLE(
device: Device,
swapchain: SwapchainKHR,
pDisplayTimingProperties: *RefreshCycleDurationGOOGLE,
) callconv(CallConv) Result;
pub extern fn vkGetPastPresentationTimingGOOGLE(
device: Device,
swapchain: SwapchainKHR,
pPresentationTimingCount: *u32,
pPresentationTimings: ?[*]PastPresentationTimingGOOGLE,
) callconv(CallConv) Result;
pub inline fn GetRefreshCycleDurationGOOGLE(device: Device, swapchain: SwapchainKHR) error{VK_DEVICE_LOST,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!RefreshCycleDurationGOOGLE {
var out_displayTimingProperties: RefreshCycleDurationGOOGLE = undefined;
const result = vkGetRefreshCycleDurationGOOGLE(device, swapchain, &out_displayTimingProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_displayTimingProperties;
}
pub const GetPastPresentationTimingGOOGLEResult = struct {
result: Result,
presentationTimings: []PastPresentationTimingGOOGLE,
};
pub inline fn GetPastPresentationTimingGOOGLE(device: Device, swapchain: SwapchainKHR, presentationTimings: []PastPresentationTimingGOOGLE) error{VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!GetPastPresentationTimingGOOGLEResult {
var returnValues: GetPastPresentationTimingGOOGLEResult = undefined;
var presentationTimingCount: u32 = @intCast(u32, presentationTimings.len);
const result = vkGetPastPresentationTimingGOOGLE(device, swapchain, &presentationTimingCount, presentationTimings.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.presentationTimings = presentationTimings[0..presentationTimingCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPastPresentationTimingCountGOOGLE(device: Device, swapchain: SwapchainKHR) error{VK_DEVICE_LOST,VK_OUT_OF_DATE_KHR,VK_SURFACE_LOST_KHR,VK_UNDOCUMENTED_ERROR}!u32 {
var out_presentationTimingCount: u32 = undefined;
const result = vkGetPastPresentationTimingGOOGLE(device, swapchain, &out_presentationTimingCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_DEVICE_LOST => error.VK_DEVICE_LOST,
.ERROR_OUT_OF_DATE_KHR => error.VK_OUT_OF_DATE_KHR,
.ERROR_SURFACE_LOST_KHR => error.VK_SURFACE_LOST_KHR,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_presentationTimingCount;
}
pub const NV_sample_mask_override_coverage = 1;
pub const NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION = 1;
pub const NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME = "VK_NV_sample_mask_override_coverage";
pub const NV_geometry_shader_passthrough = 1;
pub const NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION = 1;
pub const NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME = "VK_NV_geometry_shader_passthrough";
pub const NV_viewport_array2 = 1;
pub const NV_VIEWPORT_ARRAY2_SPEC_VERSION = 1;
pub const NV_VIEWPORT_ARRAY2_EXTENSION_NAME = "VK_NV_viewport_array2";
pub const NVX_multiview_per_view_attributes = 1;
pub const NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION = 1;
pub const NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME = "VK_NVX_multiview_per_view_attributes";
pub const PhysicalDeviceMultiviewPerViewAttributesPropertiesNVX = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX,
pNext: ?*c_void = null,
perViewPositionAllComponents: Bool32,
};
pub const NV_viewport_swizzle = 1;
pub const NV_VIEWPORT_SWIZZLE_SPEC_VERSION = 1;
pub const NV_VIEWPORT_SWIZZLE_EXTENSION_NAME = "VK_NV_viewport_swizzle";
pub const ViewportCoordinateSwizzleNV = extern enum(i32) {
POSITIVE_X = 0,
NEGATIVE_X = 1,
POSITIVE_Y = 2,
NEGATIVE_Y = 3,
POSITIVE_Z = 4,
NEGATIVE_Z = 5,
POSITIVE_W = 6,
NEGATIVE_W = 7,
_,
};
pub const PipelineViewportSwizzleStateCreateFlagsNV = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ViewportSwizzleNV = extern struct {
x: ViewportCoordinateSwizzleNV,
y: ViewportCoordinateSwizzleNV,
z: ViewportCoordinateSwizzleNV,
w: ViewportCoordinateSwizzleNV,
};
pub const PipelineViewportSwizzleStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
flags: PipelineViewportSwizzleStateCreateFlagsNV align(4) = PipelineViewportSwizzleStateCreateFlagsNV{},
viewportCount: u32,
pViewportSwizzles: [*]const ViewportSwizzleNV,
};
pub const EXT_discard_rectangles = 1;
pub const EXT_DISCARD_RECTANGLES_SPEC_VERSION = 1;
pub const EXT_DISCARD_RECTANGLES_EXTENSION_NAME = "VK_EXT_discard_rectangles";
pub const DiscardRectangleModeEXT = extern enum(i32) {
INCLUSIVE = 0,
EXCLUSIVE = 1,
_,
};
pub const PipelineDiscardRectangleStateCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceDiscardRectanglePropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT,
pNext: ?*c_void = null,
maxDiscardRectangles: u32,
};
pub const PipelineDiscardRectangleStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: PipelineDiscardRectangleStateCreateFlagsEXT align(4) = PipelineDiscardRectangleStateCreateFlagsEXT{},
discardRectangleMode: DiscardRectangleModeEXT,
discardRectangleCount: u32 = 0,
pDiscardRectangles: ?[*]const Rect2D = null,
};
pub extern fn vkCmdSetDiscardRectangleEXT(
commandBuffer: CommandBuffer,
firstDiscardRectangle: u32,
discardRectangleCount: u32,
pDiscardRectangles: [*]const Rect2D,
) callconv(CallConv) void;
pub inline fn CmdSetDiscardRectangleEXT(commandBuffer: CommandBuffer, firstDiscardRectangle: u32, discardRectangles: []const Rect2D) void {
vkCmdSetDiscardRectangleEXT(commandBuffer, firstDiscardRectangle, @intCast(u32, discardRectangles.len), discardRectangles.ptr);
}
pub const EXT_conservative_rasterization = 1;
pub const EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION = 1;
pub const EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME = "VK_EXT_conservative_rasterization";
pub const ConservativeRasterizationModeEXT = extern enum(i32) {
DISABLED = 0,
OVERESTIMATE = 1,
UNDERESTIMATE = 2,
_,
};
pub const PipelineRasterizationConservativeStateCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceConservativeRasterizationPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT,
pNext: ?*c_void = null,
primitiveOverestimationSize: f32,
maxExtraPrimitiveOverestimationSize: f32,
extraPrimitiveOverestimationSizeGranularity: f32,
primitiveUnderestimation: Bool32,
conservativePointAndLineRasterization: Bool32,
degenerateTrianglesRasterized: Bool32,
degenerateLinesRasterized: Bool32,
fullyCoveredFragmentShaderInputVariable: Bool32,
conservativeRasterizationPostDepthCoverage: Bool32,
};
pub const PipelineRasterizationConservativeStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: PipelineRasterizationConservativeStateCreateFlagsEXT align(4) = PipelineRasterizationConservativeStateCreateFlagsEXT{},
conservativeRasterizationMode: ConservativeRasterizationModeEXT,
extraPrimitiveOverestimationSize: f32,
};
pub const EXT_depth_clip_enable = 1;
pub const EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION = 1;
pub const EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME = "VK_EXT_depth_clip_enable";
pub const PipelineRasterizationDepthClipStateCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceDepthClipEnableFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT,
pNext: ?*c_void = null,
depthClipEnable: Bool32,
};
pub const PipelineRasterizationDepthClipStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: PipelineRasterizationDepthClipStateCreateFlagsEXT align(4) = PipelineRasterizationDepthClipStateCreateFlagsEXT{},
depthClipEnable: Bool32,
};
pub const EXT_swapchain_colorspace = 1;
pub const EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION = 4;
pub const EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME = "VK_EXT_swapchain_colorspace";
pub const EXT_hdr_metadata = 1;
pub const EXT_HDR_METADATA_SPEC_VERSION = 2;
pub const EXT_HDR_METADATA_EXTENSION_NAME = "VK_EXT_hdr_metadata";
pub const XYColorEXT = extern struct {
x: f32,
y: f32,
};
pub const HdrMetadataEXT = extern struct {
sType: StructureType = .HDR_METADATA_EXT,
pNext: ?*const c_void = null,
displayPrimaryRed: XYColorEXT,
displayPrimaryGreen: XYColorEXT,
displayPrimaryBlue: XYColorEXT,
whitePoint: XYColorEXT,
maxLuminance: f32,
minLuminance: f32,
maxContentLightLevel: f32,
maxFrameAverageLightLevel: f32,
};
pub extern fn vkSetHdrMetadataEXT(
device: Device,
swapchainCount: u32,
pSwapchains: [*]const SwapchainKHR,
pMetadata: [*]const HdrMetadataEXT,
) callconv(CallConv) void;
pub inline fn SetHdrMetadataEXT(device: Device, swapchains: []const SwapchainKHR, metadata: []const HdrMetadataEXT) void {
assert(metadata.len >= swapchains.len);
vkSetHdrMetadataEXT(device, @intCast(u32, swapchains.len), swapchains.ptr, metadata.ptr);
}
pub const EXT_external_memory_dma_buf = 1;
pub const EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION = 1;
pub const EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME = "VK_EXT_external_memory_dma_buf";
pub const EXT_queue_family_foreign = 1;
pub const EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION = 1;
pub const EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME = "VK_EXT_queue_family_foreign";
pub const QUEUE_FAMILY_FOREIGN_EXT = (~@as(u32, 0)-2);
pub const EXT_debug_utils = 1;
pub const DebugUtilsMessengerEXT = *@OpaqueType();
pub const EXT_DEBUG_UTILS_SPEC_VERSION = 1;
pub const EXT_DEBUG_UTILS_EXTENSION_NAME = "VK_EXT_debug_utils";
pub const DebugUtilsMessengerCallbackDataFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DebugUtilsMessengerCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const DebugUtilsMessageSeverityFlagsEXT = packed struct {
verbose: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
info: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
warning: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
errorBit: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DebugUtilsMessageTypeFlagsEXT = packed struct {
general: bool = false,
validation: bool = false,
performance: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const DebugUtilsObjectNameInfoEXT = extern struct {
sType: StructureType = .DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
pNext: ?*const c_void = null,
objectType: ObjectType,
objectHandle: u64,
pObjectName: ?CString = null,
};
pub const DebugUtilsObjectTagInfoEXT = extern struct {
sType: StructureType = .DEBUG_UTILS_OBJECT_TAG_INFO_EXT,
pNext: ?*const c_void = null,
objectType: ObjectType,
objectHandle: u64,
tagName: u64,
tagSize: usize,
pTag: ?*const c_void,
};
pub const DebugUtilsLabelEXT = extern struct {
sType: StructureType = .DEBUG_UTILS_LABEL_EXT,
pNext: ?*const c_void = null,
pLabelName: CString,
color: [4]f32 = 0,
};
pub const DebugUtilsMessengerCallbackDataEXT = extern struct {
sType: StructureType = .DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT,
pNext: ?*const c_void = null,
flags: DebugUtilsMessengerCallbackDataFlagsEXT align(4) = DebugUtilsMessengerCallbackDataFlagsEXT{},
pMessageIdName: ?CString = null,
messageIdNumber: i32 = 0,
pMessage: CString,
queueLabelCount: u32 = 0,
pQueueLabels: [*]const DebugUtilsLabelEXT = undefined,
cmdBufLabelCount: u32 = 0,
pCmdBufLabels: [*]const DebugUtilsLabelEXT = undefined,
objectCount: u32 = 0,
pObjects: [*]const DebugUtilsObjectNameInfoEXT = undefined,
};
pub const PFN_DebugUtilsMessengerCallbackEXT = fn (
DebugUtilsMessageSeverityFlagsEXT.IntType,
DebugUtilsMessageTypeFlagsEXT.IntType,
?[*]const DebugUtilsMessengerCallbackDataEXT,
?*c_void,
) callconv(CallConv) Bool32;
pub const DebugUtilsMessengerCreateInfoEXT = extern struct {
sType: StructureType = .DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: DebugUtilsMessengerCreateFlagsEXT align(4) = DebugUtilsMessengerCreateFlagsEXT{},
messageSeverity: DebugUtilsMessageSeverityFlagsEXT align(4),
messageType: DebugUtilsMessageTypeFlagsEXT align(4),
pfnUserCallback: PFN_DebugUtilsMessengerCallbackEXT,
pUserData: ?*c_void = null,
};
pub extern fn vkSetDebugUtilsObjectNameEXT(
device: Device,
pNameInfo: *const DebugUtilsObjectNameInfoEXT,
) callconv(CallConv) Result;
pub extern fn vkSetDebugUtilsObjectTagEXT(
device: Device,
pTagInfo: *const DebugUtilsObjectTagInfoEXT,
) callconv(CallConv) Result;
pub extern fn vkQueueBeginDebugUtilsLabelEXT(
queue: Queue,
pLabelInfo: *const DebugUtilsLabelEXT,
) callconv(CallConv) void;
pub extern fn vkQueueEndDebugUtilsLabelEXT(queue: Queue) callconv(CallConv) void;
pub extern fn vkQueueInsertDebugUtilsLabelEXT(
queue: Queue,
pLabelInfo: *const DebugUtilsLabelEXT,
) callconv(CallConv) void;
pub extern fn vkCmdBeginDebugUtilsLabelEXT(
commandBuffer: CommandBuffer,
pLabelInfo: *const DebugUtilsLabelEXT,
) callconv(CallConv) void;
pub extern fn vkCmdEndDebugUtilsLabelEXT(commandBuffer: CommandBuffer) callconv(CallConv) void;
pub extern fn vkCmdInsertDebugUtilsLabelEXT(
commandBuffer: CommandBuffer,
pLabelInfo: *const DebugUtilsLabelEXT,
) callconv(CallConv) void;
pub extern fn vkCreateDebugUtilsMessengerEXT(
instance: Instance,
pCreateInfo: *const DebugUtilsMessengerCreateInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pMessenger: *DebugUtilsMessengerEXT,
) callconv(CallConv) Result;
pub extern fn vkDestroyDebugUtilsMessengerEXT(
instance: Instance,
messenger: DebugUtilsMessengerEXT,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkSubmitDebugUtilsMessageEXT(
instance: Instance,
messageSeverity: DebugUtilsMessageSeverityFlagsEXT.IntType,
messageTypes: DebugUtilsMessageTypeFlagsEXT.IntType,
pCallbackData: *const DebugUtilsMessengerCallbackDataEXT,
) callconv(CallConv) void;
pub inline fn SetDebugUtilsObjectNameEXT(device: Device, nameInfo: DebugUtilsObjectNameInfoEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn SetDebugUtilsObjectTagEXT(device: Device, tagInfo: DebugUtilsObjectTagInfoEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkSetDebugUtilsObjectTagEXT(device, &tagInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn QueueBeginDebugUtilsLabelEXT(queue: Queue, labelInfo: DebugUtilsLabelEXT) void {
vkQueueBeginDebugUtilsLabelEXT(queue, &labelInfo);
}
pub const QueueEndDebugUtilsLabelEXT = vkQueueEndDebugUtilsLabelEXT;
pub inline fn QueueInsertDebugUtilsLabelEXT(queue: Queue, labelInfo: DebugUtilsLabelEXT) void {
vkQueueInsertDebugUtilsLabelEXT(queue, &labelInfo);
}
pub inline fn CmdBeginDebugUtilsLabelEXT(commandBuffer: CommandBuffer, labelInfo: DebugUtilsLabelEXT) void {
vkCmdBeginDebugUtilsLabelEXT(commandBuffer, &labelInfo);
}
pub const CmdEndDebugUtilsLabelEXT = vkCmdEndDebugUtilsLabelEXT;
pub inline fn CmdInsertDebugUtilsLabelEXT(commandBuffer: CommandBuffer, labelInfo: DebugUtilsLabelEXT) void {
vkCmdInsertDebugUtilsLabelEXT(commandBuffer, &labelInfo);
}
pub inline fn CreateDebugUtilsMessengerEXT(instance: Instance, createInfo: DebugUtilsMessengerCreateInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!DebugUtilsMessengerEXT {
var out_messenger: DebugUtilsMessengerEXT = undefined;
const result = vkCreateDebugUtilsMessengerEXT(instance, &createInfo, pAllocator, &out_messenger);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_messenger;
}
pub const DestroyDebugUtilsMessengerEXT = vkDestroyDebugUtilsMessengerEXT;
pub inline fn SubmitDebugUtilsMessageEXT(instance: Instance, messageSeverity: DebugUtilsMessageSeverityFlagsEXT, messageTypes: DebugUtilsMessageTypeFlagsEXT, callbackData: DebugUtilsMessengerCallbackDataEXT) void {
vkSubmitDebugUtilsMessageEXT(instance, messageSeverity.toInt(), messageTypes.toInt(), &callbackData);
}
pub const EXT_sampler_filter_minmax = 1;
pub const EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION = 2;
pub const EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME = "VK_EXT_sampler_filter_minmax";
pub const SamplerReductionModeEXT = SamplerReductionMode;
pub const SamplerReductionModeCreateInfoEXT = SamplerReductionModeCreateInfo;
pub const PhysicalDeviceSamplerFilterMinmaxPropertiesEXT = PhysicalDeviceSamplerFilterMinmaxProperties;
pub const AMD_gpu_shader_int16 = 1;
pub const AMD_GPU_SHADER_INT16_SPEC_VERSION = 2;
pub const AMD_GPU_SHADER_INT16_EXTENSION_NAME = "VK_AMD_gpu_shader_int16";
pub const AMD_mixed_attachment_samples = 1;
pub const AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION = 1;
pub const AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME = "VK_AMD_mixed_attachment_samples";
pub const AMD_shader_fragment_mask = 1;
pub const AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION = 1;
pub const AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME = "VK_AMD_shader_fragment_mask";
pub const EXT_inline_uniform_block = 1;
pub const EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION = 1;
pub const EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME = "VK_EXT_inline_uniform_block";
pub const PhysicalDeviceInlineUniformBlockFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT,
pNext: ?*c_void = null,
inlineUniformBlock: Bool32,
descriptorBindingInlineUniformBlockUpdateAfterBind: Bool32,
};
pub const PhysicalDeviceInlineUniformBlockPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT,
pNext: ?*c_void = null,
maxInlineUniformBlockSize: u32,
maxPerStageDescriptorInlineUniformBlocks: u32,
maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks: u32,
maxDescriptorSetInlineUniformBlocks: u32,
maxDescriptorSetUpdateAfterBindInlineUniformBlocks: u32,
};
pub const WriteDescriptorSetInlineUniformBlockEXT = extern struct {
sType: StructureType = .WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT,
pNext: ?*const c_void = null,
dataSize: u32,
pData: ?*const c_void,
};
pub const DescriptorPoolInlineUniformBlockCreateInfoEXT = extern struct {
sType: StructureType = .DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
maxInlineUniformBlockBindings: u32,
};
pub const EXT_shader_stencil_export = 1;
pub const EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION = 1;
pub const EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME = "VK_EXT_shader_stencil_export";
pub const EXT_sample_locations = 1;
pub const EXT_SAMPLE_LOCATIONS_SPEC_VERSION = 1;
pub const EXT_SAMPLE_LOCATIONS_EXTENSION_NAME = "VK_EXT_sample_locations";
pub const SampleLocationEXT = extern struct {
x: f32,
y: f32,
};
pub const SampleLocationsInfoEXT = extern struct {
sType: StructureType = .SAMPLE_LOCATIONS_INFO_EXT,
pNext: ?*const c_void = null,
sampleLocationsPerPixel: SampleCountFlags align(4) = SampleCountFlags{},
sampleLocationGridSize: Extent2D,
sampleLocationsCount: u32 = 0,
pSampleLocations: [*]const SampleLocationEXT = undefined,
};
pub const AttachmentSampleLocationsEXT = extern struct {
attachmentIndex: u32,
sampleLocationsInfo: SampleLocationsInfoEXT,
};
pub const SubpassSampleLocationsEXT = extern struct {
subpassIndex: u32,
sampleLocationsInfo: SampleLocationsInfoEXT,
};
pub const RenderPassSampleLocationsBeginInfoEXT = extern struct {
sType: StructureType = .RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT,
pNext: ?*const c_void = null,
attachmentInitialSampleLocationsCount: u32 = 0,
pAttachmentInitialSampleLocations: [*]const AttachmentSampleLocationsEXT = undefined,
postSubpassSampleLocationsCount: u32 = 0,
pPostSubpassSampleLocations: [*]const SubpassSampleLocationsEXT = undefined,
};
pub const PipelineSampleLocationsStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
sampleLocationsEnable: Bool32,
sampleLocationsInfo: SampleLocationsInfoEXT,
};
pub const PhysicalDeviceSampleLocationsPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT,
pNext: ?*c_void = null,
sampleLocationSampleCounts: SampleCountFlags align(4),
maxSampleLocationGridSize: Extent2D,
sampleLocationCoordinateRange: [2]f32,
sampleLocationSubPixelBits: u32,
variableSampleLocations: Bool32,
};
pub const MultisamplePropertiesEXT = extern struct {
sType: StructureType = .MULTISAMPLE_PROPERTIES_EXT,
pNext: ?*c_void = null,
maxSampleLocationGridSize: Extent2D,
};
pub extern fn vkCmdSetSampleLocationsEXT(
commandBuffer: CommandBuffer,
pSampleLocationsInfo: *const SampleLocationsInfoEXT,
) callconv(CallConv) void;
pub extern fn vkGetPhysicalDeviceMultisamplePropertiesEXT(
physicalDevice: PhysicalDevice,
samples: SampleCountFlags.IntType,
pMultisampleProperties: *MultisamplePropertiesEXT,
) callconv(CallConv) void;
pub inline fn CmdSetSampleLocationsEXT(commandBuffer: CommandBuffer, sampleLocationsInfo: SampleLocationsInfoEXT) void {
vkCmdSetSampleLocationsEXT(commandBuffer, &sampleLocationsInfo);
}
pub inline fn GetPhysicalDeviceMultisamplePropertiesEXT(physicalDevice: PhysicalDevice, samples: SampleCountFlags) MultisamplePropertiesEXT {
var out_multisampleProperties: MultisamplePropertiesEXT = undefined;
vkGetPhysicalDeviceMultisamplePropertiesEXT(physicalDevice, samples.toInt(), &out_multisampleProperties);
return out_multisampleProperties;
}
pub const EXT_blend_operation_advanced = 1;
pub const EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION = 2;
pub const EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME = "VK_EXT_blend_operation_advanced";
pub const BlendOverlapEXT = extern enum(i32) {
UNCORRELATED = 0,
DISJOINT = 1,
CONJOINT = 2,
_,
};
pub const PhysicalDeviceBlendOperationAdvancedFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT,
pNext: ?*c_void = null,
advancedBlendCoherentOperations: Bool32,
};
pub const PhysicalDeviceBlendOperationAdvancedPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT,
pNext: ?*c_void = null,
advancedBlendMaxColorAttachments: u32,
advancedBlendIndependentBlend: Bool32,
advancedBlendNonPremultipliedSrcColor: Bool32,
advancedBlendNonPremultipliedDstColor: Bool32,
advancedBlendCorrelatedOverlap: Bool32,
advancedBlendAllOperations: Bool32,
};
pub const PipelineColorBlendAdvancedStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
srcPremultiplied: Bool32,
dstPremultiplied: Bool32,
blendOverlap: BlendOverlapEXT,
};
pub const NV_fragment_coverage_to_color = 1;
pub const NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION = 1;
pub const NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME = "VK_NV_fragment_coverage_to_color";
pub const PipelineCoverageToColorStateCreateFlagsNV = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCoverageToColorStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
flags: PipelineCoverageToColorStateCreateFlagsNV align(4) = PipelineCoverageToColorStateCreateFlagsNV{},
coverageToColorEnable: Bool32,
coverageToColorLocation: u32 = 0,
};
pub const NV_framebuffer_mixed_samples = 1;
pub const NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION = 1;
pub const NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME = "VK_NV_framebuffer_mixed_samples";
pub const CoverageModulationModeNV = extern enum(i32) {
NONE = 0,
RGB = 1,
ALPHA = 2,
RGBA = 3,
_,
};
pub const PipelineCoverageModulationStateCreateFlagsNV = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCoverageModulationStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
flags: PipelineCoverageModulationStateCreateFlagsNV align(4) = PipelineCoverageModulationStateCreateFlagsNV{},
coverageModulationMode: CoverageModulationModeNV,
coverageModulationTableEnable: Bool32,
coverageModulationTableCount: u32 = 0,
pCoverageModulationTable: ?[*]const f32 = null,
};
pub const NV_fill_rectangle = 1;
pub const NV_FILL_RECTANGLE_SPEC_VERSION = 1;
pub const NV_FILL_RECTANGLE_EXTENSION_NAME = "VK_NV_fill_rectangle";
pub const NV_shader_sm_builtins = 1;
pub const NV_SHADER_SM_BUILTINS_SPEC_VERSION = 1;
pub const NV_SHADER_SM_BUILTINS_EXTENSION_NAME = "VK_NV_shader_sm_builtins";
pub const PhysicalDeviceShaderSMBuiltinsPropertiesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV,
pNext: ?*c_void = null,
shaderSMCount: u32,
shaderWarpsPerSM: u32,
};
pub const PhysicalDeviceShaderSMBuiltinsFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV,
pNext: ?*c_void = null,
shaderSMBuiltins: Bool32,
};
pub const EXT_post_depth_coverage = 1;
pub const EXT_POST_DEPTH_COVERAGE_SPEC_VERSION = 1;
pub const EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME = "VK_EXT_post_depth_coverage";
pub const EXT_image_drm_format_modifier = 1;
pub const EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION = 1;
pub const EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME = "VK_EXT_image_drm_format_modifier";
pub const DrmFormatModifierPropertiesEXT = extern struct {
drmFormatModifier: u64,
drmFormatModifierPlaneCount: u32,
drmFormatModifierTilingFeatures: FormatFeatureFlags align(4),
};
pub const DrmFormatModifierPropertiesListEXT = extern struct {
sType: StructureType = .DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
pNext: ?*c_void = null,
drmFormatModifierCount: u32 = 0,
pDrmFormatModifierProperties: [*]DrmFormatModifierPropertiesEXT = undefined,
};
pub const PhysicalDeviceImageDrmFormatModifierInfoEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT,
pNext: ?*const c_void = null,
drmFormatModifier: u64,
sharingMode: SharingMode,
queueFamilyIndexCount: u32 = 0,
pQueueFamilyIndices: [*]const u32 = undefined,
};
pub const ImageDrmFormatModifierListCreateInfoEXT = extern struct {
sType: StructureType = .IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
drmFormatModifierCount: u32,
pDrmFormatModifiers: [*]const u64,
};
pub const ImageDrmFormatModifierExplicitCreateInfoEXT = extern struct {
sType: StructureType = .IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
drmFormatModifier: u64,
drmFormatModifierPlaneCount: u32,
pPlaneLayouts: [*]const SubresourceLayout,
};
pub const ImageDrmFormatModifierPropertiesEXT = extern struct {
sType: StructureType = .IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT,
pNext: ?*c_void = null,
drmFormatModifier: u64,
};
pub extern fn vkGetImageDrmFormatModifierPropertiesEXT(
device: Device,
image: Image,
pProperties: *ImageDrmFormatModifierPropertiesEXT,
) callconv(CallConv) Result;
pub inline fn GetImageDrmFormatModifierPropertiesEXT(device: Device, image: Image) error{VK_UNDOCUMENTED_ERROR}!ImageDrmFormatModifierPropertiesEXT {
var out_properties: ImageDrmFormatModifierPropertiesEXT = undefined;
const result = vkGetImageDrmFormatModifierPropertiesEXT(device, image, &out_properties);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
return out_properties;
}
pub const EXT_validation_cache = 1;
pub const ValidationCacheEXT = *@OpaqueType();
pub const EXT_VALIDATION_CACHE_SPEC_VERSION = 1;
pub const EXT_VALIDATION_CACHE_EXTENSION_NAME = "VK_EXT_validation_cache";
pub const ValidationCacheHeaderVersionEXT = extern enum(i32) {
ONE = 1,
_,
};
pub const ValidationCacheCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const ValidationCacheCreateInfoEXT = extern struct {
sType: StructureType = .VALIDATION_CACHE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: ValidationCacheCreateFlagsEXT align(4) = ValidationCacheCreateFlagsEXT{},
initialDataSize: usize = 0,
pInitialData: ?*const c_void = undefined,
};
pub const ShaderModuleValidationCacheCreateInfoEXT = extern struct {
sType: StructureType = .SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
validationCache: ValidationCacheEXT,
};
pub extern fn vkCreateValidationCacheEXT(
device: Device,
pCreateInfo: *const ValidationCacheCreateInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pValidationCache: *ValidationCacheEXT,
) callconv(CallConv) Result;
pub extern fn vkDestroyValidationCacheEXT(
device: Device,
validationCache: ?ValidationCacheEXT,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkMergeValidationCachesEXT(
device: Device,
dstCache: ValidationCacheEXT,
srcCacheCount: u32,
pSrcCaches: [*]const ValidationCacheEXT,
) callconv(CallConv) Result;
pub extern fn vkGetValidationCacheDataEXT(
device: Device,
validationCache: ValidationCacheEXT,
pDataSize: *usize,
pData: ?*c_void,
) callconv(CallConv) Result;
pub inline fn CreateValidationCacheEXT(device: Device, createInfo: ValidationCacheCreateInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!ValidationCacheEXT {
var out_validationCache: ValidationCacheEXT = undefined;
const result = vkCreateValidationCacheEXT(device, &createInfo, pAllocator, &out_validationCache);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_validationCache;
}
pub const DestroyValidationCacheEXT = vkDestroyValidationCacheEXT;
pub inline fn MergeValidationCachesEXT(device: Device, dstCache: ValidationCacheEXT, srcCaches: []const ValidationCacheEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkMergeValidationCachesEXT(device, dstCache, @intCast(u32, srcCaches.len), srcCaches.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const GetValidationCacheDataEXTResult = struct {
result: Result,
data: []u8,
};
pub inline fn GetValidationCacheDataEXT(device: Device, validationCache: ValidationCacheEXT, data: []u8) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetValidationCacheDataEXTResult {
var returnValues: GetValidationCacheDataEXTResult = undefined;
var dataSize: usize = @intCast(usize, data.len);
const result = vkGetValidationCacheDataEXT(device, validationCache, &dataSize, data.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.data = data[0..dataSize];
returnValues.result = result;
return returnValues;
}
pub inline fn GetValidationCacheDataCountEXT(device: Device, validationCache: ValidationCacheEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!usize {
var out_dataSize: usize = undefined;
const result = vkGetValidationCacheDataEXT(device, validationCache, &out_dataSize, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_dataSize;
}
pub const EXT_descriptor_indexing = 1;
pub const EXT_DESCRIPTOR_INDEXING_SPEC_VERSION = 2;
pub const EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME = "VK_EXT_descriptor_indexing";
pub const DescriptorBindingFlagsEXT = DescriptorBindingFlags;
pub const DescriptorSetLayoutBindingFlagsCreateInfoEXT = DescriptorSetLayoutBindingFlagsCreateInfo;
pub const PhysicalDeviceDescriptorIndexingFeaturesEXT = PhysicalDeviceDescriptorIndexingFeatures;
pub const PhysicalDeviceDescriptorIndexingPropertiesEXT = PhysicalDeviceDescriptorIndexingProperties;
pub const DescriptorSetVariableDescriptorCountAllocateInfoEXT = DescriptorSetVariableDescriptorCountAllocateInfo;
pub const DescriptorSetVariableDescriptorCountLayoutSupportEXT = DescriptorSetVariableDescriptorCountLayoutSupport;
pub const EXT_shader_viewport_index_layer = 1;
pub const EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION = 1;
pub const EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME = "VK_EXT_shader_viewport_index_layer";
pub const NV_shading_rate_image = 1;
pub const NV_SHADING_RATE_IMAGE_SPEC_VERSION = 3;
pub const NV_SHADING_RATE_IMAGE_EXTENSION_NAME = "VK_NV_shading_rate_image";
pub const ShadingRatePaletteEntryNV = extern enum(i32) {
NO_INVOCATIONS = 0,
T_16_INVOCATIONS_PER_PIXEL = 1,
T_8_INVOCATIONS_PER_PIXEL = 2,
T_4_INVOCATIONS_PER_PIXEL = 3,
T_2_INVOCATIONS_PER_PIXEL = 4,
T_1_INVOCATION_PER_PIXEL = 5,
T_1_INVOCATION_PER_2X1_PIXELS = 6,
T_1_INVOCATION_PER_1X2_PIXELS = 7,
T_1_INVOCATION_PER_2X2_PIXELS = 8,
T_1_INVOCATION_PER_4X2_PIXELS = 9,
T_1_INVOCATION_PER_2X4_PIXELS = 10,
T_1_INVOCATION_PER_4X4_PIXELS = 11,
_,
};
pub const CoarseSampleOrderTypeNV = extern enum(i32) {
DEFAULT = 0,
CUSTOM = 1,
PIXEL_MAJOR = 2,
SAMPLE_MAJOR = 3,
_,
};
pub const ShadingRatePaletteNV = extern struct {
shadingRatePaletteEntryCount: u32,
pShadingRatePaletteEntries: [*]const ShadingRatePaletteEntryNV,
};
pub const PipelineViewportShadingRateImageStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
shadingRateImageEnable: Bool32,
viewportCount: u32 = 0,
pShadingRatePalettes: ?[*]const ShadingRatePaletteNV = null,
};
pub const PhysicalDeviceShadingRateImageFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV,
pNext: ?*c_void = null,
shadingRateImage: Bool32,
shadingRateCoarseSampleOrder: Bool32,
};
pub const PhysicalDeviceShadingRateImagePropertiesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV,
pNext: ?*c_void = null,
shadingRateTexelSize: Extent2D,
shadingRatePaletteSize: u32,
shadingRateMaxCoarseSamples: u32,
};
pub const CoarseSampleLocationNV = extern struct {
pixelX: u32,
pixelY: u32,
sample: u32,
};
pub const CoarseSampleOrderCustomNV = extern struct {
shadingRate: ShadingRatePaletteEntryNV,
sampleCount: u32,
sampleLocationCount: u32,
pSampleLocations: [*]const CoarseSampleLocationNV,
};
pub const PipelineViewportCoarseSampleOrderStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
sampleOrderType: CoarseSampleOrderTypeNV,
customSampleOrderCount: u32 = 0,
pCustomSampleOrders: [*]const CoarseSampleOrderCustomNV = undefined,
};
pub extern fn vkCmdBindShadingRateImageNV(
commandBuffer: CommandBuffer,
imageView: ?ImageView,
imageLayout: ImageLayout,
) callconv(CallConv) void;
pub extern fn vkCmdSetViewportShadingRatePaletteNV(
commandBuffer: CommandBuffer,
firstViewport: u32,
viewportCount: u32,
pShadingRatePalettes: [*]const ShadingRatePaletteNV,
) callconv(CallConv) void;
pub extern fn vkCmdSetCoarseSampleOrderNV(
commandBuffer: CommandBuffer,
sampleOrderType: CoarseSampleOrderTypeNV,
customSampleOrderCount: u32,
pCustomSampleOrders: [*]const CoarseSampleOrderCustomNV,
) callconv(CallConv) void;
pub const CmdBindShadingRateImageNV = vkCmdBindShadingRateImageNV;
pub inline fn CmdSetViewportShadingRatePaletteNV(commandBuffer: CommandBuffer, firstViewport: u32, shadingRatePalettes: []const ShadingRatePaletteNV) void {
vkCmdSetViewportShadingRatePaletteNV(commandBuffer, firstViewport, @intCast(u32, shadingRatePalettes.len), shadingRatePalettes.ptr);
}
pub inline fn CmdSetCoarseSampleOrderNV(commandBuffer: CommandBuffer, sampleOrderType: CoarseSampleOrderTypeNV, customSampleOrders: []const CoarseSampleOrderCustomNV) void {
vkCmdSetCoarseSampleOrderNV(commandBuffer, sampleOrderType, @intCast(u32, customSampleOrders.len), customSampleOrders.ptr);
}
pub const NV_ray_tracing = 1;
pub const AccelerationStructureNV = *@OpaqueType();
pub const NV_RAY_TRACING_SPEC_VERSION = 3;
pub const NV_RAY_TRACING_EXTENSION_NAME = "VK_NV_ray_tracing";
pub const SHADER_UNUSED_NV = (~@as(u32, 0));
pub const AccelerationStructureTypeNV = extern enum(i32) {
TOP_LEVEL = 0,
BOTTOM_LEVEL = 1,
_,
};
pub const RayTracingShaderGroupTypeNV = extern enum(i32) {
GENERAL = 0,
TRIANGLES_HIT_GROUP = 1,
PROCEDURAL_HIT_GROUP = 2,
_,
};
pub const GeometryTypeNV = extern enum(i32) {
TRIANGLES = 0,
AABBS = 1,
_,
};
pub const CopyAccelerationStructureModeNV = extern enum(i32) {
CLONE = 0,
COMPACT = 1,
_,
};
pub const AccelerationStructureMemoryRequirementsTypeNV = extern enum(i32) {
OBJECT = 0,
BUILD_SCRATCH = 1,
UPDATE_SCRATCH = 2,
_,
};
pub const GeometryFlagsNV = packed struct {
opaque: bool = false,
noDuplicateAnyHitInvocation: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const GeometryInstanceFlagsNV = packed struct {
triangleCullDisable: bool = false,
triangleFrontCounterclockwise: bool = false,
forceOpaque: bool = false,
forceNoOpaque: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const BuildAccelerationStructureFlagsNV = packed struct {
allowUpdate: bool = false,
allowCompaction: bool = false,
preferFastTrace: bool = false,
preferFastBuild: bool = false,
lowMemory: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const RayTracingShaderGroupCreateInfoNV = extern struct {
sType: StructureType = .RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
pNext: ?*const c_void = null,
inType: RayTracingShaderGroupTypeNV,
generalShader: u32,
closestHitShader: u32,
anyHitShader: u32,
intersectionShader: u32,
};
pub const RayTracingPipelineCreateInfoNV = extern struct {
sType: StructureType = .RAY_TRACING_PIPELINE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
flags: PipelineCreateFlags align(4) = PipelineCreateFlags{},
stageCount: u32,
pStages: [*]const PipelineShaderStageCreateInfo,
groupCount: u32,
pGroups: [*]const RayTracingShaderGroupCreateInfoNV,
maxRecursionDepth: u32,
layout: PipelineLayout,
basePipelineHandle: ?Pipeline = null,
basePipelineIndex: i32,
};
pub const GeometryTrianglesNV = extern struct {
sType: StructureType = .GEOMETRY_TRIANGLES_NV,
pNext: ?*const c_void = null,
vertexData: ?Buffer = null,
vertexOffset: DeviceSize,
vertexCount: u32,
vertexStride: DeviceSize,
vertexFormat: Format,
indexData: ?Buffer = null,
indexOffset: DeviceSize,
indexCount: u32,
indexType: IndexType,
transformData: ?Buffer = null,
transformOffset: DeviceSize,
};
pub const GeometryAABBNV = extern struct {
sType: StructureType = .GEOMETRY_AABB_NV,
pNext: ?*const c_void = null,
aabbData: ?Buffer = null,
numAABBs: u32,
stride: u32,
offset: DeviceSize,
};
pub const GeometryDataNV = extern struct {
triangles: GeometryTrianglesNV,
aabbs: GeometryAABBNV,
};
pub const GeometryNV = extern struct {
sType: StructureType = .GEOMETRY_NV,
pNext: ?*const c_void = null,
geometryType: GeometryTypeNV,
geometry: GeometryDataNV,
flags: GeometryFlagsNV align(4) = GeometryFlagsNV{},
};
pub const AccelerationStructureInfoNV = extern struct {
sType: StructureType = .ACCELERATION_STRUCTURE_INFO_NV,
pNext: ?*const c_void = null,
inType: AccelerationStructureTypeNV,
flags: BuildAccelerationStructureFlagsNV align(4) = BuildAccelerationStructureFlagsNV{},
instanceCount: u32 = 0,
geometryCount: u32 = 0,
pGeometries: [*]const GeometryNV = undefined,
};
pub const AccelerationStructureCreateInfoNV = extern struct {
sType: StructureType = .ACCELERATION_STRUCTURE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
compactedSize: DeviceSize,
info: AccelerationStructureInfoNV,
};
pub const BindAccelerationStructureMemoryInfoNV = extern struct {
sType: StructureType = .BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV,
pNext: ?*const c_void = null,
accelerationStructure: AccelerationStructureNV,
memory: DeviceMemory,
memoryOffset: DeviceSize,
deviceIndexCount: u32 = 0,
pDeviceIndices: [*]const u32 = undefined,
};
pub const WriteDescriptorSetAccelerationStructureNV = extern struct {
sType: StructureType = .WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV,
pNext: ?*const c_void = null,
accelerationStructureCount: u32,
pAccelerationStructures: [*]const AccelerationStructureNV,
};
pub const AccelerationStructureMemoryRequirementsInfoNV = extern struct {
sType: StructureType = .ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
pNext: ?*const c_void = null,
inType: AccelerationStructureMemoryRequirementsTypeNV,
accelerationStructure: AccelerationStructureNV,
};
pub const PhysicalDeviceRayTracingPropertiesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV,
pNext: ?*c_void = null,
shaderGroupHandleSize: u32,
maxRecursionDepth: u32,
maxShaderGroupStride: u32,
shaderGroupBaseAlignment: u32,
maxGeometryCount: u64,
maxInstanceCount: u64,
maxTriangleCount: u64,
maxDescriptorSetAccelerationStructures: u32,
};
pub extern fn vkCreateAccelerationStructureNV(
device: Device,
pCreateInfo: *const AccelerationStructureCreateInfoNV,
pAllocator: ?*const AllocationCallbacks,
pAccelerationStructure: *AccelerationStructureNV,
) callconv(CallConv) Result;
pub extern fn vkDestroyAccelerationStructureNV(
device: Device,
accelerationStructure: AccelerationStructureNV,
pAllocator: ?*const AllocationCallbacks,
) callconv(CallConv) void;
pub extern fn vkGetAccelerationStructureMemoryRequirementsNV(
device: Device,
pInfo: *const AccelerationStructureMemoryRequirementsInfoNV,
pMemoryRequirements: *MemoryRequirements2KHR,
) callconv(CallConv) void;
pub extern fn vkBindAccelerationStructureMemoryNV(
device: Device,
bindInfoCount: u32,
pBindInfos: [*]const BindAccelerationStructureMemoryInfoNV,
) callconv(CallConv) Result;
pub extern fn vkCmdBuildAccelerationStructureNV(
commandBuffer: CommandBuffer,
pInfo: *const AccelerationStructureInfoNV,
instanceData: ?Buffer,
instanceOffset: DeviceSize,
update: Bool32,
dst: AccelerationStructureNV,
src: ?AccelerationStructureNV,
scratch: Buffer,
scratchOffset: DeviceSize,
) callconv(CallConv) void;
pub extern fn vkCmdCopyAccelerationStructureNV(
commandBuffer: CommandBuffer,
dst: AccelerationStructureNV,
src: AccelerationStructureNV,
mode: CopyAccelerationStructureModeNV,
) callconv(CallConv) void;
pub extern fn vkCmdTraceRaysNV(
commandBuffer: CommandBuffer,
raygenShaderBindingTableBuffer: Buffer,
raygenShaderBindingOffset: DeviceSize,
missShaderBindingTableBuffer: ?Buffer,
missShaderBindingOffset: DeviceSize,
missShaderBindingStride: DeviceSize,
hitShaderBindingTableBuffer: ?Buffer,
hitShaderBindingOffset: DeviceSize,
hitShaderBindingStride: DeviceSize,
callableShaderBindingTableBuffer: ?Buffer,
callableShaderBindingOffset: DeviceSize,
callableShaderBindingStride: DeviceSize,
width: u32,
height: u32,
depth: u32,
) callconv(CallConv) void;
pub extern fn vkCreateRayTracingPipelinesNV(
device: Device,
pipelineCache: ?PipelineCache,
createInfoCount: u32,
pCreateInfos: [*]const RayTracingPipelineCreateInfoNV,
pAllocator: ?*const AllocationCallbacks,
pPipelines: [*]Pipeline,
) callconv(CallConv) Result;
pub extern fn vkGetRayTracingShaderGroupHandlesNV(
device: Device,
pipeline: Pipeline,
firstGroup: u32,
groupCount: u32,
dataSize: usize,
pData: ?*c_void,
) callconv(CallConv) Result;
pub extern fn vkGetAccelerationStructureHandleNV(
device: Device,
accelerationStructure: AccelerationStructureNV,
dataSize: usize,
pData: ?*c_void,
) callconv(CallConv) Result;
pub extern fn vkCmdWriteAccelerationStructuresPropertiesNV(
commandBuffer: CommandBuffer,
accelerationStructureCount: u32,
pAccelerationStructures: [*]const AccelerationStructureNV,
queryType: QueryType,
queryPool: QueryPool,
firstQuery: u32,
) callconv(CallConv) void;
pub extern fn vkCompileDeferredNV(
device: Device,
pipeline: Pipeline,
shader: u32,
) callconv(CallConv) Result;
pub inline fn CreateAccelerationStructureNV(device: Device, createInfo: AccelerationStructureCreateInfoNV, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!AccelerationStructureNV {
var out_accelerationStructure: AccelerationStructureNV = undefined;
const result = vkCreateAccelerationStructureNV(device, &createInfo, pAllocator, &out_accelerationStructure);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_accelerationStructure;
}
pub const DestroyAccelerationStructureNV = vkDestroyAccelerationStructureNV;
pub inline fn GetAccelerationStructureMemoryRequirementsNV(device: Device, info: AccelerationStructureMemoryRequirementsInfoNV) MemoryRequirements2KHR {
var out_memoryRequirements: MemoryRequirements2KHR = undefined;
vkGetAccelerationStructureMemoryRequirementsNV(device, &info, &out_memoryRequirements);
return out_memoryRequirements;
}
pub inline fn BindAccelerationStructureMemoryNV(device: Device, bindInfos: []const BindAccelerationStructureMemoryInfoNV) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkBindAccelerationStructureMemoryNV(device, @intCast(u32, bindInfos.len), bindInfos.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CmdBuildAccelerationStructureNV(commandBuffer: CommandBuffer, info: AccelerationStructureInfoNV, instanceData: ?Buffer, instanceOffset: DeviceSize, update: Bool32, dst: AccelerationStructureNV, src: ?AccelerationStructureNV, scratch: Buffer, scratchOffset: DeviceSize) void {
vkCmdBuildAccelerationStructureNV(commandBuffer, &info, instanceData, instanceOffset, update, dst, src, scratch, scratchOffset);
}
pub const CmdCopyAccelerationStructureNV = vkCmdCopyAccelerationStructureNV;
pub const CmdTraceRaysNV = vkCmdTraceRaysNV;
pub inline fn CreateRayTracingPipelinesNV(device: Device, pipelineCache: ?PipelineCache, createInfos: []const RayTracingPipelineCreateInfoNV, pAllocator: ?*const AllocationCallbacks, pipelines: []Pipeline) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_INVALID_SHADER_NV,VK_UNDOCUMENTED_ERROR}!void {
assert(pipelines.len >= createInfos.len);
const result = vkCreateRayTracingPipelinesNV(device, pipelineCache, @intCast(u32, createInfos.len), createInfos.ptr, pAllocator, pipelines.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
.ERROR_INVALID_SHADER_NV => error.VK_INVALID_SHADER_NV,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetRayTracingShaderGroupHandlesNV(device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, data: []u8) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkGetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, @intCast(usize, data.len), data.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetAccelerationStructureHandleNV(device: Device, accelerationStructure: AccelerationStructureNV, data: []u8) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkGetAccelerationStructureHandleNV(device, accelerationStructure, @intCast(usize, data.len), data.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CmdWriteAccelerationStructuresPropertiesNV(commandBuffer: CommandBuffer, accelerationStructures: []const AccelerationStructureNV, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) void {
vkCmdWriteAccelerationStructuresPropertiesNV(commandBuffer, @intCast(u32, accelerationStructures.len), accelerationStructures.ptr, queryType, queryPool, firstQuery);
}
pub inline fn CompileDeferredNV(device: Device, pipeline: Pipeline, shader: u32) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkCompileDeferredNV(device, pipeline, shader);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const NV_representative_fragment_test = 1;
pub const NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION = 2;
pub const NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME = "VK_NV_representative_fragment_test";
pub const PhysicalDeviceRepresentativeFragmentTestFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV,
pNext: ?*c_void = null,
representativeFragmentTest: Bool32,
};
pub const PipelineRepresentativeFragmentTestStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
representativeFragmentTestEnable: Bool32,
};
pub const EXT_filter_cubic = 1;
pub const EXT_FILTER_CUBIC_SPEC_VERSION = 3;
pub const EXT_FILTER_CUBIC_EXTENSION_NAME = "VK_EXT_filter_cubic";
pub const PhysicalDeviceImageViewImageFormatInfoEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT,
pNext: ?*c_void = null,
imageViewType: ImageViewType,
};
pub const FilterCubicImageViewImageFormatPropertiesEXT = extern struct {
sType: StructureType = .FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT,
pNext: ?*c_void = null,
filterCubic: Bool32,
filterCubicMinmax: Bool32,
};
pub const EXT_global_priority = 1;
pub const EXT_GLOBAL_PRIORITY_SPEC_VERSION = 2;
pub const EXT_GLOBAL_PRIORITY_EXTENSION_NAME = "VK_EXT_global_priority";
pub const QueueGlobalPriorityEXT = extern enum(i32) {
LOW = 128,
MEDIUM = 256,
HIGH = 512,
REALTIME = 1024,
_,
};
pub const DeviceQueueGlobalPriorityCreateInfoEXT = extern struct {
sType: StructureType = .DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
globalPriority: QueueGlobalPriorityEXT,
};
pub const EXT_external_memory_host = 1;
pub const EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION = 1;
pub const EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME = "VK_EXT_external_memory_host";
pub const ImportMemoryHostPointerInfoEXT = extern struct {
sType: StructureType = .IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
pNext: ?*const c_void = null,
handleType: ExternalMemoryHandleTypeFlags align(4),
pHostPointer: ?*c_void,
};
pub const MemoryHostPointerPropertiesEXT = extern struct {
sType: StructureType = .MEMORY_HOST_POINTER_PROPERTIES_EXT,
pNext: ?*c_void = null,
memoryTypeBits: u32,
};
pub const PhysicalDeviceExternalMemoryHostPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT,
pNext: ?*c_void = null,
minImportedHostPointerAlignment: DeviceSize,
};
pub extern fn vkGetMemoryHostPointerPropertiesEXT(
device: Device,
handleType: ExternalMemoryHandleTypeFlags.IntType,
pHostPointer: ?*const c_void,
pMemoryHostPointerProperties: *MemoryHostPointerPropertiesEXT,
) callconv(CallConv) Result;
pub inline fn GetMemoryHostPointerPropertiesEXT(device: Device, handleType: ExternalMemoryHandleTypeFlags, pHostPointer: ?*const c_void) error{VK_INVALID_EXTERNAL_HANDLE,VK_UNDOCUMENTED_ERROR}!MemoryHostPointerPropertiesEXT {
var out_memoryHostPointerProperties: MemoryHostPointerPropertiesEXT = undefined;
const result = vkGetMemoryHostPointerPropertiesEXT(device, handleType.toInt(), pHostPointer, &out_memoryHostPointerProperties);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_INVALID_EXTERNAL_HANDLE => error.VK_INVALID_EXTERNAL_HANDLE,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_memoryHostPointerProperties;
}
pub const AMD_buffer_marker = 1;
pub const AMD_BUFFER_MARKER_SPEC_VERSION = 1;
pub const AMD_BUFFER_MARKER_EXTENSION_NAME = "VK_AMD_buffer_marker";
pub extern fn vkCmdWriteBufferMarkerAMD(
commandBuffer: CommandBuffer,
pipelineStage: PipelineStageFlags.IntType,
dstBuffer: Buffer,
dstOffset: DeviceSize,
marker: u32,
) callconv(CallConv) void;
pub inline fn CmdWriteBufferMarkerAMD(commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, dstBuffer: Buffer, dstOffset: DeviceSize, marker: u32) void {
vkCmdWriteBufferMarkerAMD(commandBuffer, pipelineStage.toInt(), dstBuffer, dstOffset, marker);
}
pub const AMD_pipeline_compiler_control = 1;
pub const AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION = 1;
pub const AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME = "VK_AMD_pipeline_compiler_control";
pub const PipelineCompilerControlFlagsAMD = packed struct {
__reserved_bit_00: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCompilerControlCreateInfoAMD = extern struct {
sType: StructureType = .PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD,
pNext: ?*const c_void = null,
compilerControlFlags: PipelineCompilerControlFlagsAMD align(4) = PipelineCompilerControlFlagsAMD{},
};
pub const EXT_calibrated_timestamps = 1;
pub const EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION = 1;
pub const EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME = "VK_EXT_calibrated_timestamps";
pub const TimeDomainEXT = extern enum(i32) {
DEVICE = 0,
CLOCK_MONOTONIC = 1,
CLOCK_MONOTONIC_RAW = 2,
QUERY_PERFORMANCE_COUNTER = 3,
_,
};
pub const CalibratedTimestampInfoEXT = extern struct {
sType: StructureType = .CALIBRATED_TIMESTAMP_INFO_EXT,
pNext: ?*const c_void = null,
timeDomain: TimeDomainEXT,
};
pub extern fn vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(
physicalDevice: PhysicalDevice,
pTimeDomainCount: *u32,
pTimeDomains: ?[*]TimeDomainEXT,
) callconv(CallConv) Result;
pub extern fn vkGetCalibratedTimestampsEXT(
device: Device,
timestampCount: u32,
pTimestampInfos: [*]const CalibratedTimestampInfoEXT,
pTimestamps: [*]u64,
pMaxDeviation: *u64,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceCalibrateableTimeDomainsEXTResult = struct {
result: Result,
timeDomains: []TimeDomainEXT,
};
pub inline fn GetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice: PhysicalDevice, timeDomains: []TimeDomainEXT) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceCalibrateableTimeDomainsEXTResult {
var returnValues: GetPhysicalDeviceCalibrateableTimeDomainsEXTResult = undefined;
var timeDomainCount: u32 = @intCast(u32, timeDomains.len);
const result = vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice, &timeDomainCount, timeDomains.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.timeDomains = timeDomains[0..timeDomainCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceCalibrateableTimeDomainsCountEXT(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_timeDomainCount: u32 = undefined;
const result = vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice, &out_timeDomainCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_timeDomainCount;
}
pub inline fn GetCalibratedTimestampsEXT(device: Device, timestampInfos: []const CalibratedTimestampInfoEXT, timestamps: []u64) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u64 {
var out_maxDeviation: u64 = undefined;
assert(timestamps.len >= timestampInfos.len);
const result = vkGetCalibratedTimestampsEXT(device, @intCast(u32, timestampInfos.len), timestampInfos.ptr, timestamps.ptr, &out_maxDeviation);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_maxDeviation;
}
pub const AMD_shader_core_properties = 1;
pub const AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION = 2;
pub const AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME = "VK_AMD_shader_core_properties";
pub const PhysicalDeviceShaderCorePropertiesAMD = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD,
pNext: ?*c_void = null,
shaderEngineCount: u32,
shaderArraysPerEngineCount: u32,
computeUnitsPerShaderArray: u32,
simdPerComputeUnit: u32,
wavefrontsPerSimd: u32,
wavefrontSize: u32,
sgprsPerSimd: u32,
minSgprAllocation: u32,
maxSgprAllocation: u32,
sgprAllocationGranularity: u32,
vgprsPerSimd: u32,
minVgprAllocation: u32,
maxVgprAllocation: u32,
vgprAllocationGranularity: u32,
};
pub const AMD_memory_overallocation_behavior = 1;
pub const AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION = 1;
pub const AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME = "VK_AMD_memory_overallocation_behavior";
pub const MemoryOverallocationBehaviorAMD = extern enum(i32) {
DEFAULT = 0,
ALLOWED = 1,
DISALLOWED = 2,
_,
};
pub const DeviceMemoryOverallocationCreateInfoAMD = extern struct {
sType: StructureType = .DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD,
pNext: ?*const c_void = null,
overallocationBehavior: MemoryOverallocationBehaviorAMD,
};
pub const EXT_vertex_attribute_divisor = 1;
pub const EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION = 3;
pub const EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME = "VK_EXT_vertex_attribute_divisor";
pub const PhysicalDeviceVertexAttributeDivisorPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT,
pNext: ?*c_void = null,
maxVertexAttribDivisor: u32,
};
pub const VertexInputBindingDivisorDescriptionEXT = extern struct {
binding: u32,
divisor: u32,
};
pub const PipelineVertexInputDivisorStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
vertexBindingDivisorCount: u32,
pVertexBindingDivisors: [*]const VertexInputBindingDivisorDescriptionEXT,
};
pub const PhysicalDeviceVertexAttributeDivisorFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT,
pNext: ?*c_void = null,
vertexAttributeInstanceRateDivisor: Bool32,
vertexAttributeInstanceRateZeroDivisor: Bool32,
};
pub const EXT_pipeline_creation_feedback = 1;
pub const EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION = 1;
pub const EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME = "VK_EXT_pipeline_creation_feedback";
pub const PipelineCreationFeedbackFlagsEXT = packed struct {
valid: bool = false,
applicationPipelineCacheHit: bool = false,
basePipelineAcceleration: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PipelineCreationFeedbackEXT = extern struct {
flags: PipelineCreationFeedbackFlagsEXT align(4),
duration: u64,
};
pub const PipelineCreationFeedbackCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
pPipelineCreationFeedback: *PipelineCreationFeedbackEXT,
pipelineStageCreationFeedbackCount: u32,
pPipelineStageCreationFeedbacks: [*]PipelineCreationFeedbackEXT,
};
pub const NV_shader_subgroup_partitioned = 1;
pub const NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION = 1;
pub const NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME = "VK_NV_shader_subgroup_partitioned";
pub const NV_compute_shader_derivatives = 1;
pub const NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION = 1;
pub const NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME = "VK_NV_compute_shader_derivatives";
pub const PhysicalDeviceComputeShaderDerivativesFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV,
pNext: ?*c_void = null,
computeDerivativeGroupQuads: Bool32,
computeDerivativeGroupLinear: Bool32,
};
pub const NV_mesh_shader = 1;
pub const NV_MESH_SHADER_SPEC_VERSION = 1;
pub const NV_MESH_SHADER_EXTENSION_NAME = "VK_NV_mesh_shader";
pub const PhysicalDeviceMeshShaderFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV,
pNext: ?*c_void = null,
taskShader: Bool32,
meshShader: Bool32,
};
pub const PhysicalDeviceMeshShaderPropertiesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV,
pNext: ?*c_void = null,
maxDrawMeshTasksCount: u32,
maxTaskWorkGroupInvocations: u32,
maxTaskWorkGroupSize: [3]u32,
maxTaskTotalMemorySize: u32,
maxTaskOutputCount: u32,
maxMeshWorkGroupInvocations: u32,
maxMeshWorkGroupSize: [3]u32,
maxMeshTotalMemorySize: u32,
maxMeshOutputVertices: u32,
maxMeshOutputPrimitives: u32,
maxMeshMultiviewViewCount: u32,
meshOutputPerVertexGranularity: u32,
meshOutputPerPrimitiveGranularity: u32,
};
pub const DrawMeshTasksIndirectCommandNV = extern struct {
taskCount: u32,
firstTask: u32,
};
pub extern fn vkCmdDrawMeshTasksNV(
commandBuffer: CommandBuffer,
taskCount: u32,
firstTask: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawMeshTasksIndirectNV(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
drawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub extern fn vkCmdDrawMeshTasksIndirectCountNV(
commandBuffer: CommandBuffer,
buffer: Buffer,
offset: DeviceSize,
countBuffer: Buffer,
countBufferOffset: DeviceSize,
maxDrawCount: u32,
stride: u32,
) callconv(CallConv) void;
pub const CmdDrawMeshTasksNV = vkCmdDrawMeshTasksNV;
pub const CmdDrawMeshTasksIndirectNV = vkCmdDrawMeshTasksIndirectNV;
pub const CmdDrawMeshTasksIndirectCountNV = vkCmdDrawMeshTasksIndirectCountNV;
pub const NV_fragment_shader_barycentric = 1;
pub const NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION = 1;
pub const NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME = "VK_NV_fragment_shader_barycentric";
pub const PhysicalDeviceFragmentShaderBarycentricFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV,
pNext: ?*c_void = null,
fragmentShaderBarycentric: Bool32,
};
pub const NV_shader_image_footprint = 1;
pub const NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION = 2;
pub const NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME = "VK_NV_shader_image_footprint";
pub const PhysicalDeviceShaderImageFootprintFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV,
pNext: ?*c_void = null,
imageFootprint: Bool32,
};
pub const NV_scissor_exclusive = 1;
pub const NV_SCISSOR_EXCLUSIVE_SPEC_VERSION = 1;
pub const NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME = "VK_NV_scissor_exclusive";
pub const PipelineViewportExclusiveScissorStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
exclusiveScissorCount: u32 = 0,
pExclusiveScissors: ?[*]const Rect2D = null,
};
pub const PhysicalDeviceExclusiveScissorFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV,
pNext: ?*c_void = null,
exclusiveScissor: Bool32,
};
pub extern fn vkCmdSetExclusiveScissorNV(
commandBuffer: CommandBuffer,
firstExclusiveScissor: u32,
exclusiveScissorCount: u32,
pExclusiveScissors: [*]const Rect2D,
) callconv(CallConv) void;
pub inline fn CmdSetExclusiveScissorNV(commandBuffer: CommandBuffer, firstExclusiveScissor: u32, exclusiveScissors: []const Rect2D) void {
vkCmdSetExclusiveScissorNV(commandBuffer, firstExclusiveScissor, @intCast(u32, exclusiveScissors.len), exclusiveScissors.ptr);
}
pub const NV_device_diagnostic_checkpoints = 1;
pub const NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION = 2;
pub const NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME = "VK_NV_device_diagnostic_checkpoints";
pub const QueueFamilyCheckpointPropertiesNV = extern struct {
sType: StructureType = .QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV,
pNext: ?*c_void = null,
checkpointExecutionStageMask: PipelineStageFlags align(4),
};
pub const CheckpointDataNV = extern struct {
sType: StructureType = .CHECKPOINT_DATA_NV,
pNext: ?*c_void = null,
stage: PipelineStageFlags align(4),
pCheckpointMarker: ?*c_void,
};
pub extern fn vkCmdSetCheckpointNV(
commandBuffer: CommandBuffer,
pCheckpointMarker: ?*const c_void,
) callconv(CallConv) void;
pub extern fn vkGetQueueCheckpointDataNV(
queue: Queue,
pCheckpointDataCount: *u32,
pCheckpointData: ?[*]CheckpointDataNV,
) callconv(CallConv) void;
pub const CmdSetCheckpointNV = vkCmdSetCheckpointNV;
pub inline fn GetQueueCheckpointDataNV(queue: Queue, checkpointData: []CheckpointDataNV) []CheckpointDataNV {
var out_checkpointData: []CheckpointDataNV = undefined;
var checkpointDataCount: u32 = @intCast(u32, checkpointData.len);
vkGetQueueCheckpointDataNV(queue, &checkpointDataCount, checkpointData.ptr);
out_checkpointData = checkpointData[0..checkpointDataCount];
return out_checkpointData;
}
pub inline fn GetQueueCheckpointDataCountNV(queue: Queue) u32 {
var out_checkpointDataCount: u32 = undefined;
vkGetQueueCheckpointDataNV(queue, &out_checkpointDataCount, null);
return out_checkpointDataCount;
}
pub const INTEL_shader_integer_functions2 = 1;
pub const INTEL_SHADER_INTEGER_FUNCTIONS_2_SPEC_VERSION = 1;
pub const INTEL_SHADER_INTEGER_FUNCTIONS_2_EXTENSION_NAME = "VK_INTEL_shader_integer_functions2";
pub const PhysicalDeviceShaderIntegerFunctions2FeaturesINTEL = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL,
pNext: ?*c_void = null,
shaderIntegerFunctions2: Bool32,
};
pub const INTEL_performance_query = 1;
pub const PerformanceConfigurationINTEL = *@OpaqueType();
pub const INTEL_PERFORMANCE_QUERY_SPEC_VERSION = 1;
pub const INTEL_PERFORMANCE_QUERY_EXTENSION_NAME = "VK_INTEL_performance_query";
pub const PerformanceConfigurationTypeINTEL = extern enum(i32) {
COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED = 0,
_,
};
pub const QueryPoolSamplingModeINTEL = extern enum(i32) {
MANUAL = 0,
_,
};
pub const PerformanceOverrideTypeINTEL = extern enum(i32) {
NULL_HARDWARE = 0,
FLUSH_GPU_CACHES = 1,
_,
};
pub const PerformanceParameterTypeINTEL = extern enum(i32) {
HW_COUNTERS_SUPPORTED = 0,
STREAM_MARKER_VALID_BITS = 1,
_,
};
pub const PerformanceValueTypeINTEL = extern enum(i32) {
UINT32 = 0,
UINT64 = 1,
FLOAT = 2,
BOOL = 3,
STRING = 4,
_,
};
pub const PerformanceValueDataINTEL = extern union {
value32: u32,
value64: u64,
valueFloat: f32,
valueBool: Bool32,
valueString: *const u8,
};
pub const PerformanceValueINTEL = extern struct {
inType: PerformanceValueTypeINTEL,
data: PerformanceValueDataINTEL,
};
pub const InitializePerformanceApiInfoINTEL = extern struct {
sType: StructureType = .INITIALIZE_PERFORMANCE_API_INFO_INTEL,
pNext: ?*const c_void = null,
pUserData: ?*c_void,
};
pub const QueryPoolCreateInfoINTEL = extern struct {
sType: StructureType = .QUERY_POOL_CREATE_INFO_INTEL,
pNext: ?*const c_void = null,
performanceCountersSampling: QueryPoolSamplingModeINTEL,
};
pub const PerformanceMarkerInfoINTEL = extern struct {
sType: StructureType = .PERFORMANCE_MARKER_INFO_INTEL,
pNext: ?*const c_void = null,
marker: u64,
};
pub const PerformanceStreamMarkerInfoINTEL = extern struct {
sType: StructureType = .PERFORMANCE_STREAM_MARKER_INFO_INTEL,
pNext: ?*const c_void = null,
marker: u32,
};
pub const PerformanceOverrideInfoINTEL = extern struct {
sType: StructureType = .PERFORMANCE_OVERRIDE_INFO_INTEL,
pNext: ?*const c_void = null,
inType: PerformanceOverrideTypeINTEL,
enable: Bool32,
parameter: u64,
};
pub const PerformanceConfigurationAcquireInfoINTEL = extern struct {
sType: StructureType = .PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL,
pNext: ?*const c_void = null,
inType: PerformanceConfigurationTypeINTEL,
};
pub extern fn vkInitializePerformanceApiINTEL(
device: Device,
pInitializeInfo: *const InitializePerformanceApiInfoINTEL,
) callconv(CallConv) Result;
pub extern fn vkUninitializePerformanceApiINTEL(device: Device) callconv(CallConv) void;
pub extern fn vkCmdSetPerformanceMarkerINTEL(
commandBuffer: CommandBuffer,
pMarkerInfo: *const PerformanceMarkerInfoINTEL,
) callconv(CallConv) Result;
pub extern fn vkCmdSetPerformanceStreamMarkerINTEL(
commandBuffer: CommandBuffer,
pMarkerInfo: *const PerformanceStreamMarkerInfoINTEL,
) callconv(CallConv) Result;
pub extern fn vkCmdSetPerformanceOverrideINTEL(
commandBuffer: CommandBuffer,
pOverrideInfo: *const PerformanceOverrideInfoINTEL,
) callconv(CallConv) Result;
pub extern fn vkAcquirePerformanceConfigurationINTEL(
device: Device,
pAcquireInfo: *const PerformanceConfigurationAcquireInfoINTEL,
pConfiguration: *PerformanceConfigurationINTEL,
) callconv(CallConv) Result;
pub extern fn vkReleasePerformanceConfigurationINTEL(
device: Device,
configuration: PerformanceConfigurationINTEL,
) callconv(CallConv) Result;
pub extern fn vkQueueSetPerformanceConfigurationINTEL(
queue: Queue,
configuration: PerformanceConfigurationINTEL,
) callconv(CallConv) Result;
pub extern fn vkGetPerformanceParameterINTEL(
device: Device,
parameter: PerformanceParameterTypeINTEL,
pValue: *PerformanceValueINTEL,
) callconv(CallConv) Result;
pub inline fn InitializePerformanceApiINTEL(device: Device, initializeInfo: InitializePerformanceApiInfoINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkInitializePerformanceApiINTEL(device, &initializeInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub const UninitializePerformanceApiINTEL = vkUninitializePerformanceApiINTEL;
pub inline fn CmdSetPerformanceMarkerINTEL(commandBuffer: CommandBuffer, markerInfo: PerformanceMarkerInfoINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkCmdSetPerformanceMarkerINTEL(commandBuffer, &markerInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CmdSetPerformanceStreamMarkerINTEL(commandBuffer: CommandBuffer, markerInfo: PerformanceStreamMarkerInfoINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkCmdSetPerformanceStreamMarkerINTEL(commandBuffer, &markerInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn CmdSetPerformanceOverrideINTEL(commandBuffer: CommandBuffer, overrideInfo: PerformanceOverrideInfoINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkCmdSetPerformanceOverrideINTEL(commandBuffer, &overrideInfo);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn AcquirePerformanceConfigurationINTEL(device: Device, acquireInfo: PerformanceConfigurationAcquireInfoINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!PerformanceConfigurationINTEL {
var out_configuration: PerformanceConfigurationINTEL = undefined;
const result = vkAcquirePerformanceConfigurationINTEL(device, &acquireInfo, &out_configuration);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_configuration;
}
pub inline fn ReleasePerformanceConfigurationINTEL(device: Device, configuration: PerformanceConfigurationINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkReleasePerformanceConfigurationINTEL(device, configuration);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn QueueSetPerformanceConfigurationINTEL(queue: Queue, configuration: PerformanceConfigurationINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!void {
const result = vkQueueSetPerformanceConfigurationINTEL(queue, configuration);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
}
pub inline fn GetPerformanceParameterINTEL(device: Device, parameter: PerformanceParameterTypeINTEL) error{VK_TOO_MANY_OBJECTS,VK_OUT_OF_HOST_MEMORY,VK_UNDOCUMENTED_ERROR}!PerformanceValueINTEL {
var out_value: PerformanceValueINTEL = undefined;
const result = vkGetPerformanceParameterINTEL(device, parameter, &out_value);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_TOO_MANY_OBJECTS => error.VK_TOO_MANY_OBJECTS,
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_value;
}
pub const EXT_pci_bus_info = 1;
pub const EXT_PCI_BUS_INFO_SPEC_VERSION = 2;
pub const EXT_PCI_BUS_INFO_EXTENSION_NAME = "VK_EXT_pci_bus_info";
pub const PhysicalDevicePCIBusInfoPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT,
pNext: ?*c_void = null,
pciDomain: u32,
pciBus: u32,
pciDevice: u32,
pciFunction: u32,
};
pub const AMD_display_native_hdr = 1;
pub const AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION = 1;
pub const AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME = "VK_AMD_display_native_hdr";
pub const DisplayNativeHdrSurfaceCapabilitiesAMD = extern struct {
sType: StructureType = .DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD,
pNext: ?*c_void = null,
localDimmingSupport: Bool32,
};
pub const SwapchainDisplayNativeHdrCreateInfoAMD = extern struct {
sType: StructureType = .SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD,
pNext: ?*const c_void = null,
localDimmingEnable: Bool32,
};
pub extern fn vkSetLocalDimmingAMD(
device: Device,
swapChain: SwapchainKHR,
localDimmingEnable: Bool32,
) callconv(CallConv) void;
pub const SetLocalDimmingAMD = vkSetLocalDimmingAMD;
pub const EXT_fragment_density_map = 1;
pub const EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION = 1;
pub const EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME = "VK_EXT_fragment_density_map";
pub const PhysicalDeviceFragmentDensityMapFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT,
pNext: ?*c_void = null,
fragmentDensityMap: Bool32,
fragmentDensityMapDynamic: Bool32,
fragmentDensityMapNonSubsampledImages: Bool32,
};
pub const PhysicalDeviceFragmentDensityMapPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT,
pNext: ?*c_void = null,
minFragmentDensityTexelSize: Extent2D,
maxFragmentDensityTexelSize: Extent2D,
fragmentDensityInvocations: Bool32,
};
pub const RenderPassFragmentDensityMapCreateInfoEXT = extern struct {
sType: StructureType = .RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
fragmentDensityMapAttachment: AttachmentReference,
};
pub const EXT_scalar_block_layout = 1;
pub const EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION = 1;
pub const EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME = "VK_EXT_scalar_block_layout";
pub const PhysicalDeviceScalarBlockLayoutFeaturesEXT = PhysicalDeviceScalarBlockLayoutFeatures;
pub const GOOGLE_hlsl_functionality1 = 1;
pub const GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION = 1;
pub const GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME = "VK_GOOGLE_hlsl_functionality1";
pub const GOOGLE_decorate_string = 1;
pub const GOOGLE_DECORATE_STRING_SPEC_VERSION = 1;
pub const GOOGLE_DECORATE_STRING_EXTENSION_NAME = "VK_GOOGLE_decorate_string";
pub const EXT_subgroup_size_control = 1;
pub const EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION = 2;
pub const EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME = "VK_EXT_subgroup_size_control";
pub const PhysicalDeviceSubgroupSizeControlFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT,
pNext: ?*c_void = null,
subgroupSizeControl: Bool32,
computeFullSubgroups: Bool32,
};
pub const PhysicalDeviceSubgroupSizeControlPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT,
pNext: ?*c_void = null,
minSubgroupSize: u32,
maxSubgroupSize: u32,
maxComputeWorkgroupSubgroups: u32,
requiredSubgroupSizeStages: ShaderStageFlags align(4),
};
pub const PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT,
pNext: ?*c_void = null,
requiredSubgroupSize: u32,
};
pub const AMD_shader_core_properties2 = 1;
pub const AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION = 1;
pub const AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME = "VK_AMD_shader_core_properties2";
pub const ShaderCorePropertiesFlagsAMD = packed struct {
__reserved_bit_00: bool = false,
__reserved_bit_01: bool = false,
__reserved_bit_02: bool = false,
__reserved_bit_03: bool = false,
__reserved_bit_04: bool = false,
__reserved_bit_05: bool = false,
__reserved_bit_06: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceShaderCoreProperties2AMD = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD,
pNext: ?*c_void = null,
shaderCoreFeatures: ShaderCorePropertiesFlagsAMD align(4),
activeComputeUnitCount: u32,
};
pub const AMD_device_coherent_memory = 1;
pub const AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION = 1;
pub const AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME = "VK_AMD_device_coherent_memory";
pub const PhysicalDeviceCoherentMemoryFeaturesAMD = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD,
pNext: ?*c_void = null,
deviceCoherentMemory: Bool32,
};
pub const EXT_memory_budget = 1;
pub const EXT_MEMORY_BUDGET_SPEC_VERSION = 1;
pub const EXT_MEMORY_BUDGET_EXTENSION_NAME = "VK_EXT_memory_budget";
pub const PhysicalDeviceMemoryBudgetPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT,
pNext: ?*c_void = null,
heapBudget: [MAX_MEMORY_HEAPS]DeviceSize,
heapUsage: [MAX_MEMORY_HEAPS]DeviceSize,
};
pub const EXT_memory_priority = 1;
pub const EXT_MEMORY_PRIORITY_SPEC_VERSION = 1;
pub const EXT_MEMORY_PRIORITY_EXTENSION_NAME = "VK_EXT_memory_priority";
pub const PhysicalDeviceMemoryPriorityFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT,
pNext: ?*c_void = null,
memoryPriority: Bool32,
};
pub const MemoryPriorityAllocateInfoEXT = extern struct {
sType: StructureType = .MEMORY_PRIORITY_ALLOCATE_INFO_EXT,
pNext: ?*const c_void = null,
priority: f32,
};
pub const NV_dedicated_allocation_image_aliasing = 1;
pub const NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION = 1;
pub const NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME = "VK_NV_dedicated_allocation_image_aliasing";
pub const PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV,
pNext: ?*c_void = null,
dedicatedAllocationImageAliasing: Bool32,
};
pub const EXT_buffer_device_address = 1;
pub const EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION = 2;
pub const EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME = "VK_EXT_buffer_device_address";
pub const PhysicalDeviceBufferDeviceAddressFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT,
pNext: ?*c_void = null,
bufferDeviceAddress: Bool32,
bufferDeviceAddressCaptureReplay: Bool32,
bufferDeviceAddressMultiDevice: Bool32,
};
pub const PhysicalDeviceBufferAddressFeaturesEXT = PhysicalDeviceBufferDeviceAddressFeaturesEXT;
pub const BufferDeviceAddressInfoEXT = BufferDeviceAddressInfo;
pub const BufferDeviceAddressCreateInfoEXT = extern struct {
sType: StructureType = .BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
deviceAddress: DeviceAddress,
};
pub extern fn vkGetBufferDeviceAddressEXT(
device: Device,
pInfo: *const BufferDeviceAddressInfo,
) callconv(CallConv) DeviceAddress;
pub inline fn GetBufferDeviceAddressEXT(device: Device, info: BufferDeviceAddressInfo) DeviceAddress {
const result = vkGetBufferDeviceAddressEXT(device, &info);
return result;
}
pub const EXT_tooling_info = 1;
pub const EXT_TOOLING_INFO_SPEC_VERSION = 1;
pub const EXT_TOOLING_INFO_EXTENSION_NAME = "VK_EXT_tooling_info";
pub const ToolPurposeFlagsEXT = packed struct {
validation: bool = false,
profiling: bool = false,
tracing: bool = false,
additionalFeatures: bool = false,
modifyingFeatures: bool = false,
debugReporting: bool = false,
debugMarkers: bool = false,
__reserved_bit_07: bool = false,
__reserved_bit_08: bool = false,
__reserved_bit_09: bool = false,
__reserved_bit_10: bool = false,
__reserved_bit_11: bool = false,
__reserved_bit_12: bool = false,
__reserved_bit_13: bool = false,
__reserved_bit_14: bool = false,
__reserved_bit_15: bool = false,
__reserved_bit_16: bool = false,
__reserved_bit_17: bool = false,
__reserved_bit_18: bool = false,
__reserved_bit_19: bool = false,
__reserved_bit_20: bool = false,
__reserved_bit_21: bool = false,
__reserved_bit_22: bool = false,
__reserved_bit_23: bool = false,
__reserved_bit_24: bool = false,
__reserved_bit_25: bool = false,
__reserved_bit_26: bool = false,
__reserved_bit_27: bool = false,
__reserved_bit_28: bool = false,
__reserved_bit_29: bool = false,
__reserved_bit_30: bool = false,
__reserved_bit_31: bool = false,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceToolPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT,
pNext: ?*c_void = null,
name: [MAX_EXTENSION_NAME_SIZE-1:0]u8,
version: [MAX_EXTENSION_NAME_SIZE-1:0]u8,
purposes: ToolPurposeFlagsEXT align(4),
description: [MAX_DESCRIPTION_SIZE-1:0]u8,
layer: [MAX_EXTENSION_NAME_SIZE-1:0]u8,
};
pub extern fn vkGetPhysicalDeviceToolPropertiesEXT(
physicalDevice: PhysicalDevice,
pToolCount: *u32,
pToolProperties: ?[*]PhysicalDeviceToolPropertiesEXT,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceToolPropertiesEXTResult = struct {
result: Result,
toolProperties: []PhysicalDeviceToolPropertiesEXT,
};
pub inline fn GetPhysicalDeviceToolPropertiesEXT(physicalDevice: PhysicalDevice, toolProperties: []PhysicalDeviceToolPropertiesEXT) error{VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceToolPropertiesEXTResult {
var returnValues: GetPhysicalDeviceToolPropertiesEXTResult = undefined;
var toolCount: u32 = @intCast(u32, toolProperties.len);
const result = vkGetPhysicalDeviceToolPropertiesEXT(physicalDevice, &toolCount, toolProperties.ptr);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
returnValues.toolProperties = toolProperties[0..toolCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceToolPropertiesCountEXT(physicalDevice: PhysicalDevice) error{VK_UNDOCUMENTED_ERROR}!u32 {
var out_toolCount: u32 = undefined;
const result = vkGetPhysicalDeviceToolPropertiesEXT(physicalDevice, &out_toolCount, null);
if (@bitCast(c_int, result) < 0) {
return error.VK_UNDOCUMENTED_ERROR;
}
return out_toolCount;
}
pub const EXT_separate_stencil_usage = 1;
pub const EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION = 1;
pub const EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME = "VK_EXT_separate_stencil_usage";
pub const ImageStencilUsageCreateInfoEXT = ImageStencilUsageCreateInfo;
pub const EXT_validation_features = 1;
pub const EXT_VALIDATION_FEATURES_SPEC_VERSION = 2;
pub const EXT_VALIDATION_FEATURES_EXTENSION_NAME = "VK_EXT_validation_features";
pub const ValidationFeatureEnableEXT = extern enum(i32) {
GPU_ASSISTED = 0,
GPU_ASSISTED_RESERVE_BINDING_SLOT = 1,
BEST_PRACTICES = 2,
_,
};
pub const ValidationFeatureDisableEXT = extern enum(i32) {
ALL = 0,
SHADERS = 1,
THREAD_SAFETY = 2,
API_PARAMETERS = 3,
OBJECT_LIFETIMES = 4,
CORE_CHECKS = 5,
UNIQUE_HANDLES = 6,
_,
};
pub const ValidationFeaturesEXT = extern struct {
sType: StructureType = .VALIDATION_FEATURES_EXT,
pNext: ?*const c_void = null,
enabledValidationFeatureCount: u32 = 0,
pEnabledValidationFeatures: [*]const ValidationFeatureEnableEXT = undefined,
disabledValidationFeatureCount: u32 = 0,
pDisabledValidationFeatures: [*]const ValidationFeatureDisableEXT = undefined,
};
pub const NV_cooperative_matrix = 1;
pub const NV_COOPERATIVE_MATRIX_SPEC_VERSION = 1;
pub const NV_COOPERATIVE_MATRIX_EXTENSION_NAME = "VK_NV_cooperative_matrix";
pub const ComponentTypeNV = extern enum(i32) {
FLOAT16 = 0,
FLOAT32 = 1,
FLOAT64 = 2,
SINT8 = 3,
SINT16 = 4,
SINT32 = 5,
SINT64 = 6,
UINT8 = 7,
UINT16 = 8,
UINT32 = 9,
UINT64 = 10,
_,
};
pub const ScopeNV = extern enum(i32) {
DEVICE = 1,
WORKGROUP = 2,
SUBGROUP = 3,
QUEUE_FAMILY = 5,
_,
};
pub const CooperativeMatrixPropertiesNV = extern struct {
sType: StructureType = .COOPERATIVE_MATRIX_PROPERTIES_NV,
pNext: ?*c_void = null,
MSize: u32,
NSize: u32,
KSize: u32,
AType: ComponentTypeNV,
BType: ComponentTypeNV,
CType: ComponentTypeNV,
DType: ComponentTypeNV,
scope: ScopeNV,
};
pub const PhysicalDeviceCooperativeMatrixFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV,
pNext: ?*c_void = null,
cooperativeMatrix: Bool32,
cooperativeMatrixRobustBufferAccess: Bool32,
};
pub const PhysicalDeviceCooperativeMatrixPropertiesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV,
pNext: ?*c_void = null,
cooperativeMatrixSupportedStages: ShaderStageFlags align(4),
};
pub extern fn vkGetPhysicalDeviceCooperativeMatrixPropertiesNV(
physicalDevice: PhysicalDevice,
pPropertyCount: *u32,
pProperties: ?[*]CooperativeMatrixPropertiesNV,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceCooperativeMatrixPropertiesNVResult = struct {
result: Result,
properties: []CooperativeMatrixPropertiesNV,
};
pub inline fn GetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice: PhysicalDevice, properties: []CooperativeMatrixPropertiesNV) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceCooperativeMatrixPropertiesNVResult {
var returnValues: GetPhysicalDeviceCooperativeMatrixPropertiesNVResult = undefined;
var propertyCount: u32 = @intCast(u32, properties.len);
const result = vkGetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice, &propertyCount, properties.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.properties = properties[0..propertyCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceCooperativeMatrixPropertiesCountNV(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_propertyCount: u32 = undefined;
const result = vkGetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice, &out_propertyCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_propertyCount;
}
pub const NV_coverage_reduction_mode = 1;
pub const NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION = 1;
pub const NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME = "VK_NV_coverage_reduction_mode";
pub const CoverageReductionModeNV = extern enum(i32) {
MERGE = 0,
TRUNCATE = 1,
_,
};
pub const PipelineCoverageReductionStateCreateFlagsNV = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const PhysicalDeviceCoverageReductionModeFeaturesNV = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV,
pNext: ?*c_void = null,
coverageReductionMode: Bool32,
};
pub const PipelineCoverageReductionStateCreateInfoNV = extern struct {
sType: StructureType = .PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV,
pNext: ?*const c_void = null,
flags: PipelineCoverageReductionStateCreateFlagsNV align(4) = PipelineCoverageReductionStateCreateFlagsNV{},
coverageReductionMode: CoverageReductionModeNV,
};
pub const FramebufferMixedSamplesCombinationNV = extern struct {
sType: StructureType = .FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV,
pNext: ?*c_void = null,
coverageReductionMode: CoverageReductionModeNV,
rasterizationSamples: SampleCountFlags align(4),
depthStencilSamples: SampleCountFlags align(4),
colorSamples: SampleCountFlags align(4),
};
pub extern fn vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(
physicalDevice: PhysicalDevice,
pCombinationCount: *u32,
pCombinations: ?[*]FramebufferMixedSamplesCombinationNV,
) callconv(CallConv) Result;
pub const GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNVResult = struct {
result: Result,
combinations: []FramebufferMixedSamplesCombinationNV,
};
pub inline fn GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice: PhysicalDevice, combinations: []FramebufferMixedSamplesCombinationNV) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNVResult {
var returnValues: GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNVResult = undefined;
var combinationCount: u32 = @intCast(u32, combinations.len);
const result = vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice, &combinationCount, combinations.ptr);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
returnValues.combinations = combinations[0..combinationCount];
returnValues.result = result;
return returnValues;
}
pub inline fn GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsCountNV(physicalDevice: PhysicalDevice) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!u32 {
var out_combinationCount: u32 = undefined;
const result = vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice, &out_combinationCount, null);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_combinationCount;
}
pub const EXT_fragment_shader_interlock = 1;
pub const EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION = 1;
pub const EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME = "VK_EXT_fragment_shader_interlock";
pub const PhysicalDeviceFragmentShaderInterlockFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT,
pNext: ?*c_void = null,
fragmentShaderSampleInterlock: Bool32,
fragmentShaderPixelInterlock: Bool32,
fragmentShaderShadingRateInterlock: Bool32,
};
pub const EXT_ycbcr_image_arrays = 1;
pub const EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION = 1;
pub const EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME = "VK_EXT_ycbcr_image_arrays";
pub const PhysicalDeviceYcbcrImageArraysFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT,
pNext: ?*c_void = null,
ycbcrImageArrays: Bool32,
};
pub const EXT_headless_surface = 1;
pub const EXT_HEADLESS_SURFACE_SPEC_VERSION = 1;
pub const EXT_HEADLESS_SURFACE_EXTENSION_NAME = "VK_EXT_headless_surface";
pub const HeadlessSurfaceCreateFlagsEXT = packed struct {
__reserved_bits_00_31: u32 = 0,
pub usingnamespace FlagsMixin(@This());
};
pub const HeadlessSurfaceCreateInfoEXT = extern struct {
sType: StructureType = .HEADLESS_SURFACE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
flags: HeadlessSurfaceCreateFlagsEXT align(4) = HeadlessSurfaceCreateFlagsEXT{},
};
pub extern fn vkCreateHeadlessSurfaceEXT(
instance: Instance,
pCreateInfo: *const HeadlessSurfaceCreateInfoEXT,
pAllocator: ?*const AllocationCallbacks,
pSurface: *SurfaceKHR,
) callconv(CallConv) Result;
pub inline fn CreateHeadlessSurfaceEXT(instance: Instance, createInfo: HeadlessSurfaceCreateInfoEXT, pAllocator: ?*const AllocationCallbacks) error{VK_OUT_OF_HOST_MEMORY,VK_OUT_OF_DEVICE_MEMORY,VK_UNDOCUMENTED_ERROR}!SurfaceKHR {
var out_surface: SurfaceKHR = undefined;
const result = vkCreateHeadlessSurfaceEXT(instance, &createInfo, pAllocator, &out_surface);
if (@bitCast(c_int, result) < 0) {
return switch (result) {
.ERROR_OUT_OF_HOST_MEMORY => error.VK_OUT_OF_HOST_MEMORY,
.ERROR_OUT_OF_DEVICE_MEMORY => error.VK_OUT_OF_DEVICE_MEMORY,
else => error.VK_UNDOCUMENTED_ERROR,
};
}
return out_surface;
}
pub const EXT_line_rasterization = 1;
pub const EXT_LINE_RASTERIZATION_SPEC_VERSION = 1;
pub const EXT_LINE_RASTERIZATION_EXTENSION_NAME = "VK_EXT_line_rasterization";
pub const LineRasterizationModeEXT = extern enum(i32) {
DEFAULT = 0,
RECTANGULAR = 1,
BRESENHAM = 2,
RECTANGULAR_SMOOTH = 3,
_,
};
pub const PhysicalDeviceLineRasterizationFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT,
pNext: ?*c_void = null,
rectangularLines: Bool32,
bresenhamLines: Bool32,
smoothLines: Bool32,
stippledRectangularLines: Bool32,
stippledBresenhamLines: Bool32,
stippledSmoothLines: Bool32,
};
pub const PhysicalDeviceLineRasterizationPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT,
pNext: ?*c_void = null,
lineSubPixelPrecisionBits: u32,
};
pub const PipelineRasterizationLineStateCreateInfoEXT = extern struct {
sType: StructureType = .PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT,
pNext: ?*const c_void = null,
lineRasterizationMode: LineRasterizationModeEXT,
stippledLineEnable: Bool32,
lineStippleFactor: u32 = 0,
lineStipplePattern: u16 = 0,
};
pub extern fn vkCmdSetLineStippleEXT(
commandBuffer: CommandBuffer,
lineStippleFactor: u32,
lineStipplePattern: u16,
) callconv(CallConv) void;
pub const CmdSetLineStippleEXT = vkCmdSetLineStippleEXT;
pub const EXT_host_query_reset = 1;
pub const EXT_HOST_QUERY_RESET_SPEC_VERSION = 1;
pub const EXT_HOST_QUERY_RESET_EXTENSION_NAME = "VK_EXT_host_query_reset";
pub const PhysicalDeviceHostQueryResetFeaturesEXT = PhysicalDeviceHostQueryResetFeatures;
pub extern fn vkResetQueryPoolEXT(
device: Device,
queryPool: QueryPool,
firstQuery: u32,
queryCount: u32,
) callconv(CallConv) void;
pub const ResetQueryPoolEXT = vkResetQueryPoolEXT;
pub const EXT_index_type_uint8 = 1;
pub const EXT_INDEX_TYPE_UINT8_SPEC_VERSION = 1;
pub const EXT_INDEX_TYPE_UINT8_EXTENSION_NAME = "VK_EXT_index_type_uint8";
pub const PhysicalDeviceIndexTypeUint8FeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT,
pNext: ?*c_void = null,
indexTypeUint8: Bool32,
};
pub const EXT_shader_demote_to_helper_invocation = 1;
pub const EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION = 1;
pub const EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME = "VK_EXT_shader_demote_to_helper_invocation";
pub const PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT,
pNext: ?*c_void = null,
shaderDemoteToHelperInvocation: Bool32,
};
pub const EXT_texel_buffer_alignment = 1;
pub const EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION = 1;
pub const EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME = "VK_EXT_texel_buffer_alignment";
pub const PhysicalDeviceTexelBufferAlignmentFeaturesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT,
pNext: ?*c_void = null,
texelBufferAlignment: Bool32,
};
pub const PhysicalDeviceTexelBufferAlignmentPropertiesEXT = extern struct {
sType: StructureType = .PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT,
pNext: ?*c_void = null,
storageTexelBufferOffsetAlignmentBytes: DeviceSize,
storageTexelBufferOffsetSingleTexelAlignment: Bool32,
uniformTexelBufferOffsetAlignmentBytes: DeviceSize,
uniformTexelBufferOffsetSingleTexelAlignment: Bool32,
};
pub const GOOGLE_user_type = 1;
pub const GOOGLE_USER_TYPE_SPEC_VERSION = 1;
pub const GOOGLE_USER_TYPE_EXTENSION_NAME = "VK_GOOGLE_user_type"; | src/vk.zig |
const std = @import("std");
const print = std.debug.print;
const expect = std.testing.expect;
const eql = std.mem.eql;
const startsWith = std.mem.startsWith;
const endsWith = std.mem.endsWith;
test "string concat at comptime" {
const str1 = "one";
const str2: []const u8 = "two";
const str3 = str1 ++ " " ++ str2;
print(" str3={} ", .{str3});
expect(eql(u8, str3, "one two"));
}
test "string eql" {
const str = "string";
expect(eql(u8, str, "string"));
}
test "string startsWith" {
const str = "string";
expect(startsWith(u8, str, "stri"));
}
test "string endsWith" {
const str = "string";
expect(endsWith(u8, str, "ing"));
}
test "multiline string" {
const str =
\\line one
\\line two
\\line three
; // end
expect(endsWith(u8, str, "two\nline three"));
}
// joining requires an allocator to create a new string.
test "join strings" {
var buffer: [64]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&buffer); // or buffer[0..]
var allocator = &fba.allocator;
const str1 = try std.mem.join(allocator, ", ", &[_][]const u8{ "jill", "jack", "jane", "john" });
defer allocator.free(str1);
const str2 = try std.mem.join(allocator, "... ", &[_][]const u8{ "four", "three", "two", "one" });
defer allocator.free(str2);
expect(eql(u8, str1, "jill, jack, jane, john"));
expect(eql(u8, str2, "four... three... two... one"));
}
test "iterating utf8 runes" {
const str1: []const u8 = "こんにちは!";
print(" str1={} ", .{str1});
const view = try std.unicode.Utf8View.init(str1);
var itr = view.iterator();
var idx: u8 = 0;
while (itr.nextCodepointSlice()) |rune| : (idx += 1) {
if (idx == 0) {
expect(eql(u8, rune, "こ"));
}
if (idx == 1) {
expect(eql(u8, rune, "ん"));
}
if (idx == 4) {
expect(eql(u8, rune, "は"));
}
if (idx == 5) {
expect(eql(u8, rune, "!"));
}
}
} | web/src/203_strings/strings.zig |
const std = @import("std");
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const expectError = std.testing.expectError;
var result: [3]u8 = undefined;
var index: usize = undefined;
fn runSomeErrorDefers(x: bool) !bool {
index = 0;
defer {
result[index] = 'a';
index += 1;
}
errdefer {
result[index] = 'b';
index += 1;
}
defer {
result[index] = 'c';
index += 1;
}
return if (x) x else error.FalseNotAllowed;
}
test "mixing normal and error defers" {
try expect(runSomeErrorDefers(true) catch unreachable);
try expect(result[0] == 'c');
try expect(result[1] == 'a');
const ok = runSomeErrorDefers(false) catch |err| x: {
try expect(err == error.FalseNotAllowed);
break :x true;
};
try expect(ok);
try expect(result[0] == 'c');
try expect(result[1] == 'b');
try expect(result[2] == 'a');
}
test "break and continue inside loop inside defer expression" {
testBreakContInDefer(10);
comptime testBreakContInDefer(10);
}
fn testBreakContInDefer(x: usize) void {
defer {
var i: usize = 0;
while (i < x) : (i += 1) {
if (i < 5) continue;
if (i == 5) break;
}
expect(i == 5) catch @panic("test failure");
}
}
test "defer and labeled break" {
var i = @as(usize, 0);
blk: {
defer i += 1;
break :blk;
}
try expect(i == 1);
}
test "errdefer does not apply to fn inside fn" {
if (testNestedFnErrDefer()) |_| @panic("expected error") else |e| try expect(e == error.Bad);
}
fn testNestedFnErrDefer() anyerror!void {
var a: i32 = 0;
errdefer a += 1;
const S = struct {
fn baz() anyerror {
return error.Bad;
}
};
return S.baz();
}
test "return variable while defer expression in scope to modify it" {
const S = struct {
fn doTheTest() !void {
try expect(notNull().? == 1);
}
fn notNull() ?u8 {
var res: ?u8 = 1;
defer res = null;
return res;
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "errdefer with payload" {
const S = struct {
fn foo() !i32 {
errdefer |a| {
expectEqual(error.One, a) catch @panic("test failure");
}
return error.One;
}
fn doTheTest() !void {
try expectError(error.One, foo());
}
};
try S.doTheTest();
comptime try S.doTheTest();
} | test/behavior/defer_stage1.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Date = @import("date.zig");
const util = @import("util.zig");
pub const Task = @import("task.zig");
pub const Tasks = std.TailQueue(Task);
const Self = @This();
alloc: *Allocator,
tasks: Tasks,
timezone: Date.Timezone,
pub const Parser = struct {
pub const seperator = "\x01";
pub fn str(self: Self, buffer: []u8) ![:0]u8 {
var todo_iter = self.tasks.first;
var i: usize = 0;
var tail: usize = 0;
const size = util.tailQueueLen(self.tasks);
// Saving timezone and daylight
{
var line = buffer[tail .. 10];
const daylight: u8 = if (self.timezone.daylight) 1 else 0;
const printed = try std.fmt.bufPrint(line, "{d}\n{d}\n", .{self.timezone.offset.hours, daylight});
tail += printed.len;
}
while (i < size) : (i += 1) {
var line = buffer[tail..];
const task = todo_iter.?.data;
const completed: i64 = if (task.completed) 1 else 0;
const printed = blk: {
if (task.due) |d| {
break :blk try std.fmt.bufPrint(line, "{s}" ++ seperator ++ "{d}" ++ seperator ++ "{d}\n", .{task.content, d.dateToEpoch() ,completed});
} else {
break :blk try std.fmt.bufPrint(line, "{s}" ++ seperator ++ "{any}" ++ seperator ++ "{d}\n", .{task.content, task.due, completed});
}
};
tail = tail + printed.len;
todo_iter = todo_iter.?.next;
}
buffer[tail] = 0;
return buffer[0..tail:0];
}
/// Assumes valid input
pub fn parse(allocator: *Allocator, buffer: [:0]const u8) !Self {
const Helpers = struct {
pub fn getDue(token: []const u8) ?Date {
const epoch = std.fmt.parseInt(i64, token, 10) catch null;
if (epoch) |val|
return Date.epochToDate(val)
else
return null;
}
pub fn getCompleted(token: []const u8) !bool {
const val = try std.fmt.parseInt(u8, token, 10);
return val != 0;
}
};
var todo = init(allocator);
var lines = std.mem.tokenize(buffer, "\n");
if (lines.next()) |offset| {
todo.timezone = Date.Timezone {
.offset = Date {
.hours = try std.fmt.parseInt(i64, offset, 10),
},
.daylight = false,
};
}
if (lines.next()) |daylight| {
todo.timezone.daylight = (try std.fmt.parseInt(u8, daylight, 10)) != 0;
}
while (lines.next()) |line| {
var tokens = std.mem.tokenize(line, seperator);
const content: []const u8 = tokens.next().?;
const due: ?Date = Helpers.getDue(tokens.next().?);
const completed: bool = try Helpers.getCompleted(tokens.next().?);
try todo.add(Task {
.content = content,
.due = due,
.completed = completed,
});
}
return todo;
}
};
pub fn init(allocator: *Allocator) Self {
return Self {
.alloc = allocator,
.tasks = Tasks{},
.timezone = Date.Timezone {
.offset = Date.Timezone.utc,
.daylight = false,
},
};
}
pub fn deinit(self: Self) void {
var it = self.tasks.first;
while (it) |node| {
it = node.next;
self.alloc.destroy(node);
}
}
/// Adds a new task based on its due date and completion status.
/// Allocates memory
pub fn add(self: *Self, task: Task) !void {
var to_add = try self.alloc.create(Tasks.Node);
to_add.* = Tasks.Node {
.data = task,
};
var largest_node_smaller_than_me: ?*Tasks.Node = null;
var it = self.tasks.first;
while (it) |node| : (it = node.next) {
const compare = node.data.compare(to_add.data);
if (compare <= 0) {
largest_node_smaller_than_me = node;
}
}
if (largest_node_smaller_than_me) |node| {
self.tasks.insertAfter(node, to_add);
} else {
self.tasks.prepend(to_add);
}
}
pub fn updateIndicies(self: *Self) void {
var it = self.tasks.first;
var i: usize = 1;
while (it) |node| : (it = node.next) {
node.data.index = i;
i += 1;
}
}
/// Removes a node. Index based, starts from 0.
/// deinit will NOT deallocate this memory.
pub fn remove(self: *Self, index: usize) ?*Tasks.Node {
if (index == 0) {
return self.tasks.popFirst();
}
const node = self.get(index) orelse return null;
self.tasks.remove(node);
return node;
}
/// Returns a node based on index given. Starts from 0.
pub fn get(self: *Self, index: usize) ?*Tasks.Node {
var it = self.tasks.first;
var i: usize = 0;
while (it) |node| : (it = node.next) {
if (i == index) {
return node;
}
i += 1;
}
return null;
}
/// Removes tasks based on whether they're complete or not, as specified by the complete parameter.
/// Automatically deallocates
pub fn removeTasks(self: *Self, completed: bool) void {
var it = self.tasks.first;
while (it) |node| {
if (node.data.completed == completed) {
it = node.next;
self.tasks.remove(node);
self.alloc.destroy(node);
} else it = node.next;
}
}
/// Filters tasks to include phrase
pub fn filterTasks(self: *Self, phrase: []const u8) void {
var it = self.tasks.first;
while (it) |node| {
if (util.indexOfNoCase(u8, node.data.content, phrase) == null) {
self.tasks.remove(node);
it = node.next;
self.alloc.destroy(node);
} else it = node.next;
}
}
test "Basic" {
const alloc = std.testing.allocator;
var todo = Self.init(alloc);
defer todo.deinit();
try todo.add(Task {
.content = "Remove me",
.due = Date {
.days = 18725 + 30,
},
.completed = false,
});
try todo.add(Task {
.content = "Chemistry assignment",
.due = Date {
.days = 18725,
},
.completed = false,
});
try todo.add(Task {
.content = "Math assignment",
.due = Date {
.days = 18725 + 15,
},
.completed = true,
});
const removed = todo.remove(1);
defer alloc.destroy(removed.?);
var buffer: [200]u8 = undefined;
const string = try Parser.str(todo, &buffer);
const expected = "0\n0\nChemistry assignment\x011617840000\x010\nMath assignment\x011619136000\x011\n";
std.testing.expect(std.mem.eql(u8, string, expected));
}
test "Loading" {
const alloc = std.testing.allocator;
const string = "0\n0\nChemistry assignment\x011617840000\x010\nMath assignment\x011619136000\x011\n";
var result = try Parser.parse(alloc, string);
defer result.deinit();
std.testing.expect(std.mem.eql(u8, "Chemistry assignment", result.tasks.first.?.data.content));
std.testing.expectEqual(Date { .days = 18725 }, result.tasks.first.?.data.due.?);
std.testing.expectEqual(false, result.tasks.first.?.data.completed);
std.testing.expect(std.mem.eql(u8, "Math assignment", result.tasks.first.?.next.?.data.content));
std.testing.expectEqual(Date { .days = 18725 + 15}, result.tasks.first.?.next.?.data.due.?);
std.testing.expectEqual(true, result.tasks.first.?.next.?.data.completed);
} | src/todo.zig |
const std = @import("std");
const os = std.os;
const mem = std.mem;
pub const NameserverList = std.ArrayList([]const u8);
/// Read the `/etc/resolv.conf` file in the system and return a list
/// of nameserver addresses
pub fn readNameservers(allocator: *std.mem.Allocator) !NameserverList {
var file = try std.fs.cwd().openFile("/etc/resolv.conf", .{ .read = true, .write = false });
defer file.close();
var nameservers = NameserverList.init(allocator);
errdefer nameservers.deinit();
// TODO maybe a better approach would be adding an iterator
// to file to go through lines that reads (and allocates) bytes until '\n'.
var buf = try allocator.alloc(u8, std.mem.page_size);
defer allocator.free(buf);
while ((try file.read(buf)) != 0) {
buf = try allocator.realloc(buf, buf.len + std.mem.page_size);
}
var it = mem.tokenize(buf, "\n");
while (it.next()) |line| {
if (mem.startsWith(u8, line, "#")) continue;
var ns_it = std.mem.split(line, " ");
const decl_name = ns_it.next();
if (decl_name == null) continue;
if (std.mem.eql(u8, decl_name.?, "nameserver")) {
const owned_str = try allocator.dupe(u8, ns_it.next().?);
try nameservers.append(owned_str);
}
}
return nameservers;
}
pub fn freeNameservers(allocator: *std.mem.Allocator, nameservers: NameserverList) void {
for (nameservers.items) |string| {
allocator.free(string);
}
}
test "reading /etc/resolv.conf" {
var nameservers = try readNameservers(std.heap.page_allocator);
defer freeNameservers(nameservers);
}
pub fn randomNameserver(output_buffer: []u8) !?[]const u8 {
var file = try std.fs.cwd().openFile(
"/etc/resolv.conf",
.{ .read = true, .write = false },
);
defer file.close();
// iterate through all lines to find the amount of nameservers, then select
// a random one, then read AGAIN so that we can return it.
//
// this doesn't need any allocator or lists or whatever. just the
// output buffer
try file.seekTo(0);
var line_buffer: [1024]u8 = undefined;
var nameserver_amount: usize = 0;
while (try file.reader().readUntilDelimiterOrEof(&line_buffer, '\n')) |line| {
if (mem.startsWith(u8, line, "#")) continue;
var ns_it = std.mem.split(line, " ");
const decl_name = ns_it.next();
if (decl_name == null) continue;
if (std.mem.eql(u8, decl_name.?, "nameserver")) {
nameserver_amount += 1;
}
}
const seed = @truncate(u64, @bitCast(u128, std.time.nanoTimestamp()));
var r = std.rand.DefaultPrng.init(seed);
const selected = r.random.uintLessThan(usize, nameserver_amount);
try file.seekTo(0);
var current_nameserver: usize = 0;
while (try file.reader().readUntilDelimiterOrEof(&line_buffer, '\n')) |line| {
if (mem.startsWith(u8, line, "#")) continue;
var ns_it = std.mem.split(line, " ");
const decl_name = ns_it.next();
if (decl_name == null) continue;
if (std.mem.eql(u8, decl_name.?, "nameserver")) {
if (current_nameserver == selected) {
const nameserver_addr = ns_it.next().?;
std.mem.copy(u8, output_buffer, nameserver_addr);
return output_buffer[0..nameserver_addr.len];
}
current_nameserver += 1;
}
}
return null;
} | src/pkg2/resolvconf.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const assert = std.debug.assert;
const panic = std.debug.panic;
const initCodebase = @import("init_codebase.zig").initCodebase;
const List = @import("list.zig").List;
const ecs = @import("ecs.zig");
const Entity = ecs.Entity;
const ECS = ecs.ECS;
const strings = @import("strings.zig");
const Strings = strings.Strings;
const InternedString = strings.InternedString;
const components = @import("components.zig");
const tokenizer = @import("tokenizer.zig");
const Tokens = tokenizer.Tokens;
const tokenize = tokenizer.tokenize;
const literalOf = @import("query.zig").literalOf;
pub fn parseExpression(codebase: *ECS, tokens: *Tokens, precedence: u64) error{OutOfMemory}!Entity {
const token = tokens.next().?;
var left = try prefixParser(tokens, token);
while (true) {
if (InfixParser.init(tokens, left)) |parser| {
const parser_precedence = parser.precedence();
if (precedence <= parser_precedence) {
left = try parser.run(codebase, tokens, left, parser_precedence);
} else return left;
} else return left;
}
}
fn parseGrouping(codebase: *ECS, tokens: *Tokens) !Entity {
const expression = try parseExpression(codebase, tokens, LOWEST);
_ = tokens.consume(.right_paren);
return expression;
}
fn parseArray(codebase: *ECS, tokens: *Tokens, left_bracket: Entity) !Entity {
const begin = left_bracket.get(components.Span).begin;
if (tokens.peek().?.get(components.TokenKind) == .right_bracket) {
_ = tokens.consume(.right_bracket);
const value = try parseExpression(codebase, tokens, HIGHEST);
const end = value.get(components.Span).end;
const span = components.Span.init(begin, end);
return try codebase.createEntity(.{
components.AstKind.array,
components.Value.init(value),
span,
});
}
const array_literal = try codebase.createEntity(.{components.AstKind.array_literal});
var values = components.Values.init(codebase.arena.allocator());
var token = tokens.peek().?;
while (true) {
const kind = token.get(components.TokenKind);
switch (kind) {
.right_bracket => {
const end = token.get(components.Span).end;
const span = components.Span.init(begin, end);
_ = try array_literal.set(.{
values,
span,
});
token = tokens.next().?;
break;
},
.comma, .new_line => {
_ = tokens.next().?;
token = tokens.peek().?;
},
else => {
const expression = try parseExpression(codebase, tokens, LOWEST);
try values.append(expression);
token = tokens.peek().?;
},
}
}
return array_literal;
}
fn parseIf(codebase: *ECS, tokens: *Tokens, if_: Entity) !Entity {
const conditional = components.Conditional.init(try parseExpression(codebase, tokens, LOWEST));
assert(tokens.next().?.get(components.TokenKind) == .left_brace);
const allocator = codebase.arena.allocator();
const begin = if_.get(components.Span).begin;
var then = components.Then.init(allocator);
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.new_line => _ = tokens.next(),
.right_brace => {
_ = tokens.next();
break;
},
else => try then.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
_ = tokens.consume(.else_);
_ = tokens.consume(.left_brace);
var else_ = components.Else.init(allocator);
const result = try codebase.createEntity(.{
components.AstKind.if_,
conditional,
then,
});
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.new_line => _ = tokens.next(),
.right_brace => {
const end = tokens.next().?.get(components.Span).end;
_ = try result.set(.{
else_,
components.Span.init(begin, end),
});
break;
},
else => try else_.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
return result;
}
fn parseWhile(codebase: *ECS, tokens: *Tokens, while_: Entity) !Entity {
const begin = while_.get(components.Span).begin;
_ = tokens.consume(.left_paren);
const conditional = components.Conditional.init(try parseExpression(codebase, tokens, LOWEST));
_ = tokens.consume(.right_paren);
_ = tokens.consume(.left_brace);
var body = components.Body.init(codebase.arena.allocator());
const result = try codebase.createEntity(.{
components.AstKind.while_,
conditional,
});
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.new_line => _ = tokens.next(),
.right_brace => {
const end = tokens.next().?.get(components.Span).end;
_ = try result.set(.{
body,
components.Span.init(begin, end),
});
break;
},
else => try body.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
return result;
}
fn parseForOldSyntax(codebase: *ECS, tokens: *Tokens, for_: Entity) !Entity {
const loop_variable = tokens.consume(.symbol);
_ = tokens.consume(.in);
const iterator = try parseExpression(codebase, tokens, LOWEST);
assert(iterator.get(components.AstKind) == .range);
assert(tokens.next().?.get(components.TokenKind) == .left_brace);
const begin = for_.get(components.Span).begin;
var body = components.Body.init(codebase.arena.allocator());
const result = try codebase.createEntity(.{
components.AstKind.for_,
components.LoopVariable.init(loop_variable),
components.Iterator.init(iterator),
});
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.new_line => _ = tokens.next(),
.right_brace => {
const end = tokens.next().?.get(components.Span).end;
_ = try result.set(.{
body,
components.Span.init(begin, end),
});
break;
},
else => try body.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
return result;
}
fn parseForNewSyntax(codebase: *ECS, tokens: *Tokens, for_: Entity) !Entity {
_ = tokens.consume(.left_paren);
const iterator = try parseExpression(codebase, tokens, LOWEST);
assert(iterator.get(components.AstKind) == .range);
const result = try codebase.createEntity(.{
components.AstKind.for_,
components.Iterator.init(iterator),
});
_ = tokens.consume(.right_paren);
switch (tokens.peek().?.get(components.TokenKind)) {
.left_brace => _ = tokens.next(),
.symbol => {
const loop_variable = tokens.consume(.symbol);
_ = tokens.consume(.left_brace);
_ = try result.set(.{
components.LoopVariable.init(loop_variable),
});
},
.left_paren => {
_ = tokens.next();
const loop_variable = tokens.consume(.symbol);
_ = tokens.consume(.right_paren);
_ = tokens.consume(.left_brace);
_ = try result.set(.{
components.LoopVariable.init(loop_variable),
});
},
else => |kind| panic("\nparse for new syntax unexpected kind {}\n", .{kind}),
}
const begin = for_.get(components.Span).begin;
var body = components.Body.init(codebase.arena.allocator());
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.new_line => _ = tokens.next(),
.right_brace => {
const end = tokens.next().?.get(components.Span).end;
_ = try result.set(.{
body,
components.Span.init(begin, end),
});
break;
},
else => try body.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
return result;
}
fn parseFor(codebase: *ECS, tokens: *Tokens, for_: Entity) !Entity {
return switch (tokens.peek().?.get(components.TokenKind)) {
.symbol => try parseForOldSyntax(codebase, tokens, for_),
.left_paren => try parseForNewSyntax(codebase, tokens, for_),
else => |kind| panic("\nparse for unexpected token kind {}\n", .{kind}),
};
}
fn parsePointer(codebase: *ECS, tokens: *Tokens, star: Entity) !Entity {
const begin = star.get(components.Span).begin;
const value = try parseExpression(codebase, tokens, DOT);
const end = value.get(components.Span).end;
const span = components.Span.init(begin, end);
return try codebase.createEntity(.{
components.AstKind.pointer,
components.Value.init(value),
span,
});
}
fn parseRange(codebase: *ECS, tokens: *Tokens, colon: Entity) !Entity {
const last = try parseExpression(codebase, tokens, LOWEST);
const begin = colon.get(components.Span).begin;
const end = last.get(components.Span).end;
return try codebase.createEntity(.{
components.AstKind.range,
components.Span.init(begin, end),
components.Last.init(last),
});
}
fn prefixParser(tokens: *Tokens, token: Entity) !Entity {
const kind = token.get(components.TokenKind);
return try switch (kind) {
.symbol => token.set(.{components.AstKind.symbol}),
.int => token.set(.{
components.AstKind.int,
components.Type.init(token.ecs.get(components.Builtins).IntLiteral),
}),
.float => token.set(.{
components.AstKind.float,
components.Type.init(token.ecs.get(components.Builtins).FloatLiteral),
}),
.string => token.set(.{components.AstKind.string}),
.char => token.set(.{components.AstKind.char}),
.left_paren => parseGrouping(token.ecs, tokens),
.left_bracket => parseArray(token.ecs, tokens, token),
.if_ => parseIf(token.ecs, tokens, token),
.while_ => parseWhile(token.ecs, tokens, token),
.for_ => parseFor(token.ecs, tokens, token),
.underscore => token.set(.{components.AstKind.underscore}),
.times => parsePointer(token.ecs, tokens, token),
.colon => parseRange(token.ecs, tokens, token),
else => panic("\nno prefix parser for {}\n", .{kind}),
};
}
const NEXT_PRECEDENCE: u64 = 10;
pub const LOWEST: u64 = 0;
const DEFINE: u64 = LOWEST;
const PIPELINE: u64 = DEFINE + NEXT_PRECEDENCE;
const LESS_THAN: u64 = PIPELINE + NEXT_PRECEDENCE;
const LESS_EQUAL: u64 = LESS_THAN;
const GREATER_THAN: u64 = LESS_THAN;
const GREATER_EQUAL: u64 = LESS_THAN;
const EQUAL: u64 = LESS_THAN;
const NOT_EQUAL: u64 = LESS_THAN;
const BIT_OR: u64 = LESS_THAN + NEXT_PRECEDENCE;
const BIT_XOR: u64 = BIT_OR + NEXT_PRECEDENCE;
const BIT_AND: u64 = BIT_XOR + NEXT_PRECEDENCE;
const LEFT_SHIFT: u64 = BIT_AND + NEXT_PRECEDENCE;
const RIGHT_SHIFT: u64 = LEFT_SHIFT;
const ADD: u64 = LEFT_SHIFT + NEXT_PRECEDENCE;
const SUBTRACT: u64 = ADD;
const MULTIPLY: u64 = ADD + NEXT_PRECEDENCE;
const DIVIDE: u64 = MULTIPLY;
const REMAINDER: u64 = MULTIPLY;
const DOT: u64 = MULTIPLY + NEXT_PRECEDENCE;
const CALL: u64 = DOT + NEXT_PRECEDENCE;
const INDEX: u64 = CALL;
const HIGHEST: u64 = CALL;
const InfixParser = union(enum) {
binary_op: struct { op: components.BinaryOp, precedence: u64 },
define_type_infer,
define_or_range,
call,
plus_equal,
times_equal,
index,
fn init(tokens: *Tokens, left: Entity) ?InfixParser {
if (tokens.peek()) |token| {
const kind = token.get(components.TokenKind);
switch (kind) {
.plus => return InfixParser{ .binary_op = .{ .op = .add, .precedence = ADD } },
.plus_equal => return InfixParser.plus_equal,
.times_equal => return InfixParser.times_equal,
.minus => return InfixParser{ .binary_op = .{ .op = .subtract, .precedence = SUBTRACT } },
.times => return InfixParser{ .binary_op = .{ .op = .multiply, .precedence = MULTIPLY } },
.slash => return InfixParser{ .binary_op = .{ .op = .divide, .precedence = DIVIDE } },
.percent => return InfixParser{ .binary_op = .{ .op = .remainder, .precedence = REMAINDER } },
.dot => return InfixParser{ .binary_op = .{ .op = .dot, .precedence = DOT } },
.less_than => return InfixParser{ .binary_op = .{ .op = .less_than, .precedence = LESS_THAN } },
.less_equal => return InfixParser{ .binary_op = .{ .op = .less_equal, .precedence = LESS_EQUAL } },
.less_less => return InfixParser{ .binary_op = .{ .op = .left_shift, .precedence = LEFT_SHIFT } },
.greater_than => return InfixParser{ .binary_op = .{ .op = .greater_than, .precedence = GREATER_THAN } },
.greater_equal => return InfixParser{ .binary_op = .{ .op = .greater_equal, .precedence = GREATER_EQUAL } },
.greater_greater => return InfixParser{ .binary_op = .{ .op = .right_shift, .precedence = RIGHT_SHIFT } },
.equal_equal => return InfixParser{ .binary_op = .{ .op = .equal, .precedence = EQUAL } },
.bang_equal => return InfixParser{ .binary_op = .{ .op = .not_equal, .precedence = NOT_EQUAL } },
.bar => return InfixParser{ .binary_op = .{ .op = .bit_or, .precedence = BIT_OR } },
.caret => return InfixParser{ .binary_op = .{ .op = .bit_xor, .precedence = BIT_XOR } },
.ampersand => return InfixParser{ .binary_op = .{ .op = .bit_and, .precedence = BIT_AND } },
.equal => return InfixParser.define_type_infer,
.colon => return InfixParser.define_or_range,
.left_paren => {
const left_end = left.get(components.Span).end;
const paren_begin = token.get(components.Span).begin;
if (left_end.row != paren_begin.row or left_end.column != paren_begin.column)
return null;
return InfixParser.call;
},
.left_bracket => return InfixParser.index,
else => return null,
}
} else {
return null;
}
}
fn precedence(self: InfixParser) u64 {
return switch (self) {
.binary_op => |binary_op| binary_op.precedence,
.define_type_infer => DEFINE,
.define_or_range => DEFINE,
.plus_equal => DEFINE,
.times_equal => DEFINE,
.call => CALL,
.index => INDEX,
};
}
fn run(self: InfixParser, codebase: *ECS, tokens: *Tokens, left: Entity, parser_precedence: u64) !Entity {
_ = tokens.next();
return try switch (self) {
.binary_op => |binary_op| parseBinaryOp(
codebase,
tokens,
left,
binary_op.op,
parser_precedence,
),
.define_type_infer => parseDefineTypeInfer(codebase, tokens, left, parser_precedence),
.define_or_range => parseDefineOrRange(codebase, tokens, left, parser_precedence),
.call => parseCall(codebase, tokens, left),
.plus_equal => parsePlusEqual(codebase, tokens, left, parser_precedence),
.times_equal => parseTimesEqual(codebase, tokens, left, parser_precedence),
.index => parseIndex(codebase, tokens, left),
};
}
};
fn parseBinaryOp(codebase: *ECS, tokens: *Tokens, left: Entity, op: components.BinaryOp, precedence: u64) !Entity {
const right = try parseExpression(codebase, tokens, precedence + 1);
const arguments = try components.Arguments.fromSlice(codebase.arena.allocator(), &.{ left, right });
return try codebase.createEntity(.{
components.AstKind.binary_op,
op,
components.Span.init(left.get(components.Span).begin, right.get(components.Span).end),
arguments,
});
}
fn parsePlusEqual(codebase: *ECS, tokens: *Tokens, left: Entity, precedence: u64) !Entity {
const right = try parseExpression(codebase, tokens, precedence + 1);
const arguments = try components.Arguments.fromSlice(codebase.arena.allocator(), &.{ left, right });
return try codebase.createEntity(.{
components.AstKind.plus_equal,
components.Span.init(left.get(components.Span).begin, right.get(components.Span).end),
arguments,
});
}
fn parseTimesEqual(codebase: *ECS, tokens: *Tokens, left: Entity, precedence: u64) !Entity {
const right = try parseExpression(codebase, tokens, precedence + 1);
const arguments = try components.Arguments.fromSlice(codebase.arena.allocator(), &.{ left, right });
return try codebase.createEntity(.{
components.AstKind.times_equal,
components.Span.init(left.get(components.Span).begin, right.get(components.Span).end),
arguments,
});
}
fn parseDefineTypeInfer(codebase: *ECS, tokens: *Tokens, name: Entity, precedence: u64) !Entity {
const value = try parseExpression(codebase, tokens, precedence);
return try codebase.createEntity(.{
components.AstKind.define,
components.Name.init(name),
components.Value.init(value),
components.Span.init(name.get(components.Span).begin, value.get(components.Span).end),
});
}
fn parseDefineOrRange(codebase: *ECS, tokens: *Tokens, lhs: Entity, precedence: u64) !Entity {
const kind = lhs.get(components.AstKind);
switch (kind) {
.symbol => {
const type_ast = try parseExpression(codebase, tokens, DEFINE + NEXT_PRECEDENCE);
if (tokens.peek()) |token| {
if (token.get(components.TokenKind) == .equal) {
_ = tokens.next();
const value = try parseExpression(codebase, tokens, precedence);
return try codebase.createEntity(.{
components.AstKind.define,
components.Name.init(lhs),
components.TypeAst.init(type_ast),
components.Value.init(value),
components.Span.init(lhs.get(components.Span).begin, value.get(components.Span).end),
});
}
}
return try codebase.createEntity(.{
components.AstKind.range,
components.Span.init(lhs.get(components.Span).begin, type_ast.get(components.Span).end),
components.First.init(lhs),
components.Last.init(type_ast),
});
},
.int => {
const last = try parseExpression(codebase, tokens, LOWEST);
return try codebase.createEntity(.{
components.AstKind.range,
components.Span.init(lhs.get(components.Span).begin, last.get(components.Span).end),
components.First.init(lhs),
components.Last.init(last),
});
},
else => panic("\nparsing define or range got kind {}\n", .{kind}),
}
}
fn parseCall(codebase: *ECS, tokens: *Tokens, callable: Entity) !Entity {
var arguments = components.Arguments.init(codebase.arena.allocator());
var named_arguments = components.NamedArguments.init(codebase.arena.allocator(), codebase.getPtr(Strings));
while (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.right_paren => break,
.comma => _ = tokens.next(),
else => {
const argument = try parseExpression(codebase, tokens, LOWEST);
if (argument.get(components.AstKind) == .define) {
const name = argument.get(components.Name);
const value = argument.get(components.Value).entity;
try named_arguments.putName(name, value);
} else {
try arguments.append(argument);
}
},
}
}
return try codebase.createEntity(.{
components.AstKind.call,
components.Callable.init(callable),
arguments,
named_arguments,
components.Span.init(callable.get(components.Span).begin, tokens.next().?.get(components.Span).end),
});
}
fn parseIndex(codebase: *ECS, tokens: *Tokens, array: Entity) !Entity {
const index = try parseExpression(codebase, tokens, LOWEST);
const end = tokens.consume(.right_bracket).get(components.Span).end;
const arguments = try components.Arguments.fromSlice(codebase.arena.allocator(), &.{ array, index });
return try codebase.createEntity(.{
components.AstKind.index,
arguments,
components.Span.init(array.get(components.Span).begin, end),
});
}
fn parseFunctionParameters(codebase: *ECS, tokens: *Tokens) !components.Parameters {
var parameters = components.Parameters.init(codebase.arena.allocator());
while (tokens.next()) |token| {
const kind = token.get(components.TokenKind);
switch (kind) {
.right_paren => break,
.comma => continue,
.symbol => {
_ = tokens.consume(.colon);
_ = try token.set(.{
components.TypeAst.init(try parseExpression(codebase, tokens, LOWEST)),
});
try parameters.append(token);
},
else => panic("\ninvalid token kind, {}\n", .{kind}),
}
}
return parameters;
}
fn parseFunctionBody(codebase: *ECS, tokens: *Tokens) !components.Body {
var body = components.Body.init(codebase.arena.allocator());
while (true) {
if (tokens.peek()) |token| {
switch (token.get(components.TokenKind)) {
.right_brace => break,
.new_line => _ = tokens.next(),
else => try body.append(try parseExpression(codebase, tokens, LOWEST)),
}
} else break;
}
return body;
}
fn parseImport(tokens: *Tokens, imports: *components.Imports) !void {
const string = tokens.consume(.string);
const path = components.Path.init(string);
const import = try string.ecs.createEntity(.{
components.AstKind.import,
path,
string.get(components.Span),
});
try imports.append(import);
}
fn overloadFunction(top_level: *components.TopLevel, function: Entity, name: components.Name) !void {
const codebase = function.ecs;
_ = try function.set(.{name});
if (top_level.hasName(name)) |overload_set| {
try overload_set.getPtr(components.Overloads).append(function);
} else {
var overloads = components.Overloads.init(codebase.arena.allocator());
try overloads.append(function);
const overload_set = try codebase.createEntity(.{
components.AstKind.overload_set,
overloads,
});
try top_level.putName(name, overload_set);
}
}
pub fn parseFunction(codebase: *ECS, tokens: *Tokens, name: Entity) !Entity {
const function = try codebase.createEntity(.{components.AstKind.function});
const begin = name.get(components.Span).begin;
const parameters = try parseFunctionParameters(codebase, tokens);
switch (tokens.peek().?.get(components.TokenKind)) {
.left_brace => _ = tokens.next(),
else => {
const return_type = components.ReturnTypeAst.init(try parseExpression(codebase, tokens, HIGHEST));
_ = try function.set(.{return_type});
_ = tokens.consume(.left_brace);
},
}
const body = try parseFunctionBody(codebase, tokens);
const end = tokens.consume(.right_brace).get(components.Span).end;
const span = components.Span.init(begin, end);
return try function.set(.{
parameters,
body,
span,
});
}
fn parseStruct(tokens: *Tokens, top_level: *components.TopLevel, struct_token: Entity) !void {
const codebase = struct_token.ecs;
const begin = struct_token.get(components.Span).begin;
const name = tokens.consume(.symbol);
_ = tokens.consume(.left_brace);
var fields = components.Fields.init(codebase.arena.allocator());
while (tokens.next()) |token| {
const kind = token.get(components.TokenKind);
switch (kind) {
.right_brace => {
const end = token.get(components.Span).end;
const span = components.Span.init(begin, end);
const struct_ = try codebase.createEntity(.{
components.AstKind.struct_,
fields,
span,
name.get(components.Literal),
components.Type.init(codebase.get(components.Builtins).Type),
});
try overloadFunction(top_level, struct_, components.Name.init(name));
return;
},
.new_line => continue,
.symbol => {
_ = tokens.consume(.colon);
_ = try token.set(.{
components.TypeAst.init(try parseExpression(codebase, tokens, LOWEST)),
});
try fields.append(token);
},
else => panic("\ninvalid token kind, {}\n", .{kind}),
}
}
panic("\ncompiler bug in parse struct\n", .{});
}
fn parseAttributeExport(tokens: *Tokens, top_level: *components.TopLevel, foreign_exports: *components.ForeignExports) !void {
_ = tokens.consume(.new_line);
const name = tokens.consume(.symbol);
_ = tokens.consume(.left_paren);
const function = try parseFunction(name.ecs, tokens, name);
try overloadFunction(top_level, function, components.Name.init(name));
try foreign_exports.append(name);
}
fn parseAttributeImportInferName(tokens: *Tokens, top_level: *components.TopLevel) !void {
_ = tokens.consume(.new_line);
const name = tokens.consume(.symbol);
const foreign_module = blk: {
const interned = try name.ecs.getPtr(Strings).intern("host");
const literal = components.Literal.init(interned);
const length = components.Length{ .value = 4 };
const entity = try name.ecs.createEntity(.{
components.TokenKind.string,
literal,
length,
});
break :blk components.ForeignModule.init(entity);
};
const foreign_name = blk: {
const literal = name.get(components.Literal);
const span = name.get(components.Span);
const length = components.Length{ .value = @intCast(i32, span.end.column - span.begin.column) };
const entity = try name.ecs.createEntity(.{
components.TokenKind.string,
literal,
length,
span,
});
break :blk components.ForeignName.init(entity);
};
const begin = name.get(components.Span).begin;
_ = tokens.consume(.left_paren);
const codebase = name.ecs;
const parameters = try parseFunctionParameters(codebase, tokens);
const return_type = components.ReturnTypeAst.init(try parseExpression(codebase, tokens, HIGHEST));
const end = return_type.entity.get(components.Span).end;
const span = components.Span.init(begin, end);
const function = try codebase.createEntity(.{
components.AstKind.function,
foreign_module,
foreign_name,
parameters,
return_type,
span,
});
try overloadFunction(top_level, function, components.Name.init(name));
}
fn parseAttributeImport(tokens: *Tokens, top_level: *components.TopLevel) !void {
if (tokens.peek().?.get(components.TokenKind) != .left_paren) {
return parseAttributeImportInferName(tokens, top_level);
}
const begin = tokens.consume(.left_paren).get(components.Span).begin;
const foreign_module = components.ForeignModule.init(tokens.consume(.string));
_ = tokens.consume(.comma);
const foreign_name = components.ForeignName.init(tokens.consume(.string));
_ = tokens.consume(.right_paren);
_ = tokens.consume(.new_line);
const name = tokens.consume(.symbol);
_ = tokens.consume(.left_paren);
const codebase = name.ecs;
const parameters = try parseFunctionParameters(codebase, tokens);
const return_type = components.ReturnTypeAst.init(try parseExpression(codebase, tokens, HIGHEST));
const end = return_type.entity.get(components.Span).end;
const span = components.Span.init(begin, end);
const function = try codebase.createEntity(.{
components.AstKind.function,
foreign_module,
foreign_name,
parameters,
return_type,
span,
});
try overloadFunction(top_level, function, components.Name.init(name));
}
pub fn parse(module: Entity, tokens: *Tokens) !void {
const codebase = module.ecs;
const allocator = codebase.arena.allocator();
var top_level = components.TopLevel.init(allocator, codebase.getPtr(Strings));
var imports = components.Imports.init(allocator);
var foreign_exports = components.ForeignExports.init(allocator);
while (tokens.next()) |token| {
const kind = token.get(components.TokenKind);
switch (kind) {
.symbol => {
const name = components.Name.init(token);
assert(tokens.next().?.get(components.TokenKind) == .left_paren);
const function = try parseFunction(token.ecs, tokens, token);
try overloadFunction(&top_level, function, name);
},
.new_line => continue,
.struct_ => try parseStruct(tokens, &top_level, token),
.import => try parseImport(tokens, &imports),
.attribute_export => try parseAttributeExport(tokens, &top_level, &foreign_exports),
.attribute_import => try parseAttributeImport(tokens, &top_level),
else => panic("\nparse unsupported kind {}\n", .{kind}),
}
}
_ = try module.set(.{
top_level,
foreign_exports,
imports,
components.Type.init(codebase.get(components.Builtins).Module),
});
} | src/parser.zig |
const Opcode = @import("instruction.zig").Opcode;
const Instruction = @import("function.zig").Instruction;
pub const LimitType = enum(u8) {
Min,
MinMax,
};
pub fn limitMatch(min_imported: u32, max_imported: ?u32, min_stated: u32, max_stated: ?u32) bool {
// TODO: this is a bit confusing, clean it up
if (min_imported < min_stated) return false;
if (max_stated) |defined_max| {
if (max_imported) |imported_max| {
if (!(imported_max <= defined_max)) {
return false;
}
} else {
return false;
}
}
return true;
}
// Table / Memory
pub const Limit = struct {
min: u32,
max: ?u32,
import: ?u32,
};
pub const Mutability = enum(u8) {
Immutable,
Mutable,
};
pub const ValueType = enum(u8) {
I32 = 0x7F,
I64 = 0x7E,
F32 = 0x7D,
F64 = 0x7C,
};
pub fn valueTypeFromBlockType(block_type: i32) !ValueType {
return switch (block_type) {
-0x01 => .I32,
-0x02 => .I64,
-0x03 => .F32,
-0x04 => .F64,
else => error.UnexpectedBlockType,
};
}
pub fn toValueType(comptime t: type) ValueType {
return switch (t) {
i32 => .I32,
i64 => .I64,
f32 => .F32,
f64 => .F64,
u32 => .I32,
else => @compileError("toValueType: unsupported type: " ++ @typeName(t)),
};
}
pub const FuncType = struct {
params: []const ValueType,
results: []const ValueType,
};
pub const Function = struct {
typeidx: u32,
import: ?u32,
};
pub const Global = struct {
value_type: ValueType,
mutability: Mutability,
start: ?usize,
import: ?u32,
};
pub const Import = struct {
module: []const u8,
name: []const u8,
desc_tag: Tag,
// desc: u8,
};
pub const Export = struct {
name: []const u8,
tag: Tag,
index: u32,
};
pub const Element = struct {};
pub const Segment = struct {
index: u32,
start: usize, // Initialisation code start
count: u32, // Number of elements in data (useful when data is not []u8)
data: []const u8,
};
pub const Tag = enum(u8) {
Func,
Table,
Mem,
Global,
};
pub const Range = struct {
offset: usize = 0,
count: usize = 0,
};
pub const LocalType = struct {
count: u32,
value_type: ValueType,
}; | src/common.zig |
const builtin = @import("builtin");
const std = @import("std");
const mem = std.mem;
const redis = @import("./redismodule.zig");
const cuckoo = @import("./lib/zig-cuckoofilter.zig");
const t_ccf = @import("./t_cuckoofilter.zig");
// We save the initial state of Xoroshiro seeded at 42 at compile-time,
// used to initialize the prng state for each new cuckoofilter key.
// This way we are able to provide fully deterministic behavior.
const XoroDefaultState: [2]u64 = comptime std.rand.Xoroshiro128.init(42).s;
// Compares two strings ignoring case (ascii strings, not fancy unicode strings).
// Used by commands to check if a given flag (e.g. NX, EXACT, ...) was given as an arugment.
// Specialzied version where one string is comptime known (and all uppercase).
inline fn insensitive_eql(comptime uppercase: []const u8, str: []const u8) bool {
comptime {
var i = 0;
while (i < uppercase.len) : (i += 1) {
if (uppercase[i] >= 'a' and uppercase[i] <= 'z') {
@compileError("`insensitive_eql` requires the first argument to be all uppercase");
}
}
}
if (uppercase.len != str.len) return false;
if (uppercase.len < 10) {
comptime var i = 0;
inline while (i < uppercase.len) : (i += 1) {
const val = if (str[i] >= 'a' and str[i] <= 'z') str[i] - 32 else str[i];
if (val != uppercase[i]) return false;
}
} else {
var i = 0;
while (i < uppercase.len) : (i += 1) {
const val = if (str[i] >= 'a' and str[i] <= 'z') str[i] - 32 else str[i];
if (val != uppercase[i]) return false;
}
}
return true;
}
// Given a byte count, returns the equivalent string size (e.g. 1024 -> "1K")
// Specialized version for some powers of 2
fn size2str(size: usize, buf: *[5]u8) ![]u8 {
var pow_1024: usize = 0;
var num = size;
while (num >= 1024) {
num = try std.math.divExact(usize, num, 1024);
pow_1024 += 1;
}
var letter: u8 = undefined;
switch (pow_1024) {
0 => return error.TooSmall,
1 => letter = 'K',
2 => letter = 'M',
3 => letter = 'G',
else => return error.TooBig,
}
// We want to stop at 8G
if (pow_1024 == 3 and num > 8) return error.TooBig;
return switch (num) {
1, 2, 4, 8, 16, 32, 64, 128, 256, 512 => try std.fmt.bufPrint(buf, "{}{c}\x00", num, letter),
else => error.Error,
};
}
// Given a size, returns the equivalent byte count (e.g. "1K" -> 1024)
// Specialized version for some powers of 2
fn str2size(str: []const u8) !usize {
if (str.len < 2 or str.len > 4) return error.Error;
var pow_1024: usize = undefined;
switch (str[str.len - 1]) {
'k', 'K' => pow_1024 = 1024,
'm', 'M' => pow_1024 = 1024 * 1024,
'g', 'G' => pow_1024 = 1024 * 1024 * 1024,
else => return error.Error,
}
// Parse the numeric part
const num: usize = try std.fmt.parseInt(usize, str[0..(str.len - 1)], 10);
// We want to stop at 8G
if (pow_1024 == 3 and num > 8) return error.Error;
return switch (num) {
1, 2, 4, 8, 16, 32, 64, 128, 256, 512 => try std.math.mul(usize, num, pow_1024),
else => error.Error,
};
}
// Parses hash and fp values, used by most commands.
inline fn parse_args(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int, hash: *u64, fp: *u32) !void {
if (argc != 4) {
_ = redis.RedisModule_WrongArity.?(ctx);
return error.Error;
}
// Parse hash as u64
var hash_len: usize = undefined;
var hash_str = redis.RedisModule_StringPtrLen.?(argv[2], &hash_len);
var hash_start: usize = 0;
if (hash_len > 0 and hash_str[0] == '-') {
// Shift forward by 1 to skip the negative sign
hash_start = 1;
}
hash.* = std.fmt.parseInt(u64, hash_str[hash_start..hash_len], 10) catch |err| {
_ = switch (err) {
error.Overflow => redis.RedisModule_ReplyWithError.?(ctx, c"ERR hash overflows u64"),
error.InvalidCharacter => redis.RedisModule_ReplyWithError.?(ctx, c"ERR hash contains bad character"),
};
return error.Error;
};
// The hash was a negative number
if (hash_start == 1) {
hash.* = std.math.sub(u64, std.math.maxInt(u64), hash.*) catch {
_ = redis.RedisModule_ReplyWithError.?(ctx, c"ERR hash underflows u64");
return error.Error;
};
}
// Parse fp as u32
var fp_len: usize = undefined;
var fp_str = redis.RedisModule_StringPtrLen.?(argv[3], &fp_len);
var fp_start: usize = 0;
if (fp_len > 0 and fp_str[0] == '-') {
// Shift forward by 1 to skip the negative sign
fp_start = 1;
}
fp.* = @bitCast(u32, std.fmt.parseInt(i32, fp_str[fp_start..fp_len], 10) catch |err| {
_ = switch (err) {
error.Overflow => redis.RedisModule_ReplyWithError.?(ctx, c"ERR fp overflows u32"),
error.InvalidCharacter => redis.RedisModule_ReplyWithError.?(ctx, c"ERR fp contains bad character"),
};
return error.Error;
});
// The fp was a negative number
if (fp_start == 1) {
fp.* = std.math.sub(u32, std.math.maxInt(u32), fp.*) catch {
_ = redis.RedisModule_ReplyWithError.?(ctx, c"ERR fp underflows u32");
return error.Error;
};
}
}
// Registers the module and its commands.
export fn RedisModule_OnLoad(ctx: *redis.RedisModuleCtx, argv: [*c]*redis.RedisModuleString, argc: c_int) c_int {
if (redis.RedisModule_Init(ctx, c"cuckoofilter", 1, redis.REDISMODULE_APIVER_1) == redis.REDISMODULE_ERR) {
return redis.REDISMODULE_ERR;
}
// Register our custom types
t_ccf.RegisterTypes(ctx) catch return redis.REDISMODULE_ERR;
// Register our commands
registerCommand(ctx, c"cf.init", CF_INIT, c"write deny-oom", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.rem", CF_REM, c"write fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.add", CF_ADD, c"write fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.fixtoofull", CF_FIXTOOFULL, c"write fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.check", CF_CHECK, c"readonly fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.count", CF_COUNT, c"readonly fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.isbroken", CF_ISBROKEN, c"readonly fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.istoofull", CF_ISTOOFULL, c"readonly fast", 1, 1, 1) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.capacity", CF_CAPACITY, c"fast allow-loading allow-stale", 0, 0, 0) catch return redis.REDISMODULE_ERR;
registerCommand(ctx, c"cf.sizefor", CF_SIZEFOR, c"fast allow-loading allow-stale", 0, 0, 0) catch return redis.REDISMODULE_ERR;
return redis.REDISMODULE_OK;
}
inline fn registerCommand(ctx: *redis.RedisModuleCtx, cmd: [*c]const u8, func: redis.RedisModuleCmdFunc, mode: [*c]const u8, firstkey: c_int, lastkey: c_int, keystep: c_int) !void {
const err = redis.RedisModule_CreateCommand.?(ctx, cmd, func, mode, firstkey, lastkey, keystep);
if (err == redis.REDISMODULE_ERR) return error.Error;
}
// CF.INIT size [fpsize]
export fn CF_INIT(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 3 and argc != 4) return redis.RedisModule_WrongArity.?(ctx);
// size argument
var size_len: usize = undefined;
const size_str = redis.RedisModule_StringPtrLen.?(argv[2], &size_len)[0..size_len];
const size = str2size(size_str) catch return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad size");
// fpsize argument
var fp_size = "1"[0..];
if (argc == 4) {
var fp_size_len: usize = undefined;
fp_size = redis.RedisModule_StringPtrLen.?(argv[3], &fp_size_len)[0..fp_size_len];
}
// Obtain the key from Redis.
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
var keyType = redis.RedisModule_KeyType.?(key);
if (keyType != redis.REDISMODULE_KEYTYPE_EMPTY) return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key already exists");
// New Cuckoo Filter!
if (fp_size.len != 1) return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize");
return switch (fp_size[0]) {
'1' => do_init(t_ccf.Filter8, ctx, key, size),
'2' => do_init(t_ccf.Filter16, ctx, key, size),
'4' => do_init(t_ccf.Filter32, ctx, key, size),
else => return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize"),
};
}
inline fn do_init(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey, size: usize) c_int {
var cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_Alloc.?(@sizeOf(CFType))));
var buckets = @ptrCast([*]u8, @alignCast(@alignOf(usize), redis.RedisModule_Alloc.?(size)));
const realCFType = @typeOf(cf.cf);
cf.s = XoroDefaultState;
cf.cf = realCFType.init(buckets[0..size]) catch return redis.RedisModule_ReplyWithError.?(ctx, c"ERR could not create filter");
switch (CFType) {
t_ccf.Filter8 => _ = redis.RedisModule_ModuleTypeSetValue.?(key, t_ccf.Type8, cf),
t_ccf.Filter16 => _ = redis.RedisModule_ModuleTypeSetValue.?(key, t_ccf.Type16, cf),
t_ccf.Filter32 => _ = redis.RedisModule_ModuleTypeSetValue.?(key, t_ccf.Type32, cf),
else => unreachable,
}
_ = redis.RedisModule_ReplicateVerbatim.?(ctx);
return redis.RedisModule_ReplyWithSimpleString.?(ctx, c"OK");
}
// CF.ADD key hash fp
export fn CF_ADD(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
var hash: u64 = undefined;
var fp: u32 = undefined;
parse_args(ctx, argv, argc, &hash, &fp) catch return redis.REDISMODULE_OK;
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_add(t_ccf.Filter8, ctx, key, hash, fp) else if (keyType == t_ccf.Type16) do_add(t_ccf.Filter16, ctx, key, hash, fp) else if (keyType == t_ccf.Type32) do_add(t_ccf.Filter32, ctx, key, hash, fp) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_add(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey, hash: u64, fp: u32) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
const realCFType = @typeOf(cf.cf);
cuckoo.set_default_prng_state(cf.s);
defer {
cf.s = cuckoo.get_default_prng_state();
}
_ = redis.RedisModule_ReplicateVerbatim.?(ctx);
return if (cf.cf.add(hash, @truncate(realCFType.FPType, fp)))
redis.RedisModule_ReplyWithSimpleString.?(ctx, c"OK")
else |err| switch (err) {
error.Broken => redis.RedisModule_ReplyWithError.?(ctx, c"ERR filter is broken"),
error.TooFull => redis.RedisModule_ReplyWithError.?(ctx, c"ERR too full"),
};
}
// CF.CHECK key hash fp
export fn CF_CHECK(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
var hash: u64 = undefined;
var fp: u32 = undefined;
parse_args(ctx, argv, argc, &hash, &fp) catch return redis.REDISMODULE_OK;
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_check(t_ccf.Filter8, ctx, key, hash, fp) else if (keyType == t_ccf.Type16) do_check(t_ccf.Filter16, ctx, key, hash, fp) else if (keyType == t_ccf.Type32) do_check(t_ccf.Filter32, ctx, key, hash, fp) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_check(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey, hash: u64, fp: u32) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
const realCFType = @typeOf(cf.cf);
return if (cf.cf.maybe_contains(hash, @truncate(realCFType.FPType, fp))) |maybe_found|
redis.RedisModule_ReplyWithSimpleString.?(ctx, if (maybe_found) c"1" else c"0")
else |err| switch (err) {
error.Broken => redis.RedisModule_ReplyWithError.?(ctx, c"ERR filter is broken"),
};
}
// CF.REM key hash fp
export fn CF_REM(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
var hash: u64 = undefined;
var fp: u32 = undefined;
parse_args(ctx, argv, argc, &hash, &fp) catch return redis.REDISMODULE_OK;
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_rem(t_ccf.Filter8, ctx, key, hash, fp) else if (keyType == t_ccf.Type16) do_rem(t_ccf.Filter16, ctx, key, hash, fp) else if (keyType == t_ccf.Type32) do_rem(t_ccf.Filter32, ctx, key, hash, fp) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_rem(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey, hash: u64, fp: u32) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
const realCFType = @typeOf(cf.cf);
_ = redis.RedisModule_ReplicateVerbatim.?(ctx);
return if (cf.cf.remove(hash, @truncate(realCFType.FPType, fp)))
redis.RedisModule_ReplyWithSimpleString.?(ctx, c"OK")
else |err| switch (err) {
error.Broken => redis.RedisModule_ReplyWithError.?(ctx, c"ERR filter is broken"),
};
}
// CF.FIXTOOFULL key
export fn CF_FIXTOOFULL(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2) return redis.RedisModule_WrongArity.?(ctx);
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_fixtoofull(t_ccf.Filter8, ctx, key) else if (keyType == t_ccf.Type16) do_fixtoofull(t_ccf.Filter16, ctx, key) else if (keyType == t_ccf.Type32) do_fixtoofull(t_ccf.Filter32, ctx, key) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_fixtoofull(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
const realCFType = @typeOf(cf.cf);
cuckoo.set_default_prng_state(cf.s);
defer {
cf.s = cuckoo.get_default_prng_state();
}
_ = redis.RedisModule_ReplicateVerbatim.?(ctx);
return if (cf.cf.fix_toofull())
redis.RedisModule_ReplyWithSimpleString.?(ctx, c"OK")
else |err| switch (err) {
error.Broken => redis.RedisModule_ReplyWithError.?(ctx, c"ERR filter is broken"),
error.TooFull => redis.RedisModule_ReplyWithError.?(ctx, c"ERR too full"),
};
}
// CF.COUNT key
export fn CF_COUNT(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2) return redis.RedisModule_WrongArity.?(ctx);
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_count(t_ccf.Filter8, ctx, key) else if (keyType == t_ccf.Type16) do_count(t_ccf.Filter16, ctx, key) else if (keyType == t_ccf.Type32) do_count(t_ccf.Filter32, ctx, key) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_count(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
return if (cf.cf.count()) |count|
redis.RedisModule_ReplyWithLongLong.?(ctx, @intCast(c_longlong, count))
else |err| switch (err) {
error.Broken => redis.RedisModule_ReplyWithError.?(ctx, c"ERR filter is broken"),
};
}
// CF.ISTOOFULL key
export fn CF_ISTOOFULL(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2) return redis.RedisModule_WrongArity.?(ctx);
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_istoofull(t_ccf.Filter8, ctx, key) else if (keyType == t_ccf.Type16) do_istoofull(t_ccf.Filter16, ctx, key) else if (keyType == t_ccf.Type32) do_istoofull(t_ccf.Filter32, ctx, key) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_istoofull(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
return redis.RedisModule_ReplyWithSimpleString.?(ctx, if (cf.cf.is_toofull()) c"1" else c"0");
}
// CF.ISBROKEN key
export fn CF_ISBROKEN(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2) return redis.RedisModule_WrongArity.?(ctx);
var key = @ptrCast(?*redis.RedisModuleKey, redis.RedisModule_OpenKey.?(ctx, argv[1], redis.REDISMODULE_READ | redis.REDISMODULE_WRITE));
defer redis.RedisModule_CloseKey.?(key);
if (redis.RedisModule_KeyType.?(key) == redis.REDISMODULE_KEYTYPE_EMPTY)
return redis.RedisModule_ReplyWithError.?(ctx, c"ERR key does not exist");
const keyType = redis.RedisModule_ModuleTypeGetType.?(key);
return if (keyType == t_ccf.Type8) do_isbroken(t_ccf.Filter8, ctx, key) else if (keyType == t_ccf.Type16) do_isbroken(t_ccf.Filter16, ctx, key) else if (keyType == t_ccf.Type32) do_isbroken(t_ccf.Filter32, ctx, key) else redis.RedisModule_ReplyWithError.?(ctx, redis.REDISMODULE_ERRORMSG_WRONGTYPE);
}
inline fn do_isbroken(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, key: ?*redis.RedisModuleKey) c_int {
const cf = @ptrCast(*CFType, @alignCast(@alignOf(usize), redis.RedisModule_ModuleTypeGetValue.?(key)));
return redis.RedisModule_ReplyWithSimpleString.?(ctx, if (cf.cf.is_broken()) c"1" else c"0");
}
// CF.CAPACITY size [fpsize]
export fn CF_CAPACITY(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2 and argc != 3) return redis.RedisModule_WrongArity.?(ctx);
// SIZE argument
var size_len: usize = undefined;
const size_str = redis.RedisModule_StringPtrLen.?(argv[1], &size_len)[0..size_len];
// FPSIZE argument
var fp_size = "1"[0..];
if (argc == 3) {
var fpsize_len: usize = undefined;
fp_size = redis.RedisModule_StringPtrLen.?(argv[2], &fpsize_len)[0..fpsize_len];
}
const size = str2size(size_str) catch return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad size");
if (fp_size.len != 1) return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize");
return switch (fp_size[0]) {
'1' => redis.RedisModule_ReplyWithLongLong.?(ctx, @intCast(c_longlong, cuckoo.Filter8.capacity(size))),
'2' => redis.RedisModule_ReplyWithLongLong.?(ctx, @intCast(c_longlong, cuckoo.Filter16.capacity(size))),
'4' => redis.RedisModule_ReplyWithLongLong.?(ctx, @intCast(c_longlong, cuckoo.Filter32.capacity(size))),
else => redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize"),
};
}
// CF.SIZEFOR universe [fpsize] [EXACT]
export fn CF_SIZEFOR(ctx: ?*redis.RedisModuleCtx, argv: [*c]?*redis.RedisModuleString, argc: c_int) c_int {
if (argc != 2 and argc != 3 and argc != 4) return redis.RedisModule_WrongArity.?(ctx);
// Parse universe
var uni_len: usize = undefined;
var uni_str = redis.RedisModule_StringPtrLen.?(argv[1], &uni_len);
const universe = std.fmt.parseInt(usize, uni_str[0..uni_len], 10) catch |err| return switch (err) {
error.Overflow => redis.RedisModule_ReplyWithError.?(ctx, c"ERR universe overflows usize"),
error.InvalidCharacter => redis.RedisModule_ReplyWithError.?(ctx, c"ERR universe contains bad character"),
};
// Parse fpsize and EXACT
var fp_size = "1"[0..];
var exact = false;
if (argc > 2) {
var arg2len: usize = undefined;
const arg2 = redis.RedisModule_StringPtrLen.?(argv[2], &arg2len)[0..arg2len];
if (insensitive_eql("EXACT", arg2)) exact = true else fp_size = arg2;
}
if (argc == 4) {
if (exact) return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize");
var arg3len: usize = undefined;
const arg3 = redis.RedisModule_StringPtrLen.?(argv[3], &arg3len)[0..arg3len];
if (insensitive_eql("EXACT", arg3)) exact = true else return redis.RedisModule_WrongArity.?(ctx);
}
if (fp_size.len != 1) return redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize");
return switch (fp_size[0]) {
'1' => do_sizefor(cuckoo.Filter8, ctx, universe, exact),
'2' => do_sizefor(cuckoo.Filter16, ctx, universe, exact),
'4' => do_sizefor(cuckoo.Filter32, ctx, universe, exact),
else => redis.RedisModule_ReplyWithError.?(ctx, c"ERR bad fpsize"),
};
}
fn do_sizefor(comptime CFType: type, ctx: ?*redis.RedisModuleCtx, universe: usize, exact: bool) c_int {
var buf: [5]u8 = undefined;
const size = if (exact) CFType.size_for_exactly(universe) else CFType.size_for(universe);
_ = size2str(std.math.max(1024, size), &buf) catch |err| switch (err) {
error.TooBig => return redis.RedisModule_ReplyWithError.?(ctx, c"ERR unsupported resulting size (8G max)"),
else => return redis.RedisModule_ReplyWithError.?(ctx, c"ERR unexpected error. Please report it at github.com/kristoff-it/redis-cuckoofilter"),
};
return redis.RedisModule_ReplyWithSimpleString.?(ctx, @ptrCast([*c]const u8, &buf));
}
test "insensitive_eql" {
std.testing.expect(insensitive_eql("EXACT", "EXACT"));
std.testing.expect(insensitive_eql("EXACT", "exact"));
std.testing.expect(insensitive_eql("EXACT", "exacT"));
std.testing.expect(insensitive_eql("EXACT", "eXacT"));
std.testing.expect(insensitive_eql("", ""));
std.testing.expect(insensitive_eql("1", "1"));
std.testing.expect(insensitive_eql("1234", "1234"));
std.testing.expect(!insensitive_eql("", "1"));
std.testing.expect(!insensitive_eql("1", "2"));
std.testing.expect(!insensitive_eql("1", "12"));
std.testing.expect(!insensitive_eql("EXACT", "AXACT"));
std.testing.expect(!insensitive_eql("EXACT", "ESACT"));
std.testing.expect(!insensitive_eql("EXACT", "EXECT"));
std.testing.expect(!insensitive_eql("EXACT", "EXAZT"));
std.testing.expect(!insensitive_eql("EXACT", "EXACZ"));
}
test "size2str" {
var buf: [5]u8 = undefined;
std.testing.expect(mem.eql(u8, "1K\x00", size2str(1024 * 1, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "2K\x00", size2str(1024 * 2, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "4K\x00", size2str(1024 * 4, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "8K\x00", size2str(1024 * 8, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "16K\x00", size2str(1024 * 16, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "32K\x00", size2str(1024 * 32, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "64K\x00", size2str(1024 * 64, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "128K\x00", size2str(1024 * 128, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "256K\x00", size2str(1024 * 256, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "512K\x00", size2str(1024 * 512, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "1M\x00", size2str(1024 * 1024 * 1, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "2M\x00", size2str(1024 * 1024 * 2, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "4M\x00", size2str(1024 * 1024 * 4, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "8M\x00", size2str(1024 * 1024 * 8, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "16M\x00", size2str(1024 * 1024 * 16, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "32M\x00", size2str(1024 * 1024 * 32, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "64M\x00", size2str(1024 * 1024 * 64, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "128M\x00", size2str(1024 * 1024 * 128, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "256M\x00", size2str(1024 * 1024 * 256, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "512M\x00", size2str(1024 * 1024 * 512, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "1G\x00", size2str(1024 * 1024 * 1024 * 1, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "2G\x00", size2str(1024 * 1024 * 1024 * 2, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "4G\x00", size2str(1024 * 1024 * 1024 * 4, &buf) catch unreachable));
std.testing.expect(mem.eql(u8, "8G\x00", size2str(1024 * 1024 * 1024 * 8, &buf) catch unreachable));
std.testing.expectError(error.TooSmall, size2str(1, &buf));
std.testing.expectError(error.UnexpectedRemainder, size2str(1025, &buf));
std.testing.expectError(error.TooSmall, size2str(0, &buf));
}
test "str2size" {
std.testing.expect(1024 * 1 == str2size("1K") catch unreachable);
std.testing.expect(1024 * 2 == str2size("2K") catch unreachable);
std.testing.expect(1024 * 4 == str2size("4K") catch unreachable);
std.testing.expect(1024 * 8 == str2size("8K") catch unreachable);
std.testing.expect(1024 * 16 == str2size("16K") catch unreachable);
std.testing.expect(1024 * 32 == str2size("32K") catch unreachable);
std.testing.expect(1024 * 64 == str2size("64K") catch unreachable);
std.testing.expect(1024 * 128 == str2size("128K") catch unreachable);
std.testing.expect(1024 * 256 == str2size("256K") catch unreachable);
std.testing.expect(1024 * 512 == str2size("512K") catch unreachable);
std.testing.expect(1024 * 1024 * 1 == str2size("1M") catch unreachable);
std.testing.expect(1024 * 1024 * 2 == str2size("2M") catch unreachable);
std.testing.expect(1024 * 1024 * 4 == str2size("4M") catch unreachable);
std.testing.expect(1024 * 1024 * 8 == str2size("8M") catch unreachable);
std.testing.expect(1024 * 1024 * 16 == str2size("16M") catch unreachable);
std.testing.expect(1024 * 1024 * 32 == str2size("32M") catch unreachable);
std.testing.expect(1024 * 1024 * 64 == str2size("64M") catch unreachable);
std.testing.expect(1024 * 1024 * 128 == str2size("128M") catch unreachable);
std.testing.expect(1024 * 1024 * 256 == str2size("256M") catch unreachable);
std.testing.expect(1024 * 1024 * 512 == str2size("512M") catch unreachable);
std.testing.expect(1024 * 1024 * 1024 * 1 == str2size("1G") catch unreachable);
std.testing.expect(1024 * 1024 * 1024 * 2 == str2size("2G") catch unreachable);
std.testing.expect(1024 * 1024 * 1024 * 4 == str2size("4G") catch unreachable);
std.testing.expect(1024 * 1024 * 1024 * 8 == str2size("8G") catch unreachable);
std.testing.expectError(error.Error, str2size(""));
std.testing.expectError(error.Error, str2size("5K"));
std.testing.expectError(error.Error, str2size("55"));
std.testing.expectError(error.Error, str2size("800G"));
} | src/redis-cuckoofilter.zig |
const std = @import("std");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Pkg = std.build.Pkg;
const CrossTarget = std.zig.CrossTarget;
const Mode = std.builtin.Mode;
const string = []const u8;
const pkg_sokol = Pkg {
.name = "sokol",
.path = .{ .path = "src/sokol/sokol.zig" },
};
const pkg_stb = Pkg {
.name = "stb",
.path = .{ .path = "src/stb/stb.zig" },
};
pub fn addCLibs(
exe: *LibExeObjStep,
b: *Builder,
target: CrossTarget,
mode: Mode,
) void {
const sokol = buildSokol(b, target, mode);
const stb = buildStb(b, target, mode);
exe.linkLibC();
exe.addPackage(pkg_sokol);
exe.addPackage(pkg_stb);
exe.linkLibrary(sokol);
exe.linkLibrary(stb);
}
fn buildSokol(b: *Builder, target: CrossTarget, mode: Mode) *LibExeObjStep {
const lib = b.addStaticLibrary("sokol", null);
lib.setTarget(target);
lib.setBuildMode(mode);
lib.linkLibC();
const sokol_path = "src/sokol/c/";
const csources = [_][]const u8 {
"sokol_app.c",
"sokol_gfx.c",
"sokol_time.c",
"sokol_audio.c",
};
if (lib.target.isDarwin()) {
b.env_map.put("ZIG_SYSTEM_LINKER_HACK", "1") catch unreachable;
inline for (csources) |csrc| {
lib.addCSourceFile(sokol_path ++ csrc, &[_][]const u8{"-ObjC", "-DIMPL"});
}
lib.linkFramework("MetalKit");
lib.linkFramework("Metal");
lib.linkFramework("Cocoa");
lib.linkFramework("QuartzCore");
lib.linkFramework("AudioToolbox");
} else {
inline for (csources) |csrc| {
lib.addCSourceFile(sokol_path ++ csrc, &[_][]const u8{"-DIMPL"});
}
if (lib.target.isLinux()) {
lib.linkSystemLibrary("X11");
lib.linkSystemLibrary("Xi");
lib.linkSystemLibrary("Xcursor");
lib.linkSystemLibrary("GL");
lib.linkSystemLibrary("asound");
}
else if (lib.target.isWindows()) {
lib.linkSystemLibrary("kernel32");
lib.linkSystemLibrary("user32");
lib.linkSystemLibrary("gdi32");
lib.linkSystemLibrary("ole32");
lib.linkSystemLibrary("d3d11");
lib.linkSystemLibrary("dxgi");
}
}
return lib;
}
fn buildStb(b: *Builder, target: CrossTarget, mode: Mode) *LibExeObjStep {
const lib = b.addStaticLibrary("stb", null);
lib.setTarget(target);
lib.setBuildMode(mode);
lib.linkLibC();
const stb_path = "src/stb/c/";
lib.addCSourceFile(
stb_path ++ "stb.c",
&[_][]const u8{
"-std=c99"
}
);
return lib;
} | clibs.zig |
const std = @import("std");
const win32 = @import("win32");
const WMI = win32.system.wmi;
const COM = win32.system.com;
const OLE = win32.system.ole;
const Foundation = win32.foundation;
const Allocator = std.mem.Allocator;
pub const SysInfoWMI = extern struct {
/// Property for when `initialiseIWbemServices()` is called,
/// to ensure it doesn't attempt to connect to the local namespace
/// more than a single time.
///
/// It is thread safe due to the nature of `initialiseIWbemServices()`'s
/// internal handles. It uses `std.Thread.Mutex.lock()` to lock the declaration
/// for this value to a single thread, and unlock it afterwards.
pub var iwb_service: ?*WMI.IWbemServices = null;
var lock: std.Thread.Mutex = .{};
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
// Enums' properties are sorted alphabetically.
/// Union enum for storing type values
/// of all the possible values a `COM.VARIANT` instance
/// could contain.
pub const VariantElem = union(enum) {
AnyArray: ?*COM.SAFEARRAY, // => 8192 + varType of elements' type.
Boolean: i16, // => 11
Byte: u8, // => 17
Currency: COM.CY, // => 6
Date: f64, // => 7
Decimal: Foundation.DECIMAL, // => 14
Double: f64, // => 5
EMPTY: void, // => 0
ERROR: error{ERROR}, // => 10
Int: i32, // => 2
Long: i32, // => 3
LongLong: i64, // => 20
NULL: void, // => 1
ObjectRef: ?*c_void, // => 9
Single: i32, // => 4
String: ?[]u8, // => 8 (This is actually ?BSTR, but we automatically convert.)
Variant: ?*COM.VARIANT, // => 12
VariantNull: void, // => 13
};
/// Converts a UTF-16 string into UTF-8 using `std.unicode.utf16leToUtf8Alloc()`
///
/// `utf16_str` - The UTF-16 string to convert from.
/// `allocator` - The allocator used to allocate the converted value to heap.
///
/// Returns: A UTF8 "string" representation of the UTF16 string.
///
/// **NOTE**: You MUST free the returned value after you're done using it.
/// The library won't, and can't, do this automatically.
pub fn convertUtf16ToUtf8(
self: @This(),
utf16_str: []const u16,
allocator: *Allocator,
) !?[]u8 {
// Discarding reference to `self` so
// the compiler won't complain.
_ = self;
return try std.unicode.utf16leToUtf8Alloc(allocator, utf16_str);
}
/// Converts a `BSTR` (`?*u16`) value into UTF-8.
///
/// `bstr` - The `BSTR` value to convert from.
/// `allocator` - The allocator used to allocate the converted value to heap.
///
/// Returns: A "string" representation of the `BSTR` value.
///
/// **NOTE**: You MUST free the returned value after you're done using it.
/// The library won't, and can't, do this automatically.
pub fn convertBSTRToUtf8(
self: @This(),
bstr: Foundation.BSTR,
allocator: *Allocator,
) !?[]u8 {
const slice = std.mem.sliceTo(@ptrCast([*:0]u16, bstr), 0);
return self.convertUtf16ToUtf8(slice, allocator);
}
/// Destructs the elements inside of a `SafeArray`
/// into a `StringHashMap`; which can contain any
/// element of type `VariantElem`.
///
/// `obj` - The `IWbemClassObject` instance to obtain the data from.
/// `safeArr` - The `SafeArray` instance to iterate over.
/// `allocator` - The allocator instance used to allocate the hashmap to heap.
///
/// **Note**: The returned `StringHashMap` MUST be freed after
/// you're done using it! The library does not, and cannot, do this automatically.
///
/// **Returns**: A `StringHashMap` containing the values from the provided `SafeArray`.
pub fn destructSafeArray(
self: @This(),
obj: ?*WMI.IWbemClassObject,
safeArr: ?*COM.SAFEARRAY,
allocator: *Allocator,
) std.StringHashMap(VariantElem) {
var map = std.StringHashMap(VariantElem).init(allocator);
var lUpper: i32 = 0;
var lLower: i32 = 0;
var propName: ?*c_void = null;
var propVal: COM.VARIANT = undefined;
if (OLE.SafeArrayGetUBound(safeArr, 1, &lUpper) != 0)
return map;
if (OLE.SafeArrayGetLBound(safeArr, 1, &lLower) != 0)
return map;
var i: i32 = lLower;
while (i < lUpper) : (i += 1) {
var t: ?*i32 = null;
if (OLE.SafeArrayGetElement(safeArr, &i, &propName) != 0) continue;
var bstr: *Foundation.BSTR = @ptrCast(
*Foundation.BSTR,
@alignCast(@alignOf(Foundation.BSTR), propName.?),
);
const slice = std.mem.sliceTo(
@ptrCast([*:0]u16, bstr),
0,
);
if (obj.?.*.IWbemClassObject_Get(
slice,
0,
&propVal,
t,
t,
) != 0) continue;
defer _ = OLE.VariantClear(&propVal);
if (std.unicode.utf16leToUtf8Alloc(&gpa.allocator, slice)) |propName_utf8| {
if (self.getElementVariant(propVal, &gpa.allocator) catch null) |val|
map.put(propName_utf8, val) catch continue;
} else |_| continue;
}
return map;
}
/// Executes a method based on its name and argument descriptions.
///
/// `path` - The path to the parent `IWbemClassObject` which holds the method definition.
/// `method` - The name of the method to execute.
/// `pInInst` - The argument descriptions of the method.
///
/// **Returns**: A pointer to an `IWbemClassObject` instance,
/// which is the outputted value from the method.
pub fn execMethod(
self: @This(),
path: Foundation.BSTR,
method: Foundation.BSTR,
pInInst: ?*WMI.IWbemClassObject,
) ?*WMI.IWbemClassObject {
_ = self;
var pOutInst: ?*WMI.IWbemClassObject = null;
if (iwb_service.?.*.IWbemServices_ExecMethod(
path,
method,
0,
null,
pInInst,
&pOutInst,
null
) != 0) return null;
return pOutInst;
}
/// Extracts the valid element from the Variant value
/// based on the `vt` property--which indicates the type
/// of value allocated.
///
/// `variant` - The value of a `VARIANT` reference.
/// `allocator` - The allocator used to allocate `BSTR` to heap, only. Sometimes this won't be used. If you receive a `[]u8` back, you must free the allocated value from memory.
///
/// Returns: A `VariantElem` union, or an error if something goes wrong.
///
/// **NOTE**: Do not forget to free the `String` value from memory if
/// this value was returned!
pub fn getElementVariant(
self: @This(),
variant: COM.VARIANT,
allocator: *Allocator,
) !VariantElem {
// Discarding reference to `self` so
// the compiler won't complain.
_ = self;
switch (variant.Anonymous.Anonymous.vt) {
0 => return VariantElem{ .EMPTY = {} },
1 => return VariantElem{ .NULL = {} },
2 => return VariantElem{ .Int = variant.Anonymous.Anonymous.Anonymous.intVal },
3 => return VariantElem{ .Long = variant.Anonymous.Anonymous.Anonymous.lVal },
4 => return VariantElem{ .Single = variant.Anonymous.Anonymous.Anonymous.scode },
5 => return VariantElem{ .Double = variant.Anonymous.Anonymous.Anonymous.dblVal },
6 => return VariantElem{ .Currency = variant.Anonymous.Anonymous.Anonymous.cyVal },
7 => return VariantElem{ .Date = variant.Anonymous.Anonymous.Anonymous.date },
8 => {
if (variant.Anonymous.Anonymous.Anonymous.bstrVal == null) return VariantElem{ .String = null };
// Have to ignore here...
return VariantElem{ .String = self.convertBSTRToUtf8(variant.Anonymous.Anonymous.Anonymous.bstrVal.?, allocator) catch null };
},
9 => return VariantElem{ .ObjectRef = variant.Anonymous.Anonymous.Anonymous.byref },
10 => return VariantElem{ .ERROR = error.ERROR },
11 => return VariantElem{ .Boolean = variant.Anonymous.Anonymous.Anonymous.boolVal },
12 => return VariantElem{ .Variant = variant.Anonymous.Anonymous.Anonymous.pvarVal },
13 => return VariantElem{ .VariantNull = {} },
14 => return VariantElem{ .Decimal = variant.Anonymous.decVal },
17 => return VariantElem{ .Byte = variant.Anonymous.Anonymous.Anonymous.bVal },
20 => return VariantElem{ .LongLong = variant.Anonymous.Anonymous.Anonymous.llVal },
8192...8228 => return VariantElem{ .AnyArray = variant.Anonymous.Anonymous.Anonymous.parray },
else => return error.UnknownValue,
}
}
/// Obtains a value of some specified property from the current CIM/WMI class/object.
///
/// `enumerator` - The enumerator instance returned from a query. See: `WMI.query()`; defined as nullable, but the function won't execute without this parameter.
/// `property` - The name of the property to retrieve.
/// `allocator` - The allocator instance used to allocate the value to heap.
///
/// Returns: The queried item. Can be of any type from `VariantElem` union.
///
/// **NOTE**: You MUST free the value allocated to heap after you've finished using it!
/// The library does not, nor can it, do this automatically.
pub fn getItem(
self: @This(),
enumerator: ?*WMI.IEnumWbemClassObject,
obj: ?*WMI.IWbemClassObject,
property: []const u8,
allocator: *Allocator,
) !?VariantElem {
var pclsObj: ?*WMI.IWbemClassObject = obj;
var uReturn: u32 = 0;
while (true) {
var t: i32 = 0;
if (obj == null) {
if (enumerator == null) break;
if (enumerator.?.*.IEnumWbemClassObject_Next(
@enumToInt(WMI.WBEM_INFINITE),
1,
@ptrCast([*]?*WMI.IWbemClassObject, &pclsObj),
&uReturn,
) != 0) return null;
if (uReturn == 0) break;
}
var prop: COM.VARIANT = undefined;
if (std.unicode.utf8ToUtf16LeWithNull(allocator, property)) |utf16_str| {
// Free the freshly allocated utf16_str after scope is finished.
defer allocator.free(utf16_str);
if (pclsObj.?.*.IWbemClassObject_Get(
utf16_str,
0,
&prop,
&t,
&t,
) != 0) return null;
defer _ = OLE.VariantClear(&prop);
defer _ = pclsObj.?.*.IUnknown_Release();
return try self.getElementVariant(prop, allocator);
} else |err| return err;
}
return null;
}
/// Obtains a list of values of all properties (which aren't exposed through this method) from the current CIM/WMI object/class.
///
/// `enumerator` - The enumerator instance returned from a query. See: `WMI.query()`; defined as nullable, but the function won't execute without this parameter.
/// `allocator` - The allocator instance used to allocate the ArrayList to heap.
///
/// Returns: An `ArrayList` of all the values of the current CIM/WMI object/class,
/// each value is stored in a hashmap.
///
/// **NOTE**: You MUST `deinit` the list & values inside after you're done using it!
/// The library does not, nor can it, do this automatically.
pub fn getItems(
self: @This(),
enumerator: ?*WMI.IEnumWbemClassObject,
obj: ?*WMI.IWbemClassObject,
allocator: *Allocator,
) std.ArrayList(std.StringHashMap(VariantElem)) {
var array = std.ArrayList(std.StringHashMap(VariantElem)).init(allocator);
var pclsObj: ?*WMI.IWbemClassObject = obj;
var uReturn: u32 = 0;
var hres: i32 = 0;
if (obj == null) {
if (enumerator == null) return array;
hres = enumerator.?.*.IEnumWbemClassObject_Next(
@enumToInt(WMI.WBEM_INFINITE),
1,
@ptrCast([*]?*WMI.IWbemClassObject, &pclsObj),
&uReturn,
);
if (hres != 0 or uReturn == 0) return array;
}
var qualifier: ?*COM.VARIANT = null;
var safe_arr: ?*COM.SAFEARRAY = null;
if (pclsObj.?.*.IWbemClassObject_GetNames(
null,
0,
qualifier,
&safe_arr,
) != 0) return array;
defer _ = pclsObj.?.*.IUnknown_Release();
_ = array.append(self.destructSafeArray(pclsObj, safe_arr, allocator)) catch return array;
_ = OLE.SafeArrayDestroy(safe_arr);
_ = array.appendSlice((self.getItems(enumerator, null, allocator)).items) catch return array;
return array;
}
/// Obtains an instance of the object
/// based on the provided path.
///
/// `path` - The path of the wanted object.
///
/// **Returns**: A pointer to an `IWbemClassObject` instance, if possible.
pub fn getObjectInst(
self: @This(),
path: Foundation.BSTR,
) ?*WMI.IWbemClassObject {
_ = self;
var obj: ?*WMI.IWbemClassObject = null;
if (iwb_service.?.*.IWbemServices_GetObject(
path,
0,
null,
&obj,
null,
) != 0) return null;
return obj;
}
/// Obtains a method matching the provided method name.
///
/// `obj` - The object from which to obtain the method.
/// `name` - The name of the method to attempt to find.
///
/// **Returns**: A pointer to an `IWbemClassObject` instance
/// which matches the method's argument descriptions.
pub fn getMethod(
self: @This(),
obj: ?*WMI.IWbemClassObject,
name: Foundation.BSTR
) ?*WMI.IWbemClassObject {
_ = self;
var pInClass: ?*WMI.IWbemClassObject = null;
var pInInst: ?*WMI.IWbemClassObject = null;
if (obj.?.*.IWbemClassObject_GetMethod(
std.mem.sliceTo(
@ptrCast([*:0]u16, name),
0
),
0,
&pInClass,
null,
) != 0) return null;
if (pInClass.?.*.IWbemClassObject_SpawnInstance(
0,
&pInInst,
) != 0) return null;
return pInInst;
}
/// Initialises a new `IWbemServices` instance by using `COM` and `WMI`
///
/// Returns: A pointer to an `IWbemServices` instance if successful, otherwise `null`.
pub fn initialiseIWbemServices(
self: @This(),
namespace: ?[]u8,
) ?*WMI.IWbemServices {
var pLoc: ?*c_void = null;
var pSvc: ?*WMI.IWbemServices = null;
var hres: i32 = 0;
var n: u16 = 0;
if (iwb_service != null) return iwb_service;
lock.lock();
defer lock.unlock();
if (COM.CoInitializeEx(null, COM.COINIT_MULTITHREADED) != 0) return null;
if (COM.CoInitializeSecurity(
null,
-1,
null,
null,
COM.RPC_C_AUTHN_LEVEL_DEFAULT,
COM.RPC_C_IMP_LEVEL_IMPERSONATE,
null,
COM.EOAC_NONE,
null,
) != 0) return null;
if (COM.CoCreateInstance(
WMI.CLSID_WbemLocator,
null,
COM.CLSCTX_INPROC_SERVER,
WMI.IID_IWbemLocator,
&pLoc,
) != 0) return null;
if (hres != 0) return null;
const IWbemLocator = @ptrCast(
?*WMI.IWbemLocator,
@alignCast(@alignOf(WMI.IWbemLocator), pLoc),
);
// Use the provided namespace if possible,
// otherwise, fallback to the default namespace for WMI objects.
const Namespace = self.utf8ToBSTR(namespace orelse "ROOT\\CIMV2") catch return null;
if (IWbemLocator.?.*.IWbemLocator_ConnectServer(
Namespace,
null,
null,
&n,
0,
&n,
null,
&pSvc,
) != 0) return null;
iwb_service = pSvc;
return pSvc;
}
/// Runs the provided query in the current namespace `ROOT\\CIMV2`
///
/// `search_query` - The full query string to execute.
/// `pSvcArg` - The `IWbemServices` instance. Provide null if you can't create one. By default, this calls `WMI.initialiseIWbemServices()`
///
/// Returns: A reference to an `IEnumWbemClassObject` if successful. Otherwise, `null`.
pub fn query(
self: @This(),
searchQuery: []const u8,
pSvcArg: ?*WMI.IWbemServices,
namespace: ?[]u8,
) ?*WMI.IEnumWbemClassObject {
var pEnumerator: ?*WMI.IEnumWbemClassObject = null;
var pSvc: ?*WMI.IWbemServices = pSvcArg orelse self.initialiseIWbemServices(namespace orelse null) orelse return null;
const WQL = self.utf8ToBSTR("WQL") catch return null;
const Query = self.utf8ToBSTR(searchQuery) catch return null;
defer Foundation.SysFreeString(WQL);
defer Foundation.SysFreeString(Query);
// `flag` here should have a value of 16
const flag = @enumToInt(WMI.WBEM_FLAG_RETURN_IMMEDIATELY);
const hres = pSvc.?.*.IWbemServices_ExecQuery(
WQL, // WQL = WMI Query Language
Query,
flag,
null,
&pEnumerator,
);
// In case the search wasn't successful,
// return null.
if (hres != 0) return null;
return pEnumerator;
}
/// Converts a "regular" UTF-8 string to a BSTR.
///
/// `str` - The string to convert.
///
/// Returns: A `BSTR` representation of the string.
pub fn utf8ToBSTR(
self: @This(),
str: []const u8,
) !?Foundation.BSTR {
const allocator = &gpa.allocator;
// Discarding reference to `self` so
// the compiler won't complain.
_ = self;
if (std.unicode.utf8ToUtf16LeWithNull(allocator, str)) |utf16_str| {
// Free the freshly allocated utf16_str after scope is finished.
defer allocator.free(utf16_str);
return Foundation.SysAllocString(utf16_str);
} else |err| return err;
}
}; | lib/core/wmi.zig |
const std = @import("std");
const testing = std.testing;
pub const Passport = struct {
seen: std.AutoHashMap(usize, void),
top: usize,
pub fn init() Passport {
const allocator = std.heap.page_allocator;
var self = Passport{
.seen = std.AutoHashMap(usize, void).init(allocator),
.top = 0,
};
return self;
}
pub fn deinit(self: *Passport) void {
self.seen.deinit();
}
pub fn parse(self: *Passport, line: []const u8) usize {
const row = self.parse_binary(line[0..7]);
const col = self.parse_binary(line[7..10]);
const id = row * 8 + col;
// std.debug.warn("LINE [{}] = {} * {} = {}\n", .{ line, row, col, id });
self.add(id);
if (self.top < id) self.top = id;
return id;
}
pub fn find_missing(self: *Passport) usize {
var candidate: usize = 1;
while (candidate <= self.top) : (candidate += 1) {
if (self.seen.contains(candidate)) {
continue;
}
if (!self.seen.contains(candidate + 1)) {
continue;
}
if (!self.seen.contains(candidate - 1)) {
continue;
}
return candidate;
}
return 0;
}
fn parse_binary(self: *Passport, str: []const u8) usize {
_ = self;
var value: usize = 0;
for (str) |c| {
value *= 2;
if (c == 'B' or c == 'R') {
value += 1;
}
}
return value;
}
fn add(self: *Passport, value: usize) void {
if (self.seen.contains(value)) {
return;
}
_ = self.seen.put(value, {}) catch unreachable;
}
};
test "sample no validation" {
const data: []const u8 =
\\FBFBBFFRLR 357
\\BFFFBBFRRR 567
\\FFFBBBFRRR 119
\\BBFFBBFRLL 820
;
var passport = Passport.init();
defer passport.deinit();
var it = std.mem.split(u8, data, "\n");
while (it.next()) |line| {
var itf = std.mem.tokenize(u8, line, " ");
const pstr = itf.next().?;
const istr = itf.next().?;
const expected = std.fmt.parseInt(usize, istr, 10) catch unreachable;
const id = passport.parse(pstr);
try testing.expect(id == expected);
}
} | 2020/p05/passport.zig |
const builtin = @import("builtin");
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const testing = std.testing;
/// Parses RedisBlobString values
pub const BlobStringParser = struct {
pub fn isSupported(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Int, .Float, .Array => true,
else => false,
};
}
pub fn parse(comptime T: type, comptime _: type, msg: anytype) !T {
var buf: [100]u8 = undefined;
var end: usize = 0;
for (buf) |*elem, i| {
const ch = try msg.readByte();
elem.* = ch;
if (ch == '\r') {
end = i;
break;
}
}
try msg.skipBytes(1, .{});
const size = try fmt.parseInt(usize, buf[0..end], 10);
switch (@typeInfo(T)) {
else => unreachable,
.Int => {
// Try to parse an int from the string.
// TODO: write real implementation
if (size > buf.len) return error.SorryBadImplementation;
try msg.readNoEof(buf[0..size]);
const res = try fmt.parseInt(T, buf[0..size], 10);
try msg.skipBytes(2, .{});
return res;
},
.Float => {
// Try to parse a float from the string.
// TODO: write real implementation
if (size > buf.len) return error.SorryBadImplementation;
try msg.readNoEof(buf[0..size]);
const res = try fmt.parseFloat(T, buf[0..size]);
try msg.skipBytes(2, .{});
return res;
},
.Array => |arr| {
var res: [arr.len]arr.child = undefined;
var bytesSlice = mem.sliceAsBytes(res[0..]);
if (bytesSlice.len != size) {
return error.LengthMismatch;
}
try msg.readNoEof(bytesSlice);
try msg.skipBytes(2, .{});
return res;
},
}
}
pub fn isSupportedAlloc(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Pointer => true,
else => isSupported(T),
};
}
pub fn parseAlloc(comptime T: type, comptime rootParser: type, allocator: *std.mem.Allocator, msg: anytype) !T {
// @compileLog(@typeInfo(T));
// std.debug.print("\n\nTYPE={}\n\n", .{@typeInfo(T)});
switch (@typeInfo(T)) {
.Pointer => |ptr| {
// TODO: write real implementation
var buf: [100]u8 = undefined;
var end: usize = 0;
for (buf) |*elem, i| {
const ch = try msg.readByte();
elem.* = ch;
if (ch == '\r') {
end = i;
break;
}
}
try msg.skipBytes(1, .{});
var size = try fmt.parseInt(usize, buf[0..end], 10);
if (ptr.size == .C) size += @sizeOf(ptr.child);
const elemSize = std.math.divExact(usize, size, @sizeOf(ptr.child)) catch return error.LengthMismatch;
var res = try allocator.alignedAlloc(ptr.child, @alignOf(T), elemSize);
errdefer allocator.free(res);
var bytes = mem.sliceAsBytes(res);
if (ptr.size == .C) {
msg.readNoEof(bytes[0 .. size - @sizeOf(ptr.child)]) catch return error.GraveProtocolError;
if (ptr.size == .C) {
// TODO: maybe reword this loop for better performance?
for (bytes[(size - @sizeOf(ptr.child))..]) |*b| b.* = 0;
}
} else {
msg.readNoEof(bytes[0..]) catch return error.GraveProtocolError;
}
try msg.skipBytes(2, .{});
return switch (ptr.size) {
.One, .Many => @compileError("Only Slices and C pointers should reach sub-parsers"),
.Slice => res,
.C => @ptrCast(T, res.ptr),
};
},
else => return parse(T, struct {}, msg),
}
}
};
test "string" {
{
testing.expect(1337 == try BlobStringParser.parse(u32, struct {}, MakeInt().inStream()));
testing.expectError(error.InvalidCharacter, BlobStringParser.parse(u32, struct {}, MakeString().inStream()));
testing.expect(1337.0 == try BlobStringParser.parse(f32, struct {}, MakeInt().inStream()));
testing.expect(12.34 == try BlobStringParser.parse(f64, struct {}, MakeFloat().inStream()));
testing.expectEqualSlices(u8, "Hello World!", &try BlobStringParser.parse([12]u8, struct {}, MakeString().inStream()));
const res = try BlobStringParser.parse([2][4]u8, struct {}, MakeEmoji2().inStream());
testing.expectEqualSlices(u8, "😈", &res[0]);
testing.expectEqualSlices(u8, "👿", &res[1]);
}
{
const allocator = std.heap.page_allocator;
{
const s = try BlobStringParser.parseAlloc([]u8, struct {}, allocator, MakeString().inStream());
defer allocator.free(s);
testing.expectEqualSlices(u8, s, "Hello World!");
}
{
const s = try BlobStringParser.parseAlloc([*c]u8, struct {}, allocator, MakeString().inStream());
defer allocator.free(s[0..12]);
testing.expectEqualSlices(u8, s[0..13], "Hello World!\x00");
}
{
const s = try BlobStringParser.parseAlloc([][4]u8, struct {}, allocator, MakeEmoji2().inStream());
defer allocator.free(s);
testing.expectEqualSlices(u8, "😈", &s[0]);
testing.expectEqualSlices(u8, "👿", &s[1]);
}
{
const s = try BlobStringParser.parseAlloc([*c][4]u8, struct {}, allocator, MakeEmoji2().inStream());
defer allocator.free(s[0..3]);
testing.expectEqualSlices(u8, "😈", &s[0]);
testing.expectEqualSlices(u8, "👿", &s[1]);
testing.expectEqualSlices(u8, &[4]u8{ 0, 0, 0, 0 }, &s[3]);
}
{
testing.expectError(error.LengthMismatch, BlobStringParser.parseAlloc([][5]u8, struct {}, allocator, MakeString().inStream()));
}
}
}
fn MakeEmoji2() std.io.FixedBufferStream([]const u8) {
return std.io.fixedBufferStream("$8\r\n😈👿\r\n"[1..]);
}
fn MakeString() std.io.FixedBufferStream([]const u8) {
return std.io.fixedBufferStream("$12\r\nHello World!\r\n"[1..]);
}
fn MakeInt() std.io.FixedBufferStream([]const u8) {
return std.io.fixedBufferStream("$4\r\n1337\r\n"[1..]);
}
fn MakeFloat() std.io.FixedBufferStream([]const u8) {
return std.io.fixedBufferStream("$5\r\n12.34\r\n"[1..]);
} | src/parser/t_string_blob.zig |
const std = @import("std");
const tools = @import("tools");
const with_trace = false;
const assert = std.debug.assert;
fn trace(comptime fmt: []const u8, args: anytype) void {
if (with_trace) std.debug.print(fmt, args);
}
pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 {
var input_alloc: []u4 = try allocator.alloc(u4, input.len);
defer allocator.free(input_alloc);
const input_signal = blk: {
var len: u32 = 0;
for (std.mem.trim(u8, input, " \n\r\t")) |c| {
input_alloc[len] = @intCast(u4, c - '0');
len += 1;
}
break :blk input_alloc[0..len];
};
var answer1: [8]u8 = undefined;
{
const signals = [2][]u4{ try allocator.alloc(u4, input_signal.len), try allocator.alloc(u4, input_signal.len) };
defer {
for (signals) |s| {
allocator.free(s);
}
}
std.mem.copy(u4, signals[0], input_signal);
var phase: u32 = 0;
while (phase < 100) : (phase += 1) {
const in: []const u4 = signals[phase % 2];
const out: []u4 = signals[1 - (phase % 2)];
for (out) |*sample_out, index_out| {
var sum: i32 = 0;
for (in) |sample_in, index_in| {
const pattern_values = [_]i32{ 0, 1, 0, -1 };
const index_pattern = ((index_in + 1) / (index_out + 1)) % 4;
const pattern = pattern_values[index_pattern];
trace("{}*{}, ", .{ sample_in, pattern });
sum += @as(i32, sample_in) * pattern;
}
trace("{}\n", .{sum});
sample_out.* = @intCast(u4, if (sum >= 0) @intCast(u32, sum) % 10 else @intCast(u32, -sum) % 10);
}
for (out) |sample_out, i| {
if (i >= answer1.len) break;
answer1[i] = '0' + @intCast(u8, sample_out);
}
}
}
var answer2: [8]u8 = undefined;
{
const repeats = 10000;
const signals = [2][]u4{ try allocator.alloc(u4, input_signal.len * repeats), try allocator.alloc(u4, input_signal.len * repeats) };
defer {
for (signals) |s| {
allocator.free(s);
}
}
var repeat: u32 = 0;
while (repeat < repeats) : (repeat += 1) {
std.mem.copy(u4, signals[0][repeat * input_signal.len .. (repeat + 1) * input_signal.len], input_signal);
}
const offset = 5976277;
assert(offset > signals[0].len / 2); // du coup, le pattern se resume à que des uns.. super. c'est naze.
var phase: u32 = 0;
while (phase < 100) : (phase += 1) {
const in: []const u4 = signals[phase % 2];
const out: []u4 = signals[1 - (phase % 2)];
var sum: i32 = 0;
var index_out: usize = out.len - 1;
while (index_out >= offset) : (index_out -= 1) {
const sample_in = in[index_out];
const pattern = 1;
sum += @as(i32, sample_in) * pattern;
out[index_out] = @intCast(u4, if (sum >= 0) @intCast(u32, sum) % 10 else @intCast(u32, -sum) % 10);
}
for (out[offset .. offset + 8]) |sample_out, i| {
if (i >= answer2.len) break;
answer2[i] = '0' + @intCast(u8, sample_out);
}
}
}
return [_][]const u8{
try std.fmt.allocPrint(allocator, "{s}", .{answer2}),
try std.fmt.allocPrint(allocator, "{s}", .{answer1}),
};
}
pub const main = tools.defaultMain("2019/day16.txt", run); | 2019/day16.zig |
const std = @import("std");
pub const CreateFlags = packed struct {
antialias: bool = false,
stencil_strokes: bool = false,
debug: bool = false,
fn toCInt(self: CreateFlags) c_int {
return @bitCast(std.meta.Int(.unsigned, @bitSizeOf(CreateFlags)), self);
}
};
pub const Color = extern struct {
r: f32,
g: f32,
b: f32,
a: f32,
pub fn hex(rgba_hex: u32) Color {
var c: [4]u8 = undefined;
std.mem.writeIntBig(u32, &c, rgba_hex);
return rgba(c[0], c[1], c[2], c[3]);
}
pub fn rgba(r: u8, g: u8, b: u8, a: u8) Color {
return .{
.r = @intToFloat(f32, r) / 0xff,
.g = @intToFloat(f32, g) / 0xff,
.b = @intToFloat(f32, b) / 0xff,
.a = @intToFloat(f32, a) / 0xff,
};
}
pub fn rgbaf(r: f32, g: f32, b: f32, a: f32) Color {
return .{ .r = r, .g = g, .b = b, .a = a };
}
const hsla = nvgHSLA;
extern fn nvgHSLA(h: f32, s: f32, l: f32, a: u8) Color;
};
pub const Paint = extern struct {
xform: [6]f32,
extent: [2]f32,
radius: f32,
feather: f32,
inner_color: Color,
outer_color: Color,
image: Image,
};
pub const Winding = enum(c_int) {
ccw = 1,
cw = 2,
};
pub const Solidity = enum(c_int) {
solid = 1,
hole = 2,
};
pub const LineCap = enum(c_int) {
butt,
round,
square,
bevel,
miter,
};
pub const Align = struct {
h: Horizontal = .left,
v: Vertical = .baseline,
pub const Horizontal = enum { left, center, right };
pub const Vertical = enum { top, middle, bottom, baseline };
fn toCInt(self: Align) c_int {
const h = @as(c_int, 1) << @enumToInt(self.h);
const v = @as(c_int, 1) << @enumToInt(self.v);
return h | (v << 3);
}
};
pub const BlendFactor = enum(c_int) {
zero = 1 << 0,
one = 1 << 1,
src_color = 1 << 2,
one_minus_src_color = 1 << 3,
dst_color = 1 << 4,
one_minus_dst_color = 1 << 5,
src_alpha = 1 << 6,
one_minus_src_alpha = 1 << 7,
dst_alpha = 1 << 8,
one_minus_dst_alpha = 1 << 9,
src_alpha_saturate = 1 << 10,
};
pub const CompositeOperation = enum(c_int) {
source_over,
source_in,
source_out,
atop,
destination_over,
destination_in,
destination_out,
destination_atop,
lighter,
copy,
xor,
};
pub const CompositeOperationState = extern struct {
src_rgb: c_int,
dst_rgb: c_int,
src_alpha: c_int,
dst_alpha: c_int,
};
pub const Font = enum(c_int) { _ };
pub const GlyphPosition = extern struct {
str: *const u8,
x: f32,
min_x: f32,
max_x: f32,
};
pub const TextRow = extern struct {
start: [*]const u8,
end: [*]const u8,
next: [*]const u8,
width: f32,
min_x: f32,
max_x: f32,
};
pub const TextMetrics = struct {
ascender: f32,
descender: f32,
line_height: f32,
};
pub const Image = enum(c_int) { _ };
pub const ImageFlags = packed struct {
generate_mipmaps: bool = false,
repeat_x: bool = false,
repeat_y: bool = false,
flip_y: bool = false,
premultiplied: bool = false,
nearest: bool = false,
fn toCInt(self: ImageFlags) c_int {
return @bitCast(std.meta.Int(.Unsigned, @bitSizeOf(ImageFlags)), self);
}
};
pub const Context = opaque {
pub fn createGl2(flags: CreateFlags) *Context {
return nvgCreateGL2(flags.toCInt());
}
pub fn createGl3(flags: CreateFlags) *Context {
return nvgCreateGL3(flags.toCInt());
}
pub fn createGles2(flags: CreateFlags) *Context {
return nvgCreateGLES2(flags.toCInt());
}
pub fn createGles3(flags: CreateFlags) *Context {
return nvgCreateGLES3(flags.toCInt());
}
extern fn nvgCreateGL2(flags: c_int) *Context;
extern fn nvgCreateGL3(flags: c_int) *Context;
extern fn nvgCreateGLES2(flags: c_int) *Context;
extern fn nvgCreateGLES3(flags: c_int) *Context;
pub const deleteGl2 = nvgDeleteGL2;
pub const deleteGl3 = nvgDeleteGL3;
pub const deleteGles2 = nvgDeleteGLES2;
pub const deleteGles3 = nvgDeleteGLES3;
extern fn nvgDeleteGL2(self: *Context) void;
extern fn nvgDeleteGL3(self: *Context) void;
extern fn nvgDeleteGLES2(self: *Context) void;
extern fn nvgDeleteGLES3(self: *Context) void;
pub const beginFrame = nvgBeginFrame;
pub const cancelFrame = nvgCancelFrame;
pub const endFrame = nvgEndFrame;
extern fn nvgBeginFrame(self: *Context, win_width: f32, win_height: f32, dev_pixel_ratio: f32) void;
extern fn nvgCancelFrame(self: *Context) void;
extern fn nvgEndFrame(self: *Context) void;
pub const globalCompositeOperation = nvgGlobalCompositeOperation;
pub const globalCompositeBlendFunc = nvgGlobalCompositeBlendFunc;
pub const globalCompositeBlendFuncSeparate = nvgGlobalCompositeBlendFuncSeparate;
extern fn nvgGlobalCompositeOperation(self: *Context, op: CompositeOperation) void;
extern fn nvgGlobalCompositeBlendFunc(self: *Context, src: BlendFactor, dst: BlendFactor) void;
extern fn nvgGlobalCompositeBlendFuncSeparate(
self: *Context,
src_rgb: BlendFactor,
dst_rgb: BlendFactor,
src_alpha: BlendFactor,
dst_alpha: BlendFactor,
) void;
pub const save = nvgSave;
pub const restore = nvgRestore;
pub const reset = nvgReset;
extern fn nvgSave(self: *Context) void;
extern fn nvgRestore(self: *Context) void;
extern fn nvgReset(self: *Context) void;
pub fn shapeAntiAlias(self: *Context, enabled: bool) void {
self.nvgShapeAntiAlias(@boolToInt(enabled));
}
extern fn nvgShapeAntiAlias(self: *Context, enabled: c_int) void;
pub const strokeColor = nvgStrokeColor;
pub const strokePaint = nvgStrokePaint;
pub const fillColor = nvgFillColor;
pub const fillPaint = nvgFillPaint;
pub const miterLimit = nvgMiterLimit;
pub const strokeWidth = nvgStrokeWidth;
pub const lineCap = nvgLineCap;
pub const lineJoin = nvgLineJoin;
pub const globalAlpha = nvgGlobalAlpha;
extern fn nvgStrokeColor(self: *Context, color: Color) void;
extern fn nvgStrokePaint(self: *Context, paint: Paint) void;
extern fn nvgFillColor(self: *Context, color: Color) void;
extern fn nvgFillPaint(self: *Context, paint: Paint) void;
extern fn nvgMiterLimit(self: *Context, limit: f32) void;
extern fn nvgStrokeWidth(self: *Context, size: f32) void;
extern fn nvgLineCap(self: *Context, cap: LineCap) void;
extern fn nvgLineJoin(self: *Context, join: LineCap) void;
extern fn nvgGlobalAlpha(self: *Context, alpha: f32) void;
const resetTransform = nvgResetTransform;
const transform = nvgTransform;
const translate = nvgTranslate;
const rotate = nvgRotate;
const skewX = nvgSkewX;
const skewY = nvgSkewY;
const scale = nvgScale;
extern fn nvgResetTransform(self: *Context) void;
extern fn nvgTransform(self: *Context, a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) void;
extern fn nvgTranslate(self: *Context, x: f32, y: f32) void;
extern fn nvgRotate(self: *Context, angle: f32) void;
extern fn nvgSkewX(self: *Context, angle: f32) void;
extern fn nvgSkewY(self: *Context, angle: f32) void;
extern fn nvgScale(self: *Context, x: f32, y: f32) void;
pub fn currentTransform(self: *Context) [6]f32 {
var xform: [6]f32 = undefined;
self.nvgCurrentTransform(&xform);
return xform;
}
extern fn nvgCurrentTransform(self: *Context, xform: *[6]f32) void;
pub fn createImage(self: *Context, filename: [*:0]const u8, flags: ImageFlags) Image {
return self.nvgCreateImage(filename, flags.toCInt());
}
extern fn nvgCreateImage(self: *Context, filename: [*:0]const u8, flags: c_int) Image;
pub fn createImageMem(self: *Context, flags: ImageFlags, data: []const u8) Image {
return self.nvgCreateImageMem(flags.toCInt(), data.ptr, @intCast(c_int, data.len));
}
extern fn nvgCreateImageMem(self: *Context, flags: c_int, data: [*]const u8, len: c_int) Image;
pub fn createImageRgba(self: *Context, w: u32, h: u32, flags: ImageFlags, data: []const u8) Image {
std.debug.assert(data.len == w * h * 4);
return self.nvgCreateImageRGBA(@intCast(c_int, w), @intCast(c_int, h), flags.toCInt(), data.ptr);
}
extern fn nvgCreateImageRGBA(self: *Context, w: c_int, h: c_int, flags: c_int, data: [*]const u8) Image;
pub fn updateImage(self: *Context, img: Image, data: []const u8) void {
const size = self.imageSize(img);
std.debug.assert(data.len == size[0] * size[1] * 4);
self.nvgUpdateImage(img, data.ptr);
}
extern fn nvgUpdateImage(self: *Context, img: Image, data: [*]const u8) void;
pub fn imageSize(self: *Context, img: Image) [2]u32 {
var w: c_int = undefined;
var h: c_int = undefined;
self.nvgImageSize(img, &w, &h);
return .{ @intCast(u32, w), @intCast(u32, h) };
}
extern fn nvgImageSize(self: *Context, img: Image, w: *c_int, h: *c_int) void;
pub const deleteImage = nvgDeleteImage;
extern fn nvgDeleteImage(self: *Context, img: Image) void;
pub const linearGradient = nvgLinearGradient;
pub const boxGradient = nvgBoxGradient;
pub const radialGradient = nvgRadialGradient;
pub const imagePattern = nvgImagePattern;
extern fn nvgLinearGradient(
self: *Context,
sx: f32,
sy: f32,
ex: f32,
ey: f32,
icol: Color,
ocol: Color,
) Paint;
extern fn nvgBoxGradient(
self: *Context,
x: f32,
y: f32,
w: f32,
h: f32,
r: f32,
f: f32,
icol: Color,
ocol: Color,
) Paint;
extern fn nvgRadialGradient(
self: *Context,
cx: f32,
cy: f32,
inr: f32,
outr: f32,
icol: Color,
ocol: Color,
) Paint;
extern fn nvgImagePattern(
self: *Context,
ox: f32,
oy: f32,
ex: f32,
ey: f32,
angle: f32,
image: c_int,
alpha: f32,
) Paint;
pub const scissor = nvgScissor;
pub const intersectScissor = nvgIntersectScissor;
pub const resetScissor = nvgResetScissor;
extern fn nvgScissor(self: *Context, x: f32, y: f32, w: f32, h: f32) void;
extern fn nvgIntersectScissor(self: *Context, x: f32, y: f32, w: f32, h: f32) void;
extern fn nvgResetScissor(self: *Context) void;
pub const beginPath = nvgBeginPath;
pub const moveTo = nvgMoveTo;
pub const lineTo = nvgLineTo;
pub const bezierTo = nvgBezierTo;
pub const quadTo = nvgQuadTo;
pub const arcTo = nvgArcTo;
pub const closePath = nvgClosePath;
pub const pathWinding = nvgPathWinding;
pub const arc = nvgArc;
extern fn nvgBeginPath(self: *Context) void;
extern fn nvgMoveTo(self: *Context, x: f32, y: f32) void;
extern fn nvgLineTo(self: *Context, x: f32, y: f32) void;
extern fn nvgBezierTo(self: *Context, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32) void;
extern fn nvgQuadTo(self: *Context, cx: f32, cy: f32, x: f32, y: f32) void;
extern fn nvgArcTo(self: *Context, x1: f32, y1: f32, x2: f32, y2: f32, radius: f32) void;
extern fn nvgClosePath(self: *Context) void;
extern fn nvgPathWinding(self: *Context, dir: Winding) void;
extern fn nvgArc(self: *Context, cx: f32, cy: f32, r: f32, a0: f32, a1: f32, dir: Winding) void;
pub fn barc(self: *Context, cx: f32, cy: f32, r: f32, a0: f32, a1: f32, dir: Winding, join: bool) void {
self.nvgBarc(cx, cy, r, a0, a1, dir, @boolToInt(join));
}
extern fn nvgBarc(self: *Context, cx: f32, cy: f32, r: f32, a0: f32, a1: f32, dir: Winding, join: c_int) void;
pub const rect = nvgRect;
pub const roundedRect = nvgRoundedRect;
pub const roundedRectVarying = nvgRoundedRectVarying;
pub const ellipse = nvgEllipse;
pub const circle = nvgCircle;
pub const fill = nvgFill;
pub const stroke = nvgStroke;
extern fn nvgRect(self: *Context, x: f32, y: f32, w: f32, h: f32) void;
extern fn nvgRoundedRect(self: *Context, x: f32, y: f32, w: f32, h: f32, r: f32) void;
extern fn nvgRoundedRectVarying(
self: *Context,
x: f32,
y: f32,
w: f32,
h: f32,
rad_top_left: f32,
rad_top_right: f32,
rad_bottom_right: f32,
rad_bottom_left: f32,
) void;
extern fn nvgEllipse(self: *Context, cx: f32, cy: f32, rx: f32, ry: f32) void;
extern fn nvgCircle(self: *Context, cx: f32, cy: f32, r: f32) void;
extern fn nvgFill(self: *Context) void;
extern fn nvgStroke(self: *Context) void;
pub const createFont = nvgCreateFont;
pub const createFontAtIndex = nvgCreateFontAtIndex;
extern fn nvgCreateFont(self: *Context, name: [*:0]const u8, filename: [*:0]const u8) Font;
extern fn nvgCreateFontAtIndex(
self: *Context,
name: [*:0]const u8,
filename: [*:0]const u8,
font_index: c_int,
) Font;
pub fn createFontMem(
self: *Context,
name: [*:0]const u8,
data: []const u8,
free_data: bool,
) Font {
return self.nvgCreateFontMem(name, data.ptr, @intCast(c_int, data.len), @boolToInt(free_data));
}
extern fn nvgCreateFontMem(
self: *Context,
name: [*:0]const u8,
data: [*]const u8,
ndata: c_int,
free_data: c_int,
) Font;
pub fn createFontMemAtIndex(
self: *Context,
name: [*:0]const u8,
data: []const u8,
free_data: bool,
font_index: c_int,
) Font {
return self.nvgCreateFontMem(
name,
data.ptr,
@intCast(c_int, data.len),
@boolToInt(free_data),
font_index,
);
}
extern fn nvgCreateFontMemAtIndex(
self: *Context,
name: [*:0]const u8,
data: [*]const u8,
ndata: c_int,
free_data: c_int,
font_index: c_int,
) Font;
pub const findFont = nvgFindFont;
pub const addFallbackFontId = nvgAddFallbackFontId;
pub const addFallbackFont = nvgAddFallbackFont;
pub const resetFallbackFontsId = nvgResetFallbackFontsId;
pub const resetFallbackFonts = nvgResetFallbackFonts;
extern fn nvgFindFont(self: *Context, name: [*:0]const u8) Font;
extern fn nvgAddFallbackFontId(self: *Context, base: Font, fallback: Font) Font;
extern fn nvgAddFallbackFont(self: *Context, base: [*:0]const u8, fallback: [*:0]const u8) Font;
extern fn nvgResetFallbackFontsId(self: *Context, base: Font) void;
extern fn nvgResetFallbackFonts(self: *Context, base: [*:0]const u8) void;
pub const fontSize = nvgFontSize;
pub const fontBlur = nvgFontBlur;
pub const textLetterSpacing = nvgTextLetterSpacing;
pub const textLineHeight = nvgTextLineHeight;
extern fn nvgFontSize(self: *Context, size: f32) void;
extern fn nvgFontBlur(self: *Context, blur: f32) void;
extern fn nvgTextLetterSpacing(self: *Context, spacing: f32) void;
extern fn nvgTextLineHeight(self: *Context, lineHeight: f32) void;
pub fn textAlign(self: *Context, text_align: Align) void {
return self.nvgTextAlign(text_align.toCInt());
}
extern fn nvgTextAlign(self: *Context, text_align: c_int) void;
pub const fontFaceId = nvgFontFaceId;
pub const fontFace = nvgFontFace;
extern fn nvgFontFaceId(self: *Context, font: Font) void;
extern fn nvgFontFace(self: *Context, font: [*:0]const u8) void;
pub fn text(self: *Context, x: f32, y: f32, string: []const u8) f32 {
return self.nvgText(x, y, string.ptr, string[string.len..].ptr);
}
extern fn nvgText(self: *Context, x: f32, y: f32, string: [*]const u8, end: [*]const u8) f32;
pub fn textBox(self: *Context, x: f32, y: f32, wrap_width: f32, string: []const u8) void {
self.nvgTextBox(x, y, wrap_width, string.ptr, string[string.len..].ptr);
}
extern fn nvgTextBox(
self: *Context,
x: f32,
y: f32,
wrap_width: f32,
string: [*]const u8,
end: [*]const u8,
) void;
pub fn textBounds(
self: *Context,
x: f32,
y: f32,
string: []const u8,
bounds: *[4]f32,
) f32 {
self.nvgTextBounds(x, y, string.ptr, string[string.len..].ptr, bounds);
}
extern fn nvgTextBounds(
self: *Context,
x: f32,
y: f32,
string: [*]const u8,
end: [*]const u8,
bounds: *[4]f32,
) f32;
pub fn textBoxBounds(
self: *Context,
x: f32,
y: f32,
wrap_width: f32,
string: []const u8,
bounds: *[4]f32,
) f32 {
self.nvgTextBoxBounds(x, y, wrap_width, string.ptr, string[string.len..].ptr, bounds);
}
extern fn nvgTextBoxBounds(
self: *Context,
x: f32,
y: f32,
wrap_width: f32,
string: [*]const u8,
end: [*]const u8,
bounds: *f32,
) void;
pub fn textGlyphPositions(
self: *Context,
x: f32,
y: f32,
string: []const u8,
positions: []GlyphPosition,
) usize {
return @intCast(usize, self.nvgTextGlyphPositions(
x,
y,
string.ptr,
string[string.len..].ptr,
positions.ptr,
@intCast(c_int, positions.len),
));
}
extern fn nvgTextGlyphPositions(
self: *Context,
x: f32,
y: f32,
string: [*]const u8,
end: [*]const u8,
positions: [*]GlyphPosition,
max_positions: c_int,
) c_int;
pub fn textMetrics(self: *Context) TextMetrics {
var metrics: TextMetrics = undefined;
self.nvgTextMetrics(&metrics.ascender, &metrics.descender, &metrics.line_height);
return metrics;
}
extern fn nvgTextMetrics(
self: *Context,
ascender: *f32,
descender: *f32,
lineh: *f32,
) void;
pub fn textBreakLines(self: *Context, string: []const u8, wrap_width: f32, rows: []TextRow) usize {
return @intCast(usize, self.nvgTextBreakLines(
string.ptr,
string[string.len..].ptr,
wrap_width,
rows.ptr,
@intCast(c_int, rows.len),
));
}
extern fn nvgTextBreakLines(
self: *Context,
string: [*]const u8,
end: [*]const u8,
wrap_width: f32,
rows: [*]TextRow,
max_rows: c_int,
) c_int;
};
// TODO: wrap nvgTransform*, nvgDegToRad, nvgRadToDeg
// TODO: wrap nvglImage[From]Handle* | nanovg.zig |
const std = @import("std");
const testing = std.testing;
const math = std.math;
const utils = @import("utils.zig");
const Vec2 = @import("vec2.zig").Vec2;
const Mat4 = @import("mat4.zig").Mat4;
/// A Mat3 identity matrix
pub const mat3_identity = Mat3{
.data = .{
.{ 1, 0, 0 },
.{ 0, 1, 0 },
.{ 0, 0, 1 },
},
};
pub const Mat3 = struct {
data: [3][3]f32,
pub const identity = mat3_identity;
pub fn create(m00: f32, m01: f32, m02: f32, m10: f32, m11: f32, m12: f32, m20: f32, m21: f32, m22: f32) Mat3 {
return Mat3{
.data = .{
.{ m00, m01, m02 },
.{ m10, m11, m12 },
.{ m20, m21, m22 },
},
};
}
pub fn fromMat4(m: Mat4) Mat3 {
return Mat3{
.data = .{
.{ m.data[0][0], m.data[0][1], m.data[0][2] },
.{ m.data[1][0], m.data[1][1], m.data[1][2] },
.{ m.data[2][0], m.data[2][1], m.data[2][2] },
},
};
}
pub fn transpose(m: Mat3) Mat3 {
return Mat3{
.data = .{
.{ m.data[0][0], m.data[1][0], m.data[2][0] },
.{ m.data[0][1], m.data[1][1], m.data[2][1] },
.{ m.data[0][2], m.data[1][2], m.data[2][2] },
},
};
}
test "transpose" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const out = matA.transpose();
const expected = Mat3.create( //
1, 0, 1, //
0, 1, 2, //
0, 0, 1);
try expectEqual(expected, out);
}
/// Inverts the matrix
pub fn invert(m: Mat3) ?Mat3 {
const b01 = m.data[2][2] * m.data[1][1] - m.data[1][2] * m.data[2][1];
const b11 = -m.data[2][2] * m.data[1][0] + m.data[1][2] * m.data[2][0];
const b21 = m.data[2][1] * m.data[1][0] - m.data[1][1] * m.data[2][0];
// Calculate the determinant
var det = m.data[0][0] * b01 + m.data[0][1] * b11 + m.data[0][2] * b21;
if (det == 0) {
return null;
}
det = 1 / det;
return Mat3{
.data = .{
.{
b01 * det,
(-m.data[2][2] * m.data[0][1] + m.data[0][2] * m.data[2][1]) * det,
(m.data[1][2] * m.data[0][1] - m.data[0][2] * m.data[1][1]) * det,
},
.{
b11 * det,
(m.data[2][2] * m.data[0][0] - m.data[0][2] * m.data[2][0]) * det,
(-m.data[1][2] * m.data[0][0] + m.data[0][2] * m.data[1][0]) * det,
},
.{
b21 * det,
(-m.data[2][1] * m.data[0][0] + m.data[0][1] * m.data[2][0]) * det,
(m.data[1][1] * m.data[0][0] - m.data[0][1] * m.data[1][0]) * det,
},
},
};
}
test "invert" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const out = matA.invert() orelse @panic("test failed");
const expected = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
-1, -2, 1);
try expectEqual(expected, out);
}
/// Calculates the adjugate
pub fn adjoint(m: Mat3) Mat3 {
return Mat3{
.data = .{
.{
(m.data[1][1] * m.data[2][2] - m.data[1][2] * m.data[2][1]),
(m.data[0][2] * m.data[2][1] - m.data[0][1] * m.data[2][2]),
(m.data[0][1] * m.data[1][2] - m.data[0][2] * m.data[1][1]),
},
.{
(m.data[1][2] * m.data[2][0] - m.data[1][0] * m.data[2][2]),
(m.data[0][0] * m.data[2][2] - m.data[0][2] * m.data[2][0]),
(m.data[0][2] * m.data[1][0] - m.data[0][0] * m.data[1][2]),
},
.{
(m.data[1][0] * m.data[2][1] - m.data[1][1] * m.data[2][0]),
(m.data[0][1] * m.data[2][0] - m.data[0][0] * m.data[2][1]),
(m.data[0][0] * m.data[1][1] - m.data[0][1] * m.data[1][0]),
},
},
};
}
test "adjoint" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const out = matA.adjoint();
const expected = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
-1, -2, 1);
try expectEqual(expected, out);
}
///Calculates the determinant
pub fn determinant(m: Mat3) f32 {
return m.data[0][0] * (m.data[2][2] * m.data[1][1] - m.data[1][2] * m.data[2][1]) //
+ m.data[0][1] * (-m.data[2][2] * m.data[1][0] + m.data[1][2] * m.data[2][0]) //
+ m.data[0][2] * (m.data[2][1] * m.data[1][0] - m.data[1][1] * m.data[2][0]);
}
test "determinant" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const out = matA.determinant();
try testing.expectEqual(out, 1);
}
pub fn add(a: Mat3, b: Mat3) Mat3 {
return Mat3{
.data = .{
.{
a.data[0][0] + b.data[0][0],
a.data[0][1] + b.data[0][1],
a.data[0][2] + b.data[0][2],
},
.{
a.data[1][0] + b.data[1][0],
a.data[1][1] + b.data[1][1],
a.data[1][2] + b.data[1][2],
},
.{
a.data[2][0] + b.data[2][0],
a.data[2][1] + b.data[2][1],
a.data[2][2] + b.data[2][2],
},
},
};
}
test "add" {
const matA = Mat3.create(1, 2, 3, 4, 5, 6, 7, 8, 9);
const matB = Mat3.create(10, 11, 12, 13, 14, 15, 16, 17, 18);
const out = Mat3.add(matA, matB);
const expected = Mat3.create( //
11, 13, 15, //
17, 19, 21, //
23, 25, 27);
try expectEqual(expected, out);
}
pub fn subtract(a: Mat3, b: Mat3) Mat3 {
return Mat3{
.data = .{
.{
a.data[0][0] - b.data[0][0],
a.data[0][1] - b.data[0][1],
a.data[0][2] - b.data[0][2],
},
.{
a.data[1][0] - b.data[1][0],
a.data[1][1] - b.data[1][1],
a.data[1][2] - b.data[1][2],
},
.{
a.data[2][0] - b.data[2][0],
a.data[2][1] - b.data[2][1],
a.data[2][2] - b.data[2][2],
},
},
};
}
pub const sub = subtract;
test "substract" {
const matA = Mat3.create(1, 2, 3, 4, 5, 6, 7, 8, 9);
const matB = Mat3.create(10, 11, 12, 13, 14, 15, 16, 17, 18);
const out = Mat3.sub(matA, matB);
const expected = Mat3.create( //
-9, -9, -9, //
-9, -9, -9, //
-9, -9, -9);
try expectEqual(expected, out);
}
///Multiplies two Mat3
pub fn multiply(a: Mat3, b: Mat3) Mat3 {
return Mat3{
.data = .{
.{
b.data[0][0] * a.data[0][0] + b.data[0][1] * a.data[1][0] + b.data[0][2] * a.data[2][0],
b.data[0][0] * a.data[0][1] + b.data[0][1] * a.data[1][1] + b.data[0][2] * a.data[2][1],
b.data[0][0] * a.data[0][2] + b.data[0][1] * a.data[1][2] + b.data[0][2] * a.data[2][2],
},
.{
b.data[1][0] * a.data[0][0] + b.data[1][1] * a.data[1][0] + b.data[1][2] * a.data[2][0],
b.data[1][0] * a.data[0][1] + b.data[1][1] * a.data[1][1] + b.data[1][2] * a.data[2][1],
b.data[1][0] * a.data[0][2] + b.data[1][1] * a.data[1][2] + b.data[1][2] * a.data[2][2],
},
.{
b.data[2][0] * a.data[0][0] + b.data[2][1] * a.data[1][0] + b.data[2][2] * a.data[2][0],
b.data[2][0] * a.data[0][1] + b.data[2][1] * a.data[1][1] + b.data[2][2] * a.data[2][1],
b.data[2][0] * a.data[0][2] + b.data[2][1] * a.data[1][2] + b.data[2][2] * a.data[2][2],
},
},
};
}
pub const mul = multiply;
test "multiply" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const matB = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
3, 4, 1);
const out = Mat3.mul(matA, matB);
const expected = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
4, 6, 1);
try expectEqual(expected, out);
}
pub fn multiplyScalar(a: Mat3, s: f32) Mat3 {
return Mat3{
.data = .{
.{
a.data[0][0] * s,
a.data[0][1] * s,
a.data[0][2] * s,
},
.{
a.data[1][0] * s,
a.data[1][1] * s,
a.data[1][2] * s,
},
.{
a.data[2][0] * s,
a.data[2][1] * s,
a.data[2][2] * s,
},
},
};
}
test "multiplyScalar" {
const matA = Mat3.create( //
1, 2, 3, //
4, 5, 6, //
7, 8, 9);
const out = matA.multiplyScalar(2);
const expected = Mat3.create( //
2, 4, 6, //
8, 10, 12, //
14, 16, 18);
try expectEqual(expected, out);
}
pub fn multiplyScalarAndAdd(a: Mat3, b: Mat3, s: f32) Mat3 {
return Mat3{
.data = .{
.{
@mulAdd(f32, b.data[0][0], s, a.data[0][0]),
@mulAdd(f32, b.data[0][1], s, a.data[0][1]),
@mulAdd(f32, b.data[0][2], s, a.data[0][2]),
},
.{
@mulAdd(f32, b.data[1][0], s, a.data[1][0]),
@mulAdd(f32, b.data[1][1], s, a.data[1][1]),
@mulAdd(f32, b.data[1][2], s, a.data[1][2]),
},
.{
@mulAdd(f32, b.data[2][0], s, a.data[2][0]),
@mulAdd(f32, b.data[2][1], s, a.data[2][1]),
@mulAdd(f32, b.data[2][2], s, a.data[2][2]),
},
},
};
}
test "multiplyScalarAndAdd" {
const matA = Mat3.create(1, 2, 3, 4, 5, 6, 7, 8, 9);
const matB = Mat3.create(10, 11, 12, 13, 14, 15, 16, 17, 18);
const out = Mat3.multiplyScalarAndAdd(matA, matB, 0.5);
const expected = Mat3.create(6, 7.5, 9, 10.5, 12, 13.5, 15, 16.5, 18);
try expectEqual(expected, out);
}
pub fn translate(a: Mat3, b: Vec2) Mat3 {
return Mat3{
.data = .{
.{
a.data[0][0],
a.data[0][1],
a.data[0][2],
},
.{
a.data[1][0],
a.data[1][1],
a.data[1][2],
},
.{
b.data[0] * a.data[0][0] + b.data[1] * a.data[1][0] + a.data[2][0],
b.data[0] * a.data[0][1] + b.data[1] * a.data[1][1] + a.data[2][1],
b.data[0] * a.data[0][2] + b.data[1] * a.data[1][2] + a.data[2][2],
},
},
};
}
pub fn rotate(a: Mat3, rad: f32) Mat3 {
const s = @sin(rad);
const c = @cos(rad);
return Mat3{
.data = .{
.{
c * a.data[0][0] + s * a.data[1][0],
c * a.data[0][1] + s * a.data[1][1],
c * a.data[0][2] + s * a.data[1][2],
},
.{
c * a.data[1][0] - s * a.data[0][0],
c * a.data[1][1] - s * a.data[0][1],
c * a.data[1][2] - s * a.data[0][2],
},
.{
a.data[2][0],
a.data[2][1],
a.data[2][2],
},
},
};
}
pub fn scale(a: Mat3, v: Vec2) Mat3 {
return Mat3{
.data = .{
.{
v.x * a.data[0][0],
v.x * a.data[0][1],
v.x * a.data[0][2],
},
.{
v.y * a.data[1][0],
v.y * a.data[1][1],
v.y * a.data[1][2],
},
.{
a.data[2][0],
a.data[2][1],
a.data[2][2],
},
},
};
}
test "scale" {
const matA = Mat3.create( //
1, 0, 0, //
0, 1, 0, //
1, 2, 1);
const out = matA.scale(Vec2.create(2, 2));
const expected = Mat3.create( //
2, 0, 0, //
0, 2, 0, //
1, 2, 1);
try expectEqual(expected, out);
}
pub fn fromTranslation(v: Vec2) Mat3 {
const x = v.data[0];
const y = v.data[1];
return Mat3{
.data = .{
.{
1, 0, 0,
},
.{
0, 1, 0,
},
.{
x, y, 1,
},
},
};
}
pub fn fromRotation(rad: f32) Mat3 {
const sin = @sin(rad);
const cos = @cos(rad);
return Mat3{
.data = .{
.{
cos, sin, 0,
},
.{
-sin, cos, 0,
},
.{
0, 0, 1,
},
},
};
}
pub fn fromScaling(v: Vec2) Mat3 {
return Mat3{
.data = .{
.{
v.data[0], 0, 0,
},
.{
0, v.data[1], 0,
},
.{
0, 0, 1,
},
},
};
}
//pub fn normalFromMat4(a: Mat4) Mat3 {
// const b00 = a.data[0][0] * a.data[1][1] - a.data[0][1] * a.data[1][0];
// const b01 = a.data[0][0] * a.data[1][2] - a.data[0][2] * a.data[1][0];
// const b02 = a.data[0][0] * a.data[1][3] - a.data[0][3] * a.data[1][0];
// const b03 = a.data[0][1] * a.data[1][2] - a.data[0][2] * a.data[1][1];
// const b04 = a.data[0][1] * a.data[1][3] - a.data[0][3] * a.data[1][1];
// const b05 = a.data[0][2] * a.data[1][3] - a.data[0][3] * a.data[1][2];
// const b06 = a.data[2][0] * a.data[3][1] - a.data[2][1] * a.data[3][0];
// const b07 = a.data[2][0] * a.data[3][2] - a.data[2][2] * a.data[3][0];
// const b08 = a.data[2][0] * a.data[3][3] - a.data[2][3] * a.data[3][0];
// const b09 = a.data[2][1] * a.data[3][2] - a.data[2][2] * a.data[3][1];
// const b10 = a.data[2][1] * a.data[3][3] - a.data[2][3] * a.data[3][1];
// const b11 = a.data[2][2] * a.data[3][3] - a.data[2][3] * a.data[3][2];
// // Calculate the determinant
// var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
// if (!det) {
// return null;
// }
// det = 1 / det;
// return Mat3{
// .data = .{
// .{
// (a.data[1][1] * b11 - a.data[1][2] * b10 + a.data[1][3] * b09) * det,
// (a.data[1][2] * b08 - a.data[1][0] * b11 - a.data[1][3] * b07) * det,
// (a.data[1][0] * b10 - a.data[1][1] * b08 + a.data[1][3] * b06) * det,
// },
// .{
// (a.data[0][2] * b10 - a.data[0][1] * b11 - a.data[0][3] * b09) * det,
// (a.data[0][0] * b11 - a.data[0][2] * b08 + a.data[0][3] * b07) * det,
// (a.data[0][1] * b08 - a.data[0][0] * b10 - a.data[0][3] * b06) * det,
// },
// .{
// (a.data[3][1] * b05 - a.data[3][2] * b04 + a.data[3][3] * b03) * det,
// (a.data[3][2] * b02 - a.data[3][0] * b05 - a.data[3][3] * b01) * det,
// (a.data[3][0] * b04 - a.data[3][1] * b02 + a.data[3][3] * b00) * det,
// },
// },
// };
//}
pub fn projection(width: f32, height: f32) Mat3 {
return Mat3{
.data = .{
.{
2 / width, 0, 0,
},
.{
0, -2 / height, 0,
},
.{
-1, 1, 1,
},
},
};
}
test "projection" {
const out = Mat3.projection(100, 200);
const expected = Mat3.create(0.02, 0, 0, 0, -0.01, 0, -1, 1, 1);
try expectEqual(expected, out);
}
//pub fn frob(a: Mat3) f32 {
// return -1;
// //return(Math.hypot(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]))
//}
pub fn equals(a: Mat3, b: Mat3) bool {
const epsilon = utils.epsilon;
const a0 = a.data[0][0];
const a1 = a.data[0][1];
const a2 = a.data[0][2];
const a3 = a.data[1][0];
const a4 = a.data[1][1];
const a5 = a.data[1][2];
const a6 = a.data[2][0];
const a7 = a.data[2][1];
const a8 = a.data[2][2];
const b0 = b.data[0][0];
const b1 = b.data[0][1];
const b2 = b.data[0][2];
const b3 = b.data[1][0];
const b4 = b.data[1][1];
const b5 = b.data[1][2];
const b6 = b.data[2][0];
const b7 = b.data[2][1];
const b8 = b.data[2][2];
return (@fabs(a0 - b0) <= epsilon * math.max(1, math.max(@fabs(a0), @fabs(b0))) and
@fabs(a1 - b1) <= epsilon * math.max(1, math.max(@fabs(a1), @fabs(b1))) and
@fabs(a2 - b2) <= epsilon * math.max(1, math.max(@fabs(a2), @fabs(b2))) and
@fabs(a3 - b3) <= epsilon * math.max(1, math.max(@fabs(a3), @fabs(b3))) and
@fabs(a4 - b4) <= epsilon * math.max(1, math.max(@fabs(a4), @fabs(b4))) and
@fabs(a5 - b5) <= epsilon * math.max(1, math.max(@fabs(a5), @fabs(b5))) and
@fabs(a6 - b6) <= epsilon * math.max(1, math.max(@fabs(a6), @fabs(b6))) and
@fabs(a7 - b7) <= epsilon * math.max(1, math.max(@fabs(a7), @fabs(b7))) and
@fabs(a8 - b8) <= epsilon * math.max(1, math.max(@fabs(a8), @fabs(b8))));
}
pub fn exactEquals(a: Mat3, b: Mat3) bool {
return a.data[0][0] == b.data[0][0] and
a.data[0][1] == b.data[0][1] and
a.data[0][2] == b.data[0][2] and
a.data[1][0] == b.data[1][0] and
a.data[1][1] == b.data[1][1] and
a.data[1][2] == b.data[1][2] and
a.data[2][0] == b.data[2][0] and
a.data[2][1] == b.data[2][1] and
a.data[2][2] == b.data[2][2];
}
pub fn format(
value: @This(),
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = options;
_ = fmt;
const str = "Mat3({d:.3}, {d:.3}, {d:.3}, {d:.3}, {d:.3}, {d:.3}, {d:.3}, {d:.3}, {d:.3})";
return std.fmt.format(
writer,
str,
.{
value.data[0][0], value.data[0][1], value.data[0][2],
value.data[1][0], value.data[1][1], value.data[1][2],
value.data[2][0], value.data[2][1], value.data[2][2],
},
);
}
fn expectEqual(a: Mat3, b: Mat3) !void {
if (!a.equals(b)) {
std.debug.warn("Expected: {}, found {}\n", .{ a, b });
return error.NotEqual;
}
}
}; | src/mat3.zig |
const std = @import("std");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Step = std.build.Step;
const builtin = @import("builtin");
pub fn build(b: *Builder) void {
// Blue Pill STM32F103C8T6
const target = .{
.cpu_arch = .thumb,
.cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m3 },
.os_tag = .freestanding,
.abi = .eabi,
};
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const elf = b.addExecutable("zig-stm32-blink.elf", "src/startup.zig");
elf.setTarget(target);
elf.setBuildMode(mode);
const vector_obj = b.addObject("vector", "src/vector.zig");
vector_obj.setTarget(target);
vector_obj.setBuildMode(mode);
elf.addObject(vector_obj);
elf.setLinkerScriptPath("linker.ld");
b.default_step.dependOn(&elf.step);
b.installArtifact(elf);
// const bin = b.addInstallRaw(elf, "zig-stm32-blink.bin");
// const bin_step = b.step("bin", "Generate binary file to be flashed");
// bin_step.dependOn(&bin.step);
const bin_step = create_binary(b, elf);
const flash_step = dfu_flash(b, "firmware.bin");
flash_step.dependOn(bin_step);
}
fn create_binary(b: *Builder, elf: *LibExeObjStep) *Step {
if (elf.install_step == null) {
@panic("install_step not set");
}
const install_step = elf.install_step.?;
const objcopy_cmd = b.addSystemCommand(&[_][]const u8{
"llvm-objcopy", "-Obinary",
b.getInstallPath(install_step.dest_dir, elf.out_filename),
"firmware.bin",
});
objcopy_cmd.step.dependOn(&install_step.step);
const bin_step = b.step("bin", "Generate binary file to be flashed");
bin_step.dependOn(&objcopy_cmd.step);
return bin_step;
}
fn dfu_flash(b: *Builder, firmware: []const u8) *Step {
// ROM base address from `linker.ld`
const base_addr = "0x08002000";
const flash_cmd = b.addSystemCommand(&[_][]const u8{
"dfu-util", "-i0",
"-s", base_addr,
"-D", firmware,
});
const flash_step = b.step("flash", "Flash firmware (dfu-util)");
flash_step.dependOn(&flash_cmd.step);
return &flash_cmd.step;
} | build.zig |
const std = @import("std");
usingnamespace @import("oidavm.zig");
const parser = @import("parser.zig");
const RunMode = enum {
Debug,
Run,
};
pub fn main() !void {
var allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer allocator.deinit();
const alloc = &allocator.allocator;
var arguments = try std.process.argsAlloc(alloc);
defer std.process.argsFree(alloc, arguments);
if (arguments.len < 2 or std.mem.eql(u8, arguments[1], "help") or std.mem.eql(u8, arguments[1], "--help")) {
printUsageAndExit();
}
var mode: RunMode = blk: {
if (std.mem.eql(u8, arguments[1], "run")) {
break :blk .Run;
} else if (std.mem.eql(u8, arguments[1], "dbg")) {
break :blk .Debug;
} else {
std.debug.warn("unknown argument {}\n", .{arguments[1]});
printUsageAndExit();
}
};
var file = try std.fs.cwd().openFile(arguments[2], .{});
defer file.close();
const file_content = try file.inStream().readAllAlloc(alloc, try file.getEndPos());
var timestamp = std.time.timestamp(); // `var` to avoid comptime initialization of RNG
var vm: OidaVm = .{
.memory = try parser.assemble(file_content),
.rng = std.rand.DefaultPrng.init(timestamp).random,
};
// Just run the program and exit
if (mode == .Run) {
const entry_point = if (arguments.len == 4)
(std.fmt.parseInt(u12, arguments[3], 16) catch 0)
else
0;
vm.eval(entry_point);
return;
}
// Run oiDB REPL
std.debug.warn(
"Welcome to oiDB!\n{}\noiDB@{X:0^3}) ",
.{
oidb_usage,
vm.instruction_ptr,
},
);
var breakpoints = std.ArrayList(u12).init(alloc);
var in_buffer = std.ArrayList(u8).init(alloc);
repl: while (true) : (std.debug.warn("\noiDB@{X:0^3}) ", .{vm.instruction_ptr})) {
try std.io.getStdIn().inStream().readUntilDelimiterArrayList(&in_buffer, '\n', 1024);
var tokens = std.mem.tokenize(in_buffer.items, " ");
const instruction_token = tokens.next() orelse continue;
switch (instruction_token[0]) {
'h', '?' => {
// Display help
std.debug.warn("{}", .{oidb_usage});
},
'n' => {
// Step to next instruction
if (vm.memory[vm.instruction_ptr] == 0xf00f) {
std.debug.warn("Reached cease instruction", .{});
continue :repl;
} else {
vm.step();
vm.instruction_ptr += 1;
}
},
'd' => {
// Dump VM state
std.debug.warn("\n", .{});
vm.dump();
},
'q' => {
// Exit
std.debug.warn("\n", .{});
std.process.exit(0);
},
'i' => {
// Set instruction pointer
const address_token = tokens.next() orelse continue;
const value = std.fmt.parseInt(u12, address_token, 16) catch continue;
vm.instruction_ptr = value;
std.debug.warn("Set instruction pointer to 0x{X:0^3}", .{value});
},
'a' => {
// Set ACC
const value_token = tokens.next() orelse continue;
const value = std.fmt.parseInt(u16, value_token, 16) catch continue;
vm.accumulator = value;
std.debug.warn("Set ACC to 0x{X:0^4}", .{value});
},
's' => {
// Set arbitrary memory
const address_token = tokens.next() orelse continue;
const value_token = tokens.next() orelse continue;
const address = std.fmt.parseInt(u12, address_token, 16) catch continue;
const value = std.fmt.parseInt(u16, value_token, 16) catch continue;
vm.memory[address] = value;
std.debug.warn("Set memory at 0x{X:0^3} to 0x{X:0^4}", .{ address, value });
},
'p' => {
// Print memory
const address_token = tokens.next() orelse continue;
const address = std.fmt.parseInt(u12, address_token, 16) catch continue;
std.debug.warn("Memory at 0x{X:0^3}: 0x{X:0^4}", .{ address, vm.memory[address] });
},
'b' => {
// Add breakpoint
const address_token = tokens.next() orelse continue;
const address = std.fmt.parseInt(u12, address_token, 16) catch continue;
for (breakpoints.items) |bp| {
if (bp == address) {
std.debug.warn("Breakpoint already present at 0x{X:0^3}", .{address});
continue :repl;
}
}
try breakpoints.append(address);
std.debug.warn("Added breakpoint at 0x{X:0^3}", .{address});
},
'l' => {
// List breakpoints
const num_breakpoints = breakpoints.items.len;
const fmt_pluralize = if (num_breakpoints == 0) "s" else if (num_breakpoints == 1) ":" else "s:";
std.debug.warn("{} Breakpoint{} ", .{
num_breakpoints,
fmt_pluralize,
});
for (breakpoints.items) |bp, i| {
const fmt_cond_comma = if (i == num_breakpoints - 1) "" else ", ";
std.debug.warn("0x{X:0^3}{}", .{
bp,
fmt_cond_comma,
});
}
},
'r' => {
// Remove breakpoint
const address_token = tokens.next() orelse continue;
const address = std.fmt.parseInt(u12, address_token, 16) catch continue;
for (breakpoints.items) |bp, i| {
if (bp == address) {
_ = breakpoints.orderedRemove(i);
std.debug.warn("Removed breakpoint at 0x{X:0^3}", .{address});
continue :repl;
}
}
std.debug.warn("No breakpoint at 0x{X:0^3} to remove", .{address});
},
'c' => {
// Continue execution up to next breakpoint
const pointer_at_start = vm.instruction_ptr;
while (vm.instruction_ptr < 4095) : (vm.instruction_ptr += 1) {
if (vm.memory[vm.instruction_ptr] == 0xf00f) {
std.debug.warn("Reached cease instruction", .{});
continue :repl;
}
for (breakpoints.items) |bp| {
if (vm.instruction_ptr == bp and !(pointer_at_start == bp)) continue :repl;
}
vm.step();
}
},
else => continue,
}
}
}
fn printUsageAndExit() noreturn {
std.debug.warn("{}", .{oidavm_usage});
std.process.exit(0);
}
const oidavm_usage =
\\OidaVM 0.1
\\
\\Usage: ovm run [file.oidasm] <entry point>
\\ ovm dbg [file.oidasm]
\\ ovm help
\\
;
const oidb_usage =
\\oiDB Commands
\\ d dump VM's state
\\ q quit oiDB
\\ h,? display this message
\\
\\ n execute and increase instruction pointer
\\ i set the instruction pointer: i 000
\\ a set ACC: a 0000
\\ s set memory: s 000 f00f
\\ p print memory: p 000
\\
\\ b set breakpoint: b 000
\\ l list breakpoints
\\ r remove breakpoint: r 000
\\ c continue execution to next breakpoint
\\
; | src/main.zig |
const std = @import("std");
const msgpack = @import("msgpack.zig");
pub const Status = enum {
Okay,
Changed,
Done,
};
pub const Buffer = struct {
const Self = @This();
lines: [][]const u8,
alloc: *std.mem.Allocator,
pub fn init(alloc: *std.mem.Allocator) !Self {
const lines = try alloc.alloc([]const u8, 0);
return Self{
.lines = lines,
.alloc = alloc,
};
}
pub fn deinit(self: *Buffer) void {
for (self.lines) |line| {
self.alloc.free(line);
}
self.alloc.free(self.lines);
}
pub fn to_buf(self: *Buffer) ![]const u8 {
var total_length: usize = 0;
for (self.lines) |line| {
total_length += line.len + 1;
}
var out = try self.alloc.alloc(u8, total_length);
var pos: usize = 0;
for (self.lines) |line| {
std.mem.copy(u8, out[pos..(pos + line.len)], line);
out[pos + line.len] = '\n';
pos += line.len + 1;
}
return out;
}
fn api_lines_event(self: *Buffer, args: []const msgpack.Value) !Status {
// Special-case for the first event after we've attached. which send
// the full buffer with last == -1
if (args[2] == .Int) {
// Check various states to ensure that this is the first event
std.debug.assert(args[1].UInt == 0);
std.debug.assert(args[2].Int == -1);
std.debug.assert(self.lines.len == 0);
const lines = args[3].Array;
self.lines = try self.alloc.alloc([]const u8, lines.len);
var i: u32 = 0;
while (i < lines.len) : (i += 1) {
self.lines[i] = lines[i].RawString;
lines[i] = .Nil;
}
return Status.Changed;
}
const first = args[1].UInt;
// Work around buf #13418 in Neovim
const last = std.math.min(args[2].UInt, self.lines.len);
std.debug.assert(last >= first);
const lines = args[3].Array;
const new_size = self.lines.len + lines.len - (last - first);
if (new_size != self.lines.len) {
var new_lines = try self.alloc.alloc([]const u8, new_size);
// Copy lines from before the region of interest
var i: u32 = 0;
var j: u32 = 0;
while (i < first) : (i += 1) {
new_lines[i] = self.lines[j];
j += 1;
}
// Copy the modified lines
while (i - first < lines.len) : (i += 1) {
new_lines[i] = lines[i - first].RawString;
lines[i - first] = .Nil;
}
// Erase the old region of interest
while (j < last) : (j += 1) {
self.alloc.free(self.lines[j]);
}
// Copy lines after the region of interest
while (j < self.lines.len) : (j += 1) {
new_lines[i] = self.lines[j];
i += 1;
}
self.alloc.free(self.lines);
self.lines = new_lines;
} else {
var i = first;
while (i < last) : (i += 1) {
self.alloc.free(self.lines[i]);
// Steal the value from the msgpack array
self.lines[i] = lines[i - first].RawString;
lines[i - first] = .Nil;
}
}
return Status.Changed;
}
// This API event is the only one which returns 'true', indicating
// that the buffer should be destroyed
fn api_detach_event(self: *Buffer, args: []const msgpack.Value) !Status {
_ = self;
_ = args;
return Status.Done;
}
pub fn rpc_method(self: *Buffer, name: []const u8, args: []const msgpack.Value) !Status {
// Same trick as in tui.zig
const opts = comptime std.builtin.CallOptions{};
inline for (@typeInfo(Self).Struct.decls) |s| {
// This conditional should be optimized out, since
// it's known at comptime.
const is_api = comptime std.mem.startsWith(u8, s.name, "api_");
if (is_api) {
// Skip nvim_buf_ in the RPC name and api_ in the API name
if (std.mem.eql(u8, name[9..], s.name[4..])) {
return @call(opts, @field(Self, s.name), .{ self, args });
}
}
}
std.debug.warn("[Buffer] Unimplemented API: {s}\n", .{name});
return Status.Okay;
}
}; | src/buffer.zig |
// TODO: 3D camera
// TODO: Some kind of ecs
// TODO: Simple layering system
const std = @import("std");
const renderer = @import("kira/renderer.zig");
const gl = @import("kira/gl.zig");
const c = @import("kira/c.zig");
const m = @import("kira/math/common.zig");
usingnamespace @import("sharedtypes.zig");
usingnamespace @import("kira/log.zig");
const check = @import("kira/utils.zig").check;
pub const Vertex2DNoTexture = comptime renderer.VertexGeneric(false, Vec2f);
pub const Vertex2DTexture = comptime renderer.VertexGeneric(true, Vec2f);
// Maybe create a white texture and remove this?
// With that you'll be able to use textured batchs with shape draw calls
pub const Batch2DQuadNoTexture = comptime renderer.BatchGeneric(1024 * 8, 6, 4, Vertex2DNoTexture);
pub const Batch2DQuadTexture = comptime renderer.BatchGeneric(1024 * 8, 6, 4, Vertex2DTexture);
/// Helper type
const Renderer2D = struct {
tag: Renderer2DBatchTag = Renderer2DBatchTag.quads,
cam: Camera2D = Camera2D{},
quadbatch_notexture: Batch2DQuadNoTexture = Batch2DQuadNoTexture{},
quadbatch_texture: Batch2DQuadTexture = Batch2DQuadTexture{},
current_texture: Texture = Texture{},
current_quadbatch_notexture: *Batch2DQuadNoTexture = undefined,
current_quadbatch_texture: *Batch2DQuadTexture = undefined,
current_quadbatch_shader: u32 = undefined,
custombatch: bool = false,
autoflush: bool = true,
notextureshader: u32 = 0,
textureshader: u32 = 0,
textured: bool = false,
};
pub const Renderer2DBatchTag = enum {
pixels,
/// Line & circle line draw can olsa be used in non-textured line batch
lines,
/// Triangle & rectangle & circles draw can also be used in non-textured triangle batch
triangles,
/// Triangle & rectangle & circles draw can also be used in non-textured quad batch
quads,
};
/// Particle type
pub const Particle = struct {
/// Particle position
position: Vec2f = Vec2f{},
/// Particle size
size: Vec2f = Vec2f{},
/// Particle velocity
velocity: Vec2f = Vec2f{},
/// Colour modifier(particle colour)
colour: Colour = Colour{},
/// Lifetime modifier,
/// Particle gonna die after this hits 0
lifetime: f32 = 0,
/// Fade modifier,
/// Particle gonna fade over lifetime decreases
/// With this modifier as a decrease value
fade: f32 = 100,
/// Fade colour modifier
/// Particles colour is gonna change over fade modifer,
/// until hits this modifier value
fade_colour: Colour = colour,
/// Is particle alive?
is_alive: bool = false,
};
/// Particle system generic function
pub fn ParticleSystemGeneric(maxparticle_count: u32) type {
return struct {
const Self = @This();
/// Maximum particle count
pub const maxparticle = maxparticle_count;
/// Particle list
list: [maxparticle]Particle = undefined,
/// Draw function for drawing particle
drawfn: ?fn (self: Particle) Error!void = null,
/// Clear the all particles
pub fn clearAll(self: *Self) void {
// This is going to set every particle to default values
self.list = undefined;
}
/// Draw the particles
pub fn draw(self: Self) Error!void {
if (self.drawfn) |fun| {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
try fun(self.list[i]);
}
}
} else {
std.log.warn("kiragine -> particle system draw fallbacks to drawing as rectangles", .{});
try self.drawAsRectangles();
}
}
/// Draws the particles as rectangles
pub fn drawAsRectangles(self: Self) Error!void {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
const rect = Rectangle{
.x = self.list[i].position.x,
.y = self.list[i].position.y,
.width = self.list[i].size.x,
.height = self.list[i].size.y,
};
try drawRectangle(rect, self.list[i].colour);
}
}
}
/// Draws the particles as triangles
pub fn drawAsTriangles(self: Self) Error!void {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
const triangle = [3]Vec2f{
.{ .x = self.list[i].position.x, .y = self.list[i].position.y },
.{ .x = self.list[i].position.x + (self.list[i].size.x / 2), .y = self.list[i].position.y - self.list[i].size.y },
.{ .x = self.list[i].position.x + self.list[i].size.x, .y = self.list[i].position.y },
};
try drawTriangle(triangle[0], triangle[1], triangle[2], self.list[i].colour);
}
}
}
/// Draws the particles as circles
pub fn drawAsCircles(self: Self) Error!void {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
const rad: f32 = (self.list[i].size.x / self.list[i].size.y) * 10;
try drawCircle(self.list[i].position, rad, self.list[i].colour);
}
}
}
/// Draws the particles as textures
/// Don't forget the enable texture batch!
pub fn drawAsTextures(self: Self) Error!void {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
const t = try getTextureBatch2D();
const rect = Rectangle{
.x = self.list[i].position.x,
.y = self.list[i].position.y,
.width = self.list[i].size.x,
.height = self.list[i].size.y,
};
const srcrect = Rectangle{
.x = 0,
.y = 0,
.width = t.width,
.height = t.height,
};
try drawTexture(rect, srcrect, self.list[i].colour);
}
}
}
/// Update the particles
pub fn update(self: *Self, fixedtime: f32) void {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (self.list[i].is_alive) {
const vel = Vec2f{
.x = self.list[i].velocity.x * fixedtime,
.y = self.list[i].velocity.y * fixedtime,
};
self.list[i].position = Vec2f.add(self.list[i].position, vel);
if (self.list[i].lifetime > 0) {
self.list[i].lifetime -= 1 * fixedtime;
var alpha: f32 = self.list[i].colour.a;
var r: f32 = self.list[i].colour.r;
var g: f32 = self.list[i].colour.g;
var b: f32 = self.list[i].colour.b;
if (r < self.list[i].fade_colour.r) {
r = self.list[i].fade_colour.r;
} else r = ((r * 255.0) - (self.list[i].fade * fixedtime)) / 255.0;
if (g < self.list[i].fade_colour.g) {
g = self.list[i].fade_colour.g;
} else g = ((g * 255.0) - (self.list[i].fade * fixedtime)) / 255.0;
if (b < self.list[i].fade_colour.b) {
b = self.list[i].fade_colour.b;
} else b = ((b * 255.0) - (self.list[i].fade * fixedtime)) / 255.0;
if (alpha < self.list[i].fade_colour.a) {
alpha = self.list[i].fade_colour.a;
} else alpha = ((alpha * 255.0) - (self.list[i].fade * fixedtime)) / 255.0;
self.list[i].colour.a = alpha;
self.list[i].colour.r = r;
self.list[i].colour.g = g;
self.list[i].colour.b = b;
} else self.list[i].is_alive = false;
}
}
}
/// Add particle
/// Will return false if failes to add a particle
/// Which means the list has been filled
pub fn add(self: *Self, particle: Particle) bool {
var i: u32 = 0;
while (i < Self.maxparticle) : (i += 1) {
if (!self.list[i].is_alive) {
self.list[i] = particle;
self.list[i].is_alive = true;
return true;
}
}
return false;
}
};
}
const pnotexture_vertex_shader = @embedFile("../../assets/shaders/notexture.vert");
const pnotexture_fragment_shader = @embedFile("../../assets/shaders/notexture.frag");
const ptexture_vertex_shader = @embedFile("../../assets/shaders/texture.vert");
const ptexture_fragment_shader = @embedFile("../../assets/shaders/texture.frag");
var prenderer2D: *Renderer2D = undefined;
var allocator: *std.mem.Allocator = undefined;
/// Initializes the renderer
/// WARN: Do NOT call this if you already called the init function
pub fn initRenderer(alloc: *std.mem.Allocator, pwin: *const Window) !void {
allocator = alloc;
prenderer2D = try allocator.create(Renderer2D);
prenderer2D.* = Renderer2D{};
prenderer2D.cam.ortho = Mat4x4f.ortho(0, @intToFloat(f32, pwin.size.width), @intToFloat(f32, pwin.size.height), 0, -1, 1);
prenderer2D.notextureshader = try gl.shaderProgramCreate(allocator, pnotexture_vertex_shader, pnotexture_fragment_shader);
prenderer2D.textureshader = try gl.shaderProgramCreate(allocator, ptexture_vertex_shader, ptexture_fragment_shader);
try prenderer2D.quadbatch_notexture.create(prenderer2D.notextureshader, pnoTextureShaderAttribs);
try prenderer2D.quadbatch_texture.create(prenderer2D.textureshader, pTextureShaderAttribs);
prenderer2D.current_quadbatch_notexture = &prenderer2D.quadbatch_notexture;
prenderer2D.current_quadbatch_texture = &prenderer2D.quadbatch_texture;
}
/// Deinitializes the renderer
/// WARN: Do NOT call this if you already called the deinit function
pub fn deinitRenderer() void {
prenderer2D.quadbatch_notexture.destroy();
prenderer2D.quadbatch_texture.destroy();
gl.shaderProgramDelete(prenderer2D.notextureshader);
gl.shaderProgramDelete(prenderer2D.textureshader);
allocator.destroy(prenderer2D);
}
/// Clears the screen with given colour
pub fn clearScreen(r: f32, g: f32, b: f32, a: f32) void {
gl.clearColour(r, g, b, a);
gl.clearBuffers(gl.BufferBit.colour);
}
/// Returns the 2D camera
pub fn getCamera2D() *Camera2D {
return &prenderer2D.cam;
}
/// Enables the autoflush
pub fn enableAutoFlushBatch2D() void {
prenderer2D.autoflush = true;
}
/// Disables the autoflush
pub fn disableAutoFlushBatch2D() void {
prenderer2D.autoflush = false;
}
/// Enables the texture
pub fn enableTextureBatch2D(t: Texture) void {
prenderer2D.current_texture = t;
prenderer2D.textured = true;
}
/// Disables the texture
pub fn disableTextureBatch2D() void {
prenderer2D.current_texture.id = 0;
prenderer2D.textured = false;
}
/// Returns the enabled texture
pub fn getTextureBatch2D() Error!Texture {
if (prenderer2D.textured) {
return prenderer2D.current_texture;
}
return Error.InvalidTexture;
}
/// Enables the custom batch
pub fn enableCustomBatch2D(comptime batchtype: type, batch: *batchtype, shader: u32) Error!void {
if (batchtype == Batch2DQuadNoTexture) {
if (prenderer2D.custombatch) {
return Error.UnableToEnableCustomBatch;
}
prenderer2D.custombatch = true;
prenderer2D.current_quadbatch_notexture = batch;
prenderer2D.current_quadbatch_shader = shader;
return;
} else if (batchtype == Batch2DQuadTexture) {
if (prenderer2D.custombatch) {
return Error.UnableToEnableCustomBatch;
}
prenderer2D.custombatch = true;
prenderer2D.current_quadbatch_texture = batch;
prenderer2D.current_quadbatch_shader = shader;
return;
}
@compileError("Unknown batch type!");
}
/// Disables the custom batch
pub fn disableCustomBatch2D(comptime batchtype: type) void {
if (batchtype == Batch2DQuadNoTexture) {
prenderer2D.custombatch = false;
prenderer2D.current_quadbatch_notexture = undefined;
prenderer2D.current_quadbatch_shader = 0;
return;
} else if (batchtype == Batch2DQuadTexture) {
prenderer2D.custombatch = false;
prenderer2D.current_quadbatch_texture = undefined;
prenderer2D.current_quadbatch_shader = 0;
return;
}
@compileError("Unknown batch type!");
}
/// Returns the current batch
pub fn getCustomBatch2D(comptime batchtype: type) Error!*batchtype {
if (batchtype == Batch2DQuadNoTexture) {
return ¤t_quadbatch_notexture;
} else if (batchtype == Batch2DQuadTexture) {
return ¤t_quadbatch_texture;
}
@compileError("Unknown batch type!");
}
/// Pushes the batch
pub fn pushBatch2D(tag: Renderer2DBatchTag) Error!void {
prenderer2D.tag = tag;
switch (prenderer2D.tag) {
Renderer2DBatchTag.pixels => {
if (prenderer2D.textured) return Error.InvalidBatch; // No textured lines
prenderer2D.current_quadbatch_notexture.submitfn = pnoTextureSubmitQuadfn;
},
Renderer2DBatchTag.lines => {
if (prenderer2D.textured) return Error.InvalidBatch; // No textured lines
prenderer2D.current_quadbatch_notexture.submitfn = pnoTextureSubmitQuadfn;
},
Renderer2DBatchTag.triangles => {
if (prenderer2D.textured) return Error.InvalidBatch; // No textured triangle
prenderer2D.current_quadbatch_notexture.submitfn = pnoTextureSubmitQuadfn;
},
Renderer2DBatchTag.quads => {
prenderer2D.current_quadbatch_texture.submitfn = pTextureSubmitQuadfn;
prenderer2D.current_quadbatch_notexture.submitfn = pnoTextureSubmitQuadfn;
},
}
var shader: u32 = 0;
var mvploc: i32 = -1;
if (!prenderer2D.textured) {
if (prenderer2D.custombatch) {
shader = prenderer2D.current_quadbatch_shader;
} else {
shader = prenderer2D.notextureshader;
}
try check(shader == 0, "kiragine -> unable to use non-textured shader!", .{});
mvploc = gl.shaderProgramGetUniformLocation(shader, "MVP");
try check(mvploc == -1, "kiragine -> unable to use uniforms from non-textured shader!", .{});
} else {
if (prenderer2D.custombatch) {
shader = prenderer2D.current_quadbatch_shader;
} else {
shader = prenderer2D.textureshader;
}
try check(shader == 0, "kiragine -> unable to use textured shader!", .{});
mvploc = gl.shaderProgramGetUniformLocation(shader, "MVP");
try check(mvploc == -1, "kiragine -> unable to use uniforms from textured shader!", .{});
}
gl.shaderProgramUse(shader);
prenderer2D.cam.attach();
gl.shaderProgramSetMat4x4f(mvploc, @ptrCast([*]const f32, &prenderer2D.cam.view.toArray()));
}
/// Pops the batch
pub fn popBatch2D() Error!void {
defer {
prenderer2D.cam.detach();
if (prenderer2D.textured) {
prenderer2D.current_quadbatch_texture.submission_counter = 0;
prenderer2D.current_quadbatch_texture.cleanAll();
} else {
prenderer2D.current_quadbatch_notexture.submission_counter = 0;
prenderer2D.current_quadbatch_notexture.cleanAll();
}
}
switch (prenderer2D.tag) {
Renderer2DBatchTag.pixels => {
if (prenderer2D.textured) {
return Error.InvalidBatch;
} else {
try prenderer2D.current_quadbatch_notexture.draw(gl.DrawMode.points);
}
},
Renderer2DBatchTag.lines => {
if (prenderer2D.textured) {
return Error.InvalidBatch;
} else {
try prenderer2D.current_quadbatch_notexture.draw(gl.DrawMode.lines);
}
},
Renderer2DBatchTag.triangles => {
if (prenderer2D.textured) {
return Error.InvalidBatch;
} else {
try prenderer2D.current_quadbatch_notexture.draw(gl.DrawMode.triangles);
}
},
Renderer2DBatchTag.quads => {
if (prenderer2D.textured) {
gl.textureBind(gl.TextureType.t2D, prenderer2D.current_texture.id);
try prenderer2D.current_quadbatch_texture.draw(gl.DrawMode.triangles);
gl.textureBind(gl.TextureType.t2D, 0);
} else {
try prenderer2D.current_quadbatch_notexture.draw(gl.DrawMode.triangles);
}
},
}
}
/// Flushes the batch
pub fn flushBatch2D() Error!void {
const tag = prenderer2D.tag;
try popBatch2D();
try pushBatch2D(tag);
}
/// Draws a pixel
pub fn drawPixel(pixel: Vec2f, colour: Colour) Error!void {
if (prenderer2D.textured) return Error.InvalidBatch;
switch (prenderer2D.tag) {
Renderer2DBatchTag.quads, Renderer2DBatchTag.triangles, Renderer2DBatchTag.lines => {
return Error.InvalidBatch;
},
else => {},
}
prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
}) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
.{ .position = pixel, .colour = colour },
});
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a line
pub fn drawLine(line0: Vec2f, line1: Vec2f, colour: Colour) Error!void {
if (prenderer2D.textured) return Error.InvalidBatch;
switch (prenderer2D.tag) {
Renderer2DBatchTag.quads, Renderer2DBatchTag.triangles => {
return Error.InvalidBatch;
},
else => {},
}
prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = line0, .colour = colour },
.{ .position = line1, .colour = colour },
.{ .position = line1, .colour = colour },
.{ .position = line1, .colour = colour },
}) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = line0, .colour = colour },
.{ .position = line1, .colour = colour },
.{ .position = line1, .colour = colour },
.{ .position = line1, .colour = colour },
});
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a triangle
pub fn drawTriangle(left: Vec2f, top: Vec2f, right: Vec2f, colour: Colour) Error!void {
if (prenderer2D.textured) return Error.InvalidBatch;
switch (prenderer2D.tag) {
Renderer2DBatchTag.lines => {
return Error.InvalidBatch;
},
else => {},
}
prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = left, .colour = colour },
.{ .position = top, .colour = colour },
.{ .position = right, .colour = colour },
.{ .position = right, .colour = colour },
}) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = left, .colour = colour },
.{ .position = top, .colour = colour },
.{ .position = right, .colour = colour },
.{ .position = right, .colour = colour },
});
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a circle
/// The segments are lowered for sake of
/// making it smaller on the batch
pub fn drawCircle(position: Vec2f, radius: f32, colour: Colour) Error!void {
try drawCircleAdvanced(position, radius, 0, 360, 16, colour);
}
// Source: https://github.com/raysan5/raylib/blob/f1ed8be5d7e2d966d577a3fd28e53447a398b3b6/src/shapes.c#L209
/// Draws a circle
pub fn drawCircleAdvanced(center: Vec2f, radius: f32, startangle: i32, endangle: i32, segments: i32, colour: Colour) Error!void {
const SMOOTH_CIRCLE_ERROR_RATE = comptime 0.5;
var iradius = radius;
var istartangle = startangle;
var iendangle = endangle;
var isegments = segments;
if (iradius <= 0.0) iradius = 0.1; // Avoid div by zero
// Function expects (endangle > startangle)
if (iendangle < istartangle) {
// Swap values
const tmp = istartangle;
istartangle = iendangle;
iendangle = tmp;
}
if (isegments < 4) {
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
const th: f32 = std.math.acos(2 * std.math.pow(f32, 1 - SMOOTH_CIRCLE_ERROR_RATE / iradius, 2) - 1);
isegments = @floatToInt(i32, (@intToFloat(f32, (iendangle - istartangle)) * std.math.ceil(2 * m.PI / th) / 360));
if (isegments <= 0) isegments = 4;
}
const steplen: f32 = @intToFloat(f32, iendangle - istartangle) / @intToFloat(f32, isegments);
var angle: f32 = @intToFloat(f32, istartangle);
// NOTE: Every QUAD actually represents two segments
var i: i32 = 0;
while (i < @divTrunc(isegments, 2)) : (i += 1) {
const pos0 = Vec2f{ .x = center.x, .y = center.y };
const pos1 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle)) * iradius,
};
const pos2 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle + steplen)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle + steplen)) * iradius,
};
const pos3 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle + steplen * 2)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle + steplen * 2)) * iradius,
};
angle += steplen * 2;
pdrawRectangle(pos0, pos1, pos2, pos3, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawRectangle(pos0, pos1, pos2, pos3, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
// NOTE: In case number of segments is odd, we add one last piece to the cake
if (@mod(isegments, 2) != 0) {
const pos0 = Vec2f{ .x = center.x, .y = center.y };
const pos1 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle)) * iradius,
};
const pos2 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle + steplen)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle + steplen)) * iradius,
};
const pos3 = Vec2f{ .x = center.x, .y = center.y };
pdrawRectangle(pos0, pos1, pos2, pos3, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawRectangle(pos0, pos1, pos2, pos3, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
}
/// Draws a circle lines
/// The segments are lowered for sake of
/// making it smaller on the batch
pub fn drawCircleLines(position: Vec2f, radius: f32, colour: Colour) Error!void {
try drawCircleLinesAdvanced(position, radius, 0, 360, 16, colour);
}
// Source: https://github.com/raysan5/raylib/blob/f1ed8be5d7e2d966d577a3fd28e53447a398b3b6/src/shapes.c#L298
/// Draws a circle lines
pub fn drawCircleLinesAdvanced(center: Vec2f, radius: f32, startangle: i32, endangle: i32, segments: i32, colour: Colour) Error!void {
const SMOOTH_CIRCLE_ERROR_RATE = comptime 0.5;
var iradius = radius;
var istartangle = startangle;
var iendangle = endangle;
var isegments = segments;
if (iradius <= 0.0) iradius = 0.1; // Avoid div by zero
// Function expects (endangle > startangle)
if (iendangle < istartangle) {
// Swap values
const tmp = istartangle;
istartangle = iendangle;
iendangle = tmp;
}
if (isegments < 4) {
// Calculate the maximum angle between segments based on the error rate (usually 0.5f)
const th: f32 = std.math.acos(2 * std.math.pow(f32, 1 - SMOOTH_CIRCLE_ERROR_RATE / iradius, 2) - 1);
isegments = @floatToInt(i32, (@intToFloat(f32, (iendangle - istartangle)) * std.math.ceil(2 * m.PI / th) / 360));
if (isegments <= 0) isegments = 4;
}
const steplen: f32 = @intToFloat(f32, iendangle - istartangle) / @intToFloat(f32, isegments);
var angle: f32 = @intToFloat(f32, istartangle);
// Hide the cap lines when the circle is full
var showcaplines: bool = true;
var limit: i32 = 2 * (isegments + 2);
if (@mod(iendangle - istartangle, 350) == 0) {
limit = 2 * isegments;
showcaplines = false;
}
if (showcaplines) {
const pos0 = Vec2f{ .x = center.x, .y = center.y };
const pos1 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle)) * iradius,
};
try drawLine(pos0, pos1, colour);
}
var i: i32 = 0;
while (i < isegments) : (i += 1) {
const pos1 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle)) * iradius,
};
const pos2 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle + steplen)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle + steplen)) * iradius,
};
try drawLine(pos1, pos2, colour);
angle += steplen;
}
if (showcaplines) {
const pos0 = Vec2f{ .x = center.x, .y = center.y };
const pos1 = Vec2f{
.x = center.x + std.math.sin(m.deg2radf(angle)) * iradius,
.y = center.y + std.math.cos(m.deg2radf(angle)) * iradius,
};
try drawLine(pos0, pos1, colour);
}
}
/// Draws a rectangle
pub fn drawRectangle(rect: Rectangle, colour: Colour) Error!void {
const pos0 = Vec2f{ .x = rect.x, .y = rect.y };
const pos1 = Vec2f{ .x = rect.x + rect.width, .y = rect.y };
const pos2 = Vec2f{ .x = rect.x + rect.width, .y = rect.y + rect.height };
const pos3 = Vec2f{ .x = rect.x, .y = rect.y + rect.height };
pdrawRectangle(pos0, pos1, pos2, pos3, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawRectangle(pos0, pos1, pos2, pos3, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a rectangle lines
pub fn drawRectangleLines(rect: Rectangle, colour: Colour) Error!void {
try drawRectangle(.{ .x = rect.x, .y = rect.y, .width = rect.width, .height = 1 }, colour);
try drawRectangle(.{ .x = rect.x + rect.width - 1, .y = rect.y + 1, .width = 1, .height = rect.height - 2 }, colour);
try drawRectangle(.{ .x = rect.x, .y = rect.y + rect.height - 1, .width = rect.width, .height = 1 }, colour);
try drawRectangle(.{ .x = rect.x, .y = rect.y + 1, .width = 1, .height = rect.height - 2 }, colour);
}
/// Draws a rectangle rotated(rotation should be provided in radians)
pub fn drawRectangleRotated(rect: Rectangle, origin: Vec2f, rotation: f32, colour: Colour) Error!void {
var matrix = ModelMatrix{};
matrix.translate(rect.x, rect.y, 0);
matrix.translate(origin.x, origin.y, 0);
matrix.rotate(0, 0, 1, rotation);
matrix.translate(-origin.x, -origin.y, 0);
const mvp = matrix.model;
const r0 = Vec3f.transform(.{ .x = 0, .y = 0 }, mvp);
const r1 = Vec3f.transform(.{ .x = rect.width, .y = 0 }, mvp);
const r2 = Vec3f.transform(.{ .x = rect.width, .y = rect.height }, mvp);
const r3 = Vec3f.transform(.{ .x = 0, .y = rect.height }, mvp);
const pos0 = Vec2f{ .x = rect.x + r0.x, .y = rect.y + r0.y };
const pos1 = Vec2f{ .x = rect.x + r1.x, .y = rect.y + r1.y };
const pos2 = Vec2f{ .x = rect.x + r2.x, .y = rect.y + r2.y };
const pos3 = Vec2f{ .x = rect.x + r3.x, .y = rect.y + r3.y };
pdrawRectangle(pos0, pos1, pos2, pos3, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawRectangle(pos0, pos1, pos2, pos3, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a texture
pub fn drawTexture(rect: Rectangle, srcrect: Rectangle, colour: Colour) Error!void {
const pos0 = Vec2f{ .x = rect.x, .y = rect.y };
const pos1 = Vec2f{ .x = rect.x + rect.width, .y = rect.y };
const pos2 = Vec2f{ .x = rect.x + rect.width, .y = rect.y + rect.height };
const pos3 = Vec2f{ .x = rect.x, .y = rect.y + rect.height };
pdrawTexture(pos0, pos1, pos2, pos3, srcrect, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawTexture(pos0, pos1, pos2, pos3, srcrect, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
/// Draws a texture(rotation should be provided in radians)
pub fn drawTextureRotated(rect: Rectangle, srcrect: Rectangle, origin: Vec2f, rotation: f32, colour: Colour) Error!void {
var matrix = ModelMatrix{};
matrix.translate(rect.x, rect.y, 0);
matrix.translate(origin.x, origin.y, 0);
matrix.rotate(0, 0, 1, rotation);
matrix.translate(-origin.x, -origin.y, 0);
const mvp = matrix.model;
const r0 = Vec3f.transform(.{ .x = 0, .y = 0 }, mvp);
const r1 = Vec3f.transform(.{ .x = rect.width, .y = 0 }, mvp);
const r2 = Vec3f.transform(.{ .x = rect.width, .y = rect.height }, mvp);
const r3 = Vec3f.transform(.{ .x = 0, .y = rect.height }, mvp);
const pos0 = Vec2f{ .x = rect.x + r0.x, .y = rect.y + r0.y };
const pos1 = Vec2f{ .x = rect.x + r1.x, .y = rect.y + r1.y };
const pos2 = Vec2f{ .x = rect.x + r2.x, .y = rect.y + r2.y };
const pos3 = Vec2f{ .x = rect.x + r3.x, .y = rect.y + r3.y };
pdrawTexture(pos0, pos1, pos2, pos3, srcrect, colour) catch |err| {
if (err == renderer.Error.ObjectOverflow) {
if (prenderer2D.autoflush) {
try flushBatch2D();
try pdrawTexture(pos0, pos1, pos2, pos3, srcrect, colour);
} else {
return Error.FailedToDraw;
}
} else return err;
};
}
// PRIVATE FUNCTIONS
fn pnoTextureShaderAttribs() void {
const stride = @sizeOf(Vertex2DNoTexture);
gl.shaderProgramSetVertexAttribArray(0, true);
gl.shaderProgramSetVertexAttribArray(1, true);
gl.shaderProgramSetVertexAttribPointer(0, 2, f32, false, stride, @intToPtr(?*const c_void, @byteOffsetOf(Vertex2DNoTexture, "position")));
gl.shaderProgramSetVertexAttribPointer(1, 4, f32, false, stride, @intToPtr(?*const c_void, @byteOffsetOf(Vertex2DNoTexture, "colour")));
}
fn pTextureShaderAttribs() void {
const stride = @sizeOf(Vertex2DTexture);
gl.shaderProgramSetVertexAttribArray(0, true);
gl.shaderProgramSetVertexAttribArray(1, true);
gl.shaderProgramSetVertexAttribArray(2, true);
gl.shaderProgramSetVertexAttribPointer(0, 2, f32, false, stride, @intToPtr(?*const c_void, @byteOffsetOf(Vertex2DTexture, "position")));
gl.shaderProgramSetVertexAttribPointer(1, 2, f32, false, stride, @intToPtr(?*const c_void, @byteOffsetOf(Vertex2DTexture, "texcoord")));
gl.shaderProgramSetVertexAttribPointer(2, 4, f32, false, stride, @intToPtr(?*const c_void, @byteOffsetOf(Vertex2DTexture, "colour")));
}
fn pnoTextureSubmitQuadfn(self: *Batch2DQuadNoTexture, vertex: [Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture) renderer.Error!void {
try psubmitVerticesQuad(Batch2DQuadNoTexture, self, vertex);
try psubmitIndiciesQuad(Batch2DQuadNoTexture, self);
self.submission_counter += 1;
}
fn pTextureSubmitQuadfn(self: *Batch2DQuadTexture, vertex: [Batch2DQuadTexture.max_vertex_count]Vertex2DTexture) renderer.Error!void {
try psubmitVerticesQuad(Batch2DQuadTexture, self, vertex);
try psubmitIndiciesQuad(Batch2DQuadTexture, self);
self.submission_counter += 1;
}
fn psubmitVerticesQuad(comptime typ: type, self: *typ, vertex: [typ.max_vertex_count]typ.Vertex) renderer.Error!void {
try self.submitVertex(self.submission_counter, 0, vertex[0]);
try self.submitVertex(self.submission_counter, 1, vertex[1]);
try self.submitVertex(self.submission_counter, 2, vertex[2]);
try self.submitVertex(self.submission_counter, 3, vertex[3]);
}
fn psubmitIndiciesQuad(comptime typ: type, self: *typ) renderer.Error!void {
if (self.submission_counter == 0) {
try self.submitIndex(self.submission_counter, 0, 0);
try self.submitIndex(self.submission_counter, 1, 1);
try self.submitIndex(self.submission_counter, 2, 2);
try self.submitIndex(self.submission_counter, 3, 2);
try self.submitIndex(self.submission_counter, 4, 3);
try self.submitIndex(self.submission_counter, 5, 0);
} else {
const back = self.index_list[self.submission_counter - 1];
var i: u8 = 0;
while (i < typ.max_index_count) : (i += 1) {
try self.submitIndex(self.submission_counter, i, back[i] + 4);
try self.submitIndex(self.submission_counter, i, back[i] + 4);
try self.submitIndex(self.submission_counter, i, back[i] + 4);
try self.submitIndex(self.submission_counter, i, back[i] + 4);
try self.submitIndex(self.submission_counter, i, back[i] + 4);
try self.submitIndex(self.submission_counter, i, back[i] + 4);
}
}
}
fn pdrawRectangle(pos0: Vec2f, pos1: Vec2f, pos2: Vec2f, pos3: Vec2f, colour: Colour) Error!void {
if (prenderer2D.textured) return Error.InvalidBatch;
switch (prenderer2D.tag) {
Renderer2DBatchTag.lines => {
return Error.InvalidBatch;
},
else => {},
}
try prenderer2D.current_quadbatch_notexture.submitDrawable([Batch2DQuadNoTexture.max_vertex_count]Vertex2DNoTexture{
.{ .position = pos0, .colour = colour },
.{ .position = pos1, .colour = colour },
.{ .position = pos2, .colour = colour },
.{ .position = pos3, .colour = colour },
});
}
fn pdrawTexture(pos0: Vec2f, pos1: Vec2f, pos2: Vec2f, pos3: Vec2f, srcrect: Rectangle, colour: Colour) Error!void {
if (!prenderer2D.textured) return Error.InvalidBatch;
switch (prenderer2D.tag) {
Renderer2DBatchTag.triangles, Renderer2DBatchTag.lines => {
return Error.InvalidBatch;
},
else => {},
}
const width: f32 = @intToFloat(f32, prenderer2D.current_texture.width);
const height: f32 = @intToFloat(f32, prenderer2D.current_texture.height);
var src = srcrect;
var flipX: bool = true;
if (srcrect.width > 0) {
flipX = false;
src.width *= -1;
}
if (srcrect.height < 0) {
src.y -= src.height;
}
const t0 = Vec2f{
.x = if (flipX) src.x / width else (src.x + src.width) / width,
.y = src.y / height,
};
const t1 = Vec2f{
.x = if (flipX) (src.x + src.width) / width else src.x / width,
.y = src.y / height,
};
const t2 = Vec2f{
.x = if (flipX) (src.x + src.width) / width else src.x / width,
.y = (src.y + src.height) / height,
};
const t3 = Vec2f{
.x = if (flipX) src.x / width else (src.x + src.width) / width,
.y = (src.y + src.height) / height,
};
try prenderer2D.current_quadbatch_texture.submitDrawable([Batch2DQuadTexture.max_vertex_count]Vertex2DTexture{
.{ .position = pos0, .texcoord = t0, .colour = colour },
.{ .position = pos1, .texcoord = t1, .colour = colour },
.{ .position = pos2, .texcoord = t2, .colour = colour },
.{ .position = pos3, .texcoord = t3, .colour = colour },
});
} | src/kiragine/renderer.zig |
const Self = @This();
const std = @import("std");
const util = @import("util.zig");
const Server = @import("Server.zig");
const Mode = @import("Mode.zig");
const AttachMode = @import("view_stack.zig").AttachMode;
const View = @import("View.zig");
pub const FocusFollowsCursorMode = enum {
disabled,
/// Only change focus on entering a surface
normal,
};
pub const WarpCursorMode = enum {
disabled,
@"on-output-change",
};
/// Color of background in RGBA (alpha should only affect nested sessions)
background_color: [4]f32 = [_]f32{ 0.0, 0.16862745, 0.21176471, 1.0 }, // Solarized base03
/// Width of borders in pixels
border_width: u32 = 2,
/// Color of border of focused window in RGBA
border_color_focused: [4]f32 = [_]f32{ 0.57647059, 0.63137255, 0.63137255, 1.0 }, // Solarized base1
/// Color of border of unfocused window in RGBA
border_color_unfocused: [4]f32 = [_]f32{ 0.34509804, 0.43137255, 0.45882353, 1.0 }, // Solarized base01
/// Color of border of urgent window in RGBA
border_color_urgent: [4]f32 = [_]f32{ 0.86274510, 0.19607843, 0.18431373, 1.0 }, // Solarized red
/// Map of keymap mode name to mode id
mode_to_id: std.StringHashMap(usize),
/// All user-defined keymap modes, indexed by mode id
modes: std.ArrayList(Mode),
/// Sets of app_ids and titles which will be started floating
float_filter_app_ids: std.StringHashMapUnmanaged(void) = .{},
float_filter_titles: std.StringHashMapUnmanaged(void) = .{},
/// Sets of app_ids and titles which are allowed to use client side decorations
csd_filter_app_ids: std.StringHashMapUnmanaged(void) = .{},
csd_filter_titles: std.StringHashMapUnmanaged(void) = .{},
/// The selected focus_follows_cursor mode
focus_follows_cursor: FocusFollowsCursorMode = .disabled,
/// If true, the cursor warps to the center of the focused output
warp_cursor: WarpCursorMode = .disabled,
/// The default layout namespace for outputs which have never had a per-output
/// value set. Call Output.handleLayoutNamespaceChange() on setting this if
/// Output.layout_namespace is null.
default_layout_namespace: []const u8 = &[0]u8{},
/// Determines where new views will be attached to the view stack.
attach_mode: AttachMode = .top,
/// Keyboard repeat rate in characters per second
repeat_rate: u31 = 25,
/// Keyboard repeat delay in milliseconds
repeat_delay: u31 = 600,
pub fn init() !Self {
var self = Self{
.mode_to_id = std.StringHashMap(usize).init(util.gpa),
.modes = std.ArrayList(Mode).init(util.gpa),
};
errdefer self.deinit();
// Start with two empty modes, "normal" and "locked"
try self.modes.ensureCapacity(2);
{
// Normal mode, id 0
const owned_slice = try std.mem.dupe(util.gpa, u8, "normal");
try self.mode_to_id.putNoClobber(owned_slice, 0);
self.modes.appendAssumeCapacity(Mode.init());
}
{
// Locked mode, id 1
const owned_slice = try std.mem.dupe(util.gpa, u8, "locked");
try self.mode_to_id.putNoClobber(owned_slice, 1);
self.modes.appendAssumeCapacity(Mode.init());
}
return self;
}
pub fn deinit(self: *Self) void {
{
var it = self.mode_to_id.keyIterator();
while (it.next()) |key| util.gpa.free(key.*);
self.mode_to_id.deinit();
}
for (self.modes.items) |mode| mode.deinit();
self.modes.deinit();
{
var it = self.float_filter_app_ids.keyIterator();
while (it.next()) |key| util.gpa.free(key.*);
self.float_filter_app_ids.deinit(util.gpa);
}
{
var it = self.float_filter_titles.keyIterator();
while (it.next()) |key| util.gpa.free(key.*);
self.float_filter_titles.deinit(util.gpa);
}
{
var it = self.csd_filter_app_ids.keyIterator();
while (it.next()) |key| util.gpa.free(key.*);
self.csd_filter_app_ids.deinit(util.gpa);
}
{
var it = self.csd_filter_titles.keyIterator();
while (it.next()) |key| util.gpa.free(key.*);
self.csd_filter_titles.deinit(util.gpa);
}
util.gpa.free(self.default_layout_namespace);
}
pub fn shouldFloat(self: Self, view: *View) bool {
if (view.getAppId()) |app_id| {
if (self.float_filter_app_ids.contains(std.mem.span(app_id))) {
return true;
}
}
if (view.getTitle()) |title| {
if (self.float_filter_titles.contains(std.mem.span(title))) {
return true;
}
}
return false;
}
pub fn csdAllowed(self: Self, view: *View) bool {
if (view.getAppId()) |app_id| {
if (self.csd_filter_app_ids.contains(std.mem.span(app_id))) {
return true;
}
}
if (view.getTitle()) |title| {
if (self.csd_filter_titles.contains(std.mem.span(title))) {
return true;
}
}
return false;
} | source/river-0.1.0/river/Config.zig |
const std = @import("std");
const print = std.debug.print;
const List = std.ArrayList;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day14.txt");
const Rule = struct {
pair: []const u8,
insert: u8,
};
const Pair = struct {
a: u8,
b: u8,
pub fn new(a: u8, b: u8) @This() {
return .{
.a = a,
.b = b,
};
}
};
pub fn main() !void {
var lines = try util.toStrSlice(data, "\n");
const template = lines[0];
var polymer = List(u8).init(gpa);
defer polymer.deinit();
for (template) |c| {
try polymer.append(c);
}
var rules = List(Rule).init(gpa);
defer rules.deinit();
for (lines[1..]) |line| {
var rule = try util.parseInto(Rule, line, " -> ");
try rules.append(rule);
}
{
var step: usize = 0;
while (step < 10) : (step += 1) {
var build = List(u8).init(gpa);
defer build.deinit();
var it: usize = 0;
while (it < polymer.items.len - 1) : (it += 1) {
try build.append(polymer.items[it]);
for (rules.items) |rule| {
if (util.streq(rule.pair, polymer.items[it .. it + 2])) {
try build.append(rule.insert);
}
}
}
try build.append(polymer.items[polymer.items.len - 1]);
polymer.clearAndFree();
for (build.items) |c| {
try polymer.append(c);
}
}
var counts = [_]?usize{null} ** 26;
var min: usize = std.math.maxInt(usize);
var max: usize = 0;
for (polymer.items) |c| {
if (counts[c - 'A']) |*count| {
count.* += 1;
} else counts[c - 'A'] = 1;
}
for (counts) |c| {
if (c) |*count| {
if (count.* < min) min = count.*;
if (count.* > max) max = count.*;
}
}
print("{}\n", .{max - min});
}
{
var pairs = util.Counter(Pair).init(gpa);
defer pairs.deinit();
for (template[0 .. template.len - 1]) |_, i| {
try pairs.add(Pair.new(template[i], template[i + 1]));
}
var step: usize = 0;
var chars = util.Counter(u8).init(gpa);
defer chars.deinit();
while (step < 40) : (step += 1) {
chars.counter.clearAndFree();
var new_pairs = util.Counter(Pair).init(gpa);
var it = pairs.counter.iterator();
var i: usize = 0;
while (it.next()) |item| : (i += 1) {
for (rules.items) |rule| {
if (rule.pair[0] == item.key_ptr.*.a and rule.pair[1] == item.key_ptr.*.b) {
try chars.addCount(rule.pair[0], item.value_ptr.*);
try chars.addCount(rule.insert, item.value_ptr.*);
var p = Pair.new(rule.pair[0], rule.insert);
try new_pairs.addCount(p, item.value_ptr.*);
p = Pair.new(rule.insert, rule.pair[1]);
try new_pairs.addCount(p, item.value_ptr.*);
}
}
if (i == pairs.counter.count() - 1) {
try chars.add(item.key_ptr.*.b);
}
}
pairs = new_pairs;
}
var min: usize = std.math.maxInt(usize);
var max: usize = 0;
var it = chars.counter.iterator();
while (it.next()) |val| {
if (val.value_ptr.* > max) max = val.value_ptr.*;
if (val.value_ptr.* < min) min = val.value_ptr.*;
}
// TODO: off by one here...
print("{}\n", .{max - min + 1});
}
} | 2021/src/day14.zig |
const std = @import("std");
const id3v2 = @import("id3v2.zig");
const id3v2_data = @import("id3v2_data.zig");
const id3v1 = @import("id3v1.zig");
const flac = @import("flac.zig");
const vorbis = @import("vorbis.zig");
const ape = @import("ape.zig");
const mp4 = @import("mp4.zig");
const Allocator = std.mem.Allocator;
const fmtUtf8SliceEscapeUpper = @import("util.zig").fmtUtf8SliceEscapeUpper;
const BufferedStreamSource = @import("buffered_stream_source.zig").BufferedStreamSource;
const time = std.time;
const Timer = time.Timer;
var timer: Timer = undefined;
pub fn readAll(allocator: Allocator, stream_source: *std.io.StreamSource) !AllMetadata {
timer = try Timer.start();
// Note: Using a buffered stream source here doesn't actually seem to make much
// difference performance-wise for most files. However, it probably does give a performance
// boost when reading unsynch files, since UnsynchCapableReader reads byte-by-byte
// when it's reading ID3v2.3 unsynch tags.
//
// TODO: unsynch ID3v2.3 tags might be rare enough that the buffering is just
// not necessary
//
// Also, if the buffer is too large then it seems to actually start slowing things down,
// presumably because it starts filling the buffer with bytes that are going to be skipped
// anyway so it's just doing extra work for no reason.
const buffer_size = 512;
var buffered_stream_source = BufferedStreamSource(buffer_size).init(stream_source);
var reader = buffered_stream_source.reader();
var seekable_stream = buffered_stream_source.seekableStream();
var all_metadata = std.ArrayList(TypedMetadata).init(allocator);
errdefer {
var cleanup_helper = AllMetadata{
.allocator = allocator,
.tags = all_metadata.toOwnedSlice(),
};
cleanup_helper.deinit();
}
var time_taken = timer.read();
std.debug.print("setup: {}us\n", .{time_taken / time.ns_per_us});
timer.reset();
// TODO: this won't handle id3v2 when a SEEK frame is used
while (true) {
const initial_pos = try seekable_stream.getPos();
var id3v2_meta: ?ID3v2Metadata = id3v2.read(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (id3v2_meta != null) {
{
errdefer id3v2_meta.?.deinit();
try all_metadata.append(TypedMetadata{ .id3v2 = id3v2_meta.? });
}
continue;
}
try seekable_stream.seekTo(initial_pos);
var flac_metadata: ?Metadata = flac.read(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (flac_metadata != null) {
{
errdefer flac_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .flac = flac_metadata.? });
}
continue;
}
try seekable_stream.seekTo(initial_pos);
var vorbis_metadata: ?Metadata = vorbis.read(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (vorbis_metadata != null) {
{
errdefer vorbis_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .vorbis = vorbis_metadata.? });
}
continue;
}
try seekable_stream.seekTo(initial_pos);
var ape_metadata: ?APEMetadata = ape.readFromHeader(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (ape_metadata != null) {
{
errdefer ape_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .ape = ape_metadata.? });
}
continue;
}
try seekable_stream.seekTo(initial_pos);
var mp4_metadata: ?Metadata = mp4.read(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (mp4_metadata != null) {
{
errdefer mp4_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .mp4 = mp4_metadata.? });
}
continue;
}
// if we get here, then we're out of valid tag headers to parse
break;
}
time_taken = timer.read();
std.debug.print("prefixed tags: {}us\n", .{time_taken / time.ns_per_us});
timer.reset();
const end_pos = try seekable_stream.getEndPos();
try seekable_stream.seekTo(end_pos);
const last_tag_end_offset: ?usize = offset: {
if (all_metadata.items.len == 0) break :offset null;
const last_tag = all_metadata.items[all_metadata.items.len - 1];
break :offset switch (last_tag) {
.id3v1, .flac, .vorbis, .mp4 => |v| v.end_offset,
.id3v2 => |v| v.metadata.end_offset,
.ape => |v| v.metadata.end_offset,
};
};
while (true) {
const initial_pos = try seekable_stream.getPos();
// we don't want to read any tags that have already been read, so
// if we're going to read into the last already read tag, then bail out
if (last_tag_end_offset != null and try seekable_stream.getPos() <= last_tag_end_offset.?) {
break;
}
var id3v1_metadata: ?Metadata = id3v1.read(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (id3v1_metadata != null) {
{
errdefer id3v1_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .id3v1 = id3v1_metadata.? });
}
try seekable_stream.seekTo(id3v1_metadata.?.start_offset);
continue;
}
try seekable_stream.seekTo(initial_pos);
var ape_metadata: ?APEMetadata = ape.readFromFooter(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (ape_metadata != null) {
{
errdefer ape_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .ape = ape_metadata.? });
}
try seekable_stream.seekTo(ape_metadata.?.metadata.start_offset);
continue;
}
try seekable_stream.seekTo(initial_pos);
var id3v2_metadata: ?ID3v2Metadata = id3v2.readFromFooter(allocator, reader, seekable_stream) catch |e| switch (e) {
error.OutOfMemory => |err| return err,
else => null,
};
if (id3v2_metadata != null) {
{
errdefer id3v2_metadata.?.deinit();
try all_metadata.append(TypedMetadata{ .id3v2 = id3v2_metadata.? });
}
try seekable_stream.seekTo(id3v2_metadata.?.metadata.start_offset);
continue;
}
// if we get here, then we're out of valid tag headers to parse
break;
}
time_taken = timer.read();
std.debug.print("suffixed tags: {}us\n", .{time_taken / time.ns_per_us});
timer.reset();
return AllMetadata{
.allocator = allocator,
.tags = all_metadata.toOwnedSlice(),
};
}
pub const MetadataType = enum {
id3v1,
id3v2,
ape,
flac,
vorbis,
mp4,
};
pub const TypedMetadata = union(MetadataType) {
id3v1: Metadata,
id3v2: ID3v2Metadata,
ape: APEMetadata,
flac: Metadata,
vorbis: Metadata,
mp4: Metadata,
/// Convenience function to get the Metadata for any TypedMetadata
pub fn getMetadata(typed_meta: TypedMetadata) Metadata {
return switch (typed_meta) {
.id3v1, .flac, .vorbis, .mp4 => |val| val,
.id3v2 => |val| val.metadata,
.ape => |val| val.metadata,
};
}
};
pub const AllMetadata = struct {
allocator: Allocator,
tags: []TypedMetadata,
pub fn deinit(self: *AllMetadata) void {
for (self.tags) |*tag| {
// using a pointer and then deferencing it allows
// the final capture to be non-const
// TODO: this feels hacky
switch (tag.*) {
.id3v1, .flac, .vorbis, .mp4 => |*metadata| {
metadata.deinit();
},
.id3v2 => |*id3v2_metadata| {
id3v2_metadata.deinit();
},
.ape => |*ape_metadata| {
ape_metadata.deinit();
},
}
}
self.allocator.free(self.tags);
}
pub fn dump(self: *const AllMetadata) void {
for (self.tags) |tag| {
switch (tag) {
.id3v1 => |*id3v1_meta| {
std.debug.print("# ID3v1 0x{x}-0x{x}\n", .{ id3v1_meta.start_offset, id3v1_meta.end_offset });
id3v1_meta.map.dump();
},
.flac => |*flac_meta| {
std.debug.print("# FLAC 0x{x}-0x{x}\n", .{ flac_meta.start_offset, flac_meta.end_offset });
flac_meta.map.dump();
},
.vorbis => |*vorbis_meta| {
std.debug.print("# Vorbis 0x{x}-0x{x}\n", .{ vorbis_meta.start_offset, vorbis_meta.end_offset });
vorbis_meta.map.dump();
},
.id3v2 => |*id3v2_meta| {
std.debug.print("# ID3v2 v2.{d} 0x{x}-0x{x}\n", .{ id3v2_meta.header.major_version, id3v2_meta.metadata.start_offset, id3v2_meta.metadata.end_offset });
id3v2_meta.dump();
},
.ape => |*ape_meta| {
std.debug.print("# APEv{d} 0x{x}-0x{x}\n", .{ ape_meta.header_or_footer.version, ape_meta.metadata.start_offset, ape_meta.metadata.end_offset });
ape_meta.metadata.map.dump();
},
.mp4 => |*mp4_meta| {
std.debug.print("# MP4 0x{x}-0x{x}\n", .{ mp4_meta.start_offset, mp4_meta.end_offset });
mp4_meta.map.dump();
},
}
}
}
/// Returns an allocated slice of pointers to all metadata of the given type.
/// Caller is responsible for freeing the slice's memory.
pub fn getAllMetadataOfType(self: AllMetadata, allocator: Allocator, comptime tag_type: MetadataType) ![]*std.meta.TagPayload(TypedMetadata, tag_type) {
const T = std.meta.TagPayload(TypedMetadata, tag_type);
var buf = std.ArrayList(*T).init(allocator);
errdefer buf.deinit();
for (self.tags) |*tag| {
if (@as(MetadataType, tag.*) == tag_type) {
var val = &@field(tag.*, @tagName(tag_type));
try buf.append(val);
}
}
return buf.toOwnedSlice();
}
pub fn getFirstMetadataOfType(self: AllMetadata, comptime tag_type: MetadataType) ?*std.meta.TagPayload(TypedMetadata, tag_type) {
for (self.tags) |*tag| {
if (@as(MetadataType, tag.*) == tag_type) {
return &@field(tag.*, @tagName(tag_type));
}
}
return null;
}
pub fn getLastMetadataOfType(self: AllMetadata, comptime tag_type: MetadataType) ?*std.meta.TagPayload(TypedMetadata, tag_type) {
var i = self.tags.len;
while (i != 0) {
i -= 1;
if (@as(MetadataType, self.tags[i]) == tag_type) {
return &@field(self.tags[i], @tagName(tag_type));
}
}
return null;
}
};
pub const AllID3v2Metadata = struct {
allocator: Allocator,
tags: []ID3v2Metadata,
pub fn deinit(self: *AllID3v2Metadata) void {
for (self.tags) |*tag| {
tag.deinit();
}
self.allocator.free(self.tags);
}
};
pub const ID3v2Metadata = struct {
header: id3v2.ID3Header,
metadata: Metadata,
user_defined: MetadataMap,
comments: id3v2_data.FullTextMap,
unsynchronized_lyrics: id3v2_data.FullTextMap,
pub fn init(allocator: Allocator, header: id3v2.ID3Header, start_offset: usize, end_offset: usize) ID3v2Metadata {
return .{
.header = header,
.metadata = Metadata.initWithOffsets(allocator, start_offset, end_offset),
.user_defined = MetadataMap.init(allocator),
.comments = id3v2_data.FullTextMap.init(allocator),
.unsynchronized_lyrics = id3v2_data.FullTextMap.init(allocator),
};
}
pub fn deinit(self: *ID3v2Metadata) void {
self.metadata.deinit();
self.user_defined.deinit();
self.comments.deinit();
self.unsynchronized_lyrics.deinit();
}
pub fn dump(self: ID3v2Metadata) void {
self.metadata.map.dump();
self.user_defined.dump();
if (self.comments.entries.items.len > 0) {
std.debug.print("-- COMM --\n", .{});
self.comments.dump();
}
if (self.unsynchronized_lyrics.entries.items.len > 0) {
std.debug.print("-- USLT --\n", .{});
self.unsynchronized_lyrics.dump();
}
}
};
pub const AllAPEMetadata = struct {
allocator: Allocator,
tags: []APEMetadata,
pub fn deinit(self: *AllAPEMetadata) void {
for (self.tags) |*tag| {
tag.deinit();
}
self.allocator.free(self.tags);
}
};
pub const APEMetadata = struct {
metadata: Metadata,
header_or_footer: ape.APEHeader,
pub fn init(allocator: Allocator, header_or_footer: ape.APEHeader, start_offset: usize, end_offset: usize) APEMetadata {
return .{
.metadata = Metadata.initWithOffsets(allocator, start_offset, end_offset),
.header_or_footer = header_or_footer,
};
}
pub fn deinit(self: *APEMetadata) void {
self.metadata.deinit();
}
};
pub const Metadata = struct {
map: MetadataMap,
start_offset: usize,
end_offset: usize,
pub fn init(allocator: Allocator) Metadata {
return Metadata.initWithOffsets(allocator, undefined, undefined);
}
pub fn initWithOffsets(allocator: Allocator, start_offset: usize, end_offset: usize) Metadata {
return .{
.map = MetadataMap.init(allocator),
.start_offset = start_offset,
.end_offset = end_offset,
};
}
pub fn deinit(self: *Metadata) void {
self.map.deinit();
}
};
/// HashMap-like but can handle multiple values with the same key.
pub const MetadataMap = struct {
allocator: Allocator,
entries: EntryList,
name_to_indexes: NameToIndexesMap,
pub const Entry = struct {
name: []const u8,
value: []const u8,
};
const EntryList = std.ArrayListUnmanaged(Entry);
const IndexList = std.ArrayListUnmanaged(usize);
const NameToIndexesMap = std.StringHashMapUnmanaged(IndexList);
pub fn init(allocator: Allocator) MetadataMap {
return .{
.allocator = allocator,
.entries = .{},
.name_to_indexes = .{},
};
}
pub fn deinit(self: *MetadataMap) void {
for (self.entries.items) |item| {
self.allocator.free(item.value);
}
self.entries.deinit(self.allocator);
var map_it = self.name_to_indexes.iterator();
while (map_it.next()) |entry| {
entry.value_ptr.deinit(self.allocator);
self.allocator.free(entry.key_ptr.*);
}
self.name_to_indexes.deinit(self.allocator);
}
pub fn getOrPutEntry(self: *MetadataMap, name: []const u8) !NameToIndexesMap.GetOrPutResult {
return blk: {
if (self.name_to_indexes.getEntry(name)) |entry| {
break :blk NameToIndexesMap.GetOrPutResult{
.key_ptr = entry.key_ptr,
.value_ptr = entry.value_ptr,
.found_existing = true,
};
} else {
var name_dup = try self.allocator.dupe(u8, name);
errdefer self.allocator.free(name_dup);
const entry = try self.name_to_indexes.getOrPutValue(self.allocator, name_dup, IndexList{});
break :blk NameToIndexesMap.GetOrPutResult{
.key_ptr = entry.key_ptr,
.value_ptr = entry.value_ptr,
.found_existing = false,
};
}
};
}
pub fn getOrPutEntryNoDupe(self: *MetadataMap, name: []const u8) !NameToIndexesMap.GetOrPutResult {
return blk: {
if (self.name_to_indexes.getEntry(name)) |entry| {
break :blk NameToIndexesMap.GetOrPutResult{
.key_ptr = entry.key_ptr,
.value_ptr = entry.value_ptr,
.found_existing = true,
};
} else {
const entry = try self.name_to_indexes.getOrPutValue(self.allocator, name, IndexList{});
break :blk NameToIndexesMap.GetOrPutResult{
.key_ptr = entry.key_ptr,
.value_ptr = entry.value_ptr,
.found_existing = false,
};
}
};
}
pub fn appendToEntry(self: *MetadataMap, entry: NameToIndexesMap.GetOrPutResult, value: []const u8) !void {
const entry_index = entry_index: {
const value_dup = try self.allocator.dupe(u8, value);
errdefer self.allocator.free(value_dup);
const entry_index = self.entries.items.len;
try self.entries.append(self.allocator, Entry{
.name = entry.key_ptr.*,
.value = value_dup,
});
break :entry_index entry_index;
};
try entry.value_ptr.append(self.allocator, entry_index);
}
pub fn appendToEntryNoDupe(self: *MetadataMap, entry: NameToIndexesMap.GetOrPutResult, value: []const u8) !void {
const entry_index = entry_index: {
const entry_index = self.entries.items.len;
try self.entries.append(self.allocator, Entry{
.name = entry.key_ptr.*,
.value = value,
});
break :entry_index entry_index;
};
try entry.value_ptr.append(self.allocator, entry_index);
}
pub fn put(self: *MetadataMap, name: []const u8, value: []const u8) !void {
const indexes_entry = try self.getOrPutEntry(name);
try self.appendToEntry(indexes_entry, value);
}
pub fn putNoDupe(self: *MetadataMap, name: []const u8, value: []const u8) !void {
const indexes_entry = try self.getOrPutEntryNoDupe(name);
try self.appendToEntryNoDupe(indexes_entry, value);
}
pub fn putOrReplaceFirst(self: *MetadataMap, name: []const u8, new_value: []const u8) !void {
const maybe_entry_index_list = self.name_to_indexes.getPtr(name);
if (maybe_entry_index_list == null or maybe_entry_index_list.?.items.len == 0) {
return self.put(name, new_value);
}
const entry_index_list = maybe_entry_index_list.?;
const entry_index = entry_index_list.items[0];
var entry = &self.entries.items[entry_index];
const new_value_dup = try self.allocator.dupe(u8, new_value);
self.allocator.free(entry.value);
entry.value = new_value_dup;
}
pub fn contains(self: *MetadataMap, name: []const u8) bool {
return self.name_to_indexes.contains(name);
}
pub fn valueCount(self: *MetadataMap, name: []const u8) ?usize {
const entry_index_list = (self.name_to_indexes.getPtr(name)) orelse return null;
return entry_index_list.items.len;
}
pub const ValueIterator = struct {
metadata_map: *const MetadataMap,
index_list: []usize,
index: usize,
pub fn next(self: *ValueIterator) ?[]const u8 {
if (self.index >= self.index_list.len) {
return null;
}
const entry_index = self.index_list[self.index];
self.index += 1;
return self.metadata_map.entries.items[entry_index].value;
}
};
pub fn valueIterator(self: *MetadataMap, name: []const u8) ValueIterator {
if (self.name_to_indexes.getPtr(name)) |entry_index_list| {
return ValueIterator{
.metadata_map = self,
.index_list = entry_index_list.items,
.index = 0,
};
} else {
return ValueIterator{
.metadata_map = self,
.index_list = &[_]usize{},
.index = 0,
};
}
}
pub fn getAllAlloc(self: *MetadataMap, allocator: Allocator, name: []const u8) !?[][]const u8 {
const entry_index_list = (self.name_to_indexes.getPtr(name)) orelse return null;
if (entry_index_list.items.len == 0) return null;
const buf = try allocator.alloc([]const u8, entry_index_list.items.len);
for (entry_index_list.items) |entry_index, i| {
buf[i] = self.entries.items[entry_index].value;
}
return buf;
}
pub fn getFirst(self: *MetadataMap, name: []const u8) ?[]const u8 {
const entry_index_list = (self.name_to_indexes.getPtr(name)) orelse return null;
if (entry_index_list.items.len == 0) return null;
const entry_index = entry_index_list.items[0];
return self.entries.items[entry_index].value;
}
pub fn getJoinedAlloc(self: *MetadataMap, allocator: Allocator, name: []const u8, separator: []const u8) !?[]u8 {
const entry_index_list = (self.name_to_indexes.getPtr(name)) orelse return null;
if (entry_index_list.items.len == 0) return null;
if (entry_index_list.items.len == 1) {
const entry_index = entry_index_list.items[0];
const duped_value = try allocator.dupe(u8, self.entries.items[entry_index].value);
return duped_value;
} else {
var values = try allocator.alloc([]const u8, entry_index_list.items.len);
defer allocator.free(values);
for (entry_index_list.items) |entry_index, i| {
values[i] = self.entries.items[entry_index].value;
}
const joined = try std.mem.join(allocator, separator, values);
return joined;
}
}
pub fn dump(metadata: *const MetadataMap) void {
for (metadata.entries.items) |entry| {
std.debug.print("{s}={s}\n", .{ fmtUtf8SliceEscapeUpper(entry.name), fmtUtf8SliceEscapeUpper(entry.value) });
}
}
};
test "metadata map" {
var allocator = std.testing.allocator;
var metadata = MetadataMap.init(allocator);
defer metadata.deinit();
try std.testing.expect(!metadata.contains("date"));
try metadata.put("date", "2018");
try metadata.put("date", "2018-04-25");
const joined_date = (try metadata.getJoinedAlloc(allocator, "date", ";")).?;
defer allocator.free(joined_date);
try std.testing.expectEqualStrings("2018;2018-04-25", joined_date);
try std.testing.expect(metadata.contains("date"));
try std.testing.expect(!metadata.contains("missing"));
try metadata.putOrReplaceFirst("date", "2019");
const new_date = metadata.getFirst("date").?;
try std.testing.expectEqualStrings("2019", new_date);
var date_it = metadata.valueIterator("date");
var num_dates: usize = 0;
while (date_it.next()) |value| {
switch (num_dates) {
0 => try std.testing.expectEqualStrings("2019", value),
1 => try std.testing.expectEqualStrings("2018-04-25", value),
else => unreachable,
}
num_dates += 1;
}
try std.testing.expectEqual(@as(usize, 2), num_dates);
}
test "AllMetadata.getXOfType" {
var allocator = std.testing.allocator;
var metadata_buf = std.ArrayList(TypedMetadata).init(allocator);
defer metadata_buf.deinit();
try metadata_buf.append(TypedMetadata{ .id3v2 = ID3v2Metadata{
.metadata = undefined,
.user_defined = undefined,
.header = undefined,
.comments = undefined,
.unsynchronized_lyrics = undefined,
} });
try metadata_buf.append(TypedMetadata{ .id3v2 = ID3v2Metadata{
.metadata = undefined,
.user_defined = undefined,
.header = undefined,
.comments = undefined,
.unsynchronized_lyrics = undefined,
} });
try metadata_buf.append(TypedMetadata{ .flac = undefined });
try metadata_buf.append(TypedMetadata{ .id3v1 = undefined });
try metadata_buf.append(TypedMetadata{ .id3v1 = undefined });
var all = AllMetadata{
.allocator = allocator,
.tags = metadata_buf.toOwnedSlice(),
};
defer all.deinit();
const all_id3v2 = try all.getAllMetadataOfType(allocator, .id3v2);
defer allocator.free(all_id3v2);
try std.testing.expectEqual(@as(usize, 2), all_id3v2.len);
const first_id3v2 = all.getFirstMetadataOfType(.id3v2);
try std.testing.expect(first_id3v2 == &all.tags[0].id3v2);
const last_id3v2 = all.getLastMetadataOfType(.id3v2).?;
try std.testing.expect(last_id3v2 == &all.tags[1].id3v2);
const last_id3v1 = all.getLastMetadataOfType(.id3v1).?;
try std.testing.expect(last_id3v1 == &all.tags[all.tags.len - 1].id3v1);
try std.testing.expect(null == all.getFirstMetadataOfType(.vorbis));
} | src/metadata.zig |
const std = @import("std");
const c = @import("internal/c.zig");
const internal = @import("internal/internal.zig");
const log = std.log.scoped(.git);
const git = @import("git.zig");
/// An instance for a custom memory allocator
///
/// Setting the pointers of this structure allows the developer to implement custom memory allocators.
/// The global memory allocator can be set by using `Handle.optionSetAllocator` function.
/// Keep in mind that all fields need to be set to a proper function.
pub const GitAllocator = extern struct {
/// Allocate `n` bytes of memory
malloc: fn (n: usize, file: [*:0]const u8, line: c_int) callconv(.C) ?*anyopaque,
/// Allocate memory for an array of `nelem` elements, where each element has a size of `elsize`.
/// Returned memory shall be initialized to all-zeroes
calloc: fn (nelem: usize, elsize: usize, file: [*:0]const u8, line: c_int) callconv(.C) ?*anyopaque,
/// Allocate memory for the string `str` and duplicate its contents.
strdup: fn (str: [*:0]const u8, file: [*:0]const u8, line: c_int) callconv(.C) [*:0]const u8,
/// Equivalent to the `gstrdup` function, but only duplicating at most `n + 1` bytes
strndup: fn (str: [*:0]const u8, n: usize, file: [*:0]const u8, line: c_int) callconv(.C) [*:0]const u8,
/// Equivalent to `gstrndup`, but will always duplicate exactly `n` bytes of `str`. Thus, out of bounds reads at `str`
/// may happen.
substrdup: fn (str: [*:0]const u8, n: usize, file: [*:0]const u8, line: c_int) callconv(.C) [*:0]const u8,
/// This function shall deallocate the old object `ptr` and return a pointer to a new object that has the size specified by
/// size`. In case `ptr` is `null`, a new array shall be allocated.
realloc: fn (ptr: ?*anyopaque, size: usize, file: [*:0]const u8, line: c_int) callconv(.C) ?*anyopaque,
/// This function shall be equivalent to `grealloc`, but allocating `neleme * elsize` bytes.
reallocarray: fn (ptr: ?*anyopaque, nelem: usize, elsize: usize, file: [*:0]const u8, line: c_int) callconv(.C) ?*anyopaque,
/// This function shall allocate a new array of `nelem` elements, where each element has a size of `elsize` bytes.
mallocarray: fn (nelem: usize, elsize: usize, file: [*:0]const u8, line: c_int) callconv(.C) ?*anyopaque,
/// This function shall free the memory pointed to by `ptr`. In case `ptr` is `null`, this shall be a no-op.
free: fn (ptr: ?*anyopaque) callconv(.C) void,
test {
try std.testing.expectEqual(@sizeOf(c.git_allocator), @sizeOf(GitAllocator));
try std.testing.expectEqual(@bitSizeOf(c.git_allocator), @bitSizeOf(GitAllocator));
}
comptime {
std.testing.refAllDecls(@This());
}
};
comptime {
std.testing.refAllDecls(@This());
} | src/alloc.zig |
const std = @import("std");
const c = @import("internal/c.zig");
const internal = @import("internal/internal.zig");
const log = std.log.scoped(.git);
const git = @import("git.zig");
pub const Indexer = opaque {
/// Add data to the indexer
///
/// ## Parameters
/// * `data` - The data to add
/// * `stats` - Stat storage
pub fn append(self: *Indexer, data: []const u8, stats: *IndexerProgress) !void {
log.debug("Indexer.append called, data_len: {}, stats: {}", .{ data.len, stats });
try internal.wrapCall("git_indexer_append", .{
@ptrCast(*c.git_indexer, self),
data.ptr,
data.len,
@ptrCast(*c.git_indexer_progress, stats),
});
log.debug("successfully appended to indexer", .{});
}
/// Finalize the pack and index
///
/// Resolve any pending deltas and write out the index file
///
/// ## Parameters
/// * `data` - The data to add
/// * `stats` - Stat storage
pub fn commit(self: *Indexer, stats: *IndexerProgress) !void {
log.debug("Indexer.commit called, stats: {}", .{stats});
try internal.wrapCall("git_indexer_commit", .{
@ptrCast(*c.git_indexer, self),
@ptrCast(*c.git_indexer_progress, stats),
});
log.debug("successfully commited indexer", .{});
}
/// Get the packfile's hash
///
/// A packfile's name is derived from the sorted hashing of all object names. This is only correct after the index has been
/// finalized.
pub fn hash(self: *const Indexer) ?*const git.Oid {
log.debug("Indexer.hash called", .{});
return @ptrCast(
?*const git.Oid,
c.git_indexer_hash(@ptrCast(*const c.git_indexer, self)),
);
}
pub fn deinit(self: *Indexer) void {
log.debug("Indexer.deinit called", .{});
c.git_indexer_free(@ptrCast(*c.git_indexer, self));
log.debug("Indexer freed successfully", .{});
}
comptime {
std.testing.refAllDecls(@This());
}
};
/// This structure is used to provide callers information about the progress of indexing a packfile, either directly or part
/// of a fetch or clone that downloads a packfile.
pub const IndexerProgress = extern struct {
/// number of objects in the packfile being indexed
total_objects: c_int,
/// received objects that have been hashed
indexed_objects: c_int,
/// received_objects: objects which have been downloaded
received_objects: c_int,
/// locally-available objects that have been injected in order to fix a thin pack
local_objects: c_int,
/// number of deltas in the packfile being indexed
total_deltas: c_int,
/// received deltas that have been indexed
indexed_deltas: c_int,
/// size of the packfile received up to now
received_bytes: usize,
test {
try std.testing.expectEqual(@sizeOf(c.git_indexer_progress), @sizeOf(IndexerProgress));
try std.testing.expectEqual(@bitSizeOf(c.git_indexer_progress), @bitSizeOf(IndexerProgress));
}
comptime {
std.testing.refAllDecls(@This());
}
};
pub const IndexerOptions = struct {
/// permissions to use creating packfile or 0 for defaults
mode: c_uint = 0,
/// do connectivity checks for the received pack
verify: bool = false,
};
comptime {
std.testing.refAllDecls(@This());
} | src/indexer.zig |
const std = @import("std");
const pike = @import("pike.zig");
const mem = std.mem;
const meta = std.meta;
const math = std.math;
const testing = std.testing;
const assert = std.debug.assert;
pub const Waker = struct {
const EMPTY = 0;
const NOTIFIED: usize = 1;
const SHUTDOWN: usize = 2;
state: usize = EMPTY,
pub const Node = struct {
dead: bool = false,
task: pike.Task,
};
pub fn wait(self: *Waker, args: anytype) !void {
var node: Node = .{ .task = pike.Task.init(@frame()) };
suspend {
var state = @atomicLoad(usize, &self.state, .Monotonic);
while (true) {
const new_state = switch (state) {
EMPTY => @ptrToInt(&node),
NOTIFIED => EMPTY,
SHUTDOWN => {
node.dead = true;
pike.dispatch(&node.task, .{ .use_lifo = true });
break;
},
else => unreachable,
};
state = @cmpxchgWeak(
usize,
&self.state,
state,
new_state,
.Release,
.Monotonic,
) orelse {
if (new_state == EMPTY) pike.dispatch(&node.task, args);
break;
};
}
}
if (node.dead) return error.OperationCancelled;
}
pub fn notify(self: *Waker) ?*pike.Task {
var state = @atomicLoad(usize, &self.state, .Monotonic);
while (true) {
const new_state = switch (state) {
EMPTY => NOTIFIED,
NOTIFIED, SHUTDOWN => return null,
else => EMPTY,
};
state = @cmpxchgWeak(usize, &self.state, state, new_state, .Acquire, .Monotonic) orelse {
if (new_state == NOTIFIED) return null;
const node = @intToPtr(*Node, state);
return &node.task;
};
}
}
pub fn shutdown(self: *Waker) ?*pike.Task {
return switch (@atomicRmw(usize, &self.state, .Xchg, SHUTDOWN, .AcqRel)) {
EMPTY, NOTIFIED, SHUTDOWN => null,
else => |state| {
const node = @intToPtr(*Node, state);
node.dead = true;
return &node.task;
},
};
}
};
test "Waker.wait() / Waker.notify() / Waker.shutdown()" {
var waker: Waker = .{};
{
var frame = async waker.wait(.{});
pike.dispatch(waker.notify().?, .{});
try nosuspend await frame;
}
{
testing.expect(waker.shutdown() == null);
testing.expectError(error.OperationCancelled, nosuspend waker.wait(.{}));
}
}
pub fn PackedWaker(comptime Frame: type, comptime Set: type) type {
const set_fields = meta.fields(Set);
const set_count = set_fields.len;
return struct {
pub const FrameList = PackedList(Frame, Set);
pub const FrameNode = FrameList.Node;
const Self = @This();
ready: [set_count]bool = [_]bool{false} ** set_count,
heads: [set_count]?*FrameNode = [_]?*FrameNode{null} ** set_count,
pub fn wait(self: *Self, set: Set) bool {
var any_ready = false;
inline for (set_fields) |field, field_index| {
if (@field(set, field.name) and self.ready[field_index]) {
if (self.ready[field_index]) {
self.ready[field_index] = false;
any_ready = true;
}
}
}
return any_ready;
}
pub fn wake(self: *Self, set: Set) ?*FrameList.Node {
return FrameList.pop(&self.heads, set) orelse blk: {
inline for (set_fields) |field, field_index| {
if (@field(set, field.name) and self.heads[field_index] == null) {
self.ready[field_index] = true;
}
}
break :blk null;
};
}
pub fn next(self: *Self, set: Set) ?*FrameList.Node {
inline for (set_fields) |field, field_index| {
if (@field(set, field.name) and self.heads[field_index] == null) {
return null;
}
}
return FrameList.pop(&self.heads, set);
}
};
}
test "PackedWaker.wake() / PackedWaker.wait()" {
const Set = struct {
a: bool = false,
b: bool = false,
c: bool = false,
d: bool = false,
};
const Scope = struct {
inner: anyframe,
};
const Test = struct {
fn do(waker: *PackedWaker(*Scope, Set), set: Set, completed: *bool) callconv(.Async) void {
defer completed.* = true;
if (waker.wait(set)) return;
suspend {
var scope = Scope{ .inner = @frame() };
var node = meta.Child(@TypeOf(waker)).FrameNode{ .data = &scope };
meta.Child(@TypeOf(waker)).FrameList.append(&waker.heads, set, &node);
}
}
};
var waker: PackedWaker(*Scope, Set) = .{};
testing.expect(waker.wake(.{ .a = true, .b = true, .c = true, .d = true }) == null);
testing.expect(mem.allEqual(bool, &waker.ready, true));
testing.expect(waker.wait(.{ .a = true, .b = true, .c = true, .d = true }));
testing.expect(mem.allEqual(bool, &waker.ready, false));
var A_done = false;
var B_done = false;
var C_done = false;
var D_done = false;
var A = async Test.do(&waker, .{ .a = true, .c = true }, &A_done);
var B = async Test.do(&waker, .{ .a = true, .b = true, .c = true }, &B_done);
var C = async Test.do(&waker, .{ .a = true, .b = true, .d = true }, &C_done);
var D = async Test.do(&waker, .{ .d = true }, &D_done);
resume waker.wake(.{ .b = true }).?.data.inner;
nosuspend await B;
testing.expect(B_done);
resume waker.wake(.{ .b = true }).?.data.inner;
nosuspend await C;
testing.expect(C_done);
resume waker.wake(.{ .a = true }).?.data.inner;
nosuspend await A;
testing.expect(A_done);
resume waker.wake(.{ .d = true }).?.data.inner;
nosuspend await D;
testing.expect(D_done);
}
fn PackedList(comptime T: type, comptime U: type) type {
const set_fields = meta.fields(U);
const set_count = set_fields.len;
return struct {
const Self = @This();
pub const Node = struct {
data: T,
next: [set_count]?*Self.Node = [_]?*Node{null} ** set_count,
prev: [set_count]?*Self.Node = [_]?*Node{null} ** set_count,
};
pub fn append(heads: *[set_count]?*Self.Node, set: U, node: *Self.Node) void {
assert(mem.allEqual(?*Self.Node, &node.prev, null));
assert(mem.allEqual(?*Self.Node, &node.next, null));
inline for (set_fields) |field, i| {
if (@field(set, field.name)) {
if (heads[i]) |head| {
const tail = head.prev[i] orelse unreachable;
node.prev[i] = tail;
tail.next[i] = node;
head.prev[i] = node;
} else {
node.prev[i] = node;
heads[i] = node;
}
}
}
}
pub fn prepend(heads: *[set_count]?*Self.Node, set: U, node: *Self.Node) void {
assert(mem.allEqual(?*Self.Node, &node.prev, null));
assert(mem.allEqual(?*Self.Node, &node.next, null));
inline for (set_fields) |field, i| {
if (@field(set, field.name)) {
if (heads[i]) |head| {
node.prev[i] = head;
node.next[i] = head;
head.prev[i] = node;
heads[i] = node;
} else {
node.prev[i] = node;
heads[i] = node;
}
}
}
}
pub fn pop(heads: *[set_count]?*Self.Node, set: U) ?*Self.Node {
inline for (set_fields) |field, field_index| {
if (@field(set, field.name) and heads[field_index] != null) {
const head = heads[field_index] orelse unreachable;
comptime var j = 0;
inline while (j < set_count) : (j += 1) {
if (head.prev[j]) |prev| prev.next[j] = if (prev != head.next[j]) head.next[j] else null;
if (head.next[j]) |next| next.prev[j] = head.prev[j];
if (heads[j] == head) heads[j] = head.next[j];
}
return head;
}
}
return null;
}
};
}
test "PackedList.append() / PackedList.prepend() / PackedList.pop()" {
const Set = struct {
a: bool = false,
b: bool = false,
c: bool = false,
d: bool = false,
};
const U8List = PackedList(u8, Set);
const Node = U8List.Node;
var heads: [@sizeOf(Set)]?*Node = [_]?*Node{null} ** @sizeOf(Set);
var A = Node{ .data = 'A' };
var B = Node{ .data = 'B' };
var C = Node{ .data = 'C' };
var D = Node{ .data = 'D' };
U8List.append(&heads, .{ .a = true, .c = true }, &A);
U8List.append(&heads, .{ .a = true, .b = true, .c = true }, &B);
U8List.prepend(&heads, .{ .a = true, .b = true, .d = true }, &C);
U8List.append(&heads, .{ .d = true }, &D);
testing.expect(U8List.pop(&heads, .{ .b = true }).?.data == C.data);
testing.expect(U8List.pop(&heads, .{ .b = true }).?.data == B.data);
testing.expect(U8List.pop(&heads, .{ .a = true }).?.data == A.data);
testing.expect(U8List.pop(&heads, .{ .d = true }).?.data == D.data);
testing.expect(mem.allEqual(?*Node, &heads, null));
}
test "PackedList.append() / PackedList.prepend() / PackedList.pop()" {
const Set = struct {
a: bool = false,
b: bool = false,
c: bool = false,
d: bool = false,
};
const U8List = PackedList(u8, Set);
const Node = U8List.Node;
var heads: [@sizeOf(Set)]?*Node = [_]?*Node{null} ** @sizeOf(Set);
var A = Node{ .data = 'A' };
var B = Node{ .data = 'B' };
U8List.append(&heads, .{ .a = true, .b = true }, &A);
testing.expect(heads[0] == &A and heads[0].?.prev[0] == &A and heads[0].?.next[0] == null);
testing.expect(heads[1] == &A and heads[1].?.prev[1] == &A and heads[1].?.next[1] == null);
testing.expect(heads[2] == null);
testing.expect(heads[3] == null);
U8List.prepend(&heads, .{ .a = true, .c = true }, &B);
testing.expect(heads[0] == &B and heads[0].?.prev[0] == &A and heads[0].?.prev[0].?.next[0] == null);
testing.expect(heads[1] == &A and heads[1].?.prev[1] == &A and heads[1].?.prev[1].?.next[1] == null);
testing.expect(heads[2] == &B and heads[2].?.prev[2] == &B and heads[2].?.prev[2].?.next[2] == null);
testing.expect(heads[3] == null);
testing.expect(U8List.pop(&heads, .{ .a = true }).?.data == B.data);
testing.expect(heads[0] == &A);
testing.expect(heads[0].?.prev[0] == &A);
testing.expect(mem.allEqual(?*Node, &heads[0].?.next, null));
testing.expect(U8List.pop(&heads, .{ .a = true }).?.data == A.data);
testing.expect(mem.allEqual(?*Node, &heads, null));
} | waker.zig |
pub const MILBITMAPEFFECT_SDK_VERSION = @as(u32, 16777216);
pub const CLSID_MILBitmapEffectGroup = Guid.initString("ac9c1a9a-7e18-4f64-ac7e-47cf7f051e95");
pub const CLSID_MILBitmapEffectBlur = Guid.initString("a924df87-225d-4373-8f5b-b90ec85ae3de");
pub const CLSID_MILBitmapEffectDropShadow = Guid.initString("459a3fbe-d8ac-4692-874b-7a265715aa16");
pub const CLSID_MILBitmapEffectOuterGlow = Guid.initString("e2161bdd-7eb6-4725-9c0b-8a2a1b4f0667");
pub const CLSID_MILBitmapEffectBevel = Guid.initString("fd361dbe-6c9b-4de0-8290-f6400c2737ed");
pub const CLSID_MILBitmapEffectEmboss = Guid.initString("cd299846-824f-47ec-a007-12aa767f2816");
//--------------------------------------------------------------------------------
// Section: Types (23)
//--------------------------------------------------------------------------------
pub const MilRectD = extern struct {
left: f64,
top: f64,
right: f64,
bottom: f64,
};
pub const MilPoint2D = extern struct {
X: f64,
Y: f64,
};
pub const MILMatrixF = extern struct {
_11: f64,
_12: f64,
_13: f64,
_14: f64,
_21: f64,
_22: f64,
_23: f64,
_24: f64,
_31: f64,
_32: f64,
_33: f64,
_34: f64,
_41: f64,
_42: f64,
_43: f64,
_44: f64,
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectConnectorInfo_Value = @import("../zig.zig").Guid.initString("f66d2e4b-b46b-42fc-859e-3da0ecdb3c43");
pub const IID_IMILBitmapEffectConnectorInfo = &IID_IMILBitmapEffectConnectorInfo_Value;
pub const IMILBitmapEffectConnectorInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetIndex: fn(
self: *const IMILBitmapEffectConnectorInfo,
puiIndex: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOptimalFormat: fn(
self: *const IMILBitmapEffectConnectorInfo,
pFormat: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNumberFormats: fn(
self: *const IMILBitmapEffectConnectorInfo,
pulNumberFormats: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFormat: fn(
self: *const IMILBitmapEffectConnectorInfo,
ulIndex: u32,
pFormat: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectorInfo_GetIndex(self: *const T, puiIndex: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectorInfo.VTable, self.vtable).GetIndex(@ptrCast(*const IMILBitmapEffectConnectorInfo, self), puiIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectorInfo_GetOptimalFormat(self: *const T, pFormat: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectorInfo.VTable, self.vtable).GetOptimalFormat(@ptrCast(*const IMILBitmapEffectConnectorInfo, self), pFormat);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectorInfo_GetNumberFormats(self: *const T, pulNumberFormats: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectorInfo.VTable, self.vtable).GetNumberFormats(@ptrCast(*const IMILBitmapEffectConnectorInfo, self), pulNumberFormats);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectorInfo_GetFormat(self: *const T, ulIndex: u32, pFormat: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectorInfo.VTable, self.vtable).GetFormat(@ptrCast(*const IMILBitmapEffectConnectorInfo, self), ulIndex, pFormat);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectConnectionsInfo_Value = @import("../zig.zig").Guid.initString("476b538a-c765-4237-ba4a-d6a880ff0cfc");
pub const IID_IMILBitmapEffectConnectionsInfo = &IID_IMILBitmapEffectConnectionsInfo_Value;
pub const IMILBitmapEffectConnectionsInfo = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetNumberInputs: fn(
self: *const IMILBitmapEffectConnectionsInfo,
puiNumInputs: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNumberOutputs: fn(
self: *const IMILBitmapEffectConnectionsInfo,
puiNumOutputs: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInputConnectorInfo: fn(
self: *const IMILBitmapEffectConnectionsInfo,
uiIndex: u32,
ppConnectorInfo: ?*?*IMILBitmapEffectConnectorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputConnectorInfo: fn(
self: *const IMILBitmapEffectConnectionsInfo,
uiIndex: u32,
ppConnectorInfo: ?*?*IMILBitmapEffectConnectorInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectionsInfo_GetNumberInputs(self: *const T, puiNumInputs: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectionsInfo.VTable, self.vtable).GetNumberInputs(@ptrCast(*const IMILBitmapEffectConnectionsInfo, self), puiNumInputs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectionsInfo_GetNumberOutputs(self: *const T, puiNumOutputs: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectionsInfo.VTable, self.vtable).GetNumberOutputs(@ptrCast(*const IMILBitmapEffectConnectionsInfo, self), puiNumOutputs);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectionsInfo_GetInputConnectorInfo(self: *const T, uiIndex: u32, ppConnectorInfo: ?*?*IMILBitmapEffectConnectorInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectionsInfo.VTable, self.vtable).GetInputConnectorInfo(@ptrCast(*const IMILBitmapEffectConnectionsInfo, self), uiIndex, ppConnectorInfo);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnectionsInfo_GetOutputConnectorInfo(self: *const T, uiIndex: u32, ppConnectorInfo: ?*?*IMILBitmapEffectConnectorInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnectionsInfo.VTable, self.vtable).GetOutputConnectorInfo(@ptrCast(*const IMILBitmapEffectConnectionsInfo, self), uiIndex, ppConnectorInfo);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectConnections_Value = @import("../zig.zig").Guid.initString("c2b5d861-9b1a-4374-89b0-dec4874d6a81");
pub const IID_IMILBitmapEffectConnections = &IID_IMILBitmapEffectConnections_Value;
pub const IMILBitmapEffectConnections = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetInputConnector: fn(
self: *const IMILBitmapEffectConnections,
uiIndex: u32,
ppConnector: ?*?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputConnector: fn(
self: *const IMILBitmapEffectConnections,
uiIndex: u32,
ppConnector: ?*?*IMILBitmapEffectOutputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnections_GetInputConnector(self: *const T, uiIndex: u32, ppConnector: ?*?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnections.VTable, self.vtable).GetInputConnector(@ptrCast(*const IMILBitmapEffectConnections, self), uiIndex, ppConnector);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnections_GetOutputConnector(self: *const T, uiIndex: u32, ppConnector: ?*?*IMILBitmapEffectOutputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnections.VTable, self.vtable).GetOutputConnector(@ptrCast(*const IMILBitmapEffectConnections, self), uiIndex, ppConnector);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffect_Value = @import("../zig.zig").Guid.initString("8a6ff321-c944-4a1b-9944-9954af301258");
pub const IID_IMILBitmapEffect = &IID_IMILBitmapEffect_Value;
pub const IMILBitmapEffect = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetOutput: fn(
self: *const IMILBitmapEffect,
uiIndex: u32,
pContext: ?*IMILBitmapEffectRenderContext,
ppBitmapSource: ?*?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetParentEffect: fn(
self: *const IMILBitmapEffect,
ppParentEffect: ?*?*IMILBitmapEffectGroup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetInputSource: fn(
self: *const IMILBitmapEffect,
uiIndex: u32,
pBitmapSource: ?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffect_GetOutput(self: *const T, uiIndex: u32, pContext: ?*IMILBitmapEffectRenderContext, ppBitmapSource: ?*?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffect.VTable, self.vtable).GetOutput(@ptrCast(*const IMILBitmapEffect, self), uiIndex, pContext, ppBitmapSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffect_GetParentEffect(self: *const T, ppParentEffect: ?*?*IMILBitmapEffectGroup) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffect.VTable, self.vtable).GetParentEffect(@ptrCast(*const IMILBitmapEffect, self), ppParentEffect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffect_SetInputSource(self: *const T, uiIndex: u32, pBitmapSource: ?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffect.VTable, self.vtable).SetInputSource(@ptrCast(*const IMILBitmapEffect, self), uiIndex, pBitmapSource);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectImpl_Value = @import("../zig.zig").Guid.initString("cc2468f2-9936-47be-b4af-06b5df5dbcbb");
pub const IID_IMILBitmapEffectImpl = &IID_IMILBitmapEffectImpl_Value;
pub const IMILBitmapEffectImpl = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
IsInPlaceModificationAllowed: fn(
self: *const IMILBitmapEffectImpl,
pOutputConnector: ?*IMILBitmapEffectOutputConnector,
pfModifyInPlace: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetParentEffect: fn(
self: *const IMILBitmapEffectImpl,
pParentEffect: ?*IMILBitmapEffectGroup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInputSource: fn(
self: *const IMILBitmapEffectImpl,
uiIndex: u32,
ppBitmapSource: ?*?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInputSourceBounds: fn(
self: *const IMILBitmapEffectImpl,
uiIndex: u32,
pRect: ?*MilRectD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInputBitmapSource: fn(
self: *const IMILBitmapEffectImpl,
uiIndex: u32,
pRenderContext: ?*IMILBitmapEffectRenderContext,
pfModifyInPlace: ?*i16,
ppBitmapSource: ?*?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputBitmapSource: fn(
self: *const IMILBitmapEffectImpl,
uiIndex: u32,
pRenderContext: ?*IMILBitmapEffectRenderContext,
pfModifyInPlace: ?*i16,
ppBitmapSource: ?*?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize: fn(
self: *const IMILBitmapEffectImpl,
pInner: ?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_IsInPlaceModificationAllowed(self: *const T, pOutputConnector: ?*IMILBitmapEffectOutputConnector, pfModifyInPlace: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).IsInPlaceModificationAllowed(@ptrCast(*const IMILBitmapEffectImpl, self), pOutputConnector, pfModifyInPlace);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_SetParentEffect(self: *const T, pParentEffect: ?*IMILBitmapEffectGroup) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).SetParentEffect(@ptrCast(*const IMILBitmapEffectImpl, self), pParentEffect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_GetInputSource(self: *const T, uiIndex: u32, ppBitmapSource: ?*?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).GetInputSource(@ptrCast(*const IMILBitmapEffectImpl, self), uiIndex, ppBitmapSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_GetInputSourceBounds(self: *const T, uiIndex: u32, pRect: ?*MilRectD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).GetInputSourceBounds(@ptrCast(*const IMILBitmapEffectImpl, self), uiIndex, pRect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_GetInputBitmapSource(self: *const T, uiIndex: u32, pRenderContext: ?*IMILBitmapEffectRenderContext, pfModifyInPlace: ?*i16, ppBitmapSource: ?*?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).GetInputBitmapSource(@ptrCast(*const IMILBitmapEffectImpl, self), uiIndex, pRenderContext, pfModifyInPlace, ppBitmapSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_GetOutputBitmapSource(self: *const T, uiIndex: u32, pRenderContext: ?*IMILBitmapEffectRenderContext, pfModifyInPlace: ?*i16, ppBitmapSource: ?*?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).GetOutputBitmapSource(@ptrCast(*const IMILBitmapEffectImpl, self), uiIndex, pRenderContext, pfModifyInPlace, ppBitmapSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectImpl_Initialize(self: *const T, pInner: ?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectImpl.VTable, self.vtable).Initialize(@ptrCast(*const IMILBitmapEffectImpl, self), pInner);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectGroup_Value = @import("../zig.zig").Guid.initString("2f952360-698a-4ac6-81a1-bcfdf08eb8e8");
pub const IID_IMILBitmapEffectGroup = &IID_IMILBitmapEffectGroup_Value;
pub const IMILBitmapEffectGroup = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetInteriorInputConnector: fn(
self: *const IMILBitmapEffectGroup,
uiIndex: u32,
ppConnector: ?*?*IMILBitmapEffectOutputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetInteriorOutputConnector: fn(
self: *const IMILBitmapEffectGroup,
uiIndex: u32,
ppConnector: ?*?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IMILBitmapEffectGroup,
pEffect: ?*IMILBitmapEffect,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroup_GetInteriorInputConnector(self: *const T, uiIndex: u32, ppConnector: ?*?*IMILBitmapEffectOutputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroup.VTable, self.vtable).GetInteriorInputConnector(@ptrCast(*const IMILBitmapEffectGroup, self), uiIndex, ppConnector);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroup_GetInteriorOutputConnector(self: *const T, uiIndex: u32, ppConnector: ?*?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroup.VTable, self.vtable).GetInteriorOutputConnector(@ptrCast(*const IMILBitmapEffectGroup, self), uiIndex, ppConnector);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroup_Add(self: *const T, pEffect: ?*IMILBitmapEffect) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroup.VTable, self.vtable).Add(@ptrCast(*const IMILBitmapEffectGroup, self), pEffect);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectGroupImpl_Value = @import("../zig.zig").Guid.initString("78fed518-1cfc-4807-8b85-6b6e51398f62");
pub const IID_IMILBitmapEffectGroupImpl = &IID_IMILBitmapEffectGroupImpl_Value;
pub const IMILBitmapEffectGroupImpl = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Preprocess: fn(
self: *const IMILBitmapEffectGroupImpl,
pContext: ?*IMILBitmapEffectRenderContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetNumberChildren: fn(
self: *const IMILBitmapEffectGroupImpl,
puiNumberChildren: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetChildren: fn(
self: *const IMILBitmapEffectGroupImpl,
pChildren: ?*?*IMILBitmapEffects,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroupImpl_Preprocess(self: *const T, pContext: ?*IMILBitmapEffectRenderContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroupImpl.VTable, self.vtable).Preprocess(@ptrCast(*const IMILBitmapEffectGroupImpl, self), pContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroupImpl_GetNumberChildren(self: *const T, puiNumberChildren: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroupImpl.VTable, self.vtable).GetNumberChildren(@ptrCast(*const IMILBitmapEffectGroupImpl, self), puiNumberChildren);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectGroupImpl_GetChildren(self: *const T, pChildren: ?*?*IMILBitmapEffects) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectGroupImpl.VTable, self.vtable).GetChildren(@ptrCast(*const IMILBitmapEffectGroupImpl, self), pChildren);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectRenderContext_Value = @import("../zig.zig").Guid.initString("12a2ec7e-2d33-44b2-b334-1abb7846e390");
pub const IID_IMILBitmapEffectRenderContext = &IID_IMILBitmapEffectRenderContext_Value;
pub const IMILBitmapEffectRenderContext = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
SetOutputPixelFormat: fn(
self: *const IMILBitmapEffectRenderContext,
format: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputPixelFormat: fn(
self: *const IMILBitmapEffectRenderContext,
pFormat: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetUseSoftwareRenderer: fn(
self: *const IMILBitmapEffectRenderContext,
fSoftware: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetInitialTransform: fn(
self: *const IMILBitmapEffectRenderContext,
pMatrix: ?*MILMatrixF,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFinalTransform: fn(
self: *const IMILBitmapEffectRenderContext,
pMatrix: ?*MILMatrixF,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetOutputDPI: fn(
self: *const IMILBitmapEffectRenderContext,
dblDpiX: f64,
dblDpiY: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputDPI: fn(
self: *const IMILBitmapEffectRenderContext,
pdblDpiX: ?*f64,
pdblDpiY: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRegionOfInterest: fn(
self: *const IMILBitmapEffectRenderContext,
pRect: ?*MilRectD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_SetOutputPixelFormat(self: *const T, format: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).SetOutputPixelFormat(@ptrCast(*const IMILBitmapEffectRenderContext, self), format);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_GetOutputPixelFormat(self: *const T, pFormat: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).GetOutputPixelFormat(@ptrCast(*const IMILBitmapEffectRenderContext, self), pFormat);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_SetUseSoftwareRenderer(self: *const T, fSoftware: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).SetUseSoftwareRenderer(@ptrCast(*const IMILBitmapEffectRenderContext, self), fSoftware);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_SetInitialTransform(self: *const T, pMatrix: ?*MILMatrixF) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).SetInitialTransform(@ptrCast(*const IMILBitmapEffectRenderContext, self), pMatrix);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_GetFinalTransform(self: *const T, pMatrix: ?*MILMatrixF) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).GetFinalTransform(@ptrCast(*const IMILBitmapEffectRenderContext, self), pMatrix);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_SetOutputDPI(self: *const T, dblDpiX: f64, dblDpiY: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).SetOutputDPI(@ptrCast(*const IMILBitmapEffectRenderContext, self), dblDpiX, dblDpiY);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_GetOutputDPI(self: *const T, pdblDpiX: ?*f64, pdblDpiY: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).GetOutputDPI(@ptrCast(*const IMILBitmapEffectRenderContext, self), pdblDpiX, pdblDpiY);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContext_SetRegionOfInterest(self: *const T, pRect: ?*MilRectD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContext.VTable, self.vtable).SetRegionOfInterest(@ptrCast(*const IMILBitmapEffectRenderContext, self), pRect);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectRenderContextImpl_Value = @import("../zig.zig").Guid.initString("4d25accb-797d-4fd2-b128-dffeff84fcc3");
pub const IID_IMILBitmapEffectRenderContextImpl = &IID_IMILBitmapEffectRenderContextImpl_Value;
pub const IMILBitmapEffectRenderContextImpl = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetUseSoftwareRenderer: fn(
self: *const IMILBitmapEffectRenderContextImpl,
pfSoftware: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTransform: fn(
self: *const IMILBitmapEffectRenderContextImpl,
pMatrix: ?*MILMatrixF,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateTransform: fn(
self: *const IMILBitmapEffectRenderContextImpl,
pMatrix: ?*MILMatrixF,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputBounds: fn(
self: *const IMILBitmapEffectRenderContextImpl,
pRect: ?*MilRectD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateOutputBounds: fn(
self: *const IMILBitmapEffectRenderContextImpl,
pRect: ?*MilRectD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContextImpl_GetUseSoftwareRenderer(self: *const T, pfSoftware: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContextImpl.VTable, self.vtable).GetUseSoftwareRenderer(@ptrCast(*const IMILBitmapEffectRenderContextImpl, self), pfSoftware);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContextImpl_GetTransform(self: *const T, pMatrix: ?*MILMatrixF) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContextImpl.VTable, self.vtable).GetTransform(@ptrCast(*const IMILBitmapEffectRenderContextImpl, self), pMatrix);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContextImpl_UpdateTransform(self: *const T, pMatrix: ?*MILMatrixF) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContextImpl.VTable, self.vtable).UpdateTransform(@ptrCast(*const IMILBitmapEffectRenderContextImpl, self), pMatrix);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContextImpl_GetOutputBounds(self: *const T, pRect: ?*MilRectD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContextImpl.VTable, self.vtable).GetOutputBounds(@ptrCast(*const IMILBitmapEffectRenderContextImpl, self), pRect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectRenderContextImpl_UpdateOutputBounds(self: *const T, pRect: ?*MilRectD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectRenderContextImpl.VTable, self.vtable).UpdateOutputBounds(@ptrCast(*const IMILBitmapEffectRenderContextImpl, self), pRect);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectFactory_Value = @import("../zig.zig").Guid.initString("33a9df34-a403-4ec7-b07e-bc0682370845");
pub const IID_IMILBitmapEffectFactory = &IID_IMILBitmapEffectFactory_Value;
pub const IMILBitmapEffectFactory = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
CreateEffect: fn(
self: *const IMILBitmapEffectFactory,
pguidEffect: ?*const Guid,
ppEffect: ?*?*IMILBitmapEffect,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateContext: fn(
self: *const IMILBitmapEffectFactory,
ppContext: ?*?*IMILBitmapEffectRenderContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateEffectOuter: fn(
self: *const IMILBitmapEffectFactory,
ppEffect: ?*?*IMILBitmapEffect,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectFactory_CreateEffect(self: *const T, pguidEffect: ?*const Guid, ppEffect: ?*?*IMILBitmapEffect) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectFactory.VTable, self.vtable).CreateEffect(@ptrCast(*const IMILBitmapEffectFactory, self), pguidEffect, ppEffect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectFactory_CreateContext(self: *const T, ppContext: ?*?*IMILBitmapEffectRenderContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectFactory.VTable, self.vtable).CreateContext(@ptrCast(*const IMILBitmapEffectFactory, self), ppContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectFactory_CreateEffectOuter(self: *const T, ppEffect: ?*?*IMILBitmapEffect) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectFactory.VTable, self.vtable).CreateEffectOuter(@ptrCast(*const IMILBitmapEffectFactory, self), ppEffect);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectPrimitive_Value = @import("../zig.zig").Guid.initString("67e31025-3091-4dfc-98d6-dd494551461d");
pub const IID_IMILBitmapEffectPrimitive = &IID_IMILBitmapEffectPrimitive_Value;
pub const IMILBitmapEffectPrimitive = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetOutput: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
pContext: ?*IMILBitmapEffectRenderContext,
pfModifyInPlace: ?*i16,
ppBitmapSource: ?*?*IWICBitmapSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
TransformPoint: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
p: ?*MilPoint2D,
fForwardTransform: i16,
pContext: ?*IMILBitmapEffectRenderContext,
pfPointTransformed: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
TransformRect: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
p: ?*MilRectD,
fForwardTransform: i16,
pContext: ?*IMILBitmapEffectRenderContext,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
HasAffineTransform: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
pfAffine: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
HasInverseTransform: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
pfHasInverse: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAffineMatrix: fn(
self: *const IMILBitmapEffectPrimitive,
uiIndex: u32,
pMatrix: ?*MilMatrix3x2D,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_GetOutput(self: *const T, uiIndex: u32, pContext: ?*IMILBitmapEffectRenderContext, pfModifyInPlace: ?*i16, ppBitmapSource: ?*?*IWICBitmapSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).GetOutput(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, pContext, pfModifyInPlace, ppBitmapSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_TransformPoint(self: *const T, uiIndex: u32, p: ?*MilPoint2D, fForwardTransform: i16, pContext: ?*IMILBitmapEffectRenderContext, pfPointTransformed: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).TransformPoint(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, p, fForwardTransform, pContext, pfPointTransformed);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_TransformRect(self: *const T, uiIndex: u32, p: ?*MilRectD, fForwardTransform: i16, pContext: ?*IMILBitmapEffectRenderContext) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).TransformRect(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, p, fForwardTransform, pContext);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_HasAffineTransform(self: *const T, uiIndex: u32, pfAffine: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).HasAffineTransform(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, pfAffine);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_HasInverseTransform(self: *const T, uiIndex: u32, pfHasInverse: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).HasInverseTransform(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, pfHasInverse);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitive_GetAffineMatrix(self: *const T, uiIndex: u32, pMatrix: ?*MilMatrix3x2D) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitive.VTable, self.vtable).GetAffineMatrix(@ptrCast(*const IMILBitmapEffectPrimitive, self), uiIndex, pMatrix);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectPrimitiveImpl_Value = @import("../zig.zig").Guid.initString("ce41e00b-efa6-44e7-b007-dd042e3ae126");
pub const IID_IMILBitmapEffectPrimitiveImpl = &IID_IMILBitmapEffectPrimitiveImpl_Value;
pub const IMILBitmapEffectPrimitiveImpl = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
IsDirty: fn(
self: *const IMILBitmapEffectPrimitiveImpl,
uiOutputIndex: u32,
pfDirty: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsVolatile: fn(
self: *const IMILBitmapEffectPrimitiveImpl,
uiOutputIndex: u32,
pfVolatile: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitiveImpl_IsDirty(self: *const T, uiOutputIndex: u32, pfDirty: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitiveImpl.VTable, self.vtable).IsDirty(@ptrCast(*const IMILBitmapEffectPrimitiveImpl, self), uiOutputIndex, pfDirty);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectPrimitiveImpl_IsVolatile(self: *const T, uiOutputIndex: u32, pfVolatile: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectPrimitiveImpl.VTable, self.vtable).IsVolatile(@ptrCast(*const IMILBitmapEffectPrimitiveImpl, self), uiOutputIndex, pfVolatile);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffects_Value = @import("../zig.zig").Guid.initString("51ac3dce-67c5-448b-9180-ad3eabddd5dd");
pub const IID_IMILBitmapEffects = &IID_IMILBitmapEffects_Value;
pub const IMILBitmapEffects = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
_NewEnum: fn(
self: *const IMILBitmapEffects,
ppiuReturn: ?*?*IUnknown,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Parent: fn(
self: *const IMILBitmapEffects,
ppEffect: ?*?*IMILBitmapEffectGroup,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Item: fn(
self: *const IMILBitmapEffects,
uindex: u32,
ppEffect: ?*?*IMILBitmapEffect,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IMILBitmapEffects,
puiCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffects__NewEnum(self: *const T, ppiuReturn: ?*?*IUnknown) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffects.VTable, self.vtable)._NewEnum(@ptrCast(*const IMILBitmapEffects, self), ppiuReturn);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffects_get_Parent(self: *const T, ppEffect: ?*?*IMILBitmapEffectGroup) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffects.VTable, self.vtable).get_Parent(@ptrCast(*const IMILBitmapEffects, self), ppEffect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffects_Item(self: *const T, uindex: u32, ppEffect: ?*?*IMILBitmapEffect) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffects.VTable, self.vtable).Item(@ptrCast(*const IMILBitmapEffects, self), uindex, ppEffect);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffects_get_Count(self: *const T, puiCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffects.VTable, self.vtable).get_Count(@ptrCast(*const IMILBitmapEffects, self), puiCount);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectConnector_Value = @import("../zig.zig").Guid.initString("f59567b3-76c1-4d47-ba1e-79f955e350ef");
pub const IID_IMILBitmapEffectConnector = &IID_IMILBitmapEffectConnector_Value;
pub const IMILBitmapEffectConnector = extern struct {
pub const VTable = extern struct {
base: IMILBitmapEffectConnectorInfo.VTable,
IsConnected: fn(
self: *const IMILBitmapEffectConnector,
pfConnected: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetBitmapEffect: fn(
self: *const IMILBitmapEffectConnector,
ppEffect: ?*?*IMILBitmapEffect,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMILBitmapEffectConnectorInfo.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnector_IsConnected(self: *const T, pfConnected: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnector.VTable, self.vtable).IsConnected(@ptrCast(*const IMILBitmapEffectConnector, self), pfConnected);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectConnector_GetBitmapEffect(self: *const T, ppEffect: ?*?*IMILBitmapEffect) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectConnector.VTable, self.vtable).GetBitmapEffect(@ptrCast(*const IMILBitmapEffectConnector, self), ppEffect);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectInputConnector_Value = @import("../zig.zig").Guid.initString("a9b4ecaa-7a3c-45e7-8573-f4b81b60dd6c");
pub const IID_IMILBitmapEffectInputConnector = &IID_IMILBitmapEffectInputConnector_Value;
pub const IMILBitmapEffectInputConnector = extern struct {
pub const VTable = extern struct {
base: IMILBitmapEffectConnector.VTable,
ConnectTo: fn(
self: *const IMILBitmapEffectInputConnector,
pConnector: ?*IMILBitmapEffectOutputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetConnection: fn(
self: *const IMILBitmapEffectInputConnector,
ppConnector: ?*?*IMILBitmapEffectOutputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMILBitmapEffectConnector.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectInputConnector_ConnectTo(self: *const T, pConnector: ?*IMILBitmapEffectOutputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectInputConnector.VTable, self.vtable).ConnectTo(@ptrCast(*const IMILBitmapEffectInputConnector, self), pConnector);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectInputConnector_GetConnection(self: *const T, ppConnector: ?*?*IMILBitmapEffectOutputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectInputConnector.VTable, self.vtable).GetConnection(@ptrCast(*const IMILBitmapEffectInputConnector, self), ppConnector);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectOutputConnector_Value = @import("../zig.zig").Guid.initString("92957aad-841b-4866-82ec-8752468b07fd");
pub const IID_IMILBitmapEffectOutputConnector = &IID_IMILBitmapEffectOutputConnector_Value;
pub const IMILBitmapEffectOutputConnector = extern struct {
pub const VTable = extern struct {
base: IMILBitmapEffectConnector.VTable,
GetNumberConnections: fn(
self: *const IMILBitmapEffectOutputConnector,
puiNumberConnections: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetConnection: fn(
self: *const IMILBitmapEffectOutputConnector,
uiIndex: u32,
ppConnection: ?*?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMILBitmapEffectConnector.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectOutputConnector_GetNumberConnections(self: *const T, puiNumberConnections: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectOutputConnector.VTable, self.vtable).GetNumberConnections(@ptrCast(*const IMILBitmapEffectOutputConnector, self), puiNumberConnections);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectOutputConnector_GetConnection(self: *const T, uiIndex: u32, ppConnection: ?*?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectOutputConnector.VTable, self.vtable).GetConnection(@ptrCast(*const IMILBitmapEffectOutputConnector, self), uiIndex, ppConnection);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectOutputConnectorImpl_Value = @import("../zig.zig").Guid.initString("21fae777-8b39-4bfa-9f2d-f3941ed36913");
pub const IID_IMILBitmapEffectOutputConnectorImpl = &IID_IMILBitmapEffectOutputConnectorImpl_Value;
pub const IMILBitmapEffectOutputConnectorImpl = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
AddBackLink: fn(
self: *const IMILBitmapEffectOutputConnectorImpl,
pConnection: ?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveBackLink: fn(
self: *const IMILBitmapEffectOutputConnectorImpl,
pConnection: ?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectOutputConnectorImpl_AddBackLink(self: *const T, pConnection: ?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectOutputConnectorImpl.VTable, self.vtable).AddBackLink(@ptrCast(*const IMILBitmapEffectOutputConnectorImpl, self), pConnection);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectOutputConnectorImpl_RemoveBackLink(self: *const T, pConnection: ?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectOutputConnectorImpl.VTable, self.vtable).RemoveBackLink(@ptrCast(*const IMILBitmapEffectOutputConnectorImpl, self), pConnection);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectInteriorInputConnector_Value = @import("../zig.zig").Guid.initString("20287e9e-86a2-4e15-953d-eb1438a5b842");
pub const IID_IMILBitmapEffectInteriorInputConnector = &IID_IMILBitmapEffectInteriorInputConnector_Value;
pub const IMILBitmapEffectInteriorInputConnector = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetInputConnector: fn(
self: *const IMILBitmapEffectInteriorInputConnector,
pInputConnector: ?*?*IMILBitmapEffectInputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectInteriorInputConnector_GetInputConnector(self: *const T, pInputConnector: ?*?*IMILBitmapEffectInputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectInteriorInputConnector.VTable, self.vtable).GetInputConnector(@ptrCast(*const IMILBitmapEffectInteriorInputConnector, self), pInputConnector);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectInteriorOutputConnector_Value = @import("../zig.zig").Guid.initString("00bbb6dc-acc9-4bfc-b344-8bee383dfefa");
pub const IID_IMILBitmapEffectInteriorOutputConnector = &IID_IMILBitmapEffectInteriorOutputConnector_Value;
pub const IMILBitmapEffectInteriorOutputConnector = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetOutputConnector: fn(
self: *const IMILBitmapEffectInteriorOutputConnector,
pOutputConnector: ?*?*IMILBitmapEffectOutputConnector,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectInteriorOutputConnector_GetOutputConnector(self: *const T, pOutputConnector: ?*?*IMILBitmapEffectOutputConnector) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectInteriorOutputConnector.VTable, self.vtable).GetOutputConnector(@ptrCast(*const IMILBitmapEffectInteriorOutputConnector, self), pOutputConnector);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IMILBitmapEffectEvents_Value = @import("../zig.zig").Guid.initString("2e880dd8-f8ce-457b-8199-d60bb3d7ef98");
pub const IID_IMILBitmapEffectEvents = &IID_IMILBitmapEffectEvents_Value;
pub const IMILBitmapEffectEvents = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
PropertyChange: fn(
self: *const IMILBitmapEffectEvents,
pEffect: ?*IMILBitmapEffect,
bstrPropertyName: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DirtyRegion: fn(
self: *const IMILBitmapEffectEvents,
pEffect: ?*IMILBitmapEffect,
pRect: ?*MilRectD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectEvents_PropertyChange(self: *const T, pEffect: ?*IMILBitmapEffect, bstrPropertyName: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectEvents.VTable, self.vtable).PropertyChange(@ptrCast(*const IMILBitmapEffectEvents, self), pEffect, bstrPropertyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMILBitmapEffectEvents_DirtyRegion(self: *const T, pEffect: ?*IMILBitmapEffect, pRect: ?*MilRectD) callconv(.Inline) HRESULT {
return @ptrCast(*const IMILBitmapEffectEvents.VTable, self.vtable).DirtyRegion(@ptrCast(*const IMILBitmapEffectEvents, self), pEffect, pRect);
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (0)
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (6)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BSTR = @import("../foundation.zig").BSTR;
const HRESULT = @import("../foundation.zig").HRESULT;
const IUnknown = @import("../system/com.zig").IUnknown;
const IWICBitmapSource = @import("../graphics/imaging.zig").IWICBitmapSource;
const MilMatrix3x2D = @import("../graphics/dwm.zig").MilMatrix3x2D;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/ui/wpf.zig |
const std = @import("std");
const upaya = @import("upaya");
usingnamespace @import("imgui");
const persistence = @import("persistence.zig");
const ts = @import("tilescript.zig");
const TileScript = ts.TileScript;
const Texture = upaya.Texture;
const Map = ts.Map;
pub const AppState = struct {
map: Map,
// general state
opened_file: ?[]const u8 = null,
exported_file: ?[]const u8 = null,
object_edit_mode: bool = false,
selected_brush_index: usize = 0,
texture: Texture,
tiles_per_row: usize = 0,
map_rect_size: f32 = 12,
// toasts
toast_timer: i32 = -1,
toast_text: [255]u8 = undefined,
// map data
map_data_dirty: bool = true,
processed_map_data: []u8,
final_map_data: []u8,
random_map_data: []Randoms,
prefs: Prefs = .{
.windows = .{},
},
pub const Randoms = struct {
float: f32,
int: usize,
};
/// persisted data
pub const Prefs = struct {
// ui state
show_animations: bool = false,
show_objects: bool = true,
tile_size_multiplier: usize = 1,
win_x: i32 = 0,
win_y: i32 = 0,
win_w: i32 = 1024,
win_h: i32 = 768,
// menu state
windows: struct {
objects: bool = false,
object_editor: bool = false,
tags: bool = false,
tile_definitions: bool = false,
animations: bool = false,
post_processed_map: bool = true,
},
};
/// generates a texture with 4x4, 16px blocks of color
pub fn generateTexture() Texture {
const rc = upaya.math.rand.color;
var colors = [_]u32{
ts.colors.brushes[12], ts.colors.brushes[11], ts.colors.brushes[10], ts.colors.brushes[9],
ts.colors.brushes[8], ts.colors.brushes[7], ts.colors.brushes[6], ts.colors.brushes[5],
ts.colors.brushes[4], ts.colors.brushes[3], ts.colors.brushes[2], ts.colors.brushes[1],
rc().value, rc().value, rc().value, rc().value,
};
var pixels: [16 * 4 * 16 * 4]u32 = undefined;
var y: usize = 0;
while (y < 16 * 4) : (y += 1) {
var x: usize = 0;
while (x < 16 * 4) : (x += 1) {
const xx = @divTrunc(x, 16);
const yy = @divTrunc(y, 16);
pixels[x + y * 16 * 4] = colors[xx + yy * 2];
}
}
return Texture.initWithColorData(&pixels, 16 * 4, 16 * 4, .nearest);
}
pub fn init() AppState {
const prefs = upaya.fs.readPrefsJson(AppState.Prefs, "aya_tile", "prefs.json") catch AppState.Prefs{ .windows = .{} };
// aya.window.setSize(prefs.win_w, prefs.win_h);
if (prefs.win_x != 0 and prefs.win_y != 0) {
// aya.window.setPosition(prefs.win_x, prefs.win_y);
}
// load up a temp map
const tile_size = 16;
const map = Map.init(tile_size, 0);
var state = AppState{
.map = map,
.map_rect_size = @intToFloat(f32, tile_size * prefs.tile_size_multiplier),
.processed_map_data = upaya.mem.allocator.alloc(u8, 64 * 64) catch unreachable,
.final_map_data = upaya.mem.allocator.alloc(u8, 64 * 64) catch unreachable,
.random_map_data = upaya.mem.allocator.alloc(Randoms, 64 * 64) catch unreachable,
.texture = generateTexture(),
.prefs = prefs,
};
state.generateRandomData(state.map.ruleset.seed);
// test data for messing with folders
// var i: usize = 10;
// while (i < 20) : (i += 1) {
// state.map.ruleset.addRule();
// var rule = &state.map.ruleset.rules.items[state.map.ruleset.rules.items.len - 1];
// std.mem.copy(u8, &rule.name, std.fmt.allocPrint(upaya.mem.tmp_allocator, "Rule {}", .{i}) catch unreachable);
// }
return state;
}
pub fn savePrefs(self: *AppState) void {
// aya.window.size(&self.prefs.win_w, &self.prefs.win_h);
// aya.window.position(&self.prefs.win_x, &self.prefs.win_y);
upaya.fs.savePrefsJson("aya_tile", "prefs.json", self.prefs) catch unreachable;
}
/// returns the number of tiles in each row of the tileset image
pub fn tilesPerRow(self: *AppState) usize {
// calculate tiles_per_row if needed
if (self.tiles_per_row == 0) {
var accum: usize = self.map.tile_spacing * 2;
while (true) {
self.tiles_per_row += 1;
accum += self.map.tile_size + self.map.tile_spacing;
if (accum >= self.texture.width) {
break;
}
}
}
return self.tiles_per_row;
}
pub fn tilesPerCol(self: *AppState) usize {
var tiles_per_col: usize = 0;
var accum: usize = self.map.tile_spacing * 2;
while (true) {
tiles_per_col += 1;
accum += self.map.tile_size + 2 * self.map.tile_spacing;
if (accum >= self.texture.height) {
break;
}
}
return tiles_per_col;
}
pub fn mapSize(self: AppState) ImVec2 {
return ImVec2{ .x = @intToFloat(f32, self.map.w) * self.map_rect_size, .y = @intToFloat(f32, self.map.h) * self.map_rect_size };
}
/// resizes the map and all of the sub-maps
pub fn resizeMap(self: *AppState, w: usize, h: usize) void {
ts.history.reset();
self.map_data_dirty = true;
const shrunk = self.map.w > w or self.map.h > h;
// map_data is our source so we need to copy the old data into a temporary slice
var new_slice = upaya.mem.allocator.alloc(u8, w * h) catch unreachable;
std.mem.set(u8, new_slice, 0);
// copy taking into account that we may have shrunk
const max_x = std.math.min(self.map.w, w);
const max_y = std.math.min(self.map.h, h);
var y: usize = 0;
while (y < max_y) : (y += 1) {
var x: usize = 0;
while (x < max_x) : (x += 1) {
new_slice[x + y * w] = self.map.getTile(x, y);
}
}
self.map.w = w;
self.map.h = h;
upaya.mem.allocator.free(self.map.data);
self.map.data = new_slice;
// resize our two generated maps
upaya.mem.allocator.free(self.processed_map_data);
upaya.mem.allocator.free(self.final_map_data);
upaya.mem.allocator.free(self.random_map_data);
self.processed_map_data = upaya.mem.allocator.alloc(u8, w * h) catch unreachable;
self.final_map_data = upaya.mem.allocator.alloc(u8, w * h) catch unreachable;
self.random_map_data = upaya.mem.allocator.alloc(Randoms, w * h) catch unreachable;
// if we shrunk handle anything that needs to be fixed
if (shrunk) {
for (self.map.objects.items) |*anim| {
if (anim.x >= w) anim.x = w - 1;
if (anim.y >= h) anim.y = h - 1;
}
}
}
/// regenerates the stored random data per tile. Only needs to be called on seed change or map resize
pub fn generateRandomData(self: *AppState, seed: u64) void {
upaya.math.rand.seed(seed);
// pre-generate random data per tile
var i: usize = 0;
while (i < self.map.w * self.map.h) : (i += 1) {
self.random_map_data[i] = .{
.float = upaya.math.rand.float(f32),
.int = upaya.math.rand.int(usize),
};
}
}
pub fn getProcessedTile(self: AppState, x: usize, y: usize) u32 {
if (x >= self.map.w or y >= self.map.h) {
return 0;
}
return self.processed_map_data[x + y * @intCast(usize, self.map.w)];
}
pub fn showToast(self: *AppState, text: []const u8, duration: i32) void {
std.mem.copy(u8, &self.toast_text, text);
self.toast_timer = duration;
}
pub fn saveMap(self: AppState, file: []const u8) !void {
try persistence.save(self.map, file);
}
pub fn exportJson(self: AppState, file: []const u8) !void {
try persistence.exportJson(self.map, self.final_map_data, file);
}
pub fn clearQuickFile(self: *AppState, which: enum { opened, exported }) void {
var file = if (which == .opened) &self.opened_file else &self.exported_file;
if (file.* != null) {
upaya.mem.allocator.free(file.*.?);
file.* = null;
}
}
pub fn toggleEditMode(self: *AppState) void {
self.object_edit_mode = !self.object_edit_mode;
ts.colors.toggleObjectMode(self.object_edit_mode);
self.showToast(if (self.object_edit_mode) "Entering object edit mode" else "Exiting object edit mode", 70);
}
pub fn loadMap(self: *AppState, file: []const u8) !void {
if (std.mem.endsWith(u8, file, ".ts")) {
self.map = try persistence.load(file);
} else if (std.mem.endsWith(u8, file, ".tkp")) {
self.map = try @import("tilekit_importer.zig").import(file);
}
self.map_rect_size = @intToFloat(f32, self.map.tile_size * self.prefs.tile_size_multiplier);
const curr_dir = try std.fs.cwd().openDir(std.fs.path.dirname(file).?, .{});
try curr_dir.setAsCwd();
// unload old texture and load new texture
self.texture.deinit();
if (std.mem.len(self.map.image) == 0) {
self.texture = generateTexture();
self.map.tile_size = 16;
} else {
try curr_dir.access(self.map.image, .{});
const image_path = try std.fs.path.join(upaya.mem.tmp_allocator, &[_][]const u8{ std.fs.path.dirname(file).?, self.map.image });
self.texture = try Texture.initFromFile(image_path, .nearest);
}
// resize and clear processed_map_data and final_map_data
upaya.mem.allocator.free(self.processed_map_data);
upaya.mem.allocator.free(self.final_map_data);
upaya.mem.allocator.free(self.random_map_data);
self.processed_map_data = try upaya.mem.allocator.alloc(u8, self.map.w * self.map.h);
self.final_map_data = try upaya.mem.allocator.alloc(u8, self.map.w * self.map.h);
self.random_map_data = upaya.mem.allocator.alloc(Randoms, self.map.w * self.map.h) catch unreachable;
self.map_data_dirty = true;
self.tiles_per_row = 0;
// keep our file so we can save later and clear our exported file if we have one
self.clearQuickFile(.opened);
self.opened_file = try upaya.mem.allocator.dupe(u8, file);
self.clearQuickFile(.exported);
}
}; | tilescript/app_state.zig |
usingnamespace @import("../windows/bits.zig");
const ws2_32 = @import("../windows/ws2_32.zig");
// TODO: Stop using os.iovec in std.fs et al on Windows in the future
const posix = @import("posix.zig");
pub const iovec = posix.iovec;
pub const iovec_const = posix.iovec_const;
pub const fd_t = HANDLE;
pub const ino_t = LARGE_INTEGER;
pub const pid_t = HANDLE;
pub const mode_t = u0;
pub const PATH_MAX = 260;
pub const time_t = c_longlong;
pub const timespec = extern struct {
tv_sec: time_t,
tv_nsec: c_long,
};
pub const timeval = extern struct {
tv_sec: c_long,
tv_usec: c_long,
};
pub const sig_atomic_t = c_int;
/// maximum signal number + 1
pub const NSIG = 23;
// Signal types
/// interrupt
pub const SIGINT = 2;
/// illegal instruction - invalid function image
pub const SIGILL = 4;
/// floating point exception
pub const SIGFPE = 8;
/// segment violation
pub const SIGSEGV = 11;
/// Software termination signal from kill
pub const SIGTERM = 15;
/// Ctrl-Break sequence
pub const SIGBREAK = 21;
/// abnormal termination triggered by abort call
pub const SIGABRT = 22;
/// SIGABRT compatible with other platforms, same as SIGABRT
pub const SIGABRT_COMPAT = 6;
// Signal action codes
/// default signal action
pub const SIG_DFL = 0;
/// ignore signal
pub const SIG_IGN = 1;
/// return current value
pub const SIG_GET = 2;
/// signal gets error
pub const SIG_SGE = 3;
/// acknowledge
pub const SIG_ACK = 4;
/// Signal error value (returned by signal call on error)
pub const SIG_ERR = -1;
pub const SEEK_SET = 0;
pub const SEEK_CUR = 1;
pub const SEEK_END = 2;
pub const E = enum(u16) {
/// No error occurred.
SUCCESS = 0,
PERM = 1,
NOENT = 2,
SRCH = 3,
INTR = 4,
IO = 5,
NXIO = 6,
@"2BIG" = 7,
NOEXEC = 8,
BADF = 9,
CHILD = 10,
AGAIN = 11,
NOMEM = 12,
ACCES = 13,
FAULT = 14,
BUSY = 16,
EXIST = 17,
XDEV = 18,
NODEV = 19,
NOTDIR = 20,
ISDIR = 21,
NFILE = 23,
MFILE = 24,
NOTTY = 25,
FBIG = 27,
NOSPC = 28,
SPIPE = 29,
ROFS = 30,
MLINK = 31,
PIPE = 32,
DOM = 33,
/// Also means `DEADLOCK`.
DEADLK = 36,
NAMETOOLONG = 38,
NOLCK = 39,
NOSYS = 40,
NOTEMPTY = 41,
INVAL = 22,
RANGE = 34,
ILSEQ = 42,
// POSIX Supplement
ADDRINUSE = 100,
ADDRNOTAVAIL = 101,
AFNOSUPPORT = 102,
ALREADY = 103,
BADMSG = 104,
CANCELED = 105,
CONNABORTED = 106,
CONNREFUSED = 107,
CONNRESET = 108,
DESTADDRREQ = 109,
HOSTUNREACH = 110,
IDRM = 111,
INPROGRESS = 112,
ISCONN = 113,
LOOP = 114,
MSGSIZE = 115,
NETDOWN = 116,
NETRESET = 117,
NETUNREACH = 118,
NOBUFS = 119,
NODATA = 120,
NOLINK = 121,
NOMSG = 122,
NOPROTOOPT = 123,
NOSR = 124,
NOSTR = 125,
NOTCONN = 126,
NOTRECOVERABLE = 127,
NOTSOCK = 128,
NOTSUP = 129,
OPNOTSUPP = 130,
OTHER = 131,
OVERFLOW = 132,
OWNERDEAD = 133,
PROTO = 134,
PROTONOSUPPORT = 135,
PROTOTYPE = 136,
TIME = 137,
TIMEDOUT = 138,
TXTBSY = 139,
WOULDBLOCK = 140,
DQUOT = 10069,
_,
};
pub const STRUNCATE = 80;
pub const F_OK = 0;
/// Remove directory instead of unlinking file
pub const AT_REMOVEDIR = 0x200;
pub const in_port_t = u16;
pub const sa_family_t = ws2_32.ADDRESS_FAMILY;
pub const socklen_t = ws2_32.socklen_t;
pub const sockaddr = ws2_32.sockaddr;
pub const sockaddr_in = ws2_32.sockaddr_in;
pub const sockaddr_in6 = ws2_32.sockaddr_in6;
pub const sockaddr_un = ws2_32.sockaddr_un;
pub const in6_addr = [16]u8;
pub const in_addr = u32;
pub const addrinfo = ws2_32.addrinfo;
pub const AF_UNSPEC = ws2_32.AF_UNSPEC;
pub const AF_UNIX = ws2_32.AF_UNIX;
pub const AF_INET = ws2_32.AF_INET;
pub const AF_IMPLINK = ws2_32.AF_IMPLINK;
pub const AF_PUP = ws2_32.AF_PUP;
pub const AF_CHAOS = ws2_32.AF_CHAOS;
pub const AF_NS = ws2_32.AF_NS;
pub const AF_IPX = ws2_32.AF_IPX;
pub const AF_ISO = ws2_32.AF_ISO;
pub const AF_OSI = ws2_32.AF_OSI;
pub const AF_ECMA = ws2_32.AF_ECMA;
pub const AF_DATAKIT = ws2_32.AF_DATAKIT;
pub const AF_CCITT = ws2_32.AF_CCITT;
pub const AF_SNA = ws2_32.AF_SNA;
pub const AF_DECnet = ws2_32.AF_DECnet;
pub const AF_DLI = ws2_32.AF_DLI;
pub const AF_LAT = ws2_32.AF_LAT;
pub const AF_HYLINK = ws2_32.AF_HYLINK;
pub const AF_APPLETALK = ws2_32.AF_APPLETALK;
pub const AF_NETBIOS = ws2_32.AF_NETBIOS;
pub const AF_VOICEVIEW = ws2_32.AF_VOICEVIEW;
pub const AF_FIREFOX = ws2_32.AF_FIREFOX;
pub const AF_UNKNOWN1 = ws2_32.AF_UNKNOWN1;
pub const AF_BAN = ws2_32.AF_BAN;
pub const AF_ATM = ws2_32.AF_ATM;
pub const AF_INET6 = ws2_32.AF_INET6;
pub const AF_CLUSTER = ws2_32.AF_CLUSTER;
pub const AF_12844 = ws2_32.AF_12844;
pub const AF_IRDA = ws2_32.AF_IRDA;
pub const AF_NETDES = ws2_32.AF_NETDES;
pub const AF_TCNPROCESS = ws2_32.AF_TCNPROCESS;
pub const AF_TCNMESSAGE = ws2_32.AF_TCNMESSAGE;
pub const AF_ICLFXBM = ws2_32.AF_ICLFXBM;
pub const AF_BTH = ws2_32.AF_BTH;
pub const AF_MAX = ws2_32.AF_MAX;
pub const SOCK_STREAM = ws2_32.SOCK_STREAM;
pub const SOCK_DGRAM = ws2_32.SOCK_DGRAM;
pub const SOCK_RAW = ws2_32.SOCK_RAW;
pub const SOCK_RDM = ws2_32.SOCK_RDM;
pub const SOCK_SEQPACKET = ws2_32.SOCK_SEQPACKET;
/// WARNING: this flag is not supported by windows socket functions directly,
/// it is only supported by std.os.socket. Be sure that this value does
/// not share any bits with any of the SOCK_* values.
pub const SOCK_CLOEXEC = 0x10000;
/// WARNING: this flag is not supported by windows socket functions directly,
/// it is only supported by std.os.socket. Be sure that this value does
/// not share any bits with any of the SOCK_* values.
pub const SOCK_NONBLOCK = 0x20000;
pub const IPPROTO_ICMP = ws2_32.IPPROTO_ICMP;
pub const IPPROTO_IGMP = ws2_32.IPPROTO_IGMP;
pub const BTHPROTO_RFCOMM = ws2_32.BTHPROTO_RFCOMM;
pub const IPPROTO_TCP = ws2_32.IPPROTO_TCP;
pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP;
pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6;
pub const IPPROTO_RM = ws2_32.IPPROTO_RM;
pub const nfds_t = c_ulong;
pub const pollfd = ws2_32.pollfd;
pub const POLLRDNORM = ws2_32.POLLRDNORM;
pub const POLLRDBAND = ws2_32.POLLRDBAND;
pub const POLLIN = ws2_32.POLLIN;
pub const POLLPRI = ws2_32.POLLPRI;
pub const POLLWRNORM = ws2_32.POLLWRNORM;
pub const POLLOUT = ws2_32.POLLOUT;
pub const POLLWRBAND = ws2_32.POLLWRBAND;
pub const POLLERR = ws2_32.POLLERR;
pub const POLLHUP = ws2_32.POLLHUP;
pub const POLLNVAL = ws2_32.POLLNVAL;
pub const SOL_SOCKET = ws2_32.SOL_SOCKET;
pub const SO_DEBUG = ws2_32.SO_DEBUG;
pub const SO_ACCEPTCONN = ws2_32.SO_ACCEPTCONN;
pub const SO_REUSEADDR = ws2_32.SO_REUSEADDR;
pub const SO_KEEPALIVE = ws2_32.SO_KEEPALIVE;
pub const SO_DONTROUTE = ws2_32.SO_DONTROUTE;
pub const SO_BROADCAST = ws2_32.SO_BROADCAST;
pub const SO_USELOOPBACK = ws2_32.SO_USELOOPBACK;
pub const SO_LINGER = ws2_32.SO_LINGER;
pub const SO_OOBINLINE = ws2_32.SO_OOBINLINE;
pub const SO_DONTLINGER = ws2_32.SO_DONTLINGER;
pub const SO_EXCLUSIVEADDRUSE = ws2_32.SO_EXCLUSIVEADDRUSE;
pub const SO_SNDBUF = ws2_32.SO_SNDBUF;
pub const SO_RCVBUF = ws2_32.SO_RCVBUF;
pub const SO_SNDLOWAT = ws2_32.SO_SNDLOWAT;
pub const SO_RCVLOWAT = ws2_32.SO_RCVLOWAT;
pub const SO_SNDTIMEO = ws2_32.SO_SNDTIMEO;
pub const SO_RCVTIMEO = ws2_32.SO_RCVTIMEO;
pub const SO_ERROR = ws2_32.SO_ERROR;
pub const SO_TYPE = ws2_32.SO_TYPE;
pub const SO_GROUP_ID = ws2_32.SO_GROUP_ID;
pub const SO_GROUP_PRIORITY = ws2_32.SO_GROUP_PRIORITY;
pub const SO_MAX_MSG_SIZE = ws2_32.SO_MAX_MSG_SIZE;
pub const SO_PROTOCOL_INFOA = ws2_32.SO_PROTOCOL_INFOA;
pub const SO_PROTOCOL_INFOW = ws2_32.SO_PROTOCOL_INFOW;
pub const PVD_CONFIG = ws2_32.PVD_CONFIG;
pub const SO_CONDITIONAL_ACCEPT = ws2_32.SO_CONDITIONAL_ACCEPT;
pub const TCP_NODELAY = ws2_32.TCP_NODELAY;
pub const O_RDONLY = 0o0;
pub const O_WRONLY = 0o1;
pub const O_RDWR = 0o2;
pub const O_CREAT = 0o100;
pub const O_EXCL = 0o200;
pub const O_NOCTTY = 0o400;
pub const O_TRUNC = 0o1000;
pub const O_APPEND = 0o2000;
pub const O_NONBLOCK = 0o4000;
pub const O_DSYNC = 0o10000;
pub const O_SYNC = 0o4010000;
pub const O_RSYNC = 0o4010000;
pub const O_DIRECTORY = 0o200000;
pub const O_NOFOLLOW = 0o400000;
pub const O_CLOEXEC = 0o2000000;
pub const O_ASYNC = 0o20000;
pub const O_DIRECT = 0o40000;
pub const O_LARGEFILE = 0;
pub const O_NOATIME = 0o1000000;
pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
pub const IFNAMESIZE = 30; | lib/std/os/bits/windows.zig |
// // const sokol = @import("sokol");
// const sokol = @import("sokol/sokol.zig");
// const app = sokol.app;
// const sg = sokol.gfx;
// const sgapp = sokol.app_gfx_glue;
// const time = sokol.time;
// const gfx = @import("gfx.zig");
// // usingnamespace @import("math.zig");
// const SpriteBatcher = @import("sprite_batcher.zig").SpriteBatcher;
// // const shader = @import("default.glsl.zig");
// const state = struct {
// var bind: sg.Bindings = .{};
// var pip: sg.Pipeline = .{};
// var pass_action: sg.PassAction = .{};
// // const view = Mat4.lookat(.{ .x=0.0, .y=1.5, .z=6.0 }, Vec3.zero(), Vec3.up());
// var batch: SpriteBatcher = .{
// .allocator = std.testing.allocator
// };
// // var rx: f32 = 0;
// // var ry: f32 = 0;
// };
// export fn init() void {
// sg.setup(.{
// .context = sgapp.context()
// });
// time.setup();
// const vertices = [_]gfx.Vertex {
// // pos color texcoords
// .{ .x=-1.0, .y=-1.0, .z=-1.0, .color=0xFF0000FF, .u= 0, .v= 0 },
// .{ .x= 1.0, .y=-1.0, .z=-1.0, .color=0xFF0000FF, .u=32767, .v= 0 },
// .{ .x= 1.0, .y= 1.0, .z=-1.0, .color=0xFF0000FF, .u=32767, .v=32767 },
// .{ .x=-1.0, .y= 1.0, .z=-1.0, .color=0xFF0000FF, .u= 0, .v=32767 },
// .{ .x=-1.0, .y=-1.0, .z= 1.0, .color=0xFF00FF00, .u= 0, .v= 0 },
// .{ .x= 1.0, .y=-1.0, .z= 1.0, .color=0xFF00FF00, .u=32767, .v= 0 },
// .{ .x= 1.0, .y= 1.0, .z= 1.0, .color=0xFF00FF00, .u=32767, .v=32767 },
// .{ .x=-1.0, .y= 1.0, .z= 1.0, .color=0xFF00FF00, .u= 0, .v=32767 },
// .{ .x=-1.0, .y=-1.0, .z=-1.0, .color=0xFFFF0000, .u= 0, .v= 0 },
// .{ .x=-1.0, .y= 1.0, .z=-1.0, .color=0xFFFF0000, .u=32767, .v= 0 },
// .{ .x=-1.0, .y= 1.0, .z= 1.0, .color=0xFFFF0000, .u=32767, .v=32767 },
// .{ .x=-1.0, .y=-1.0, .z= 1.0, .color=0xFFFF0000, .u= 0, .v=32767 },
// .{ .x= 1.0, .y=-1.0, .z=-1.0, .color=0xFFFF007F, .u= 0, .v= 0 },
// .{ .x= 1.0, .y= 1.0, .z=-1.0, .color=0xFFFF007F, .u=32767, .v= 0 },
// .{ .x= 1.0, .y= 1.0, .z= 1.0, .color=0xFFFF007F, .u=32767, .v=32767 },
// .{ .x= 1.0, .y=-1.0, .z= 1.0, .color=0xFFFF007F, .u= 0, .v=32767 },
// .{ .x=-1.0, .y=-1.0, .z=-1.0, .color=0xFFFF7F00, .u= 0, .v= 0 },
// .{ .x=-1.0, .y=-1.0, .z= 1.0, .color=0xFFFF7F00, .u=32767, .v= 0 },
// .{ .x= 1.0, .y=-1.0, .z= 1.0, .color=0xFFFF7F00, .u=32767, .v=32767 },
// .{ .x= 1.0, .y=-1.0, .z=-1.0, .color=0xFFFF7F00, .u= 0, .v=32767 },
// .{ .x=-1.0, .y= 1.0, .z=-1.0, .color=0xFF007FFF, .u= 0, .v= 0 },
// .{ .x=-1.0, .y= 1.0, .z= 1.0, .color=0xFF007FFF, .u=32767, .v= 0 },
// .{ .x= 1.0, .y= 1.0, .z= 1.0, .color=0xFF007FFF, .u=32767, .v=32767 },
// .{ .x= 1.0, .y= 1.0, .z=-1.0, .color=0xFF007FFF, .u= 0, .v=32767 },
// };
// state.bind.vertex_buffers[0] = sg.makeBuffer(.{
// .data = sg.asRange(vertices)
// });
// // cube index buffer
// const indices = [_]u16 {
// 0, 1, 2, 0, 2, 3,
// 6, 5, 4, 7, 6, 4,
// 8, 9, 10, 8, 10, 11,
// 14, 13, 12, 15, 14, 12,
// 16, 17, 18, 16, 18, 19,
// 22, 21, 20, 23, 22, 20
// };
// state.bind.index_buffer = sg.makeBuffer(.{
// .type = .INDEXBUFFER,
// .data = sg.asRange(indices)
// });
// // create a small checker-board texture
// const pixels = [4*4]u32 {
// 0xFFFFFFFF, 0xFF000000, 0xFFFFFFFF, 0xFF000000,
// 0xFF000000, 0xFFFFFFFF, 0xFF000000, 0xFFFFFFFF,
// 0xFFFFFFFF, 0xFF000000, 0xFFFFFFFF, 0xFF000000,
// 0xFF000000, 0xFFFFFFFF, 0xFF000000, 0xFFFFFFFF,
// };
// var img_desc: sg.ImageDesc = .{
// .width = 4,
// .height = 4,
// };
// img_desc.data.subimage[0][0] = sg.asRange(pixels);
// state.bind.fs_images[shader.SLOT_tex] = sg.makeImage(img_desc);
// var pip_desc: sg.PipelineDesc = .{
// .shader = sg.makeShader(shader.texcubeShaderDesc(sg.queryBackend())),
// .index_type = .UINT16,
// .depth = .{
// .compare = .LESS_EQUAL,
// .write_enabled = true,
// },
// .cull_mode = .BACK
// };
// pip_desc.layout.attrs[shader.ATTR_vs_pos].format = .FLOAT3;
// pip_desc.layout.attrs[shader.ATTR_vs_color0].format = .UBYTE4N;
// pip_desc.layout.attrs[shader.ATTR_vs_texcoord0].format = .SHORT2N;
// state.pip = sg.makePipeline(pip_desc);
// // pass action for clearing the frame buffer
// state.pass_action.colors[0] = .{ .action = .CLEAR, .value = .{ .r=0.25, .g=0.5, .b=0.75, .a=1 } };
// }
// export fn frame() void {
// sg.beginDefaultPass(.{}, app.width(), app.height());
// sg.applyPipeline(state.pip);
// sg.applyBindings(state.bind);
// // sg.applyUniforms(.VS, shader.SLOT_vs_params, sg.asRange(vs_params));
// // sg.draw(0, 36, 1);
// sg.endPass();
// sg.commit();
// }
// export fn event(ev: [*c]const app.Event) void {
// if(ev != null) {
// const e = ev.*;
// _ = e;
// // print("event: {}", .{e.type});
// }
// }
// export fn cleanup() void {
// sg.shutdown();
// }
// pub fn main() anyerror!void {
// app.run(.{
// .init_cb = init,
// .frame_cb = frame,
// .event_cb = event,
// .cleanup_cb = cleanup,
// .width = 640,
// .height = 480,
// .icon = .{
// .sokol_default = true
// },
// .window_title = "pocket"
// });
// }
const std = @import("std");
const err = std.log.err;
const warn = std.log.warn;
const info = std.log.info;
const debug = std.log.debug;
const pretty = @import("prettyprint.zig");
const sokol = @import("sokol/sokol.zig");
const app = sokol.app;
const Core = @import("core.zig").Core;
const Texture = @import("texture.zig").Texture;
usingnamespace @import("sprite_batcher.zig");
const stb = @import("stb/stb.zig");
const GpaType = std.heap.GeneralPurposeAllocator(.{});
var gpa = GpaType{};
var batch: SpriteBatcher = undefined;
var txt: Texture = undefined;
pub fn log(
comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype
) void {
pretty.log(level, scope, format, args);
}
pub fn main() !void {
std.log.notice("test: {}", .{12});
Core.run(.{
.init_fn = init,
.frame_fn = frame,
.event_fn = event,
.cleanup_fn = cleanup,
.width = 500,
.height = 500,
.title = "pocket zig"
});
}
fn init() !void {
txt = try Texture.load("data/red.png");
batch = .{ .allocator = &gpa.allocator };
batch.init();
}
fn frame() !void {
batch.drawSprite(&.{
.texture = txt,
});
}
fn event(e: *const app.Event) !void {
_ = e;
}
fn cleanup() !void {
txt.destroy();
if(gpa.deinit()) {
err("Leaks found", .{});
return error.MemoryLeak;
}
} | src/main.zig |
const std = @import("std");
const assert = std.debug.assert;
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const Form = struct {
answers: [26]bool = [1]bool{false} ** 26,
pub fn parse(self: *@This(), questions: []const u8) void {
for (questions) |question| {
const base = 'a';
var i: usize = base;
while (i <= 'z') : (i += 1) {
if (question == i) {
self.answers[i - base] = true;
}
}
}
}
pub fn countYes(self: @This()) u32 {
var sum: u32 = 0;
for (self.answers) |answer| {
if (answer == true) {
sum += 1;
}
}
return sum;
}
};
pub fn main() !void {
const args = try std.process.argsAlloc(allocator);
defer std.process.argsFree(allocator, args);
if (args.len != 2) {
std.log.err("Please provide an input file path.", .{});
return;
}
const input_file = try std.fs.cwd().openFile(args[1], .{});
defer input_file.close();
const input_reader = input_file.reader();
const buf = try input_reader.readAllAlloc(allocator, 10000000);
defer allocator.free(buf);
std.log.info("The solution for part 1 is {}.", .{part1(buf)});
std.log.info("The solution for part 2 is {}.", .{part2(buf)});
}
pub fn part1(buf: []u8) u32 {
var sum: u32 = 0;
var it = std.mem.split(buf, "\n\n");
while (it.next()) |group| {
var positive: Form = .{};
positive.parse(group);
sum += positive.countYes();
}
return sum;
}
pub fn part2(buf: []u8) !u32 {
var sum: u32 = 0;
var group_it = std.mem.split(buf, "\n\n");
while (group_it.next()) |group| {
var answers = std.ArrayList(Form).init(allocator);
var member_it = std.mem.tokenize(buf, "\n");
while (member_it.next()) |member| {
var form: Form = .{};
form.parse(group);
try answers.append(form);
}
var sum_of_answers: [26]u32 = [1]u32{0} ** 26;
for (answers.items) |answer| {
}
}
return sum;
} | src/day06.zig |
const fmath = @import("index.zig");
const expo2 = @import("_expo2.zig").expo2;
pub fn tanh(x: var) -> @typeOf(x) {
const T = @typeOf(x);
switch (T) {
f32 => @inlineCall(tanhf, x),
f64 => @inlineCall(tanhd, x),
else => @compileError("tanh not implemented for " ++ @typeName(T)),
}
}
// tanh(x) = (exp(x) - exp(-x)) / (exp(x) + exp(-x))
// = (exp(2x) - 1) / (exp(2x) - 1 + 2)
// = (1 - exp(-2x)) / (exp(-2x) - 1 + 2)
fn tanhf(x: f32) -> f32 {
const u = @bitCast(u32, x);
const ux = u & 0x7FFFFFFF;
const ax = @bitCast(f32, ux);
var t: f32 = undefined;
// |x| < log(3) / 2 ~= 0.5493 or nan
if (ux > 0x3F0C9F54) {
// |x| > 10
if (ux > 0x41200000) {
t = 1.0 + 0 / x;
} else {
t = fmath.expm1(2 * x);
t = 1 - 2 / (t + 2);
}
}
// |x| > log(5 / 3) / 2 ~= 0.2554
else if (ux > 0x3E82C578) {
t = fmath.expm1(2 * x);
t = t / (t + 2);
}
// |x| >= 0x1.0p-126
else if (ux >= 0x00800000) {
t = fmath.expm1(-2 * x);
t = -t / (t + 2);
}
// |x| is subnormal
else {
fmath.forceEval(x * x);
t = x;
}
if (u >> 31 != 0) {
-t
} else {
t
}
}
fn tanhd(x: f64) -> f64 {
const u = @bitCast(u64, x);
const w = u32(u >> 32);
const ax = @bitCast(f64, u & (@maxValue(u64) >> 1));
var t: f64 = undefined;
// |x| < log(3) / 2 ~= 0.5493 or nan
if (w > 0x3Fe193EA) {
// |x| > 20 or nan
if (w > 0x40340000) {
t = 1.0 + 0 / x;
} else {
t = fmath.expm1(2 * x);
t = 1 - 2 / (t + 2);
}
}
// |x| > log(5 / 3) / 2 ~= 0.2554
else if (w > 0x3FD058AE) {
t = fmath.expm1(2 * x);
t = t / (t + 2);
}
// |x| >= 0x1.0p-1022
else if (w >= 0x00100000) {
t = fmath.expm1(-2 * x);
t = -t / (t + 2);
}
// |x| is subnormal
else {
fmath.forceEval(f32(x));
t = x;
}
if (u >> 63 != 0) {
-t
} else {
t
}
}
test "tanh" {
fmath.assert(tanh(f32(1.5)) == tanhf(1.5));
fmath.assert(tanh(f64(1.5)) == tanhd(1.5));
}
test "tanhf" {
const epsilon = 0.000001;
fmath.assert(fmath.approxEq(f32, tanhf(0.0), 0.0, epsilon));
fmath.assert(fmath.approxEq(f32, tanhf(0.2), 0.197375, epsilon));
fmath.assert(fmath.approxEq(f32, tanhf(0.8923), 0.712528, epsilon));
fmath.assert(fmath.approxEq(f32, tanhf(1.5), 0.905148, epsilon));
fmath.assert(fmath.approxEq(f32, tanhf(37.45), 1.0, epsilon));
}
test "tanhd" {
const epsilon = 0.000001;
fmath.assert(fmath.approxEq(f64, tanhd(0.0), 0.0, epsilon));
fmath.assert(fmath.approxEq(f64, tanhd(0.2), 0.197375, epsilon));
fmath.assert(fmath.approxEq(f64, tanhd(0.8923), 0.712528, epsilon));
fmath.assert(fmath.approxEq(f64, tanhd(1.5), 0.905148, epsilon));
fmath.assert(fmath.approxEq(f64, tanhd(37.45), 1.0, epsilon));
} | src/tanh.zig |
const wasm4 = @import("wasm4.zig");
const wasm4_omissions = struct { // documented but not provided in wasm4.zig
/// Draws text using the built-in system font, given external string length.
pub extern fn textUtf8(strUtf8: [*]const u8, byteLength: u32, x: i32, y: i32) void;
comptime {
std.debug.assert(!@hasDecl(wasm4, "textUtf8"));
}
/// Draws text using the built-in system font, given external string length.
pub extern fn textUtf16(strUtf8: [*]const u16, byteLength: u32, x: i32, y: i32) void;
comptime {
std.debug.assert(!@hasDecl(wasm4, "textUtf16"));
}
};
const std = @import("std");
pub const canvas_size: comptime_int = wasm4.CANVAS_SIZE; // explicit type of u32 carries no meaning/information
pub const Component = std.meta.Int(.unsigned, std.math.log2_int_ceil(usize, canvas_size));
pub const Coordinate = struct {
x: Component,
y: Component,
};
pub const ScreenLength = Component;
pub const ScreenSize = struct {
width: ScreenLength,
height: ScreenLength,
};
const PaletteColor = struct {
const Native = u32;
red: u8,
green: u8,
blue: u8,
pub fn fromNative(native: Native) PaletteColor {
const getByte = struct {
fn getByte(composite: Native, comptime shift_i: u2) u8 {
const shifted = (composite >> (shift_i * 8));
return @intCast(u8, shifted & @as(u8, 0xFF));
}
}.getByte;
const highest_byte = getByte(native, 3);
if (highest_byte != 0) {
std.log.warn("converting native PaletteColor with highest byte set to {x}", .{highest_byte});
}
return .{
.red = getByte(native, 2),
.green = getByte(native, 1),
.blue = getByte(native, 0),
};
}
pub fn toNative(self: PaletteColor) Native {
return (@as(Native, self.red) << 2 * 8) |
(@as(Native, self.green) << 1 * 8) |
(self.blue << 0 * 8);
}
};
comptime {
std.debug.assert(@TypeOf(wasm4.PALETTE) == *[4]PaletteColor.Native);
}
pub const palette = @ptrCast(*[4]PaletteColor, wasm4.PALETTE);
pub const DrawColor = ?draw_color.PaletteIndex;
const draw_color = struct {
const PaletteIndex = u2;
pub const Native = enum(u4) {
transparent = 0,
@"0" = 1,
@"1" = 2,
@"2" = 3,
@"3" = 4,
};
pub fn fromNative(native: Native) DrawColor {
switch (native) {
.transparent => return null,
else => return @enumToInt(native) - 1,
}
}
pub fn toNative(self: DrawColor) Native {
if (self) |index| {
return @intToEnum(Native, @as(@typeInfo(Native).Enum.tag_type, index) + 1);
}
return .transparent;
}
};
pub const draw_colors = struct {
const Native = u16;
const Length = 4;
comptime {
const expected_draw_colors_ptr_type = *Native;
std.debug.assert(@TypeOf(wasm4.DRAW_COLORS) == expected_draw_colors_ptr_type);
std.debug.assert(@divExact(std.meta.bitCount(Native), std.meta.bitCount(@typeInfo(draw_color.Native).Enum.tag_type)) == Length);
}
const Index = std.meta.Int(.unsigned, std.math.log2_int(usize, Length));
fn checkIndex(index: Index) void {
std.debug.assert(index <= Length);
}
pub fn get(index: Index) !DrawColor {
checkIndex(index);
const shifted = wasm4.DRAW_COLORS.* >> (index * 8);
return draw_color.fromNative(try std.meta.IntToEnum(draw_color.Native, @intCast(u4, shifted & 0xF)));
}
//could add
//`pub fn getMultiple(comptime count: std.meta.Int(.unsigned, std.math.log2_int(Length+1)), indices: [count]Index) ![count]DrawColor;`
//for guaranteeing only one memory access
pub fn getAll() ![Length]DrawColor {
var result: [Length]DrawColor = undefined;
for (result) |*element, index| {
element.* = try get(index);
}
return result;
}
pub fn set(index: Index, value: DrawColor) void {
checkIndex(index);
const ShiftType = std.math.Log2Int(Native);
const shift = @as(ShiftType, index) * 4;
const retention_mask = (~@as(Native, 0)) & (~(@as(Native, 0xF) << shift));
wasm4.DRAW_COLORS.* = ((wasm4.DRAW_COLORS.*) & retention_mask) | (@as(Native, @enumToInt(draw_color.toNative(value))) << shift);
}
//could add
//`pub fn setMultiple(comptime count: std.meta.Int(.unsigned, std.math.log2_int(Length+1)), indices: [count]Index, values: [count]DrawColor) void;`
//for guaranteeing only one memory access
pub fn setAll(values: [Length]DrawColor) void {
var new_composite_value: Native = 0;
for (values) |element, index| {
new_composite_value |= element << (index * 8);
}
wasm4.DRAW_COLORS = draw_color.toNative(new_composite_value);
}
};
pub const Gamepad = struct {
const Native = u8;
comptime {
const expected_gamepad_ptr_type = *const Native;
std.debug.assert(@TypeOf(wasm4.GAMEPAD1) == expected_gamepad_ptr_type);
std.debug.assert(@TypeOf(wasm4.GAMEPAD2) == expected_gamepad_ptr_type);
std.debug.assert(@TypeOf(wasm4.GAMEPAD3) == expected_gamepad_ptr_type);
std.debug.assert(@TypeOf(wasm4.GAMEPAD4) == expected_gamepad_ptr_type);
}
pub const DirectionButtons = struct {
left: bool,
right: bool,
up: bool,
down: bool,
};
pub const none_pressed = Gamepad{
.single_buttons = .{
false,
false,
},
.direction_buttons = .{
.left = false,
.right = false,
.up = false,
.down = false,
},
};
single_buttons: [2]bool,
direction_buttons: DirectionButtons,
pub fn fromNative(native: Native) Gamepad {
const Index = std.math.Log2Int(Native);
const getBit = struct {
fn getBit(composite: Native, index: Index) bool {
return (composite & (@as(Native, 1) << index)) != 0;
}
}.getBit;
for ([_]Index{ 2, 3 }) |index| {
const bit_state = getBit(native, index);
if (bit_state != false) {
std.log.warn("converting native Gamepad with bit {} set to {}", .{ index, bit_state });
}
}
return .{
.single_buttons = .{
getBit(native, 0),
getBit(native, 1),
},
.direction_buttons = .{
.left = getBit(native, 4),
.right = getBit(native, 5),
.up = getBit(native, 6),
.down = getBit(native, 7),
},
};
}
pub fn toNative(self: Gamepad) Native {
return (@as(Native, @boolToInt(self.single_buttons[0])) << 0) |
(@as(Native, @boolToInt(self.single_buttons[1])) << 1) |
(@as(Native, @boolToInt(self.direction_buttons.left)) << 4) |
(@as(Native, @boolToInt(self.direction_buttons.right)) << 5) |
(@as(Native, @boolToInt(self.direction_buttons.up)) << 6) |
(@as(Native, @boolToInt(self.direction_buttons.down)) << 7);
}
};
pub fn GamepadSingleton(comptime native_address: *const Gamepad.Native) type {
return struct {
pub fn get() Gamepad {
return Gamepad.fromNative(native_address.*);
}
};
}
pub const gamepads = [_]type{
GamepadSingleton(wasm4.GAMEPAD1),
GamepadSingleton(wasm4.GAMEPAD2),
GamepadSingleton(wasm4.GAMEPAD3),
GamepadSingleton(wasm4.GAMEPAD4),
};
pub const BlitEffectFlags = struct {
const Native = u32;
pub const none = BlitEffectFlags{
.flip_x = false,
.flip_y = false,
.rotate_anti_clockwise_quarter = false,
};
flip_x: bool,
flip_y: bool,
rotate_anti_clockwise_quarter: bool,
pub fn toNative(self: BlitEffectFlags) Native {
const flip_x = if (self.flip_x) wasm4.BLIT_FLIP_X else 0;
const flip_y = if (self.flip_y) wasm4.BLIT_FLIP_Y else 0;
const rotate_anti_clockwise_quarter = if (self.rotate_anti_clockwise_quarter) wasm4.BLIT_ROTATE else 0;
return flip_x |
flip_y |
rotate_anti_clockwise_quarter;
}
};
pub const BlitFlags = struct {
const Native = u32;
pub const BitsPerPixel = enum {
one,
two,
pub fn numeric(self: BitsPerPixel) u2 {
switch (self) {
.one => return 1,
.two => return 2,
}
}
};
bits_per_pixel: BitsPerPixel,
effects: BlitEffectFlags,
pub fn empty1BitPerPixel() BlitFlags {
return .{
.bits_per_pixel = .one,
.effects = BlitEffectFlags.none,
};
}
pub fn empty2BitsPerPixel() BlitFlags {
return .{
.bits_per_pixel = .two,
.effects = BlitEffectFlags.none,
};
}
pub fn fromNative(native: Native) BlitFlags {
const Index = std.math.Log2Int(Native);
const getBit = struct {
fn getBit(composite: Native, index: Index) bool {
return (composite & (@as(Native, 1) << index)) != 0;
}
}.getBit;
{
const first_unused_bit_index = 4;
comptime {
const first_unused_bit_mask = @as(Native, 1) << first_unused_bit_index;
std.debug.assert(first_unused_bit_mask > wasm4.BLIT_1BPP);
std.debug.assert(first_unused_bit_mask > wasm4.BLIT_2BPP);
std.debug.assert(first_unused_bit_mask > wasm4.BLIT_FLIP_X);
std.debug.assert(first_unused_bit_mask > wasm4.BLIT_FLIP_Y);
std.debug.assert(first_unused_bit_mask > wasm4.BLIT_ROTATE);
}
{
var unused_bit_index = first_unused_bit_index;
while (true) : (unused_bit_index += 1) {
if (getBit(native, unused_bit_index)) {
std.log.warn("converting native BlitFlags with unused bit #{d} set", .{unused_bit_index});
}
}
}
}
comptime {
std.debug.assert(wasm4.BLIT_1BPP == 0);
}
const bits_per_pixel = if (getBit(native, std.math.log2_int(wasm4.BLIT_2BPP))) .two else .one;
return .{
.bits_per_pixel = bits_per_pixel,
.effects = .{
.flip_x = getBit(native, std.math.log2_int(wasm4.BLIT_FLIP_X)),
.flip_y = getBit(native, std.math.log2_int(wasm4.BLIT_FLIP_Y)),
.rotate_anti_clockwise_quarter = getBit(native, std.math.log2_int(wasm4.BLIT_ROTATE)),
},
};
}
pub fn toNative(self: BlitFlags) Native {
const bits_per_pixel = switch (self.bits_per_pixel) {
.one => wasm4.BLIT_1BPP,
.two => wasm4.BLIT_2BPP,
};
const effects = self.effects.toNative();
return bits_per_pixel | effects;
}
};
pub fn Sprite(comptime dimensions: ScreenSize, comptime bits_per_pixel: BlitFlags.BitsPerPixel) type {
return struct {
pub const dimensions = dimensions;
pub const width = dimensions.width;
pub const height = dimensions.height;
pub const bits_per_pixel = bits_per_pixel;
pub const PixelBits = std.meta.Int(.unsigned, bits_per_pixel.numeric());
pub const Data = std.PackedIntArray(PixelBits, width * height);
data: Data,
pub fn init(arg: [((width * height) + 7) / 8]u8) @This() {
var self: @This() = undefined;
self.data.bytes = arg; // weird "cannot assign to constant" error
return self;
}
pub fn blit(self: *const @This(), top_left: Coordinate, effect_flags: BlitEffectFlags, colors: [2]DrawColor) void {
draw_colors.set(0, colors[0]);
draw_colors.set(1, colors[1]);
self.retainedColorsBlit(top_left, effect_flags);
}
pub fn blitSub(self: *const @This(), top_left: Coordinate, sub_dimensions: ScreenSize, source_top_left: Coordinate, horizontal_stride: ?ScreenLength, effect_flags: BlitEffectFlags, colors: [4]DrawColor) void {
draw_colors.set(0, colors[0]);
draw_colors.set(1, colors[1]);
draw_colors.set(2, colors[2]);
draw_colors.set(3, colors[3]);
self.retainedColorsBlitSub(top_left, sub_dimensions, source_top_left, horizontal_stride, effect_flags);
}
pub fn retainedColorsBlit(self: *const @This(), top_left: Coordinate, effect_flags: BlitEffectFlags) void {
retained_colors.blitFixed(
bits_per_pixel,
dimensions,
&self.data.bytes,
top_left,
effect_flags,
);
}
pub fn retainedColorsBlitSub(self: *const @This(), top_left: Coordinate, sub_dimensions: ScreenSize, source_top_left: Coordinate, horizontal_stride: ?ScreenLength, effect_flags: BlitEffectFlags) void {
retained_colors.blitSub(
bits_per_pixel,
dimensions,
&self.data.bytes,
top_left,
sub_dimensions,
source_top_left,
horizontal_stride orelse width,
effect_flags,
);
}
};
}
pub const Frequency = u16;
pub const FrequencySlide = struct {
pub const Native = u32;
start: Frequency,
end: Frequency,
pub fn toNative(self: FrequencySlide) Native {
return (@as(Native, self.start) << 0) |
(@as(Native, self.end) << 16);
}
};
pub fn checkVolume(volume: u7) !void {
if (volume > 100) {
return error.OutOfRange;
}
}
pub const Adsr = struct {
const Native = u32;
pub const stop = Adsr.init(0, 0, 0, 0);
attack_frames: u8,
decay_frames: u8,
sustain_frames: u8,
release_frames: u8,
pub fn init(attack_frames: u8, decay_frames: u8, sustain_frames: u8, release_frames: u8) Adsr {
return .{
.attack_frames = attack_frames,
.decay_frames = decay_frames,
.sustain_frames = sustain_frames,
.release_frames = release_frames,
};
}
pub fn toNative(self: Adsr) Native {
return (@as(Native, self.attack_frames) << (3 * 8)) |
(@as(Native, self.decay_frames) << (2 * 8)) |
(@as(Native, self.release_frames) << (1 * 8)) |
(@as(Native, self.sustain_frames) << (0 * 8));
}
};
pub const Instrument = union(enum) {
const Native = u4;
pub const PulseDuty = enum {
eighth,
quarter,
half,
three_quarters,
pub fn toNative(self: PulseDuty) u4 {
switch (self) {
.eighth => return wasm4.TONE_MODE1,
.quarter => return wasm4.TONE_MODE2,
.half => return wasm4.TONE_MODE3,
.three_quarters => return wasm4.TONE_MODE4,
}
}
};
pulse_0: PulseDuty,
pulse_1: PulseDuty,
triangle,
noise,
pub fn toNative(self: Instrument) Native {
switch (self) {
.pulse_0, .pulse_1 => |duty| {
const instrument_index: u4 = switch (self) {
else => unreachable,
.pulse_0 => wasm4.TONE_PULSE1,
.pulse_1 => wasm4.TONE_PULSE2,
};
return instrument_index | duty.toNative();
},
.triangle => return wasm4.TONE_TRIANGLE,
.noise => return wasm4.TONE_NOISE,
}
}
};
pub fn tone(frequency_slide: FrequencySlide, adsr: Adsr, volume: u7, instrument: Instrument) !void {
try checkVolume(volume);
wasm4.tone(frequency_slide.toNative(), adsr.toNative(), volume, instrument.toNative());
}
pub fn text(str: [*:0]const u8, top_left: Coordinate, color: DrawColor) void {
draw_colors.set(0, color);
retained_colors.text(str, top_left);
}
pub fn textUtf8(str: []const u8, top_left: Coordinate, color: DrawColor) void {
draw_colors.set(0, color);
retained_colors.textUtf8(str, top_left);
}
pub fn textUtf16(str: []const u16, top_left: Coordinate, color: DrawColor) void {
draw_colors.set(0, color);
retained_colors.textUtf16(str, top_left);
}
pub fn blitFixed(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
comptime dimensions: ScreenSize,
sprite_data: [((dimensions.width * dimensions.height * bits_per_pixel.numeric()) + 7) / 8]u8,
top_left: Coordinate,
effect_flags: BlitEffectFlags,
colors: [2]DrawColor,
) void {
draw_colors.set(0, colors[0]);
draw_colors.set(1, colors[1]);
retained_colors.blitFixed(bits_per_pixel, dimensions, &sprite_data, top_left, effect_flags);
}
pub fn blit(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
dimensions: ScreenSize,
sprite_data: []const u8,
top_left: Coordinate,
effect_flags: BlitEffectFlags,
colors: [2]DrawColor,
) void {
draw_colors.set(0, colors[0]);
draw_colors.set(1, colors[1]);
retained_colors.blit(
bits_per_pixel,
dimensions,
sprite_data,
top_left,
effect_flags,
);
}
pub fn blitSub(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
sprite_data: []const u8,
sub_dimensions: ScreenSize,
source_top_left: Coordinate,
horizontal_stride: ScreenLength,
effect_flags: BlitEffectFlags,
colors: [4]DrawColor,
) void {
draw_colors.set(0, colors[0]);
draw_colors.set(1, colors[1]);
draw_colors.set(2, colors[2]);
draw_colors.set(3, colors[3]);
retained_colors.blitSub(
bits_per_pixel,
sprite_data,
sub_dimensions,
source_top_left,
horizontal_stride,
effect_flags,
);
}
pub const retained_colors = struct {
pub fn text(str: [*:0]const u8, top_left: Coordinate) void {
wasm4.text(str, top_left.x, top_left.y);
}
pub fn textUtf8(str: []const u8, top_left: Coordinate) void {
wasm4_omissions.textUtf8(str.ptr, str.len, top_left.x, top_left.y);
}
pub fn textUtf16(str: []const u16, top_left: Coordinate) void {
wasm4_omissions.textUtf16(str.ptr, str.len, top_left.x, top_left.y);
}
pub fn blitFixed(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
comptime dimensions: ScreenSize,
sprite_data: [((dimensions.width * dimensions.height * bits_per_pixel.numeric()) + 7) / 8]u8,
top_left: Coordinate,
effect_flags: BlitEffectFlags,
) void {
retained_colors.blit(bits_per_pixel, dimensions, &sprite_data, top_left, effect_flags);
}
pub fn blit(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
dimensions: ScreenSize,
sprite_data: []const u8,
top_left: Coordinate,
effect_flags: BlitEffectFlags,
) void {
const required_data_length_pixels = dimensions.width * dimensions.height;
const required_data_length_bytes = ((required_data_length_pixels * bits_per_pixel.numeric()) + 7) / 8;
var blit_flags = comptime switch (bits_per_pixel) {
.one => BlitFlags.empty1BitPerPixel(),
.two => BlitFlags.empty2BitsPerPixel(),
};
blit_flags.effects = effect_flags;
wasm4.blit(
sprite_data[0..required_data_length_bytes].ptr,
top_left.x,
top_left.y,
dimensions.width,
dimensions.height,
blit_flags.toNative(),
);
}
pub fn blitSub(
comptime bits_per_pixel: BlitFlags.BitsPerPixel,
sprite_data: []const u8,
top_left: Coordinate,
sub_dimensions: ScreenSize,
source_top_left: Coordinate,
horizontal_stride: ScreenLength,
effect_flags: BlitEffectFlags,
) void {
const required_data_length_pixels = (source_top_left.y + sub_dimensions.height) * horizontal_stride + (source_top_left.x + sub_dimensions.width);
const required_data_length_bytes = ((required_data_length_pixels * bits_per_pixel.numeric()) + 7) / 8;
var blit_flags = comptime switch (bits_per_pixel) {
.one => BlitFlags.empty1BitPerPixel(),
.two => BlitFlags.empty2BitsPerPixel(),
};
blit_flags.effects = effect_flags;
wasm4.blitSub(
sprite_data[0..required_data_length_bytes].ptr,
top_left.x,
top_left.y,
sub_dimensions.width,
sub_dimensions.height,
source_top_left.x,
source_top_left.y,
horizontal_stride,
blit_flags.toNative(),
);
}
}; | src/wrapper4.zig |
const interrupt = @import("interrupt.zig");
const isr = @import("isr.zig");
const layout = @import("layout.zig");
const pmem = @import("pmem.zig");
const scheduler = @import("scheduler.zig");
const tty = @import("tty.zig");
const x86 = @import("x86.zig");
const assert = @import("std").debug.assert;
// A single entry in a page table.
const PageEntry = usize;
// Page table structures (mapped with the recursive PD trick).
const PD = @intToPtr(&PageEntry, layout.PD);
const PTs = @intToPtr(&PageEntry, layout.PTs);
// Page mapping flags. Refer to the official Intel manual.
pub const PAGE_PRESENT = (1 << 0);
pub const PAGE_WRITE = (1 << 1);
pub const PAGE_USER = (1 << 2);
pub const PAGE_4MB = (1 << 7);
pub const PAGE_GLOBAL = (1 << 8);
pub const PAGE_ALLOCATED = (1 << 9);
// Calculate the PD and PT indexes given a virtual address.
fn pdIndex(v_addr: usize) usize { return v_addr >> 22; }
fn ptIndex(v_addr: usize) usize { return (v_addr >> 12) & 0x3FF; }
// Return pointers to the PD and PT entries given a virtual address.
fn pdEntry(v_addr: usize) &PageEntry { return &PD[pdIndex(v_addr)]; }
fn ptEntry(v_addr: usize) &PageEntry {
return &PTs[(pdIndex(v_addr) * 0x400) + ptIndex(v_addr)];
}
////
// Map a virtual page to a physical one with the given flags.
//
// Arguments:
// v_addr: Virtual address of the page to be mapped.
// p_addr: Physical address to map the page to (or null to allocate it).
// flags: Paging flags (protection etc.).
//
pub fn map(v_addr: usize, p_addr: ?usize, flags: u32) void {
// Do not touch the identity mapped area.
assert (v_addr >= layout.IDENTITY);
const pd_entry = pdEntry(v_addr);
const pt_entry = ptEntry(v_addr);
// If the relevant Page Directory entry is empty, we need a new Page Table.
if (*pd_entry == 0) {
// Allocate the new Page Table and point the Page Directory entry to it.
// Permissive flags are set in the PD, as restrictions are set in the PT entry.
*pd_entry = pmem.allocate() | flags | PAGE_PRESENT | PAGE_WRITE | PAGE_USER;
x86.invlpg(@ptrToInt(pt_entry));
zeroPageTable(x86.pageBase(pt_entry));
}
if (p_addr) |p| {
// If the currently mapped physical page was allocated, free it.
if (*pt_entry & PAGE_ALLOCATED != 0) pmem.free(*pt_entry);
// Point the Page Table entry to the specified physical page.
*pt_entry = x86.pageBase(p) | flags | PAGE_PRESENT;
} else {
if (*pt_entry & PAGE_ALLOCATED != 0) {
// Reuse the existing allocated page.
*pt_entry = x86.pageBase(*pt_entry) | flags | PAGE_PRESENT | PAGE_ALLOCATED;
} else {
// Allocate a new physical page.
*pt_entry = pmem.allocate() | flags | PAGE_PRESENT | PAGE_ALLOCATED;
}
}
x86.invlpg(v_addr);
}
////
// Unmap a virtual page.
//
// Arguments:
// v_addr: Virtual address of the page to be unmapped.
//
pub fn unmap(v_addr: usize) void {
assert (v_addr >= layout.IDENTITY);
const pd_entry = pdEntry(v_addr);
if (*pd_entry == 0) return;
const pt_entry = ptEntry(v_addr);
// Deallocate the physical page if it was allocated during mapping.
if (*pt_entry & PAGE_ALLOCATED != 0) pmem.free(*pt_entry);
*pt_entry = 0;
x86.invlpg(v_addr);
}
////
// Map a virtual memory zone.
//
// Arguments:
// v_addr: Beginning of the virtual memory zone.
// p_addr: Beginning of the physical memory zone (or null to allocate it).
// size: Size of the memory zone.
// flags: Paging flags (protection etc.)
//
pub fn mapZone(v_addr: usize, p_addr: ?usize, size: usize, flags: u32) void {
var i: usize = 0;
while (i < size) : (i += x86.PAGE_SIZE) {
map(v_addr + i, if (p_addr) |p| p + i else null, flags);
}
}
////
// Unmap a virtual memory zone.
//
// Arguments:
// v_addr: Beginning of the virtual memory zone.
// size: Size of the memory zone.
//
pub fn unmapZone(v_addr: usize, size: usize) void {
var i: usize = 0;
while (i < size) : (i += x86.PAGE_SIZE) {
unmap(v_addr + i);
}
}
////
// Enable the paging system (defined in assembly).
//
// Arguments:
// phys_pd: Physical pointer to the page directory.
//
extern fn setupPaging(phys_pd: usize)void;
////
// Fill a page table with zeroes.
//
// Arguments:
// page_table: The address of the table.
//
fn zeroPageTable(page_table: &PageEntry) void {
const pt = @ptrCast(&u8, page_table);
@memset(pt, 0, x86.PAGE_SIZE);
}
////
// Initialize a new address space.
//
// Returns:
// The address of the new Page Directory.
//
pub fn createAddressSpace() usize {
// Allocate space for a new Page Directory.
const phys_pd = pmem.allocate();
const virt_pd = @intToPtr(&PageEntry, layout.TMP);
// Map it somewhere and initialize it.
map(@ptrToInt(virt_pd), phys_pd, PAGE_WRITE);
zeroPageTable(virt_pd);
// Copy the kernel space of the original address space.
var i: usize = 0;
while (i < pdIndex(layout.USER)) : (i += 1) {
virt_pd[i] = PD[i];
}
// Last PD entry -> PD itself (to map page tables at the end of memory).
virt_pd[1023] = phys_pd | PAGE_PRESENT | PAGE_WRITE;
return phys_pd;
}
////
// Unmap and deallocate all userspace in the current address space.
//
pub fn destroyAddressSpace() void {
var i: usize = pdIndex(layout.USER);
// NOTE: Preserve 1024th entry (contains the page tables).
while (i < 1023) : (i += 1) {
const v_addr = i * 0x400000;
const pd_entry = pdEntry(v_addr);
if (*pd_entry == 0) continue;
unmapZone(v_addr, 0x400000);
}
// TODO: deallocate page directory.
// TODO: deallocate page tables.
}
////
// Handler for page faults interrupts.
//
fn pageFault() void {
// Get the faulting address from the CR2 register.
const address = x86.readCR2();
// Get the error code from the interrupt stack.
const code = isr.context.error_code;
const err = if (code & PAGE_PRESENT != 0) "protection" else "non-present";
const operation = if (code & PAGE_WRITE != 0) "write" else "read";
const privilege = if (code & PAGE_USER != 0) "user" else "kernel";
// Handle return from thread.
if (address == layout.THREAD_DESTROY) {
const thread = ??scheduler.current();
return thread.destroy();
}
// Trigger a kernel panic with details about the error.
tty.panic(
\\page fault
\\ address: 0x{X}
\\ error: {}
\\ operation: {}
\\ privilege: {}
, address, err, operation, privilege);
}
////
// Initialize the virtual memory system.
//
pub fn initialize() void {
tty.step("Initializing Paging");
// Ensure we map all the page stack.
assert (pmem.stack_end < layout.IDENTITY);
// Allocate a page for the Page Directory.
const pd = @intToPtr(&PageEntry, pmem.allocate());
zeroPageTable(pd);
// Identity map the kernel (first 8 MB) and point last entry of PD to the PD itself.
pd[0] = 0x000000 | PAGE_PRESENT | PAGE_WRITE | PAGE_4MB | PAGE_GLOBAL;
pd[1] = 0x400000 | PAGE_PRESENT | PAGE_WRITE | PAGE_4MB | PAGE_GLOBAL;
pd[1023] = @ptrToInt(pd) | PAGE_PRESENT | PAGE_WRITE;
// The recursive PD trick maps the whole paging hierarchy at the end of the address space.
interrupt.register(14, pageFault); // Register the page fault handler.
setupPaging(@ptrToInt(pd)); // Enable paging.
tty.stepOK();
} | kernel/vmem.zig |
const std = @import("std");
pub const ASTNode = union(enum) {
alias: *Alias,
and_: *And,
annotation: *Annotation,
annotation_def: *AnnotationDef,
arg: *Arg,
array_literal: *ArrayLiteral,
asm_: *Asm,
asm_operand: *AsmOperand,
assign: *Assign,
block: *Block,
bool_literal: *BoolLiteral,
break_: *Break,
c_struct_or_union_def: *CStructOrUnionDef,
call: *Call,
case: *Case,
cast: *Cast,
char_literal: *CharLiteral,
class_def: *ClassDef,
class_var: *ClassVar,
def: *Def,
double_splat: *DoubleSplat,
enum_def: *EnumDef,
exception_handler: *ExceptionHandler,
expressions: *Expressions,
extend: *Extend,
external_var: *ExternalVar,
fun_def: *FunDef,
generic: *Generic,
global: *Global,
hash_literal: *HashLiteral,
if_: *If,
implicit_obj: *ImplicitObj,
include: *Include,
instance_size_of: *InstanceSizeOf,
instance_var: *InstanceVar,
is_a: *IsA,
lib_def: *LibDef,
macro: *Macro,
macro_expression: *MacroExpression,
macro_for: *MacroFor,
macro_if: *MacroIf,
macro_literal: *MacroLiteral,
macro_var: *MacroVar,
macro_verbatim: *MacroVerbatim,
magic_constant: *MagicConstant,
metaclass: *Metaclass,
module_def: *ModuleDef,
multi_assign: *MultiAssign,
named_argument: *NamedArgument,
named_tuple_literal: *NamedTupleLiteral,
next: *Next,
nil: *Nil,
nilable_cast: *NilableCast,
nop: *Nop,
not: *Not,
number_literal: *NumberLiteral,
offset_of: *OffsetOf,
op_assign: *OpAssign,
or_: *Or,
out: *Out,
path: *Path,
pointer_of: *PointerOf,
proc_literal: *ProcLiteral,
proc_notation: *ProcNotation,
proc_pointer: *ProcPointer,
range_literal: *RangeLiteral,
read_instance_var: *ReadInstanceVar,
regex_literal: *RegexLiteral,
require: *Require,
rescue: *Rescue,
responds_to: *RespondsTo,
return_: *Return,
select: *Select,
self: *Self,
size_of: *SizeOf,
splat: *Splat,
string_interpolation: *StringInterpolation,
string_literal: *StringLiteral,
symbol_literal: *SymbolLiteral,
tuple_literal: *TupleLiteral,
type_declaration: *TypeDeclaration,
type_def: *TypeDef,
type_of: *TypeOf,
underscore: *Underscore,
uninitialized_var: *UninitializedVar,
union_: *Union,
unless: *Unless,
until: *Until,
var_: *Var,
visibility_modifier: *VisibilityModifier,
when: *When,
while_: *While,
yield: *Yield,
pub fn isNop(self: @This()) bool {
return self == .nop;
}
pub fn isTrueLiteral(self: @This()) bool {
return self == .bool_literal and self.bool_literal.value;
}
pub fn isFalseLiteral(self: @This()) bool {
return self == .bool_literal and !self.bool_literal.value;
}
pub fn singleExpression(self: @This()) ASTNode {
if (self == .expressions) {
if (self.expressions.singleExpression()) |single_expression| {
return single_expression;
}
}
return self;
}
};
pub const Nop = struct {
pub fn create(allocator: std.mem.Allocator) !*@This() {
return try allocator.create(@This());
}
pub fn new(allocator: std.mem.Allocator) !ASTNode {
return ASTNode { .nop = try create(allocator) };
}
};
pub const Nil = struct {
pub fn create(allocator: std.mem.Allocator) !*@This() {
return try allocator.create(@This());
}
pub fn new(allocator: std.mem.Allocator) !ASTNode {
return ASTNode { .nil = try create(allocator) };
}
};
pub const Expressions = struct {
pub const Keyword = enum {
None,
Paren,
Begin,
};
expressions: []ASTNode,
keyword: Keyword = .None,
pub fn create(allocator: std.mem.Allocator, expressions: []ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .expressions = expressions };
return instance;
}
pub fn new(allocator: std.mem.Allocator, expressions: []ASTNode) !ASTNode {
return ASTNode { .expressions = try create(allocator, expressions) };
}
pub fn from(allocator: std.mem.Allocator, obj: anytype) !ASTNode {
switch (@TypeOf(obj)) {
@TypeOf(null) => return Nop.new(allocator),
[]ASTNode => {
switch (obj.len) {
0 => return Nop.new(allocator),
1 => return obj[0],
else => return new(allocator, obj),
}
},
ASTNode => return obj,
?ASTNode => return if (obj) |node| node else Nop.new(allocator),
else => @compileError("Expected pointer or array, found " ++ @typeName(@TypeOf(obj))),
}
}
pub fn singleExpression(self: @This()) ?ASTNode {
if (self.expressions.len == 1) {
return self.expressions[0].singleExpression();
} else {
return null;
}
}
};
pub const BoolLiteral = struct {
value: bool,
pub fn create(allocator: std.mem.Allocator, value: bool) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .value = value };
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: bool) !ASTNode {
return ASTNode { .bool_literal = try create(allocator, value) };
}
};
pub const NumberKind = enum {
I8,
I16,
I32,
I64,
I128,
U8,
U16,
U32,
U64,
U128,
F32,
F64,
pub fn bytesize(self: @This()) u8 {
return switch (self) {
.I8 => 8,
.I16 => 16,
.I32 => 32,
.I64 => 64,
.I128 => 128,
.U8 => 8,
.U16 => 16,
.U32 => 32,
.U64 => 64,
.U128 => 128,
.F32 => 32,
.F64 => 64,
};
}
pub fn isSignedInt(self: @This()) bool {
return switch (self) {
.I8, .I16, .I32, .I64, .I128 => true,
else => false,
};
}
pub fn isUnignedInt(self: @This()) bool {
return switch (self) {
.U8, .U16, .U32, .U64, .U128 => true,
else => false,
};
}
pub fn isFloat(self: @This()) bool {
return switch (self) {
.F32, .F64 => true,
else => false,
};
}
pub fn fromNumber(number: anytype) @This() {
switch (@TypeOf(number)) {
i8 => return .I8,
i16 => return .I16,
i32 => return .I32,
i64 => return .I64,
i128 => return .I128,
u8 => return .U8,
u16 => return .U16,
u32 => return .U32,
u64 => return .U64,
u128 => return .U128,
f32 => return .F32,
f64 => return .F64,
comptime_int => comptime {
if (number >= std.math.minInt(i32) and number <= std.math.maxInt(i32)) return .I32;
if (number >= std.math.minInt(i64) and number <= std.math.maxInt(i64)) return .I64;
if (number >= std.math.minInt(i128) and number <= std.math.maxInt(i128)) return .I128;
if (number >= std.math.minInt(u128) and number <= std.math.maxInt(u128)) return .U128;
@compileError("Unsupported int for NumberLiteral: " ++ std.fmt.comptimePrint("{}", .{number}));
},
comptime_float => comptime {
if (number == 0.0) return .F32;
if (@fabs(number) >= std.math.f32_min and @fabs(number) <= std.math.f32_max) return .F32;
if (@fabs(number) >= std.math.f64_min and @fabs(number) <= std.math.f64_max) return .F64;
@compileError("Unsupported float for NumberLiteral: " ++ std.fmt.comptimePrint("{}", .{number}));
},
else => @compileError("Unsupported number type for NumberLiteral: " ++ @typeName(@TypeOf(number))),
}
}
pub fn numberType(self: @This()) type {
return switch (self) {
.I8 => i8,
.I16 => i16,
.I32 => i32,
.I64 => i64,
.I128 => i128,
.U8 => u8,
.U16 => u16,
.U32 => u32,
.U64 => u64,
.U128 => u128,
.F32 => f32,
.F64 => f64,
};
}
};
pub const NumberLiteral = struct {
value: []const u8,
kind: NumberKind = .I32,
pub fn create(allocator: std.mem.Allocator, value: anytype) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.value = try std.fmt.allocPrint(allocator, "{d}", .{value}),
.kind = NumberKind.fromNumber(value),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: anytype) !ASTNode {
return ASTNode { .number_literal = try create(allocator, value) };
}
pub fn hasSign(self: @This()) bool {
return self.value[0] == '+' or self.value[0] == '-';
}
};
pub const CharLiteral = struct {
value: u8,
pub fn create(allocator: std.mem.Allocator, value: u8) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .value = value };
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: u8) !ASTNode {
return ASTNode { .char_literal = try create(allocator, value) };
}
};
pub const StringLiteral = struct {
value: []const u8,
pub fn create(allocator: std.mem.Allocator, value: []const u8) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .value = value };
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: []const u8) !ASTNode {
return ASTNode { .string_literal = try create(allocator, value) };
}
};
pub const StringInterpolation = struct {
expressions: []ASTNode,
heredoc_indent: i32 = 0,
pub fn create(allocator: std.mem.Allocator, expressions: []ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .expressions = expressions };
return instance;
}
pub fn new(allocator: std.mem.Allocator, expressions: []ASTNode) !ASTNode {
return ASTNode { .string_interpolation = try create(allocator, expressions) };
}
};
pub const SymbolLiteral = struct {
value: []const u8,
pub fn create(allocator: std.mem.Allocator, value: []const u8) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .value = value };
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: []const u8) !ASTNode {
return ASTNode { .symbol_literal = try create(allocator, value) };
}
};
pub const ArrayLiteral = struct {
elements: []ASTNode,
of: ?ASTNode = null,
name: ?ASTNode = null,
pub fn create(allocator: std.mem.Allocator, elements: []ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .elements = elements };
return instance;
}
pub fn new(allocator: std.mem.Allocator, elements: []ASTNode) !ASTNode {
return ASTNode { .array_literal = try create(allocator, elements) };
}
pub fn map(allocator: std.mem.Allocator, values: anytype, block: anytype) !ASTNode {
// TODO: validate block
var new_values = try allocator.alloc(ASTNode, values.len);
for (values) |value, index| {
new_values[index] = try block.call(allocator, value);
}
return new(allocator, new_values);
}
pub fn mapWithIndex(allocator: std.mem.Allocator, values: anytype, block: anytype) !ASTNode {
// TODO: validate block
var new_values = try allocator.alloc(ASTNode, values.len);
for (values) |value, index| {
new_values[index] = try block.call(allocator, value, index);
}
return new(allocator, new_values);
}
};
pub const HashLiteral = struct {
entries: []Entry,
of: ?ASTNode = null,
name: ?ASTNode = null,
pub fn create(allocator: std.mem.Allocator, entries: []Entry) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .entries = entries };
return instance;
}
pub fn new(allocator: std.mem.Allocator, entries: []Entry) !ASTNode {
return ASTNode { .hash_literal = try create(allocator, entries) };
}
pub const Entry = struct { key: ASTNode, value: ASTNode };
};
pub const NamedTupleLiteral = struct {
entries: []Entry,
pub fn create(allocator: std.mem.Allocator, entries: []Entry) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .entries = entries };
return instance;
}
pub fn new(allocator: std.mem.Allocator, entries: []Entry) !ASTNode {
return ASTNode { .named_tuple_literal = try create(allocator, entries) };
}
pub const Entry = struct { key: []const u8, value: ASTNode };
};
pub const RangeLiteral = struct {
from: ASTNode,
to: ASTNode,
is_exclusive: bool,
pub fn create(allocator: std.mem.Allocator, from: ASTNode, to: ASTNode, is_exclusive: bool) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.from = from,
.to = to,
.is_exclusive = is_exclusive,
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, from: ASTNode, to: ASTNode, is_exclusive: bool) !ASTNode {
return ASTNode { .range_literal = try create(allocator, from, to, is_exclusive) };
}
};
pub const RegexOptions = struct {
ignore_case: bool = false,
multiline: bool = false,
extended: bool = false,
anchored: bool = false,
utf_8: bool = false,
no_utf8_check: bool = false,
dupnames: bool = false,
ucp: bool = false,
};
pub const RegexLiteral = struct {
value: ASTNode,
options: RegexOptions = .{},
pub fn create(allocator: std.mem.Allocator, value: ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .value = value };
return instance;
}
pub fn new(allocator: std.mem.Allocator, value: ASTNode) !ASTNode {
return ASTNode { .regex_literal = try create(allocator, value) };
}
};
pub const TupleLiteral = struct {
elements: []ASTNode,
pub fn create(allocator: std.mem.Allocator, elements: []ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .elements = elements };
return instance;
}
pub fn new(allocator: std.mem.Allocator, elements: []ASTNode) !ASTNode {
return ASTNode { .tuple_literal = try create(allocator, elements) };
}
};
pub const Var = struct {
name: []const u8,
pub fn create(allocator: std.mem.Allocator, name: []const u8) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{ .name = name };
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: []const u8) !ASTNode {
return ASTNode { .var_ = try create(allocator, name) };
}
};
pub const Block = struct {
args: []*Var,
body: ASTNode,
call: ?*Call = null,
splat_index: ?i32 = null,
pub fn create(allocator: std.mem.Allocator, args: []*Var, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.args = args,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, args: []*Var, body: ?ASTNode) !ASTNode {
return ASTNode { .block = try create(allocator, args, body) };
}
};
pub const Call = struct {
obj: ?ASTNode,
name: []const u8,
args: []ASTNode,
block: ?*Block = null,
block_arg: ?ASTNode = null,
named_args: ?[]*NamedArgument = null,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
is_global: bool = false,
is_expansion: bool = false,
has_parentheses: bool = false,
};
pub const NamedArgument = struct {
name: []const u8,
value: ASTNode,
};
pub const If = struct {
cond: ASTNode,
then: ASTNode,
else_: ASTNode,
is_ternary: bool = false,
pub fn create(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.cond = cond,
.then = try Expressions.from(allocator, then),
.else_ = try Expressions.from(allocator, else_),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !ASTNode {
return ASTNode { .if_ = try create(allocator, cond, then, else_) };
}
};
pub const Unless = struct {
cond: ASTNode,
then: ASTNode,
else_: ASTNode,
pub fn create(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.cond = cond,
.then = try Expressions.from(allocator, then),
.else_ = try Expressions.from(allocator, else_),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !ASTNode {
return ASTNode { .unless = try create(allocator, cond, then, else_) };
}
};
pub const Assign = struct {
target: ASTNode,
value: ASTNode,
doc: ?[]const u8 = null,
};
pub const OpAssign = struct {
target: ASTNode,
op: []const u8,
value: ASTNode,
};
pub const MultiAssign = struct {
targets: []ASTNode,
values: []ASTNode,
};
pub const InstanceVar = struct {
name: []const u8,
};
pub const ReadInstanceVar = struct {
obj: ASTNode,
name: []const u8,
};
pub const ClassVar = struct {
name: []const u8,
};
pub const Global = struct {
name: []const u8,
};
pub fn BinaryOp() type {
return struct {
left: ASTNode,
right: ASTNode,
};
}
pub const And = BinaryOp();
pub const Or = BinaryOp();
pub const Arg = struct {
name: []const u8,
external_name: []const u8,
default_value: ?ASTNode = null,
restruction: ?ASTNode = null,
doc: ?[]const u8 = null,
};
pub const ProcNotation = struct {
inputs: ?[]ASTNode = null,
output: ?ASTNode = null,
};
pub const Def = struct {
free_vars: ?[][]const u8 = null,
receiver: ?ASTNode = null,
name: []const u8,
args: []*Arg,
double_splat: ?*Arg = null,
body: ASTNode,
block_arg: ?*Arg = null,
return_type: ?ASTNode = null,
yields: ?i32 = null,
splat_index: ?i32 = null,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
is_macro_def: bool = false,
calls_super: bool = false,
calls_initialize: bool = false,
calls_previous_def: bool = false,
uses_block_arg: bool = false,
assigns_special_var: bool = false,
is_abstract: bool = false,
pub fn create(allocator: std.mem.Allocator, name: []const u8, args: []*Arg, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.args = args,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: []const u8, args: []*Arg, body: ?ASTNode) !ASTNode {
return ASTNode { .def = try create(allocator, name, args, body) };
}
};
pub const Macro = struct {
name: []const u8,
args: []*Arg,
body: ASTNode,
double_splat: ?*Arg = null,
block_arg: ?*Arg = null,
splat_index: ?i32 = null,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
pub fn create(allocator: std.mem.Allocator, name: []const u8, args: []*Arg, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.args = args,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: []const u8, args: []*Arg, body: ?ASTNode) !ASTNode {
return ASTNode { .macro = try create(allocator, name, args, body) };
}
};
pub fn UnaryExpression() type {
return struct {
exp: ASTNode,
};
}
pub const Not = UnaryExpression();
pub const PointerOf = UnaryExpression();
pub const SizeOf = UnaryExpression();
pub const InstanceSizeOf = UnaryExpression();
pub const Out = UnaryExpression();
pub const OffsetOf = struct {
offsetof_type: ASTNode,
offset: ASTNode,
};
pub const VisibilityModifier = struct {
modifier: Visibility,
exp: ASTNode,
doc: ?[]const u8 = null,
};
pub const IsA = struct {
obj: ASTNode,
const_: ASTNode,
is_nil_check: bool = false,
};
pub const RespondsTo = struct {
obj: ASTNode,
name: []const u8,
};
pub const Require = struct {
string: []const u8,
};
pub const When = struct {
conds: []ASTNode,
body: ASTNode,
is_exhaustive: bool = false,
pub fn create(allocator: std.mem.Allocator, conds: []ASTNode, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.conds = conds,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, conds: []ASTNode, body: ?ASTNode) !ASTNode {
return ASTNode { .when = try create(allocator, conds, body) };
}
};
pub const Case = struct {
cond: ?ASTNode,
whens: []*When,
else_: ?ASTNode,
is_exhaustive: bool,
};
pub const Select = struct {
pub const When = struct { condition: ASTNode, body: ASTNode };
whens: []@This().When,
else_: ?ASTNode = null,
};
pub const ImplicitObj = struct {};
pub const Path = struct {
names: [][]const u8,
is_global: bool = false,
visibility: Visibility = .Public,
pub fn create(allocator: std.mem.Allocator, names: [][]const u8) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.names = names,
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, names: [][]const u8) !ASTNode {
return ASTNode { .path = try create(allocator, names) };
}
};
pub const ClassDef = struct {
name: *Path,
body: ASTNode,
superclass: ?ASTNode = null,
type_vars: ?[][]const u8 = null,
doc: ?[]const u8 = null,
splat_index: ?i32 = null,
is_abstract: bool = false,
is_struct: bool = false,
visibility: Visibility = .Public,
pub fn create(allocator: std.mem.Allocator, name: *Path, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: *Path, body: ?ASTNode) !ASTNode {
return ASTNode { .class_def = try create(allocator, name, body) };
}
};
pub const ModuleDef = struct {
name: *Path,
body: ASTNode,
type_vars: ?[][]const u8 = null,
splat_index: ?i32 = null,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
pub fn create(allocator: std.mem.Allocator, name: *Path, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: *Path, body: ?ASTNode) !ASTNode {
return ASTNode { .module_def = try create(allocator, name, body) };
}
};
pub const AnnotationDef = struct {
name: *Path,
doc: ?[]const u8 = null,
};
pub const While = struct {
cond: ASTNode,
body: ASTNode,
pub fn create(allocator: std.mem.Allocator, cond: ASTNode, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.cond = cond,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, cond: ASTNode, body: ?ASTNode) !ASTNode {
return ASTNode { .while_ = try create(allocator, cond, body) };
}
};
pub const Until = struct {
cond: ASTNode,
body: ASTNode,
pub fn create(allocator: std.mem.Allocator, cond: ASTNode, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.cond = cond,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, cond: ASTNode, body: ?ASTNode) !ASTNode {
return ASTNode { .until = try create(allocator, cond, body) };
}
};
pub const Generic = struct {
name: ASTNode,
type_vars: []ASTNode,
names_args: ?[]*NamedArgument = null,
suffix: Suffix = .None,
pub const Suffix = enum {
None,
Question,
Asterisk,
Bracket,
};
};
pub const TypeDeclaration = struct {
var_: ASTNode,
declared_type: ASTNode,
value: ?ASTNode = null,
};
pub const UninitializedVar = struct {
var_: ASTNode,
declared_type: ASTNode,
};
pub const Rescue = struct {
body: ASTNode,
types: ?[]ASTNode = null,
name: ?[]const u8 = null,
pub fn create(allocator: std.mem.Allocator, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, body: ?ASTNode) !ASTNode {
return ASTNode { .rescue = try create(allocator, body) };
}
};
pub const ExceptionHandler = struct {
body: ASTNode,
rescues: ?[]*Rescue = null,
else_: ?ASTNode = null,
ensure: ?ASTNode = null,
is_implicit: bool = false,
is_suffix: bool = false,
pub fn create(allocator: std.mem.Allocator, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, body: ?ASTNode) !ASTNode {
return ASTNode { .exception_handler = try create(allocator, body) };
}
};
pub const ProcLiteral = struct {
def: *Def,
};
pub const ProcPointer = struct {
obj: ?ASTNode,
name: []const u8,
args: []ASTNode,
};
pub const Union = struct {
types: []ASTNode,
};
pub const Self = struct {
pub fn create(allocator: std.mem.Allocator) !*@This() {
return try allocator.create(@This());
}
pub fn new(allocator: std.mem.Allocator) !ASTNode {
return ASTNode { .self = try create(allocator) };
}
};
pub fn ControlExpression() type {
return struct {
exp: ?ASTNode = null,
};
}
pub const Return = ControlExpression();
pub const Break = ControlExpression();
pub const Next = ControlExpression();
pub const Yield = struct {
exps: []ASTNode,
scope: ?ASTNode = null,
has_parentheses: bool = false,
};
pub const Include = struct {
name: ASTNode,
};
pub const Extend = struct {
name: ASTNode,
};
pub const LibDef = struct {
name: []const u8,
body: ASTNode,
visibility: Visibility = .Public,
pub fn create(allocator: std.mem.Allocator, name: []const u8, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: []const u8, body: ?ASTNode) !ASTNode {
return ASTNode { .lib_def = try create(allocator, name, body) };
}
};
pub const FunDef = struct {
name: []const u8,
args: []*Arg,
return_type: ?ASTNode = null,
body: ?ASTNode = null,
real_name: []const u8,
doc: ?[]const u8 = null,
varargs: bool = false,
};
pub const TypeDef = struct {
name: []const u8,
type_spec: ASTNode,
};
pub const CStructOrUnionDef = struct {
name: []const u8,
body: ASTNode,
is_union: bool = false,
pub fn create(allocator: std.mem.Allocator, name: []const u8, body: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.name = name,
.body = try Expressions.from(allocator, body),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, name: []const u8, body: ?ASTNode) !ASTNode {
return ASTNode { .c_struct_or_union_def = try create(allocator, name, body) };
}
};
pub const EnumDef = struct {
name: *Path,
members: []ASTNode,
base_type: ?ASTNode = null,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
};
pub const ExternalVar = struct {
name: []const u8,
type_spec: ASTNode,
real_name: ?[]const u8 = null,
};
pub const Alias = struct {
name: *Path,
value: ASTNode,
doc: ?[]const u8 = null,
visibility: Visibility = .Public,
};
pub const Metaclass = struct {
name: ASTNode,
};
pub const Cast = struct {
obj: ASTNode,
to: ASTNode,
};
pub const NilableCast = struct {
obj: ASTNode,
to: ASTNode,
};
pub const TypeOf = struct {
expressions: []ASTNode,
};
pub const Annotation = struct {
path: Path,
args: []ASTNode,
named_args: ?[]*NamedArgument = null,
doc: ?[]const u8 = null,
};
pub const MacroExpression = struct {
exp: ASTNode,
output: bool = true,
};
pub const MacroLiteral = struct {
value: []const u8,
};
pub const MacroVerbatim = UnaryExpression();
pub const MacroIf = struct {
cond: ASTNode,
then: ASTNode,
else_: ASTNode,
pub fn create(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !*@This() {
var instance = try allocator.create(@This());
instance.* = .{
.cond = cond,
.then = try Expressions.from(allocator, then),
.else_ = try Expressions.from(allocator, else_),
};
return instance;
}
pub fn new(allocator: std.mem.Allocator, cond: ASTNode, then: ?ASTNode, else_: ?ASTNode) !ASTNode {
return ASTNode { .macro_if = try create(allocator, cond, then, else_) };
}
};
pub const MacroFor = struct {
vars: []*Var,
exp: ASTNode,
body: ASTNode,
};
pub const MacroVar = struct {
name: []const u8,
exps: ?[]ASTNode = null,
};
pub const Underscore = struct {
pub fn create(allocator: std.mem.Allocator) !*@This() {
return try allocator.create(@This());
}
pub fn new(allocator: std.mem.Allocator) !ASTNode {
return ASTNode { .underscore = try create(allocator) };
}
};
pub const Splat = UnaryExpression();
pub const DoubleSplat = UnaryExpression();
pub const MagicConstant = struct {
name: []const u8, // Symbol
};
pub const Asm = struct {
text: []const u8,
outputs: ?[]*AsmOperand = null,
inputs: ?[]*AsmOperand = null,
clobbers: ?[][]const u8 = null,
volatile_: bool = false,
alignstack: bool = false,
intel: bool = false,
can_throw: bool = false,
};
pub const AsmOperand = struct {
constraint: []const u8,
exp: ASTNode,
};
pub const Visibility = enum(i8) {
Public,
Protected,
Private,
};
const print = std.debug.print;
const c_allocator = std.heap.c_allocator;
const utils = @import("utils.zig");
const inspect = utils.inspect;
const pp = utils.pp;
const p = utils.p;
const xprint = utils.xprint;
pub fn main() !void {
var n: ASTNode = undefined;
p(.{ @TypeOf(std.debug) });
p(.{ @as(ASTNode, .nop) });
// p(.{ ASTNode { .expressions = .{ .expressions = &.{} } } });
// p(.{ ASTNode { .expressions = .{ .expressions = &.{}, .keyword = .Paren } } });
p(NumberKind.fromNumber(0) != .I8);
p(NumberKind.fromNumber(128) != .I16);
p(NumberKind.fromNumber(32768) == .I32);
p(NumberKind.fromNumber(2147483648) == .I64);
p(NumberKind.fromNumber(9223372036854775808) == .I128);
p(NumberKind.fromNumber(170141183460469231731687303715884105728) == .U128);
p(NumberKind.fromNumber(0.0) == .F32);
p(NumberKind.fromNumber(-3.402823466385288598121e+38) == .F64);
// pp(NumberKind.fromNumber(-1.797693134862315708151e+308));
// pp(NumberKind.fromNumber(340282366920938463463374607431768211456));
p(NumberKind.fromNumber(@as(f64, -3.402823466385288598121e+38)));
p(NumberKind.fromNumber(@as(f64, -1.79769313486231570815e+308)));
p(NumberKind.fromNumber(@as(i8, 1)));
p(NumberKind.fromNumber(@as(i16, 1)));
p(NumberKind.fromNumber(@as(i32, 1)));
p(NumberKind.fromNumber(@as(i64, 1)));
p(NumberKind.fromNumber(@as(i128, 1)));
p(NumberKind.fromNumber(@as(u8, 1)));
p(NumberKind.fromNumber(@as(u16, 1)));
p(NumberKind.fromNumber(@as(u32, 1)));
p(NumberKind.fromNumber(@as(u64, 1)));
p(NumberKind.fromNumber(@as(u128, 1)));
p(NumberKind.fromNumber(@as(f32, 1)));
p(NumberKind.fromNumber(@as(f64, 1)));
p(NumberKind.fromNumber(@as(i8, 1)).bytesize());
p(NumberKind.fromNumber(@as(i16, 1)).bytesize());
p(NumberKind.fromNumber(@as(i32, 1)).bytesize());
p(NumberKind.fromNumber(@as(i64, 1)).bytesize());
p(NumberKind.fromNumber(@as(i128, 1)).bytesize());
p(NumberKind.fromNumber(@as(u8, 1)).bytesize());
p(NumberKind.fromNumber(@as(u16, 1)).bytesize());
p(NumberKind.fromNumber(@as(u32, 1)).bytesize());
p(NumberKind.fromNumber(@as(u64, 1)).bytesize());
p(NumberKind.fromNumber(@as(u128, 1)).bytesize());
p(NumberKind.fromNumber(@as(f32, 1)).bytesize());
p(NumberKind.fromNumber(@as(f64, 1)).bytesize());
p(NumberKind.fromNumber(@as(i32, 1)).isSignedInt());
p(NumberKind.fromNumber(@as(i32, 1)).isUnignedInt());
p(NumberKind.fromNumber(@as(i32, 1)).isFloat());
p(NumberKind.fromNumber(@as(u32, 1)).isSignedInt());
p(NumberKind.fromNumber(@as(u32, 1)).isUnignedInt());
p(NumberKind.fromNumber(@as(u32, 1)).isFloat());
p(NumberKind.fromNumber(@as(f32, 1)).isSignedInt());
p(NumberKind.fromNumber(@as(f32, 1)).isUnignedInt());
p(NumberKind.fromNumber(@as(f32, 1)).isFloat());
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .I8 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .I16 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .I32 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .I64 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .I128 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .U8 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .U16 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .U32 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .U64 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .U128 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .F32 } } });
// p(.{ ASTNode { .number_literal = .{ .value = "1", .kind = .F64 } } });
// n = .{ .number_literal = .{ .value = "1" } }; p(.{ n.number_literal.hasSign() });
// n = .{ .number_literal = .{ .value = "+1" } }; p(.{ n.number_literal.hasSign() });
// n = .{ .number_literal = .{ .value = "-1" } }; p(.{ n.number_literal.hasSign() });
n = try NumberLiteral.new(c_allocator, 1); xprint("{s}\n", .{ n.number_literal.value });
n = try NumberLiteral.new(c_allocator, 1); p(.{ n.number_literal.hasSign() });
// xprint("{}\n", .{@TypeOf(null)});
// xprint("{}\n", .{@Type(.Null)});
p(try Expressions.from(c_allocator, null));
// const x: []*ASTNode = &.{};
// p([]*ASTNode);
// p(@TypeOf(x));
p(try Expressions.from(c_allocator, try NumberLiteral.new(c_allocator, 1)));
p(try Expressions.from(c_allocator, try c_allocator.alloc(ASTNode, 0)));
{
var array = try c_allocator.alloc(ASTNode, 0);
array = try c_allocator.alloc(ASTNode, 1); array[0] = try NumberLiteral.new(c_allocator, 2); p(try Expressions.from(c_allocator, array));
array = try c_allocator.alloc(ASTNode, 2); array[0] = try NumberLiteral.new(c_allocator, 3);
array[1] = try NumberLiteral.new(c_allocator, 4); xprint("{any}\n", .{(try Expressions.from(c_allocator, array)).expressions.*.expressions});
}
p(try Block.new(c_allocator, try c_allocator.alloc(*Var, 0), null));
p(try If.new(c_allocator, try BoolLiteral.new(c_allocator, true), null, null));
p(try Unless.new(c_allocator, try BoolLiteral.new(c_allocator, true), null, null));
p(try Def.new(c_allocator, "foo", try c_allocator.alloc(*Arg, 0), null));
p(try When.new(c_allocator, try c_allocator.alloc(ASTNode, 0), null));
p(try Path.create(c_allocator, try c_allocator.alloc([]const u8, 0)));
p(try Path.new(c_allocator, try c_allocator.alloc([]const u8, 0)));
p(try ClassDef.new(c_allocator, try Path.create(c_allocator, try c_allocator.alloc([]const u8, 0)), null));
p(try ModuleDef.new(c_allocator, try Path.create(c_allocator, try c_allocator.alloc([]const u8, 0)), null));
p(try While.new(c_allocator, try BoolLiteral.new(c_allocator, true), null));
p(try Until.new(c_allocator, try BoolLiteral.new(c_allocator, true), null));
p(try Rescue.new(c_allocator, null));
p(try ExceptionHandler.new(c_allocator, null));
p(try LibDef.new(c_allocator, "Foo", null));
p(try CStructOrUnionDef.new(c_allocator, "Foo", null));
p(try MacroIf.new(c_allocator, try BoolLiteral.new(c_allocator, true), null, null));
p((try Nop.new(c_allocator)).isNop());
p((try BoolLiteral.new(c_allocator, true)).isTrueLiteral());
p((try BoolLiteral.new(c_allocator, false)).isFalseLiteral());
p((try NumberLiteral.new(c_allocator, 1)).singleExpression());
p((try Expressions.new(c_allocator, try c_allocator.alloc(ASTNode, 0))).singleExpression());
{
var expressions = try c_allocator.alloc(ASTNode, 1);
expressions[0] = try NumberLiteral.new(c_allocator, 1);
p((try Expressions.new(c_allocator, expressions)).singleExpression());
}
{
var expressions = try c_allocator.alloc(ASTNode, 2);
expressions[0] = try NumberLiteral.new(c_allocator, 1);
expressions[1] = try NumberLiteral.new(c_allocator, 2);
p((try Expressions.new(c_allocator, expressions)).singleExpression());
}
{
var values = try c_allocator.alloc(ASTNode, 2);
values[0] = try BoolLiteral.new(c_allocator, true);
values[1] = try BoolLiteral.new(c_allocator, false);
const array = try ArrayLiteral.new(c_allocator, values);
const array2 = try ArrayLiteral.map(c_allocator, values, struct {
fn call(allocator: std.mem.Allocator, node: ASTNode) !ASTNode {
return try BoolLiteral.new(allocator, !node.bool_literal.*.value);
}
});
const array3 = try ArrayLiteral.mapWithIndex(c_allocator, values, struct {
fn call(allocator: std.mem.Allocator, node: ASTNode, index: usize) !ASTNode {
return if (index == 0) try BoolLiteral.new(allocator, !node.bool_literal.*.value) else node;
}
});
p(array.array_literal.*.elements[0]);
p(array2.array_literal.*.elements[0]);
p(array3.array_literal.*.elements[0]);
p(array3.array_literal.*.elements[1]);
}
} | ast.zig |
const std = @import("std");
const c = @cImport({
@cInclude("ini.h");
});
test "parser create/destroy" {
var buffer: c.ini_Parser = undefined;
c.ini_create_buffer(&buffer, "", 0);
c.ini_destroy(&buffer);
}
fn expectNull(record: c.ini_Record) void {
std.testing.expectEqual(c.ini_RecordType.INI_RECORD_NUL, record.type);
}
fn expectSection(heading: []const u8, record: c.ini_Record) void {
std.testing.expectEqual(c.ini_RecordType.INI_RECORD_SECTION, record.type);
std.testing.expectEqualStrings(heading, std.mem.span(record.unnamed_0.section));
}
fn expectKeyValue(key: []const u8, value: []const u8, record: c.ini_Record) void {
std.testing.expectEqual(c.ini_RecordType.INI_RECORD_PROPERTY, record.type);
std.testing.expectEqualStrings(key, std.mem.span(record.unnamed_0.property.key));
std.testing.expectEqualStrings(value, std.mem.span(record.unnamed_0.property.value));
}
fn expectEnumeration(enumeration: []const u8, record: c.ini_Record) void {
std.testing.expectEqual(c.ini_RecordType.INI_RECORD_ENUMERATION, record.type);
std.testing.expectEqualStrings(enumeration, std.mem.span(record.unnamed_0.enumeration));
}
fn parseNext(parser: *c.ini_Parser) !c.ini_Record {
var record: c.ini_Record = undefined;
const err = c.ini_next(parser, &record);
switch (err) {
.INI_SUCCESS => return record,
.INI_ERR_OUT_OF_MEMORY => return error.OutOfMemory,
.INI_ERR_IO => return error.InputOutput,
.INI_ERR_INVALID_DATA => return error.InvalidData,
_ => unreachable,
}
}
fn commonTest(parser: *c.ini_Parser) !void {
expectSection("Meta", try parseNext(parser));
expectKeyValue("author", "xq", try parseNext(parser));
expectKeyValue("library", "ini", try parseNext(parser));
expectSection("Albums", try parseNext(parser));
expectEnumeration("Thriller", try parseNext(parser));
expectEnumeration("Back in Black", try parseNext(parser));
expectEnumeration("Bat Out of Hell", try parseNext(parser));
expectEnumeration("The Dark Side of the Moon", try parseNext(parser));
expectNull(try parseNext(parser));
}
test "buffer parser" {
const slice =
\\[Meta]
\\author = xq
\\library = ini
\\
\\[Albums]
\\Thriller
\\Back in Black
\\Bat Out of Hell
\\The Dark Side of the Moon
;
var parser: c.ini_Parser = undefined;
c.ini_create_buffer(&parser, slice, slice.len);
defer c.ini_destroy(&parser);
try commonTest(&parser);
}
test "file parser" {
var file = c.fopen("example/example.ini", "rb") orelse unreachable;
defer _ = c.fclose(file);
var parser: c.ini_Parser = undefined;
c.ini_create_file(&parser, file);
defer c.ini_destroy(&parser);
try commonTest(&parser);
} | src/lib-test.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const vk = @import("../include/vk.zig");
const zva = @import("zva");
const Context = @import("context.zig").Context;
pub const Buffer = struct {
initFn: fn (self: *Buffer, allocator: *Allocator, vallocator: *zva.Allocator, context: *const Context) anyerror!void,
deinitFn: fn (self: *Buffer) void,
bufferFn: fn (self: *Buffer) vk.Buffer,
pushFn: fn (self: *Buffer) anyerror!void,
lenFn: fn (self: *Buffer) u32,
is_inited: bool = false,
pub fn init(self: *Buffer, allocator: *Allocator, vallocator: *zva.Allocator, context: *const Context) !void {
if (!self.is_inited) try self.initFn(self, allocator, vallocator, context);
self.is_inited = true;
}
pub fn deinit(self: *Buffer) void {
self.deinitFn(self);
self.is_inited = false;
}
pub fn buffer(self: *Buffer) vk.Buffer {
return self.bufferFn(self);
}
pub fn push(self: *Buffer) !void {
try self.pushFn(self);
}
pub fn len(self: *Buffer) u32 {
return self.lenFn(self);
}
};
pub const Usage = enum {
Vertex,
Index,
Storage,
Uniform,
};
fn getVkUsage(usage: Usage) vk.BufferUsageFlags {
return switch (usage) {
.Vertex => vk.BufferUsageFlags{ .vertex_buffer_bit = true },
.Index => vk.BufferUsageFlags{ .index_buffer_bit = true },
.Storage => vk.BufferUsageFlags{ .storage_buffer_bit = true },
.Uniform => vk.BufferUsageFlags{ .uniform_buffer_bit = true },
};
}
pub fn DirectBuffer(comptime T: type, comptime usage: Usage) type {
const bUsage = getVkUsage(usage);
return struct {
const Self = @This();
buf: Buffer,
allocator: *Allocator,
vallocator: *zva.Allocator,
context: *const Context,
buffer: vk.Buffer,
allocation: zva.Allocation,
len: u32,
size: u64,
data: []T,
pub fn new(data: []T) Self {
return Self{
.buf = Buffer{
.initFn = init,
.deinitFn = deinit,
.bufferFn = buffer,
.pushFn = push,
.lenFn = len,
},
.allocator = undefined,
.vallocator = undefined,
.context = undefined,
.buffer = undefined,
.allocation = undefined,
.len = @intCast(u32, data.len),
.size = @sizeOf(T) * data.len,
.data = data,
};
}
pub fn init(buf: *Buffer, allocator: *Allocator, vallocator: *zva.Allocator, context: *const Context) anyerror!void {
const self = @fieldParentPtr(Self, "buf", buf);
self.allocator = allocator;
self.vallocator = vallocator;
self.context = context;
const queueFamilyIndices = [_]u32{ context.indices.graphics_family.?, context.indices.transfer_family.? };
const differentFamilies = context.indices.graphics_family.? != context.indices.transfer_family.?;
const bufferInfo = vk.BufferCreateInfo{
.size = self.size,
.usage = bUsage,
.sharing_mode = if (differentFamilies) .concurrent else .exclusive,
.queue_family_index_count = if (differentFamilies) 2 else 0,
.p_queue_family_indices = if (differentFamilies) &queueFamilyIndices else undefined,
.flags = .{},
};
self.buffer = try context.vkd.createBuffer(self.context.device, bufferInfo, null);
const memRequirements = context.vkd.getBufferMemoryRequirements(self.context.device, self.buffer);
self.allocation = try self.vallocator.alloc(memRequirements.size, memRequirements.alignment, memRequirements.memory_type_bits, .CpuToGpu, .Buffer);
try context.vkd.bindBufferMemory(self.context.device, self.buffer, self.allocation.memory, self.allocation.offset);
std.mem.copy(T, std.mem.bytesAsSlice(T, self.allocation.data), self.data);
}
pub fn deinit(buf: *Buffer) void {
const self = @fieldParentPtr(Self, "buf", buf);
self.context.vkd.destroyBuffer(self.context.device, self.buffer, null);
self.vallocator.free(self.allocation);
}
pub fn update(self: *Self, data: []T) !void {
std.debug.assert(data.len == self.len);
self.data = data;
}
pub fn buffer(buf: *Buffer) vk.Buffer {
const self = @fieldParentPtr(Self, "buf", buf);
return self.buffer;
}
pub fn push(buf: *Buffer) !void {
const self = @fieldParentPtr(Self, "buf", buf);
std.mem.copy(T, std.mem.bytesAsSlice(T, self.allocation.data), self.data);
}
pub fn len(buf: *Buffer) u32 {
const self = @fieldParentPtr(Self, "buf", buf);
return self.len;
}
};
}
pub fn StagedBuffer(comptime T: type, comptime usage: Usage) type {
const bUsage = getVkUsage(usage);
return struct {
const Self = @This();
buf: Buffer,
allocator: *Allocator,
vallocator: *zva.Allocator,
context: *const Context,
sbuffer: vk.Buffer,
sallocation: zva.Allocation,
dbuffer: vk.Buffer,
dallocation: zva.Allocation,
len: u32,
size: u64,
data: []T,
pub fn new(data: []T) Self {
return Self{
.buf = Buffer{
.initFn = init,
.deinitFn = deinit,
.bufferFn = buffer,
.pushFn = push,
.lenFn = len,
},
.allocator = undefined,
.vallocator = undefined,
.context = undefined,
.sbuffer = undefined,
.sallocation = undefined,
.dbuffer = undefined,
.dallocation = undefined,
.len = @intCast(u32, data.len),
.size = @sizeOf(T) * data.len,
.data = data,
};
}
pub fn init(buf: *Buffer, allocator: *Allocator, vallocator: *zva.Allocator, context: *const Context) anyerror!void {
const self = @fieldParentPtr(Self, "buf", buf);
self.allocator = allocator;
self.vallocator = vallocator;
self.context = context;
const sBufferInfo = vk.BufferCreateInfo{
.size = self.size,
.usage = vk.BufferUsageFlags{ .transfer_src_bit = true },
.sharing_mode = .exclusive,
.flags = .{},
.queue_family_index_count = 0,
.p_queue_family_indices = undefined,
};
self.sbuffer = try context.vkd.createBuffer(self.context.device, sBufferInfo, null);
const sMemRequirements = context.vkd.getBufferMemoryRequirements(self.context.device, self.sbuffer);
self.sallocation = try self.vallocator.alloc(sMemRequirements.size, sMemRequirements.alignment, sMemRequirements.memory_type_bits, .CpuToGpu, .Buffer);
try context.vkd.bindBufferMemory(self.context.device, self.sbuffer, self.sallocation.memory, self.sallocation.offset);
std.mem.copy(T, std.mem.bytesAsSlice(T, self.sallocation.data), self.data);
const queueFamilyIndices = [_]u32{ context.indices.graphics_family.?, context.indices.transfer_family.? };
const differentFamilies = context.indices.graphics_family.? != context.indices.transfer_family.?;
const dBufferInfo = vk.BufferCreateInfo{
.size = self.size,
.usage = (vk.BufferUsageFlags{ .transfer_dst_bit = true }).merge(bUsage),
.sharing_mode = if (differentFamilies) .concurrent else .exclusive,
.queue_family_index_count = if (differentFamilies) 2 else 0,
.p_queue_family_indices = if (differentFamilies) &queueFamilyIndices else undefined,
.flags = .{},
};
self.dbuffer = try context.vkd.createBuffer(self.context.device, dBufferInfo, null);
const dMemRequirements = context.vkd.getBufferMemoryRequirements(self.context.device, self.dbuffer);
self.dallocation = try self.vallocator.alloc(dMemRequirements.size, dMemRequirements.alignment, dMemRequirements.memory_type_bits, .GpuOnly, .Buffer);
try context.vkd.bindBufferMemory(self.context.device, self.dbuffer, self.dallocation.memory, self.dallocation.offset);
try self.copyBuffer();
self.vallocator.free(self.sallocation);
context.vkd.destroyBuffer(self.context.device, self.sbuffer, null);
}
pub fn deinit(buf: *Buffer) void {
const self = @fieldParentPtr(Self, "buf", buf);
self.context.vkd.destroyBuffer(self.context.device, self.dbuffer, null);
self.vallocator.free(self.dallocation);
}
pub fn update(self: *Self, data: []T) !void {
std.debug.assert(data.len == self.len);
self.data = data;
}
pub fn copyBuffer(self: *Self) !void {
const allocInfo = vk.CommandBufferAllocateInfo{
.level = .primary,
.command_pool = self.context.transfer_pool,
.command_buffer_count = 1,
};
var commandBuffer: vk.CommandBuffer = undefined;
try self.context.vkd.allocateCommandBuffers(self.context.device, allocInfo, @ptrCast([*]vk.CommandBuffer, &commandBuffer));
const beginInfo = vk.CommandBufferBeginInfo{
.flags = vk.CommandBufferUsageFlags{ .one_time_submit_bit = true },
.p_inheritance_info = undefined,
};
try self.context.vkd.beginCommandBuffer(commandBuffer, beginInfo);
const copyRegions = [_]vk.BufferCopy{vk.BufferCopy{
.src_offset = 0,
.dst_offset = 0,
.size = self.size,
}};
self.context.vkd.cmdCopyBuffer(commandBuffer, self.sbuffer, self.dbuffer, copyRegions.len, ©Regions);
try self.context.vkd.endCommandBuffer(commandBuffer);
const submitInfos = [_]vk.SubmitInfo{vk.SubmitInfo{
.command_buffer_count = 1,
.p_command_buffers = &[_]vk.CommandBuffer{commandBuffer},
.wait_semaphore_count = 0,
.p_wait_semaphores = undefined,
.signal_semaphore_count = 0,
.p_signal_semaphores = undefined,
.p_wait_dst_stage_mask = undefined,
}};
try self.context.vkd.queueSubmit(self.context.transfer_queue, submitInfos.len, &submitInfos, .null_handle);
try self.context.vkd.queueWaitIdle(self.context.transfer_queue);
self.context.vkd.freeCommandBuffers(self.context.device, self.context.transfer_pool, 1, &[_]vk.CommandBuffer{commandBuffer});
}
pub fn buffer(buf: *Buffer) vk.Buffer {
const self = @fieldParentPtr(Self, "buf", buf);
return self.dbuffer;
}
pub fn push(buf: *Buffer) vk.Buffer !void {
const self = @fieldParentPtr(Self, "buf", buf);
const sBufferInfo = vk.BufferCreateInfo{
.size = self.size,
.usage = vk.BufferUsageFlags{ .transfer_src_bit = true },
.sharing_mode = .exclusive,
.flags = .{},
.queue_family_index_count = 0,
.p_queue_family_indices = undefined,
};
self.sbuffer = try self.context.vkd.createBuffer(self.context.device, sBufferInfo, null);
const sMemRequirements = self.context.vkd.getBufferMemoryRequirements(self.context.device, self.sbuffer);
self.sallocation = try self.vallocator.alloc(sMemRequirements.size, sMemRequirements.alignment, sMemRequirements.memory_type_bits, .CpuToGpu, .Buffer);
try self.context.vkd.bindBufferMemory(self.context.device, self.sbuffer, self.sallocation.memory, self.sallocation.offset);
std.mem.copy(T, std.mem.bytesAsSlice(T, self.sallocation.data), self.data);
try self.copyBuffer();
self.vallocator.free(self.sallocation);
self.context.vkd.destroyBuffer(self.context.device, self.sbuffer, null);
}
pub fn len(buf: *Buffer) u32 {
const self = @fieldParentPtr(Self, "buf", buf);
return self.len;
}
};
} | render/src/backend/buffer.zig |
const expect = @import("std").testing.expect;
pub const EmptyStruct = struct {};
test "optional pointer to size zero struct" {
var e = EmptyStruct{};
var o: ?*EmptyStruct = &e;
expect(o != null);
}
test "equality compare nullable pointers" {
testNullPtrsEql();
comptime testNullPtrsEql();
}
fn testNullPtrsEql() void {
var number: i32 = 1234;
var x: ?*i32 = null;
var y: ?*i32 = null;
expect(x == y);
y = &number;
expect(x != y);
expect(x != &number);
expect(&number != x);
x = &number;
expect(x == y);
expect(x == &number);
expect(&number == x);
}
test "address of unwrap optional" {
const S = struct {
const Foo = struct {
a: i32,
};
var global: ?Foo = null;
pub fn getFoo() anyerror!*Foo {
return &global.?;
}
};
S.global = S.Foo{ .a = 1234 };
const foo = S.getFoo() catch unreachable;
expect(foo.a == 1234);
}
test "passing an optional integer as a parameter" {
const S = struct {
fn entry() bool {
var x: i32 = 1234;
return foo(x);
}
fn foo(x: ?i32) bool {
return x.? == 1234;
}
};
expect(S.entry());
comptime expect(S.entry());
}
test "unwrap function call with optional pointer return value" {
const S = struct {
fn entry() void {
expect(foo().?.* == 1234);
expect(bar() == null);
}
const global: i32 = 1234;
fn foo() ?*const i32 {
return &global;
}
fn bar() ?*i32 {
return null;
}
};
S.entry();
comptime S.entry();
}
test "nested orelse" {
const S = struct {
fn entry() void {
expect(func() == null);
}
fn maybe() ?Foo {
return null;
}
fn func() ?Foo {
const x = maybe() orelse
maybe() orelse
return null;
unreachable;
}
const Foo = struct {
field: i32,
};
};
S.entry();
comptime S.entry();
}
test "self-referential struct through a slice of optional" {
const S = struct {
const Node = struct {
children: []?Node,
data: ?u8,
fn new() Node {
return Node{
.children = undefined,
.data = null,
};
}
};
};
var n = S.Node.new();
expect(n.data == null);
}
test "assigning to an unwrapped optional field in an inline loop" {
comptime var maybe_pos_arg: ?comptime_int = null;
inline for ("ab") |x| {
maybe_pos_arg = 0;
if (maybe_pos_arg.? != 0) {
@compileError("bad");
}
maybe_pos_arg.? = 10;
}
}
test "coerce an anon struct literal to optional struct" {
const S = struct {
const Struct = struct {
field: u32,
};
export fn doTheTest() void {
var maybe_dims: ?Struct = null;
maybe_dims = .{ .field = 1 };
expect(maybe_dims.?.field == 1);
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "optional with void type" {
const Foo = struct {
x: ?void,
};
var x = Foo{ .x = null };
expect(x.x == null);
} | test/stage1/behavior/optional.zig |
const std = @import("std");
const mem = std.mem;
const c = @import("c.zig");
const Compilation = @import("compilation.zig").Compilation;
const Target = std.Target;
const ObjectFormat = Target.ObjectFormat;
const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
const assert = std.debug.assert;
const util = @import("util.zig");
const Context = struct {
comp: *Compilation,
arena: std.heap.ArenaAllocator,
args: std.ArrayList([*:0]const u8),
link_in_crt: bool,
link_err: error{OutOfMemory}!void,
link_msg: std.Buffer,
libc: *LibCInstallation,
out_file_path: std.Buffer,
};
pub fn link(comp: *Compilation) !void {
var ctx = Context{
.comp = comp,
.arena = std.heap.ArenaAllocator.init(comp.gpa()),
.args = undefined,
.link_in_crt = comp.haveLibC() and comp.kind == .Exe,
.link_err = {},
.link_msg = undefined,
.libc = undefined,
.out_file_path = undefined,
};
defer ctx.arena.deinit();
ctx.args = std.ArrayList([*:0]const u8).init(&ctx.arena.allocator);
ctx.link_msg = std.Buffer.initNull(&ctx.arena.allocator);
ctx.out_file_path = try std.Buffer.init(&ctx.arena.allocator, comp.name.toSliceConst());
switch (comp.kind) {
.Exe => {
try ctx.out_file_path.append(comp.target.exeFileExt());
},
.Lib => {
try ctx.out_file_path.append(if (comp.is_static) comp.target.staticLibSuffix() else comp.target.dynamicLibSuffix());
},
.Obj => {
try ctx.out_file_path.append(comp.target.oFileExt());
},
}
// even though we're calling LLD as a library it thinks the first
// argument is its own exe name
try ctx.args.append("lld");
if (comp.haveLibC()) {
// TODO https://github.com/ziglang/zig/issues/3190
var libc = ctx.comp.override_libc orelse blk: {
switch (comp.target) {
Target.Native => {
break :blk comp.zig_compiler.getNativeLibC() catch return error.LibCRequiredButNotProvidedOrFound;
},
else => return error.LibCRequiredButNotProvidedOrFound,
}
};
ctx.libc = libc;
}
try constructLinkerArgs(&ctx);
if (comp.verbose_link) {
for (ctx.args.toSliceConst()) |arg, i| {
const space = if (i == 0) "" else " ";
std.debug.warn("{}{s}", .{ space, arg });
}
std.debug.warn("\n", .{});
}
const extern_ofmt = toExternObjectFormatType(util.getObjectFormat(comp.target));
const args_slice = ctx.args.toSlice();
{
// LLD is not thread-safe, so we grab a global lock.
const held = comp.zig_compiler.lld_lock.acquire();
defer held.release();
// Not evented I/O. LLD does its own multithreading internally.
if (!ZigLLDLink(extern_ofmt, args_slice.ptr, args_slice.len, linkDiagCallback, @ptrCast(*c_void, &ctx))) {
if (!ctx.link_msg.isNull()) {
// TODO capture these messages and pass them through the system, reporting them through the
// event system instead of printing them directly here.
// perhaps try to parse and understand them.
std.debug.warn("{}\n", .{ctx.link_msg.toSliceConst()});
}
return error.LinkFailed;
}
}
}
extern fn ZigLLDLink(
oformat: c.ZigLLVM_ObjectFormatType,
args: [*]const [*]const u8,
arg_count: usize,
append_diagnostic: extern fn (*c_void, [*]const u8, usize) void,
context: *c_void,
) bool;
extern fn linkDiagCallback(context: *c_void, ptr: [*]const u8, len: usize) void {
const ctx = @ptrCast(*Context, @alignCast(@alignOf(Context), context));
ctx.link_err = linkDiagCallbackErrorable(ctx, ptr[0..len]);
}
fn linkDiagCallbackErrorable(ctx: *Context, msg: []const u8) !void {
if (ctx.link_msg.isNull()) {
try ctx.link_msg.resize(0);
}
try ctx.link_msg.append(msg);
}
fn toExternObjectFormatType(ofmt: ObjectFormat) c.ZigLLVM_ObjectFormatType {
return switch (ofmt) {
.unknown => .ZigLLVM_UnknownObjectFormat,
.coff => .ZigLLVM_COFF,
.elf => .ZigLLVM_ELF,
.macho => .ZigLLVM_MachO,
.wasm => .ZigLLVM_Wasm,
};
}
fn constructLinkerArgs(ctx: *Context) !void {
switch (util.getObjectFormat(ctx.comp.target)) {
.unknown => unreachable,
.coff => return constructLinkerArgsCoff(ctx),
.elf => return constructLinkerArgsElf(ctx),
.macho => return constructLinkerArgsMachO(ctx),
.wasm => return constructLinkerArgsWasm(ctx),
}
}
fn constructLinkerArgsElf(ctx: *Context) !void {
// TODO commented out code in this function
//if (g->linker_script) {
// lj->args.append("-T");
// lj->args.append(g->linker_script);
//}
try ctx.args.append("--gc-sections");
if (ctx.comp.link_eh_frame_hdr) {
try ctx.args.append("--eh-frame-hdr");
}
//lj->args.append("-m");
//lj->args.append(getLDMOption(&g->zig_target));
//bool is_lib = g->out_type == OutTypeLib;
//bool shared = !g->is_static && is_lib;
//Buf *soname = nullptr;
if (ctx.comp.is_static) {
if (util.isArmOrThumb(ctx.comp.target)) {
try ctx.args.append("-Bstatic");
} else {
try ctx.args.append("-static");
}
}
//} else if (shared) {
// lj->args.append("-shared");
// if (buf_len(&lj->out_file) == 0) {
// buf_appendf(&lj->out_file, "lib%s.so.%" ZIG_PRI_usize ".%" ZIG_PRI_usize ".%" ZIG_PRI_usize "",
// buf_ptr(g->root_out_name), g->version_major, g->version_minor, g->version_patch);
// }
// soname = buf_sprintf("lib%s.so.%" ZIG_PRI_usize "", buf_ptr(g->root_out_name), g->version_major);
//}
try ctx.args.append("-o");
try ctx.args.append(ctx.out_file_path.toSliceConst());
if (ctx.link_in_crt) {
const crt1o = if (ctx.comp.is_static) "crt1.o" else "Scrt1.o";
const crtbegino = if (ctx.comp.is_static) "crtbeginT.o" else "crtbegin.o";
try addPathJoin(ctx, ctx.libc.lib_dir.?, crt1o);
try addPathJoin(ctx, ctx.libc.lib_dir.?, "crti.o");
try addPathJoin(ctx, ctx.libc.static_lib_dir.?, crtbegino);
}
if (ctx.comp.haveLibC()) {
try ctx.args.append("-L");
// TODO addNullByte should probably return [:0]u8
try ctx.args.append(@ptrCast([*:0]const u8, (try std.cstr.addNullByte(&ctx.arena.allocator, ctx.libc.lib_dir.?)).ptr));
try ctx.args.append("-L");
try ctx.args.append(@ptrCast([*:0]const u8, (try std.cstr.addNullByte(&ctx.arena.allocator, ctx.libc.static_lib_dir.?)).ptr));
if (!ctx.comp.is_static) {
const dl = blk: {
if (ctx.libc.dynamic_linker_path) |dl| break :blk dl;
if (util.getDynamicLinkerPath(ctx.comp.target)) |dl| break :blk dl;
return error.LibCMissingDynamicLinker;
};
try ctx.args.append("-dynamic-linker");
try ctx.args.append(@ptrCast([*:0]const u8, (try std.cstr.addNullByte(&ctx.arena.allocator, dl)).ptr));
}
}
//if (shared) {
// lj->args.append("-soname");
// lj->args.append(buf_ptr(soname));
//}
// .o files
for (ctx.comp.link_objects) |link_object| {
const link_obj_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, link_object);
try ctx.args.append(@ptrCast([*:0]const u8, link_obj_with_null.ptr));
}
try addFnObjects(ctx);
//if (g->out_type == OutTypeExe || g->out_type == OutTypeLib) {
// if (g->libc_link_lib == nullptr) {
// Buf *builtin_o_path = build_o(g, "builtin");
// lj->args.append(buf_ptr(builtin_o_path));
// }
// // sometimes libgcc is missing stuff, so we still build compiler_rt and rely on weak linkage
// Buf *compiler_rt_o_path = build_compiler_rt(g);
// lj->args.append(buf_ptr(compiler_rt_o_path));
//}
//for (size_t i = 0; i < g->link_libs_list.length; i += 1) {
// LinkLib *link_lib = g->link_libs_list.at(i);
// if (buf_eql_str(link_lib->name, "c")) {
// continue;
// }
// Buf *arg;
// if (buf_starts_with_str(link_lib->name, "/") || buf_ends_with_str(link_lib->name, ".a") ||
// buf_ends_with_str(link_lib->name, ".so"))
// {
// arg = link_lib->name;
// } else {
// arg = buf_sprintf("-l%s", buf_ptr(link_lib->name));
// }
// lj->args.append(buf_ptr(arg));
//}
// libc dep
if (ctx.comp.haveLibC()) {
if (ctx.comp.is_static) {
try ctx.args.append("--start-group");
try ctx.args.append("-lgcc");
try ctx.args.append("-lgcc_eh");
try ctx.args.append("-lc");
try ctx.args.append("-lm");
try ctx.args.append("--end-group");
} else {
try ctx.args.append("-lgcc");
try ctx.args.append("--as-needed");
try ctx.args.append("-lgcc_s");
try ctx.args.append("--no-as-needed");
try ctx.args.append("-lc");
try ctx.args.append("-lm");
try ctx.args.append("-lgcc");
try ctx.args.append("--as-needed");
try ctx.args.append("-lgcc_s");
try ctx.args.append("--no-as-needed");
}
}
// crt end
if (ctx.link_in_crt) {
try addPathJoin(ctx, ctx.libc.static_lib_dir.?, "crtend.o");
try addPathJoin(ctx, ctx.libc.lib_dir.?, "crtn.o");
}
if (ctx.comp.target != Target.Native) {
try ctx.args.append("--allow-shlib-undefined");
}
}
fn addPathJoin(ctx: *Context, dirname: []const u8, basename: []const u8) !void {
const full_path = try std.fs.path.join(&ctx.arena.allocator, &[_][]const u8{ dirname, basename });
const full_path_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, full_path);
try ctx.args.append(@ptrCast([*:0]const u8, full_path_with_null.ptr));
}
fn constructLinkerArgsCoff(ctx: *Context) !void {
try ctx.args.append("-NOLOGO");
if (!ctx.comp.strip) {
try ctx.args.append("-DEBUG");
}
switch (ctx.comp.target.getArch()) {
.i386 => try ctx.args.append("-MACHINE:X86"),
.x86_64 => try ctx.args.append("-MACHINE:X64"),
.aarch64 => try ctx.args.append("-MACHINE:ARM"),
else => return error.UnsupportedLinkArchitecture,
}
const is_library = ctx.comp.kind == .Lib;
const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));
if (ctx.comp.haveLibC()) {
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));
}
if (ctx.link_in_crt) {
const lib_str = if (ctx.comp.is_static) "lib" else "";
const d_str = if (ctx.comp.build_mode == .Debug) "d" else "";
if (ctx.comp.is_static) {
const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr));
} else {
const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr));
}
const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
lib_str,
d_str,
});
try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr));
const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr));
// Visual C++ 2015 Conformance Changes
// https://msdn.microsoft.com/en-us/library/bb531344.aspx
try ctx.args.append("legacy_stdio_definitions.lib");
// msvcrt depends on kernel32
try ctx.args.append("kernel32.lib");
} else {
try ctx.args.append("-NODEFAULTLIB");
if (!is_library) {
try ctx.args.append("-ENTRY:WinMainCRTStartup");
}
}
if (is_library and !ctx.comp.is_static) {
try ctx.args.append("-DLL");
}
for (ctx.comp.link_objects) |link_object| {
const link_obj_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, link_object);
try ctx.args.append(@ptrCast([*:0]const u8, link_obj_with_null.ptr));
}
try addFnObjects(ctx);
switch (ctx.comp.kind) {
.Exe, .Lib => {
if (!ctx.comp.haveLibC()) {
@panic("TODO");
}
},
.Obj => {},
}
}
fn constructLinkerArgsMachO(ctx: *Context) !void {
try ctx.args.append("-demangle");
if (ctx.comp.linker_rdynamic) {
try ctx.args.append("-export_dynamic");
}
const is_lib = ctx.comp.kind == .Lib;
const shared = !ctx.comp.is_static and is_lib;
if (ctx.comp.is_static) {
try ctx.args.append("-static");
} else {
try ctx.args.append("-dynamic");
}
try ctx.args.append("-arch");
try ctx.args.append(util.getDarwinArchString(ctx.comp.target));
const platform = try DarwinPlatform.get(ctx.comp);
switch (platform.kind) {
.MacOS => try ctx.args.append("-macosx_version_min"),
.IPhoneOS => try ctx.args.append("-iphoneos_version_min"),
.IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"),
}
const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
platform.major,
platform.minor,
platform.micro,
});
try ctx.args.append(@ptrCast([*:0]const u8, ver_str.ptr));
if (ctx.comp.kind == .Exe) {
if (ctx.comp.is_static) {
try ctx.args.append("-no_pie");
} else {
try ctx.args.append("-pie");
}
}
try ctx.args.append("-o");
try ctx.args.append(ctx.out_file_path.toSliceConst());
if (shared) {
try ctx.args.append("-headerpad_max_install_names");
} else if (ctx.comp.is_static) {
try ctx.args.append("-lcrt0.o");
} else {
switch (platform.kind) {
.MacOS => {
if (platform.versionLessThan(10, 5)) {
try ctx.args.append("-lcrt1.o");
} else if (platform.versionLessThan(10, 6)) {
try ctx.args.append("-lcrt1.10.5.o");
} else if (platform.versionLessThan(10, 8)) {
try ctx.args.append("-lcrt1.10.6.o");
}
},
.IPhoneOS => {
if (ctx.comp.target.getArch() == .aarch64) {
// iOS does not need any crt1 files for arm64
} else if (platform.versionLessThan(3, 1)) {
try ctx.args.append("-lcrt1.o");
} else if (platform.versionLessThan(6, 0)) {
try ctx.args.append("-lcrt1.3.1.o");
}
},
.IPhoneOSSimulator => {}, // no crt1.o needed
}
}
for (ctx.comp.link_objects) |link_object| {
const link_obj_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, link_object);
try ctx.args.append(@ptrCast([*:0]const u8, link_obj_with_null.ptr));
}
try addFnObjects(ctx);
if (ctx.comp.target == Target.Native) {
for (ctx.comp.link_libs_list.toSliceConst()) |lib| {
if (mem.eql(u8, lib.name, "c")) {
// on Darwin, libSystem has libc in it, but also you have to use it
// to make syscalls because the syscall numbers are not documented
// and change between versions.
// so we always link against libSystem
try ctx.args.append("-lSystem");
} else {
if (mem.indexOfScalar(u8, lib.name, '/') == null) {
const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));
} else {
const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name);
try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));
}
}
}
} else {
try ctx.args.append("-undefined");
try ctx.args.append("dynamic_lookup");
}
if (platform.kind == .MacOS) {
if (platform.versionLessThan(10, 5)) {
try ctx.args.append("-lgcc_s.10.4");
} else if (platform.versionLessThan(10, 6)) {
try ctx.args.append("-lgcc_s.10.5");
}
} else {
@panic("TODO");
}
}
fn constructLinkerArgsWasm(ctx: *Context) void {
@panic("TODO");
}
fn addFnObjects(ctx: *Context) !void {
const held = ctx.comp.fn_link_set.acquire();
defer held.release();
var it = held.value.first;
while (it) |node| {
const fn_val = node.data orelse {
// handle the tombstone. See Value.Fn.destroy.
it = node.next;
held.value.remove(node);
ctx.comp.gpa().destroy(node);
continue;
};
try ctx.args.append(fn_val.containing_object.toSliceConst());
it = node.next;
}
}
const DarwinPlatform = struct {
kind: Kind,
major: u32,
minor: u32,
micro: u32,
const Kind = enum {
MacOS,
IPhoneOS,
IPhoneOSSimulator,
};
fn get(comp: *Compilation) !DarwinPlatform {
var result: DarwinPlatform = undefined;
const ver_str = switch (comp.darwin_version_min) {
.MacOS => |ver| blk: {
result.kind = .MacOS;
break :blk ver;
},
.Ios => |ver| blk: {
result.kind = .IPhoneOS;
break :blk ver;
},
.None => blk: {
assert(comp.target.getOs() == .macosx);
result.kind = .MacOS;
break :blk "10.14";
},
};
var had_extra: bool = undefined;
try darwinGetReleaseVersion(
ver_str,
&result.major,
&result.minor,
&result.micro,
&had_extra,
);
if (had_extra or result.major != 10 or result.minor >= 100 or result.micro >= 100) {
return error.InvalidDarwinVersionString;
}
if (result.kind == .IPhoneOS) {
switch (comp.target.getArch()) {
.i386,
.x86_64,
=> result.kind = .IPhoneOSSimulator,
else => {},
}
}
return result;
}
fn versionLessThan(self: DarwinPlatform, major: u32, minor: u32) bool {
if (self.major < major)
return true;
if (self.major > major)
return false;
if (self.minor < minor)
return true;
return false;
}
};
/// Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the
/// grouped values as integers. Numbers which are not provided are set to 0.
/// return true if the entire string was parsed (9.2), or all groups were
/// parsed (10.3.5extrastuff).
fn darwinGetReleaseVersion(str: []const u8, major: *u32, minor: *u32, micro: *u32, had_extra: *bool) !void {
major.* = 0;
minor.* = 0;
micro.* = 0;
had_extra.* = false;
if (str.len == 0)
return error.InvalidDarwinVersionString;
var start_pos: usize = 0;
for ([_]*u32{ major, minor, micro }) |v| {
const dot_pos = mem.indexOfScalarPos(u8, str, start_pos, '.');
const end_pos = dot_pos orelse str.len;
v.* = std.fmt.parseUnsigned(u32, str[start_pos..end_pos], 10) catch return error.InvalidDarwinVersionString;
start_pos = (dot_pos orelse return) + 1;
if (start_pos == str.len) return;
}
had_extra.* = true;
} | src-self-hosted/link.zig |
const std = @import("std");
const Value = @import("value.zig").Value;
const Type = @import("type.zig").Type;
const Module = @import("Module.zig");
const assert = std.debug.assert;
const codegen = @import("codegen.zig");
/// These are in-memory, analyzed instructions. See `zir.Inst` for the representation
/// of instructions that correspond to the ZIR text format.
/// This struct owns the `Value` and `Type` memory. When the struct is deallocated,
/// so are the `Value` and `Type`. The value of a constant must be copied into
/// a memory location for the value to survive after a const instruction.
pub const Inst = struct {
tag: Tag,
/// Each bit represents the index of an `Inst` parameter in the `args` field.
/// If a bit is set, it marks the end of the lifetime of the corresponding
/// instruction parameter. For example, 0b101 means that the first and
/// third `Inst` parameters' lifetimes end after this instruction, and will
/// not have any more following references.
/// The most significant bit being set means that the instruction itself is
/// never referenced, in other words its lifetime ends as soon as it finishes.
/// If bit 15 (0b1xxx_xxxx_xxxx_xxxx) is set, it means this instruction itself is unreferenced.
/// If bit 14 (0bx1xx_xxxx_xxxx_xxxx) is set, it means this is a special case and the
/// lifetimes of operands are encoded elsewhere.
deaths: DeathsInt = undefined,
ty: Type,
/// Byte offset into the source.
src: usize,
pub const DeathsInt = u16;
pub const DeathsBitIndex = std.math.Log2Int(DeathsInt);
pub const unreferenced_bit_index = @typeInfo(DeathsInt).Int.bits - 1;
pub const deaths_bits = unreferenced_bit_index - 1;
pub fn isUnused(self: Inst) bool {
return (self.deaths & (1 << unreferenced_bit_index)) != 0;
}
pub fn operandDies(self: Inst, index: DeathsBitIndex) bool {
assert(index < deaths_bits);
return @truncate(u1, self.deaths >> index) != 0;
}
pub fn specialOperandDeaths(self: Inst) bool {
return (self.deaths & (1 << deaths_bits)) != 0;
}
pub const Tag = enum {
add,
arg,
assembly,
bitcast,
block,
br,
breakpoint,
brvoid,
call,
cmp_lt,
cmp_lte,
cmp_eq,
cmp_gte,
cmp_gt,
cmp_neq,
condbr,
constant,
isnonnull,
isnull,
ptrtoint,
ret,
retvoid,
sub,
unreach,
not,
floatcast,
intcast,
/// There is one-to-one correspondence between tag and type for now,
/// but this will not always be the case. For example, binary operations
/// such as + and - will have different tags but the same type.
pub fn Type(tag: Tag) type {
return switch (tag) {
.retvoid,
.unreach,
.arg,
.breakpoint,
=> NoOp,
.ret,
.bitcast,
.not,
.isnonnull,
.isnull,
.ptrtoint,
.floatcast,
.intcast,
=> UnOp,
.add,
.sub,
.cmp_lt,
.cmp_lte,
.cmp_eq,
.cmp_gte,
.cmp_gt,
.cmp_neq,
=> BinOp,
.assembly => Assembly,
.block => Block,
.br => Br,
.brvoid => BrVoid,
.call => Call,
.condbr => CondBr,
.constant => Constant,
};
}
pub fn fromCmpOp(op: std.math.CompareOperator) Tag {
return switch (op) {
.lt => .cmp_lt,
.lte => .cmp_lte,
.eq => .cmp_eq,
.gte => .cmp_gte,
.gt => .cmp_gt,
.neq => .cmp_neq,
};
}
};
/// Prefer `castTag` to this.
pub fn cast(base: *Inst, comptime T: type) ?*T {
if (@hasField(T, "base_tag")) {
return base.castTag(T.base_tag);
}
inline for (@typeInfo(Tag).Enum.fields) |field| {
const tag = @intToEnum(Tag, field.value);
if (base.tag == tag) {
if (T == tag.Type()) {
return @fieldParentPtr(T, "base", base);
}
return null;
}
}
unreachable;
}
pub fn castTag(base: *Inst, comptime tag: Tag) ?*tag.Type() {
if (base.tag == tag) {
return @fieldParentPtr(tag.Type(), "base", base);
}
return null;
}
pub fn Args(comptime T: type) type {
return std.meta.fieldInfo(T, "args").field_type;
}
/// Returns `null` if runtime-known.
pub fn value(base: *Inst) ?Value {
if (base.ty.onePossibleValue())
return Value.initTag(.the_one_possible_value);
const inst = base.cast(Constant) orelse return null;
return inst.val;
}
pub fn cmpOperator(base: *Inst) ?std.math.CompareOperator {
return switch (self.base.tag) {
.cmp_lt => .lt,
.cmp_lte => .lte,
.cmp_eq => .eq,
.cmp_gte => .gte,
.cmp_gt => .gt,
.cmp_neq => .neq,
else => null,
};
}
pub fn operandCount(base: *Inst) usize {
inline for (@typeInfo(Tag).Enum.fields) |field| {
const tag = @intToEnum(Tag, field.value);
if (tag == base.tag) {
return @fieldParentPtr(tag.Type(), "base", base).operandCount();
}
}
unreachable;
}
pub fn getOperand(base: *Inst, index: usize) ?*Inst {
inline for (@typeInfo(Tag).Enum.fields) |field| {
const tag = @intToEnum(Tag, field.value);
if (tag == base.tag) {
return @fieldParentPtr(tag.Type(), "base", base).getOperand(index);
}
}
unreachable;
}
pub const NoOp = struct {
base: Inst,
pub fn operandCount(self: *const NoOp) usize {
return 0;
}
pub fn getOperand(self: *const NoOp, index: usize) ?*Inst {
return null;
}
};
pub const UnOp = struct {
base: Inst,
operand: *Inst,
pub fn operandCount(self: *const UnOp) usize {
return 1;
}
pub fn getOperand(self: *const UnOp, index: usize) ?*Inst {
if (index == 0)
return self.operand;
return null;
}
};
pub const BinOp = struct {
base: Inst,
lhs: *Inst,
rhs: *Inst,
pub fn operandCount(self: *const BinOp) usize {
return 2;
}
pub fn getOperand(self: *const BinOp, index: usize) ?*Inst {
var i = index;
if (i < 1)
return self.lhs;
i -= 1;
if (i < 1)
return self.rhs;
i -= 1;
return null;
}
};
pub const Assembly = struct {
pub const base_tag = Tag.assembly;
base: Inst,
asm_source: []const u8,
is_volatile: bool,
output: ?[]const u8,
inputs: []const []const u8,
clobbers: []const []const u8,
args: []const *Inst,
pub fn operandCount(self: *const Assembly) usize {
return self.args.len;
}
pub fn getOperand(self: *const Assembly, index: usize) ?*Inst {
if (index < self.args.len)
return self.args[index];
return null;
}
};
pub const Block = struct {
pub const base_tag = Tag.block;
base: Inst,
body: Body,
/// This memory is reserved for codegen code to do whatever it needs to here.
codegen: codegen.BlockData = .{},
pub fn operandCount(self: *const Block) usize {
return 0;
}
pub fn getOperand(self: *const Block, index: usize) ?*Inst {
return null;
}
};
pub const Br = struct {
pub const base_tag = Tag.br;
base: Inst,
block: *Block,
operand: *Inst,
pub fn operandCount(self: *const Br) usize {
return 0;
}
pub fn getOperand(self: *const Br, index: usize) ?*Inst {
if (index == 0)
return self.operand;
return null;
}
};
pub const BrVoid = struct {
pub const base_tag = Tag.brvoid;
base: Inst,
block: *Block,
pub fn operandCount(self: *const BrVoid) usize {
return 0;
}
pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst {
return null;
}
};
pub const Call = struct {
pub const base_tag = Tag.call;
base: Inst,
func: *Inst,
args: []const *Inst,
pub fn operandCount(self: *const Call) usize {
return self.args.len + 1;
}
pub fn getOperand(self: *const Call, index: usize) ?*Inst {
var i = index;
if (i < 1)
return self.func;
i -= 1;
if (i < self.args.len)
return self.args[i];
i -= self.args.len;
return null;
}
};
pub const CondBr = struct {
pub const base_tag = Tag.condbr;
base: Inst,
condition: *Inst,
then_body: Body,
else_body: Body,
/// Set of instructions whose lifetimes end at the start of one of the branches.
/// The `true` branch is first: `deaths[0..true_death_count]`.
/// The `false` branch is next: `(deaths + true_death_count)[..false_death_count]`.
deaths: [*]*Inst = undefined,
true_death_count: u32 = 0,
false_death_count: u32 = 0,
pub fn operandCount(self: *const CondBr) usize {
return 1;
}
pub fn getOperand(self: *const CondBr, index: usize) ?*Inst {
var i = index;
if (i < 1)
return self.condition;
i -= 1;
return null;
}
};
pub const Constant = struct {
pub const base_tag = Tag.constant;
base: Inst,
val: Value,
pub fn operandCount(self: *const Constant) usize {
return 0;
}
pub fn getOperand(self: *const Constant, index: usize) ?*Inst {
return null;
}
};
};
pub const Body = struct {
instructions: []*Inst,
}; | src-self-hosted/ir.zig |
const std = @import("std");
const Builder = std.build.Builder;
const system_sdk = @import("system_sdk.zig");
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode);
main_tests.setTarget(target);
link(b, main_tests, .{});
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
}
pub const LinuxWindowManager = enum {
X11,
Wayland,
};
pub const Options = struct {
/// Not supported on macOS.
vulkan: bool = true,
/// Only respected on macOS.
metal: bool = true,
/// Deprecated on macOS.
opengl: bool = false,
/// Not supported on macOS. GLES v3.2 only, currently.
gles: bool = false,
/// Only respected on Linux.
linux_window_manager: LinuxWindowManager = .X11,
/// System SDK options.
system_sdk: system_sdk.Options = .{},
};
pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
const lib = buildLibrary(b, step, options);
step.linkLibrary(lib);
linkGLFWDependencies(b, step, options);
}
fn buildLibrary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) *std.build.LibExeObjStep {
const main_abs = std.fs.path.join(b.allocator, &.{ thisDir(), "src/main.zig" }) catch unreachable;
const lib = b.addStaticLibrary("glfw", main_abs);
lib.setBuildMode(step.build_mode);
lib.setTarget(step.target);
// TODO(build-system): pass system SDK options through
system_sdk.include(b, step, .{});
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
const include_glfw_src = "-I" ++ thisDir() ++ "/upstream/glfw/src";
switch (target.os.tag) {
.windows => lib.addCSourceFile(thisDir() ++ "/src/sources_windows.c", &.{ "-D_GLFW_WIN32", include_glfw_src }),
.macos => lib.addCSourceFiles(&.{
thisDir() ++ "/src/sources_macos.m",
thisDir() ++ "/src/sources_macos.c",
}, &.{ "-D_GLFW_COCOA", include_glfw_src }),
else => {
// TODO(future): for now, Linux must be built with glibc, not musl:
//
// ```
// ld.lld: error: cannot create a copy relocation for symbol stderr
// thread 2004762 panic: attempt to unwrap error: LLDReportedFailure
// ```
step.target.abi = .gnu;
lib.setTarget(step.target);
var sources = std.ArrayList([]const u8).init(b.allocator);
const flag = switch (options.linux_window_manager) {
.X11 => "-D_GLFW_X11",
.Wayland => "-D_GLFW_WAYLAND",
};
sources.append(thisDir() ++ "/src/sources_linux.c") catch unreachable;
switch (options.linux_window_manager) {
.X11 => sources.append(thisDir() ++ "/src/sources_linux_x11.c") catch unreachable,
.Wayland => sources.append(thisDir() ++ "/src/sources_linux_wayland.c") catch unreachable,
}
lib.addCSourceFiles(sources.items, &.{ flag, "-I" ++ thisDir() ++ "/upstream/glfw/src" });
},
}
linkGLFWDependencies(b, lib, options);
lib.install();
return lib;
}
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
const include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/glfw/include" }) catch unreachable;
defer b.allocator.free(include_dir);
step.addIncludeDir(include_dir);
const vulkan_include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/vulkan_headers/include" }) catch unreachable;
defer b.allocator.free(vulkan_include_dir);
step.addIncludeDir(vulkan_include_dir);
step.linkLibC();
// TODO(build-system): pass system SDK options through
system_sdk.include(b, step, .{});
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
switch (target.os.tag) {
.windows => {
step.linkSystemLibrary("gdi32");
step.linkSystemLibrary("user32");
step.linkSystemLibrary("shell32");
if (options.opengl) {
step.linkSystemLibrary("opengl32");
}
if (options.gles) {
step.linkSystemLibrary("GLESv3");
}
},
.macos => {
step.linkFramework("IOKit");
step.linkFramework("CoreFoundation");
if (options.metal) {
step.linkFramework("Metal");
}
if (options.opengl) {
step.linkFramework("OpenGL");
}
step.linkSystemLibrary("objc");
step.linkFramework("AppKit");
step.linkFramework("CoreServices");
step.linkFramework("CoreGraphics");
step.linkFramework("Foundation");
},
else => {
// Assume Linux-like
switch (options.linux_window_manager) {
.X11 => {
step.linkSystemLibrary("X11");
step.linkSystemLibrary("xcb");
step.linkSystemLibrary("Xau");
step.linkSystemLibrary("Xdmcp");
},
.Wayland => step.linkSystemLibrary("wayland-client"),
}
// Note: no need to link against vulkan, GLFW finds it dynamically at runtime.
// https://www.glfw.org/docs/3.3/vulkan_guide.html#vulkan_loader
if (options.opengl) {
step.linkSystemLibrary("GL");
}
if (options.gles) {
step.linkSystemLibrary("GLESv3");
}
},
}
} | build.zig |
const std = @import("std");
const c = @import("internal/c.zig");
const internal = @import("internal/internal.zig");
const log = std.log.scoped(.git);
const git = @import("git.zig");
pub const Mailmap = opaque {
/// Allocate a new mailmap object.
///
/// This object is empty, so you'll have to add a mailmap file before you can do anything with it.
/// The mailmap must be freed with 'deinit'.
pub fn init() !*Mailmap {
log.debug("Mailmap.init called", .{});
var mailmap: *Mailmap = undefined;
try internal.wrapCall("git_mailmap_new", .{
@ptrCast(*?*c.git_mailmap, &mailmap),
});
log.debug("successfully initalized mailmap {*}", .{mailmap});
return mailmap;
}
/// Free the mailmap and its associated memory.
pub fn deinit(self: *Mailmap) void {
log.debug("Mailmap.deinit called", .{});
c.git_mailmap_free(@ptrCast(*c.git_mailmap, self));
log.debug("Mailmap freed successfully", .{});
}
/// Add a single entry to the given mailmap object. If the entry already exists, it will be replaced with the new entry.
///
/// ## Parameters
/// * `real_name` - the real name to use, or NULL
/// * `real_email` - the real email to use, or NULL
/// * `replace_name` - the name to replace, or NULL
/// * `replace_email` - the email to replace
pub fn addEntry(
self: *Mailmap,
real_name: ?[:0]const u8,
real_email: ?[:0]const u8,
replace_name: ?[:0]const u8,
replace_email: [:0]const u8,
) !void {
log.debug(
"Mailmap.addEntry called, real_name={s}, real_email={s}, replace_name={s}, replace_email={s}",
.{ real_name, real_email, replace_name, replace_email },
);
const c_real_name = if (real_name) |ptr| ptr.ptr else null;
const c_real_email = if (real_email) |ptr| ptr.ptr else null;
const c_replace_name = if (replace_name) |ptr| ptr.ptr else null;
try internal.wrapCall("git_mailmap_add_entry", .{
@ptrCast(*c.git_mailmap, self),
c_real_name,
c_real_email,
c_replace_name,
replace_email.ptr,
});
log.debug("successfully added entry to mailmap", .{});
}
pub const ResolveResult = struct {
real_name: [:0]const u8,
real_email: [:0]const u8,
};
/// Resolve a name and email to the corresponding real name and email.
///
/// The lifetime of the strings are tied to `self`, `name`, and `email` parameters.
///
/// ## Parameters
/// * `self` - the mailmap to perform a lookup with (may be NULL)
/// * `name` - the name to look up
/// * `email` - the email to look up
pub fn resolve(self: ?*const Mailmap, name: [:0]const u8, email: [:0]const u8) !ResolveResult {
log.debug("Mailmap.resolve called, name={s}, email={s}", .{ name, email });
var real_name: [*c]const u8 = undefined;
var real_email: [*c]const u8 = undefined;
try internal.wrapCall("git_mailmap_resolve", .{
&real_name,
&real_email,
@ptrCast(*const c.git_mailmap, self),
name.ptr,
email.ptr,
});
const ret = ResolveResult{
.real_name = std.mem.sliceTo(real_name, 0),
.real_email = std.mem.sliceTo(real_email, 0),
};
log.debug("successfully resolved name and email: {}", .{ret});
return ret;
}
/// Resolve a signature to use real names and emails with a mailmap.
///
/// Call `git.Signature.deinit` to free the data.
///
/// ## Parameters
/// * `signature` - signature to resolve
pub fn resolveSignature(self: *const Mailmap, signature: *const git.Signature) !*git.Signature {
log.debug("Mailmap.resolveSignature called, signature={*}", .{signature});
var sig: *git.Signature = undefined;
try internal.wrapCall("git_mailmap_resolve_signature", .{
@ptrCast(*[*c]c.git_signature, &sig),
@ptrCast(*const c.git_mailmap, self),
@ptrCast(*const c.git_signature, signature),
});
log.debug("successfully resolved signature", .{});
return sig;
}
comptime {
std.testing.refAllDecls(@This());
}
};
comptime {
std.testing.refAllDecls(@This());
} | src/mailmap.zig |
const memory = @import("memory.zig");
pub fn List(comptime Type: type) type {
return struct {
const Self = @This();
pub const Node = struct {
next: ?*Node,
prev: ?*Node,
value: Type,
};
alloc: *memory.Allocator,
head: ?*Node = null,
tail: ?*Node = null,
len: usize = 0,
pub fn remove_node(self: *Self, node_maybe: ?*Node) void {
if (node_maybe) |node| {
if (node.next) |next| {
next.prev = node.prev;
}
if (node.prev) |prev| {
prev.next = node.next;
}
if (node == self.head) {
self.head = node.next;
}
if (node == self.tail) {
self.tail = node.prev;
}
self.len -= 1;
}
}
pub fn push_front_node(self: *Self, node: *Node) void {
node.next = self.head;
node.prev = null;
if (self.head) |head| {
head.prev = node;
}
self.head = node;
if (self.len == 0) {
self.tail = node;
}
self.len += 1;
}
pub fn push_front(self: *Self, value: Type) memory.MemoryError!void {
const node = try self.alloc.alloc(Node);
node.value = value;
self.push_front_node(node);
}
pub fn pop_front_node(self: *Self) ?*Node {
const node = self.head;
self.remove_node(node);
return node;
}
pub fn pop_front(self: *Self) memory.MemoryError!?Type {
if (self.pop_front_node()) |node| {
const value = node.value;
try self.alloc.free(node);
return value;
}
return null;
}
pub fn bump_node_to_front(self: *Self, node: *Node) void {
if (self.head == node) {
return;
}
self.remove_node(node);
self.push_front_node(node);
}
pub fn push_back_node(self: *Self, node: *Node) void {
node.next = null;
node.prev = self.tail;
if (self.tail) |tail| {
tail.next = node;
}
self.tail = node;
if (self.len == 0) {
self.head = node;
}
self.len += 1;
}
pub fn push_back(self: *Self, value: Type) memory.MemoryError!void {
const node = try self.alloc.alloc(Node);
node.value = value;
self.push_back_node(node);
}
pub fn pop_back_node(self: *Self) ?*Node {
const node = self.tail;
self.remove_node(node);
return node;
}
pub fn pop_back(self: *Self) memory.MemoryError!?Type {
if (self.pop_back_node()) |node| {
const value = node.value;
try self.alloc.free(node);
return value;
}
return null;
}
pub fn bump_node_to_back(self: *Self, node: *Node) void {
if (self.tail == node) {
return;
}
self.remove_node(node);
self.push_back_node(node);
}
pub fn push_back_list(self: *Self, other: *Self) void {
if (other.head) |other_head| {
other_head.prev = self.tail;
if (self.tail) |tail| {
tail.next = other_head;
}
self.tail = other.tail;
if (self.len == 0) {
self.head = other_head;
}
self.len += other.len;
other.head = null;
other.tail = null;
other.len = 0;
}
}
pub fn clear(self: *Self) memory.MemoryError!void {
while (self.pop_back_node()) |node| {
try self.alloc.free(node);
}
}
pub const Iterator = struct {
node: ?*Node,
pub fn next(self: *Iterator) ?Type {
if (self.node) |n| {
self.node = n.next;
return n.value;
}
return null;
}
pub fn done(self: *const Iterator) bool {
return self.node == null;
}
};
pub fn iterator(self: *Self) Iterator {
return Iterator{.node = self.head};
}
// TODO: Make generic with Iterator?
pub const ConstIterator = struct {
node: ?*const Node,
pub fn next(self: *ConstIterator) ?Type {
if (self.node) |n| {
self.node = n.next;
return n.value;
}
return null;
}
pub fn done(self: *const ConstIterator) bool {
return self.node == null;
}
};
pub fn const_iterator(self: *const Self) ConstIterator {
return ConstIterator{.node = self.head};
}
};
}
test "List" {
const std = @import("std");
const equal = std.testing.expectEqual;
var alloc = memory.UnitTestAllocator{};
alloc.init();
defer alloc.done();
const UsizeList = List(usize);
var list = UsizeList{.alloc = &alloc.allocator};
const nilv: ?usize = null;
const niln: ?*UsizeList.Node = null;
// Empty
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
// Push Some Values
try list.push_back(1);
try equal(@as(usize, 1), list.len);
try list.push_back(2);
try equal(@as(usize, 2), list.len);
try list.push_back(3);
try equal(@as(usize, 3), list.len);
// Test Iterator
var i: usize = 0;
const expected = [_]usize{1, 2, 3};
var it = list.iterator();
while (it.next()) |actual| {
try equal(expected[i], actual);
i += 1;
}
// pop_back The Values
try equal(@as(usize, 3), (try list.pop_back()).?);
try equal(@as(usize, 2), list.len);
try equal(@as(usize, 2), (try list.pop_back()).?);
try equal(@as(usize, 1), list.len);
try equal(@as(usize, 1), (try list.pop_back()).?);
// It's empty again
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
// Push Some Values
try list.push_front(1);
try equal(@as(usize, 1), list.len);
try list.push_back(2);
try list.push_front(3);
try list.push_front(10);
try equal(@as(usize, 4), list.len);
// pop_back The Values
try equal(@as(usize, 10), (try list.pop_front()).?);
try equal(@as(usize, 3), (try list.pop_front()).?);
try equal(@as(usize, 1), (try list.pop_front()).?);
try equal(@as(usize, 2), (try list.pop_front()).?);
// It's empty yet again
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
// Clear
try list.push_back(12);
try list.push_front(6);
try list.clear();
// It's empty ... again
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
// Test push_back_list by adding empty list to empty list
var other_list = UsizeList{.alloc = &alloc.allocator};
list.push_back_list(&other_list);
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
// Test push_back_list by adding non empty list to empty list
try other_list.push_back(1);
try other_list.push_back(3);
list.push_back_list(&other_list);
try equal(@as(usize, 0), other_list.len);
try equal(nilv, try other_list.pop_back());
try equal(nilv, try other_list.pop_front());
try equal(niln, other_list.head);
try equal(niln, other_list.tail);
try equal(@as(usize, 2), list.len);
// Test push_back_list by adding non empty list to non empty list
try other_list.push_back(5);
try other_list.push_back(7);
list.push_back_list(&other_list);
try equal(@as(usize, 0), other_list.len);
try equal(nilv, try other_list.pop_back());
try equal(nilv, try other_list.pop_front());
try equal(niln, other_list.head);
try equal(niln, other_list.tail);
try equal(@as(usize, 4), list.len);
try equal(@as(usize, 1), (try list.pop_front()).?);
try equal(@as(usize, 3), (try list.pop_front()).?);
try equal(@as(usize, 5), (try list.pop_front()).?);
try equal(@as(usize, 7), (try list.pop_front()).?);
try equal(@as(usize, 0), list.len);
try equal(nilv, try list.pop_back());
try equal(nilv, try list.pop_front());
try equal(niln, list.head);
try equal(niln, list.tail);
} | kernel/list.zig |
const mem = @import("../mem.zig");
const math = @import("../math/index.zig");
const endian = @import("../endian.zig");
const builtin = @import("builtin");
const debug = @import("../debug/index.zig");
const fmt = @import("../fmt/index.zig");
const RoundParam = struct {
a: usize,
b: usize,
c: usize,
d: usize,
k: usize,
s: u32,
t: u32,
};
fn Rp(a: usize, b: usize, c: usize, d: usize, k: usize, s: u32, t: u32) RoundParam {
return RoundParam{
.a = a,
.b = b,
.c = c,
.d = d,
.k = k,
.s = s,
.t = t,
};
}
pub const Md5 = struct {
const Self = @This();
const block_length = 64;
const digest_length = 16;
s: [4]u32,
// Streaming Cache
buf: [64]u8,
buf_len: u8,
total_len: u64,
pub fn init() Self {
var d: Self = undefined;
d.reset();
return d;
}
pub fn reset(d: *Self) void {
d.s[0] = 0x67452301;
d.s[1] = 0xEFCDAB89;
d.s[2] = 0x98BADCFE;
d.s[3] = 0x10325476;
d.buf_len = 0;
d.total_len = 0;
}
pub fn hash(b: []const u8, out: []u8) void {
var d = Md5.init();
d.update(b);
d.final(out);
}
pub fn update(d: *Self, b: []const u8) void {
var off: usize = 0;
// Partial buffer exists from previous update. Copy into buffer then hash.
if (d.buf_len != 0 and d.buf_len + b.len > 64) {
off += 64 - d.buf_len;
mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
d.round(d.buf[0..]);
d.buf_len = 0;
}
// Full middle blocks.
while (off + 64 <= b.len) : (off += 64) {
d.round(b[off .. off + 64]);
}
// Copy any remainder for next pass.
mem.copy(u8, d.buf[d.buf_len..], b[off..]);
d.buf_len += @intCast(u8, b[off..].len);
// Md5 uses the bottom 64-bits for length padding
d.total_len +%= b.len;
}
pub fn final(d: *Self, out: []u8) void {
debug.assert(out.len >= 16);
// The buffer here will never be completely full.
mem.set(u8, d.buf[d.buf_len..], 0);
// Append padding bits.
d.buf[d.buf_len] = 0x80;
d.buf_len += 1;
// > 448 mod 512 so need to add an extra round to wrap around.
if (64 - d.buf_len < 8) {
d.round(d.buf[0..]);
mem.set(u8, d.buf[0..], 0);
}
// Append message length.
var i: usize = 1;
var len = d.total_len >> 5;
d.buf[56] = @intCast(u8, d.total_len & 0x1f) << 3;
while (i < 8) : (i += 1) {
d.buf[56 + i] = @intCast(u8, len & 0xff);
len >>= 8;
}
d.round(d.buf[0..]);
for (d.s) |s, j| {
mem.writeInt(out[4 * j .. 4 * j + 4], s, builtin.Endian.Little);
}
}
fn round(d: *Self, b: []const u8) void {
debug.assert(b.len == 64);
var s: [16]u32 = undefined;
var i: usize = 0;
while (i < 16) : (i += 1) {
// NOTE: Performing or's separately improves perf by ~10%
s[i] = 0;
s[i] |= u32(b[i * 4 + 0]);
s[i] |= u32(b[i * 4 + 1]) << 8;
s[i] |= u32(b[i * 4 + 2]) << 16;
s[i] |= u32(b[i * 4 + 3]) << 24;
}
var v: [4]u32 = []u32{
d.s[0],
d.s[1],
d.s[2],
d.s[3],
};
const round0 = comptime []RoundParam{
Rp(0, 1, 2, 3, 0, 7, 0xD76AA478),
Rp(3, 0, 1, 2, 1, 12, 0xE8C7B756),
Rp(2, 3, 0, 1, 2, 17, 0x242070DB),
Rp(1, 2, 3, 0, 3, 22, 0xC1BDCEEE),
Rp(0, 1, 2, 3, 4, 7, 0xF57C0FAF),
Rp(3, 0, 1, 2, 5, 12, 0x4787C62A),
Rp(2, 3, 0, 1, 6, 17, 0xA8304613),
Rp(1, 2, 3, 0, 7, 22, 0xFD469501),
Rp(0, 1, 2, 3, 8, 7, 0x698098D8),
Rp(3, 0, 1, 2, 9, 12, 0x8B44F7AF),
Rp(2, 3, 0, 1, 10, 17, 0xFFFF5BB1),
Rp(1, 2, 3, 0, 11, 22, 0x895CD7BE),
Rp(0, 1, 2, 3, 12, 7, 0x6B901122),
Rp(3, 0, 1, 2, 13, 12, 0xFD987193),
Rp(2, 3, 0, 1, 14, 17, 0xA679438E),
Rp(1, 2, 3, 0, 15, 22, 0x49B40821),
};
inline for (round0) |r| {
v[r.a] = v[r.a] +% (v[r.d] ^ (v[r.b] & (v[r.c] ^ v[r.d]))) +% r.t +% s[r.k];
v[r.a] = v[r.b] +% math.rotl(u32, v[r.a], r.s);
}
const round1 = comptime []RoundParam{
Rp(0, 1, 2, 3, 1, 5, 0xF61E2562),
Rp(3, 0, 1, 2, 6, 9, 0xC040B340),
Rp(2, 3, 0, 1, 11, 14, 0x265E5A51),
Rp(1, 2, 3, 0, 0, 20, 0xE9B6C7AA),
Rp(0, 1, 2, 3, 5, 5, 0xD62F105D),
Rp(3, 0, 1, 2, 10, 9, 0x02441453),
Rp(2, 3, 0, 1, 15, 14, 0xD8A1E681),
Rp(1, 2, 3, 0, 4, 20, 0xE7D3FBC8),
Rp(0, 1, 2, 3, 9, 5, 0x21E1CDE6),
Rp(3, 0, 1, 2, 14, 9, 0xC33707D6),
Rp(2, 3, 0, 1, 3, 14, 0xF4D50D87),
Rp(1, 2, 3, 0, 8, 20, 0x455A14ED),
Rp(0, 1, 2, 3, 13, 5, 0xA9E3E905),
Rp(3, 0, 1, 2, 2, 9, 0xFCEFA3F8),
Rp(2, 3, 0, 1, 7, 14, 0x676F02D9),
Rp(1, 2, 3, 0, 12, 20, 0x8D2A4C8A),
};
inline for (round1) |r| {
v[r.a] = v[r.a] +% (v[r.c] ^ (v[r.d] & (v[r.b] ^ v[r.c]))) +% r.t +% s[r.k];
v[r.a] = v[r.b] +% math.rotl(u32, v[r.a], r.s);
}
const round2 = comptime []RoundParam{
Rp(0, 1, 2, 3, 5, 4, 0xFFFA3942),
Rp(3, 0, 1, 2, 8, 11, 0x8771F681),
Rp(2, 3, 0, 1, 11, 16, 0x6D9D6122),
Rp(1, 2, 3, 0, 14, 23, 0xFDE5380C),
Rp(0, 1, 2, 3, 1, 4, 0xA4BEEA44),
Rp(3, 0, 1, 2, 4, 11, 0x4BDECFA9),
Rp(2, 3, 0, 1, 7, 16, 0xF6BB4B60),
Rp(1, 2, 3, 0, 10, 23, 0xBEBFBC70),
Rp(0, 1, 2, 3, 13, 4, 0x289B7EC6),
Rp(3, 0, 1, 2, 0, 11, 0xEAA127FA),
Rp(2, 3, 0, 1, 3, 16, 0xD4EF3085),
Rp(1, 2, 3, 0, 6, 23, 0x04881D05),
Rp(0, 1, 2, 3, 9, 4, 0xD9D4D039),
Rp(3, 0, 1, 2, 12, 11, 0xE6DB99E5),
Rp(2, 3, 0, 1, 15, 16, 0x1FA27CF8),
Rp(1, 2, 3, 0, 2, 23, 0xC4AC5665),
};
inline for (round2) |r| {
v[r.a] = v[r.a] +% (v[r.b] ^ v[r.c] ^ v[r.d]) +% r.t +% s[r.k];
v[r.a] = v[r.b] +% math.rotl(u32, v[r.a], r.s);
}
const round3 = comptime []RoundParam{
Rp(0, 1, 2, 3, 0, 6, 0xF4292244),
Rp(3, 0, 1, 2, 7, 10, 0x432AFF97),
Rp(2, 3, 0, 1, 14, 15, 0xAB9423A7),
Rp(1, 2, 3, 0, 5, 21, 0xFC93A039),
Rp(0, 1, 2, 3, 12, 6, 0x655B59C3),
Rp(3, 0, 1, 2, 3, 10, 0x8F0CCC92),
Rp(2, 3, 0, 1, 10, 15, 0xFFEFF47D),
Rp(1, 2, 3, 0, 1, 21, 0x85845DD1),
Rp(0, 1, 2, 3, 8, 6, 0x6FA87E4F),
Rp(3, 0, 1, 2, 15, 10, 0xFE2CE6E0),
Rp(2, 3, 0, 1, 6, 15, 0xA3014314),
Rp(1, 2, 3, 0, 13, 21, 0x4E0811A1),
Rp(0, 1, 2, 3, 4, 6, 0xF7537E82),
Rp(3, 0, 1, 2, 11, 10, 0xBD3AF235),
Rp(2, 3, 0, 1, 2, 15, 0x2AD7D2BB),
Rp(1, 2, 3, 0, 9, 21, 0xEB86D391),
};
inline for (round3) |r| {
v[r.a] = v[r.a] +% (v[r.c] ^ (v[r.b] | ~v[r.d])) +% r.t +% s[r.k];
v[r.a] = v[r.b] +% math.rotl(u32, v[r.a], r.s);
}
d.s[0] +%= v[0];
d.s[1] +%= v[1];
d.s[2] +%= v[2];
d.s[3] +%= v[3];
}
};
const htest = @import("test.zig");
test "md5 single" {
htest.assertEqualHash(Md5, "d41d8cd98f00b204e9800998ecf8427e", "");
htest.assertEqualHash(Md5, "0cc175b9c0f1b6a831c399e269772661", "a");
htest.assertEqualHash(Md5, "900150983cd24fb0d6963f7d28e17f72", "abc");
htest.assertEqualHash(Md5, "f96b697d7cb7938d525a2f31aaf161d0", "message digest");
htest.assertEqualHash(Md5, "c3fcd3d76192e4007dfb496cca67e13b", "abcdefghijklmnopqrstuvwxyz");
htest.assertEqualHash(Md5, "d174ab98d277d9f5a5611c2c9f419d9f", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
htest.assertEqualHash(Md5, "57edf4a22be3c955ac49da2e2107b67a", "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
}
test "md5 streaming" {
var h = Md5.init();
var out: [16]u8 = undefined;
h.final(out[0..]);
htest.assertEqual("d41d8cd98f00b204e9800998ecf8427e", out[0..]);
h.reset();
h.update("abc");
h.final(out[0..]);
htest.assertEqual("900150983cd24fb0d6963f7d28e17f72", out[0..]);
h.reset();
h.update("a");
h.update("b");
h.update("c");
h.final(out[0..]);
htest.assertEqual("900150983cd24fb0d6963f7d28e17f72", out[0..]);
}
test "md5 aligned final" {
var block = []u8{0} ** Md5.block_length;
var out: [Md5.digest_length]u8 = undefined;
var h = Md5.init();
h.update(block);
h.final(out[0..]);
} | std/crypto/md5.zig |
const std = @import("std");
const mem = std.mem;
const json = std.json;
const Lexer = @import("lexer.zig").Lexer;
const TokenIds = [_][]const u8{
"Invalid",
"Whitespace",
"Text",
"AtxHeader",
"EOF",
};
pub const TokenId = enum {
Invalid,
Whitespace,
Text,
AtxHeader,
EOF,
pub fn string(self: TokenId) []const u8 {
const m = @enumToInt(self);
if (@enumToInt(TokenId.Invalid) <= m and m <= @enumToInt(TokenId.EOF)) {
return TokenIds[m];
}
unreachable;
}
pub fn jsonStringify(
self: @This(),
options: json.StringifyOptions,
out_stream: anytype,
) !void {
try json.stringify(self.string(), options, out_stream);
}
};
pub const Token = struct {
ID: TokenId,
startOffset: u32,
endOffset: u32,
string: []const u8,
lineNumber: u32,
column: u32,
pub fn jsonStringify(
value: @This(),
options: json.StringifyOptions,
out_stream: anytype,
) !void {
try out_stream.writeByte('{');
const T = @TypeOf(value);
const S = @typeInfo(T).Struct;
comptime var field_output = false;
var child_options = options;
if (child_options.whitespace) |*child_whitespace| {
child_whitespace.indent_level += 1;
}
inline for (S.fields) |Field, field_i| {
if (Field.field_type == void) continue;
if (!field_output) {
field_output = true;
} else {
try out_stream.writeByte(',');
}
if (child_options.whitespace) |child_whitespace| {
// FIXME: all this to remove this line...
// try out_stream.writeByte('\n');
try child_whitespace.outputIndent(out_stream);
}
try json.stringify(Field.name, options, out_stream);
try out_stream.writeByte(':');
if (child_options.whitespace) |child_whitespace| {
if (child_whitespace.separator) {
try out_stream.writeByte(' ');
}
}
if (comptime !mem.eql(u8, Field.name, "Children")) {
try json.stringify(@field(value, Field.name), child_options, out_stream);
} else {
var boop = @field(value, Field.name);
if (boop.items.len == 0) {
_ = try out_stream.writeAll("[]");
} else {
_ = try out_stream.write("[");
for (boop.items) |item| {
try json.stringify(item, child_options, out_stream);
}
_ = try out_stream.write("]");
}
}
}
if (field_output) {
if (options.whitespace) |whitespace| {
// FIXME: all this to remove this line...
// try out_stream.writeByte('\n');
try whitespace.outputIndent(out_stream);
}
}
try out_stream.writeByte(' ');
try out_stream.writeByte('}');
return;
}
};
pub const TokenRule = fn (lexer: *Lexer) anyerror!?Token; | src/md/token.zig |
const sg = @import("sokol").gfx;
//
// #version:1# (machine generated, don't edit!)
//
// Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
//
// Cmdline: sokol-shdc -i main.glsl -o main.zig -l glsl330:glsl100:hlsl4:metal_macos -f sokol_zig
//
// Overview:
//
// Shader program 'main':
// Get shader desc: shd.mainShaderDesc(sg.queryBackend());
// Vertex shader: vs
// Attribute slots:
// ATTR_vs_pos = 0
// ATTR_vs_color0 = 1
// ATTR_vs_texcoord0 = 2
// Uniform block 'vs_params':
// C struct: vs_params_t
// Bind slot: SLOT_vs_params = 0
// Fragment shader: fs
// Uniform block 'fs_params':
// C struct: fs_params_t
// Bind slot: SLOT_fs_params = 0
// Image 'tex':
// Type: ._2D
// Component Type: .FLOAT
// Bind slot: SLOT_tex = 0
//
//
pub const ATTR_vs_pos = 0;
pub const ATTR_vs_color0 = 1;
pub const ATTR_vs_texcoord0 = 2;
pub const SLOT_tex = 0;
pub const SLOT_vs_params = 0;
pub const VsParams = extern struct {
mvp: @import("../math.zig").Mat4 align(16),
};
pub const SLOT_fs_params = 0;
pub const FsParams = extern struct {
globalcolor: [4]f32 align(16),
cropping: [4]f32,
};
//
// #version 330
//
// uniform vec4 vs_params[4];
// layout(location = 0) in vec4 pos;
// out vec4 color;
// layout(location = 1) in vec4 color0;
// out vec2 uv;
// layout(location = 2) in vec2 texcoord0;
//
// void main()
// {
// gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * pos;
// color = color0;
// uv = texcoord0 * 5.0;
// }
//
//
const vs_source_glsl330 = [332]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,
0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,
0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,
0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
0x72,0x64,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
0x5d,0x29,0x20,0x2a,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,
0x20,0x2a,0x20,0x35,0x2e,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// #version 330
//
// uniform vec4 fs_params[2];
// uniform sampler2D tex;
//
// layout(location = 0) out vec4 frag_color;
// in vec2 uv;
// in vec4 color;
//
// void main()
// {
// frag_color = texture(tex, (uv * fs_params[1].xy) + fs_params[1].zw) * fs_params[0];
// }
//
//
const fs_source_glsl330 = [241]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x3b,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,
0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x76,0x65,
0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,
0x78,0x2c,0x20,0x28,0x75,0x76,0x20,0x2a,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x31,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2b,0x20,0x66,0x73,0x5f,0x70,
0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2e,0x7a,0x77,0x29,0x20,0x2a,0x20,0x66,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
};
//
// #version 100
//
// uniform vec4 vs_params[4];
// attribute vec4 pos;
// varying vec4 color;
// attribute vec4 color0;
// varying vec2 uv;
// attribute vec2 texcoord0;
//
// void main()
// {
// gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * pos;
// color = color0;
// uv = texcoord0 * 5.0;
// }
//
//
const vs_source_glsl100 = [298]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x76,0x61,0x72,
0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,
0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,
0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x2a,
0x20,0x35,0x2e,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// #version 100
// precision mediump float;
// precision highp int;
//
// uniform highp vec4 fs_params[2];
// uniform highp sampler2D tex;
//
// varying highp vec2 uv;
// varying highp vec4 color;
//
// void main()
// {
// gl_FragData[0] = texture2D(tex, (uv * fs_params[1].xy) + fs_params[1].zw) * fs_params[0];
// }
//
//
const fs_source_glsl100 = [285]u8 {
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65,
0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,
0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,
0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x3b,0x0a,0x75,0x6e,0x69,
0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,
0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,
0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,
0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,
0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x28,
0x75,0x76,0x20,0x2a,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,
0x5d,0x2e,0x78,0x79,0x29,0x20,0x2b,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x31,0x5d,0x2e,0x7a,0x77,0x29,0x20,0x2a,0x20,0x66,0x73,0x5f,0x70,0x61,
0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// cbuffer vs_params : register(b0)
// {
// row_major float4x4 _21_mvp : packoffset(c0);
// };
//
//
// static float4 gl_Position;
// static float4 pos;
// static float4 color;
// static float4 color0;
// static float2 uv;
// static float2 texcoord0;
//
// struct SPIRV_Cross_Input
// {
// float4 pos : TEXCOORD0;
// float4 color0 : TEXCOORD1;
// float2 texcoord0 : TEXCOORD2;
// };
//
// struct SPIRV_Cross_Output
// {
// float4 color : TEXCOORD0;
// float2 uv : TEXCOORD1;
// float4 gl_Position : SV_Position;
// };
//
// #line 18 "main.glsl"
// void vert_main()
// {
// #line 18 "main.glsl"
// gl_Position = mul(pos, _21_mvp);
// #line 19 "main.glsl"
// color = color0;
// #line 20 "main.glsl"
// uv = texcoord0 * 5.0f;
// }
//
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
// {
// pos = stage_input.pos;
// color0 = stage_input.color0;
// texcoord0 = stage_input.texcoord0;
// vert_main();
// SPIRV_Cross_Output stage_output;
// stage_output.gl_Position = gl_Position;
// stage_output.color = color;
// stage_output.uv = uv;
// return stage_output;
// }
//
const vs_source_hlsl4 = [1003]u8 {
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,
0x70,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,
0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,
0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,
0x4f,0x52,0x44,0x32,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,
0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,
0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x6f,
0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,
0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x70,0x6f,0x73,0x2c,
0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,
0x20,0x31,0x39,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x6d,0x61,
0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,
0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x2a,0x20,0x35,0x2e,
0x30,0x66,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x69,0x6e,0x70,0x75,0x74,0x2e,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
0x75,0x74,0x70,0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
};
//
// cbuffer fs_params : register(b0)
// {
// float4 _23_globalcolor : packoffset(c0);
// float4 _23_cropping : packoffset(c1);
// };
//
// Texture2D<float4> tex : register(t0);
// SamplerState _tex_sampler : register(s0);
//
// static float4 frag_color;
// static float2 uv;
// static float4 color;
//
// struct SPIRV_Cross_Input
// {
// float4 color : TEXCOORD0;
// float2 uv : TEXCOORD1;
// };
//
// struct SPIRV_Cross_Output
// {
// float4 frag_color : SV_Target0;
// };
//
// #line 18 "main.glsl"
// void frag_main()
// {
// #line 18 "main.glsl"
// frag_color = tex.Sample(_tex_sampler, (uv * _23_cropping.xy) + _23_cropping.zw) * _23_globalcolor;
// }
//
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
// {
// uv = stage_input.uv;
// color = stage_input.color;
// frag_main();
// SPIRV_Cross_Output stage_output;
// stage_output.frag_color = frag_color;
// return stage_output;
// }
//
const fs_source_hlsl4 = [833]u8 {
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,
0x33,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,
0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x32,0x33,0x5f,0x63,
0x72,0x6f,0x70,0x70,0x69,0x6e,0x67,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,
0x66,0x73,0x65,0x74,0x28,0x63,0x31,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x54,0x65,
0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x3e,0x20,
0x74,0x65,0x78,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x74,
0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61,0x74,0x65,
0x20,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x3a,0x20,
0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a,0x0a,0x73,
0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,
0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,
0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,
0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,0x56,0x5f,
0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,
0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,
0x22,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x6d,
0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x53,
0x61,0x6d,0x70,0x6c,0x65,0x28,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,
0x65,0x72,0x2c,0x20,0x28,0x75,0x76,0x20,0x2a,0x20,0x5f,0x32,0x33,0x5f,0x63,0x72,
0x6f,0x70,0x70,0x69,0x6e,0x67,0x2e,0x78,0x79,0x29,0x20,0x2b,0x20,0x5f,0x32,0x33,
0x5f,0x63,0x72,0x6f,0x70,0x70,0x69,0x6e,0x67,0x2e,0x7a,0x77,0x29,0x20,0x2a,0x20,
0x5f,0x32,0x33,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,
0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,
0x74,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,
0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
0x00,
};
//
// #include <metal_stdlib>
// #include <simd/simd.h>
//
// using namespace metal;
//
// struct vs_params
// {
// float4x4 mvp;
// };
//
// struct main0_out
// {
// float4 color [[user(locn0)]];
// float2 uv [[user(locn1)]];
// float4 gl_Position [[position]];
// };
//
// struct main0_in
// {
// float4 pos [[attribute(0)]];
// float4 color0 [[attribute(1)]];
// float2 texcoord0 [[attribute(2)]];
// };
//
// #line 18 "main.glsl"
// vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _21 [[buffer(0)]])
// {
// main0_out out = {};
// #line 18 "main.glsl"
// out.gl_Position = _21.mvp * in.pos;
// #line 19 "main.glsl"
// out.color = in.color0;
// #line 20 "main.glsl"
// out.uv = in.texcoord0 * 5.0;
// return out;
// }
//
//
const vs_source_metal_macos = [686]u8 {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x20,0x5b,
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,
0x69,0x62,0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,
0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,
0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,
0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,
0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,
0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,
0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
0x3d,0x20,0x5f,0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x70,
0x6f,0x73,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x39,0x20,0x22,0x6d,0x61,
0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
0x72,0x30,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x6d,0x61,
0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
0x64,0x30,0x20,0x2a,0x20,0x35,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,
0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
//
// #include <metal_stdlib>
// #include <simd/simd.h>
//
// using namespace metal;
//
// struct fs_params
// {
// float4 globalcolor;
// float4 cropping;
// };
//
// struct main0_out
// {
// float4 frag_color [[color(0)]];
// };
//
// struct main0_in
// {
// float2 uv [[user(locn1)]];
// };
//
// #line 18 "main.glsl"
// fragment main0_out main0(main0_in in [[stage_in]], constant fs_params& _23 [[buffer(0)]], texture2d<float> tex [[texture(0)]], sampler texSmplr [[sampler(0)]])
// {
// main0_out out = {};
// #line 18 "main.glsl"
// out.frag_color = tex.sample(texSmplr, ((in.uv * _23.cropping.xy) + _23.cropping.zw)) * _23.globalcolor;
// return out;
// }
//
//
const fs_source_metal_macos = [608]u8 {
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x66,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x63,0x6f,0x6c,0x6f,
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x72,
0x6f,0x70,0x70,0x69,0x6e,0x67,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,
0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,
0x63,0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,
0x65,0x20,0x31,0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,
0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x66,0x73,0x5f,
0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x33,0x20,0x5b,0x5b,0x62,0x75,
0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,
0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,0x78,0x20,
0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,
0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,
0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,
0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,
0x20,0x31,0x38,0x20,0x22,0x6d,0x61,0x69,0x6e,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x28,0x28,0x69,0x6e,0x2e,0x75,
0x76,0x20,0x2a,0x20,0x5f,0x32,0x33,0x2e,0x63,0x72,0x6f,0x70,0x70,0x69,0x6e,0x67,
0x2e,0x78,0x79,0x29,0x20,0x2b,0x20,0x5f,0x32,0x33,0x2e,0x63,0x72,0x6f,0x70,0x70,
0x69,0x6e,0x67,0x2e,0x7a,0x77,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x33,0x2e,0x67,
0x6c,0x6f,0x62,0x61,0x6c,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
};
pub fn mainShaderDesc(backend: sg.Backend) sg.ShaderDesc {
var desc: sg.ShaderDesc = .{};
switch (backend) {
.GLCORE33 => {
desc.attrs[0].name = "pos";
desc.attrs[1].name = "color0";
desc.attrs[2].name = "texcoord0";
desc.vs.source = &vs_source_glsl330;
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
desc.vs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
desc.fs.source = &fs_source_glsl330;
desc.fs.entry = "main";
desc.fs.uniform_blocks[0].size = 32;
desc.fs.uniform_blocks[0].uniforms[0].name = "fs_params";
desc.fs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
desc.fs.uniform_blocks[0].uniforms[0].array_count = 2;
desc.fs.images[0].name = "tex";
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "main_shader";
},
.GLES2 => {
desc.attrs[0].name = "pos";
desc.attrs[1].name = "color0";
desc.attrs[2].name = "texcoord0";
desc.vs.source = &vs_source_glsl100;
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
desc.vs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
desc.fs.source = &fs_source_glsl100;
desc.fs.entry = "main";
desc.fs.uniform_blocks[0].size = 32;
desc.fs.uniform_blocks[0].uniforms[0].name = "fs_params";
desc.fs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
desc.fs.uniform_blocks[0].uniforms[0].array_count = 2;
desc.fs.images[0].name = "tex";
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "main_shader";
},
.D3D11 => {
desc.attrs[0].sem_name = "TEXCOORD";
desc.attrs[0].sem_index = 0;
desc.attrs[1].sem_name = "TEXCOORD";
desc.attrs[1].sem_index = 1;
desc.attrs[2].sem_name = "TEXCOORD";
desc.attrs[2].sem_index = 2;
desc.vs.source = &vs_source_hlsl4;
desc.vs.d3d11_target = "vs_4_0";
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.fs.source = &fs_source_hlsl4;
desc.fs.d3d11_target = "ps_4_0";
desc.fs.entry = "main";
desc.fs.uniform_blocks[0].size = 32;
desc.fs.images[0].name = "tex";
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "main_shader";
},
.METAL_MACOS => {
desc.vs.source = &vs_source_metal_macos;
desc.vs.entry = "main0";
desc.vs.uniform_blocks[0].size = 64;
desc.fs.source = &fs_source_metal_macos;
desc.fs.entry = "main0";
desc.fs.uniform_blocks[0].size = 32;
desc.fs.images[0].name = "tex";
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sampler_type = .FLOAT;
desc.label = "main_shader";
},
else => {},
}
return desc;
} | src/shaders/main.zig |
const std = @import("std");
const imr = @import("imr.zig");
const Allocator = std.mem.Allocator;
const eqlIgnoreCase = std.ascii.eqlIgnoreCase;
const Url = @import("../url.zig").Url;
const LineType = enum {
text,
link,
heading
};
const ParserState = union(enum) {
Text,
Link,
Preformatting,
/// usize = heading level
Heading: usize
};
fn getLineEnd(text: []const u8, pos: usize) usize {
const newPos = std.mem.indexOfScalarPos(u8, text, pos, '\r') orelse (std.mem.indexOfScalarPos(u8, text, pos, '\n') orelse text.len);
if (newPos == text.len or text[newPos] == '\r') {
return newPos;
} else if (text[newPos] == '\n') {
return if (newPos >= 1 and text[newPos-1] == '\r') newPos-1 else newPos;
} else {
unreachable;
}
}
fn getNextLine(text: []const u8, pos: usize) usize {
const newPos = std.mem.indexOfScalarPos(u8, text, pos, '\r') orelse (std.mem.indexOfScalarPos(u8, text, pos, '\n') orelse text.len);
if (newPos == text.len) {
return newPos;
} else if (text[newPos] == '\n') {
return newPos+1;
} else if (text[newPos] == '\r') {
return newPos+2;
} else {
unreachable;
}
}
/// Parses `text` into a document.
/// Note that this method returns tags that depend on slices created from text.
/// This means you cannot free text unless done with document.
/// Memory is caller owned.
pub fn parse(allocator: *Allocator, root: Url, text: []const u8) !imr.Document {
var document = imr.Document {
.tags = imr.TagList.init(allocator)
};
errdefer document.deinit();
var pos: usize = 0;
var state = ParserState { .Text = {} };
while (pos < text.len) {
switch (state) {
.Text => {
if (pos < text.len-3 and std.mem.eql(u8, text[pos..pos+2], "=>")) {
pos += 2;
state = .Link;
} else if (pos < text.len-4 and std.mem.eql(u8, text[pos..pos+3], "```")) {
pos = getNextLine(text, pos);
state = .Preformatting;
} else if (pos < text.len-2 and text[pos] == '#') {
state = .{ .Heading = 0 };
} else {
const end = getLineEnd(text, pos);
const tag = imr.Tag {
.allocator = allocator,
.elementType = "text",
.data = .{
.text = try allocator.dupeZ(u8, text[pos..end])
},
.style = .{
.margin = .{
.x = .{ .Pixels = 40 }
}
}
};
try document.tags.append(tag);
pos = getNextLine(text, pos);
}
},
.Link => {
const end = getLineEnd(text, pos);
while (text[pos] == ' ' or text[pos] == '\t') { pos += 1; }
var urlEnd: usize = pos;
while (text[urlEnd] != ' ' and text[urlEnd] != '\t' and text[urlEnd] != '\r' and text[urlEnd] != '\n') { urlEnd += 1; }
var nameStart: usize = urlEnd;
while ((text[nameStart] == ' ' or text[nameStart] == '\t') and nameStart < text.len-1) { nameStart += 1; }
const url = text[pos..urlEnd];
const href = root.combine(allocator, url) catch |err| blk: {
switch (err) {
error.TooLong => {
std.log.warn("URL too long: {s}", .{url});
break :blk root.dupe(allocator) catch |e| return e;
},
error.EmptyString => {
break :blk root.dupe(allocator) catch |e| return e;
},
else => return err
}
};
const name = if (urlEnd == end) text[pos..end] else text[nameStart..end];
const tag = imr.Tag {
.allocator = allocator,
.href = href,
.elementType = "link",
.style = .{
.textColor = .{.red = 0x00, .green = 0x00, .blue = 0xFF},
.margin = .{
.x = .{ .Pixels = 40 }
}
},
.data = .{
.text = try allocator.dupeZ(u8, name)
}
};
try document.tags.append(tag);
pos = getNextLine(text, pos);
state = .Text;
},
.Heading => |level| {
if (text[pos] == '#') {
pos += 1;
state = .{ .Heading = level+1 };
} else {
const end = getLineEnd(text, pos);
while (text[pos] == ' ' or text[pos] == '\t') { pos += 1; }
const tag = imr.Tag {
.allocator = allocator,
.elementType = "h",
.style = .{
.fontSize = 42.0 * (1 - @log10(@intToFloat(f32, level+1))),
.lineHeight = 1.0,
.margin = .{
.x = .{ .Pixels = 10*@intToFloat(f64, level) }
}
},
.data = .{
.text = try allocator.dupeZ(u8, text[pos..end])
}
};
try document.tags.append(tag);
pos = getNextLine(text, pos);
state = .Text;
}
},
.Preformatting => {
const end = std.mem.indexOfPos(u8, text, pos, "```") orelse text.len;
const tag = imr.Tag {
.allocator = allocator,
.elementType = "pre",
.style = .{
.fontFace = "monospace",
.fontSize = 10
},
.data = .{
.text = try allocator.dupeZ(u8, text[pos..end])
}
};
try document.tags.append(tag);
pos = getNextLine(text, end);
state = .Text;
}
}
}
return document;
} | zervo/markups/gemini.zig |
const std = @import("std");
const builtin = @import("builtin");
const testing = std.testing;
const x86 = @import("machine.zig");
const Instruction = x86.Instruction;
const AsmError = x86.AsmError;
const Machine = x86.Machine;
const Operand = x86.Operand;
const Mnemonic = x86.Mnemonic;
const EncodingControl = x86.EncodingControl;
pub const debug: bool = true;
var hide_debug: bool = true;
pub fn rexValue(w: u1, r: u1, x: u1, b: u1) u8 {
// 0b0100_WRXB
return (
(0b0100 << 4)
| (@as(u8, w) << 3)
| (@as(u8, r) << 2)
| (@as(u8, x) << 1)
| (@as(u8, b) << 0)
);
}
pub fn modrmValue(mod: u2, reg: u3, rm: u3) u8 {
// mm_rrr_rrr
return (
(@as(u8, mod) << 6)
| (@as(u8, reg) << 3)
| (@as(u8, rm) << 0)
);
}
pub fn sibValue(scale: u2, index: u3, base: u3) u8 {
return (
(@as(u8, scale) << 6)
| (@as(u8, index) << 3)
| (@as(u8, base) << 0)
);
}
pub fn warnDummy(a: var, b: var) void {}
/// Returns true if bytes matches the given hex string. ie:
/// matchesHexString(&[3]u8{0xaa, 0xbb, 0xcc}, "aa bb cc") -> true
pub fn matchesHexString(bytes: []const u8, str: []const u8) bool {
var lo: ?u8 = null;
var hi: ?u8 = null;
var pos: usize = 0;
for (str) |c| {
if (c == ' ') {
continue;
}
if (hi == null) {
hi = std.fmt.charToDigit(c, 16) catch unreachable;
} else {
lo = std.fmt.charToDigit(c, 16) catch unreachable;
const cur_byte = (hi.? << 4) | (lo.? << 0);
// bytes string is too short to be a match
if (pos >= bytes.len) {
return false;
}
if (bytes[pos] != cur_byte) {
return false;
}
pos += 1;
hi = null;
lo = null;
}
}
if (pos != bytes.len) {
// not enough bytes in bytes[] array
return false;
}
if (hi != null and lo == null) {
std.debug.panic("invalid hex string: must have even number of hex digits", .{});
}
return true;
}
pub fn isMatchingMemory(instr: AsmError!Instruction, hex_str: []const u8) bool {
if (instr) |temp| {
return matchesHexString(temp.asSlice(), hex_str);
} else |err| {
return false;
}
}
pub fn debugPrint(on: bool) void {
if (on) {
// automatically added newline to work around the test runners formating
std.debug.warn("\n", .{});
}
hide_debug = !on;
}
pub fn printOp(
hide_message: bool,
machine: Machine,
ctrl: ?*const EncodingControl,
mnem: Mnemonic,
instr: AsmError!Instruction,
op1: ?*const Operand,
op2: ?*const Operand,
op3: ?*const Operand,
op4: ?*const Operand,
op5: ?*const Operand,
) void {
if (hide_message) {
return;
}
switch (machine.mode) {
.x86_16 => std.debug.warn("x86-16: ", .{}),
.x86_32 => std.debug.warn("x86-32: ", .{}),
.x64 => std.debug.warn("x86-64: ", .{}),
}
if (ctrl) |c| {
for (c.prefixes) |pre| {
if (pre == .None) {
break;
}
std.debug.warn("{} ", .{@tagName(pre)});
}
}
std.debug.warn("{} ", .{@tagName(mnem)});
if (op1) |op| {
std.debug.warn("{}", .{op1});
}
if (op2) |op| {
std.debug.warn(", {}", .{op2});
}
if (op3) |op| {
std.debug.warn(", {}", .{op3});
}
if (op4) |op| {
std.debug.warn(", {}", .{op4});
}
if (op5) |op| {
std.debug.warn(", {}", .{op5});
}
if (instr) |temp| {
std.debug.warn(": {x}\n", .{temp.asSlice()});
} else |err| {
std.debug.warn(": {}\n", .{err});
}
}
pub fn testOp(
machine: Machine,
ctrl: ?*const EncodingControl,
mnem: Mnemonic,
op1: ?*const Operand,
op2: ?*const Operand,
op3: ?*const Operand,
op4: ?*const Operand,
op5: ?*const Operand,
comptime thing_to_match: var,
) void {
switch (@TypeOf(thing_to_match)) {
AsmError => {
testOpError(machine, ctrl, mnem, op1, op2, op3, op4, op5, thing_to_match);
},
else => {
testOpInstruction(machine, ctrl, mnem, op1, op2, op3, op4, op5, thing_to_match);
},
}
}
pub fn testOpInstruction(
machine: Machine,
ctrl: ?*const EncodingControl,
mnem: Mnemonic,
op1: ?*const Operand,
op2: ?*const Operand,
op3: ?*const Operand,
op4: ?*const Operand,
op5: ?*const Operand,
hex_str: []const u8
) void {
const instr = machine.build(ctrl, mnem, op1, op2, op3, op4, op5);
printOp(hide_debug, machine, ctrl, mnem, instr, op1, op2, op3, op4, op5);
if (!isMatchingMemory(instr, hex_str)) {
// strip any spaces from the string to unify formating
var expected_hex: [128]u8 = undefined;
var pos: usize = 0;
for (hex_str) |c| {
if (c != ' ') {
expected_hex[pos] = c;
pos += 1;
}
}
std.debug.warn("Test failed:\n", .{});
std.debug.warn("Expeced: {}\n", .{expected_hex[0..pos]});
if (instr) |ins| {
std.debug.warn("But got: {x}\n", .{ins.asSlice()});
} else |err| {
std.debug.warn("But got: {}\n", .{err});
}
printOp(false, machine, ctrl, mnem, instr, op1, op2, op3, op4, op5);
std.debug.warn("\n", .{});
testing.expect(false);
}
}
pub fn testOpError(
machine: Machine,
ctrl: ?*const EncodingControl,
mnem: Mnemonic,
op1: ?*const Operand,
op2: ?*const Operand,
op3: ?*const Operand,
op4: ?*const Operand,
op5: ?*const Operand,
comptime err: AsmError,
) void {
const instr = machine.build(ctrl, mnem, op1, op2, op3, op4, op5);
printOp(hide_debug, machine, ctrl, mnem, instr, op1, op2, op3, op4, op5);
if (!isErrorMatch(instr, err)) {
std.debug.warn("Test failed:\n", .{});
std.debug.warn("Expeced error: {}\n", .{err});
if (instr) |ins| {
std.debug.warn("But got instr: {x}\n", .{ins.asSlice()});
} else |actual_error| {
std.debug.warn("But got error: {}\n", .{actual_error});
}
printOp(false, machine, ctrl, mnem, instr, op1, op2, op3, op4, op5);
std.debug.warn("\n", .{});
testing.expect(false);
}
}
pub fn isErrorMatch(instr: AsmError!Instruction, err: AsmError) bool {
if (instr) |temp| {
return false;
} else |actual_error| {
return actual_error == err;
}
}
pub fn testOp0(machine: Machine, mnem: Mnemonic, comptime expected: var) void {
testOp(machine, null, mnem, null, null, null, null, null, expected);
}
pub fn testOp1(machine: Machine, mnem: Mnemonic, op1: Operand, comptime expected: var) void {
testOp(machine, null, mnem, &op1, null, null, null, null, expected);
}
pub fn testOp2(machine: Machine, mnem: Mnemonic, op1: Operand, op2: Operand, comptime expected: var) void {
testOp(machine, null, mnem, &op1, &op2, null, null, null, expected);
}
pub fn testOp3(machine: Machine, mnem: Mnemonic, op1: Operand, op2: Operand, op3: Operand, comptime expected: var) void {
testOp(machine, null, mnem, &op1, &op2, &op3, null, null, expected);
}
pub fn testOp4(
machine: Machine,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
op3: Operand,
op4: Operand,
comptime expected: var
) void {
testOp(machine, null, mnem, &op1, &op2, &op3, &op4, null, expected);
}
pub fn testOp5(
machine: Machine,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
op3: Operand,
op4: Operand,
op5: Operand,
comptime expected: var
) void {
testOp(machine, null, mnem, &op1, &op2, &op3, &op4, &op5, expected);
}
pub fn testOpCtrl0(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, null, null, null, null, null, expected);
}
pub fn testOpCtrl1(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
op1: Operand,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, &op1, null, null, null, null, expected);
}
pub fn testOpCtrl2(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, &op1, &op2, null, null, null, expected);
}
pub fn testOpCtrl3(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
op3: Operand,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, &op1, &op2, &op3, null, null, expected);
}
pub fn testOpCtrl4(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
op3: Operand,
op4: Operand,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, &op1, &op2, &op3, &op4, null, expected);
}
pub fn testOpCtrl5(
machine: Machine,
ctrl: EncodingControl,
mnem: Mnemonic,
op1: Operand,
op2: Operand,
op3: Operand,
op4: Operand,
op5: Operand,
comptime expected: var
) void {
testOp(machine, &ctrl, mnem, &op1, &op2, &op3, &op4, &op5, expected);
} | src/x86/util.zig |
const std = @import("std");
pub fn pkg(b: *std.build.Builder, pkg_name: []const u8, dir: []const u8) std.build.Pkg {
const step = ClassGenStep.init(b, pkg_name, dir);
// Create main pkg
var main_pkg = std.build.Pkg{
.name = pkg_name,
.path = .{ .generated = &step.out_file },
};
// Create internal pkg
const internal_main = std.fs.path.join(b.allocator, &.{ dir, "main.zig" }) catch unreachable;
const internal_pkg = std.build.Pkg{
.name = "classgen_internal",
.path = .{ .path = internal_main },
.dependencies = b.allocator.dupe(std.build.Pkg, &.{main_pkg}) catch unreachable,
};
// Add internal pkg as main pkg dep
main_pkg.dependencies = b.allocator.dupe(std.build.Pkg, &.{internal_pkg}) catch unreachable;
return main_pkg;
}
const ClassGenStep = struct {
b: *std.build.Builder,
step: std.build.Step,
dir: []const u8,
out_file: std.build.GeneratedFile,
pub fn init(b: *std.build.Builder, pkg_name: []const u8, dir: []const u8) *ClassGenStep {
const self = b.allocator.create(ClassGenStep) catch unreachable;
const out_path = b.fmt("{s}/{s}.zig", .{ b.cache_root, pkg_name });
self.* = .{
.b = b,
.step = std.build.Step.init(.custom, b.fmt("ClassGen {s}", .{dir}), b.allocator, make),
.dir = dir,
.out_file = .{ .step = &self.step, .path = out_path },
};
return self;
}
pub fn make(step: *std.build.Step) !void {
const self = @fieldParentPtr(ClassGenStep, "step", step);
var gen = try ClassGenerator.init(self.b.allocator);
const dir = try std.fs.cwd().openDir(self.dir, .{ .iterate = true });
var it = dir.iterate();
while (try it.next()) |entry| {
if (entry.kind != .File) continue;
if (std.mem.startsWith(u8, entry.name, ".")) continue;
if (std.mem.endsWith(u8, entry.name, ".zig")) {
try gen.zigImport("classgen_internal");
} else {
gen.classFromFilename(dir, entry.name) catch |err| switch (err) {
error.InvalidFormat => std.os.exit(1),
else => |e| return e,
};
}
}
const code = try gen.finish();
const f = try std.fs.cwd().createFile(self.out_file.path.?, .{});
defer f.close();
try f.writeAll(code);
}
};
const ClassGenerator = struct {
allocator: std.mem.Allocator,
buf: std.ArrayList(u8),
pub fn init(arena_allocator: std.mem.Allocator) !ClassGenerator {
var self = ClassGenerator{
.allocator = arena_allocator,
.buf = std.ArrayList(u8).init(arena_allocator),
};
errdefer self.deinit();
try self.write(
\\const std = @import("std");
\\const sdk = @This();
);
try self.sep();
return self;
}
pub fn deinit(self: ClassGenerator) void {
self.buf.deinit();
}
/// Return the generated source code as an owned slice.
/// The ClassGenerator is reset and can be reused.
pub fn finish(self: *ClassGenerator) ![]u8 {
const source = try self.buf.toOwnedSliceSentinel(0);
var tree = try std.zig.parse(self.allocator, source);
defer tree.deinit(self.allocator);
if (tree.errors.len != 0) {
for (tree.errors) |err| {
tree.renderError(err, std.io.getStdErr().writer()) catch unreachable;
std.debug.print("\n", .{});
}
unreachable;
}
return tree.render(self.allocator);
}
pub fn zigImport(self: *ClassGenerator, filename: []const u8) !void {
try self.print("pub usingnamespace @import(\"{}\");\n", .{std.zig.fmtEscapes(filename)});
}
pub fn classFromFilename(self: *ClassGenerator, dir: std.fs.Dir, filename: []const u8) !void {
const f = try dir.openFile(filename, .{});
defer f.close();
const class_name = std.fs.path.basename(filename);
var cls = self.class(class_name);
var line_no: u32 = 0;
while (try f.reader().readUntilDelimiterOrEofAlloc(self.allocator, '\n', 1 << 20)) |line| {
line_no += 1;
var toks = std.mem.split(u8, line, "\t");
const zig_name = toks.next() orelse continue;
if (zig_name.len == 0) continue;
if (zig_name[0] == '#') continue;
const dispatch_group = toks.next() orelse {
std.debug.print("Missing dispatch group at {s}:{}\n", .{ filename, line_no });
return error.InvalidFormat;
};
const signature_s = toks.next() orelse {
std.debug.print("Missing method signature at {s}:{}\n", .{ filename, line_no });
return error.InvalidFormat;
};
if (toks.next() != null) {
std.debug.print("Unexpected extra fields at {s}:{}\n", .{ filename, line_no });
return error.InvalidFormat;
}
const signature_z = try self.allocator.dupeZ(u8, signature_s);
const signature = (try TypeDesc.parse(self.allocator, signature_z)) orelse {
std.debug.print("Invalid signature type at {s}:{}\n", .{ filename, line_no });
return error.InvalidFormat;
};
if (signature != .func) {
std.debug.print("Invalid signature type at {s}:{}\n", .{ filename, line_no });
return error.InvalidFormat;
}
try cls.vmethod(.{
.zig_name = zig_name,
.dispatch_group = dispatch_group,
.signature = signature.func,
});
}
try cls.finish();
}
fn print(self: *ClassGenerator, comptime fmt: []const u8, args: anytype) !void {
try self.buf.writer().print(fmt, args);
}
fn write(self: *ClassGenerator, str: []const u8) !void {
try self.buf.writer().writeAll(str);
}
pub fn class(self: *ClassGenerator, class_name: []const u8) Class {
return Class{ .gen = self, .name = class_name };
}
pub const Class = struct {
gen: *ClassGenerator,
name: []const u8,
vmethods: std.ArrayListUnmanaged(Method) = .{},
pub fn finish(self: Class) !void {
try self.gen.print("pub const {} = extern struct {{\n", .{std.zig.fmtId(self.name)});
try self.gen.vtable(self.name, self.vmethods.items);
try self.gen.sep();
for (self.vmethods.items) |m| {
try self.gen.wrapper(m.zig_name, self.name, m.signature);
}
try self.gen.write("};");
try self.gen.sep();
}
pub fn vmethod(self: *Class, m: Method) !void {
try self.vmethods.append(self.gen.allocator, m);
}
};
pub const Method = struct {
zig_name: []const u8,
dispatch_group: []const u8,
signature: TypeDesc.Fn,
};
fn vtable(self: *ClassGenerator, class_name: []const u8, methods: []const Method) !void {
try self.write("vtable: *const Vtable,");
try self.sep();
try self.write(
\\pub const Vtable = switch (@import("builtin").os.tag) {
\\ .windows => extern struct {
\\
);
// Generate msvc vtable
var groups = std.StringArrayHashMap(std.ArrayListUnmanaged(Method)).init(self.allocator);
for (methods) |m| {
const res = try groups.getOrPutValue(m.dispatch_group, .{});
try res.value_ptr.append(self.allocator, m);
}
for (groups.values()) |group| {
var i = group.items.len;
while (i > 0) {
i -= 1;
var m = group.items[i];
if (std.mem.eql(u8, m.zig_name, "~")) {
m.signature.args = &.{.{ .named = "u16" }};
}
try self.vmethod(m.zig_name, class_name, m.signature, if (m.signature.variadic) .C else .Thiscall);
}
}
try self.write(
\\ },
\\ else => extern struct {
\\
);
// Generate gcc vtable
for (methods) |m| {
if (std.mem.eql(u8, m.zig_name, "~")) {
try self.vmethod("~DUMMY", class_name, .{
.args = &.{},
.return_type = &.{ .named = "void" },
.variadic = false,
}, .C);
}
try self.vmethod(m.zig_name, class_name, m.signature, .C);
}
try self.write(
\\ },
\\};
);
}
fn vmethod(
self: *ClassGenerator,
name: []const u8,
class_name: []const u8,
sig: TypeDesc.Fn,
call_conv: std.builtin.CallingConvention,
) !void {
try self.print("{}: fn (*{}", .{ std.zig.fmtId(name), std.zig.fmtId(class_name) });
for (sig.args) |arg| {
try self.print(", {}", .{arg});
}
if (sig.variadic) {
try self.write(", ...");
}
try self.print(") callconv(.{}) {},\n", .{ std.zig.fmtId(@tagName(call_conv)), sig.return_type });
}
fn wrapper(self: *ClassGenerator, name: []const u8, class_name: []const u8, sig: TypeDesc.Fn) !void {
try self.print("pub inline fn {}(self: *{}", .{ std.zig.fmtId(name), std.zig.fmtId(class_name) });
for (sig.args) |arg, i| {
try self.print(", arg{}: {}", .{ i, arg });
}
if (sig.variadic) {
try self.write(", rest: anytype");
}
try self.print(") {} {{\n", .{sig.return_type});
if (std.mem.eql(u8, name, "~")) {
try self.write(
\\return switch (std.builtin.os.tag) {
\\ .windows => self.vtable.@"~"(self, 0),
\\ else => self.vtable.@"~"(self),
\\};
);
} else if (sig.variadic) {
try self.print("return @call(.{{}}, self.vtable.{}, .{{self", .{std.zig.fmtId(name)});
for (sig.args) |_, i| {
try self.print(", arg{}", .{i});
}
try self.write("} ++ rest);");
} else {
try self.print("return self.vtable.{}(self", .{std.zig.fmtId(name)});
for (sig.args) |_, i| {
try self.print(", arg{}", .{i});
}
try self.write(");");
}
try self.write("}\n");
}
fn sep(self: *ClassGenerator) !void {
try self.write("\n\n");
}
};
// Has no deinit function because we use an arena for everything
const TypeDesc = union(enum) {
named: []const u8,
ptr: Pointer,
array: Array,
func: Fn,
optional: *const TypeDesc,
pub const Pointer = struct {
size: Size,
is_const: bool,
child: *const TypeDesc,
sentinel: ?[]const u8,
pub const Size = enum {
one,
many,
};
};
pub const Array = struct {
len: usize,
child: *const TypeDesc,
sentinel: ?[]const u8,
};
pub const Fn = struct {
args: []const TypeDesc,
return_type: *const TypeDesc,
variadic: bool,
};
pub fn format(value: TypeDesc, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
switch (value) {
.named => |name| try writer.writeAll(name),
.ptr => |ptr| {
switch (ptr.size) {
.one => try writer.writeAll("*"),
.many => {
try writer.writeAll("[*");
if (ptr.sentinel) |sentinel| {
try writer.print(":{s}", .{sentinel});
}
try writer.writeAll("]");
},
}
const const_s = if (ptr.is_const) "const " else "";
try writer.print("{s}{}", .{ const_s, ptr.child.* });
},
.array => |ary| {
try writer.print("[{}", .{ary.len});
if (ary.sentinel) |sentinel| {
try writer.print(":{s}", .{sentinel});
}
try writer.print("]{}", .{ary.child.*});
},
.func => |func| {
try writer.writeAll("fn (");
for (func.args) |arg, i| {
if (i > 0) try writer.writeAll(", ");
try writer.print("{}", .{arg});
}
if (func.variadic) {
try writer.writeAll(", ...");
}
try writer.print(") callconv(.C) {}", .{func.return_type});
},
.optional => |child| {
try writer.print("?{}", .{child.*});
},
}
}
pub fn parse(allocator: std.mem.Allocator, str: [:0]const u8) !?TypeDesc {
var parser = Parser{
.allocator = allocator,
.toks = std.zig.Tokenizer.init(str),
};
return parser.parse() catch |err| switch (err) {
error.WrongToken => null,
else => |e| return e,
};
}
const Parser = struct {
allocator: std.mem.Allocator,
toks: std.zig.Tokenizer,
peeked: ?std.zig.Token = null,
peeked2: ?std.zig.Token = null,
fn nextTok(self: *Parser) std.zig.Token {
const t = self.peekTok();
self.peeked = self.peeked2;
self.peeked2 = null;
return t;
}
fn peekTok(self: *Parser) std.zig.Token {
if (self.peeked == null) {
self.peeked = self.toks.next();
}
return self.peeked.?;
}
fn peekTok2(self: *Parser) std.zig.Token {
_ = self.peekTok();
if (self.peeked2 == null) {
self.peeked2 = self.toks.next();
}
return self.peeked2.?;
}
fn parse(self: *Parser) !TypeDesc {
if (self.peekTok().tag == .identifier) return self.parseNamedType();
return switch (self.nextTok().tag) {
.asterisk => self.parsePointer(.one, null),
.l_bracket => self.parseArray(),
.keyword_fn => self.parseFn(),
.question_mark => self.parseOptional(),
else => error.WrongToken, // TODO: better errors
};
}
fn parseAlloc(self: *Parser) !*TypeDesc {
const desc = try self.allocator.create(TypeDesc);
desc.* = try self.parse();
return desc;
}
fn parseNamedType(self: *Parser) !TypeDesc {
var name = std.ArrayList(u8).init(self.allocator);
var tok = self.nextTok();
if (tok.tag != .identifier) return error.WrongToken;
try name.appendSlice(self.toks.buffer[tok.loc.start..tok.loc.end]);
while (self.peekTok().tag == .period) {
_ = self.nextTok();
tok = self.nextTok();
if (tok.tag != .identifier) return error.WrongToken;
try name.append('.');
try name.appendSlice(self.toks.buffer[tok.loc.start..tok.loc.end]);
}
return TypeDesc{ .named = name.toOwnedSlice() };
}
fn parsePointer(self: *Parser, size: Pointer.Size, sentinel: ?[]const u8) !TypeDesc {
var ptr = Pointer{
.size = size,
.is_const = false,
.child = undefined,
.sentinel = sentinel,
};
if (self.peekTok().tag == .keyword_const) {
_ = self.nextTok();
ptr.is_const = true;
}
ptr.child = try self.parseAlloc();
return TypeDesc{ .ptr = ptr };
}
fn parseArray(self: *Parser) !TypeDesc {
const tok = self.nextTok();
return switch (tok.tag) {
.integer_literal => blk: {
const len = std.fmt.parseUnsigned(
usize,
self.toks.buffer[tok.loc.start..tok.loc.end],
10,
) catch return error.WrongToken;
const sentinel = try self.parseSentinel();
break :blk TypeDesc{ .array = .{
.len = len,
.child = try self.parseAlloc(),
.sentinel = sentinel,
} };
},
.asterisk => self.parsePointer(.many, try self.parseSentinel()),
else => error.WrongToken,
};
}
fn parseSentinel(self: *Parser) !?[]const u8 {
var tok = self.nextTok();
if (tok.tag == .r_bracket) return null;
if (tok.tag != .colon) return error.WrongToken;
const start = tok.loc.end;
var end = start;
while (tok.tag != .r_bracket) : (tok = self.nextTok()) {
if (tok.tag == .eof) return error.WrongToken;
end = tok.loc.end;
}
if (start == end) {
return error.WrongToken;
} else {
return self.toks.buffer[start..end];
}
}
fn parseFn(self: *Parser) !TypeDesc {
if (self.nextTok().tag != .l_paren) return error.WrongToken;
var args = std.ArrayList(TypeDesc).init(self.allocator);
var variadic = false;
while (self.peekTok().tag != .r_paren) {
if (variadic) {
return error.WrongToken;
}
switch (self.peekTok().tag) {
.ellipsis3 => {
_ = self.nextTok();
variadic = true;
},
.identifier => {
// Might be a name or a type
if (self.peekTok2().tag == .colon) {
_ = self.nextTok();
_ = self.nextTok();
}
try args.append(try self.parse());
},
else => try args.append(try self.parse()),
}
switch (self.peekTok().tag) {
.comma => _ = self.nextTok(),
.r_paren => break,
else => return error.WrongToken,
}
}
_ = self.nextTok();
return TypeDesc{ .func = .{
.args = args.toOwnedSlice(),
.return_type = try self.parseAlloc(),
.variadic = variadic,
} };
}
fn parseOptional(self: *Parser) !TypeDesc {
const child = try self.parseAlloc();
return TypeDesc{ .optional = child };
}
};
}; | classgen.zig |
const std = @import("std");
const wren = @import("wren");
pub var alloc = std.testing.allocator;
// This will be a foreign class in Wren
pub const Point = struct {
size:f64 = 0,
pub fn setSize (vm:?*wren.VM) void {
// Get the Wren class handle which holds our Zig instance memory
if(wren.getSlotForeign(vm, 0)) |ptr| {
// Convert slot 0 memory back into the Zig class
var point = wren.foreign.castDataPtr(Point,ptr);
// Get the constructor argument
var nsize:f64 = wren.getSlotAuto(vm,f64,1);
std.debug.print(" [+] Setting point to: {d}\n",.{nsize});
// Error checking
if(nsize < 1.0) {
// Error handling, put error msg back in slot 0 and abort the fiber
wren.setSlotAuto(vm,0,"That is way too small!");
wren.abortFiber(vm, 0);
return;
}
// Otherwise set the value
point.*.size = nsize;
std.debug.print(" [+] Point is now: {d}\n",.{nsize});
}
}
};
// A pair of allocate and finalize functions to keep Wren and Zig in sync
// when using the Point class above.
// Allocate is called on Wren class creation and finalize on Wren destruction.
pub fn pointAllocate(vm:?*wren.VM) void {
std.debug.print(" [+] ALLOC Point\n",.{});
// Tell Wren how many bytes we need for the Zig class instance
var ptr:?*c_void = wren.setSlotNewForeign(vm, 0, 0, @sizeOf(Point));
// Get the parameter given to the class constructor in Wren
var size_param:f64 = wren.getSlotAuto(vm, f64, 1);
// Get a typed pointer to the Wren-allocated
var pt_ptr = wren.foreign.castDataPtr(Point, ptr);
// Create the Zig class instance into the Wren memory location,
// applying the passed value to keep them in sync
pt_ptr.* = Point { .size = size_param };
std.debug.print(" [+] ALLOC Point Done\n",.{});
}
pub fn pointFinalize(data:?*c_void) void {
_=data;
std.debug.print(" [+] Finalize Point\n",.{});
// Do whatever cleanup is needed here, deinits etc
}
pub fn main() anyerror!void {
// Initialize the data structures for the wrapper
wren.init(alloc);
defer wren.deinit();
// Set up a VM configuration using the supplied default bindings
// You can override the bindings after calling this to change them
var config = wren.util.defaultConfig();
// Create a new VM from our config we generated previously
const vm = wren.newVM(&config);
defer wren.freeVM(vm);
// Register our foreign class, defining the createion and destruction fns
try wren.foreign.registerClass(vm,"main","Point",pointAllocate,pointFinalize);
// Register our method, see example/foreign_method.zig
try wren.foreign.registerMethod(vm,"main","Point","setSize(_)",false,Point.setSize);
// Note that in this case, the class is defined as foreign like how
// we can define methods as foreign. When this class is instantiated
// in Wren, the VM calls the function we defined so that Zig can
// build it's copy of the data structure.
// When the VM destructs the class, the finalize fn is called so Zig
// can free memory, or whatever else needs to happen.
// We intentionally cause an error in the last setSize call.
wren.util.run(vm,"main",
\\ foreign class Point {
\\ construct create(size) {}
\\
\\ foreign setSize(size)
\\ }
\\ var point = Point.create(20)
\\ point.setSize(40)
\\ point.setSize(0)
) catch |err| {
std.debug.print("THIS IS FINE TOO - {s}\n",.{err});
};
} | example/foreign_class.zig |
const macro = @import("pspmacros.zig");
comptime {
asm (macro.import_module_start("ThreadManForUser", "0x40010000", "126"));
asm (macro.import_function("ThreadManForUser", "0x6E9EA350", "_sceKernelReturnFromCallback"));
asm (macro.import_function("ThreadManForUser", "0x0C106E53", "sceKernelRegisterThreadEventHandler_stub"));
asm (macro.import_function("ThreadManForUser", "0x72F3C145", "sceKernelReleaseThreadEventHandler"));
asm (macro.import_function("ThreadManForUser", "0x369EEB6B", "sceKernelReferThreadEventHandlerStatus"));
asm (macro.import_function("ThreadManForUser", "0xE81CAF8F", "sceKernelCreateCallback"));
asm (macro.import_function("ThreadManForUser", "0xEDBA5844", "sceKernelDeleteCallback"));
asm (macro.import_function("ThreadManForUser", "0xC11BA8C4", "sceKernelNotifyCallback"));
asm (macro.import_function("ThreadManForUser", "0xBA4051D6", "sceKernelCancelCallback"));
asm (macro.import_function("ThreadManForUser", "0x2A3D44FF", "sceKernelGetCallbackCount"));
asm (macro.import_function("ThreadManForUser", "0x349D6D6C", "sceKernelCheckCallback"));
asm (macro.import_function("ThreadManForUser", "0x730ED8BC", "sceKernelReferCallbackStatus"));
asm (macro.import_function("ThreadManForUser", "0x9ACE131E", "sceKernelSleepThread"));
asm (macro.import_function("ThreadManForUser", "0x82826F70", "sceKernelSleepThreadCB"));
asm (macro.import_function("ThreadManForUser", "0xD59EAD2F", "sceKernelWakeupThread"));
asm (macro.import_function("ThreadManForUser", "0xFCCFAD26", "sceKernelCancelWakeupThread"));
asm (macro.import_function("ThreadManForUser", "0x9944F31F", "sceKernelSuspendThread"));
asm (macro.import_function("ThreadManForUser", "0x75156E8F", "sceKernelResumeThread"));
asm (macro.import_function("ThreadManForUser", "0x278C0DF5", "sceKernelWaitThreadEnd"));
asm (macro.import_function("ThreadManForUser", "0x840E8133", "sceKernelWaitThreadEndCB"));
asm (macro.import_function("ThreadManForUser", "0xCEADEB47", "sceKernelDelayThread"));
asm (macro.import_function("ThreadManForUser", "0x68DA9E36", "sceKernelDelayThreadCB"));
asm (macro.import_function("ThreadManForUser", "0xBD123D9E", "sceKernelDelaySysClockThread"));
asm (macro.import_function("ThreadManForUser", "0x1181E963", "sceKernelDelaySysClockThreadCB"));
asm (macro.import_function("ThreadManForUser", "0xD6DA4BA1", "sceKernelCreateSema_stub"));
asm (macro.import_function("ThreadManForUser", "0x28B6489C", "sceKernelDeleteSema"));
asm (macro.import_function("ThreadManForUser", "0x3F53E640", "sceKernelSignalSema"));
asm (macro.import_function("ThreadManForUser", "0x4E3A1105", "sceKernelWaitSema"));
asm (macro.import_function("ThreadManForUser", "0x6D212BAC", "sceKernelWaitSemaCB"));
asm (macro.import_function("ThreadManForUser", "0x58B1F937", "sceKernelPollSema"));
asm (macro.import_function("ThreadManForUser", "0x8FFDF9A2", "sceKernelCancelSema"));
asm (macro.import_function("ThreadManForUser", "0xBC6FEBC5", "sceKernelReferSemaStatus"));
asm (macro.import_function("ThreadManForUser", "0x55C20A00", "sceKernelCreateEventFlag"));
asm (macro.import_function("ThreadManForUser", "0xEF9E4C70", "sceKernelDeleteEventFlag"));
asm (macro.import_function("ThreadManForUser", "0x1FB15A32", "sceKernelSetEventFlag"));
asm (macro.import_function("ThreadManForUser", "0x812346E4", "sceKernelClearEventFlag"));
asm (macro.import_function("ThreadManForUser", "0x402FCF22", "sceKernelWaitEventFlag_stub"));
asm (macro.import_function("ThreadManForUser", "0x328C546A", "sceKernelWaitEventFlagCB_stub"));
asm (macro.import_function("ThreadManForUser", "0x30FD48F0", "sceKernelPollEventFlag"));
asm (macro.import_function("ThreadManForUser", "0xCD203292", "sceKernelCancelEventFlag"));
asm (macro.import_function("ThreadManForUser", "0xA66B0120", "sceKernelReferEventFlagStatus"));
asm (macro.import_function("ThreadManForUser", "0x8125221D", "sceKernelCreateMbx"));
asm (macro.import_function("ThreadManForUser", "0x86255ADA", "sceKernelDeleteMbx"));
asm (macro.import_function("ThreadManForUser", "0xE9B3061E", "sceKernelSendMbx"));
asm (macro.import_function("ThreadManForUser", "0x18260574", "sceKernelReceiveMbx"));
asm (macro.import_function("ThreadManForUser", "0xF3986382", "sceKernelReceiveMbxCB"));
asm (macro.import_function("ThreadManForUser", "0x0D81716A", "sceKernelPollMbx"));
asm (macro.import_function("ThreadManForUser", "0x87D4DD36", "sceKernelCancelReceiveMbx"));
asm (macro.import_function("ThreadManForUser", "0xA8E8C846", "sceKernelReferMbxStatus"));
asm (macro.import_function("ThreadManForUser", "0x7C0DC2A0", "sceKernelCreateMsgPipe_stub"));
asm (macro.import_function("ThreadManForUser", "0xF0B7DA1C", "sceKernelDeleteMsgPipe"));
asm (macro.import_function("ThreadManForUser", "0x876DBFAD", "sceKernelSendMsgPipe_stub"));
asm (macro.import_function("ThreadManForUser", "0x7C41F2C2", "sceKernelSendMsgPipeCB_stub"));
asm (macro.import_function("ThreadManForUser", "0x884C9F90", "sceKernelTrySendMsgPipe"));
asm (macro.import_function("ThreadManForUser", "0x74829B76", "sceKernelReceiveMsgPipe_stub"));
asm (macro.import_function("ThreadManForUser", "0xFBFA697D", "sceKernelReceiveMsgPipeCB_stub"));
asm (macro.import_function("ThreadManForUser", "0xDF52098F", "sceKernelTryReceiveMsgPipe"));
asm (macro.import_function("ThreadManForUser", "0x349B864D", "sceKernelCancelMsgPipe"));
asm (macro.import_function("ThreadManForUser", "0x33BE4024", "sceKernelReferMsgPipeStatus"));
asm (macro.import_function("ThreadManForUser", "0x56C039B5", "sceKernelCreateVpl_stub"));
asm (macro.import_function("ThreadManForUser", "0x89B3D48C", "sceKernelDeleteVpl"));
asm (macro.import_function("ThreadManForUser", "0xBED27435", "sceKernelAllocateVpl"));
asm (macro.import_function("ThreadManForUser", "0xEC0A693F", "sceKernelAllocateVplCB"));
asm (macro.import_function("ThreadManForUser", "0xAF36D708", "sceKernelTryAllocateVpl"));
asm (macro.import_function("ThreadManForUser", "0xB736E9FF", "sceKernelFreeVpl"));
asm (macro.import_function("ThreadManForUser", "0x1D371B8A", "sceKernelCancelVpl"));
asm (macro.import_function("ThreadManForUser", "0x39810265", "sceKernelReferVplStatus"));
asm (macro.import_function("ThreadManForUser", "0xC07BB470", "sceKernelCreateFpl_stub"));
asm (macro.import_function("ThreadManForUser", "0xED1410E0", "sceKernelDeleteFpl"));
asm (macro.import_function("ThreadManForUser", "0xD979E9BF", "sceKernelAllocateFpl"));
asm (macro.import_function("ThreadManForUser", "0xE7282CB6", "sceKernelAllocateFplCB"));
asm (macro.import_function("ThreadManForUser", "0x623AE665", "sceKernelTryAllocateFpl"));
asm (macro.import_function("ThreadManForUser", "0xF6414A71", "sceKernelFreeFpl"));
asm (macro.import_function("ThreadManForUser", "0xA8AA591F", "sceKernelCancelFpl"));
asm (macro.import_function("ThreadManForUser", "0xD8199E4C", "sceKernelReferFplStatus"));
asm (macro.import_function("ThreadManForUser", "0x0E927AED", "_sceKernelReturnFromTimerHandler"));
asm (macro.import_function("ThreadManForUser", "0x110DEC9A", "sceKernelUSec2SysClock"));
asm (macro.import_function("ThreadManForUser", "0xC8CD158C", "sceKernelUSec2SysClockWide"));
asm (macro.import_function("ThreadManForUser", "0xBA6B92E2", "sceKernelSysClock2USec"));
asm (macro.import_function("ThreadManForUser", "0xE1619D7C", "sceKernelSysClock2USecWide"));
asm (macro.import_function("ThreadManForUser", "0xDB738F35", "sceKernelGetSystemTime"));
asm (macro.import_function("ThreadManForUser", "0x82BC5777", "sceKernelGetSystemTimeWide"));
asm (macro.import_function("ThreadManForUser", "0x369ED59D", "sceKernelGetSystemTimeLow"));
asm (macro.import_function("ThreadManForUser", "0x6652B8CA", "sceKernelSetAlarm"));
asm (macro.import_function("ThreadManForUser", "0xB2C25152", "sceKernelSetSysClockAlarm"));
asm (macro.import_function("ThreadManForUser", "0x7E65B999", "sceKernelCancelAlarm"));
asm (macro.import_function("ThreadManForUser", "0xDAA3F564", "sceKernelReferAlarmStatus"));
asm (macro.import_function("ThreadManForUser", "0x20FFF560", "sceKernelCreateVTimer"));
asm (macro.import_function("ThreadManForUser", "0x328F9E52", "sceKernelDeleteVTimer"));
asm (macro.import_function("ThreadManForUser", "0xB3A59970", "sceKernelGetVTimerBase"));
asm (macro.import_function("ThreadManForUser", "0xB7C18B77", "sceKernelGetVTimerBaseWide"));
asm (macro.import_function("ThreadManForUser", "0x034A921F", "sceKernelGetVTimerTime"));
asm (macro.import_function("ThreadManForUser", "0xC0B3FFD2", "sceKernelGetVTimerTimeWide"));
asm (macro.import_function("ThreadManForUser", "0x542AD630", "sceKernelSetVTimerTime"));
asm (macro.import_function("ThreadManForUser", "0xFB6425C3", "sceKernelSetVTimerTimeWide"));
asm (macro.import_function("ThreadManForUser", "0xC68D9437", "sceKernelStartVTimer"));
asm (macro.import_function("ThreadManForUser", "0xD0AEEE87", "sceKernelStopVTimer"));
asm (macro.import_function("ThreadManForUser", "0xD8B299AE", "sceKernelSetVTimerHandler"));
asm (macro.import_function("ThreadManForUser", "0x53B00E9A", "sceKernelSetVTimerHandlerWide"));
asm (macro.import_function("ThreadManForUser", "0xD2D615EF", "sceKernelCancelVTimerHandler"));
asm (macro.import_function("ThreadManForUser", "0x5F32BEAA", "sceKernelReferVTimerStatus"));
asm (macro.import_function("ThreadManForUser", "0x446D8DE6", "sceKernelCreateThread_stub"));
asm (macro.import_function("ThreadManForUser", "0x9FA03CD3", "sceKernelDeleteThread"));
asm (macro.import_function("ThreadManForUser", "0xF475845D", "sceKernelStartThread"));
asm (macro.import_function("ThreadManForUser", "0x532A522E", "_sceKernelExitThread"));
asm (macro.import_function("ThreadManForUser", "0xAA73C935", "sceKernelExitThread"));
asm (macro.import_function("ThreadManForUser", "0x809CE29B", "sceKernelExitDeleteThread"));
asm (macro.import_function("ThreadManForUser", "0x616403BA", "sceKernelTerminateThread"));
asm (macro.import_function("ThreadManForUser", "0x383F7BCC", "sceKernelTerminateDeleteThread"));
asm (macro.import_function("ThreadManForUser", "0x3AD58B8C", "sceKernelSuspendDispatchThread"));
asm (macro.import_function("ThreadManForUser", "0x27E22EC2", "sceKernelResumeDispatchThread"));
asm (macro.import_function("ThreadManForUser", "0xEA748E31", "sceKernelChangeCurrentThreadAttr"));
asm (macro.import_function("ThreadManForUser", "0x71BC9871", "sceKernelChangeThreadPriority"));
asm (macro.import_function("ThreadManForUser", "0x912354A7", "sceKernelRotateThreadReadyQueue"));
asm (macro.import_function("ThreadManForUser", "0x2C34E053", "sceKernelReleaseWaitThread"));
asm (macro.import_function("ThreadManForUser", "0x293B45B8", "sceKernelGetThreadId"));
asm (macro.import_function("ThreadManForUser", "0x94AA61EE", "sceKernelGetThreadCurrentPriority"));
asm (macro.import_function("ThreadManForUser", "0x3B183E26", "sceKernelGetThreadExitStatus"));
asm (macro.import_function("ThreadManForUser", "0xD13BDE95", "sceKernelCheckThreadStack"));
asm (macro.import_function("ThreadManForUser", "0x52089CA1", "sceKernelGetThreadStackFreeSize"));
asm (macro.import_function("ThreadManForUser", "0x17C1684E", "sceKernelReferThreadStatus"));
asm (macro.import_function("ThreadManForUser", "0xFFC36A14", "sceKernelReferThreadRunStatus"));
asm (macro.import_function("ThreadManForUser", "0x627E6F3A", "sceKernelReferSystemStatus"));
asm (macro.import_function("ThreadManForUser", "0x94416130", "sceKernelGetThreadmanIdList"));
asm (macro.import_function("ThreadManForUser", "0x57CF62DD", "sceKernelGetThreadmanIdType"));
asm (macro.import_function("ThreadManForUser", "0x64D4540E", "sceKernelReferThreadProfiler"));
asm (macro.import_function("ThreadManForUser", "0x8218B4DD", "sceKernelReferGlobalProfiler"));
asm (macro.generic_abi_wrapper("sceKernelCreateThread", 6));
asm (macro.generic_abi_wrapper("sceKernelCreateSema", 5));
asm (macro.generic_abi_wrapper("sceKernelWaitEventFlag", 5));
asm (macro.generic_abi_wrapper("sceKernelWaitEventFlagCB", 5));
asm (macro.generic_abi_wrapper("sceKernelCreateMsgPipe", 5));
asm (macro.generic_abi_wrapper("sceKernelSendMsgPipeCB", 5));
asm (macro.generic_abi_wrapper("sceKernelReceiveMsgPipe", 5));
asm (macro.generic_abi_wrapper("sceKernelReceiveMsgPipeCB", 5));
asm (macro.generic_abi_wrapper("sceKernelCreateVpl", 5));
asm (macro.generic_abi_wrapper("sceKernelCreateFpl", 5));
asm (macro.generic_abi_wrapper("sceKernelRegisterThreadEventHandler", 6));
} | src/psp/nids/pspthreadman.zig |
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
const Element = @import("AllKeysFile.zig").Element;
const Elements = @import("AllKeysFile.zig").Elements;
const Key = @import("AllKeysFile.zig").Key;
const NodeMap = std.AutoHashMap(u21, Node);
const Node = struct {
value: ?Elements,
children: ?NodeMap,
fn init() Node {
return Node{
.value = null,
.children = null,
};
}
fn deinit(self: *Node) void {
if (self.children) |*children| {
var iter = children.iterator();
while (iter.next()) |entry| {
entry.value_ptr.deinit();
}
children.deinit();
}
}
};
/// `Lookup` is the result of a lookup in the trie.
pub const Lookup = struct {
index: usize,
value: ?Elements,
};
allocator: mem.Allocator,
root: Node,
const Self = @This();
pub fn init(allocator: mem.Allocator) Self {
return Self{
.allocator = allocator,
.root = Node.init(),
};
}
pub fn deinit(self: *Self) void {
self.root.deinit();
}
/// `add` an element to the trie.
pub fn add(self: *Self, key: Key, value: Elements) !void {
var current_node = &self.root;
for (key.items[0..key.len]) |cp| {
if (current_node.children == null) current_node.children = NodeMap.init(self.allocator);
var result = try current_node.children.?.getOrPut(cp);
if (!result.found_existing) {
result.value_ptr.* = Node.init();
}
current_node = result.value_ptr;
}
current_node.value = value;
}
/// `find` an element in the trie.
pub fn find(self: Self, key: []const u21) Lookup {
var current_node = self.root;
var success_index: usize = 0;
var success_value: ?Elements = null;
for (key) |cp, i| {
if (current_node.children == null or current_node.children.?.get(cp) == null) break;
current_node = current_node.children.?.get(cp).?;
if (current_node.value) |value| {
success_index = i;
success_value = value;
}
}
return .{ .index = success_index, .value = success_value };
}
test "Collator Trie" {
var trie = init(std.testing.allocator);
defer trie.deinit();
var a1: Elements = undefined;
a1.len = 2;
a1.items[0] = .{ .l1 = 1, .l2 = 1, .l3 = 1 };
a1.items[1] = .{ .l1 = 2, .l2 = 2, .l3 = 2 };
var a2: Elements = undefined;
a2.len = 3;
a2.items[0] = .{ .l1 = 1, .l2 = 1, .l3 = 1 };
a2.items[1] = .{ .l1 = 2, .l2 = 2, .l3 = 2 };
a2.items[2] = .{ .l1 = 3, .l2 = 3, .l3 = 3 };
try trie.add(Key{ .items = [_]u21{ 1, 2, 0 }, .len = 2 }, a1);
try trie.add(Key{ .items = [_]u21{ 1, 2, 3 }, .len = 3 }, a2);
var lookup = trie.find(&[_]u21{ 1, 2 });
try testing.expectEqual(@as(usize, 1), lookup.index);
try testing.expectEqualSlices(Element, a1.items[0..a1.len], lookup.value.?.items[0..lookup.value.?.len]);
lookup = trie.find(&[_]u21{ 1, 2, 3 });
try testing.expectEqual(@as(usize, 2), lookup.index);
try testing.expectEqualSlices(Element, a2.items[0..a2.len], lookup.value.?.items[0..lookup.value.?.len]);
lookup = trie.find(&[_]u21{1});
try testing.expectEqual(@as(usize, 0), lookup.index);
try testing.expect(lookup.value == null);
} | src/collator/CollatorTrie.zig |
pub const struct_xcb_connection_t = opaque {};
pub const xcb_connection_t = struct_xcb_connection_t;
pub const xcb_generic_iterator_t = extern struct {
data: ?*anyopaque,
rem: c_int,
index: c_int,
};
pub const xcb_generic_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
};
pub const xcb_generic_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
pad: [7]u32,
full_sequence: u32,
};
pub const xcb_raw_generic_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
pad: [7]u32,
};
pub const xcb_ge_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
event_type: u16,
pad1: u16,
pad: [5]u32,
full_sequence: u32,
};
pub const xcb_generic_error_t = extern struct {
response_type: u8,
error_code: u8,
sequence: u16,
resource_id: u32,
minor_code: u16,
major_code: u8,
pad0: u8,
pad: [5]u32,
full_sequence: u32,
};
pub const xcb_void_cookie_t = extern struct {
sequence: c_uint,
};
pub const struct_xcb_char2b_t = extern struct {
byte1: u8,
byte2: u8,
};
pub const xcb_char2b_t = struct_xcb_char2b_t;
pub const struct_xcb_char2b_iterator_t = extern struct {
data: [*c]xcb_char2b_t,
rem: c_int,
index: c_int,
};
pub const xcb_char2b_iterator_t = struct_xcb_char2b_iterator_t;
pub const xcb_window_t = u32;
pub const struct_xcb_window_iterator_t = extern struct {
data: [*c]xcb_window_t,
rem: c_int,
index: c_int,
};
pub const xcb_window_iterator_t = struct_xcb_window_iterator_t;
pub const xcb_pixmap_t = u32;
pub const struct_xcb_pixmap_iterator_t = extern struct {
data: [*c]xcb_pixmap_t,
rem: c_int,
index: c_int,
};
pub const xcb_pixmap_iterator_t = struct_xcb_pixmap_iterator_t;
pub const xcb_cursor_t = u32;
pub const struct_xcb_cursor_iterator_t = extern struct {
data: [*c]xcb_cursor_t,
rem: c_int,
index: c_int,
};
pub const xcb_cursor_iterator_t = struct_xcb_cursor_iterator_t;
pub const xcb_font_t = u32;
pub const struct_xcb_font_iterator_t = extern struct {
data: [*c]xcb_font_t,
rem: c_int,
index: c_int,
};
pub const xcb_font_iterator_t = struct_xcb_font_iterator_t;
pub const xcb_gcontext_t = u32;
pub const struct_xcb_gcontext_iterator_t = extern struct {
data: [*c]xcb_gcontext_t,
rem: c_int,
index: c_int,
};
pub const xcb_gcontext_iterator_t = struct_xcb_gcontext_iterator_t;
pub const xcb_colormap_t = u32;
pub const struct_xcb_colormap_iterator_t = extern struct {
data: [*c]xcb_colormap_t,
rem: c_int,
index: c_int,
};
pub const xcb_colormap_iterator_t = struct_xcb_colormap_iterator_t;
pub const xcb_atom_t = u32;
pub const struct_xcb_atom_iterator_t = extern struct {
data: [*c]xcb_atom_t,
rem: c_int,
index: c_int,
};
pub const xcb_atom_iterator_t = struct_xcb_atom_iterator_t;
pub const xcb_drawable_t = u32;
pub const struct_xcb_drawable_iterator_t = extern struct {
data: [*c]xcb_drawable_t,
rem: c_int,
index: c_int,
};
pub const xcb_drawable_iterator_t = struct_xcb_drawable_iterator_t;
pub const xcb_fontable_t = u32;
pub const struct_xcb_fontable_iterator_t = extern struct {
data: [*c]xcb_fontable_t,
rem: c_int,
index: c_int,
};
pub const xcb_fontable_iterator_t = struct_xcb_fontable_iterator_t;
pub const xcb_bool32_t = u32;
pub const struct_xcb_bool32_iterator_t = extern struct {
data: [*c]xcb_bool32_t,
rem: c_int,
index: c_int,
};
pub const xcb_bool32_iterator_t = struct_xcb_bool32_iterator_t;
pub const xcb_visualid_t = u32;
pub const struct_xcb_visualid_iterator_t = extern struct {
data: [*c]xcb_visualid_t,
rem: c_int,
index: c_int,
};
pub const xcb_visualid_iterator_t = struct_xcb_visualid_iterator_t;
pub const xcb_timestamp_t = u32;
pub const struct_xcb_timestamp_iterator_t = extern struct {
data: [*c]xcb_timestamp_t,
rem: c_int,
index: c_int,
};
pub const xcb_timestamp_iterator_t = struct_xcb_timestamp_iterator_t;
pub const xcb_keysym_t = u32;
pub const struct_xcb_keysym_iterator_t = extern struct {
data: [*c]xcb_keysym_t,
rem: c_int,
index: c_int,
};
pub const xcb_keysym_iterator_t = struct_xcb_keysym_iterator_t;
pub const xcb_keycode_t = u8;
pub const struct_xcb_keycode_iterator_t = extern struct {
data: [*c]xcb_keycode_t,
rem: c_int,
index: c_int,
};
pub const xcb_keycode_iterator_t = struct_xcb_keycode_iterator_t;
pub const xcb_keycode32_t = u32;
pub const struct_xcb_keycode32_iterator_t = extern struct {
data: [*c]xcb_keycode32_t,
rem: c_int,
index: c_int,
};
pub const xcb_keycode32_iterator_t = struct_xcb_keycode32_iterator_t;
pub const xcb_button_t = u8;
pub const struct_xcb_button_iterator_t = extern struct {
data: [*c]xcb_button_t,
rem: c_int,
index: c_int,
};
pub const xcb_button_iterator_t = struct_xcb_button_iterator_t;
pub const struct_xcb_point_t = extern struct {
x: i16,
y: i16,
};
pub const xcb_point_t = struct_xcb_point_t;
pub const struct_xcb_point_iterator_t = extern struct {
data: [*c]xcb_point_t,
rem: c_int,
index: c_int,
};
pub const xcb_point_iterator_t = struct_xcb_point_iterator_t;
pub const struct_xcb_rectangle_t = extern struct {
x: i16,
y: i16,
width: u16,
height: u16,
};
pub const xcb_rectangle_t = struct_xcb_rectangle_t;
pub const struct_xcb_rectangle_iterator_t = extern struct {
data: [*c]xcb_rectangle_t,
rem: c_int,
index: c_int,
};
pub const xcb_rectangle_iterator_t = struct_xcb_rectangle_iterator_t;
pub const struct_xcb_arc_t = extern struct {
x: i16,
y: i16,
width: u16,
height: u16,
angle1: i16,
angle2: i16,
};
pub const xcb_arc_t = struct_xcb_arc_t;
pub const struct_xcb_arc_iterator_t = extern struct {
data: [*c]xcb_arc_t,
rem: c_int,
index: c_int,
};
pub const xcb_arc_iterator_t = struct_xcb_arc_iterator_t;
pub const struct_xcb_format_t = extern struct {
depth: u8,
bits_per_pixel: u8,
scanline_pad: u8,
pad0: [5]u8,
};
pub const xcb_format_t = struct_xcb_format_t;
pub const struct_xcb_format_iterator_t = extern struct {
data: [*c]xcb_format_t,
rem: c_int,
index: c_int,
};
pub const xcb_format_iterator_t = struct_xcb_format_iterator_t;
pub const XCB_VISUAL_CLASS_STATIC_GRAY: c_int = 0;
pub const XCB_VISUAL_CLASS_GRAY_SCALE: c_int = 1;
pub const XCB_VISUAL_CLASS_STATIC_COLOR: c_int = 2;
pub const XCB_VISUAL_CLASS_PSEUDO_COLOR: c_int = 3;
pub const XCB_VISUAL_CLASS_TRUE_COLOR: c_int = 4;
pub const XCB_VISUAL_CLASS_DIRECT_COLOR: c_int = 5;
pub const enum_xcb_visual_class_t = c_uint;
pub const xcb_visual_class_t = enum_xcb_visual_class_t;
pub const struct_xcb_visualtype_t = extern struct {
visual_id: xcb_visualid_t,
_class: u8,
bits_per_rgb_value: u8,
colormap_entries: u16,
red_mask: u32,
green_mask: u32,
blue_mask: u32,
pad0: [4]u8,
};
pub const xcb_visualtype_t = struct_xcb_visualtype_t;
pub const struct_xcb_visualtype_iterator_t = extern struct {
data: [*c]xcb_visualtype_t,
rem: c_int,
index: c_int,
};
pub const xcb_visualtype_iterator_t = struct_xcb_visualtype_iterator_t;
pub const struct_xcb_depth_t = extern struct {
depth: u8,
pad0: u8,
visuals_len: u16,
pad1: [4]u8,
};
pub const xcb_depth_t = struct_xcb_depth_t;
pub const struct_xcb_depth_iterator_t = extern struct {
data: [*c]xcb_depth_t,
rem: c_int,
index: c_int,
};
pub const xcb_depth_iterator_t = struct_xcb_depth_iterator_t;
pub const XCB_EVENT_MASK_NO_EVENT: c_int = 0;
pub const XCB_EVENT_MASK_KEY_PRESS: c_int = 1;
pub const XCB_EVENT_MASK_KEY_RELEASE: c_int = 2;
pub const XCB_EVENT_MASK_BUTTON_PRESS: c_int = 4;
pub const XCB_EVENT_MASK_BUTTON_RELEASE: c_int = 8;
pub const XCB_EVENT_MASK_ENTER_WINDOW: c_int = 16;
pub const XCB_EVENT_MASK_LEAVE_WINDOW: c_int = 32;
pub const XCB_EVENT_MASK_POINTER_MOTION: c_int = 64;
pub const XCB_EVENT_MASK_POINTER_MOTION_HINT: c_int = 128;
pub const XCB_EVENT_MASK_BUTTON_1_MOTION: c_int = 256;
pub const XCB_EVENT_MASK_BUTTON_2_MOTION: c_int = 512;
pub const XCB_EVENT_MASK_BUTTON_3_MOTION: c_int = 1024;
pub const XCB_EVENT_MASK_BUTTON_4_MOTION: c_int = 2048;
pub const XCB_EVENT_MASK_BUTTON_5_MOTION: c_int = 4096;
pub const XCB_EVENT_MASK_BUTTON_MOTION: c_int = 8192;
pub const XCB_EVENT_MASK_KEYMAP_STATE: c_int = 16384;
pub const XCB_EVENT_MASK_EXPOSURE: c_int = 32768;
pub const XCB_EVENT_MASK_VISIBILITY_CHANGE: c_int = 65536;
pub const XCB_EVENT_MASK_STRUCTURE_NOTIFY: c_int = 131072;
pub const XCB_EVENT_MASK_RESIZE_REDIRECT: c_int = 262144;
pub const XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY: c_int = 524288;
pub const XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT: c_int = 1048576;
pub const XCB_EVENT_MASK_FOCUS_CHANGE: c_int = 2097152;
pub const XCB_EVENT_MASK_PROPERTY_CHANGE: c_int = 4194304;
pub const XCB_EVENT_MASK_COLOR_MAP_CHANGE: c_int = 8388608;
pub const XCB_EVENT_MASK_OWNER_GRAB_BUTTON: c_int = 16777216;
pub const enum_xcb_event_mask_t = c_uint;
pub const xcb_event_mask_t = enum_xcb_event_mask_t;
pub const XCB_BACKING_STORE_NOT_USEFUL: c_int = 0;
pub const XCB_BACKING_STORE_WHEN_MAPPED: c_int = 1;
pub const XCB_BACKING_STORE_ALWAYS: c_int = 2;
pub const enum_xcb_backing_store_t = c_uint;
pub const xcb_backing_store_t = enum_xcb_backing_store_t;
pub const struct_xcb_screen_t = extern struct {
root: xcb_window_t,
default_colormap: xcb_colormap_t,
white_pixel: u32,
black_pixel: u32,
current_input_masks: u32,
width_in_pixels: u16,
height_in_pixels: u16,
width_in_millimeters: u16,
height_in_millimeters: u16,
min_installed_maps: u16,
max_installed_maps: u16,
root_visual: xcb_visualid_t,
backing_stores: u8,
save_unders: u8,
root_depth: u8,
allowed_depths_len: u8,
};
pub const xcb_screen_t = struct_xcb_screen_t;
pub const struct_xcb_screen_iterator_t = extern struct {
data: [*c]xcb_screen_t,
rem: c_int,
index: c_int,
};
pub const xcb_screen_iterator_t = struct_xcb_screen_iterator_t;
pub const struct_xcb_setup_request_t = extern struct {
byte_order: u8,
pad0: u8,
protocol_major_version: u16,
protocol_minor_version: u16,
authorization_protocol_name_len: u16,
authorization_protocol_data_len: u16,
pad1: [2]u8,
};
pub const xcb_setup_request_t = struct_xcb_setup_request_t;
pub const struct_xcb_setup_request_iterator_t = extern struct {
data: [*c]xcb_setup_request_t,
rem: c_int,
index: c_int,
};
pub const xcb_setup_request_iterator_t = struct_xcb_setup_request_iterator_t;
pub const struct_xcb_setup_failed_t = extern struct {
status: u8,
reason_len: u8,
protocol_major_version: u16,
protocol_minor_version: u16,
length: u16,
};
pub const xcb_setup_failed_t = struct_xcb_setup_failed_t;
pub const struct_xcb_setup_failed_iterator_t = extern struct {
data: [*c]xcb_setup_failed_t,
rem: c_int,
index: c_int,
};
pub const xcb_setup_failed_iterator_t = struct_xcb_setup_failed_iterator_t;
pub const struct_xcb_setup_authenticate_t = extern struct {
status: u8,
pad0: [5]u8,
length: u16,
};
pub const xcb_setup_authenticate_t = struct_xcb_setup_authenticate_t;
pub const struct_xcb_setup_authenticate_iterator_t = extern struct {
data: [*c]xcb_setup_authenticate_t,
rem: c_int,
index: c_int,
};
pub const xcb_setup_authenticate_iterator_t = struct_xcb_setup_authenticate_iterator_t;
pub const XCB_IMAGE_ORDER_LSB_FIRST: c_int = 0;
pub const XCB_IMAGE_ORDER_MSB_FIRST: c_int = 1;
pub const enum_xcb_image_order_t = c_uint;
pub const xcb_image_order_t = enum_xcb_image_order_t;
pub const struct_xcb_setup_t = extern struct {
status: u8,
pad0: u8,
protocol_major_version: u16,
protocol_minor_version: u16,
length: u16,
release_number: u32,
resource_id_base: u32,
resource_id_mask: u32,
motion_buffer_size: u32,
vendor_len: u16,
maximum_request_length: u16,
roots_len: u8,
pixmap_formats_len: u8,
image_byte_order: u8,
bitmap_format_bit_order: u8,
bitmap_format_scanline_unit: u8,
bitmap_format_scanline_pad: u8,
min_keycode: xcb_keycode_t,
max_keycode: xcb_keycode_t,
pad1: [4]u8,
};
pub const xcb_setup_t = struct_xcb_setup_t;
pub const struct_xcb_setup_iterator_t = extern struct {
data: [*c]xcb_setup_t,
rem: c_int,
index: c_int,
};
pub const xcb_setup_iterator_t = struct_xcb_setup_iterator_t;
pub const XCB_MOD_MASK_SHIFT: c_int = 1;
pub const XCB_MOD_MASK_LOCK: c_int = 2;
pub const XCB_MOD_MASK_CONTROL: c_int = 4;
pub const XCB_MOD_MASK_1: c_int = 8;
pub const XCB_MOD_MASK_2: c_int = 16;
pub const XCB_MOD_MASK_3: c_int = 32;
pub const XCB_MOD_MASK_4: c_int = 64;
pub const XCB_MOD_MASK_5: c_int = 128;
pub const XCB_MOD_MASK_ANY: c_int = 32768;
pub const enum_xcb_mod_mask_t = c_uint;
pub const xcb_mod_mask_t = enum_xcb_mod_mask_t;
pub const XCB_KEY_BUT_MASK_SHIFT: c_int = 1;
pub const XCB_KEY_BUT_MASK_LOCK: c_int = 2;
pub const XCB_KEY_BUT_MASK_CONTROL: c_int = 4;
pub const XCB_KEY_BUT_MASK_MOD_1: c_int = 8;
pub const XCB_KEY_BUT_MASK_MOD_2: c_int = 16;
pub const XCB_KEY_BUT_MASK_MOD_3: c_int = 32;
pub const XCB_KEY_BUT_MASK_MOD_4: c_int = 64;
pub const XCB_KEY_BUT_MASK_MOD_5: c_int = 128;
pub const XCB_KEY_BUT_MASK_BUTTON_1: c_int = 256;
pub const XCB_KEY_BUT_MASK_BUTTON_2: c_int = 512;
pub const XCB_KEY_BUT_MASK_BUTTON_3: c_int = 1024;
pub const XCB_KEY_BUT_MASK_BUTTON_4: c_int = 2048;
pub const XCB_KEY_BUT_MASK_BUTTON_5: c_int = 4096;
pub const enum_xcb_key_but_mask_t = c_uint;
pub const xcb_key_but_mask_t = enum_xcb_key_but_mask_t;
pub const XCB_WINDOW_NONE: c_int = 0;
pub const enum_xcb_window_enum_t = c_uint;
pub const xcb_window_enum_t = enum_xcb_window_enum_t;
pub const struct_xcb_key_press_event_t = extern struct {
response_type: u8,
detail: xcb_keycode_t,
sequence: u16,
time: xcb_timestamp_t,
root: xcb_window_t,
event: xcb_window_t,
child: xcb_window_t,
root_x: i16,
root_y: i16,
event_x: i16,
event_y: i16,
state: u16,
same_screen: u8,
pad0: u8,
};
pub const xcb_key_press_event_t = struct_xcb_key_press_event_t;
pub const xcb_key_release_event_t = xcb_key_press_event_t;
pub const XCB_BUTTON_MASK_1: c_int = 256;
pub const XCB_BUTTON_MASK_2: c_int = 512;
pub const XCB_BUTTON_MASK_3: c_int = 1024;
pub const XCB_BUTTON_MASK_4: c_int = 2048;
pub const XCB_BUTTON_MASK_5: c_int = 4096;
pub const XCB_BUTTON_MASK_ANY: c_int = 32768;
pub const enum_xcb_button_mask_t = c_uint;
pub const xcb_button_mask_t = enum_xcb_button_mask_t;
pub const struct_xcb_button_press_event_t = extern struct {
response_type: u8,
detail: xcb_button_t,
sequence: u16,
time: xcb_timestamp_t,
root: xcb_window_t,
event: xcb_window_t,
child: xcb_window_t,
root_x: i16,
root_y: i16,
event_x: i16,
event_y: i16,
state: u16,
same_screen: u8,
pad0: u8,
};
pub const xcb_button_press_event_t = struct_xcb_button_press_event_t;
pub const xcb_button_release_event_t = xcb_button_press_event_t;
pub const XCB_MOTION_NORMAL: c_int = 0;
pub const XCB_MOTION_HINT: c_int = 1;
pub const enum_xcb_motion_t = c_uint;
pub const xcb_motion_t = enum_xcb_motion_t;
pub const struct_xcb_motion_notify_event_t = extern struct {
response_type: u8,
detail: u8,
sequence: u16,
time: xcb_timestamp_t,
root: xcb_window_t,
event: xcb_window_t,
child: xcb_window_t,
root_x: i16,
root_y: i16,
event_x: i16,
event_y: i16,
state: u16,
same_screen: u8,
pad0: u8,
};
pub const xcb_motion_notify_event_t = struct_xcb_motion_notify_event_t;
pub const XCB_NOTIFY_DETAIL_ANCESTOR: c_int = 0;
pub const XCB_NOTIFY_DETAIL_VIRTUAL: c_int = 1;
pub const XCB_NOTIFY_DETAIL_INFERIOR: c_int = 2;
pub const XCB_NOTIFY_DETAIL_NONLINEAR: c_int = 3;
pub const XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL: c_int = 4;
pub const XCB_NOTIFY_DETAIL_POINTER: c_int = 5;
pub const XCB_NOTIFY_DETAIL_POINTER_ROOT: c_int = 6;
pub const XCB_NOTIFY_DETAIL_NONE: c_int = 7;
pub const enum_xcb_notify_detail_t = c_uint;
pub const xcb_notify_detail_t = enum_xcb_notify_detail_t;
pub const XCB_NOTIFY_MODE_NORMAL: c_int = 0;
pub const XCB_NOTIFY_MODE_GRAB: c_int = 1;
pub const XCB_NOTIFY_MODE_UNGRAB: c_int = 2;
pub const XCB_NOTIFY_MODE_WHILE_GRABBED: c_int = 3;
pub const enum_xcb_notify_mode_t = c_uint;
pub const xcb_notify_mode_t = enum_xcb_notify_mode_t;
pub const struct_xcb_enter_notify_event_t = extern struct {
response_type: u8,
detail: u8,
sequence: u16,
time: xcb_timestamp_t,
root: xcb_window_t,
event: xcb_window_t,
child: xcb_window_t,
root_x: i16,
root_y: i16,
event_x: i16,
event_y: i16,
state: u16,
mode: u8,
same_screen_focus: u8,
};
pub const xcb_enter_notify_event_t = struct_xcb_enter_notify_event_t;
pub const xcb_leave_notify_event_t = xcb_enter_notify_event_t;
pub const struct_xcb_focus_in_event_t = extern struct {
response_type: u8,
detail: u8,
sequence: u16,
event: xcb_window_t,
mode: u8,
pad0: [3]u8,
};
pub const xcb_focus_in_event_t = struct_xcb_focus_in_event_t;
pub const xcb_focus_out_event_t = xcb_focus_in_event_t;
pub const struct_xcb_keymap_notify_event_t = extern struct {
response_type: u8,
keys: [31]u8,
};
pub const xcb_keymap_notify_event_t = struct_xcb_keymap_notify_event_t;
pub const struct_xcb_expose_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
window: xcb_window_t,
x: u16,
y: u16,
width: u16,
height: u16,
count: u16,
pad1: [2]u8,
};
pub const xcb_expose_event_t = struct_xcb_expose_event_t;
pub const struct_xcb_graphics_exposure_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
drawable: xcb_drawable_t,
x: u16,
y: u16,
width: u16,
height: u16,
minor_opcode: u16,
count: u16,
major_opcode: u8,
pad1: [3]u8,
};
pub const xcb_graphics_exposure_event_t = struct_xcb_graphics_exposure_event_t;
pub const struct_xcb_no_exposure_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
drawable: xcb_drawable_t,
minor_opcode: u16,
major_opcode: u8,
pad1: u8,
};
pub const xcb_no_exposure_event_t = struct_xcb_no_exposure_event_t;
pub const XCB_VISIBILITY_UNOBSCURED: c_int = 0;
pub const XCB_VISIBILITY_PARTIALLY_OBSCURED: c_int = 1;
pub const XCB_VISIBILITY_FULLY_OBSCURED: c_int = 2;
pub const enum_xcb_visibility_t = c_uint;
pub const xcb_visibility_t = enum_xcb_visibility_t;
pub const struct_xcb_visibility_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
window: xcb_window_t,
state: u8,
pad1: [3]u8,
};
pub const xcb_visibility_notify_event_t = struct_xcb_visibility_notify_event_t;
pub const struct_xcb_create_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
parent: xcb_window_t,
window: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
border_width: u16,
override_redirect: u8,
pad1: u8,
};
pub const xcb_create_notify_event_t = struct_xcb_create_notify_event_t;
pub const struct_xcb_destroy_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
};
pub const xcb_destroy_notify_event_t = struct_xcb_destroy_notify_event_t;
pub const struct_xcb_unmap_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
from_configure: u8,
pad1: [3]u8,
};
pub const xcb_unmap_notify_event_t = struct_xcb_unmap_notify_event_t;
pub const struct_xcb_map_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
override_redirect: u8,
pad1: [3]u8,
};
pub const xcb_map_notify_event_t = struct_xcb_map_notify_event_t;
pub const struct_xcb_map_request_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
parent: xcb_window_t,
window: xcb_window_t,
};
pub const xcb_map_request_event_t = struct_xcb_map_request_event_t;
pub const struct_xcb_reparent_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
parent: xcb_window_t,
x: i16,
y: i16,
override_redirect: u8,
pad1: [3]u8,
};
pub const xcb_reparent_notify_event_t = struct_xcb_reparent_notify_event_t;
pub const struct_xcb_configure_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
above_sibling: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
border_width: u16,
override_redirect: u8,
pad1: u8,
};
pub const xcb_configure_notify_event_t = struct_xcb_configure_notify_event_t;
pub const struct_xcb_configure_request_event_t = extern struct {
response_type: u8,
stack_mode: u8,
sequence: u16,
parent: xcb_window_t,
window: xcb_window_t,
sibling: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
border_width: u16,
value_mask: u16,
};
pub const xcb_configure_request_event_t = struct_xcb_configure_request_event_t;
pub const struct_xcb_gravity_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
x: i16,
y: i16,
};
pub const xcb_gravity_notify_event_t = struct_xcb_gravity_notify_event_t;
pub const struct_xcb_resize_request_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
window: xcb_window_t,
width: u16,
height: u16,
};
pub const xcb_resize_request_event_t = struct_xcb_resize_request_event_t;
pub const XCB_PLACE_ON_TOP: c_int = 0;
pub const XCB_PLACE_ON_BOTTOM: c_int = 1;
pub const enum_xcb_place_t = c_uint;
pub const xcb_place_t = enum_xcb_place_t;
pub const struct_xcb_circulate_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
event: xcb_window_t,
window: xcb_window_t,
pad1: [4]u8,
place: u8,
pad2: [3]u8,
};
pub const xcb_circulate_notify_event_t = struct_xcb_circulate_notify_event_t;
pub const xcb_circulate_request_event_t = xcb_circulate_notify_event_t;
pub const XCB_PROPERTY_NEW_VALUE: c_int = 0;
pub const XCB_PROPERTY_DELETE: c_int = 1;
pub const enum_xcb_property_t = c_uint;
pub const xcb_property_t = enum_xcb_property_t;
pub const struct_xcb_property_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
window: xcb_window_t,
atom: xcb_atom_t,
time: xcb_timestamp_t,
state: u8,
pad1: [3]u8,
};
pub const xcb_property_notify_event_t = struct_xcb_property_notify_event_t;
pub const struct_xcb_selection_clear_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
time: xcb_timestamp_t,
owner: xcb_window_t,
selection: xcb_atom_t,
};
pub const xcb_selection_clear_event_t = struct_xcb_selection_clear_event_t;
pub const XCB_TIME_CURRENT_TIME: c_int = 0;
pub const enum_xcb_time_t = c_uint;
pub const xcb_time_t = enum_xcb_time_t;
pub const XCB_ATOM_NONE: c_int = 0;
pub const XCB_ATOM_ANY: c_int = 0;
pub const XCB_ATOM_PRIMARY: c_int = 1;
pub const XCB_ATOM_SECONDARY: c_int = 2;
pub const XCB_ATOM_ARC: c_int = 3;
pub const XCB_ATOM_ATOM: c_int = 4;
pub const XCB_ATOM_BITMAP: c_int = 5;
pub const XCB_ATOM_CARDINAL: c_int = 6;
pub const XCB_ATOM_COLORMAP: c_int = 7;
pub const XCB_ATOM_CURSOR: c_int = 8;
pub const XCB_ATOM_CUT_BUFFER0: c_int = 9;
pub const XCB_ATOM_CUT_BUFFER1: c_int = 10;
pub const XCB_ATOM_CUT_BUFFER2: c_int = 11;
pub const XCB_ATOM_CUT_BUFFER3: c_int = 12;
pub const XCB_ATOM_CUT_BUFFER4: c_int = 13;
pub const XCB_ATOM_CUT_BUFFER5: c_int = 14;
pub const XCB_ATOM_CUT_BUFFER6: c_int = 15;
pub const XCB_ATOM_CUT_BUFFER7: c_int = 16;
pub const XCB_ATOM_DRAWABLE: c_int = 17;
pub const XCB_ATOM_FONT: c_int = 18;
pub const XCB_ATOM_INTEGER: c_int = 19;
pub const XCB_ATOM_PIXMAP: c_int = 20;
pub const XCB_ATOM_POINT: c_int = 21;
pub const XCB_ATOM_RECTANGLE: c_int = 22;
pub const XCB_ATOM_RESOURCE_MANAGER: c_int = 23;
pub const XCB_ATOM_RGB_COLOR_MAP: c_int = 24;
pub const XCB_ATOM_RGB_BEST_MAP: c_int = 25;
pub const XCB_ATOM_RGB_BLUE_MAP: c_int = 26;
pub const XCB_ATOM_RGB_DEFAULT_MAP: c_int = 27;
pub const XCB_ATOM_RGB_GRAY_MAP: c_int = 28;
pub const XCB_ATOM_RGB_GREEN_MAP: c_int = 29;
pub const XCB_ATOM_RGB_RED_MAP: c_int = 30;
pub const XCB_ATOM_STRING: c_int = 31;
pub const XCB_ATOM_VISUALID: c_int = 32;
pub const XCB_ATOM_WINDOW: c_int = 33;
pub const XCB_ATOM_WM_COMMAND: c_int = 34;
pub const XCB_ATOM_WM_HINTS: c_int = 35;
pub const XCB_ATOM_WM_CLIENT_MACHINE: c_int = 36;
pub const XCB_ATOM_WM_ICON_NAME: c_int = 37;
pub const XCB_ATOM_WM_ICON_SIZE: c_int = 38;
pub const XCB_ATOM_WM_NAME: c_int = 39;
pub const XCB_ATOM_WM_NORMAL_HINTS: c_int = 40;
pub const XCB_ATOM_WM_SIZE_HINTS: c_int = 41;
pub const XCB_ATOM_WM_ZOOM_HINTS: c_int = 42;
pub const XCB_ATOM_MIN_SPACE: c_int = 43;
pub const XCB_ATOM_NORM_SPACE: c_int = 44;
pub const XCB_ATOM_MAX_SPACE: c_int = 45;
pub const XCB_ATOM_END_SPACE: c_int = 46;
pub const XCB_ATOM_SUPERSCRIPT_X: c_int = 47;
pub const XCB_ATOM_SUPERSCRIPT_Y: c_int = 48;
pub const XCB_ATOM_SUBSCRIPT_X: c_int = 49;
pub const XCB_ATOM_SUBSCRIPT_Y: c_int = 50;
pub const XCB_ATOM_UNDERLINE_POSITION: c_int = 51;
pub const XCB_ATOM_UNDERLINE_THICKNESS: c_int = 52;
pub const XCB_ATOM_STRIKEOUT_ASCENT: c_int = 53;
pub const XCB_ATOM_STRIKEOUT_DESCENT: c_int = 54;
pub const XCB_ATOM_ITALIC_ANGLE: c_int = 55;
pub const XCB_ATOM_X_HEIGHT: c_int = 56;
pub const XCB_ATOM_QUAD_WIDTH: c_int = 57;
pub const XCB_ATOM_WEIGHT: c_int = 58;
pub const XCB_ATOM_POINT_SIZE: c_int = 59;
pub const XCB_ATOM_RESOLUTION: c_int = 60;
pub const XCB_ATOM_COPYRIGHT: c_int = 61;
pub const XCB_ATOM_NOTICE: c_int = 62;
pub const XCB_ATOM_FONT_NAME: c_int = 63;
pub const XCB_ATOM_FAMILY_NAME: c_int = 64;
pub const XCB_ATOM_FULL_NAME: c_int = 65;
pub const XCB_ATOM_CAP_HEIGHT: c_int = 66;
pub const XCB_ATOM_WM_CLASS: c_int = 67;
pub const XCB_ATOM_WM_TRANSIENT_FOR: c_int = 68;
pub const enum_xcb_atom_enum_t = c_uint;
pub const xcb_atom_enum_t = enum_xcb_atom_enum_t;
pub const struct_xcb_selection_request_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
time: xcb_timestamp_t,
owner: xcb_window_t,
requestor: xcb_window_t,
selection: xcb_atom_t,
target: xcb_atom_t,
property: xcb_atom_t,
};
pub const xcb_selection_request_event_t = struct_xcb_selection_request_event_t;
pub const struct_xcb_selection_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
time: xcb_timestamp_t,
requestor: xcb_window_t,
selection: xcb_atom_t,
target: xcb_atom_t,
property: xcb_atom_t,
};
pub const xcb_selection_notify_event_t = struct_xcb_selection_notify_event_t;
pub const XCB_COLORMAP_STATE_UNINSTALLED: c_int = 0;
pub const XCB_COLORMAP_STATE_INSTALLED: c_int = 1;
pub const enum_xcb_colormap_state_t = c_uint;
pub const xcb_colormap_state_t = enum_xcb_colormap_state_t;
pub const XCB_COLORMAP_NONE: c_int = 0;
pub const enum_xcb_colormap_enum_t = c_uint;
pub const xcb_colormap_enum_t = enum_xcb_colormap_enum_t;
pub const struct_xcb_colormap_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
window: xcb_window_t,
colormap: xcb_colormap_t,
_new: u8,
state: u8,
pad1: [2]u8,
};
pub const xcb_colormap_notify_event_t = struct_xcb_colormap_notify_event_t;
pub const union_xcb_client_message_data_t = extern union {
data8: [20]u8,
data16: [10]u16,
data32: [5]u32,
};
pub const xcb_client_message_data_t = union_xcb_client_message_data_t;
pub const struct_xcb_client_message_data_iterator_t = extern struct {
data: [*c]xcb_client_message_data_t,
rem: c_int,
index: c_int,
};
pub const xcb_client_message_data_iterator_t = struct_xcb_client_message_data_iterator_t;
pub const struct_xcb_client_message_event_t = extern struct {
response_type: u8,
format: u8,
sequence: u16,
window: xcb_window_t,
type: xcb_atom_t,
data: xcb_client_message_data_t,
};
pub const xcb_client_message_event_t = struct_xcb_client_message_event_t;
pub const XCB_MAPPING_MODIFIER: c_int = 0;
pub const XCB_MAPPING_KEYBOARD: c_int = 1;
pub const XCB_MAPPING_POINTER: c_int = 2;
pub const enum_xcb_mapping_t = c_uint;
pub const xcb_mapping_t = enum_xcb_mapping_t;
pub const struct_xcb_mapping_notify_event_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
request: u8,
first_keycode: xcb_keycode_t,
count: u8,
pad1: u8,
};
pub const xcb_mapping_notify_event_t = struct_xcb_mapping_notify_event_t;
pub const struct_xcb_ge_generic_event_t = extern struct {
response_type: u8,
extension: u8,
sequence: u16,
length: u32,
event_type: u16,
pad0: [22]u8,
full_sequence: u32,
};
pub const xcb_ge_generic_event_t = struct_xcb_ge_generic_event_t;
pub const struct_xcb_request_error_t = extern struct {
response_type: u8,
error_code: u8,
sequence: u16,
bad_value: u32,
minor_opcode: u16,
major_opcode: u8,
pad0: u8,
};
pub const xcb_request_error_t = struct_xcb_request_error_t;
pub const struct_xcb_value_error_t = extern struct {
response_type: u8,
error_code: u8,
sequence: u16,
bad_value: u32,
minor_opcode: u16,
major_opcode: u8,
pad0: u8,
};
pub const xcb_value_error_t = struct_xcb_value_error_t;
pub const xcb_window_error_t = xcb_value_error_t;
pub const xcb_pixmap_error_t = xcb_value_error_t;
pub const xcb_atom_error_t = xcb_value_error_t;
pub const xcb_cursor_error_t = xcb_value_error_t;
pub const xcb_font_error_t = xcb_value_error_t;
pub const xcb_match_error_t = xcb_request_error_t;
pub const xcb_drawable_error_t = xcb_value_error_t;
pub const xcb_access_error_t = xcb_request_error_t;
pub const xcb_alloc_error_t = xcb_request_error_t;
pub const xcb_colormap_error_t = xcb_value_error_t;
pub const xcb_g_context_error_t = xcb_value_error_t;
pub const xcb_id_choice_error_t = xcb_value_error_t;
pub const xcb_name_error_t = xcb_request_error_t;
pub const xcb_length_error_t = xcb_request_error_t;
pub const xcb_implementation_error_t = xcb_request_error_t;
pub const XCB_WINDOW_CLASS_COPY_FROM_PARENT: c_int = 0;
pub const XCB_WINDOW_CLASS_INPUT_OUTPUT: c_int = 1;
pub const XCB_WINDOW_CLASS_INPUT_ONLY: c_int = 2;
pub const enum_xcb_window_class_t = c_uint;
pub const xcb_window_class_t = enum_xcb_window_class_t;
pub const XCB_CW_BACK_PIXMAP: c_int = 1;
pub const XCB_CW_BACK_PIXEL: c_int = 2;
pub const XCB_CW_BORDER_PIXMAP: c_int = 4;
pub const XCB_CW_BORDER_PIXEL: c_int = 8;
pub const XCB_CW_BIT_GRAVITY: c_int = 16;
pub const XCB_CW_WIN_GRAVITY: c_int = 32;
pub const XCB_CW_BACKING_STORE: c_int = 64;
pub const XCB_CW_BACKING_PLANES: c_int = 128;
pub const XCB_CW_BACKING_PIXEL: c_int = 256;
pub const XCB_CW_OVERRIDE_REDIRECT: c_int = 512;
pub const XCB_CW_SAVE_UNDER: c_int = 1024;
pub const XCB_CW_EVENT_MASK: c_int = 2048;
pub const XCB_CW_DONT_PROPAGATE: c_int = 4096;
pub const XCB_CW_COLORMAP: c_int = 8192;
pub const XCB_CW_CURSOR: c_int = 16384;
pub const enum_xcb_cw_t = c_uint;
pub const xcb_cw_t = enum_xcb_cw_t;
pub const XCB_BACK_PIXMAP_NONE: c_int = 0;
pub const XCB_BACK_PIXMAP_PARENT_RELATIVE: c_int = 1;
pub const enum_xcb_back_pixmap_t = c_uint;
pub const xcb_back_pixmap_t = enum_xcb_back_pixmap_t;
pub const XCB_GRAVITY_BIT_FORGET: c_int = 0;
pub const XCB_GRAVITY_WIN_UNMAP: c_int = 0;
pub const XCB_GRAVITY_NORTH_WEST: c_int = 1;
pub const XCB_GRAVITY_NORTH: c_int = 2;
pub const XCB_GRAVITY_NORTH_EAST: c_int = 3;
pub const XCB_GRAVITY_WEST: c_int = 4;
pub const XCB_GRAVITY_CENTER: c_int = 5;
pub const XCB_GRAVITY_EAST: c_int = 6;
pub const XCB_GRAVITY_SOUTH_WEST: c_int = 7;
pub const XCB_GRAVITY_SOUTH: c_int = 8;
pub const XCB_GRAVITY_SOUTH_EAST: c_int = 9;
pub const XCB_GRAVITY_STATIC: c_int = 10;
pub const enum_xcb_gravity_t = c_uint;
pub const xcb_gravity_t = enum_xcb_gravity_t;
pub const struct_xcb_create_window_value_list_t = extern struct {
background_pixmap: xcb_pixmap_t,
background_pixel: u32,
border_pixmap: xcb_pixmap_t,
border_pixel: u32,
bit_gravity: u32,
win_gravity: u32,
backing_store: u32,
backing_planes: u32,
backing_pixel: u32,
override_redirect: xcb_bool32_t,
save_under: xcb_bool32_t,
event_mask: u32,
do_not_propogate_mask: u32,
colormap: xcb_colormap_t,
cursor: xcb_cursor_t,
};
pub const xcb_create_window_value_list_t = struct_xcb_create_window_value_list_t;
pub const struct_xcb_create_window_request_t = extern struct {
major_opcode: u8,
depth: u8,
length: u16,
wid: xcb_window_t,
parent: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
border_width: u16,
_class: u16,
visual: xcb_visualid_t,
value_mask: u32,
};
pub const xcb_create_window_request_t = struct_xcb_create_window_request_t;
pub const struct_xcb_change_window_attributes_value_list_t = extern struct {
background_pixmap: xcb_pixmap_t,
background_pixel: u32,
border_pixmap: xcb_pixmap_t,
border_pixel: u32,
bit_gravity: u32,
win_gravity: u32,
backing_store: u32,
backing_planes: u32,
backing_pixel: u32,
override_redirect: xcb_bool32_t,
save_under: xcb_bool32_t,
event_mask: u32,
do_not_propogate_mask: u32,
colormap: xcb_colormap_t,
cursor: xcb_cursor_t,
};
pub const xcb_change_window_attributes_value_list_t = struct_xcb_change_window_attributes_value_list_t;
pub const struct_xcb_change_window_attributes_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
value_mask: u32,
};
pub const xcb_change_window_attributes_request_t = struct_xcb_change_window_attributes_request_t;
pub const XCB_MAP_STATE_UNMAPPED: c_int = 0;
pub const XCB_MAP_STATE_UNVIEWABLE: c_int = 1;
pub const XCB_MAP_STATE_VIEWABLE: c_int = 2;
pub const enum_xcb_map_state_t = c_uint;
pub const xcb_map_state_t = enum_xcb_map_state_t;
pub const struct_xcb_get_window_attributes_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_window_attributes_cookie_t = struct_xcb_get_window_attributes_cookie_t;
pub const struct_xcb_get_window_attributes_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_get_window_attributes_request_t = struct_xcb_get_window_attributes_request_t;
pub const struct_xcb_get_window_attributes_reply_t = extern struct {
response_type: u8,
backing_store: u8,
sequence: u16,
length: u32,
visual: xcb_visualid_t,
_class: u16,
bit_gravity: u8,
win_gravity: u8,
backing_planes: u32,
backing_pixel: u32,
save_under: u8,
map_is_installed: u8,
map_state: u8,
override_redirect: u8,
colormap: xcb_colormap_t,
all_event_masks: u32,
your_event_mask: u32,
do_not_propagate_mask: u16,
pad0: [2]u8,
};
pub const xcb_get_window_attributes_reply_t = struct_xcb_get_window_attributes_reply_t;
pub const struct_xcb_destroy_window_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_destroy_window_request_t = struct_xcb_destroy_window_request_t;
pub const struct_xcb_destroy_subwindows_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_destroy_subwindows_request_t = struct_xcb_destroy_subwindows_request_t;
pub const XCB_SET_MODE_INSERT: c_int = 0;
pub const XCB_SET_MODE_DELETE: c_int = 1;
pub const enum_xcb_set_mode_t = c_uint;
pub const xcb_set_mode_t = enum_xcb_set_mode_t;
pub const struct_xcb_change_save_set_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_change_save_set_request_t = struct_xcb_change_save_set_request_t;
pub const struct_xcb_reparent_window_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
parent: xcb_window_t,
x: i16,
y: i16,
};
pub const xcb_reparent_window_request_t = struct_xcb_reparent_window_request_t;
pub const struct_xcb_map_window_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_map_window_request_t = struct_xcb_map_window_request_t;
pub const struct_xcb_map_subwindows_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_map_subwindows_request_t = struct_xcb_map_subwindows_request_t;
pub const struct_xcb_unmap_window_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_unmap_window_request_t = struct_xcb_unmap_window_request_t;
pub const struct_xcb_unmap_subwindows_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_unmap_subwindows_request_t = struct_xcb_unmap_subwindows_request_t;
pub const XCB_CONFIG_WINDOW_X: c_int = 1;
pub const XCB_CONFIG_WINDOW_Y: c_int = 2;
pub const XCB_CONFIG_WINDOW_WIDTH: c_int = 4;
pub const XCB_CONFIG_WINDOW_HEIGHT: c_int = 8;
pub const XCB_CONFIG_WINDOW_BORDER_WIDTH: c_int = 16;
pub const XCB_CONFIG_WINDOW_SIBLING: c_int = 32;
pub const XCB_CONFIG_WINDOW_STACK_MODE: c_int = 64;
pub const enum_xcb_config_window_t = c_uint;
pub const xcb_config_window_t = enum_xcb_config_window_t;
pub const XCB_STACK_MODE_ABOVE: c_int = 0;
pub const XCB_STACK_MODE_BELOW: c_int = 1;
pub const XCB_STACK_MODE_TOP_IF: c_int = 2;
pub const XCB_STACK_MODE_BOTTOM_IF: c_int = 3;
pub const XCB_STACK_MODE_OPPOSITE: c_int = 4;
pub const enum_xcb_stack_mode_t = c_uint;
pub const xcb_stack_mode_t = enum_xcb_stack_mode_t;
pub const struct_xcb_configure_window_value_list_t = extern struct {
x: i32,
y: i32,
width: u32,
height: u32,
border_width: u32,
sibling: xcb_window_t,
stack_mode: u32,
};
pub const xcb_configure_window_value_list_t = struct_xcb_configure_window_value_list_t;
pub const struct_xcb_configure_window_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
value_mask: u16,
pad1: [2]u8,
};
pub const xcb_configure_window_request_t = struct_xcb_configure_window_request_t;
pub const XCB_CIRCULATE_RAISE_LOWEST: c_int = 0;
pub const XCB_CIRCULATE_LOWER_HIGHEST: c_int = 1;
pub const enum_xcb_circulate_t = c_uint;
pub const xcb_circulate_t = enum_xcb_circulate_t;
pub const struct_xcb_circulate_window_request_t = extern struct {
major_opcode: u8,
direction: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_circulate_window_request_t = struct_xcb_circulate_window_request_t;
pub const struct_xcb_get_geometry_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_geometry_cookie_t = struct_xcb_get_geometry_cookie_t;
pub const struct_xcb_get_geometry_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
};
pub const xcb_get_geometry_request_t = struct_xcb_get_geometry_request_t;
pub const struct_xcb_get_geometry_reply_t = extern struct {
response_type: u8,
depth: u8,
sequence: u16,
length: u32,
root: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
border_width: u16,
pad0: [2]u8,
};
pub const xcb_get_geometry_reply_t = struct_xcb_get_geometry_reply_t;
pub const struct_xcb_query_tree_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_tree_cookie_t = struct_xcb_query_tree_cookie_t;
pub const struct_xcb_query_tree_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_query_tree_request_t = struct_xcb_query_tree_request_t;
pub const struct_xcb_query_tree_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
root: xcb_window_t,
parent: xcb_window_t,
children_len: u16,
pad1: [14]u8,
};
pub const xcb_query_tree_reply_t = struct_xcb_query_tree_reply_t;
pub const struct_xcb_intern_atom_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_intern_atom_cookie_t = struct_xcb_intern_atom_cookie_t;
pub const struct_xcb_intern_atom_request_t = extern struct {
major_opcode: u8,
only_if_exists: u8,
length: u16,
name_len: u16,
pad0: [2]u8,
};
pub const xcb_intern_atom_request_t = struct_xcb_intern_atom_request_t;
pub const struct_xcb_intern_atom_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
atom: xcb_atom_t,
};
pub const xcb_intern_atom_reply_t = struct_xcb_intern_atom_reply_t;
pub const struct_xcb_get_atom_name_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_atom_name_cookie_t = struct_xcb_get_atom_name_cookie_t;
pub const struct_xcb_get_atom_name_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
atom: xcb_atom_t,
};
pub const xcb_get_atom_name_request_t = struct_xcb_get_atom_name_request_t;
pub const struct_xcb_get_atom_name_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
name_len: u16,
pad1: [22]u8,
};
pub const xcb_get_atom_name_reply_t = struct_xcb_get_atom_name_reply_t;
pub const XCB_PROP_MODE_REPLACE: c_int = 0;
pub const XCB_PROP_MODE_PREPEND: c_int = 1;
pub const XCB_PROP_MODE_APPEND: c_int = 2;
pub const enum_xcb_prop_mode_t = c_uint;
pub const xcb_prop_mode_t = enum_xcb_prop_mode_t;
pub const struct_xcb_change_property_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
window: xcb_window_t,
property: xcb_atom_t,
type: xcb_atom_t,
format: u8,
pad0: [3]u8,
data_len: u32,
};
pub const xcb_change_property_request_t = struct_xcb_change_property_request_t;
pub const struct_xcb_delete_property_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
property: xcb_atom_t,
};
pub const xcb_delete_property_request_t = struct_xcb_delete_property_request_t;
pub const XCB_GET_PROPERTY_TYPE_ANY: c_int = 0;
pub const enum_xcb_get_property_type_t = c_uint;
pub const xcb_get_property_type_t = enum_xcb_get_property_type_t;
pub const struct_xcb_get_property_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_property_cookie_t = struct_xcb_get_property_cookie_t;
pub const struct_xcb_get_property_request_t = extern struct {
major_opcode: u8,
_delete: u8,
length: u16,
window: xcb_window_t,
property: xcb_atom_t,
type: xcb_atom_t,
long_offset: u32,
long_length: u32,
};
pub const xcb_get_property_request_t = struct_xcb_get_property_request_t;
pub const struct_xcb_get_property_reply_t = extern struct {
response_type: u8,
format: u8,
sequence: u16,
length: u32,
type: xcb_atom_t,
bytes_after: u32,
value_len: u32,
pad0: [12]u8,
};
pub const xcb_get_property_reply_t = struct_xcb_get_property_reply_t;
pub const struct_xcb_list_properties_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_properties_cookie_t = struct_xcb_list_properties_cookie_t;
pub const struct_xcb_list_properties_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_list_properties_request_t = struct_xcb_list_properties_request_t;
pub const struct_xcb_list_properties_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
atoms_len: u16,
pad1: [22]u8,
};
pub const xcb_list_properties_reply_t = struct_xcb_list_properties_reply_t;
pub const struct_xcb_set_selection_owner_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
owner: xcb_window_t,
selection: xcb_atom_t,
time: xcb_timestamp_t,
};
pub const xcb_set_selection_owner_request_t = struct_xcb_set_selection_owner_request_t;
pub const struct_xcb_get_selection_owner_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_selection_owner_cookie_t = struct_xcb_get_selection_owner_cookie_t;
pub const struct_xcb_get_selection_owner_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
selection: xcb_atom_t,
};
pub const xcb_get_selection_owner_request_t = struct_xcb_get_selection_owner_request_t;
pub const struct_xcb_get_selection_owner_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
owner: xcb_window_t,
};
pub const xcb_get_selection_owner_reply_t = struct_xcb_get_selection_owner_reply_t;
pub const struct_xcb_convert_selection_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
requestor: xcb_window_t,
selection: xcb_atom_t,
target: xcb_atom_t,
property: xcb_atom_t,
time: xcb_timestamp_t,
};
pub const xcb_convert_selection_request_t = struct_xcb_convert_selection_request_t;
pub const XCB_SEND_EVENT_DEST_POINTER_WINDOW: c_int = 0;
pub const XCB_SEND_EVENT_DEST_ITEM_FOCUS: c_int = 1;
pub const enum_xcb_send_event_dest_t = c_uint;
pub const xcb_send_event_dest_t = enum_xcb_send_event_dest_t;
pub const struct_xcb_send_event_request_t = extern struct {
major_opcode: u8,
propagate: u8,
length: u16,
destination: xcb_window_t,
event_mask: u32,
event: [32]u8,
};
pub const xcb_send_event_request_t = struct_xcb_send_event_request_t;
pub const XCB_GRAB_MODE_SYNC: c_int = 0;
pub const XCB_GRAB_MODE_ASYNC: c_int = 1;
pub const enum_xcb_grab_mode_t = c_uint;
pub const xcb_grab_mode_t = enum_xcb_grab_mode_t;
pub const XCB_GRAB_STATUS_SUCCESS: c_int = 0;
pub const XCB_GRAB_STATUS_ALREADY_GRABBED: c_int = 1;
pub const XCB_GRAB_STATUS_INVALID_TIME: c_int = 2;
pub const XCB_GRAB_STATUS_NOT_VIEWABLE: c_int = 3;
pub const XCB_GRAB_STATUS_FROZEN: c_int = 4;
pub const enum_xcb_grab_status_t = c_uint;
pub const xcb_grab_status_t = enum_xcb_grab_status_t;
pub const XCB_CURSOR_NONE: c_int = 0;
pub const enum_xcb_cursor_enum_t = c_uint;
pub const xcb_cursor_enum_t = enum_xcb_cursor_enum_t;
pub const struct_xcb_grab_pointer_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_grab_pointer_cookie_t = struct_xcb_grab_pointer_cookie_t;
pub const struct_xcb_grab_pointer_request_t = extern struct {
major_opcode: u8,
owner_events: u8,
length: u16,
grab_window: xcb_window_t,
event_mask: u16,
pointer_mode: u8,
keyboard_mode: u8,
confine_to: xcb_window_t,
cursor: xcb_cursor_t,
time: xcb_timestamp_t,
};
pub const xcb_grab_pointer_request_t = struct_xcb_grab_pointer_request_t;
pub const struct_xcb_grab_pointer_reply_t = extern struct {
response_type: u8,
status: u8,
sequence: u16,
length: u32,
};
pub const xcb_grab_pointer_reply_t = struct_xcb_grab_pointer_reply_t;
pub const struct_xcb_ungrab_pointer_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
time: xcb_timestamp_t,
};
pub const xcb_ungrab_pointer_request_t = struct_xcb_ungrab_pointer_request_t;
pub const XCB_BUTTON_INDEX_ANY: c_int = 0;
pub const XCB_BUTTON_INDEX_1: c_int = 1;
pub const XCB_BUTTON_INDEX_2: c_int = 2;
pub const XCB_BUTTON_INDEX_3: c_int = 3;
pub const XCB_BUTTON_INDEX_4: c_int = 4;
pub const XCB_BUTTON_INDEX_5: c_int = 5;
pub const enum_xcb_button_index_t = c_uint;
pub const xcb_button_index_t = enum_xcb_button_index_t;
pub const struct_xcb_grab_button_request_t = extern struct {
major_opcode: u8,
owner_events: u8,
length: u16,
grab_window: xcb_window_t,
event_mask: u16,
pointer_mode: u8,
keyboard_mode: u8,
confine_to: xcb_window_t,
cursor: xcb_cursor_t,
button: u8,
pad0: u8,
modifiers: u16,
};
pub const xcb_grab_button_request_t = struct_xcb_grab_button_request_t;
pub const struct_xcb_ungrab_button_request_t = extern struct {
major_opcode: u8,
button: u8,
length: u16,
grab_window: xcb_window_t,
modifiers: u16,
pad0: [2]u8,
};
pub const xcb_ungrab_button_request_t = struct_xcb_ungrab_button_request_t;
pub const struct_xcb_change_active_pointer_grab_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cursor: xcb_cursor_t,
time: xcb_timestamp_t,
event_mask: u16,
pad1: [2]u8,
};
pub const xcb_change_active_pointer_grab_request_t = struct_xcb_change_active_pointer_grab_request_t;
pub const struct_xcb_grab_keyboard_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_grab_keyboard_cookie_t = struct_xcb_grab_keyboard_cookie_t;
pub const struct_xcb_grab_keyboard_request_t = extern struct {
major_opcode: u8,
owner_events: u8,
length: u16,
grab_window: xcb_window_t,
time: xcb_timestamp_t,
pointer_mode: u8,
keyboard_mode: u8,
pad0: [2]u8,
};
pub const xcb_grab_keyboard_request_t = struct_xcb_grab_keyboard_request_t;
pub const struct_xcb_grab_keyboard_reply_t = extern struct {
response_type: u8,
status: u8,
sequence: u16,
length: u32,
};
pub const xcb_grab_keyboard_reply_t = struct_xcb_grab_keyboard_reply_t;
pub const struct_xcb_ungrab_keyboard_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
time: xcb_timestamp_t,
};
pub const xcb_ungrab_keyboard_request_t = struct_xcb_ungrab_keyboard_request_t;
pub const XCB_GRAB_ANY: c_int = 0;
pub const enum_xcb_grab_t = c_uint;
pub const xcb_grab_t = enum_xcb_grab_t;
pub const struct_xcb_grab_key_request_t = extern struct {
major_opcode: u8,
owner_events: u8,
length: u16,
grab_window: xcb_window_t,
modifiers: u16,
key: xcb_keycode_t,
pointer_mode: u8,
keyboard_mode: u8,
pad0: [3]u8,
};
pub const xcb_grab_key_request_t = struct_xcb_grab_key_request_t;
pub const struct_xcb_ungrab_key_request_t = extern struct {
major_opcode: u8,
key: xcb_keycode_t,
length: u16,
grab_window: xcb_window_t,
modifiers: u16,
pad0: [2]u8,
};
pub const xcb_ungrab_key_request_t = struct_xcb_ungrab_key_request_t;
pub const XCB_ALLOW_ASYNC_POINTER: c_int = 0;
pub const XCB_ALLOW_SYNC_POINTER: c_int = 1;
pub const XCB_ALLOW_REPLAY_POINTER: c_int = 2;
pub const XCB_ALLOW_ASYNC_KEYBOARD: c_int = 3;
pub const XCB_ALLOW_SYNC_KEYBOARD: c_int = 4;
pub const XCB_ALLOW_REPLAY_KEYBOARD: c_int = 5;
pub const XCB_ALLOW_ASYNC_BOTH: c_int = 6;
pub const XCB_ALLOW_SYNC_BOTH: c_int = 7;
pub const enum_xcb_allow_t = c_uint;
pub const xcb_allow_t = enum_xcb_allow_t;
pub const struct_xcb_allow_events_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
time: xcb_timestamp_t,
};
pub const xcb_allow_events_request_t = struct_xcb_allow_events_request_t;
pub const struct_xcb_grab_server_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_grab_server_request_t = struct_xcb_grab_server_request_t;
pub const struct_xcb_ungrab_server_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_ungrab_server_request_t = struct_xcb_ungrab_server_request_t;
pub const struct_xcb_query_pointer_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_pointer_cookie_t = struct_xcb_query_pointer_cookie_t;
pub const struct_xcb_query_pointer_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_query_pointer_request_t = struct_xcb_query_pointer_request_t;
pub const struct_xcb_query_pointer_reply_t = extern struct {
response_type: u8,
same_screen: u8,
sequence: u16,
length: u32,
root: xcb_window_t,
child: xcb_window_t,
root_x: i16,
root_y: i16,
win_x: i16,
win_y: i16,
mask: u16,
pad0: [2]u8,
};
pub const xcb_query_pointer_reply_t = struct_xcb_query_pointer_reply_t;
pub const struct_xcb_timecoord_t = extern struct {
time: xcb_timestamp_t,
x: i16,
y: i16,
};
pub const xcb_timecoord_t = struct_xcb_timecoord_t;
pub const struct_xcb_timecoord_iterator_t = extern struct {
data: [*c]xcb_timecoord_t,
rem: c_int,
index: c_int,
};
pub const xcb_timecoord_iterator_t = struct_xcb_timecoord_iterator_t;
pub const struct_xcb_get_motion_events_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_motion_events_cookie_t = struct_xcb_get_motion_events_cookie_t;
pub const struct_xcb_get_motion_events_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
start: xcb_timestamp_t,
stop: xcb_timestamp_t,
};
pub const xcb_get_motion_events_request_t = struct_xcb_get_motion_events_request_t;
pub const struct_xcb_get_motion_events_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
events_len: u32,
pad1: [20]u8,
};
pub const xcb_get_motion_events_reply_t = struct_xcb_get_motion_events_reply_t;
pub const struct_xcb_translate_coordinates_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_translate_coordinates_cookie_t = struct_xcb_translate_coordinates_cookie_t;
pub const struct_xcb_translate_coordinates_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
src_window: xcb_window_t,
dst_window: xcb_window_t,
src_x: i16,
src_y: i16,
};
pub const xcb_translate_coordinates_request_t = struct_xcb_translate_coordinates_request_t;
pub const struct_xcb_translate_coordinates_reply_t = extern struct {
response_type: u8,
same_screen: u8,
sequence: u16,
length: u32,
child: xcb_window_t,
dst_x: i16,
dst_y: i16,
};
pub const xcb_translate_coordinates_reply_t = struct_xcb_translate_coordinates_reply_t;
pub const struct_xcb_warp_pointer_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
src_window: xcb_window_t,
dst_window: xcb_window_t,
src_x: i16,
src_y: i16,
src_width: u16,
src_height: u16,
dst_x: i16,
dst_y: i16,
};
pub const xcb_warp_pointer_request_t = struct_xcb_warp_pointer_request_t;
pub const XCB_INPUT_FOCUS_NONE: c_int = 0;
pub const XCB_INPUT_FOCUS_POINTER_ROOT: c_int = 1;
pub const XCB_INPUT_FOCUS_PARENT: c_int = 2;
pub const XCB_INPUT_FOCUS_FOLLOW_KEYBOARD: c_int = 3;
pub const enum_xcb_input_focus_t = c_uint;
pub const xcb_input_focus_t = enum_xcb_input_focus_t;
pub const struct_xcb_set_input_focus_request_t = extern struct {
major_opcode: u8,
revert_to: u8,
length: u16,
focus: xcb_window_t,
time: xcb_timestamp_t,
};
pub const xcb_set_input_focus_request_t = struct_xcb_set_input_focus_request_t;
pub const struct_xcb_get_input_focus_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_input_focus_cookie_t = struct_xcb_get_input_focus_cookie_t;
pub const struct_xcb_get_input_focus_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_input_focus_request_t = struct_xcb_get_input_focus_request_t;
pub const struct_xcb_get_input_focus_reply_t = extern struct {
response_type: u8,
revert_to: u8,
sequence: u16,
length: u32,
focus: xcb_window_t,
};
pub const xcb_get_input_focus_reply_t = struct_xcb_get_input_focus_reply_t;
pub const struct_xcb_query_keymap_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_keymap_cookie_t = struct_xcb_query_keymap_cookie_t;
pub const struct_xcb_query_keymap_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_query_keymap_request_t = struct_xcb_query_keymap_request_t;
pub const struct_xcb_query_keymap_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
keys: [32]u8,
};
pub const xcb_query_keymap_reply_t = struct_xcb_query_keymap_reply_t;
pub const struct_xcb_open_font_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
fid: xcb_font_t,
name_len: u16,
pad1: [2]u8,
};
pub const xcb_open_font_request_t = struct_xcb_open_font_request_t;
pub const struct_xcb_close_font_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
font: xcb_font_t,
};
pub const xcb_close_font_request_t = struct_xcb_close_font_request_t;
pub const XCB_FONT_DRAW_LEFT_TO_RIGHT: c_int = 0;
pub const XCB_FONT_DRAW_RIGHT_TO_LEFT: c_int = 1;
pub const enum_xcb_font_draw_t = c_uint;
pub const xcb_font_draw_t = enum_xcb_font_draw_t;
pub const struct_xcb_fontprop_t = extern struct {
name: xcb_atom_t,
value: u32,
};
pub const xcb_fontprop_t = struct_xcb_fontprop_t;
pub const struct_xcb_fontprop_iterator_t = extern struct {
data: [*c]xcb_fontprop_t,
rem: c_int,
index: c_int,
};
pub const xcb_fontprop_iterator_t = struct_xcb_fontprop_iterator_t;
pub const struct_xcb_charinfo_t = extern struct {
left_side_bearing: i16,
right_side_bearing: i16,
character_width: i16,
ascent: i16,
descent: i16,
attributes: u16,
};
pub const xcb_charinfo_t = struct_xcb_charinfo_t;
pub const struct_xcb_charinfo_iterator_t = extern struct {
data: [*c]xcb_charinfo_t,
rem: c_int,
index: c_int,
};
pub const xcb_charinfo_iterator_t = struct_xcb_charinfo_iterator_t;
pub const struct_xcb_query_font_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_font_cookie_t = struct_xcb_query_font_cookie_t;
pub const struct_xcb_query_font_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
font: xcb_fontable_t,
};
pub const xcb_query_font_request_t = struct_xcb_query_font_request_t;
pub const struct_xcb_query_font_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
min_bounds: xcb_charinfo_t,
pad1: [4]u8,
max_bounds: xcb_charinfo_t,
pad2: [4]u8,
min_char_or_byte2: u16,
max_char_or_byte2: u16,
default_char: u16,
properties_len: u16,
draw_direction: u8,
min_byte1: u8,
max_byte1: u8,
all_chars_exist: u8,
font_ascent: i16,
font_descent: i16,
char_infos_len: u32,
};
pub const xcb_query_font_reply_t = struct_xcb_query_font_reply_t;
pub const struct_xcb_query_text_extents_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_text_extents_cookie_t = struct_xcb_query_text_extents_cookie_t;
pub const struct_xcb_query_text_extents_request_t = extern struct {
major_opcode: u8,
odd_length: u8,
length: u16,
font: xcb_fontable_t,
};
pub const xcb_query_text_extents_request_t = struct_xcb_query_text_extents_request_t;
pub const struct_xcb_query_text_extents_reply_t = extern struct {
response_type: u8,
draw_direction: u8,
sequence: u16,
length: u32,
font_ascent: i16,
font_descent: i16,
overall_ascent: i16,
overall_descent: i16,
overall_width: i32,
overall_left: i32,
overall_right: i32,
};
pub const xcb_query_text_extents_reply_t = struct_xcb_query_text_extents_reply_t;
pub const struct_xcb_str_t = extern struct {
name_len: u8,
};
pub const xcb_str_t = struct_xcb_str_t;
pub const struct_xcb_str_iterator_t = extern struct {
data: [*c]xcb_str_t,
rem: c_int,
index: c_int,
};
pub const xcb_str_iterator_t = struct_xcb_str_iterator_t;
pub const struct_xcb_list_fonts_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_fonts_cookie_t = struct_xcb_list_fonts_cookie_t;
pub const struct_xcb_list_fonts_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
max_names: u16,
pattern_len: u16,
};
pub const xcb_list_fonts_request_t = struct_xcb_list_fonts_request_t;
pub const struct_xcb_list_fonts_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
names_len: u16,
pad1: [22]u8,
};
pub const xcb_list_fonts_reply_t = struct_xcb_list_fonts_reply_t;
pub const struct_xcb_list_fonts_with_info_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_fonts_with_info_cookie_t = struct_xcb_list_fonts_with_info_cookie_t;
pub const struct_xcb_list_fonts_with_info_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
max_names: u16,
pattern_len: u16,
};
pub const xcb_list_fonts_with_info_request_t = struct_xcb_list_fonts_with_info_request_t;
pub const struct_xcb_list_fonts_with_info_reply_t = extern struct {
response_type: u8,
name_len: u8,
sequence: u16,
length: u32,
min_bounds: xcb_charinfo_t,
pad0: [4]u8,
max_bounds: xcb_charinfo_t,
pad1: [4]u8,
min_char_or_byte2: u16,
max_char_or_byte2: u16,
default_char: u16,
properties_len: u16,
draw_direction: u8,
min_byte1: u8,
max_byte1: u8,
all_chars_exist: u8,
font_ascent: i16,
font_descent: i16,
replies_hint: u32,
};
pub const xcb_list_fonts_with_info_reply_t = struct_xcb_list_fonts_with_info_reply_t;
pub const struct_xcb_set_font_path_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
font_qty: u16,
pad1: [2]u8,
};
pub const xcb_set_font_path_request_t = struct_xcb_set_font_path_request_t;
pub const struct_xcb_get_font_path_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_font_path_cookie_t = struct_xcb_get_font_path_cookie_t;
pub const struct_xcb_get_font_path_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_font_path_request_t = struct_xcb_get_font_path_request_t;
pub const struct_xcb_get_font_path_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
path_len: u16,
pad1: [22]u8,
};
pub const xcb_get_font_path_reply_t = struct_xcb_get_font_path_reply_t;
pub const struct_xcb_create_pixmap_request_t = extern struct {
major_opcode: u8,
depth: u8,
length: u16,
pid: xcb_pixmap_t,
drawable: xcb_drawable_t,
width: u16,
height: u16,
};
pub const xcb_create_pixmap_request_t = struct_xcb_create_pixmap_request_t;
pub const struct_xcb_free_pixmap_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
pixmap: xcb_pixmap_t,
};
pub const xcb_free_pixmap_request_t = struct_xcb_free_pixmap_request_t;
pub const XCB_GC_FUNCTION: c_int = 1;
pub const XCB_GC_PLANE_MASK: c_int = 2;
pub const XCB_GC_FOREGROUND: c_int = 4;
pub const XCB_GC_BACKGROUND: c_int = 8;
pub const XCB_GC_LINE_WIDTH: c_int = 16;
pub const XCB_GC_LINE_STYLE: c_int = 32;
pub const XCB_GC_CAP_STYLE: c_int = 64;
pub const XCB_GC_JOIN_STYLE: c_int = 128;
pub const XCB_GC_FILL_STYLE: c_int = 256;
pub const XCB_GC_FILL_RULE: c_int = 512;
pub const XCB_GC_TILE: c_int = 1024;
pub const XCB_GC_STIPPLE: c_int = 2048;
pub const XCB_GC_TILE_STIPPLE_ORIGIN_X: c_int = 4096;
pub const XCB_GC_TILE_STIPPLE_ORIGIN_Y: c_int = 8192;
pub const XCB_GC_FONT: c_int = 16384;
pub const XCB_GC_SUBWINDOW_MODE: c_int = 32768;
pub const XCB_GC_GRAPHICS_EXPOSURES: c_int = 65536;
pub const XCB_GC_CLIP_ORIGIN_X: c_int = 131072;
pub const XCB_GC_CLIP_ORIGIN_Y: c_int = 262144;
pub const XCB_GC_CLIP_MASK: c_int = 524288;
pub const XCB_GC_DASH_OFFSET: c_int = 1048576;
pub const XCB_GC_DASH_LIST: c_int = 2097152;
pub const XCB_GC_ARC_MODE: c_int = 4194304;
pub const enum_xcb_gc_t = c_uint;
pub const xcb_gc_t = enum_xcb_gc_t;
pub const XCB_GX_CLEAR: c_int = 0;
pub const XCB_GX_AND: c_int = 1;
pub const XCB_GX_AND_REVERSE: c_int = 2;
pub const XCB_GX_COPY: c_int = 3;
pub const XCB_GX_AND_INVERTED: c_int = 4;
pub const XCB_GX_NOOP: c_int = 5;
pub const XCB_GX_XOR: c_int = 6;
pub const XCB_GX_OR: c_int = 7;
pub const XCB_GX_NOR: c_int = 8;
pub const XCB_GX_EQUIV: c_int = 9;
pub const XCB_GX_INVERT: c_int = 10;
pub const XCB_GX_OR_REVERSE: c_int = 11;
pub const XCB_GX_COPY_INVERTED: c_int = 12;
pub const XCB_GX_OR_INVERTED: c_int = 13;
pub const XCB_GX_NAND: c_int = 14;
pub const XCB_GX_SET: c_int = 15;
pub const enum_xcb_gx_t = c_uint;
pub const xcb_gx_t = enum_xcb_gx_t;
pub const XCB_LINE_STYLE_SOLID: c_int = 0;
pub const XCB_LINE_STYLE_ON_OFF_DASH: c_int = 1;
pub const XCB_LINE_STYLE_DOUBLE_DASH: c_int = 2;
pub const enum_xcb_line_style_t = c_uint;
pub const xcb_line_style_t = enum_xcb_line_style_t;
pub const XCB_CAP_STYLE_NOT_LAST: c_int = 0;
pub const XCB_CAP_STYLE_BUTT: c_int = 1;
pub const XCB_CAP_STYLE_ROUND: c_int = 2;
pub const XCB_CAP_STYLE_PROJECTING: c_int = 3;
pub const enum_xcb_cap_style_t = c_uint;
pub const xcb_cap_style_t = enum_xcb_cap_style_t;
pub const XCB_JOIN_STYLE_MITER: c_int = 0;
pub const XCB_JOIN_STYLE_ROUND: c_int = 1;
pub const XCB_JOIN_STYLE_BEVEL: c_int = 2;
pub const enum_xcb_join_style_t = c_uint;
pub const xcb_join_style_t = enum_xcb_join_style_t;
pub const XCB_FILL_STYLE_SOLID: c_int = 0;
pub const XCB_FILL_STYLE_TILED: c_int = 1;
pub const XCB_FILL_STYLE_STIPPLED: c_int = 2;
pub const XCB_FILL_STYLE_OPAQUE_STIPPLED: c_int = 3;
pub const enum_xcb_fill_style_t = c_uint;
pub const xcb_fill_style_t = enum_xcb_fill_style_t;
pub const XCB_FILL_RULE_EVEN_ODD: c_int = 0;
pub const XCB_FILL_RULE_WINDING: c_int = 1;
pub const enum_xcb_fill_rule_t = c_uint;
pub const xcb_fill_rule_t = enum_xcb_fill_rule_t;
pub const XCB_SUBWINDOW_MODE_CLIP_BY_CHILDREN: c_int = 0;
pub const XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS: c_int = 1;
pub const enum_xcb_subwindow_mode_t = c_uint;
pub const xcb_subwindow_mode_t = enum_xcb_subwindow_mode_t;
pub const XCB_ARC_MODE_CHORD: c_int = 0;
pub const XCB_ARC_MODE_PIE_SLICE: c_int = 1;
pub const enum_xcb_arc_mode_t = c_uint;
pub const xcb_arc_mode_t = enum_xcb_arc_mode_t;
pub const struct_xcb_create_gc_value_list_t = extern struct {
function: u32,
plane_mask: u32,
foreground: u32,
background: u32,
line_width: u32,
line_style: u32,
cap_style: u32,
join_style: u32,
fill_style: u32,
fill_rule: u32,
tile: xcb_pixmap_t,
stipple: xcb_pixmap_t,
tile_stipple_x_origin: i32,
tile_stipple_y_origin: i32,
font: xcb_font_t,
subwindow_mode: u32,
graphics_exposures: xcb_bool32_t,
clip_x_origin: i32,
clip_y_origin: i32,
clip_mask: xcb_pixmap_t,
dash_offset: u32,
dashes: u32,
arc_mode: u32,
};
pub const xcb_create_gc_value_list_t = struct_xcb_create_gc_value_list_t;
pub const struct_xcb_create_gc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cid: xcb_gcontext_t,
drawable: xcb_drawable_t,
value_mask: u32,
};
pub const xcb_create_gc_request_t = struct_xcb_create_gc_request_t;
pub const struct_xcb_change_gc_value_list_t = extern struct {
function: u32,
plane_mask: u32,
foreground: u32,
background: u32,
line_width: u32,
line_style: u32,
cap_style: u32,
join_style: u32,
fill_style: u32,
fill_rule: u32,
tile: xcb_pixmap_t,
stipple: xcb_pixmap_t,
tile_stipple_x_origin: i32,
tile_stipple_y_origin: i32,
font: xcb_font_t,
subwindow_mode: u32,
graphics_exposures: xcb_bool32_t,
clip_x_origin: i32,
clip_y_origin: i32,
clip_mask: xcb_pixmap_t,
dash_offset: u32,
dashes: u32,
arc_mode: u32,
};
pub const xcb_change_gc_value_list_t = struct_xcb_change_gc_value_list_t;
pub const struct_xcb_change_gc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
gc: xcb_gcontext_t,
value_mask: u32,
};
pub const xcb_change_gc_request_t = struct_xcb_change_gc_request_t;
pub const struct_xcb_copy_gc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
src_gc: xcb_gcontext_t,
dst_gc: xcb_gcontext_t,
value_mask: u32,
};
pub const xcb_copy_gc_request_t = struct_xcb_copy_gc_request_t;
pub const struct_xcb_set_dashes_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
gc: xcb_gcontext_t,
dash_offset: u16,
dashes_len: u16,
};
pub const xcb_set_dashes_request_t = struct_xcb_set_dashes_request_t;
pub const XCB_CLIP_ORDERING_UNSORTED: c_int = 0;
pub const XCB_CLIP_ORDERING_Y_SORTED: c_int = 1;
pub const XCB_CLIP_ORDERING_YX_SORTED: c_int = 2;
pub const XCB_CLIP_ORDERING_YX_BANDED: c_int = 3;
pub const enum_xcb_clip_ordering_t = c_uint;
pub const xcb_clip_ordering_t = enum_xcb_clip_ordering_t;
pub const struct_xcb_set_clip_rectangles_request_t = extern struct {
major_opcode: u8,
ordering: u8,
length: u16,
gc: xcb_gcontext_t,
clip_x_origin: i16,
clip_y_origin: i16,
};
pub const xcb_set_clip_rectangles_request_t = struct_xcb_set_clip_rectangles_request_t;
pub const struct_xcb_free_gc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
gc: xcb_gcontext_t,
};
pub const xcb_free_gc_request_t = struct_xcb_free_gc_request_t;
pub const struct_xcb_clear_area_request_t = extern struct {
major_opcode: u8,
exposures: u8,
length: u16,
window: xcb_window_t,
x: i16,
y: i16,
width: u16,
height: u16,
};
pub const xcb_clear_area_request_t = struct_xcb_clear_area_request_t;
pub const struct_xcb_copy_area_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
src_drawable: xcb_drawable_t,
dst_drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
src_x: i16,
src_y: i16,
dst_x: i16,
dst_y: i16,
width: u16,
height: u16,
};
pub const xcb_copy_area_request_t = struct_xcb_copy_area_request_t;
pub const struct_xcb_copy_plane_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
src_drawable: xcb_drawable_t,
dst_drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
src_x: i16,
src_y: i16,
dst_x: i16,
dst_y: i16,
width: u16,
height: u16,
bit_plane: u32,
};
pub const xcb_copy_plane_request_t = struct_xcb_copy_plane_request_t;
pub const XCB_COORD_MODE_ORIGIN: c_int = 0;
pub const XCB_COORD_MODE_PREVIOUS: c_int = 1;
pub const enum_xcb_coord_mode_t = c_uint;
pub const xcb_coord_mode_t = enum_xcb_coord_mode_t;
pub const struct_xcb_poly_point_request_t = extern struct {
major_opcode: u8,
coordinate_mode: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_point_request_t = struct_xcb_poly_point_request_t;
pub const struct_xcb_poly_line_request_t = extern struct {
major_opcode: u8,
coordinate_mode: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_line_request_t = struct_xcb_poly_line_request_t;
pub const struct_xcb_segment_t = extern struct {
x1: i16,
y1: i16,
x2: i16,
y2: i16,
};
pub const xcb_segment_t = struct_xcb_segment_t;
pub const struct_xcb_segment_iterator_t = extern struct {
data: [*c]xcb_segment_t,
rem: c_int,
index: c_int,
};
pub const xcb_segment_iterator_t = struct_xcb_segment_iterator_t;
pub const struct_xcb_poly_segment_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_segment_request_t = struct_xcb_poly_segment_request_t;
pub const struct_xcb_poly_rectangle_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_rectangle_request_t = struct_xcb_poly_rectangle_request_t;
pub const struct_xcb_poly_arc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_arc_request_t = struct_xcb_poly_arc_request_t;
pub const XCB_POLY_SHAPE_COMPLEX: c_int = 0;
pub const XCB_POLY_SHAPE_NONCONVEX: c_int = 1;
pub const XCB_POLY_SHAPE_CONVEX: c_int = 2;
pub const enum_xcb_poly_shape_t = c_uint;
pub const xcb_poly_shape_t = enum_xcb_poly_shape_t;
pub const struct_xcb_fill_poly_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
shape: u8,
coordinate_mode: u8,
pad1: [2]u8,
};
pub const xcb_fill_poly_request_t = struct_xcb_fill_poly_request_t;
pub const struct_xcb_poly_fill_rectangle_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_fill_rectangle_request_t = struct_xcb_poly_fill_rectangle_request_t;
pub const struct_xcb_poly_fill_arc_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
};
pub const xcb_poly_fill_arc_request_t = struct_xcb_poly_fill_arc_request_t;
pub const XCB_IMAGE_FORMAT_XY_BITMAP: c_int = 0;
pub const XCB_IMAGE_FORMAT_XY_PIXMAP: c_int = 1;
pub const XCB_IMAGE_FORMAT_Z_PIXMAP: c_int = 2;
pub const enum_xcb_image_format_t = c_uint;
pub const xcb_image_format_t = enum_xcb_image_format_t;
pub const struct_xcb_put_image_request_t = extern struct {
major_opcode: u8,
format: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
width: u16,
height: u16,
dst_x: i16,
dst_y: i16,
left_pad: u8,
depth: u8,
pad0: [2]u8,
};
pub const xcb_put_image_request_t = struct_xcb_put_image_request_t;
pub const struct_xcb_get_image_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_image_cookie_t = struct_xcb_get_image_cookie_t;
pub const struct_xcb_get_image_request_t = extern struct {
major_opcode: u8,
format: u8,
length: u16,
drawable: xcb_drawable_t,
x: i16,
y: i16,
width: u16,
height: u16,
plane_mask: u32,
};
pub const xcb_get_image_request_t = struct_xcb_get_image_request_t;
pub const struct_xcb_get_image_reply_t = extern struct {
response_type: u8,
depth: u8,
sequence: u16,
length: u32,
visual: xcb_visualid_t,
pad0: [20]u8,
};
pub const xcb_get_image_reply_t = struct_xcb_get_image_reply_t;
pub const struct_xcb_poly_text_8_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
x: i16,
y: i16,
};
pub const xcb_poly_text_8_request_t = struct_xcb_poly_text_8_request_t;
pub const struct_xcb_poly_text_16_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
x: i16,
y: i16,
};
pub const xcb_poly_text_16_request_t = struct_xcb_poly_text_16_request_t;
pub const struct_xcb_image_text_8_request_t = extern struct {
major_opcode: u8,
string_len: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
x: i16,
y: i16,
};
pub const xcb_image_text_8_request_t = struct_xcb_image_text_8_request_t;
pub const struct_xcb_image_text_16_request_t = extern struct {
major_opcode: u8,
string_len: u8,
length: u16,
drawable: xcb_drawable_t,
gc: xcb_gcontext_t,
x: i16,
y: i16,
};
pub const xcb_image_text_16_request_t = struct_xcb_image_text_16_request_t;
pub const XCB_COLORMAP_ALLOC_NONE: c_int = 0;
pub const XCB_COLORMAP_ALLOC_ALL: c_int = 1;
pub const enum_xcb_colormap_alloc_t = c_uint;
pub const xcb_colormap_alloc_t = enum_xcb_colormap_alloc_t;
pub const struct_xcb_create_colormap_request_t = extern struct {
major_opcode: u8,
alloc: u8,
length: u16,
mid: xcb_colormap_t,
window: xcb_window_t,
visual: xcb_visualid_t,
};
pub const xcb_create_colormap_request_t = struct_xcb_create_colormap_request_t;
pub const struct_xcb_free_colormap_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
};
pub const xcb_free_colormap_request_t = struct_xcb_free_colormap_request_t;
pub const struct_xcb_copy_colormap_and_free_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
mid: xcb_colormap_t,
src_cmap: xcb_colormap_t,
};
pub const xcb_copy_colormap_and_free_request_t = struct_xcb_copy_colormap_and_free_request_t;
pub const struct_xcb_install_colormap_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
};
pub const xcb_install_colormap_request_t = struct_xcb_install_colormap_request_t;
pub const struct_xcb_uninstall_colormap_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
};
pub const xcb_uninstall_colormap_request_t = struct_xcb_uninstall_colormap_request_t;
pub const struct_xcb_list_installed_colormaps_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_installed_colormaps_cookie_t = struct_xcb_list_installed_colormaps_cookie_t;
pub const struct_xcb_list_installed_colormaps_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
};
pub const xcb_list_installed_colormaps_request_t = struct_xcb_list_installed_colormaps_request_t;
pub const struct_xcb_list_installed_colormaps_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
cmaps_len: u16,
pad1: [22]u8,
};
pub const xcb_list_installed_colormaps_reply_t = struct_xcb_list_installed_colormaps_reply_t;
pub const struct_xcb_alloc_color_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_alloc_color_cookie_t = struct_xcb_alloc_color_cookie_t;
pub const struct_xcb_alloc_color_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
red: u16,
green: u16,
blue: u16,
pad1: [2]u8,
};
pub const xcb_alloc_color_request_t = struct_xcb_alloc_color_request_t;
pub const struct_xcb_alloc_color_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
red: u16,
green: u16,
blue: u16,
pad1: [2]u8,
pixel: u32,
};
pub const xcb_alloc_color_reply_t = struct_xcb_alloc_color_reply_t;
pub const struct_xcb_alloc_named_color_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_alloc_named_color_cookie_t = struct_xcb_alloc_named_color_cookie_t;
pub const struct_xcb_alloc_named_color_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
name_len: u16,
pad1: [2]u8,
};
pub const xcb_alloc_named_color_request_t = struct_xcb_alloc_named_color_request_t;
pub const struct_xcb_alloc_named_color_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
pixel: u32,
exact_red: u16,
exact_green: u16,
exact_blue: u16,
visual_red: u16,
visual_green: u16,
visual_blue: u16,
};
pub const xcb_alloc_named_color_reply_t = struct_xcb_alloc_named_color_reply_t;
pub const struct_xcb_alloc_color_cells_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_alloc_color_cells_cookie_t = struct_xcb_alloc_color_cells_cookie_t;
pub const struct_xcb_alloc_color_cells_request_t = extern struct {
major_opcode: u8,
contiguous: u8,
length: u16,
cmap: xcb_colormap_t,
colors: u16,
planes: u16,
};
pub const xcb_alloc_color_cells_request_t = struct_xcb_alloc_color_cells_request_t;
pub const struct_xcb_alloc_color_cells_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
pixels_len: u16,
masks_len: u16,
pad1: [20]u8,
};
pub const xcb_alloc_color_cells_reply_t = struct_xcb_alloc_color_cells_reply_t;
pub const struct_xcb_alloc_color_planes_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_alloc_color_planes_cookie_t = struct_xcb_alloc_color_planes_cookie_t;
pub const struct_xcb_alloc_color_planes_request_t = extern struct {
major_opcode: u8,
contiguous: u8,
length: u16,
cmap: xcb_colormap_t,
colors: u16,
reds: u16,
greens: u16,
blues: u16,
};
pub const xcb_alloc_color_planes_request_t = struct_xcb_alloc_color_planes_request_t;
pub const struct_xcb_alloc_color_planes_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
pixels_len: u16,
pad1: [2]u8,
red_mask: u32,
green_mask: u32,
blue_mask: u32,
pad2: [8]u8,
};
pub const xcb_alloc_color_planes_reply_t = struct_xcb_alloc_color_planes_reply_t;
pub const struct_xcb_free_colors_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
plane_mask: u32,
};
pub const xcb_free_colors_request_t = struct_xcb_free_colors_request_t;
pub const XCB_COLOR_FLAG_RED: c_int = 1;
pub const XCB_COLOR_FLAG_GREEN: c_int = 2;
pub const XCB_COLOR_FLAG_BLUE: c_int = 4;
pub const enum_xcb_color_flag_t = c_uint;
pub const xcb_color_flag_t = enum_xcb_color_flag_t;
pub const struct_xcb_coloritem_t = extern struct {
pixel: u32,
red: u16,
green: u16,
blue: u16,
flags: u8,
pad0: u8,
};
pub const xcb_coloritem_t = struct_xcb_coloritem_t;
pub const struct_xcb_coloritem_iterator_t = extern struct {
data: [*c]xcb_coloritem_t,
rem: c_int,
index: c_int,
};
pub const xcb_coloritem_iterator_t = struct_xcb_coloritem_iterator_t;
pub const struct_xcb_store_colors_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
};
pub const xcb_store_colors_request_t = struct_xcb_store_colors_request_t;
pub const struct_xcb_store_named_color_request_t = extern struct {
major_opcode: u8,
flags: u8,
length: u16,
cmap: xcb_colormap_t,
pixel: u32,
name_len: u16,
pad0: [2]u8,
};
pub const xcb_store_named_color_request_t = struct_xcb_store_named_color_request_t;
pub const struct_xcb_rgb_t = extern struct {
red: u16,
green: u16,
blue: u16,
pad0: [2]u8,
};
pub const xcb_rgb_t = struct_xcb_rgb_t;
pub const struct_xcb_rgb_iterator_t = extern struct {
data: [*c]xcb_rgb_t,
rem: c_int,
index: c_int,
};
pub const xcb_rgb_iterator_t = struct_xcb_rgb_iterator_t;
pub const struct_xcb_query_colors_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_colors_cookie_t = struct_xcb_query_colors_cookie_t;
pub const struct_xcb_query_colors_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
};
pub const xcb_query_colors_request_t = struct_xcb_query_colors_request_t;
pub const struct_xcb_query_colors_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
colors_len: u16,
pad1: [22]u8,
};
pub const xcb_query_colors_reply_t = struct_xcb_query_colors_reply_t;
pub const struct_xcb_lookup_color_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_lookup_color_cookie_t = struct_xcb_lookup_color_cookie_t;
pub const struct_xcb_lookup_color_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cmap: xcb_colormap_t,
name_len: u16,
pad1: [2]u8,
};
pub const xcb_lookup_color_request_t = struct_xcb_lookup_color_request_t;
pub const struct_xcb_lookup_color_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
exact_red: u16,
exact_green: u16,
exact_blue: u16,
visual_red: u16,
visual_green: u16,
visual_blue: u16,
};
pub const xcb_lookup_color_reply_t = struct_xcb_lookup_color_reply_t;
pub const XCB_PIXMAP_NONE: c_int = 0;
pub const enum_xcb_pixmap_enum_t = c_uint;
pub const xcb_pixmap_enum_t = enum_xcb_pixmap_enum_t;
pub const struct_xcb_create_cursor_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cid: xcb_cursor_t,
source: xcb_pixmap_t,
mask: xcb_pixmap_t,
fore_red: u16,
fore_green: u16,
fore_blue: u16,
back_red: u16,
back_green: u16,
back_blue: u16,
x: u16,
y: u16,
};
pub const xcb_create_cursor_request_t = struct_xcb_create_cursor_request_t;
pub const XCB_FONT_NONE: c_int = 0;
pub const enum_xcb_font_enum_t = c_uint;
pub const xcb_font_enum_t = enum_xcb_font_enum_t;
pub const struct_xcb_create_glyph_cursor_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cid: xcb_cursor_t,
source_font: xcb_font_t,
mask_font: xcb_font_t,
source_char: u16,
mask_char: u16,
fore_red: u16,
fore_green: u16,
fore_blue: u16,
back_red: u16,
back_green: u16,
back_blue: u16,
};
pub const xcb_create_glyph_cursor_request_t = struct_xcb_create_glyph_cursor_request_t;
pub const struct_xcb_free_cursor_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cursor: xcb_cursor_t,
};
pub const xcb_free_cursor_request_t = struct_xcb_free_cursor_request_t;
pub const struct_xcb_recolor_cursor_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
cursor: xcb_cursor_t,
fore_red: u16,
fore_green: u16,
fore_blue: u16,
back_red: u16,
back_green: u16,
back_blue: u16,
};
pub const xcb_recolor_cursor_request_t = struct_xcb_recolor_cursor_request_t;
pub const XCB_QUERY_SHAPE_OF_LARGEST_CURSOR: c_int = 0;
pub const XCB_QUERY_SHAPE_OF_FASTEST_TILE: c_int = 1;
pub const XCB_QUERY_SHAPE_OF_FASTEST_STIPPLE: c_int = 2;
pub const enum_xcb_query_shape_of_t = c_uint;
pub const xcb_query_shape_of_t = enum_xcb_query_shape_of_t;
pub const struct_xcb_query_best_size_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_best_size_cookie_t = struct_xcb_query_best_size_cookie_t;
pub const struct_xcb_query_best_size_request_t = extern struct {
major_opcode: u8,
_class: u8,
length: u16,
drawable: xcb_drawable_t,
width: u16,
height: u16,
};
pub const xcb_query_best_size_request_t = struct_xcb_query_best_size_request_t;
pub const struct_xcb_query_best_size_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
width: u16,
height: u16,
};
pub const xcb_query_best_size_reply_t = struct_xcb_query_best_size_reply_t;
pub const struct_xcb_query_extension_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_query_extension_cookie_t = struct_xcb_query_extension_cookie_t;
pub const struct_xcb_query_extension_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
name_len: u16,
pad1: [2]u8,
};
pub const xcb_query_extension_request_t = struct_xcb_query_extension_request_t;
pub const struct_xcb_query_extension_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
present: u8,
major_opcode: u8,
first_event: u8,
first_error: u8,
};
pub const xcb_query_extension_reply_t = struct_xcb_query_extension_reply_t;
pub const struct_xcb_list_extensions_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_extensions_cookie_t = struct_xcb_list_extensions_cookie_t;
pub const struct_xcb_list_extensions_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_list_extensions_request_t = struct_xcb_list_extensions_request_t;
pub const struct_xcb_list_extensions_reply_t = extern struct {
response_type: u8,
names_len: u8,
sequence: u16,
length: u32,
pad0: [24]u8,
};
pub const xcb_list_extensions_reply_t = struct_xcb_list_extensions_reply_t;
pub const struct_xcb_change_keyboard_mapping_request_t = extern struct {
major_opcode: u8,
keycode_count: u8,
length: u16,
first_keycode: xcb_keycode_t,
keysyms_per_keycode: u8,
pad0: [2]u8,
};
pub const xcb_change_keyboard_mapping_request_t = struct_xcb_change_keyboard_mapping_request_t;
pub const struct_xcb_get_keyboard_mapping_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_keyboard_mapping_cookie_t = struct_xcb_get_keyboard_mapping_cookie_t;
pub const struct_xcb_get_keyboard_mapping_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
first_keycode: xcb_keycode_t,
count: u8,
};
pub const xcb_get_keyboard_mapping_request_t = struct_xcb_get_keyboard_mapping_request_t;
pub const struct_xcb_get_keyboard_mapping_reply_t = extern struct {
response_type: u8,
keysyms_per_keycode: u8,
sequence: u16,
length: u32,
pad0: [24]u8,
};
pub const xcb_get_keyboard_mapping_reply_t = struct_xcb_get_keyboard_mapping_reply_t;
pub const XCB_KB_KEY_CLICK_PERCENT: c_int = 1;
pub const XCB_KB_BELL_PERCENT: c_int = 2;
pub const XCB_KB_BELL_PITCH: c_int = 4;
pub const XCB_KB_BELL_DURATION: c_int = 8;
pub const XCB_KB_LED: c_int = 16;
pub const XCB_KB_LED_MODE: c_int = 32;
pub const XCB_KB_KEY: c_int = 64;
pub const XCB_KB_AUTO_REPEAT_MODE: c_int = 128;
pub const enum_xcb_kb_t = c_uint;
pub const xcb_kb_t = enum_xcb_kb_t;
pub const XCB_LED_MODE_OFF: c_int = 0;
pub const XCB_LED_MODE_ON: c_int = 1;
pub const enum_xcb_led_mode_t = c_uint;
pub const xcb_led_mode_t = enum_xcb_led_mode_t;
pub const XCB_AUTO_REPEAT_MODE_OFF: c_int = 0;
pub const XCB_AUTO_REPEAT_MODE_ON: c_int = 1;
pub const XCB_AUTO_REPEAT_MODE_DEFAULT: c_int = 2;
pub const enum_xcb_auto_repeat_mode_t = c_uint;
pub const xcb_auto_repeat_mode_t = enum_xcb_auto_repeat_mode_t;
pub const struct_xcb_change_keyboard_control_value_list_t = extern struct {
key_click_percent: i32,
bell_percent: i32,
bell_pitch: i32,
bell_duration: i32,
led: u32,
led_mode: u32,
key: xcb_keycode32_t,
auto_repeat_mode: u32,
};
pub const xcb_change_keyboard_control_value_list_t = struct_xcb_change_keyboard_control_value_list_t;
pub const struct_xcb_change_keyboard_control_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
value_mask: u32,
};
pub const xcb_change_keyboard_control_request_t = struct_xcb_change_keyboard_control_request_t;
pub const struct_xcb_get_keyboard_control_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_keyboard_control_cookie_t = struct_xcb_get_keyboard_control_cookie_t;
pub const struct_xcb_get_keyboard_control_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_keyboard_control_request_t = struct_xcb_get_keyboard_control_request_t;
pub const struct_xcb_get_keyboard_control_reply_t = extern struct {
response_type: u8,
global_auto_repeat: u8,
sequence: u16,
length: u32,
led_mask: u32,
key_click_percent: u8,
bell_percent: u8,
bell_pitch: u16,
bell_duration: u16,
pad0: [2]u8,
auto_repeats: [32]u8,
};
pub const xcb_get_keyboard_control_reply_t = struct_xcb_get_keyboard_control_reply_t;
pub const struct_xcb_bell_request_t = extern struct {
major_opcode: u8,
percent: i8,
length: u16,
};
pub const xcb_bell_request_t = struct_xcb_bell_request_t;
pub const struct_xcb_change_pointer_control_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
acceleration_numerator: i16,
acceleration_denominator: i16,
threshold: i16,
do_acceleration: u8,
do_threshold: u8,
};
pub const xcb_change_pointer_control_request_t = struct_xcb_change_pointer_control_request_t;
pub const struct_xcb_get_pointer_control_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_pointer_control_cookie_t = struct_xcb_get_pointer_control_cookie_t;
pub const struct_xcb_get_pointer_control_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_pointer_control_request_t = struct_xcb_get_pointer_control_request_t;
pub const struct_xcb_get_pointer_control_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
acceleration_numerator: u16,
acceleration_denominator: u16,
threshold: u16,
pad1: [18]u8,
};
pub const xcb_get_pointer_control_reply_t = struct_xcb_get_pointer_control_reply_t;
pub const XCB_BLANKING_NOT_PREFERRED: c_int = 0;
pub const XCB_BLANKING_PREFERRED: c_int = 1;
pub const XCB_BLANKING_DEFAULT: c_int = 2;
pub const enum_xcb_blanking_t = c_uint;
pub const xcb_blanking_t = enum_xcb_blanking_t;
pub const XCB_EXPOSURES_NOT_ALLOWED: c_int = 0;
pub const XCB_EXPOSURES_ALLOWED: c_int = 1;
pub const XCB_EXPOSURES_DEFAULT: c_int = 2;
pub const enum_xcb_exposures_t = c_uint;
pub const xcb_exposures_t = enum_xcb_exposures_t;
pub const struct_xcb_set_screen_saver_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
timeout: i16,
interval: i16,
prefer_blanking: u8,
allow_exposures: u8,
};
pub const xcb_set_screen_saver_request_t = struct_xcb_set_screen_saver_request_t;
pub const struct_xcb_get_screen_saver_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_screen_saver_cookie_t = struct_xcb_get_screen_saver_cookie_t;
pub const struct_xcb_get_screen_saver_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_screen_saver_request_t = struct_xcb_get_screen_saver_request_t;
pub const struct_xcb_get_screen_saver_reply_t = extern struct {
response_type: u8,
pad0: u8,
sequence: u16,
length: u32,
timeout: u16,
interval: u16,
prefer_blanking: u8,
allow_exposures: u8,
pad1: [18]u8,
};
pub const xcb_get_screen_saver_reply_t = struct_xcb_get_screen_saver_reply_t;
pub const XCB_HOST_MODE_INSERT: c_int = 0;
pub const XCB_HOST_MODE_DELETE: c_int = 1;
pub const enum_xcb_host_mode_t = c_uint;
pub const xcb_host_mode_t = enum_xcb_host_mode_t;
pub const XCB_FAMILY_INTERNET: c_int = 0;
pub const XCB_FAMILY_DECNET: c_int = 1;
pub const XCB_FAMILY_CHAOS: c_int = 2;
pub const XCB_FAMILY_SERVER_INTERPRETED: c_int = 5;
pub const XCB_FAMILY_INTERNET_6: c_int = 6;
pub const enum_xcb_family_t = c_uint;
pub const xcb_family_t = enum_xcb_family_t;
pub const struct_xcb_change_hosts_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
family: u8,
pad0: u8,
address_len: u16,
};
pub const xcb_change_hosts_request_t = struct_xcb_change_hosts_request_t;
pub const struct_xcb_host_t = extern struct {
family: u8,
pad0: u8,
address_len: u16,
};
pub const xcb_host_t = struct_xcb_host_t;
pub const struct_xcb_host_iterator_t = extern struct {
data: [*c]xcb_host_t,
rem: c_int,
index: c_int,
};
pub const xcb_host_iterator_t = struct_xcb_host_iterator_t;
pub const struct_xcb_list_hosts_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_list_hosts_cookie_t = struct_xcb_list_hosts_cookie_t;
pub const struct_xcb_list_hosts_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_list_hosts_request_t = struct_xcb_list_hosts_request_t;
pub const struct_xcb_list_hosts_reply_t = extern struct {
response_type: u8,
mode: u8,
sequence: u16,
length: u32,
hosts_len: u16,
pad0: [22]u8,
};
pub const xcb_list_hosts_reply_t = struct_xcb_list_hosts_reply_t;
pub const XCB_ACCESS_CONTROL_DISABLE: c_int = 0;
pub const XCB_ACCESS_CONTROL_ENABLE: c_int = 1;
pub const enum_xcb_access_control_t = c_uint;
pub const xcb_access_control_t = enum_xcb_access_control_t;
pub const struct_xcb_set_access_control_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
};
pub const xcb_set_access_control_request_t = struct_xcb_set_access_control_request_t;
pub const XCB_CLOSE_DOWN_DESTROY_ALL: c_int = 0;
pub const XCB_CLOSE_DOWN_RETAIN_PERMANENT: c_int = 1;
pub const XCB_CLOSE_DOWN_RETAIN_TEMPORARY: c_int = 2;
pub const enum_xcb_close_down_t = c_uint;
pub const xcb_close_down_t = enum_xcb_close_down_t;
pub const struct_xcb_set_close_down_mode_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
};
pub const xcb_set_close_down_mode_request_t = struct_xcb_set_close_down_mode_request_t;
pub const XCB_KILL_ALL_TEMPORARY: c_int = 0;
pub const enum_xcb_kill_t = c_uint;
pub const xcb_kill_t = enum_xcb_kill_t;
pub const struct_xcb_kill_client_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
resource: u32,
};
pub const xcb_kill_client_request_t = struct_xcb_kill_client_request_t;
pub const struct_xcb_rotate_properties_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
window: xcb_window_t,
atoms_len: u16,
delta: i16,
};
pub const xcb_rotate_properties_request_t = struct_xcb_rotate_properties_request_t;
pub const XCB_SCREEN_SAVER_RESET: c_int = 0;
pub const XCB_SCREEN_SAVER_ACTIVE: c_int = 1;
pub const enum_xcb_screen_saver_t = c_uint;
pub const xcb_screen_saver_t = enum_xcb_screen_saver_t;
pub const struct_xcb_force_screen_saver_request_t = extern struct {
major_opcode: u8,
mode: u8,
length: u16,
};
pub const xcb_force_screen_saver_request_t = struct_xcb_force_screen_saver_request_t;
pub const XCB_MAPPING_STATUS_SUCCESS: c_int = 0;
pub const XCB_MAPPING_STATUS_BUSY: c_int = 1;
pub const XCB_MAPPING_STATUS_FAILURE: c_int = 2;
pub const enum_xcb_mapping_status_t = c_uint;
pub const xcb_mapping_status_t = enum_xcb_mapping_status_t;
pub const struct_xcb_set_pointer_mapping_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_set_pointer_mapping_cookie_t = struct_xcb_set_pointer_mapping_cookie_t;
pub const struct_xcb_set_pointer_mapping_request_t = extern struct {
major_opcode: u8,
map_len: u8,
length: u16,
};
pub const xcb_set_pointer_mapping_request_t = struct_xcb_set_pointer_mapping_request_t;
pub const struct_xcb_set_pointer_mapping_reply_t = extern struct {
response_type: u8,
status: u8,
sequence: u16,
length: u32,
};
pub const xcb_set_pointer_mapping_reply_t = struct_xcb_set_pointer_mapping_reply_t;
pub const struct_xcb_get_pointer_mapping_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_pointer_mapping_cookie_t = struct_xcb_get_pointer_mapping_cookie_t;
pub const struct_xcb_get_pointer_mapping_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_pointer_mapping_request_t = struct_xcb_get_pointer_mapping_request_t;
pub const struct_xcb_get_pointer_mapping_reply_t = extern struct {
response_type: u8,
map_len: u8,
sequence: u16,
length: u32,
pad0: [24]u8,
};
pub const xcb_get_pointer_mapping_reply_t = struct_xcb_get_pointer_mapping_reply_t;
pub const XCB_MAP_INDEX_SHIFT: c_int = 0;
pub const XCB_MAP_INDEX_LOCK: c_int = 1;
pub const XCB_MAP_INDEX_CONTROL: c_int = 2;
pub const XCB_MAP_INDEX_1: c_int = 3;
pub const XCB_MAP_INDEX_2: c_int = 4;
pub const XCB_MAP_INDEX_3: c_int = 5;
pub const XCB_MAP_INDEX_4: c_int = 6;
pub const XCB_MAP_INDEX_5: c_int = 7;
pub const enum_xcb_map_index_t = c_uint;
pub const xcb_map_index_t = enum_xcb_map_index_t;
pub const struct_xcb_set_modifier_mapping_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_set_modifier_mapping_cookie_t = struct_xcb_set_modifier_mapping_cookie_t;
pub const struct_xcb_set_modifier_mapping_request_t = extern struct {
major_opcode: u8,
keycodes_per_modifier: u8,
length: u16,
};
pub const xcb_set_modifier_mapping_request_t = struct_xcb_set_modifier_mapping_request_t;
pub const struct_xcb_set_modifier_mapping_reply_t = extern struct {
response_type: u8,
status: u8,
sequence: u16,
length: u32,
};
pub const xcb_set_modifier_mapping_reply_t = struct_xcb_set_modifier_mapping_reply_t;
pub const struct_xcb_get_modifier_mapping_cookie_t = extern struct {
sequence: c_uint,
};
pub const xcb_get_modifier_mapping_cookie_t = struct_xcb_get_modifier_mapping_cookie_t;
pub const struct_xcb_get_modifier_mapping_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_get_modifier_mapping_request_t = struct_xcb_get_modifier_mapping_request_t;
pub const struct_xcb_get_modifier_mapping_reply_t = extern struct {
response_type: u8,
keycodes_per_modifier: u8,
sequence: u16,
length: u32,
pad0: [24]u8,
};
pub const xcb_get_modifier_mapping_reply_t = struct_xcb_get_modifier_mapping_reply_t;
pub const struct_xcb_no_operation_request_t = extern struct {
major_opcode: u8,
pad0: u8,
length: u16,
};
pub const xcb_no_operation_request_t = struct_xcb_no_operation_request_t;
pub extern fn xcb_char2b_next(i: [*c]xcb_char2b_iterator_t) void;
pub extern fn xcb_char2b_end(i: xcb_char2b_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_window_next(i: [*c]xcb_window_iterator_t) void;
pub extern fn xcb_window_end(i: xcb_window_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_pixmap_next(i: [*c]xcb_pixmap_iterator_t) void;
pub extern fn xcb_pixmap_end(i: xcb_pixmap_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_cursor_next(i: [*c]xcb_cursor_iterator_t) void;
pub extern fn xcb_cursor_end(i: xcb_cursor_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_font_next(i: [*c]xcb_font_iterator_t) void;
pub extern fn xcb_font_end(i: xcb_font_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_gcontext_next(i: [*c]xcb_gcontext_iterator_t) void;
pub extern fn xcb_gcontext_end(i: xcb_gcontext_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_colormap_next(i: [*c]xcb_colormap_iterator_t) void;
pub extern fn xcb_colormap_end(i: xcb_colormap_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_atom_next(i: [*c]xcb_atom_iterator_t) void;
pub extern fn xcb_atom_end(i: xcb_atom_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_drawable_next(i: [*c]xcb_drawable_iterator_t) void;
pub extern fn xcb_drawable_end(i: xcb_drawable_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_fontable_next(i: [*c]xcb_fontable_iterator_t) void;
pub extern fn xcb_fontable_end(i: xcb_fontable_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_bool32_next(i: [*c]xcb_bool32_iterator_t) void;
pub extern fn xcb_bool32_end(i: xcb_bool32_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_visualid_next(i: [*c]xcb_visualid_iterator_t) void;
pub extern fn xcb_visualid_end(i: xcb_visualid_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_timestamp_next(i: [*c]xcb_timestamp_iterator_t) void;
pub extern fn xcb_timestamp_end(i: xcb_timestamp_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_keysym_next(i: [*c]xcb_keysym_iterator_t) void;
pub extern fn xcb_keysym_end(i: xcb_keysym_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_keycode_next(i: [*c]xcb_keycode_iterator_t) void;
pub extern fn xcb_keycode_end(i: xcb_keycode_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_keycode32_next(i: [*c]xcb_keycode32_iterator_t) void;
pub extern fn xcb_keycode32_end(i: xcb_keycode32_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_button_next(i: [*c]xcb_button_iterator_t) void;
pub extern fn xcb_button_end(i: xcb_button_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_point_next(i: [*c]xcb_point_iterator_t) void;
pub extern fn xcb_point_end(i: xcb_point_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_rectangle_next(i: [*c]xcb_rectangle_iterator_t) void;
pub extern fn xcb_rectangle_end(i: xcb_rectangle_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_arc_next(i: [*c]xcb_arc_iterator_t) void;
pub extern fn xcb_arc_end(i: xcb_arc_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_format_next(i: [*c]xcb_format_iterator_t) void;
pub extern fn xcb_format_end(i: xcb_format_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_visualtype_next(i: [*c]xcb_visualtype_iterator_t) void;
pub extern fn xcb_visualtype_end(i: xcb_visualtype_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_depth_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_depth_visuals(R: [*c]const xcb_depth_t) [*c]xcb_visualtype_t;
pub extern fn xcb_depth_visuals_length(R: [*c]const xcb_depth_t) c_int;
pub extern fn xcb_depth_visuals_iterator(R: [*c]const xcb_depth_t) xcb_visualtype_iterator_t;
pub extern fn xcb_depth_next(i: [*c]xcb_depth_iterator_t) void;
pub extern fn xcb_depth_end(i: xcb_depth_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_screen_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_screen_allowed_depths_length(R: [*c]const xcb_screen_t) c_int;
pub extern fn xcb_screen_allowed_depths_iterator(R: [*c]const xcb_screen_t) xcb_depth_iterator_t;
pub extern fn xcb_screen_next(i: [*c]xcb_screen_iterator_t) void;
pub extern fn xcb_screen_end(i: xcb_screen_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_request_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_setup_request_authorization_protocol_name(R: [*c]const xcb_setup_request_t) [*c]u8;
pub extern fn xcb_setup_request_authorization_protocol_name_length(R: [*c]const xcb_setup_request_t) c_int;
pub extern fn xcb_setup_request_authorization_protocol_name_end(R: [*c]const xcb_setup_request_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_request_authorization_protocol_data(R: [*c]const xcb_setup_request_t) [*c]u8;
pub extern fn xcb_setup_request_authorization_protocol_data_length(R: [*c]const xcb_setup_request_t) c_int;
pub extern fn xcb_setup_request_authorization_protocol_data_end(R: [*c]const xcb_setup_request_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_request_next(i: [*c]xcb_setup_request_iterator_t) void;
pub extern fn xcb_setup_request_end(i: xcb_setup_request_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_failed_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_setup_failed_reason(R: [*c]const xcb_setup_failed_t) [*c]u8;
pub extern fn xcb_setup_failed_reason_length(R: [*c]const xcb_setup_failed_t) c_int;
pub extern fn xcb_setup_failed_reason_end(R: [*c]const xcb_setup_failed_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_failed_next(i: [*c]xcb_setup_failed_iterator_t) void;
pub extern fn xcb_setup_failed_end(i: xcb_setup_failed_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_authenticate_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_setup_authenticate_reason(R: [*c]const xcb_setup_authenticate_t) [*c]u8;
pub extern fn xcb_setup_authenticate_reason_length(R: [*c]const xcb_setup_authenticate_t) c_int;
pub extern fn xcb_setup_authenticate_reason_end(R: [*c]const xcb_setup_authenticate_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_authenticate_next(i: [*c]xcb_setup_authenticate_iterator_t) void;
pub extern fn xcb_setup_authenticate_end(i: xcb_setup_authenticate_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_setup_vendor(R: [*c]const xcb_setup_t) [*c]u8;
pub extern fn xcb_setup_vendor_length(R: [*c]const xcb_setup_t) c_int;
pub extern fn xcb_setup_vendor_end(R: [*c]const xcb_setup_t) xcb_generic_iterator_t;
pub extern fn xcb_setup_pixmap_formats(R: [*c]const xcb_setup_t) [*c]xcb_format_t;
pub extern fn xcb_setup_pixmap_formats_length(R: [*c]const xcb_setup_t) c_int;
pub extern fn xcb_setup_pixmap_formats_iterator(R: [*c]const xcb_setup_t) xcb_format_iterator_t;
pub extern fn xcb_setup_roots_length(R: [*c]const xcb_setup_t) c_int;
pub extern fn xcb_setup_roots_iterator(R: [*c]const xcb_setup_t) xcb_screen_iterator_t;
pub extern fn xcb_setup_next(i: [*c]xcb_setup_iterator_t) void;
pub extern fn xcb_setup_end(i: xcb_setup_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_client_message_data_next(i: [*c]xcb_client_message_data_iterator_t) void;
pub extern fn xcb_client_message_data_end(i: xcb_client_message_data_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_create_window_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u32, _aux: [*c]const xcb_create_window_value_list_t) c_int;
pub extern fn xcb_create_window_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u32, _aux: [*c]xcb_create_window_value_list_t) c_int;
pub extern fn xcb_create_window_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u32) c_int;
pub extern fn xcb_create_window_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_create_window_checked(c: ?*xcb_connection_t, depth: u8, wid: xcb_window_t, parent: xcb_window_t, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: u16, visual: xcb_visualid_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_create_window(c: ?*xcb_connection_t, depth: u8, wid: xcb_window_t, parent: xcb_window_t, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: u16, visual: xcb_visualid_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_create_window_aux_checked(c: ?*xcb_connection_t, depth: u8, wid: xcb_window_t, parent: xcb_window_t, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: u16, visual: xcb_visualid_t, value_mask: u32, value_list: [*c]const xcb_create_window_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_create_window_aux(c: ?*xcb_connection_t, depth: u8, wid: xcb_window_t, parent: xcb_window_t, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: u16, visual: xcb_visualid_t, value_mask: u32, value_list: [*c]const xcb_create_window_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_create_window_value_list(R: [*c]const xcb_create_window_request_t) ?*anyopaque;
pub extern fn xcb_change_window_attributes_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u32, _aux: [*c]const xcb_change_window_attributes_value_list_t) c_int;
pub extern fn xcb_change_window_attributes_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u32, _aux: [*c]xcb_change_window_attributes_value_list_t) c_int;
pub extern fn xcb_change_window_attributes_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u32) c_int;
pub extern fn xcb_change_window_attributes_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_window_attributes_checked(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_window_attributes(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_window_attributes_aux_checked(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u32, value_list: [*c]const xcb_change_window_attributes_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_window_attributes_aux(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u32, value_list: [*c]const xcb_change_window_attributes_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_window_attributes_value_list(R: [*c]const xcb_change_window_attributes_request_t) ?*anyopaque;
pub extern fn xcb_get_window_attributes(c: ?*xcb_connection_t, window: xcb_window_t) xcb_get_window_attributes_cookie_t;
pub extern fn xcb_get_window_attributes_unchecked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_get_window_attributes_cookie_t;
pub extern fn xcb_get_window_attributes_reply(c: ?*xcb_connection_t, cookie: xcb_get_window_attributes_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_window_attributes_reply_t;
pub extern fn xcb_destroy_window_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_destroy_window(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_destroy_subwindows_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_destroy_subwindows(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_change_save_set_checked(c: ?*xcb_connection_t, mode: u8, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_change_save_set(c: ?*xcb_connection_t, mode: u8, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_reparent_window_checked(c: ?*xcb_connection_t, window: xcb_window_t, parent: xcb_window_t, x: i16, y: i16) xcb_void_cookie_t;
pub extern fn xcb_reparent_window(c: ?*xcb_connection_t, window: xcb_window_t, parent: xcb_window_t, x: i16, y: i16) xcb_void_cookie_t;
pub extern fn xcb_map_window_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_map_window(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_map_subwindows_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_map_subwindows(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_unmap_window_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_unmap_window(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_unmap_subwindows_checked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_unmap_subwindows(c: ?*xcb_connection_t, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_configure_window_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u16, _aux: [*c]const xcb_configure_window_value_list_t) c_int;
pub extern fn xcb_configure_window_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u16, _aux: [*c]xcb_configure_window_value_list_t) c_int;
pub extern fn xcb_configure_window_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u16) c_int;
pub extern fn xcb_configure_window_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_configure_window_checked(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u16, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_configure_window(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u16, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_configure_window_aux_checked(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u16, value_list: [*c]const xcb_configure_window_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_configure_window_aux(c: ?*xcb_connection_t, window: xcb_window_t, value_mask: u16, value_list: [*c]const xcb_configure_window_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_configure_window_value_list(R: [*c]const xcb_configure_window_request_t) ?*anyopaque;
pub extern fn xcb_circulate_window_checked(c: ?*xcb_connection_t, direction: u8, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_circulate_window(c: ?*xcb_connection_t, direction: u8, window: xcb_window_t) xcb_void_cookie_t;
pub extern fn xcb_get_geometry(c: ?*xcb_connection_t, drawable: xcb_drawable_t) xcb_get_geometry_cookie_t;
pub extern fn xcb_get_geometry_unchecked(c: ?*xcb_connection_t, drawable: xcb_drawable_t) xcb_get_geometry_cookie_t;
pub extern fn xcb_get_geometry_reply(c: ?*xcb_connection_t, cookie: xcb_get_geometry_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_geometry_reply_t;
pub extern fn xcb_query_tree_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_query_tree(c: ?*xcb_connection_t, window: xcb_window_t) xcb_query_tree_cookie_t;
pub extern fn xcb_query_tree_unchecked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_query_tree_cookie_t;
pub extern fn xcb_query_tree_children(R: [*c]const xcb_query_tree_reply_t) [*c]xcb_window_t;
pub extern fn xcb_query_tree_children_length(R: [*c]const xcb_query_tree_reply_t) c_int;
pub extern fn xcb_query_tree_children_end(R: [*c]const xcb_query_tree_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_query_tree_reply(c: ?*xcb_connection_t, cookie: xcb_query_tree_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_tree_reply_t;
pub extern fn xcb_intern_atom_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_intern_atom(c: ?*xcb_connection_t, only_if_exists: u8, name_len: u16, name: [*c]const u8) xcb_intern_atom_cookie_t;
pub extern fn xcb_intern_atom_unchecked(c: ?*xcb_connection_t, only_if_exists: u8, name_len: u16, name: [*c]const u8) xcb_intern_atom_cookie_t;
pub extern fn xcb_intern_atom_reply(c: ?*xcb_connection_t, cookie: xcb_intern_atom_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_intern_atom_reply_t;
pub extern fn xcb_get_atom_name_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_atom_name(c: ?*xcb_connection_t, atom: xcb_atom_t) xcb_get_atom_name_cookie_t;
pub extern fn xcb_get_atom_name_unchecked(c: ?*xcb_connection_t, atom: xcb_atom_t) xcb_get_atom_name_cookie_t;
pub extern fn xcb_get_atom_name_name(R: [*c]const xcb_get_atom_name_reply_t) [*c]u8;
pub extern fn xcb_get_atom_name_name_length(R: [*c]const xcb_get_atom_name_reply_t) c_int;
pub extern fn xcb_get_atom_name_name_end(R: [*c]const xcb_get_atom_name_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_atom_name_reply(c: ?*xcb_connection_t, cookie: xcb_get_atom_name_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_atom_name_reply_t;
pub extern fn xcb_change_property_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_property_checked(c: ?*xcb_connection_t, mode: u8, window: xcb_window_t, property: xcb_atom_t, @"type": xcb_atom_t, format: u8, data_len: u32, data: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_property(c: ?*xcb_connection_t, mode: u8, window: xcb_window_t, property: xcb_atom_t, @"type": xcb_atom_t, format: u8, data_len: u32, data: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_property_data(R: [*c]const xcb_change_property_request_t) ?*anyopaque;
pub extern fn xcb_change_property_data_length(R: [*c]const xcb_change_property_request_t) c_int;
pub extern fn xcb_change_property_data_end(R: [*c]const xcb_change_property_request_t) xcb_generic_iterator_t;
pub extern fn xcb_delete_property_checked(c: ?*xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) xcb_void_cookie_t;
pub extern fn xcb_delete_property(c: ?*xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) xcb_void_cookie_t;
pub extern fn xcb_get_property_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_property(c: ?*xcb_connection_t, _delete: u8, window: xcb_window_t, property: xcb_atom_t, @"type": xcb_atom_t, long_offset: u32, long_length: u32) xcb_get_property_cookie_t;
pub extern fn xcb_get_property_unchecked(c: ?*xcb_connection_t, _delete: u8, window: xcb_window_t, property: xcb_atom_t, @"type": xcb_atom_t, long_offset: u32, long_length: u32) xcb_get_property_cookie_t;
pub extern fn xcb_get_property_value(R: [*c]const xcb_get_property_reply_t) ?*anyopaque;
pub extern fn xcb_get_property_value_length(R: [*c]const xcb_get_property_reply_t) c_int;
pub extern fn xcb_get_property_value_end(R: [*c]const xcb_get_property_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_property_reply(c: ?*xcb_connection_t, cookie: xcb_get_property_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_property_reply_t;
pub extern fn xcb_list_properties_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_properties(c: ?*xcb_connection_t, window: xcb_window_t) xcb_list_properties_cookie_t;
pub extern fn xcb_list_properties_unchecked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_list_properties_cookie_t;
pub extern fn xcb_list_properties_atoms(R: [*c]const xcb_list_properties_reply_t) [*c]xcb_atom_t;
pub extern fn xcb_list_properties_atoms_length(R: [*c]const xcb_list_properties_reply_t) c_int;
pub extern fn xcb_list_properties_atoms_end(R: [*c]const xcb_list_properties_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_list_properties_reply(c: ?*xcb_connection_t, cookie: xcb_list_properties_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_properties_reply_t;
pub extern fn xcb_set_selection_owner_checked(c: ?*xcb_connection_t, owner: xcb_window_t, selection: xcb_atom_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_set_selection_owner(c: ?*xcb_connection_t, owner: xcb_window_t, selection: xcb_atom_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_get_selection_owner(c: ?*xcb_connection_t, selection: xcb_atom_t) xcb_get_selection_owner_cookie_t;
pub extern fn xcb_get_selection_owner_unchecked(c: ?*xcb_connection_t, selection: xcb_atom_t) xcb_get_selection_owner_cookie_t;
pub extern fn xcb_get_selection_owner_reply(c: ?*xcb_connection_t, cookie: xcb_get_selection_owner_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_selection_owner_reply_t;
pub extern fn xcb_convert_selection_checked(c: ?*xcb_connection_t, requestor: xcb_window_t, selection: xcb_atom_t, target: xcb_atom_t, property: xcb_atom_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_convert_selection(c: ?*xcb_connection_t, requestor: xcb_window_t, selection: xcb_atom_t, target: xcb_atom_t, property: xcb_atom_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_send_event_checked(c: ?*xcb_connection_t, propagate: u8, destination: xcb_window_t, event_mask: u32, event: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_send_event(c: ?*xcb_connection_t, propagate: u8, destination: xcb_window_t, event_mask: u32, event: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_grab_pointer(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, event_mask: u16, pointer_mode: u8, keyboard_mode: u8, confine_to: xcb_window_t, cursor: xcb_cursor_t, time: xcb_timestamp_t) xcb_grab_pointer_cookie_t;
pub extern fn xcb_grab_pointer_unchecked(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, event_mask: u16, pointer_mode: u8, keyboard_mode: u8, confine_to: xcb_window_t, cursor: xcb_cursor_t, time: xcb_timestamp_t) xcb_grab_pointer_cookie_t;
pub extern fn xcb_grab_pointer_reply(c: ?*xcb_connection_t, cookie: xcb_grab_pointer_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_grab_pointer_reply_t;
pub extern fn xcb_ungrab_pointer_checked(c: ?*xcb_connection_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_ungrab_pointer(c: ?*xcb_connection_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_grab_button_checked(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, event_mask: u16, pointer_mode: u8, keyboard_mode: u8, confine_to: xcb_window_t, cursor: xcb_cursor_t, button: u8, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_grab_button(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, event_mask: u16, pointer_mode: u8, keyboard_mode: u8, confine_to: xcb_window_t, cursor: xcb_cursor_t, button: u8, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_ungrab_button_checked(c: ?*xcb_connection_t, button: u8, grab_window: xcb_window_t, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_ungrab_button(c: ?*xcb_connection_t, button: u8, grab_window: xcb_window_t, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_change_active_pointer_grab_checked(c: ?*xcb_connection_t, cursor: xcb_cursor_t, time: xcb_timestamp_t, event_mask: u16) xcb_void_cookie_t;
pub extern fn xcb_change_active_pointer_grab(c: ?*xcb_connection_t, cursor: xcb_cursor_t, time: xcb_timestamp_t, event_mask: u16) xcb_void_cookie_t;
pub extern fn xcb_grab_keyboard(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, time: xcb_timestamp_t, pointer_mode: u8, keyboard_mode: u8) xcb_grab_keyboard_cookie_t;
pub extern fn xcb_grab_keyboard_unchecked(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, time: xcb_timestamp_t, pointer_mode: u8, keyboard_mode: u8) xcb_grab_keyboard_cookie_t;
pub extern fn xcb_grab_keyboard_reply(c: ?*xcb_connection_t, cookie: xcb_grab_keyboard_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_grab_keyboard_reply_t;
pub extern fn xcb_ungrab_keyboard_checked(c: ?*xcb_connection_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_ungrab_keyboard(c: ?*xcb_connection_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_grab_key_checked(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, modifiers: u16, key: xcb_keycode_t, pointer_mode: u8, keyboard_mode: u8) xcb_void_cookie_t;
pub extern fn xcb_grab_key(c: ?*xcb_connection_t, owner_events: u8, grab_window: xcb_window_t, modifiers: u16, key: xcb_keycode_t, pointer_mode: u8, keyboard_mode: u8) xcb_void_cookie_t;
pub extern fn xcb_ungrab_key_checked(c: ?*xcb_connection_t, key: xcb_keycode_t, grab_window: xcb_window_t, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_ungrab_key(c: ?*xcb_connection_t, key: xcb_keycode_t, grab_window: xcb_window_t, modifiers: u16) xcb_void_cookie_t;
pub extern fn xcb_allow_events_checked(c: ?*xcb_connection_t, mode: u8, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_allow_events(c: ?*xcb_connection_t, mode: u8, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_grab_server_checked(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub extern fn xcb_grab_server(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub extern fn xcb_ungrab_server_checked(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub extern fn xcb_ungrab_server(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub extern fn xcb_query_pointer(c: ?*xcb_connection_t, window: xcb_window_t) xcb_query_pointer_cookie_t;
pub extern fn xcb_query_pointer_unchecked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_query_pointer_cookie_t;
pub extern fn xcb_query_pointer_reply(c: ?*xcb_connection_t, cookie: xcb_query_pointer_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_pointer_reply_t;
pub extern fn xcb_timecoord_next(i: [*c]xcb_timecoord_iterator_t) void;
pub extern fn xcb_timecoord_end(i: xcb_timecoord_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_get_motion_events_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_motion_events(c: ?*xcb_connection_t, window: xcb_window_t, start: xcb_timestamp_t, stop: xcb_timestamp_t) xcb_get_motion_events_cookie_t;
pub extern fn xcb_get_motion_events_unchecked(c: ?*xcb_connection_t, window: xcb_window_t, start: xcb_timestamp_t, stop: xcb_timestamp_t) xcb_get_motion_events_cookie_t;
pub extern fn xcb_get_motion_events_events(R: [*c]const xcb_get_motion_events_reply_t) [*c]xcb_timecoord_t;
pub extern fn xcb_get_motion_events_events_length(R: [*c]const xcb_get_motion_events_reply_t) c_int;
pub extern fn xcb_get_motion_events_events_iterator(R: [*c]const xcb_get_motion_events_reply_t) xcb_timecoord_iterator_t;
pub extern fn xcb_get_motion_events_reply(c: ?*xcb_connection_t, cookie: xcb_get_motion_events_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_motion_events_reply_t;
pub extern fn xcb_translate_coordinates(c: ?*xcb_connection_t, src_window: xcb_window_t, dst_window: xcb_window_t, src_x: i16, src_y: i16) xcb_translate_coordinates_cookie_t;
pub extern fn xcb_translate_coordinates_unchecked(c: ?*xcb_connection_t, src_window: xcb_window_t, dst_window: xcb_window_t, src_x: i16, src_y: i16) xcb_translate_coordinates_cookie_t;
pub extern fn xcb_translate_coordinates_reply(c: ?*xcb_connection_t, cookie: xcb_translate_coordinates_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_translate_coordinates_reply_t;
pub extern fn xcb_warp_pointer_checked(c: ?*xcb_connection_t, src_window: xcb_window_t, dst_window: xcb_window_t, src_x: i16, src_y: i16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16) xcb_void_cookie_t;
pub extern fn xcb_warp_pointer(c: ?*xcb_connection_t, src_window: xcb_window_t, dst_window: xcb_window_t, src_x: i16, src_y: i16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16) xcb_void_cookie_t;
pub extern fn xcb_set_input_focus_checked(c: ?*xcb_connection_t, revert_to: u8, focus: xcb_window_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_set_input_focus(c: ?*xcb_connection_t, revert_to: u8, focus: xcb_window_t, time: xcb_timestamp_t) xcb_void_cookie_t;
pub extern fn xcb_get_input_focus(c: ?*xcb_connection_t) xcb_get_input_focus_cookie_t;
pub extern fn xcb_get_input_focus_unchecked(c: ?*xcb_connection_t) xcb_get_input_focus_cookie_t;
pub extern fn xcb_get_input_focus_reply(c: ?*xcb_connection_t, cookie: xcb_get_input_focus_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_input_focus_reply_t;
pub extern fn xcb_query_keymap(c: ?*xcb_connection_t) xcb_query_keymap_cookie_t;
pub extern fn xcb_query_keymap_unchecked(c: ?*xcb_connection_t) xcb_query_keymap_cookie_t;
pub extern fn xcb_query_keymap_reply(c: ?*xcb_connection_t, cookie: xcb_query_keymap_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_keymap_reply_t;
pub extern fn xcb_open_font_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_open_font_checked(c: ?*xcb_connection_t, fid: xcb_font_t, name_len: u16, name: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_open_font(c: ?*xcb_connection_t, fid: xcb_font_t, name_len: u16, name: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_open_font_name(R: [*c]const xcb_open_font_request_t) [*c]u8;
pub extern fn xcb_open_font_name_length(R: [*c]const xcb_open_font_request_t) c_int;
pub extern fn xcb_open_font_name_end(R: [*c]const xcb_open_font_request_t) xcb_generic_iterator_t;
pub extern fn xcb_close_font_checked(c: ?*xcb_connection_t, font: xcb_font_t) xcb_void_cookie_t;
pub extern fn xcb_close_font(c: ?*xcb_connection_t, font: xcb_font_t) xcb_void_cookie_t;
pub extern fn xcb_fontprop_next(i: [*c]xcb_fontprop_iterator_t) void;
pub extern fn xcb_fontprop_end(i: xcb_fontprop_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_charinfo_next(i: [*c]xcb_charinfo_iterator_t) void;
pub extern fn xcb_charinfo_end(i: xcb_charinfo_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_query_font_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_query_font(c: ?*xcb_connection_t, font: xcb_fontable_t) xcb_query_font_cookie_t;
pub extern fn xcb_query_font_unchecked(c: ?*xcb_connection_t, font: xcb_fontable_t) xcb_query_font_cookie_t;
pub extern fn xcb_query_font_properties(R: [*c]const xcb_query_font_reply_t) [*c]xcb_fontprop_t;
pub extern fn xcb_query_font_properties_length(R: [*c]const xcb_query_font_reply_t) c_int;
pub extern fn xcb_query_font_properties_iterator(R: [*c]const xcb_query_font_reply_t) xcb_fontprop_iterator_t;
pub extern fn xcb_query_font_char_infos(R: [*c]const xcb_query_font_reply_t) [*c]xcb_charinfo_t;
pub extern fn xcb_query_font_char_infos_length(R: [*c]const xcb_query_font_reply_t) c_int;
pub extern fn xcb_query_font_char_infos_iterator(R: [*c]const xcb_query_font_reply_t) xcb_charinfo_iterator_t;
pub extern fn xcb_query_font_reply(c: ?*xcb_connection_t, cookie: xcb_query_font_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_font_reply_t;
pub extern fn xcb_query_text_extents_sizeof(_buffer: ?*const anyopaque, string_len: u32) c_int;
pub extern fn xcb_query_text_extents(c: ?*xcb_connection_t, font: xcb_fontable_t, string_len: u32, string: [*c]const xcb_char2b_t) xcb_query_text_extents_cookie_t;
pub extern fn xcb_query_text_extents_unchecked(c: ?*xcb_connection_t, font: xcb_fontable_t, string_len: u32, string: [*c]const xcb_char2b_t) xcb_query_text_extents_cookie_t;
pub extern fn xcb_query_text_extents_reply(c: ?*xcb_connection_t, cookie: xcb_query_text_extents_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_text_extents_reply_t;
pub extern fn xcb_str_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_str_name(R: [*c]const xcb_str_t) [*c]u8;
pub extern fn xcb_str_name_length(R: [*c]const xcb_str_t) c_int;
pub extern fn xcb_str_name_end(R: [*c]const xcb_str_t) xcb_generic_iterator_t;
pub extern fn xcb_str_next(i: [*c]xcb_str_iterator_t) void;
pub extern fn xcb_str_end(i: xcb_str_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_list_fonts_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_fonts(c: ?*xcb_connection_t, max_names: u16, pattern_len: u16, pattern: [*c]const u8) xcb_list_fonts_cookie_t;
pub extern fn xcb_list_fonts_unchecked(c: ?*xcb_connection_t, max_names: u16, pattern_len: u16, pattern: [*c]const u8) xcb_list_fonts_cookie_t;
pub extern fn xcb_list_fonts_names_length(R: [*c]const xcb_list_fonts_reply_t) c_int;
pub extern fn xcb_list_fonts_names_iterator(R: [*c]const xcb_list_fonts_reply_t) xcb_str_iterator_t;
pub extern fn xcb_list_fonts_reply(c: ?*xcb_connection_t, cookie: xcb_list_fonts_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_fonts_reply_t;
pub extern fn xcb_list_fonts_with_info_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_fonts_with_info(c: ?*xcb_connection_t, max_names: u16, pattern_len: u16, pattern: [*c]const u8) xcb_list_fonts_with_info_cookie_t;
pub extern fn xcb_list_fonts_with_info_unchecked(c: ?*xcb_connection_t, max_names: u16, pattern_len: u16, pattern: [*c]const u8) xcb_list_fonts_with_info_cookie_t;
pub extern fn xcb_list_fonts_with_info_properties(R: [*c]const xcb_list_fonts_with_info_reply_t) [*c]xcb_fontprop_t;
pub extern fn xcb_list_fonts_with_info_properties_length(R: [*c]const xcb_list_fonts_with_info_reply_t) c_int;
pub extern fn xcb_list_fonts_with_info_properties_iterator(R: [*c]const xcb_list_fonts_with_info_reply_t) xcb_fontprop_iterator_t;
pub extern fn xcb_list_fonts_with_info_name(R: [*c]const xcb_list_fonts_with_info_reply_t) [*c]u8;
pub extern fn xcb_list_fonts_with_info_name_length(R: [*c]const xcb_list_fonts_with_info_reply_t) c_int;
pub extern fn xcb_list_fonts_with_info_name_end(R: [*c]const xcb_list_fonts_with_info_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_list_fonts_with_info_reply(c: ?*xcb_connection_t, cookie: xcb_list_fonts_with_info_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_fonts_with_info_reply_t;
pub extern fn xcb_set_font_path_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_set_font_path_checked(c: ?*xcb_connection_t, font_qty: u16, font: [*c]const xcb_str_t) xcb_void_cookie_t;
pub extern fn xcb_set_font_path(c: ?*xcb_connection_t, font_qty: u16, font: [*c]const xcb_str_t) xcb_void_cookie_t;
pub extern fn xcb_set_font_path_font_length(R: [*c]const xcb_set_font_path_request_t) c_int;
pub extern fn xcb_set_font_path_font_iterator(R: [*c]const xcb_set_font_path_request_t) xcb_str_iterator_t;
pub extern fn xcb_get_font_path_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_font_path(c: ?*xcb_connection_t) xcb_get_font_path_cookie_t;
pub extern fn xcb_get_font_path_unchecked(c: ?*xcb_connection_t) xcb_get_font_path_cookie_t;
pub extern fn xcb_get_font_path_path_length(R: [*c]const xcb_get_font_path_reply_t) c_int;
pub extern fn xcb_get_font_path_path_iterator(R: [*c]const xcb_get_font_path_reply_t) xcb_str_iterator_t;
pub extern fn xcb_get_font_path_reply(c: ?*xcb_connection_t, cookie: xcb_get_font_path_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_font_path_reply_t;
pub extern fn xcb_create_pixmap_checked(c: ?*xcb_connection_t, depth: u8, pid: xcb_pixmap_t, drawable: xcb_drawable_t, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_create_pixmap(c: ?*xcb_connection_t, depth: u8, pid: xcb_pixmap_t, drawable: xcb_drawable_t, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_free_pixmap_checked(c: ?*xcb_connection_t, pixmap: xcb_pixmap_t) xcb_void_cookie_t;
pub extern fn xcb_free_pixmap(c: ?*xcb_connection_t, pixmap: xcb_pixmap_t) xcb_void_cookie_t;
pub extern fn xcb_create_gc_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u32, _aux: [*c]const xcb_create_gc_value_list_t) c_int;
pub extern fn xcb_create_gc_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u32, _aux: [*c]xcb_create_gc_value_list_t) c_int;
pub extern fn xcb_create_gc_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u32) c_int;
pub extern fn xcb_create_gc_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_create_gc_checked(c: ?*xcb_connection_t, cid: xcb_gcontext_t, drawable: xcb_drawable_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_create_gc(c: ?*xcb_connection_t, cid: xcb_gcontext_t, drawable: xcb_drawable_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_create_gc_aux_checked(c: ?*xcb_connection_t, cid: xcb_gcontext_t, drawable: xcb_drawable_t, value_mask: u32, value_list: [*c]const xcb_create_gc_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_create_gc_aux(c: ?*xcb_connection_t, cid: xcb_gcontext_t, drawable: xcb_drawable_t, value_mask: u32, value_list: [*c]const xcb_create_gc_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_create_gc_value_list(R: [*c]const xcb_create_gc_request_t) ?*anyopaque;
pub extern fn xcb_change_gc_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u32, _aux: [*c]const xcb_change_gc_value_list_t) c_int;
pub extern fn xcb_change_gc_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u32, _aux: [*c]xcb_change_gc_value_list_t) c_int;
pub extern fn xcb_change_gc_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u32) c_int;
pub extern fn xcb_change_gc_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_gc_checked(c: ?*xcb_connection_t, gc: xcb_gcontext_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_gc(c: ?*xcb_connection_t, gc: xcb_gcontext_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_gc_aux_checked(c: ?*xcb_connection_t, gc: xcb_gcontext_t, value_mask: u32, value_list: [*c]const xcb_change_gc_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_gc_aux(c: ?*xcb_connection_t, gc: xcb_gcontext_t, value_mask: u32, value_list: [*c]const xcb_change_gc_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_gc_value_list(R: [*c]const xcb_change_gc_request_t) ?*anyopaque;
pub extern fn xcb_copy_gc_checked(c: ?*xcb_connection_t, src_gc: xcb_gcontext_t, dst_gc: xcb_gcontext_t, value_mask: u32) xcb_void_cookie_t;
pub extern fn xcb_copy_gc(c: ?*xcb_connection_t, src_gc: xcb_gcontext_t, dst_gc: xcb_gcontext_t, value_mask: u32) xcb_void_cookie_t;
pub extern fn xcb_set_dashes_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_set_dashes_checked(c: ?*xcb_connection_t, gc: xcb_gcontext_t, dash_offset: u16, dashes_len: u16, dashes: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_set_dashes(c: ?*xcb_connection_t, gc: xcb_gcontext_t, dash_offset: u16, dashes_len: u16, dashes: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_set_dashes_dashes(R: [*c]const xcb_set_dashes_request_t) [*c]u8;
pub extern fn xcb_set_dashes_dashes_length(R: [*c]const xcb_set_dashes_request_t) c_int;
pub extern fn xcb_set_dashes_dashes_end(R: [*c]const xcb_set_dashes_request_t) xcb_generic_iterator_t;
pub extern fn xcb_set_clip_rectangles_sizeof(_buffer: ?*const anyopaque, rectangles_len: u32) c_int;
pub extern fn xcb_set_clip_rectangles_checked(c: ?*xcb_connection_t, ordering: u8, gc: xcb_gcontext_t, clip_x_origin: i16, clip_y_origin: i16, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_set_clip_rectangles(c: ?*xcb_connection_t, ordering: u8, gc: xcb_gcontext_t, clip_x_origin: i16, clip_y_origin: i16, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_set_clip_rectangles_rectangles(R: [*c]const xcb_set_clip_rectangles_request_t) [*c]xcb_rectangle_t;
pub extern fn xcb_set_clip_rectangles_rectangles_length(R: [*c]const xcb_set_clip_rectangles_request_t) c_int;
pub extern fn xcb_set_clip_rectangles_rectangles_iterator(R: [*c]const xcb_set_clip_rectangles_request_t) xcb_rectangle_iterator_t;
pub extern fn xcb_free_gc_checked(c: ?*xcb_connection_t, gc: xcb_gcontext_t) xcb_void_cookie_t;
pub extern fn xcb_free_gc(c: ?*xcb_connection_t, gc: xcb_gcontext_t) xcb_void_cookie_t;
pub extern fn xcb_clear_area_checked(c: ?*xcb_connection_t, exposures: u8, window: xcb_window_t, x: i16, y: i16, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_clear_area(c: ?*xcb_connection_t, exposures: u8, window: xcb_window_t, x: i16, y: i16, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_copy_area_checked(c: ?*xcb_connection_t, src_drawable: xcb_drawable_t, dst_drawable: xcb_drawable_t, gc: xcb_gcontext_t, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_copy_area(c: ?*xcb_connection_t, src_drawable: xcb_drawable_t, dst_drawable: xcb_drawable_t, gc: xcb_gcontext_t, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) xcb_void_cookie_t;
pub extern fn xcb_copy_plane_checked(c: ?*xcb_connection_t, src_drawable: xcb_drawable_t, dst_drawable: xcb_drawable_t, gc: xcb_gcontext_t, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16, bit_plane: u32) xcb_void_cookie_t;
pub extern fn xcb_copy_plane(c: ?*xcb_connection_t, src_drawable: xcb_drawable_t, dst_drawable: xcb_drawable_t, gc: xcb_gcontext_t, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16, bit_plane: u32) xcb_void_cookie_t;
pub extern fn xcb_poly_point_sizeof(_buffer: ?*const anyopaque, points_len: u32) c_int;
pub extern fn xcb_poly_point_checked(c: ?*xcb_connection_t, coordinate_mode: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_poly_point(c: ?*xcb_connection_t, coordinate_mode: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_poly_point_points(R: [*c]const xcb_poly_point_request_t) [*c]xcb_point_t;
pub extern fn xcb_poly_point_points_length(R: [*c]const xcb_poly_point_request_t) c_int;
pub extern fn xcb_poly_point_points_iterator(R: [*c]const xcb_poly_point_request_t) xcb_point_iterator_t;
pub extern fn xcb_poly_line_sizeof(_buffer: ?*const anyopaque, points_len: u32) c_int;
pub extern fn xcb_poly_line_checked(c: ?*xcb_connection_t, coordinate_mode: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_poly_line(c: ?*xcb_connection_t, coordinate_mode: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_poly_line_points(R: [*c]const xcb_poly_line_request_t) [*c]xcb_point_t;
pub extern fn xcb_poly_line_points_length(R: [*c]const xcb_poly_line_request_t) c_int;
pub extern fn xcb_poly_line_points_iterator(R: [*c]const xcb_poly_line_request_t) xcb_point_iterator_t;
pub extern fn xcb_segment_next(i: [*c]xcb_segment_iterator_t) void;
pub extern fn xcb_segment_end(i: xcb_segment_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_poly_segment_sizeof(_buffer: ?*const anyopaque, segments_len: u32) c_int;
pub extern fn xcb_poly_segment_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, segments_len: u32, segments: [*c]const xcb_segment_t) xcb_void_cookie_t;
pub extern fn xcb_poly_segment(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, segments_len: u32, segments: [*c]const xcb_segment_t) xcb_void_cookie_t;
pub extern fn xcb_poly_segment_segments(R: [*c]const xcb_poly_segment_request_t) [*c]xcb_segment_t;
pub extern fn xcb_poly_segment_segments_length(R: [*c]const xcb_poly_segment_request_t) c_int;
pub extern fn xcb_poly_segment_segments_iterator(R: [*c]const xcb_poly_segment_request_t) xcb_segment_iterator_t;
pub extern fn xcb_poly_rectangle_sizeof(_buffer: ?*const anyopaque, rectangles_len: u32) c_int;
pub extern fn xcb_poly_rectangle_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_poly_rectangle(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_poly_rectangle_rectangles(R: [*c]const xcb_poly_rectangle_request_t) [*c]xcb_rectangle_t;
pub extern fn xcb_poly_rectangle_rectangles_length(R: [*c]const xcb_poly_rectangle_request_t) c_int;
pub extern fn xcb_poly_rectangle_rectangles_iterator(R: [*c]const xcb_poly_rectangle_request_t) xcb_rectangle_iterator_t;
pub extern fn xcb_poly_arc_sizeof(_buffer: ?*const anyopaque, arcs_len: u32) c_int;
pub extern fn xcb_poly_arc_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, arcs_len: u32, arcs: [*c]const xcb_arc_t) xcb_void_cookie_t;
pub extern fn xcb_poly_arc(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, arcs_len: u32, arcs: [*c]const xcb_arc_t) xcb_void_cookie_t;
pub extern fn xcb_poly_arc_arcs(R: [*c]const xcb_poly_arc_request_t) [*c]xcb_arc_t;
pub extern fn xcb_poly_arc_arcs_length(R: [*c]const xcb_poly_arc_request_t) c_int;
pub extern fn xcb_poly_arc_arcs_iterator(R: [*c]const xcb_poly_arc_request_t) xcb_arc_iterator_t;
pub extern fn xcb_fill_poly_sizeof(_buffer: ?*const anyopaque, points_len: u32) c_int;
pub extern fn xcb_fill_poly_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, shape: u8, coordinate_mode: u8, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_fill_poly(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, shape: u8, coordinate_mode: u8, points_len: u32, points: [*c]const xcb_point_t) xcb_void_cookie_t;
pub extern fn xcb_fill_poly_points(R: [*c]const xcb_fill_poly_request_t) [*c]xcb_point_t;
pub extern fn xcb_fill_poly_points_length(R: [*c]const xcb_fill_poly_request_t) c_int;
pub extern fn xcb_fill_poly_points_iterator(R: [*c]const xcb_fill_poly_request_t) xcb_point_iterator_t;
pub extern fn xcb_poly_fill_rectangle_sizeof(_buffer: ?*const anyopaque, rectangles_len: u32) c_int;
pub extern fn xcb_poly_fill_rectangle_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_poly_fill_rectangle(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, rectangles_len: u32, rectangles: [*c]const xcb_rectangle_t) xcb_void_cookie_t;
pub extern fn xcb_poly_fill_rectangle_rectangles(R: [*c]const xcb_poly_fill_rectangle_request_t) [*c]xcb_rectangle_t;
pub extern fn xcb_poly_fill_rectangle_rectangles_length(R: [*c]const xcb_poly_fill_rectangle_request_t) c_int;
pub extern fn xcb_poly_fill_rectangle_rectangles_iterator(R: [*c]const xcb_poly_fill_rectangle_request_t) xcb_rectangle_iterator_t;
pub extern fn xcb_poly_fill_arc_sizeof(_buffer: ?*const anyopaque, arcs_len: u32) c_int;
pub extern fn xcb_poly_fill_arc_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, arcs_len: u32, arcs: [*c]const xcb_arc_t) xcb_void_cookie_t;
pub extern fn xcb_poly_fill_arc(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, arcs_len: u32, arcs: [*c]const xcb_arc_t) xcb_void_cookie_t;
pub extern fn xcb_poly_fill_arc_arcs(R: [*c]const xcb_poly_fill_arc_request_t) [*c]xcb_arc_t;
pub extern fn xcb_poly_fill_arc_arcs_length(R: [*c]const xcb_poly_fill_arc_request_t) c_int;
pub extern fn xcb_poly_fill_arc_arcs_iterator(R: [*c]const xcb_poly_fill_arc_request_t) xcb_arc_iterator_t;
pub extern fn xcb_put_image_sizeof(_buffer: ?*const anyopaque, data_len: u32) c_int;
pub extern fn xcb_put_image_checked(c: ?*xcb_connection_t, format: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, width: u16, height: u16, dst_x: i16, dst_y: i16, left_pad: u8, depth: u8, data_len: u32, data: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_put_image(c: ?*xcb_connection_t, format: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, width: u16, height: u16, dst_x: i16, dst_y: i16, left_pad: u8, depth: u8, data_len: u32, data: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_put_image_data(R: [*c]const xcb_put_image_request_t) [*c]u8;
pub extern fn xcb_put_image_data_length(R: [*c]const xcb_put_image_request_t) c_int;
pub extern fn xcb_put_image_data_end(R: [*c]const xcb_put_image_request_t) xcb_generic_iterator_t;
pub extern fn xcb_get_image_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_image(c: ?*xcb_connection_t, format: u8, drawable: xcb_drawable_t, x: i16, y: i16, width: u16, height: u16, plane_mask: u32) xcb_get_image_cookie_t;
pub extern fn xcb_get_image_unchecked(c: ?*xcb_connection_t, format: u8, drawable: xcb_drawable_t, x: i16, y: i16, width: u16, height: u16, plane_mask: u32) xcb_get_image_cookie_t;
pub extern fn xcb_get_image_data(R: [*c]const xcb_get_image_reply_t) [*c]u8;
pub extern fn xcb_get_image_data_length(R: [*c]const xcb_get_image_reply_t) c_int;
pub extern fn xcb_get_image_data_end(R: [*c]const xcb_get_image_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_image_reply(c: ?*xcb_connection_t, cookie: xcb_get_image_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_image_reply_t;
pub extern fn xcb_poly_text_8_sizeof(_buffer: ?*const anyopaque, items_len: u32) c_int;
pub extern fn xcb_poly_text_8_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, items_len: u32, items: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_poly_text_8(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, items_len: u32, items: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_poly_text_8_items(R: [*c]const xcb_poly_text_8_request_t) [*c]u8;
pub extern fn xcb_poly_text_8_items_length(R: [*c]const xcb_poly_text_8_request_t) c_int;
pub extern fn xcb_poly_text_8_items_end(R: [*c]const xcb_poly_text_8_request_t) xcb_generic_iterator_t;
pub extern fn xcb_poly_text_16_sizeof(_buffer: ?*const anyopaque, items_len: u32) c_int;
pub extern fn xcb_poly_text_16_checked(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, items_len: u32, items: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_poly_text_16(c: ?*xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, items_len: u32, items: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_poly_text_16_items(R: [*c]const xcb_poly_text_16_request_t) [*c]u8;
pub extern fn xcb_poly_text_16_items_length(R: [*c]const xcb_poly_text_16_request_t) c_int;
pub extern fn xcb_poly_text_16_items_end(R: [*c]const xcb_poly_text_16_request_t) xcb_generic_iterator_t;
pub extern fn xcb_image_text_8_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_image_text_8_checked(c: ?*xcb_connection_t, string_len: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, string: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_image_text_8(c: ?*xcb_connection_t, string_len: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, string: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_image_text_8_string(R: [*c]const xcb_image_text_8_request_t) [*c]u8;
pub extern fn xcb_image_text_8_string_length(R: [*c]const xcb_image_text_8_request_t) c_int;
pub extern fn xcb_image_text_8_string_end(R: [*c]const xcb_image_text_8_request_t) xcb_generic_iterator_t;
pub extern fn xcb_image_text_16_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_image_text_16_checked(c: ?*xcb_connection_t, string_len: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, string: [*c]const xcb_char2b_t) xcb_void_cookie_t;
pub extern fn xcb_image_text_16(c: ?*xcb_connection_t, string_len: u8, drawable: xcb_drawable_t, gc: xcb_gcontext_t, x: i16, y: i16, string: [*c]const xcb_char2b_t) xcb_void_cookie_t;
pub extern fn xcb_image_text_16_string(R: [*c]const xcb_image_text_16_request_t) [*c]xcb_char2b_t;
pub extern fn xcb_image_text_16_string_length(R: [*c]const xcb_image_text_16_request_t) c_int;
pub extern fn xcb_image_text_16_string_iterator(R: [*c]const xcb_image_text_16_request_t) xcb_char2b_iterator_t;
pub extern fn xcb_create_colormap_checked(c: ?*xcb_connection_t, alloc: u8, mid: xcb_colormap_t, window: xcb_window_t, visual: xcb_visualid_t) xcb_void_cookie_t;
pub extern fn xcb_create_colormap(c: ?*xcb_connection_t, alloc: u8, mid: xcb_colormap_t, window: xcb_window_t, visual: xcb_visualid_t) xcb_void_cookie_t;
pub extern fn xcb_free_colormap_checked(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_free_colormap(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_copy_colormap_and_free_checked(c: ?*xcb_connection_t, mid: xcb_colormap_t, src_cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_copy_colormap_and_free(c: ?*xcb_connection_t, mid: xcb_colormap_t, src_cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_install_colormap_checked(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_install_colormap(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_uninstall_colormap_checked(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_uninstall_colormap(c: ?*xcb_connection_t, cmap: xcb_colormap_t) xcb_void_cookie_t;
pub extern fn xcb_list_installed_colormaps_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_installed_colormaps(c: ?*xcb_connection_t, window: xcb_window_t) xcb_list_installed_colormaps_cookie_t;
pub extern fn xcb_list_installed_colormaps_unchecked(c: ?*xcb_connection_t, window: xcb_window_t) xcb_list_installed_colormaps_cookie_t;
pub extern fn xcb_list_installed_colormaps_cmaps(R: [*c]const xcb_list_installed_colormaps_reply_t) [*c]xcb_colormap_t;
pub extern fn xcb_list_installed_colormaps_cmaps_length(R: [*c]const xcb_list_installed_colormaps_reply_t) c_int;
pub extern fn xcb_list_installed_colormaps_cmaps_end(R: [*c]const xcb_list_installed_colormaps_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_list_installed_colormaps_reply(c: ?*xcb_connection_t, cookie: xcb_list_installed_colormaps_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_installed_colormaps_reply_t;
pub extern fn xcb_alloc_color(c: ?*xcb_connection_t, cmap: xcb_colormap_t, red: u16, green: u16, blue: u16) xcb_alloc_color_cookie_t;
pub extern fn xcb_alloc_color_unchecked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, red: u16, green: u16, blue: u16) xcb_alloc_color_cookie_t;
pub extern fn xcb_alloc_color_reply(c: ?*xcb_connection_t, cookie: xcb_alloc_color_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_alloc_color_reply_t;
pub extern fn xcb_alloc_named_color_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_alloc_named_color(c: ?*xcb_connection_t, cmap: xcb_colormap_t, name_len: u16, name: [*c]const u8) xcb_alloc_named_color_cookie_t;
pub extern fn xcb_alloc_named_color_unchecked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, name_len: u16, name: [*c]const u8) xcb_alloc_named_color_cookie_t;
pub extern fn xcb_alloc_named_color_reply(c: ?*xcb_connection_t, cookie: xcb_alloc_named_color_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_alloc_named_color_reply_t;
pub extern fn xcb_alloc_color_cells_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_alloc_color_cells(c: ?*xcb_connection_t, contiguous: u8, cmap: xcb_colormap_t, colors: u16, planes: u16) xcb_alloc_color_cells_cookie_t;
pub extern fn xcb_alloc_color_cells_unchecked(c: ?*xcb_connection_t, contiguous: u8, cmap: xcb_colormap_t, colors: u16, planes: u16) xcb_alloc_color_cells_cookie_t;
pub extern fn xcb_alloc_color_cells_pixels(R: [*c]const xcb_alloc_color_cells_reply_t) [*c]u32;
pub extern fn xcb_alloc_color_cells_pixels_length(R: [*c]const xcb_alloc_color_cells_reply_t) c_int;
pub extern fn xcb_alloc_color_cells_pixels_end(R: [*c]const xcb_alloc_color_cells_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_alloc_color_cells_masks(R: [*c]const xcb_alloc_color_cells_reply_t) [*c]u32;
pub extern fn xcb_alloc_color_cells_masks_length(R: [*c]const xcb_alloc_color_cells_reply_t) c_int;
pub extern fn xcb_alloc_color_cells_masks_end(R: [*c]const xcb_alloc_color_cells_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_alloc_color_cells_reply(c: ?*xcb_connection_t, cookie: xcb_alloc_color_cells_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_alloc_color_cells_reply_t;
pub extern fn xcb_alloc_color_planes_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_alloc_color_planes(c: ?*xcb_connection_t, contiguous: u8, cmap: xcb_colormap_t, colors: u16, reds: u16, greens: u16, blues: u16) xcb_alloc_color_planes_cookie_t;
pub extern fn xcb_alloc_color_planes_unchecked(c: ?*xcb_connection_t, contiguous: u8, cmap: xcb_colormap_t, colors: u16, reds: u16, greens: u16, blues: u16) xcb_alloc_color_planes_cookie_t;
pub extern fn xcb_alloc_color_planes_pixels(R: [*c]const xcb_alloc_color_planes_reply_t) [*c]u32;
pub extern fn xcb_alloc_color_planes_pixels_length(R: [*c]const xcb_alloc_color_planes_reply_t) c_int;
pub extern fn xcb_alloc_color_planes_pixels_end(R: [*c]const xcb_alloc_color_planes_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_alloc_color_planes_reply(c: ?*xcb_connection_t, cookie: xcb_alloc_color_planes_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_alloc_color_planes_reply_t;
pub extern fn xcb_free_colors_sizeof(_buffer: ?*const anyopaque, pixels_len: u32) c_int;
pub extern fn xcb_free_colors_checked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, plane_mask: u32, pixels_len: u32, pixels: [*c]const u32) xcb_void_cookie_t;
pub extern fn xcb_free_colors(c: ?*xcb_connection_t, cmap: xcb_colormap_t, plane_mask: u32, pixels_len: u32, pixels: [*c]const u32) xcb_void_cookie_t;
pub extern fn xcb_free_colors_pixels(R: [*c]const xcb_free_colors_request_t) [*c]u32;
pub extern fn xcb_free_colors_pixels_length(R: [*c]const xcb_free_colors_request_t) c_int;
pub extern fn xcb_free_colors_pixels_end(R: [*c]const xcb_free_colors_request_t) xcb_generic_iterator_t;
pub extern fn xcb_coloritem_next(i: [*c]xcb_coloritem_iterator_t) void;
pub extern fn xcb_coloritem_end(i: xcb_coloritem_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_store_colors_sizeof(_buffer: ?*const anyopaque, items_len: u32) c_int;
pub extern fn xcb_store_colors_checked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, items_len: u32, items: [*c]const xcb_coloritem_t) xcb_void_cookie_t;
pub extern fn xcb_store_colors(c: ?*xcb_connection_t, cmap: xcb_colormap_t, items_len: u32, items: [*c]const xcb_coloritem_t) xcb_void_cookie_t;
pub extern fn xcb_store_colors_items(R: [*c]const xcb_store_colors_request_t) [*c]xcb_coloritem_t;
pub extern fn xcb_store_colors_items_length(R: [*c]const xcb_store_colors_request_t) c_int;
pub extern fn xcb_store_colors_items_iterator(R: [*c]const xcb_store_colors_request_t) xcb_coloritem_iterator_t;
pub extern fn xcb_store_named_color_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_store_named_color_checked(c: ?*xcb_connection_t, flags: u8, cmap: xcb_colormap_t, pixel: u32, name_len: u16, name: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_store_named_color(c: ?*xcb_connection_t, flags: u8, cmap: xcb_colormap_t, pixel: u32, name_len: u16, name: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_store_named_color_name(R: [*c]const xcb_store_named_color_request_t) [*c]u8;
pub extern fn xcb_store_named_color_name_length(R: [*c]const xcb_store_named_color_request_t) c_int;
pub extern fn xcb_store_named_color_name_end(R: [*c]const xcb_store_named_color_request_t) xcb_generic_iterator_t;
pub extern fn xcb_rgb_next(i: [*c]xcb_rgb_iterator_t) void;
pub extern fn xcb_rgb_end(i: xcb_rgb_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_query_colors_sizeof(_buffer: ?*const anyopaque, pixels_len: u32) c_int;
pub extern fn xcb_query_colors(c: ?*xcb_connection_t, cmap: xcb_colormap_t, pixels_len: u32, pixels: [*c]const u32) xcb_query_colors_cookie_t;
pub extern fn xcb_query_colors_unchecked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, pixels_len: u32, pixels: [*c]const u32) xcb_query_colors_cookie_t;
pub extern fn xcb_query_colors_colors(R: [*c]const xcb_query_colors_reply_t) [*c]xcb_rgb_t;
pub extern fn xcb_query_colors_colors_length(R: [*c]const xcb_query_colors_reply_t) c_int;
pub extern fn xcb_query_colors_colors_iterator(R: [*c]const xcb_query_colors_reply_t) xcb_rgb_iterator_t;
pub extern fn xcb_query_colors_reply(c: ?*xcb_connection_t, cookie: xcb_query_colors_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_colors_reply_t;
pub extern fn xcb_lookup_color_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_lookup_color(c: ?*xcb_connection_t, cmap: xcb_colormap_t, name_len: u16, name: [*c]const u8) xcb_lookup_color_cookie_t;
pub extern fn xcb_lookup_color_unchecked(c: ?*xcb_connection_t, cmap: xcb_colormap_t, name_len: u16, name: [*c]const u8) xcb_lookup_color_cookie_t;
pub extern fn xcb_lookup_color_reply(c: ?*xcb_connection_t, cookie: xcb_lookup_color_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_lookup_color_reply_t;
pub extern fn xcb_create_cursor_checked(c: ?*xcb_connection_t, cid: xcb_cursor_t, source: xcb_pixmap_t, mask: xcb_pixmap_t, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) xcb_void_cookie_t;
pub extern fn xcb_create_cursor(c: ?*xcb_connection_t, cid: xcb_cursor_t, source: xcb_pixmap_t, mask: xcb_pixmap_t, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) xcb_void_cookie_t;
pub extern fn xcb_create_glyph_cursor_checked(c: ?*xcb_connection_t, cid: xcb_cursor_t, source_font: xcb_font_t, mask_font: xcb_font_t, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) xcb_void_cookie_t;
pub extern fn xcb_create_glyph_cursor(c: ?*xcb_connection_t, cid: xcb_cursor_t, source_font: xcb_font_t, mask_font: xcb_font_t, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) xcb_void_cookie_t;
pub extern fn xcb_free_cursor_checked(c: ?*xcb_connection_t, cursor: xcb_cursor_t) xcb_void_cookie_t;
pub extern fn xcb_free_cursor(c: ?*xcb_connection_t, cursor: xcb_cursor_t) xcb_void_cookie_t;
pub extern fn xcb_recolor_cursor_checked(c: ?*xcb_connection_t, cursor: xcb_cursor_t, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) xcb_void_cookie_t;
pub extern fn xcb_recolor_cursor(c: ?*xcb_connection_t, cursor: xcb_cursor_t, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) xcb_void_cookie_t;
pub extern fn xcb_query_best_size(c: ?*xcb_connection_t, _class: u8, drawable: xcb_drawable_t, width: u16, height: u16) xcb_query_best_size_cookie_t;
pub extern fn xcb_query_best_size_unchecked(c: ?*xcb_connection_t, _class: u8, drawable: xcb_drawable_t, width: u16, height: u16) xcb_query_best_size_cookie_t;
pub extern fn xcb_query_best_size_reply(c: ?*xcb_connection_t, cookie: xcb_query_best_size_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_best_size_reply_t;
pub extern fn xcb_query_extension_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_query_extension(c: ?*xcb_connection_t, name_len: u16, name: [*c]const u8) xcb_query_extension_cookie_t;
pub extern fn xcb_query_extension_unchecked(c: ?*xcb_connection_t, name_len: u16, name: [*c]const u8) xcb_query_extension_cookie_t;
pub extern fn xcb_query_extension_reply(c: ?*xcb_connection_t, cookie: xcb_query_extension_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_query_extension_reply_t;
pub extern fn xcb_list_extensions_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_extensions(c: ?*xcb_connection_t) xcb_list_extensions_cookie_t;
pub extern fn xcb_list_extensions_unchecked(c: ?*xcb_connection_t) xcb_list_extensions_cookie_t;
pub extern fn xcb_list_extensions_names_length(R: [*c]const xcb_list_extensions_reply_t) c_int;
pub extern fn xcb_list_extensions_names_iterator(R: [*c]const xcb_list_extensions_reply_t) xcb_str_iterator_t;
pub extern fn xcb_list_extensions_reply(c: ?*xcb_connection_t, cookie: xcb_list_extensions_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_extensions_reply_t;
pub extern fn xcb_change_keyboard_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_keyboard_mapping_checked(c: ?*xcb_connection_t, keycode_count: u8, first_keycode: xcb_keycode_t, keysyms_per_keycode: u8, keysyms: [*c]const xcb_keysym_t) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_mapping(c: ?*xcb_connection_t, keycode_count: u8, first_keycode: xcb_keycode_t, keysyms_per_keycode: u8, keysyms: [*c]const xcb_keysym_t) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_mapping_keysyms(R: [*c]const xcb_change_keyboard_mapping_request_t) [*c]xcb_keysym_t;
pub extern fn xcb_change_keyboard_mapping_keysyms_length(R: [*c]const xcb_change_keyboard_mapping_request_t) c_int;
pub extern fn xcb_change_keyboard_mapping_keysyms_end(R: [*c]const xcb_change_keyboard_mapping_request_t) xcb_generic_iterator_t;
pub extern fn xcb_get_keyboard_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_keyboard_mapping(c: ?*xcb_connection_t, first_keycode: xcb_keycode_t, count: u8) xcb_get_keyboard_mapping_cookie_t;
pub extern fn xcb_get_keyboard_mapping_unchecked(c: ?*xcb_connection_t, first_keycode: xcb_keycode_t, count: u8) xcb_get_keyboard_mapping_cookie_t;
pub extern fn xcb_get_keyboard_mapping_keysyms(R: [*c]const xcb_get_keyboard_mapping_reply_t) [*c]xcb_keysym_t;
pub extern fn xcb_get_keyboard_mapping_keysyms_length(R: [*c]const xcb_get_keyboard_mapping_reply_t) c_int;
pub extern fn xcb_get_keyboard_mapping_keysyms_end(R: [*c]const xcb_get_keyboard_mapping_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_keyboard_mapping_reply(c: ?*xcb_connection_t, cookie: xcb_get_keyboard_mapping_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_keyboard_mapping_reply_t;
pub extern fn xcb_change_keyboard_control_value_list_serialize(_buffer: [*c]?*anyopaque, value_mask: u32, _aux: [*c]const xcb_change_keyboard_control_value_list_t) c_int;
pub extern fn xcb_change_keyboard_control_value_list_unpack(_buffer: ?*const anyopaque, value_mask: u32, _aux: [*c]xcb_change_keyboard_control_value_list_t) c_int;
pub extern fn xcb_change_keyboard_control_value_list_sizeof(_buffer: ?*const anyopaque, value_mask: u32) c_int;
pub extern fn xcb_change_keyboard_control_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_keyboard_control_checked(c: ?*xcb_connection_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_control(c: ?*xcb_connection_t, value_mask: u32, value_list: ?*const anyopaque) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_control_aux_checked(c: ?*xcb_connection_t, value_mask: u32, value_list: [*c]const xcb_change_keyboard_control_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_control_aux(c: ?*xcb_connection_t, value_mask: u32, value_list: [*c]const xcb_change_keyboard_control_value_list_t) xcb_void_cookie_t;
pub extern fn xcb_change_keyboard_control_value_list(R: [*c]const xcb_change_keyboard_control_request_t) ?*anyopaque;
pub extern fn xcb_get_keyboard_control(c: ?*xcb_connection_t) xcb_get_keyboard_control_cookie_t;
pub extern fn xcb_get_keyboard_control_unchecked(c: ?*xcb_connection_t) xcb_get_keyboard_control_cookie_t;
pub extern fn xcb_get_keyboard_control_reply(c: ?*xcb_connection_t, cookie: xcb_get_keyboard_control_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_keyboard_control_reply_t;
pub extern fn xcb_bell_checked(c: ?*xcb_connection_t, percent: i8) xcb_void_cookie_t;
pub extern fn xcb_bell(c: ?*xcb_connection_t, percent: i8) xcb_void_cookie_t;
pub extern fn xcb_change_pointer_control_checked(c: ?*xcb_connection_t, acceleration_numerator: i16, acceleration_denominator: i16, threshold: i16, do_acceleration: u8, do_threshold: u8) xcb_void_cookie_t;
pub extern fn xcb_change_pointer_control(c: ?*xcb_connection_t, acceleration_numerator: i16, acceleration_denominator: i16, threshold: i16, do_acceleration: u8, do_threshold: u8) xcb_void_cookie_t;
pub extern fn xcb_get_pointer_control(c: ?*xcb_connection_t) xcb_get_pointer_control_cookie_t;
pub extern fn xcb_get_pointer_control_unchecked(c: ?*xcb_connection_t) xcb_get_pointer_control_cookie_t;
pub extern fn xcb_get_pointer_control_reply(c: ?*xcb_connection_t, cookie: xcb_get_pointer_control_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_pointer_control_reply_t;
pub extern fn xcb_set_screen_saver_checked(c: ?*xcb_connection_t, timeout: i16, interval: i16, prefer_blanking: u8, allow_exposures: u8) xcb_void_cookie_t;
pub extern fn xcb_set_screen_saver(c: ?*xcb_connection_t, timeout: i16, interval: i16, prefer_blanking: u8, allow_exposures: u8) xcb_void_cookie_t;
pub extern fn xcb_get_screen_saver(c: ?*xcb_connection_t) xcb_get_screen_saver_cookie_t;
pub extern fn xcb_get_screen_saver_unchecked(c: ?*xcb_connection_t) xcb_get_screen_saver_cookie_t;
pub extern fn xcb_get_screen_saver_reply(c: ?*xcb_connection_t, cookie: xcb_get_screen_saver_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_screen_saver_reply_t;
pub extern fn xcb_change_hosts_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_change_hosts_checked(c: ?*xcb_connection_t, mode: u8, family: u8, address_len: u16, address: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_change_hosts(c: ?*xcb_connection_t, mode: u8, family: u8, address_len: u16, address: [*c]const u8) xcb_void_cookie_t;
pub extern fn xcb_change_hosts_address(R: [*c]const xcb_change_hosts_request_t) [*c]u8;
pub extern fn xcb_change_hosts_address_length(R: [*c]const xcb_change_hosts_request_t) c_int;
pub extern fn xcb_change_hosts_address_end(R: [*c]const xcb_change_hosts_request_t) xcb_generic_iterator_t;
pub extern fn xcb_host_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_host_address(R: [*c]const xcb_host_t) [*c]u8;
pub extern fn xcb_host_address_length(R: [*c]const xcb_host_t) c_int;
pub extern fn xcb_host_address_end(R: [*c]const xcb_host_t) xcb_generic_iterator_t;
pub extern fn xcb_host_next(i: [*c]xcb_host_iterator_t) void;
pub extern fn xcb_host_end(i: xcb_host_iterator_t) xcb_generic_iterator_t;
pub extern fn xcb_list_hosts_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_list_hosts(c: ?*xcb_connection_t) xcb_list_hosts_cookie_t;
pub extern fn xcb_list_hosts_unchecked(c: ?*xcb_connection_t) xcb_list_hosts_cookie_t;
pub extern fn xcb_list_hosts_hosts_length(R: [*c]const xcb_list_hosts_reply_t) c_int;
pub extern fn xcb_list_hosts_hosts_iterator(R: [*c]const xcb_list_hosts_reply_t) xcb_host_iterator_t;
pub extern fn xcb_list_hosts_reply(c: ?*xcb_connection_t, cookie: xcb_list_hosts_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_list_hosts_reply_t;
pub extern fn xcb_set_access_control_checked(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_set_access_control(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_set_close_down_mode_checked(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_set_close_down_mode(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_kill_client_checked(c: ?*xcb_connection_t, resource: u32) xcb_void_cookie_t;
pub extern fn xcb_kill_client(c: ?*xcb_connection_t, resource: u32) xcb_void_cookie_t;
pub extern fn xcb_rotate_properties_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_rotate_properties_checked(c: ?*xcb_connection_t, window: xcb_window_t, atoms_len: u16, delta: i16, atoms: [*c]const xcb_atom_t) xcb_void_cookie_t;
pub extern fn xcb_rotate_properties(c: ?*xcb_connection_t, window: xcb_window_t, atoms_len: u16, delta: i16, atoms: [*c]const xcb_atom_t) xcb_void_cookie_t;
pub extern fn xcb_rotate_properties_atoms(R: [*c]const xcb_rotate_properties_request_t) [*c]xcb_atom_t;
pub extern fn xcb_rotate_properties_atoms_length(R: [*c]const xcb_rotate_properties_request_t) c_int;
pub extern fn xcb_rotate_properties_atoms_end(R: [*c]const xcb_rotate_properties_request_t) xcb_generic_iterator_t;
pub extern fn xcb_force_screen_saver_checked(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_force_screen_saver(c: ?*xcb_connection_t, mode: u8) xcb_void_cookie_t;
pub extern fn xcb_set_pointer_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_set_pointer_mapping(c: ?*xcb_connection_t, map_len: u8, map: [*c]const u8) xcb_set_pointer_mapping_cookie_t;
pub extern fn xcb_set_pointer_mapping_unchecked(c: ?*xcb_connection_t, map_len: u8, map: [*c]const u8) xcb_set_pointer_mapping_cookie_t;
pub extern fn xcb_set_pointer_mapping_reply(c: ?*xcb_connection_t, cookie: xcb_set_pointer_mapping_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_set_pointer_mapping_reply_t;
pub extern fn xcb_get_pointer_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_pointer_mapping(c: ?*xcb_connection_t) xcb_get_pointer_mapping_cookie_t;
pub extern fn xcb_get_pointer_mapping_unchecked(c: ?*xcb_connection_t) xcb_get_pointer_mapping_cookie_t;
pub extern fn xcb_get_pointer_mapping_map(R: [*c]const xcb_get_pointer_mapping_reply_t) [*c]u8;
pub extern fn xcb_get_pointer_mapping_map_length(R: [*c]const xcb_get_pointer_mapping_reply_t) c_int;
pub extern fn xcb_get_pointer_mapping_map_end(R: [*c]const xcb_get_pointer_mapping_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_pointer_mapping_reply(c: ?*xcb_connection_t, cookie: xcb_get_pointer_mapping_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_pointer_mapping_reply_t;
pub extern fn xcb_set_modifier_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_set_modifier_mapping(c: ?*xcb_connection_t, keycodes_per_modifier: u8, keycodes: [*c]const xcb_keycode_t) xcb_set_modifier_mapping_cookie_t;
pub extern fn xcb_set_modifier_mapping_unchecked(c: ?*xcb_connection_t, keycodes_per_modifier: u8, keycodes: [*c]const xcb_keycode_t) xcb_set_modifier_mapping_cookie_t;
pub extern fn xcb_set_modifier_mapping_reply(c: ?*xcb_connection_t, cookie: xcb_set_modifier_mapping_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_set_modifier_mapping_reply_t;
pub extern fn xcb_get_modifier_mapping_sizeof(_buffer: ?*const anyopaque) c_int;
pub extern fn xcb_get_modifier_mapping(c: ?*xcb_connection_t) xcb_get_modifier_mapping_cookie_t;
pub extern fn xcb_get_modifier_mapping_unchecked(c: ?*xcb_connection_t) xcb_get_modifier_mapping_cookie_t;
pub extern fn xcb_get_modifier_mapping_keycodes(R: [*c]const xcb_get_modifier_mapping_reply_t) [*c]xcb_keycode_t;
pub extern fn xcb_get_modifier_mapping_keycodes_length(R: [*c]const xcb_get_modifier_mapping_reply_t) c_int;
pub extern fn xcb_get_modifier_mapping_keycodes_end(R: [*c]const xcb_get_modifier_mapping_reply_t) xcb_generic_iterator_t;
pub extern fn xcb_get_modifier_mapping_reply(c: ?*xcb_connection_t, cookie: xcb_get_modifier_mapping_cookie_t, e: [*c][*c]xcb_generic_error_t) [*c]xcb_get_modifier_mapping_reply_t;
pub extern fn xcb_no_operation_checked(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub extern fn xcb_no_operation(c: ?*xcb_connection_t) xcb_void_cookie_t;
pub const struct_xcb_auth_info_t = extern struct {
namelen: c_int,
name: [*c]u8,
datalen: c_int,
data: [*c]u8,
};
pub const xcb_auth_info_t = struct_xcb_auth_info_t;
pub extern fn xcb_flush(c: ?*xcb_connection_t) c_int;
pub extern fn xcb_get_maximum_request_length(c: ?*xcb_connection_t) u32;
pub extern fn xcb_prefetch_maximum_request_length(c: ?*xcb_connection_t) void;
pub extern fn xcb_wait_for_event(c: ?*xcb_connection_t) [*c]xcb_generic_event_t;
pub extern fn xcb_poll_for_event(c: ?*xcb_connection_t) [*c]xcb_generic_event_t;
pub extern fn xcb_poll_for_queued_event(c: ?*xcb_connection_t) [*c]xcb_generic_event_t;
pub const struct_xcb_special_event = opaque {};
pub const xcb_special_event_t = struct_xcb_special_event;
pub extern fn xcb_poll_for_special_event(c: ?*xcb_connection_t, se: ?*xcb_special_event_t) [*c]xcb_generic_event_t;
pub extern fn xcb_wait_for_special_event(c: ?*xcb_connection_t, se: ?*xcb_special_event_t) [*c]xcb_generic_event_t;
pub const struct_xcb_extension_t = opaque {};
pub const xcb_extension_t = struct_xcb_extension_t;
pub extern fn xcb_register_for_special_xge(c: ?*xcb_connection_t, ext: ?*xcb_extension_t, eid: u32, stamp: [*c]u32) ?*xcb_special_event_t;
pub extern fn xcb_unregister_for_special_event(c: ?*xcb_connection_t, se: ?*xcb_special_event_t) void;
pub extern fn xcb_request_check(c: ?*xcb_connection_t, cookie: xcb_void_cookie_t) [*c]xcb_generic_error_t;
pub extern fn xcb_discard_reply(c: ?*xcb_connection_t, sequence: c_uint) void;
pub extern fn xcb_discard_reply64(c: ?*xcb_connection_t, sequence: u64) void;
pub extern fn xcb_get_extension_data(c: ?*xcb_connection_t, ext: ?*xcb_extension_t) [*c]const struct_xcb_query_extension_reply_t;
pub extern fn xcb_prefetch_extension_data(c: ?*xcb_connection_t, ext: ?*xcb_extension_t) void;
pub extern fn xcb_get_setup(c: ?*xcb_connection_t) [*c]const struct_xcb_setup_t;
pub extern fn xcb_get_file_descriptor(c: ?*xcb_connection_t) c_int;
pub extern fn xcb_connection_has_error(c: ?*xcb_connection_t) c_int;
pub extern fn xcb_connect_to_fd(fd: c_int, auth_info: [*c]xcb_auth_info_t) ?*xcb_connection_t;
pub extern fn xcb_disconnect(c: ?*xcb_connection_t) void;
pub extern fn xcb_parse_display(name: [*c]const u8, host: [*c][*c]u8, display: [*c]c_int, screen: [*c]c_int) c_int;
pub extern fn xcb_connect(displayname: [*c]const u8, screenp: [*c]c_int) ?*xcb_connection_t;
pub extern fn xcb_connect_to_display_with_auth_info(display: [*c]const u8, auth: [*c]xcb_auth_info_t, screen: [*c]c_int) ?*xcb_connection_t;
pub extern fn xcb_generate_id(c: ?*xcb_connection_t) u32;
pub const XCB_KEY_PRESS = @as(c_int, 2);
pub const XCB_KEY_RELEASE = @as(c_int, 3);
pub const XCB_BUTTON_PRESS = @as(c_int, 4);
pub const XCB_BUTTON_RELEASE = @as(c_int, 5);
pub const XCB_MOTION_NOTIFY = @as(c_int, 6);
pub const XCB_ENTER_NOTIFY = @as(c_int, 7);
pub const XCB_LEAVE_NOTIFY = @as(c_int, 8);
pub const XCB_FOCUS_IN = @as(c_int, 9);
pub const XCB_FOCUS_OUT = @as(c_int, 10);
pub const XCB_KEYMAP_NOTIFY = @as(c_int, 11);
pub const XCB_EXPOSE = @as(c_int, 12);
pub const XCB_GRAPHICS_EXPOSURE = @as(c_int, 13);
pub const XCB_NO_EXPOSURE = @as(c_int, 14);
pub const XCB_VISIBILITY_NOTIFY = @as(c_int, 15);
pub const XCB_CREATE_NOTIFY = @as(c_int, 16);
pub const XCB_DESTROY_NOTIFY = @as(c_int, 17);
pub const XCB_UNMAP_NOTIFY = @as(c_int, 18);
pub const XCB_MAP_NOTIFY = @as(c_int, 19);
pub const XCB_MAP_REQUEST = @as(c_int, 20);
pub const XCB_REPARENT_NOTIFY = @as(c_int, 21);
pub const XCB_CONFIGURE_NOTIFY = @as(c_int, 22);
pub const XCB_CONFIGURE_REQUEST = @as(c_int, 23);
pub const XCB_GRAVITY_NOTIFY = @as(c_int, 24);
pub const XCB_RESIZE_REQUEST = @as(c_int, 25);
pub const XCB_CIRCULATE_NOTIFY = @as(c_int, 26);
pub const XCB_CIRCULATE_REQUEST = @as(c_int, 27);
pub const XCB_PROPERTY_NOTIFY = @as(c_int, 28);
pub const XCB_SELECTION_CLEAR = @as(c_int, 29);
pub const XCB_SELECTION_REQUEST = @as(c_int, 30);
pub const XCB_SELECTION_NOTIFY = @as(c_int, 31);
pub const XCB_COLORMAP_NOTIFY = @as(c_int, 32);
pub const XCB_CLIENT_MESSAGE = @as(c_int, 33);
pub const XCB_MAPPING_NOTIFY = @as(c_int, 34);
pub const XCB_GE_GENERIC = @as(c_int, 35);
pub const XCB_REQUEST = @as(c_int, 1);
pub const XCB_VALUE = @as(c_int, 2);
pub const XCB_WINDOW = @as(c_int, 3);
pub const XCB_PIXMAP = @as(c_int, 4);
pub const XCB_ATOM = @as(c_int, 5);
pub const XCB_CURSOR = @as(c_int, 6);
pub const XCB_FONT = @as(c_int, 7);
pub const XCB_MATCH = @as(c_int, 8);
pub const XCB_DRAWABLE = @as(c_int, 9);
pub const XCB_ACCESS = @as(c_int, 10);
pub const XCB_ALLOC = @as(c_int, 11);
pub const XCB_COLORMAP = @as(c_int, 12);
pub const XCB_G_CONTEXT = @as(c_int, 13);
pub const XCB_ID_CHOICE = @as(c_int, 14);
pub const XCB_NAME = @as(c_int, 15);
pub const XCB_LENGTH = @as(c_int, 16);
pub const XCB_IMPLEMENTATION = @as(c_int, 17);
pub const XCB_CREATE_WINDOW = @as(c_int, 1);
pub const XCB_CHANGE_WINDOW_ATTRIBUTES = @as(c_int, 2);
pub const XCB_GET_WINDOW_ATTRIBUTES = @as(c_int, 3);
pub const XCB_DESTROY_WINDOW = @as(c_int, 4);
pub const XCB_DESTROY_SUBWINDOWS = @as(c_int, 5);
pub const XCB_CHANGE_SAVE_SET = @as(c_int, 6);
pub const XCB_REPARENT_WINDOW = @as(c_int, 7);
pub const XCB_MAP_WINDOW = @as(c_int, 8);
pub const XCB_MAP_SUBWINDOWS = @as(c_int, 9);
pub const XCB_UNMAP_WINDOW = @as(c_int, 10);
pub const XCB_UNMAP_SUBWINDOWS = @as(c_int, 11);
pub const XCB_CONFIGURE_WINDOW = @as(c_int, 12);
pub const XCB_CIRCULATE_WINDOW = @as(c_int, 13);
pub const XCB_GET_GEOMETRY = @as(c_int, 14);
pub const XCB_QUERY_TREE = @as(c_int, 15);
pub const XCB_INTERN_ATOM = @as(c_int, 16);
pub const XCB_GET_ATOM_NAME = @as(c_int, 17);
pub const XCB_CHANGE_PROPERTY = @as(c_int, 18);
pub const XCB_DELETE_PROPERTY = @as(c_int, 19);
pub const XCB_GET_PROPERTY = @as(c_int, 20);
pub const XCB_LIST_PROPERTIES = @as(c_int, 21);
pub const XCB_SET_SELECTION_OWNER = @as(c_int, 22);
pub const XCB_GET_SELECTION_OWNER = @as(c_int, 23);
pub const XCB_CONVERT_SELECTION = @as(c_int, 24);
pub const XCB_SEND_EVENT = @as(c_int, 25);
pub const XCB_GRAB_POINTER = @as(c_int, 26);
pub const XCB_UNGRAB_POINTER = @as(c_int, 27);
pub const XCB_GRAB_BUTTON = @as(c_int, 28);
pub const XCB_UNGRAB_BUTTON = @as(c_int, 29);
pub const XCB_CHANGE_ACTIVE_POINTER_GRAB = @as(c_int, 30);
pub const XCB_GRAB_KEYBOARD = @as(c_int, 31);
pub const XCB_UNGRAB_KEYBOARD = @as(c_int, 32);
pub const XCB_GRAB_KEY = @as(c_int, 33);
pub const XCB_UNGRAB_KEY = @as(c_int, 34);
pub const XCB_ALLOW_EVENTS = @as(c_int, 35);
pub const XCB_GRAB_SERVER = @as(c_int, 36);
pub const XCB_UNGRAB_SERVER = @as(c_int, 37);
pub const XCB_QUERY_POINTER = @as(c_int, 38);
pub const XCB_GET_MOTION_EVENTS = @as(c_int, 39);
pub const XCB_TRANSLATE_COORDINATES = @as(c_int, 40);
pub const XCB_WARP_POINTER = @as(c_int, 41);
pub const XCB_SET_INPUT_FOCUS = @as(c_int, 42);
pub const XCB_GET_INPUT_FOCUS = @as(c_int, 43);
pub const XCB_QUERY_KEYMAP = @as(c_int, 44);
pub const XCB_OPEN_FONT = @as(c_int, 45);
pub const XCB_CLOSE_FONT = @as(c_int, 46);
pub const XCB_QUERY_FONT = @as(c_int, 47);
pub const XCB_QUERY_TEXT_EXTENTS = @as(c_int, 48);
pub const XCB_LIST_FONTS = @as(c_int, 49);
pub const XCB_LIST_FONTS_WITH_INFO = @as(c_int, 50);
pub const XCB_SET_FONT_PATH = @as(c_int, 51);
pub const XCB_GET_FONT_PATH = @as(c_int, 52);
pub const XCB_CREATE_PIXMAP = @as(c_int, 53);
pub const XCB_FREE_PIXMAP = @as(c_int, 54);
pub const XCB_CREATE_GC = @as(c_int, 55);
pub const XCB_CHANGE_GC = @as(c_int, 56);
pub const XCB_COPY_GC = @as(c_int, 57);
pub const XCB_SET_DASHES = @as(c_int, 58);
pub const XCB_SET_CLIP_RECTANGLES = @as(c_int, 59);
pub const XCB_FREE_GC = @as(c_int, 60);
pub const XCB_CLEAR_AREA = @as(c_int, 61);
pub const XCB_COPY_AREA = @as(c_int, 62);
pub const XCB_COPY_PLANE = @as(c_int, 63);
pub const XCB_POLY_POINT = @as(c_int, 64);
pub const XCB_POLY_LINE = @as(c_int, 65);
pub const XCB_POLY_SEGMENT = @as(c_int, 66);
pub const XCB_POLY_RECTANGLE = @as(c_int, 67);
pub const XCB_POLY_ARC = @as(c_int, 68);
pub const XCB_FILL_POLY = @as(c_int, 69);
pub const XCB_POLY_FILL_RECTANGLE = @as(c_int, 70);
pub const XCB_POLY_FILL_ARC = @as(c_int, 71);
pub const XCB_PUT_IMAGE = @as(c_int, 72);
pub const XCB_GET_IMAGE = @as(c_int, 73);
pub const XCB_POLY_TEXT_8 = @as(c_int, 74);
pub const XCB_POLY_TEXT_16 = @as(c_int, 75);
pub const XCB_IMAGE_TEXT_8 = @as(c_int, 76);
pub const XCB_IMAGE_TEXT_16 = @as(c_int, 77);
pub const XCB_CREATE_COLORMAP = @as(c_int, 78);
pub const XCB_FREE_COLORMAP = @as(c_int, 79);
pub const XCB_COPY_COLORMAP_AND_FREE = @as(c_int, 80);
pub const XCB_INSTALL_COLORMAP = @as(c_int, 81);
pub const XCB_UNINSTALL_COLORMAP = @as(c_int, 82);
pub const XCB_LIST_INSTALLED_COLORMAPS = @as(c_int, 83);
pub const XCB_ALLOC_COLOR = @as(c_int, 84);
pub const XCB_ALLOC_NAMED_COLOR = @as(c_int, 85);
pub const XCB_ALLOC_COLOR_CELLS = @as(c_int, 86);
pub const XCB_ALLOC_COLOR_PLANES = @as(c_int, 87);
pub const XCB_FREE_COLORS = @as(c_int, 88);
pub const XCB_STORE_COLORS = @as(c_int, 89);
pub const XCB_STORE_NAMED_COLOR = @as(c_int, 90);
pub const XCB_QUERY_COLORS = @as(c_int, 91);
pub const XCB_LOOKUP_COLOR = @as(c_int, 92);
pub const XCB_CREATE_CURSOR = @as(c_int, 93);
pub const XCB_CREATE_GLYPH_CURSOR = @as(c_int, 94);
pub const XCB_FREE_CURSOR = @as(c_int, 95);
pub const XCB_RECOLOR_CURSOR = @as(c_int, 96);
pub const XCB_QUERY_BEST_SIZE = @as(c_int, 97);
pub const XCB_QUERY_EXTENSION = @as(c_int, 98);
pub const XCB_LIST_EXTENSIONS = @as(c_int, 99);
pub const XCB_CHANGE_KEYBOARD_MAPPING = @as(c_int, 100);
pub const XCB_GET_KEYBOARD_MAPPING = @as(c_int, 101);
pub const XCB_CHANGE_KEYBOARD_CONTROL = @as(c_int, 102);
pub const XCB_GET_KEYBOARD_CONTROL = @as(c_int, 103);
pub const XCB_BELL = @as(c_int, 104);
pub const XCB_CHANGE_POINTER_CONTROL = @as(c_int, 105);
pub const XCB_GET_POINTER_CONTROL = @as(c_int, 106);
pub const XCB_SET_SCREEN_SAVER = @as(c_int, 107);
pub const XCB_GET_SCREEN_SAVER = @as(c_int, 108);
pub const XCB_CHANGE_HOSTS = @as(c_int, 109);
pub const XCB_LIST_HOSTS = @as(c_int, 110);
pub const XCB_SET_ACCESS_CONTROL = @as(c_int, 111);
pub const XCB_SET_CLOSE_DOWN_MODE = @as(c_int, 112);
pub const XCB_KILL_CLIENT = @as(c_int, 113);
pub const XCB_ROTATE_PROPERTIES = @as(c_int, 114);
pub const XCB_FORCE_SCREEN_SAVER = @as(c_int, 115);
pub const XCB_SET_POINTER_MAPPING = @as(c_int, 116);
pub const XCB_GET_POINTER_MAPPING = @as(c_int, 117);
pub const XCB_SET_MODIFIER_MAPPING = @as(c_int, 118);
pub const XCB_GET_MODIFIER_MAPPING = @as(c_int, 119);
pub const XCB_NO_OPERATION = @as(c_int, 127);
pub const __XCB_H__ = "";
pub const XCB_CONN_ERROR = @as(c_int, 1);
pub const XCB_CONN_CLOSED_EXT_NOTSUPPORTED = @as(c_int, 2);
pub const XCB_CONN_CLOSED_MEM_INSUFFICIENT = @as(c_int, 3);
pub const XCB_CONN_CLOSED_REQ_LEN_EXCEED = @as(c_int, 4);
pub const XCB_CONN_CLOSED_PARSE_ERR = @as(c_int, 5);
pub const XCB_CONN_CLOSED_INVALID_SCREEN = @as(c_int, 6);
pub const XCB_CONN_CLOSED_FDPASSING_FAILED = @as(c_int, 7);
pub inline fn XCB_TYPE_PAD(T: anytype, I: anytype) @TypeOf(-I & (if (@import("std").zig.c_translation.sizeof(T) > @as(c_int, 4)) @as(c_int, 3) else @import("std").zig.c_translation.sizeof(T) - @as(c_int, 1))) {
_ = T;
return -I & (if (@import("std").zig.c_translation.sizeof(T) > @as(c_int, 4)) @as(c_int, 3) else @import("std").zig.c_translation.sizeof(T) - @as(c_int, 1));
}
pub const XCB_NONE = @as(c_long, 0);
pub const XCB_COPY_FROM_PARENT = @as(c_long, 0);
pub const XCB_CURRENT_TIME = @as(c_long, 0);
pub const XCB_NO_SYMBOL = @as(c_long, 0);
pub const xcb_special_event = struct_xcb_special_event; | modules/platform/src/linux/X11/xcb/xcb.zig |
const std = @import("std");
const tvg = @import("tinyvg.zig");
/// Renders a binary TinyVG graphic to SVG.
/// - `allocator` will be used for temporary allocations in both the TVG parser and the SVG renderer.
/// - `tvg_buffer` provides a binary TinyVG file
/// - `writer` will receive the UTF-8 encoded SVG text.
pub fn renderBinary(allocator: std.mem.Allocator, tvg_buffer: []const u8, writer: anytype) !void {
var stream = std.io.fixedBufferStream(tvg_buffer);
var parser = try tvg.parse(allocator, stream.reader());
defer parser.deinit();
return try renderStream(allocator, &parser, writer);
}
/// Renders a TinyVG command stream into a SVG file.
/// - `allocator` is used for temporary allocations
/// - `parser` is a pointer to a `tvg.parsing.Parser(Reader)`
/// - `writer` will receive the UTF-8 encoded SVG text.
pub fn renderStream(allocator: std.mem.Allocator, parser: anytype, writer: anytype) !void {
var cache = SvgStyleCache{
.color_table = parser.color_table,
.list = std.ArrayList(tvg.Style).init(allocator),
};
defer cache.list.deinit();
try writer.print(
\\<svg xmlns="http://www.w3.org/2000/svg" width="{0d}" height="{1d}" viewBox="0 0 {0d} {1d}">
, .{
parser.header.width,
parser.header.height,
});
while (try parser.next()) |command| {
switch (command) {
.fill_rectangles => |data| {
for (data.rectangles) |rect| {
try writer.print(
\\<rect style="{}" x="{d}" y="{d}" width="{d}" height="{d}"/>
,
.{
svgStyle(&cache, data.style, null, null),
rect.x,
rect.y,
rect.width,
rect.height,
},
);
}
},
.outline_fill_rectangles => |data| {
for (data.rectangles) |rect| {
try writer.print(
\\<rect style="{}" x="{d}" y="{d}" width="{d}" height="{d}"/>
,
.{
svgStyle(&cache, data.fill_style, data.line_style, data.line_width),
rect.x,
rect.y,
rect.width,
rect.height,
},
);
}
},
.draw_lines => |data| {
for (data.lines) |line| {
try writer.print(
\\<line style="{}" x1="{d}" y1="{d}" x2="{d}" y2="{d}"/>
,
.{
svgStyle(&cache, null, data.style, data.line_width),
line.start.x,
line.start.y,
line.end.x,
line.end.y,
},
);
}
},
.draw_line_loop => |data| {
try writer.print(
\\<polygon style="{}" points="
, .{
svgStyle(&cache, null, data.style, data.line_width),
});
for (data.vertices) |vertex, i| {
if (i > 0) try writer.writeAll(" ");
try writer.print("{d},{d}", .{ vertex.x, vertex.y });
}
try writer.writeAll(
\\"/>
);
},
.draw_line_strip => |data| {
try writer.print(
\\<polyline style="{}" points="
, .{
svgStyle(&cache, null, data.style, data.line_width),
});
for (data.vertices) |vertex, i| {
if (i > 0) try writer.writeAll(" ");
try writer.print("{d},{d}", .{ vertex.x, vertex.y });
}
try writer.writeAll(
\\"/>
);
},
.fill_polygon => |data| {
try writer.print(
\\<polygon style="{}" points="
, .{
svgStyle(&cache, data.style, null, null),
});
for (data.vertices) |vertex, i| {
if (i > 0) try writer.writeAll(" ");
try writer.print("{d},{d}", .{ vertex.x, vertex.y });
}
try writer.writeAll(
\\"/>
);
},
.outline_fill_polygon => |data| {
try writer.print(
\\<polygon style="{}" points="
, .{
svgStyle(&cache, data.fill_style, data.line_style, data.line_width),
});
for (data.vertices) |vertex, i| {
if (i > 0) try writer.writeAll(" ");
try writer.print("{d},{d}", .{ vertex.x, vertex.y });
}
try writer.writeAll(
\\"/>
);
},
.draw_line_path => |data| {
var style = svgStyle(&cache, null, data.style, data.line_width);
var path = SvgPath{ .path = data.path };
try writer.print(
\\<path style="{}" d="{}"/>
, .{ style, path });
},
.fill_path => |data| {
var style = svgStyle(&cache, data.style, null, null);
var path = SvgPath{ .path = data.path };
try writer.print(
\\<path style="{}" d="{}"/>
, .{ style, path });
},
.outline_fill_path => |data| {
var style = svgStyle(&cache, data.fill_style, data.line_style, data.line_width);
var path = SvgPath{ .path = data.path };
try writer.print(
\\<path style="{}" d="{}"/>
, .{ style, path });
},
}
}
if (cache.list.items.len > 0) {
try writer.writeAll("<defs>");
for (cache.list.items) |style, i| {
switch (style) {
.linear => |grad| {
try writer.print(
\\<linearGradient id="grad{}" gradientUnits="userSpaceOnUse" x1="{d}" y1="{d}" x2="{d}" y2="{d}">
, .{ i, grad.point_0.x, grad.point_0.y, grad.point_1.x, grad.point_1.y });
try writer.print(
\\<stop offset="0" style="stop-opacity:{d}; stop-color:
, .{cache.color_table[grad.color_0].a});
try cache.printColor3AndPrefix(writer, "", grad.color_0, "\" />");
try writer.print(
\\<stop offset="100%" style="stop-opacity:{d}; stop-color:
, .{cache.color_table[grad.color_1].a});
try cache.printColor3AndPrefix(writer, "", grad.color_1, "\" />");
try writer.writeAll("</linearGradient>");
},
.radial => |grad| {
_ = grad;
var dx = grad.point_1.x - grad.point_0.x;
var dy = grad.point_1.y - grad.point_0.y;
var r = std.math.sqrt(dx * dx + dy * dy);
try writer.print(
\\<radialGradient id="grad{}" gradientUnits="userSpaceOnUse" cx="{d}" cy="{d}" r="{d}">
, .{ i, grad.point_0.x, grad.point_0.y, r });
try writer.print(
\\<stop offset="0" style="stop-opacity:{d}; stop-color:
, .{cache.color_table[grad.color_0].a});
try cache.printColor3AndPrefix(writer, "", grad.color_0, "\"/>");
try writer.print(
\\<stop offset="100%" style="stop-opacity:{d}; stop-color:
, .{cache.color_table[grad.color_1].a});
try cache.printColor3AndPrefix(writer, "", grad.color_1, "\"/>");
try writer.writeAll("</radialGradient>");
},
.flat => @panic("implementation fault"),
}
}
try writer.writeAll("</defs>");
}
try writer.writeAll("</svg>");
}
const SvgStyle = struct {
cache: *SvgStyleCache,
fill_style: ?tvg.Style,
line_style: ?tvg.Style,
line_width: ?f32,
pub fn format(self: SvgStyle, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
if (self.fill_style) |style| {
switch (style) {
.flat => |ind| try self.cache.printColorForStyle(writer, "fill", ind),
.linear, .radial => try writer.print("fill:url(#grad{});", .{
self.cache.insert(style),
}),
}
} else {
try writer.writeAll("fill:none;");
}
if (self.line_style) |style| {
try writer.writeAll("stroke-linecap:round;");
switch (style) {
.flat => |ind| try self.cache.printColorForStyle(writer, "stroke", ind),
.linear, .radial => try writer.print("stroke:url(#grad{});", .{
self.cache.insert(style),
}),
}
} else {
try writer.writeAll("stroke:none;");
}
if (self.line_width) |lw| {
try writer.print("stroke-width:{d};", .{lw});
}
}
};
const SvgPath = struct {
path: tvg.Path,
pub fn format(self: SvgPath, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
for (self.path.segments) |segment| {
try writer.print("M{d},{d}", .{ segment.start.x, segment.start.y });
for (segment.commands) |cmd| {
switch (cmd) {
.line => |data| try writer.print("L{d},{d}", .{ data.data.x, data.data.y }),
.horiz => |data| try writer.print("H{d}", .{data.data}),
.vert => |data| try writer.print("V{d}", .{data.data}),
.bezier => |data| try writer.print("C{d},{d},{d},{d},{d},{d}", .{ data.data.c0.x, data.data.c0.y, data.data.c1.x, data.data.c1.y, data.data.p1.x, data.data.p1.y }),
.arc_circle => |data| try writer.print("A{d},{d},{d},{d},{d},{d},{d}", .{
data.data.radius,
data.data.radius,
0,
@boolToInt(data.data.large_arc),
@boolToInt(!data.data.sweep),
data.data.target.x,
data.data.target.y,
}),
.arc_ellipse => |data| try writer.print("A{d},{d},{d},{d},{d},{d},{d}", .{
data.data.radius_x,
data.data.radius_y,
data.data.rotation,
@boolToInt(data.data.large_arc),
@boolToInt(!data.data.sweep),
data.data.target.x,
data.data.target.y,
}),
.close => try writer.writeAll("Z"),
.quadratic_bezier => |data| try writer.print("Q{d},{d},{d},{d}", .{ data.data.c.x, data.data.c.y, data.data.p1.x, data.data.p1.y }),
}
}
}
}
};
fn svgStyle(
cache: *SvgStyleCache,
fill_style: ?tvg.Style,
line_style: ?tvg.Style,
line_width: ?f32,
) SvgStyle {
return SvgStyle{
.cache = cache,
.fill_style = fill_style,
.line_style = line_style,
.line_width = line_width,
};
}
const SvgStyleCache = struct {
color_table: []const tvg.Color,
list: std.ArrayList(tvg.Style),
pub fn insert(self: *SvgStyleCache, style: tvg.Style) usize {
self.list.append(style) catch @panic("out of memory");
return self.list.items.len - 1;
}
fn printColorForStyle(self: SvgStyleCache, writer: anytype, prefix: []const u8, i: usize) !void {
if (i >= self.color_table.len) {
try writer.print("{s}: #FFFF00;", .{prefix});
}
const color = self.color_table[i];
var r = @floatToInt(u8, std.math.clamp(255.0 * color.r, 0.0, 255.0));
var g = @floatToInt(u8, std.math.clamp(255.0 * color.g, 0.0, 255.0));
var b = @floatToInt(u8, std.math.clamp(255.0 * color.b, 0.0, 255.0));
try writer.print("{s}:#{X:0>2}{X:0>2}{X:0>2};", .{ prefix, r, g, b });
if (color.a != 1.0) {
try writer.print("{s}-opacity:{d};", .{ prefix, color.a });
}
}
fn printColor3AndPrefix(self: SvgStyleCache, writer: anytype, prefix: []const u8, i: usize, postfix: []const u8) !void {
if (i >= self.color_table.len) {
try writer.print("{s}#FFFF00{s}", .{ prefix, postfix });
}
const color = self.color_table[i];
var r = @floatToInt(u8, std.math.clamp(255.0 * color.r, 0.0, 255.0));
var g = @floatToInt(u8, std.math.clamp(255.0 * color.g, 0.0, 255.0));
var b = @floatToInt(u8, std.math.clamp(255.0 * color.b, 0.0, 255.0));
try writer.print("{s}#{X:0>2}{X:0>2}{X:0>2}{s}", .{ prefix, r, g, b, postfix });
}
}; | src/lib/svg.zig |
const Allocator = std.mem.Allocator;
const Headers = @import("./headers/headers.zig").Headers;
const Method = @import("methods.zig").Method;
const std = @import("std");
const Uri = @import("./uri/uri.zig").Uri;
const UriError = @import("./uri/uri.zig").Error;
const Version = @import("versions.zig").Version;
const AllocationError = error{
OutOfMemory,
};
const RequestBuilderError = error{
UriRequired,
};
pub const RequestError = AllocationError || RequestBuilderError || UriError || Headers.Error;
pub const RequestBuilder = struct {
build_error: ?RequestError,
_method: Method,
_uri: ?Uri,
_version: Version,
headers: Headers,
pub fn default(allocator: Allocator) RequestBuilder {
return RequestBuilder{
.build_error = null,
._method = Method.Get,
._uri = null,
._version = Version.Http11,
.headers = Headers.init(allocator),
};
}
inline fn build_has_failed(self: *RequestBuilder) bool {
return self.build_error != null;
}
pub fn body(self: *RequestBuilder, value: []const u8) RequestError!Request {
if (self.build_has_failed()) {
self.headers.deinit();
return self.build_error.?;
}
if (self._uri == null) {
return error.UriRequired;
}
return Request{ .method = self._method, .uri = self._uri.?, .version = self._version, .headers = self.headers, .body = value };
}
pub fn connect(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Connect).uri(_uri);
}
pub fn delete(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Delete).uri(_uri);
}
pub fn get(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Get).uri(_uri);
}
pub fn head(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Head).uri(_uri);
}
pub fn header(self: *RequestBuilder, name: []const u8, value: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
_ = self.headers.append(name, value) catch |err| {
self.build_error = err;
};
return self;
}
pub fn method(self: *RequestBuilder, value: Method) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
self._method = value;
return self;
}
pub fn options(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Options).uri(_uri);
}
pub fn patch(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Patch).uri(_uri);
}
pub fn post(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Post).uri(_uri);
}
pub fn put(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Put).uri(_uri);
}
pub fn trace(self: *RequestBuilder, _uri: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
return self.method(.Trace).uri(_uri);
}
pub fn uri(self: *RequestBuilder, value: []const u8) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
if (Uri.parse(value, false)) |_uri| {
self._uri = _uri;
} else |err| {
self.build_error = err;
}
return self;
}
pub fn version(self: *RequestBuilder, value: Version) *RequestBuilder {
if (self.build_has_failed()) {
return self;
}
self._version = value;
return self;
}
};
pub const Request = struct {
method: Method,
uri: Uri,
version: Version,
headers: Headers,
body: []const u8,
pub fn builder(allocator: Allocator) RequestBuilder {
return RequestBuilder.default(allocator);
}
pub fn deinit(self: *Request) void {
self.headers.deinit();
}
};
const expect = std.testing.expect;
const expectEqualStrings = std.testing.expectEqualStrings;
const expectError = std.testing.expectError;
test "Build with default values" {
var request = try Request.builder(std.testing.allocator)
.uri("https://ziglang.org/")
.body("");
defer request.deinit();
try expect(request.method == Method.Get);
try expect(request.version == .Http11);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
try expect(request.headers.len() == 0);
try expectEqualStrings(request.body, "");
}
test "Build with specific values" {
var request = try Request.builder(std.testing.allocator)
.method(Method.Get)
.uri("https://ziglang.org/")
.version(.Http11)
.header("GOTTA-GO", "FAST")
.body("ᕕ( ᐛ )ᕗ");
defer request.deinit();
try expect(request.method == Method.Get);
try expect(request.version == .Http11);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
try expectEqualStrings(request.body, "ᕕ( ᐛ )ᕗ");
var header = request.headers.get("GOTTA-GO").?;
try expectEqualStrings(header.name.raw(), "GOTTA-GO");
try expectEqualStrings(header.value, "FAST");
}
test "Build with a custom method" {
var request = try Request.builder(std.testing.allocator)
.method(Method{ .Custom = "LAUNCH-MISSILE" })
.uri("https://ziglang.org/")
.body("");
defer request.deinit();
try expectEqualStrings(request.method.Custom, "LAUNCH-MISSILE");
}
test "Fail to build when the URI is missing" {
const failure = Request.builder(std.testing.allocator).body("");
try expectError(error.UriRequired, failure);
}
test "Fail to build when the URI is invalid" {
const failure = Request.builder(std.testing.allocator)
.uri("")
.body("");
try expectError(error.EmptyUri, failure);
}
test "Fail to build when out of memory" {
var buffer: [100]u8 = undefined;
const allocator = std.heap.FixedBufferAllocator.init(&buffer).allocator();
const failure = Request.builder(allocator)
.uri("https://ziglang.org/")
.header("GOTTA-GO", "FAST")
.body("");
try expectError(error.OutOfMemory, failure);
}
test "Free headers memory on error" {
const failure = Request.builder(std.testing.allocator)
.get("https://ziglang.org/")
.header("GOTTA-GO", "FAST")
.header("INVALID HEADER", "")
.body("");
try expectError(error.InvalidHeaderName, failure);
}
test "Build a CONNECT request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).connect("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Connect);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build a DELETE request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).delete("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Delete);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build a GET request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).get("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Get);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build an HEAD request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).head("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Head);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build an OPTIONS request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).options("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Options);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build an PATCH request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).patch("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Patch);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build a POST request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).post("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Post);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build a PUT request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).put("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Put);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
}
test "Build a TRACE request with the shortcut method" {
var request = try Request.builder(std.testing.allocator).trace("https://ziglang.org/").body("");
defer request.deinit();
try expect(request.method == .Trace);
const expectedUri = try Uri.parse("https://ziglang.org/", false);
try expect(Uri.equals(request.uri, expectedUri));
} | src/request.zig |
const std = @import("std");
const stdx = @import("stdx");
const uv = @import("uv");
const graphics = @import("graphics");
const t = stdx.testing;
const runtime = @import("runtime.zig");
const RuntimeContext = runtime.RuntimeContext;
const CsWindow = runtime.CsWindow;
const log = stdx.log.scoped(.devmode);
const DevModeOptions = struct {
max_cmd_items: u32 = 100,
max_stdio_line_items: u32 = 100,
};
pub const DevModeContext = struct {
const Self = @This();
alloc: std.mem.Allocator,
// When no user windows are created, there is always a dev window.
dev_window: ?*CsWindow,
// File watch. Currently just the main script.
watcher: *WatchEntry,
// For now, there is just one global dev term.
term_items: std.ArrayList(TermItem),
term_cmds: std.ArrayList(CommandItem),
term_stdio_lines: std.ArrayList(StdioLineItem),
// Whether the current pos is at an empty new line. (hasn't inserted a line item yet.)
term_stdio_on_new_line: bool,
opts: DevModeOptions,
// In devmode, this is set true on the first uncaught js exception.
// This is then used to ensure that only the dev window interface is active. (User scripts/cbs shouldn't be invoked.)
has_error: bool,
// Once restart is requested, the runtime will perform a restart when appropriate.
// The flag is also used during restart to prevent some things from deiniting in order to persist them into the next session.
restart_requested: bool,
show_hud: bool,
pub fn init(self: *Self, alloc: std.mem.Allocator, opts: DevModeOptions) void {
self.* = .{
.alloc = alloc,
.dev_window = null,
.watcher = undefined,
.term_items = std.ArrayList(TermItem).init(alloc),
.term_cmds = std.ArrayList(CommandItem).init(alloc),
.term_stdio_lines = std.ArrayList(StdioLineItem).init(alloc),
.term_stdio_on_new_line = true,
.opts = opts,
.has_error = false,
.restart_requested = false,
.show_hud = true,
};
}
pub fn initWatcher(self: *Self, rt: *RuntimeContext, abs_path: []const u8) void {
self.watcher = self.alloc.create(WatchEntry) catch unreachable;
self.watcher.* = .{
.event = undefined,
.hash = undefined,
.path = self.alloc.dupe(u8, abs_path) catch unreachable,
};
var uv_res = uv.uv_fs_event_init(rt.uv_loop, &self.watcher.event);
uv.assertNoError(uv_res);
self.watcher.event.data = rt;
stdx.fs.getFileMd5Hash(self.alloc, abs_path, &self.watcher.hash) catch unreachable;
const abs_path_z = std.cstr.addNullByte(self.alloc, abs_path) catch unreachable;
defer self.alloc.free(abs_path_z);
const S = struct {
fn onFileChange(handle: *uv.uv_fs_event_t, filename: [*c]const u8, events: c_int, status: c_int) callconv(.C) void {
_ = filename;
uv.assertNoError(status);
if (events & uv.UV_CHANGE != 0) {
// log.debug("on file change {s}", .{filename});
const entry = stdx.mem.ptrCastAlign(*WatchEntry, handle);
const rt_ = stdx.mem.ptrCastAlign(*RuntimeContext, entry.event.data);
var hash: [16]u8 = undefined;
stdx.fs.getFileMd5Hash(rt_.alloc, entry.path, &hash) catch unreachable;
if (!std.meta.eql(hash, entry.hash)) {
entry.hash = hash;
rt_.dev_ctx.requestRestart();
}
}
}
};
uv_res = uv.uv_fs_event_start(&self.watcher.event, S.onFileChange, abs_path_z, 0);
uv.assertNoError(uv_res);
}
pub fn close(self: Self) void {
const S = struct {
fn onClose(ptr: [*c]uv.uv_handle_t) callconv(.C) void {
const entry = @ptrCast(*WatchEntry, ptr);
const rt = stdx.mem.ptrCastAlign(*RuntimeContext, entry.event.data.?);
entry.deinit(rt.alloc);
rt.alloc.destroy(entry);
}
};
uv.uv_close(@ptrCast(*uv.uv_handle_t, &self.watcher.event), S.onClose);
}
pub fn deinit(self: Self) void {
for (self.term_cmds.items) |it| {
it.deinit(self.alloc);
}
self.term_cmds.deinit();
for (self.term_stdio_lines.items) |it| {
it.deinit(self.alloc);
}
self.term_stdio_lines.deinit();
self.term_items.deinit();
}
pub fn printFmt(self: *Self, comptime format: []const u8, args: anytype) void {
const str = std.fmt.allocPrint(self.alloc, format, args) catch unreachable;
defer self.alloc.free(str);
self.print(str);
}
/// Records an emulated print to stdout.
pub fn print(self: *Self, str: []const u8) void {
var start: usize = 0;
for (str) |ch, i| {
if (ch == '\n') {
if (self.term_stdio_on_new_line) {
// Prepend a new line with everything before the newline.
self.prependStdioLine(str[start..i]);
} else {
// Append to the most recent line.
const new_str = std.fmt.allocPrint(self.alloc, "{s}{s}", .{self.term_stdio_lines.items[0].line, str[start..i]}) catch unreachable;
self.alloc.free(self.term_stdio_lines.items[0].line);
self.term_stdio_lines.items[0].line = new_str;
}
self.term_stdio_on_new_line = true;
start = i + 1;
}
}
if (start < str.len) {
if (self.term_stdio_on_new_line) {
self.prependStdioLine(str[start..str.len]);
self.term_stdio_on_new_line = false;
} else {
const new_str = std.fmt.allocPrint(self.alloc, "{s}{s}", .{self.term_stdio_lines.items[0].line, str[start..str.len]}) catch unreachable;
self.alloc.free(self.term_stdio_lines.items[0].line);
self.term_stdio_lines.items[0].line = new_str;
}
}
}
fn prependStdioLine(self: *Self, line: []const u8) void {
const full = self.term_stdio_lines.items.len == self.opts.max_stdio_line_items;
if (full) {
const last = self.term_stdio_lines.pop();
last.deinit(self.alloc);
}
self.term_stdio_lines.insert(0, .{
.line = self.alloc.dupe(u8, line) catch unreachable,
}) catch unreachable;
self.prependAggTermItem(.StdioLine, if (full) self.opts.max_stdio_line_items-1 else null);
}
fn prependAggTermItem(self: *Self, tag: TermItemTag, mb_remove_idx: ?usize) void {
if (mb_remove_idx) |remove_idx| {
// Remove from aggregate.
var i: u32 = self.aggIndexOfTermItem(tag, remove_idx).?;
while (i > 0) : (i -= 1) {
if (self.term_items.items[i-1].tag == tag) {
self.term_items.items[i] = .{
.tag = tag,
// Increment 1 since we are prepending an item.
.idx = self.term_items.items[i-1].idx + 1,
};
} else {
self.term_items.items[i] = self.term_items.items[i-1];
}
}
self.term_items.items[0] = .{
.tag = tag,
.idx = 0,
};
} else {
// Update aggregate items.
var i: u32 = 0;
while (i < self.term_items.items.len) : (i += 1) {
if (self.term_items.items[i].tag == tag) {
self.term_items.items[i].idx += 1;
}
}
self.term_items.insert(0, .{
.tag = tag,
.idx = 0,
}) catch unreachable;
}
}
pub fn cmdLog(self: *Self, str: []const u8) void {
const full = self.term_cmds.items.len == self.opts.max_cmd_items;
if (full) {
const last = self.term_cmds.pop();
last.deinit(self.alloc);
}
self.term_cmds.insert(0, .{
.msg = self.alloc.dupe(u8, str) catch unreachable,
}) catch unreachable;
self.prependAggTermItem(.Command, if (full) self.opts.max_cmd_items-1 else null);
}
fn aggIndexOfTermItem(self: Self, tag: TermItemTag, idx: usize) ?u32 {
var i: u32 = 0;
while (i < self.term_items.items.len) : (i += 1) {
if (self.term_items.items[i].tag == tag and self.term_items.items[i].idx == idx) {
return i;
}
}
return null;
}
pub fn getAggCommandItem(self: Self, idx: usize) CommandItem {
const cmd_idx = self.term_items.items[idx].idx;
return self.term_cmds.items[cmd_idx];
}
pub fn getAggStdioLineItem(self: Self, idx: usize) StdioLineItem {
const cmd_idx = self.term_items.items[idx].idx;
return self.term_stdio_lines.items[cmd_idx];
}
pub fn enterJsErrorState(self: *Self, rt: *RuntimeContext, js_err_trace: []const u8) void {
self.print(js_err_trace);
self.has_error = true;
self.dev_window = rt.active_window;
}
pub fn enterJsSuccessState(self: *Self) void {
self.has_error = false;
}
pub fn requestRestart(self: *Self) void {
self.restart_requested = true;
}
};
test "DevModeContext command items" {
var ctx: DevModeContext = undefined;
ctx.init(t.alloc, .{
.max_cmd_items = 3,
.max_stdio_line_items = 3,
});
defer ctx.deinit();
// Insert command item.
ctx.cmdLog("Command Log");
try t.eq(ctx.term_cmds.items.len, 1);
try t.eq(ctx.term_items.items.len, 1);
try t.eq(ctx.term_items.items[0].tag, .Command);
try t.eqStr(ctx.getAggCommandItem(0).msg, "Command Log");
// Insert command item to limit.
ctx.cmdLog("Log 1");
ctx.cmdLog("Log 2");
try t.eq(ctx.term_cmds.items.len, 3);
try t.eq(ctx.term_items.items.len, 3);
try t.eqStr(ctx.getAggCommandItem(0).msg, "Log 2");
try t.eqStr(ctx.getAggCommandItem(1).msg, "Log 1");
try t.eqStr(ctx.getAggCommandItem(2).msg, "Command Log");
// Insert command item at limit.
ctx.cmdLog("Command Log");
try t.eq(ctx.term_cmds.items.len, 3);
try t.eq(ctx.term_items.items.len, 3);
try t.eqStr(ctx.getAggCommandItem(0).msg, "Command Log");
try t.eqStr(ctx.getAggCommandItem(1).msg, "Log 2");
try t.eqStr(ctx.getAggCommandItem(2).msg, "Log 1");
}
test "DevModeContext stdio lines" {
t.setLogLevel(.debug);
var ctx: DevModeContext = undefined;
ctx.init(t.alloc, .{
.max_cmd_items = 3,
.max_stdio_line_items = 3,
});
defer ctx.deinit();
ctx.print("Foo");
try t.eq(ctx.term_items.items.len, 1);
try t.eq(ctx.term_stdio_lines.items.len, 1);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Foo");
ctx.print("Bar");
try t.eq(ctx.term_items.items.len, 1);
try t.eq(ctx.term_stdio_lines.items.len, 1);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "FooBar");
ctx.print("\n");
try t.eq(ctx.term_items.items.len, 1);
try t.eq(ctx.term_stdio_lines.items.len, 1);
ctx.print("Foo\n");
try t.eq(ctx.term_items.items.len, 2);
try t.eq(ctx.term_stdio_lines.items.len, 2);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Foo");
try t.eqStr(ctx.getAggStdioLineItem(1).line, "FooBar");
ctx.print("Foo\n");
try t.eq(ctx.term_items.items.len, 3);
try t.eq(ctx.term_stdio_lines.items.len, 3);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Foo");
try t.eqStr(ctx.getAggStdioLineItem(1).line, "Foo");
try t.eqStr(ctx.getAggStdioLineItem(2).line, "FooBar");
ctx.print("Overflow\n");
try t.eq(ctx.term_items.items.len, 3);
try t.eq(ctx.term_stdio_lines.items.len, 3);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Overflow");
try t.eqStr(ctx.getAggStdioLineItem(1).line, "Foo");
try t.eqStr(ctx.getAggStdioLineItem(2).line, "Foo");
}
test "DevModeContext mix term items" {
var ctx: DevModeContext = undefined;
ctx.init(t.alloc, .{
.max_cmd_items = 3,
.max_stdio_line_items = 3,
});
defer ctx.deinit();
ctx.cmdLog("Command 1");
ctx.print("Foo 1\n");
try t.eq(ctx.term_items.items.len, 2);
try t.eq(ctx.term_cmds.items.len, 1);
try t.eq(ctx.term_stdio_lines.items.len, 1);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Foo 1");
try t.eqStr(ctx.getAggCommandItem(1).msg, "Command 1");
ctx.cmdLog("Command 2");
ctx.print("Foo 2\n");
try t.eq(ctx.term_items.items.len, 4);
try t.eq(ctx.term_cmds.items.len, 2);
try t.eq(ctx.term_stdio_lines.items.len, 2);
try t.eqStr(ctx.getAggStdioLineItem(0).line, "Foo 2");
try t.eqStr(ctx.getAggCommandItem(1).msg, "Command 2");
try t.eqStr(ctx.getAggStdioLineItem(2).line, "Foo 1");
try t.eqStr(ctx.getAggCommandItem(3).msg, "Command 1");
}
const WatchEntry = struct {
const Self = @This();
event: uv.uv_fs_event_t,
hash: [16]u8,
path: []const u8,
fn deinit(self: Self, alloc: std.mem.Allocator) void {
alloc.free(self.path);
}
};
const TermItemTag = enum {
Command,
StdioLine,
};
const TermItem = struct {
tag: TermItemTag,
idx: u32,
};
const CommandItem = struct {
const Self = @This();
msg: []const u8,
fn deinit(self: Self, alloc: std.mem.Allocator) void {
alloc.free(self.msg);
}
};
const StdioLineItem = struct {
const Self = @This();
line: []const u8,
fn deinit(self: Self, alloc: std.mem.Allocator) void {
alloc.free(self.line);
}
};
pub fn renderDevHud(rt: *RuntimeContext, w: *CsWindow) void {
if (!rt.dev_ctx.show_hud) {
return;
}
const g = w.graphics;
_ = @intToFloat(f32, w.window.impl.width);
const height = @intToFloat(f32, w.window.impl.height);
g.setFont(g.getDefaultFontId(), 16);
var y = height - 70;
for (rt.dev_ctx.term_items.items) |it, i| {
switch (it.tag) {
.Command => {
const item = rt.dev_ctx.getAggCommandItem(i);
g.setFillColor(graphics.Color.Yellow);
g.fillText(20, y, item.msg);
y -= 25;
},
.StdioLine => {
const item = rt.dev_ctx.getAggStdioLineItem(i);
g.setFillColor(graphics.Color.White);
g.fillText(20, y, item.line);
y -= 25;
},
}
}
// TODO: Render input.
} | runtime/devmode.zig |
const std = @import("std");
const builtin = @import("builtin");
const liu = @import("./lib.zig");
const NULL = std.math.maxInt(u32);
pub const EntityId = struct {
index: u32,
generation: u32,
pub const NULL: EntityId = .{ .index = std.math.maxInt(u32), .generation = 0 };
};
fn FreeEnt(comptime T: type) type {
return union { t: T, next: u32 };
}
const FieldInfo = struct {
is_optional: bool,
is_pointer: bool,
T: type,
};
fn UnwrappedField(comptime FieldT: type) FieldInfo {
const is_optional = @typeInfo(FieldT) == .Optional;
const child = switch (@typeInfo(FieldT)) {
.Optional => |info| info.child,
else => FieldT,
};
const is_pointer = @typeInfo(child) == .Pointer;
const T = switch (@typeInfo(child)) {
.Pointer => |info| info.child,
else => child,
};
return .{
.is_optional = is_optional,
.is_pointer = is_pointer,
.T = T,
};
}
fn RegistryView(comptime Reg: type, comptime InViewType: type) type {
return struct {
pub const ViewType = @Type(.{
.Struct = .{
.layout = .Auto,
.decls = &.{},
.is_tuple = false,
.fields = std.meta.fields(InViewType) ++ [_]std.builtin.Type.StructField{
.{
.name = "id",
.field_type = EntityId,
.default_value = null,
.is_comptime = false,
.alignment = @alignOf(EntityId),
},
.{
.name = "meta",
.field_type = *const Reg.Meta,
.default_value = null,
.is_comptime = false,
.alignment = @alignOf(*const Reg.Meta),
},
},
},
});
const Iter = @This();
registry: *const Reg,
index: u32 = 0,
pub fn read(registry: *const Reg, index: u32) ?ViewType {
const meta = ®istry.raw(Reg.Meta)[index];
var value: ViewType = undefined;
value.id = .{ .index = index, .generation = meta.generation };
value.meta = meta;
inline for (std.meta.fields(ViewType)) |field| {
if (comptime std.mem.eql(u8, field.name, "id")) continue;
if (comptime std.mem.eql(u8, field.name, "meta")) continue;
const unwrapped = UnwrappedField(field.field_type);
if (unwrapped.is_optional) continue;
const Idx = comptime Reg.typeIndex(unwrapped.T) orelse
@compileError("field type not registered: " ++
"name=" ++ field.name ++ ", type=" ++ @typeName(unwrapped.T));
const is_set = meta.bitset.isSet(Idx);
if (!is_set) return null;
const ptr = ®istry.raw(unwrapped.T)[index];
@field(value, field.name) = if (unwrapped.is_pointer) ptr else ptr.*;
}
inline for (std.meta.fields(ViewType)) |field| {
if (comptime std.mem.eql(u8, field.name, "id")) continue;
if (comptime std.mem.eql(u8, field.name, "meta")) continue;
const unwrapped = UnwrappedField(field.field_type);
if (!unwrapped.is_optional) continue;
const Idx = comptime Reg.typeIndex(unwrapped.T) orelse
@compileError("field type not registered: " ++
"name=" ++ field.name ++ ", type=" ++ @typeName(unwrapped.T));
const is_set = meta.bitset.isSet(Idx);
@field(value, field.name) = value: {
if (!is_set) {
break :value null;
}
const ptr = ®istry.raw(unwrapped.T)[index];
break :value if (unwrapped.is_pointer) ptr else ptr.*;
};
}
return value;
}
pub fn get(self: *Iter, id: EntityId) ?ViewType {
const index = self.registry.indexOf(id) orelse return null;
return read(self.registry, index); //, &sparse);
}
pub fn reset(self: *Iter) void {
self.index = 0;
}
pub fn next(self: *Iter) ?ViewType {
while (self.index < self.registry.len) {
// this enforces the index increment, even when the return
// happens below
defer self.index += 1;
const meta = &self.registry.raw(Reg.Meta)[self.index];
if (meta.generation == NULL) continue;
const value = read(self.registry, self.index);
if (value) |v| return v;
}
return null;
}
};
}
// TODO add back sparse (commented out code is wrong so rewrite it lol)
pub fn Registry(
comptime InDense: []const type,
// comptime InSparse: []const type,
) type {
comptime {
// for (InSparse) |T| {
// if (@sizeOf(T) > 0) continue;
// @compileError("Zero-sized components should be Dense. Having them be " ++
// "Dense requires less runtime work, and also I didn't " ++
// "implement all the code for making them sparse. To be clear, " ++
// "there is no performance benefit to a component with size 0 " ++
// "being sparse instead of dense.");
// }
const InComponents = InDense;
// const InComponents = InSparse ++ InDense;
for (InComponents) |T, idx| {
// NOTE: for now, this code is a bit more verbose than necessary.
// Unfortunately, doing `Components[0..idx]` below to filter
// out all repeated instances causes a compiler bug.
for (InComponents) |S, o_idx| {
if (o_idx >= idx) break;
if (T != S) continue;
@compileError("The type '" ++ @typeName(T) ++ "' was registered " ++
"multiple times. Since components are queried by-type, " ++
"you can only have one of a component type for each entity.");
}
}
}
return struct {
const Self = @This();
const Components = DenseComponents;
// const Components = SparseComponents ++ DenseComponents;
const DenseComponents = InDense ++ [_]type{Meta};
// const SparseComponents = InSparse;
pub const Meta = struct {
name: []const u8, // use the len field to store the next freelist element
generation: u32,
bitset: std.StaticBitSet(Components.len - 1),
};
const List = std.ArrayListUnmanaged;
// const Mapping = struct {
// // index is entity ID, value is component index
// map: std.ArrayListUnmanaged(u32) = .{},
// };
const DensePointers = [DenseComponents.len][*]u8;
// const SparsePointers = [SparseComponents.len]List(u8);
alloc: std.mem.Allocator,
generation: u32,
dense: DensePointers,
len: u32,
capacity: u32,
free_head: u32,
pub fn init(capacity: u32, alloc: std.mem.Allocator) !Self {
var dense: DensePointers = undefined;
inline for (DenseComponents) |T, Idx| {
if (@sizeOf(T) == 0) continue;
const slice = try alloc.alloc(T, capacity);
dense[Idx] = @ptrCast([*]u8, slice.ptr);
}
return Self{
.dense = dense,
.len = 0,
.generation = 1,
.capacity = capacity,
.alloc = alloc,
.free_head = NULL,
};
}
pub fn deinit(self: *Self) void {
inline for (DenseComponents) |T, idx| {
if (@sizeOf(T) == 0) continue;
var slice: []T = &.{};
slice.ptr = @ptrCast([*]T, @alignCast(@alignOf(T), self.dense[idx]));
slice.len = self.capacity;
self.alloc.free(slice);
}
}
pub fn create(self: *Self, name: []const u8) !EntityId {
const index = index: {
if (self.free_head != NULL) {
const index = self.free_head;
const meta = &self.raw(Meta)[self.free_head];
self.free_head = @truncate(u32, meta.name.len);
break :index index;
}
if (self.len >= self.capacity) {
const new_capa = self.capacity + self.capacity / 2;
inline for (DenseComponents) |T, idx| {
if (@sizeOf(T) == 0) continue;
var slice: []T = &.{};
slice.ptr = @ptrCast([*]T, @alignCast(@alignOf(T), self.dense[idx]));
slice.len = self.capacity;
const new_mem = try self.alloc.realloc(slice, new_capa);
self.dense[idx] = @ptrCast([*]u8, new_mem.ptr);
}
self.capacity = new_capa;
}
const index = self.len;
self.len += 1;
break :index index;
};
const meta = &self.raw(Meta)[index];
meta.name = name;
meta.generation = self.generation;
meta.bitset = std.StaticBitSet(Components.len - 1).initEmpty();
return EntityId{ .index = index, .generation = self.generation };
}
pub fn delete(self: *Self, id: EntityId) bool {
const index = self.indexOf(id) orelse return false;
const meta = &self.raw(Meta)[index];
meta.generation = NULL;
meta.name = "";
meta.name.len = self.free_head;
self.free_head = id.index;
self.generation += 1;
return true;
}
pub fn addComponent(self: *Self, id: EntityId, component: anytype) !void {
const T = @TypeOf(component);
if (T == Meta) @compileError("Tried to add a Meta component");
const index = self.indexOf(id) orelse return;
const Idx = comptime typeIndex(T) orelse
@compileError("Type not registered: " ++ @typeName(T));
// we defer here so that we can read the previous value before
// returning
defer self.raw(Meta)[index].bitset.set(Idx);
const elements = self.raw(T);
elements[index] = component;
return;
}
fn raw(self: *const Self, comptime T: type) []T {
if (comptime denseTypeIndex(T)) |Idx| {
var slice: []T = &.{};
slice.len = self.len;
if (@sizeOf(T) > 0) {
slice.ptr = @ptrCast([*]T, @alignCast(@alignOf(T), self.dense[Idx]));
}
return slice;
}
@compileError("Type not registered: " ++ @typeName(T));
}
pub fn view(self: *Self, comptime ViewType: type) RegistryView(Self, ViewType) {
return .{ .registry = self };
}
fn indexOf(self: *Self, id: EntityId) ?u32 {
const meta_slice = self.raw(Meta);
if (id.index >= meta_slice.len) return null;
const meta = &meta_slice[id.index];
if (meta.generation > id.generation) return null;
return id.index;
}
fn typeIndex(comptime T: type) ?usize {
for (Components) |Component, idx| {
if (T == Component) return idx;
}
return null;
}
fn denseTypeIndex(comptime T: type) ?usize {
for (DenseComponents) |Component, idx| {
if (T == Component) return idx;
}
return null;
}
};
}
test "Registry: iterate" {
const TransformComponent = struct { i: u32 };
const MoveComponent = struct {};
const RegistryType = Registry(&.{ TransformComponent, MoveComponent });
var registry = try RegistryType.init(256, liu.Pages);
defer registry.deinit();
var success = false;
var i: u32 = 0;
while (i < 257) : (i += 1) {
const meh = try registry.create("meh");
success = try registry.addComponent(meh, TransformComponent{ .i = meh.index });
try std.testing.expect(success);
}
try std.testing.expect(registry.len == 257);
try std.testing.expect(registry.capacity > 256);
const View = struct {
transform: ?TransformComponent,
move: ?*MoveComponent,
};
var view = registry.view(View);
while (view.next()) |elem| {
try std.testing.expect(elem.meta.name.len == 3);
if (elem.transform) |t|
try std.testing.expect(t.i == elem.id.index)
else
try std.testing.expect(false);
try std.testing.expect(elem.move == null);
}
}
test "Registry: delete" {
const TransformComponent = struct {};
const MoveComponent = struct {};
const RegistryType = Registry(&.{ TransformComponent, MoveComponent });
var registry = try RegistryType.init(256, liu.Pages);
defer registry.deinit();
const View = struct {
transform: ?TransformComponent,
move: ?*MoveComponent,
};
_ = try registry.create("meh");
const deh = try registry.create("dehh");
try std.testing.expect(registry.delete(deh));
var view = registry.view(View);
var count: u32 = 0;
while (view.next()) |elem| {
try std.testing.expect(elem.meta.name.len == 3);
count += 1;
}
try std.testing.expect(count == 1);
view.reset();
} | src/liu/ecs.zig |
const std = @import("std");
usingnamespace @import("ast.zig");
usingnamespace @import("interpreter.zig");
usingnamespace @import("gc.zig");
usingnamespace @import("sourcelocation.zig");
// Intrinsic symbol- and function expressions. These expressions are not registered with
// the GC and are thus considered pinned and never attemped deallocated.
pub var expr_atom_last_eval = Expr{ .val = ExprValue{ .sym = "#?" } };
pub var expr_atom_last_try_err = Expr{ .val = ExprValue{ .sym = "#!" } };
pub var expr_atom_last_try_value = Expr{ .val = ExprValue{ .sym = "#value" } };
pub var expr_atom_quote = Expr{ .val = ExprValue{ .sym = "quote" } };
pub var expr_atom_quasi_quote = Expr{ .val = ExprValue{ .sym = "quasiquote" } };
pub var expr_atom_unquote = Expr{ .val = ExprValue{ .sym = "unquote" } };
pub var expr_atom_unquote_splicing = Expr{ .val = ExprValue{ .sym = "unquote-splicing" } };
pub var expr_atom_list = Expr{ .val = ExprValue{ .sym = "list" } };
pub var expr_atom_if = Expr{ .val = ExprValue{ .sym = "if" } };
pub var expr_atom_cond = Expr{ .val = ExprValue{ .sym = "cond" } };
pub var expr_atom_begin = Expr{ .val = ExprValue{ .sym = "begin" } };
pub var expr_atom_false = Expr{ .val = ExprValue{ .sym = "#f" } };
pub var expr_atom_true = Expr{ .val = ExprValue{ .sym = "#t" } };
pub var expr_atom_nil = Expr{ .val = ExprValue{ .sym = "nil" } };
pub var expr_atom_rest = Expr{ .val = ExprValue{ .sym = "&rest" } };
pub var expr_std_math_pi = Expr{ .val = ExprValue{ .num = std.math.pi } };
pub var expr_std_math_e = Expr{ .val = ExprValue{ .num = std.math.e } };
pub var expr_std_import = Expr{ .val = ExprValue{ .fun = stdImport } };
pub var expr_std_exit = Expr{ .val = ExprValue{ .fun = stdExit } };
pub var expr_std_verbose = Expr{ .val = ExprValue{ .fun = stdVerbose } };
pub var expr_std_assert_true = Expr{ .val = ExprValue{ .fun = stdAssertTrue } };
pub var expr_std_is_number = Expr{ .val = ExprValue{ .fun = stdIsNumber } };
pub var expr_std_is_symbol = Expr{ .val = ExprValue{ .fun = stdIsSymbol } };
pub var expr_std_is_list = Expr{ .val = ExprValue{ .fun = stdIsList } };
pub var expr_std_is_callable = Expr{ .val = ExprValue{ .fun = stdIsCallable } };
pub var expr_std_gensym = Expr{ .val = ExprValue{ .fun = stdGenSym } };
pub var expr_std_quote = Expr{ .val = ExprValue{ .fun = stdQuote } };
pub var expr_std_unquote = Expr{ .val = ExprValue{ .fun = stdUnquote } };
pub var expr_std_unquote_splicing = Expr{ .val = ExprValue{ .fun = stdUnquoteSplicing } };
pub var expr_std_quasi_quote = Expr{ .val = ExprValue{ .fun = stdQuasiQuote } };
pub var expr_std_double_quote = Expr{ .val = ExprValue{ .fun = stdDoubleQuote } };
pub var expr_std_len = Expr{ .val = ExprValue{ .fun = stdLen } };
pub var expr_std_range = Expr{ .val = ExprValue{ .fun = stdRange } };
pub var expr_std_string = Expr{ .val = ExprValue{ .fun = stdString } };
pub var expr_std_print = Expr{ .val = ExprValue{ .fun = stdPrint } };
pub var expr_std_read_line = Expr{ .val = ExprValue{ .fun = stdReadline } };
pub var expr_std_env = Expr{ .val = ExprValue{ .fun = stdEnv } };
pub var expr_std_self = Expr{ .val = ExprValue{ .fun = stdSelf } };
pub var expr_std_define = Expr{ .val = ExprValue{ .fun = stdDefine } };
pub var expr_std_lambda = Expr{ .val = ExprValue{ .fun = stdLambda } };
pub var expr_std_macro = Expr{ .val = ExprValue{ .fun = stdMacro } };
pub var expr_std_eval_string = Expr{ .val = ExprValue{ .fun = stdEvalString } };
pub var expr_std_eval = Expr{ .val = ExprValue{ .fun = stdEval } };
pub var expr_std_apply = Expr{ .val = ExprValue{ .fun = stdApply } };
pub var expr_std_list = Expr{ .val = ExprValue{ .fun = stdList } };
pub var expr_std_append = Expr{ .val = ExprValue{ .fun = stdAppend } };
pub var expr_std_unset = Expr{ .val = ExprValue{ .fun = stdUnset } };
pub var expr_std_error = Expr{ .val = ExprValue{ .fun = stdError } };
pub var expr_std_try = Expr{ .val = ExprValue{ .fun = stdTry } };
pub var expr_std_set = Expr{ .val = ExprValue{ .fun = stdSet } };
pub var expr_std_sum = Expr{ .val = ExprValue{ .fun = stdSum } };
pub var expr_std_sub = Expr{ .val = ExprValue{ .fun = stdSub } };
pub var expr_std_mul = Expr{ .val = ExprValue{ .fun = stdMul } };
pub var expr_std_div = Expr{ .val = ExprValue{ .fun = stdDiv } };
pub var expr_std_pow = Expr{ .val = ExprValue{ .fun = stdPow } };
pub var expr_std_time_now = Expr{ .val = ExprValue{ .fun = stdTimeNow } };
pub var expr_std_floor = Expr{ .val = ExprValue{ .fun = stdFloor } };
pub var expr_std_as = Expr{ .val = ExprValue{ .fun = stdAs } };
pub var expr_std_order = Expr{ .val = ExprValue{ .fun = stdOrder } };
pub var expr_std_eq = Expr{ .val = ExprValue{ .fun = stdEq } };
pub var expr_std_eq_approx = Expr{ .val = ExprValue{ .fun = stdEqApprox } };
pub var expr_std_run_gc = Expr{ .val = ExprValue{ .fun = stdRunGc } };
pub var expr_std_file_open = Expr{ .val = ExprValue{ .fun = stdFileOpen } };
pub var expr_std_file_close = Expr{ .val = ExprValue{ .fun = stdFileClose } };
pub var expr_std_file_read_line = Expr{ .val = ExprValue{ .fun = stdFileReadLine } };
pub var expr_std_file_write_line = Expr{ .val = ExprValue{ .fun = stdFileWriteLine } };
pub fn requireExactArgCount(args_required: usize, args: []const *Expr) !void {
if (args.len != args_required) {
return ExprErrors.InvalidArgumentCount;
}
}
pub fn requireMinimumArgCount(args_required: usize, args: []const *Expr) !void {
if (args.len < args_required) {
return ExprErrors.InvalidArgumentCount;
}
}
pub fn requireType(ev: *Interpreter, expr: *Expr, etype: ExprType) !void {
if (expr.val != etype) {
try ev.printErrorFmt(&expr.src, "Expected {}, got argument type: {}, actual value:\n", .{ etype, std.meta.activeTag(expr.val) });
try expr.print();
return ExprErrors.AlreadyReported;
}
}
/// Signals the interpreter to terminate with an exit code. We don't simply terminate
/// the process here, as we're running with leak detection, but rather sets and exit code
/// which causes the eval loop to exit. This helps stress testing the GC/cleanup logic.
pub fn stdExit(ev: *Interpreter, _: *Env, args: []const *Expr) anyerror!*Expr {
var exit_code: u8 = 0;
if (args.len > 0 and args[0].val == ExprType.num) {
exit_code = @floatToInt(u8, args[0].val.num);
}
ev.exit_code = exit_code;
return &expr_atom_nil;
}
/// Open a file for reading and writing, create it if necessary. This produces an "any"
/// expression, where the value is an opaque pointer that's casted back to its actual
/// type when needed, such as in stdFileReadline.
pub fn stdFileOpen(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const filename_expr = try ev.eval(env, args[0]);
if (filename_expr.val == ExprType.sym) {
var path = try std.fs.path.resolve(allocator, &.{filename_expr.val.sym});
defer allocator.free(path);
var file = try allocator.create(std.fs.File);
errdefer allocator.destroy(file);
file.* = std.fs.createFileAbsolute(path, .{ .truncate = false, .read = true }) catch |err| {
try ev.printErrorFmt(&filename_expr.src, "Could not open file: {}\n", .{err});
return err;
};
var expr = try Expr.create(true);
expr.val = ExprValue{ .any = @ptrToInt(file) };
return expr;
}
return &expr_atom_nil;
}
/// Close a file, and deallocate the associated File object
pub fn stdFileClose(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const file_ptr = try ev.eval(env, args[0]);
try requireType(ev, file_ptr, ExprType.any);
const file = @intToPtr(*std.fs.File, file_ptr.val.any);
file.close();
allocator.destroy(file);
return &expr_atom_nil;
}
/// Reads a line from the file
pub fn stdFileReadLine(ev: *Interpreter, env: *Env, args: []const *Expr) !*Expr {
try requireExactArgCount(1, args);
const file_ptr = try ev.eval(env, args[0]);
try requireType(ev, file_ptr, ExprType.any);
const file = @intToPtr(*std.fs.File, file_ptr.val.any);
if (file.reader().readUntilDelimiterOrEofAlloc(allocator, '\n', std.math.maxInt(usize))) |maybe| {
if (maybe) |line| {
return makeAtomAndTakeOwnership(line);
} else {
return try makeError(try makeAtomByDuplicating("EOF"));
}
} else |_| {
return try makeError(try makeAtomByDuplicating("Could not read from file"));
}
}
/// Appends a line to the file
pub fn stdFileWriteLine(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
const file_ptr = try ev.eval(env, args[0]);
const line_to_write = try ev.eval(env, args[1]);
try requireType(ev, file_ptr, ExprType.any);
try requireType(ev, line_to_write, ExprType.sym);
const file = @intToPtr(*std.fs.File, file_ptr.val.any);
try file.seekFromEnd(0);
try file.writer().writeAll(line_to_write.val.sym);
_ = try file.writer().write("\n");
return &expr_atom_nil;
}
/// Import and evaluate a Bio file
pub fn stdImport(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const filename_expr = try ev.eval(env, args[0]);
if (filename_expr.val == ExprType.sym) {
var out: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var path = std.fs.realpath(filename_expr.val.sym, &out) catch |err| switch (err) {
std.os.RealPathError.FileNotFound => {
try ev.printErrorFmt(&filename_expr.src, "File not found: {s}\n", .{filename_expr.val.sym});
return ExprErrors.AlreadyReported;
},
else => return err,
};
try SourceLocation.push(path[0..]);
defer SourceLocation.pop();
const file = std.fs.openFileAbsolute(path, .{}) catch |err| {
try ev.printErrorFmt(&filename_expr.src, "Could not open file: {}\n", .{err});
return err;
};
defer file.close();
const reader = file.reader();
var res: *Expr = &expr_atom_nil;
while (!ev.has_errors) {
if (ev.readBalancedExpr(&reader, "")) |maybe| {
if (maybe) |input| {
defer allocator.free(input);
if (try ev.parseAndEvalExpression(input)) |e| {
res = e;
try ev.env.put("#?", res);
}
} else {
break;
}
} else |err| {
try ev.printErrorFmt(&filename_expr.src, "(import) could not read expression: {}\n", .{err});
break;
}
}
return res;
} else {
return ExprErrors.InvalidArgumentType;
}
}
pub fn stdRunGc(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = ev;
_ = env;
_ = args;
try gc.run(true);
return &expr_atom_nil;
}
pub fn stdVerbose(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = env;
_ = args;
ev.verbose = !ev.verbose;
const bool_str = if (ev.verbose) "on " else "off";
try std.io.getStdOut().writer().print("Verbosity is now {s}\n", .{bool_str});
return &expr_atom_nil;
}
pub fn stdAssertTrue(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
if ((try ev.eval(env, args[0])) != &expr_atom_true) {
try std.io.getStdOut().writer().print("Assertion failed {s} line {d}\n", .{ args[0].src.file, args[0].src.line });
std.process.exit(0);
}
return &expr_atom_true;
}
/// Renders the expression as a string and returns an owned slice.
/// For now, only newline escapes are done (this should be extended to handle all of them)
fn render(ev: *Interpreter, env: *Env, expr: *Expr) ![]u8 {
_ = ev;
_ = env;
const str = try expr.toStringAlloc();
defer allocator.free(str);
return try std.mem.replaceOwned(u8, allocator, str, "\\n", "\n");
}
/// Implements (string expr...), i.e. rendering of expressions as strings
pub fn stdString(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var builder = std.ArrayList(u8).init(allocator);
defer builder.deinit();
const writer = builder.writer();
for (args) |expr| {
const value = try ev.eval(env, expr);
const rendered = try render(ev, env, value);
defer allocator.free(rendered);
try writer.writeAll(rendered);
}
return makeAtomByDuplicating(builder.items);
}
/// Implements (print expr...)
pub fn stdPrint(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
for (args) |expr, index| {
const value = try ev.eval(env, expr);
const rendered = try render(ev, env, value);
defer allocator.free(rendered);
try std.io.getStdOut().writer().print("{s}", .{rendered});
if (index + 1 < args.len) {
try std.io.getStdOut().writer().print(" ", .{});
}
}
return &expr_atom_nil;
}
/// Implements (readline)
pub fn stdReadline(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = ev;
_ = env;
_ = args;
if (try std.io.getStdIn().reader().readUntilDelimiterOrEofAlloc(allocator, '\n', std.math.maxInt(u32))) |line| {
return try makeAtomAndTakeOwnership(line);
}
return &expr_atom_nil;
}
/// Returns the current environment as an expression, allowing the user to make constructs
/// such as modules and object instances.
pub fn stdSelf(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = ev;
_ = args;
var expr = try Expr.create(true);
expr.val = ExprValue{ .env = env };
return expr;
}
/// Print environments. Runs the GC to minimize the environment listing, unless no-gc is passed.
pub fn stdEnv(ev: *Interpreter, _: *Env, args: []const *Expr) anyerror!*Expr {
if (!(args.len > 0 and args[0].val == ExprType.sym and std.mem.eql(u8, args[0].val.sym, "no-gc"))) {
try gc.run(false);
}
// Print out all environments, including which environment is the parent.
for (gc.registered_envs.items) |registered_env| {
try std.io.getStdOut().writer().print("Environment for {s}: {*}\n", .{ registered_env.name, registered_env });
var iter = registered_env.map.iterator();
while (iter.next()) |item| {
try std.io.getStdOut().writer().writeByteNTimes(' ', 4);
try std.io.getStdOut().writer().print("{s} = ", .{item.key_ptr.*.val.sym});
try item.value_ptr.*.print();
if (ev.verbose) {
try std.io.getStdOut().writer().print(", env {*}", .{item.value_ptr.*.env});
}
try std.io.getStdOut().writer().print("\n", .{});
}
if (registered_env.parent) |parent| {
try std.io.getStdOut().writer().writeByteNTimes(' ', 4);
try std.io.getStdOut().writer().print("Parent environment is {s}: {*}\n", .{ parent.name, parent });
}
try std.io.getStdOut().writer().print("\n", .{});
}
return &expr_atom_nil;
}
/// Like (if), but the branch is chosen based on error state
pub fn stdTry(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(2, args);
// Select branch based on the presence of an error
var branch: usize = 1;
const result = try ev.eval(env, args[0]);
if (result.val == ExprType.err) {
try ev.env.put(expr_atom_last_try_err.val.sym, result);
branch += 1;
} else {
try ev.env.put(expr_atom_last_try_value.val.sym, result);
}
// The error branch is optional
if (branch < args.len) {
return try ev.eval(env, args[branch]);
} else {
return &expr_atom_nil;
}
}
/// Create an error expression
pub fn stdError(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
return try makeError(try ev.eval(env, args[0]));
}
pub fn isEmptyList(expr: *Expr) bool {
return (expr.val == ExprType.lst and expr.val.lst.items.len == 0);
}
pub fn isFalsy(expr: *Expr) bool {
return expr == &expr_atom_false or expr == &expr_atom_nil or isEmptyList(expr);
}
/// Ordering, where lists are compared recurisively
fn order(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!std.math.Order {
try requireExactArgCount(2, args);
const op1 = args[0];
const op2 = args[1];
if (op1.val == ExprType.num and op2.val == ExprType.num) {
return std.math.order(op1.val.num, op2.val.num);
} else if (op1 == &expr_atom_nil and op2 == &expr_atom_nil) {
return std.math.Order.eq;
} else if (op1 == &expr_atom_nil and op2 == &expr_atom_false) {
return std.math.Order.eq;
} else if (op1 == &expr_atom_true and op2 == &expr_atom_true) {
return std.math.Order.eq;
} else if (op1 == &expr_atom_true) {
return std.math.Order.lt;
} else if (op1 == &expr_atom_false and (op2 == &expr_atom_false or op2 == &expr_atom_nil)) {
return std.math.Order.eq;
} else if (op1 == &expr_atom_false) {
return std.math.Order.lt;
} else if (op1.val == ExprType.sym and op2.val == ExprType.sym) {
return std.mem.order(u8, op1.val.sym, op2.val.sym);
} else if (op1 == &expr_atom_nil) {
return if (isEmptyList(op2)) std.math.Order.eq else std.math.Order.lt;
} else if (op2 == &expr_atom_nil) {
return if (isEmptyList(op1)) std.math.Order.eq else std.math.Order.gt;
} else if (op1.val == ExprType.lst and op2.val == ExprType.lst) {
var res = std.math.order(op1.val.lst.items.len, op2.val.lst.items.len);
if (res == std.math.Order.eq) {
for (op1.val.lst.items) |item, index| {
res = try order(ev, env, &.{ item, op2.val.lst.items[index] });
if (res != std.math.Order.eq) {
return res;
}
}
}
return res;
} else {
return ExprErrors.InvalidArgumentType;
}
}
/// Returns an numeric expression with values -1, 0, 1 to represent <, =, > respectively
pub fn stdOrder(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
return switch (try order(ev, env, &.{ try ev.eval(env, args[0]), try ev.eval(env, args[1]) })) {
std.math.Order.lt => return makeNumExpr(-1),
std.math.Order.eq => return makeNumExpr(0),
std.math.Order.gt => return makeNumExpr(1),
};
}
/// Turn a boolean into #f or #t
fn boolExpr(val: bool) *Expr {
return if (val) &expr_atom_true else &expr_atom_false;
}
/// Check for equality. If the order operation fails, such as incompatiable types, false is returned.
pub fn stdEq(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
return boolExpr((order(ev, env, &.{ try ev.eval(env, args[0]), try ev.eval(env, args[1]) }) catch return &expr_atom_false) == std.math.Order.eq);
}
/// Compare floats with a small relative epsilon comparison. An optional third argument overrides the tolerance.
pub fn stdEqApprox(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(2, args);
const op1 = try ev.eval(env, args[0]);
const op2 = try ev.eval(env, args[1]);
var tolerance: f64 = 1e-7;
if (args.len == 3) {
const tolerance_expr = try ev.eval(env, args[2]);
if (tolerance_expr.val == ExprType.num) {
tolerance = tolerance_expr.val.num;
}
}
if (op1.val == ExprType.num and op2.val == ExprType.num) {
return boolExpr(std.math.approxEqRel(f64, op1.val.num, op2.val.num, tolerance));
} else {
return ExprErrors.InvalidArgumentType;
}
}
pub fn stdIsNumber(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
const arg = try ev.eval(env, args[0]);
return switch (arg.val) {
ExprType.num => &expr_atom_true,
else => &expr_atom_false,
};
}
pub fn stdIsSymbol(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
const arg = try ev.eval(env, args[0]);
return switch (arg.val) {
ExprType.sym => &expr_atom_true,
else => &expr_atom_false,
};
}
pub fn stdIsList(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
const arg = try ev.eval(env, args[0]);
return if (arg.val == ExprType.lst) &expr_atom_true else &expr_atom_false;
}
pub fn stdIsCallable(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
const arg = try ev.eval(env, args[0]);
return switch (arg.val) {
ExprType.fun, ExprType.lam, ExprType.mac => &expr_atom_true,
else => &expr_atom_false,
};
}
/// (gensym) will generate a unique identifier
pub fn stdGenSym(ev: *Interpreter, _: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(0, args);
ev.gensym_seq += 1;
const sym = try std.fmt.allocPrint(allocator, "gensym_{d}", .{ev.gensym_seq});
return makeAtomAndTakeOwnership(sym);
}
/// Renders the expression and wraps it in double quotes, returning a new atom
pub fn stdDoubleQuote(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const arg = try ev.eval(env, args[0]);
const rendered = try render(ev, env, arg);
defer allocator.free(rendered);
const double_quoted = try std.fmt.allocPrint(allocator, "\"{s}\"", .{rendered});
return makeAtomAndTakeOwnership(double_quoted);
}
/// Returns the first argument unevaluated. Multiple arguments is an error,
/// though the argument may be a list. (quote (1 2 3)) -> '(1 2 3)
pub fn stdQuote(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = ev;
_ = env;
try requireExactArgCount(1, args);
return args[0];
}
/// Unquote is only useful in combination with quasiquoting, see stdQuasiQuote
pub fn stdUnquote(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = env;
_ = args;
try ev.printErrorFmt(SourceLocation.current(), "Can only use unquote inside a quasiquote expression\n", .{});
return ExprErrors.AlreadyReported;
}
/// Unquote with splicing is only useful in combination with quasiquoting, see stdQuasiQuote
pub fn stdUnquoteSplicing(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = env;
_ = args;
try ev.printErrorFmt(SourceLocation.current(), "Can only use unquote-splicing inside a quasiquote expression\n", .{});
return ExprErrors.AlreadyReported;
}
/// Recursive quasi-quote expansion
/// (quasiquote (1 2 (unquote (+ 1 2)) 4)) -> '(1 2 3 4)
/// (quasiquote (1 (unquote-splicing (list 2 3)) 4)) -> '(1 2 3 4)
pub fn stdQuasiQuote(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const qq_expander = struct {
fn expand(ev_inner: *Interpreter, env_inner: *Env, expr: *Expr) anyerror!*Expr {
if (expr.val == ExprType.lst) {
var result_list = try makeListExpr(null);
for (expr.val.lst.items) |item| {
// May encounter empty lists, such as lambda ()
if (item.val == ExprType.lst and item.val.lst.items.len > 0) {
if (item.val.lst.items[0] == &expr_atom_unquote) {
try result_list.val.lst.append(try ev_inner.eval(env_inner, item.val.lst.items[1]));
} else if (item.val.lst.items[0] == &expr_atom_unquote_splicing) {
const list = try ev_inner.eval(env_inner, item.val.lst.items[1]);
try requireType(ev_inner, list, ExprType.lst);
for (list.val.lst.items) |list_item| {
try result_list.val.lst.append(list_item);
}
} else {
try result_list.val.lst.append(try expand(ev_inner, env_inner, item));
}
} else {
if (item.val == ExprType.sym and item == &expr_atom_unquote) {
return try ev_inner.eval(env_inner, expr.val.lst.items[1]);
} else if (item.val == ExprType.sym and item == &expr_atom_unquote_splicing) {
try ev_inner.printErrorFmt(&expr.src, "unquotes-splice must be called from within a list\n", .{});
return ExprErrors.AlreadyReported;
} else {
try result_list.val.lst.append(item);
}
}
}
return result_list;
} else {
return expr;
}
}
};
if (ev.verbose) {
try args[0].print();
try std.io.getStdOut().writer().print("\n ^ quasiquote pre-expand\n", .{});
}
const res = try qq_expander.expand(ev, env, args[0]);
if (ev.verbose) {
try res.print();
try std.io.getStdOut().writer().print("\n ^ quasiquote post-expand\n", .{});
}
return res;
}
/// Implements (range list start? end?) where negative indices are end-relative
/// If both start and end are missing, return the first element as in (car list)
pub fn stdRange(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(1, args);
const listArg = try ev.eval(env, args[0]);
try requireType(ev, listArg, ExprType.lst);
const list = listArg.val.lst;
const size = @intCast(isize, list.items.len);
if (args.len > 1) {
const startArg = try ev.eval(env, args[1]);
try requireType(ev, startArg, ExprType.num);
var start = @floatToInt(isize, startArg.val.num);
var end = val: {
if (args.len > 2) {
const endArg = try ev.eval(env, args[2]);
try requireType(ev, endArg, ExprType.num);
break :val std.math.min(@intCast(isize, list.items.len), @floatToInt(isize, endArg.val.num));
} else break :val @intCast(isize, list.items.len);
};
if (start < 0) {
start = size + start;
}
if (end < 0) {
end = size + end;
}
var res = try makeListExpr(null);
if (size > 0 and end > 0 and start >= 0 and start < size and end <= size) {
try res.val.lst.appendSlice(list.items[@intCast(usize, start)..@intCast(usize, end)]);
return res;
} else {
return &expr_atom_nil;
}
} else {
return if (size > 0) list.items[0] else &expr_atom_nil;
}
}
pub fn stdSum(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var sum: f64 = 0;
for (args) |expr| {
const arg = try ev.eval(env, expr);
switch (arg.val) {
ExprType.num => |num| sum += num,
else => return ExprErrors.ExpectedNumber,
}
}
return makeNumExpr(sum);
}
pub fn stdSub(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var res: f64 = 0;
for (args) |expr, index| {
const arg = try ev.eval(env, expr);
switch (arg.val) {
ExprType.num => |num| {
// In the unary case, 0 is the implicit first operand
if (index == 0 and args.len > 1) {
res = num;
} else {
res -= num;
}
},
else => return ExprErrors.ExpectedNumber,
}
}
return makeNumExpr(res);
}
pub fn stdMul(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var sum: f64 = 1;
for (args) |expr| {
const arg = try ev.eval(env, expr);
switch (arg.val) {
ExprType.num => |num| sum *= num,
else => return ExprErrors.ExpectedNumber,
}
}
return makeNumExpr(sum);
}
pub fn stdDiv(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var res: f64 = 0;
for (args) |expr, index| {
const arg = try ev.eval(env, expr);
switch (arg.val) {
ExprType.num => |num| {
if (index == 0) {
res = num;
} else {
if (num == 0) {
try ev.printErrorFmt(&expr.src, "Division by zero\n", .{});
return &expr_atom_nil;
}
res /= num;
}
},
else => return ExprErrors.ExpectedNumber,
}
}
return makeNumExpr(res);
}
pub fn stdPow(ev: *Interpreter, _: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
try requireType(ev, args[0], ExprType.num);
try requireType(ev, args[1], ExprType.num);
return makeNumExpr(std.math.pow(f64, args[0].val.num, args[1].val.num));
}
pub fn stdTimeNow(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
_ = ev;
_ = env;
_ = args;
return makeNumExpr(@intToFloat(f64, std.time.milliTimestamp()));
}
/// Returns the length of a list or symbol, otherwise nil
pub fn stdLen(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const expr = try ev.eval(env, args[0]);
switch (expr.val) {
ExprType.sym => return try makeNumExpr(@intToFloat(f64, expr.val.sym.len)),
ExprType.lst => {
std.debug.print("Converting {d} to float\n", .{expr.val.lst.items.len});
return try makeNumExpr(@intToFloat(f64, expr.val.lst.items.len));
},
else => {
try ev.printErrorFmt(&expr.src, "len function only works on lists and symbols\n", .{});
return &expr_atom_nil;
},
}
}
/// Convert between symbols, numbers and lists, such as (as number (readline))
pub fn stdAs(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
const target_type = args[0];
const expr = try ev.eval(env, args[1]);
try requireType(ev, target_type, ExprType.sym);
if (std.mem.eql(u8, target_type.val.sym, "number")) {
switch (expr.val) {
ExprType.num => return expr,
ExprType.sym => return try makeNumExpr(try std.fmt.parseFloat(f64, expr.val.sym)),
else => return &expr_atom_nil,
}
} else if (std.mem.eql(u8, target_type.val.sym, "symbol")) {
switch (expr.val) {
ExprType.sym => return expr,
ExprType.num => |num| {
const val = try std.fmt.allocPrint(allocator, "{d}", .{num});
return makeAtomLiteral(val, true);
},
ExprType.lst => |lst| {
var res = std.ArrayList(u8).init(allocator);
var exprWriter = res.writer();
defer res.deinit();
for (lst.items) |item| {
const str = try item.toStringAlloc();
defer allocator.free(str);
try exprWriter.writeAll(str);
}
return makeAtomByDuplicating(res.items);
},
else => return &expr_atom_nil,
}
} else if (std.mem.eql(u8, target_type.val.sym, "list")) {
if (expr.val == ExprType.lst) {
return expr;
}
const list = try makeListExpr(null);
try list.val.lst.append(expr);
return list;
} else {
try ev.printErrorFmt(&expr.src, "Invalid target type in (as): {s}. Must be number, symbol or list\n", .{target_type.val.sym});
return &expr_atom_nil;
}
}
pub fn stdFloor(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
const arg = try ev.eval(env, args[0]);
try requireType(ev, arg, ExprType.num);
return makeNumExpr(@floor(arg.val.num));
}
/// This is called when a lambda is defined, not when it's invoked
/// The first argument must be a list, namely the lambda arguments
pub fn stdLambda(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(2, args);
try requireType(ev, args[0], ExprType.lst);
var expr = try makeLambdaExpr(env);
try expr.val.lam.appendSlice(args);
return expr;
}
/// This is called when a macro is defined
/// The first argument must be a list, namely the macro arguments
pub fn stdMacro(ev: *Interpreter, _: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(2, args);
try requireType(ev, args[0], ExprType.lst);
var expr = try makeMacroExpr();
try expr.val.mac.appendSlice(args);
return expr;
}
/// Evaluate the arguments, returning the last one as the result. If quote and quasiquote
/// expressions are encountered, these are unquoted before evaluation.
pub fn stdEval(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var res: *Expr = &expr_atom_nil;
for (args) |arg| {
if (arg.val == ExprType.lst and (arg.val.lst.items[0] == &expr_atom_quote or arg.val.lst.items[0] == &expr_atom_quasi_quote)) {
res = try ev.eval(env, try ev.eval(env, arg));
} else {
res = try ev.eval(env, arg);
}
}
return res;
}
/// Parses and evaluates a string (that is, a symbol containing Bio source code)
/// The argument can be a literal source string, or an expression producing a source string
pub fn stdEvalString(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(1, args);
const arg = args[0];
const input = expr: {
if (arg.val == ExprType.lst) {
if (arg.val == ExprType.lst and (arg.val.lst.items[0] == &expr_atom_quote or arg.val.lst.items[0] == &expr_atom_quasi_quote)) {
break :expr try ev.eval(env, try ev.eval(env, arg));
} else {
break :expr try ev.eval(env, arg);
}
} else if (arg.val == ExprType.sym) {
if (env.lookup(arg.val.sym, true)) |looked_up| {
break :expr looked_up;
} else {
break :expr arg;
}
} else {
break :expr arg;
}
};
if (input.val == ExprType.sym) {
return try ev.eval(env, try ev.parse(input.val.sym));
} else {
return input;
}
}
/// (apply fn arg1 ... args) where the last argument must be a list, which is the common contract in Lisps
/// Behaves as if fn is called with arguments from the list produced by (append (list arg1 ...) args)
pub fn stdApply(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireMinimumArgCount(2, args);
const last_arg_list = try ev.eval(env, args[args.len - 1]);
try requireType(ev, last_arg_list, ExprType.lst);
var fncall = try makeListExpr(null);
try fncall.val.lst.append(args[0]);
if (args.len > 2) {
for (args[1 .. args.len - 1]) |arg| {
try fncall.val.lst.append(arg);
}
}
for (last_arg_list.val.lst.items) |item| {
try fncall.val.lst.append(item);
}
return try ev.eval(env, fncall);
}
/// Create a new list: (list 1 2 3 'a (* 3 x))
pub fn stdList(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var list = try makeListExpr(null);
for (args) |arg| {
try list.val.lst.append(try ev.eval(env, arg));
}
return list;
}
/// Creates a new list and populates it with the arguments. If any arguments are
/// lists, their elements are spliced into the result list. nil arguments are ignored.
/// (append '(1 2) '(3 4)) -> (1 2 3 4)
pub fn stdAppend(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
var list = try makeListExpr(null);
for (args) |arg| {
const evaled = try ev.eval(env, arg);
if (evaled.val == ExprType.lst) {
for (evaled.val.lst.items) |item| {
try list.val.lst.append(item);
}
} else {
const expr = try ev.eval(env, arg);
if (expr != &expr_atom_nil) {
try list.val.lst.append(expr);
}
}
}
return list;
}
/// Adds a new binding to the current environment
pub fn stdDefine(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
try requireType(ev, args[0], ExprType.sym);
if (env.lookup(args[0].val.sym, false) != null) {
try ev.printErrorFmt(&args[0].src, "{s} is already defined\n", .{args[0].val.sym});
return ExprErrors.AlreadyReported;
}
var value = try ev.eval(env, args[1]);
try env.putWithSymbol(args[0], value);
return value;
}
/// Replace binding
pub fn stdSet(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(2, args);
try requireType(ev, args[0], ExprType.sym);
return env.replace(args[0], try ev.eval(env, args[1]));
}
/// Remove binding if it exists
pub fn stdUnset(ev: *Interpreter, env: *Env, args: []const *Expr) anyerror!*Expr {
try requireExactArgCount(1, args);
try requireType(ev, args[0], ExprType.sym);
_ = env.replace(args[0], null);
return &expr_atom_nil;
} | src/intrinsics.zig |
const std = @import("std");
const Asm = @This();
const space_width = 8;
const space = " ";
output_file: std.fs.File,
output_writer: std.fs.File.Writer,
stack_depth: usize = 0,
pub fn init(file: []const u8) !Asm {
const output_file = try std.fs.cwd().createFile(file, .{});
return Asm{ .output_file = output_file, .output_writer = output_file.writer() };
}
pub fn deinit(self: *Asm) void {
self.output_file.close();
std.debug.assert(self.stack_depth == 0);
}
/// push or put a register on the stack
pub fn push(self: *Asm, register: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}push {[register]s}\n", .{
.spaces = space,
.width = space_width,
.register = register,
});
self.stack_depth += 1;
}
///pop or remove a registor from the stack
pub fn pop(self: *Asm, register: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}pop {[register]s}\n", .{
.spaces = space,
.width = space_width,
.register = register,
});
self.stack_depth -= 1;
}
const OperandType = enum {
immediate_constant,
register,
};
fn SourceOperandType(comptime operand: OperandType) type {
if (operand == OperandType.register) {
return []const u8;
} else {
return usize;
}
}
///mov source -> destination
pub fn mov(
self: *Asm,
comptime operand_type: OperandType,
source_operand: if (operand_type == OperandType.register) []const u8 else usize,
destination_register: []const u8,
) !void {
switch (operand_type) {
.immediate_constant => try self.output_writer.print("{[spaces]s:>[width]}mov ${[immediate_constant]d},{[register]s}\n", .{
.spaces = space,
.width = space_width,
.immediate_constant = source_operand,
.register = destination_register,
}),
.register => {
try self.output_writer.print("{[spaces]s:>[width]}mov {[source]s},{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.source = source_operand,
.destination = destination_register,
});
},
}
}
///Copies the contents of the source operand (register or memory location) to the destination operand (register) and
///zero extends the value.
pub fn movzb(self: *Asm, source_byte_register: []const u8, destination_register: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}movzb {[source_byte_register]s},{[destination_register]s}\n", .{
.spaces = space,
.width = space_width,
.source_byte_register = source_byte_register,
.destination_register = destination_register,
});
}
///load effective address of source and place it in destination
pub fn lea(self: *Asm, offset: usize, source: []const u8, destination: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}lea -{[offset]d}({[source]s}),{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.offset = offset,
.source = source,
.destination = destination,
});
}
/// negate content of register
pub fn neg(self: *Asm, register: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}neg {[register]s}\n", .{
.spaces = space,
.width = space_width,
.register = register,
});
}
///sub source from destination and store result in destination
pub fn sub(
self: *Asm,
comptime operand_type: OperandType,
source_operand: SourceOperandType(operand_type),
destination: []const u8,
) !void {
switch (operand_type) {
.register => {
try self.output_writer.print("{[spaces]s:>[width]}sub {[source]s},{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.source = source_operand,
.destination = destination,
});
},
.immediate_constant => {
try self.output_writer.print("{[spaces]s:>[width]}sub ${[immediate_constant]d},{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.immediate_constant = source_operand,
.destination = destination,
});
},
}
}
///add source to destination and store result in destination
pub fn add(self: *Asm, source: []const u8, destination: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}add {[source]s},{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.source = source,
.destination = destination,
});
}
///two operand form of imul
///multiply source by destination and store result in destination
pub fn imul(self: *Asm, source: []const u8, destination: []const u8) !void {
try self.output_writer.print("{[spaces]s:>[width]}imul {[source]s},{[destination]s}\n", .{
.spaces = space,
.width = space_width,
.source = source,
.destination = destination,
});
}
pub fn idiv(self: *Asm, divisor: []const u8) !void {
//https://stackoverflow.com/questions/38416593/why-should-edx-be-0-before-using-the-div-instruction/38416896#38416896
//we are dividing a 128 dividend bit number by a 64 bit divisor number
//so we must sign extend %rax into 128 bit RDX:RAX before dividing RDX:RAX with %rdi
//sign extending extends the MSB into double the current size of the register
//this makes sure all 128 bits in RDX:RAX are set before performing idiv instruction
//else the result would be undefined
try self.output_writer.print(
\\{[spaces]s:>[width]}cqo
\\{[spaces]s:>[width]}idiv {[divisor]s}
\\
, .{
.spaces = space,
.width = space_width,
.divisor = divisor,
});
}
///Compares the first source operand with the second source operand and
///sets the status flags in the EFLAGS register according to the result
///The condition codes used by the Jcc, CMOVcc, and SETcc instructions
///are based on the results of a CMP instruction.
pub fn cmp(self: *Asm, comptime operand_type: OperandType, left_operand: SourceOperandType(operand_type), right_operand: []const u8) !void {
switch (operand_type) {
.register => {
try self.output_writer.print("{[spaces]s:>[width]}cmp {[left_operand]s},{[right_operand]s}\n", .{
.spaces = space,
.width = space_width,
.left_operand = left_operand,
.right_operand = right_operand,
});
},
.immediate_constant => {
try self.output_writer.print("{[spaces]s:>[width]}cmp ${[left_operand]d},{[right_operand]s}\n", .{
.spaces = space,
.width = space_width,
.left_operand = left_operand,
.right_operand = right_operand,
});
},
}
}
const Cc = enum {
equal,
not_equal,
less_than,
less_than_equal,
greater_than,
greater_than_equal,
};
///set byte register base on conditional codes of EFLAGS
pub fn set(self: *Asm, cc: Cc, byte_register: []const u8) !void {
switch (cc) {
Cc.equal => {
try self.output_writer.print("{[spaces]s:>[width]}sete {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.not_equal => {
try self.output_writer.print("{[spaces]s:>[width]}setne {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.less_than => {
try self.output_writer.print("{[spaces]s:>[width]}setl {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.less_than_equal => {
try self.output_writer.print("{[spaces]s:>[width]}setle {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.greater_than => {
try self.output_writer.print("{[spaces]s:>[width]}setg {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.greater_than_equal => {
try self.output_writer.print("{[spaces]s:>[width]}setge {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
}
}
///ump if Condition Is Met
pub fn jcc(self: *Asm, cc: Cc, byte_register: []const u8) !void {
switch (cc) {
Cc.equal => {
try self.output_writer.print("{[spaces]s:>[width]}je {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.not_equal => {
try self.output_writer.print("{[spaces]s:>[width]}jne {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.less_than => {
try self.output_writer.print("{[spaces]s:>[width]}jl {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.less_than_equal => {
try self.output_writer.print("{[spaces]s:>[width]}jle {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.greater_than => {
try self.output_writer.print("{[spaces]s:>[width]}jg {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
Cc.greater_than_equal => {
try self.output_writer.print("{[spaces]s:>[width]}jge {[byte_register]s}\n", .{
.spaces = space,
.width = space_width,
.byte_register = byte_register,
});
},
}
}
pub fn comment(self: *Asm, asm_comment: []const u8) !void {
try self.output_writer.print(
\\
\\#{[comments]s}
\\
, .{ .comments = asm_comment });
}
pub fn labelFunction(self: *Asm, func_name: []const u8) !void {
try self.output_writer.print(
\\{[spaces]s:>[width]}.globl {[func_name]s}
\\{[spaces]s:>[width]}.type {[func_name]s}, @function
, .{
.spaces = space,
.width = space_width,
.func_name = func_name,
});
try self.label(func_name);
}
///Add a label in asm output
pub fn label(self: *Asm, name: []const u8) !void {
try self.output_writer.print(
\\
\\{[label_name]s}:
\\
, .{
.label_name = name,
});
}
pub fn ret(self: *Asm) !void {
try self.output_writer.print(
\\{[spaces]s:>[width]}ret
\\
, .{
.spaces = space,
.width = space_width,
});
}
pub fn jmp(self: *Asm, location: []const u8) !void {
try self.output_writer.print(
\\{[space]s:>[width]}jmp {[location]s}
\\
, .{
.space = space,
.width = space_width,
.location = location,
});
} | src/asm.zig |
const c = @import("c.zig");
const nk = @import("../nuklear.zig");
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
pub const Type = c.nk_tree_type;
pub fn push(
ctx: *nk.Context,
comptime Id: type,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
) bool {
const id = nk.typeId(Id);
return pushHashed(ctx, t, title, initial_state, mem.asBytes(&id), id);
}
pub fn pushId(
ctx: *nk.Context,
comptime Id: type,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
seed: usize,
) bool {
const id = nk.typeId(Id);
return pushHashed(ctx, t, title, initial_state, mem.asBytes(&id), seed);
}
pub fn pushHashed(
ctx: *nk.Context,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
hash: []const u8,
seed: usize,
) bool {
return c.nk_tree_push_hashed(
ctx,
t,
nk.slice(title),
initial_state,
nk.slice(hash),
@intCast(c_int, seed),
) != 0;
}
pub fn imagePush(
ctx: *nk.Context,
comptime Id: type,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
) bool {
const id = nk.typeId(Id);
return imagePushHashed(ctx, t, img, title, initial_state, mem.asBytes(&id), id);
}
pub fn imagePushId(
ctx: *nk.Context,
comptime Id: type,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
seed: usize,
) bool {
const id = nk.typeId(Id);
return imagePushHashed(ctx, t, img, title, initial_state, mem.asBytes(&id), seed);
}
pub fn imagePushHashed(
ctx: *nk.Context,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
hash: []const u8,
seed: usize,
) bool {
return c.nk_tree_image_push_hashed(
ctx,
t,
img,
nk.slice(title),
initial_state,
nk.slice(hash),
@intCast(c_int, seed),
) != 0;
}
pub fn pop(ctx: *nk.Context) void {
c.nk_tree_pop(ctx);
}
pub fn statePush(ctx: *nk.Context, t: Type, title: []const u8, state: *nk.CollapseStates) bool {
return c.nk_tree_state_push(ctx, t, nk.slice(title), state) != 0;
}
pub fn stateImagePush(
ctx: *nk.Context,
t: Type,
img: nk.Image,
title: []const u8,
state: *nk.CollapseStates,
) bool {
return c.nk_tree_state_image_push(ctx, t, img, nk.slice(title), state) != 0;
}
pub fn statePop(ctx: *nk.Context) void {
c.nk_tree_state_pop(ctx);
}
pub fn elementPush(
ctx: *nk.Context,
comptime Id: type,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
) bool {
const id = nk.typeId(Id);
return elementPushHashed(ctx, t, title, initial_state, selected, mem.asBytes(&id), id);
}
pub fn elementPushId(
ctx: *nk.Context,
comptime Id: type,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
seed: usize,
) bool {
const id = nk.typeId(Id);
return elementPushHashed(ctx, t, title, initial_state, selected, mem.asBytes(&id), seed);
}
pub fn elementPushHashed(
ctx: *nk.Context,
t: Type,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
hash: []const u8,
seed: usize,
) bool {
var c_selected: c_int = undefined;
defer selected.* = c_selected != 0;
return c.nk_tree_element_push_hashed(
ctx,
t,
nk.slice(title),
initial_state,
&c_selected,
nk.slice(hash),
@intCast(c_int, seed),
) != 0;
}
pub fn elementImagePush(
ctx: *nk.Context,
comptime Id: type,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
) bool {
const id = nk.typeId(Id);
return elementImagePushHashed(ctx, t, img, title, initial_state, selected, mem.asBytes(&id), id);
}
pub fn elementImagePushId(
ctx: *nk.Context,
comptime Id: type,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
seed: usize,
) bool {
const id = nk.typeId(Id);
return elementImagePushHashed(ctx, t, img, title, initial_state, selected, mem.asBytes(&id), seed);
}
pub fn elementImagePushHashed(
ctx: *nk.Context,
t: Type,
img: nk.Image,
title: []const u8,
initial_state: nk.CollapseStates,
selected: *bool,
hash: []const u8,
seed: usize,
) bool {
var c_selected: c_int = undefined;
defer selected.* = c_selected != 0;
return c.nk_tree_element_image_push_hashed(
ctx,
t,
img,
nk.slice(title),
initial_state,
&c_selected,
nk.slice(hash),
@intCast(c_int, seed),
) != 0;
}
pub fn elementPop(ctx: *nk.Context) void {
c.nk_tree_element_pop(ctx);
}
test {
testing.refAllDecls(@This());
}
test "list" {
var ctx = &try nk.testing.init();
defer nk.free(ctx);
const flags = c.NK_WINDOW_BORDER | c.NK_WINDOW_MOVABLE | c.NK_WINDOW_SCALABLE |
c.NK_WINDOW_CLOSABLE | c.NK_WINDOW_MINIMIZABLE | c.NK_WINDOW_TITLE;
var selected: bool = false;
if (nk.window.begin(ctx, opaque {}, nk.rect(10, 10, 10, 10), .{})) |win| {
nk.layout.rowDynamic(ctx, 10, 1);
if (nk.tree.push(ctx, opaque {}, .NK_TREE_TAB, "tree", .NK_MINIMIZED)) {
defer nk.tree.pop(ctx);
}
if (nk.tree.pushId(ctx, opaque {}, .NK_TREE_TAB, "tree", .NK_MINIMIZED, 0)) {
defer nk.tree.pop(ctx);
}
if (nk.tree.imagePush(ctx, opaque {}, .NK_TREE_TAB, undefined, "tree", .NK_MINIMIZED)) {
defer nk.tree.pop(ctx);
}
if (nk.tree.imagePushId(ctx, opaque {}, .NK_TREE_TAB, undefined, "tree", .NK_MINIMIZED, 0)) {
defer nk.tree.pop(ctx);
}
if (nk.tree.elementPush(ctx, opaque {}, .NK_TREE_TAB, "tree", .NK_MINIMIZED, &selected)) {
defer nk.tree.elementPop(ctx);
}
if (nk.tree.elementPushId(ctx, opaque {}, .NK_TREE_TAB, "tree", .NK_MINIMIZED, &selected, 0)) {
defer nk.tree.elementPop(ctx);
}
if (nk.tree.elementImagePush(ctx, opaque {}, .NK_TREE_TAB, undefined, "tree", .NK_MINIMIZED, &selected)) {
defer nk.tree.elementPop(ctx);
}
if (nk.tree.elementImagePushId(ctx, opaque {}, .NK_TREE_TAB, undefined, "tree", .NK_MINIMIZED, &selected, 0)) {
defer nk.tree.elementPop(ctx);
}
}
nk.window.end(ctx);
} | src/tree.zig |
const std = @import("std");
const fun = @import("fun");
// TODO: When https://github.com/zig-lang/zig/issues/855 is fixed. Make this into a package import instead of this HACK
const nds = @import("../../src/nds/index.zig");
const generic = fun.generic;
const heap = std.heap;
const os = std.os;
const io = std.io;
const fmt = std.fmt;
const mem = std.mem;
const debug = std.debug;
const path = os.path;
/// For now, this tool only extracts nds roms to a folder of the same name.
/// Later on, we probably want to be able to create a nds file from a folder too.
/// Basicly, this is a replacement for ndstool.
pub fn main() !void {
var direct_allocator = std.heap.DirectAllocator.init();
defer direct_allocator.deinit();
var arena = std.heap.ArenaAllocator.init(&direct_allocator.allocator);
defer arena.deinit();
const allocator = &arena.allocator;
var stdout_handle = try io.getStdOut();
var stdout_file_stream = stdout_handle.outStream();
var stdout = &stdout_file_stream.stream;
// NOTE: Do we want to use another allocator for arguments? Does it matter? Idk.
const args = try os.argsAlloc(allocator);
defer os.argsFree(allocator, args);
if (args.len != 2) {
// TODO: Helpful err
return error.WrongArgs;
}
const nds_path = args[1];
var rom_file = try os.File.openRead(args[1]);
defer rom_file.close();
var rom = try nds.Rom.fromFile(rom_file, allocator);
defer rom.deinit();
// TODO: No hardcoding in here!
const out_folder = "rom";
const arm9_overlay_folder = try path.join(allocator, out_folder, "arm9_overlays");
defer allocator.free(arm9_overlay_folder);
const arm7_overlay_folder = try path.join(allocator, out_folder, "arm7_overlays");
defer allocator.free(arm7_overlay_folder);
const root_folder = try path.join(allocator, out_folder, "root");
defer allocator.free(root_folder);
try os.makePath(allocator, arm9_overlay_folder);
try os.makePath(allocator, arm7_overlay_folder);
try os.makePath(allocator, root_folder);
try writeToFileInFolder(out_folder, "arm9", rom.arm9, allocator);
try writeToFileInFolder(out_folder, "arm7", rom.arm7, allocator);
try writeToFileInFolder(out_folder, "banner", mem.toBytes(rom.banner), allocator);
if (rom.hasNitroFooter())
try writeToFileInFolder(out_folder, "nitro_footer", mem.toBytes(rom.nitro_footer), allocator);
try writeOverlays(arm9_overlay_folder, rom.arm9_overlay_table, rom.arm9_overlay_files, allocator);
try writeOverlays(arm7_overlay_folder, rom.arm7_overlay_table, rom.arm7_overlay_files, allocator);
try writeFs(nds.fs.Nitro, root_folder, rom.root, allocator);
}
fn writeFs(comptime Fs: type, p: []const u8, folder: *Fs, allocator: *mem.Allocator) !void {
const State = struct {
path: []const u8,
folder: *Fs,
};
var stack = std.ArrayList(State).init(allocator);
defer stack.deinit();
try stack.append(State{
.path = try mem.dupe(allocator, u8, p),
.folder = folder,
});
while (stack.popOrNull()) |state| {
defer allocator.free(state.path);
for (state.folder.nodes.toSliceConst()) |node| {
const node_path = try path.join(allocator, state.path, node.name);
switch (node.kind) {
Fs.Node.Kind.File => |f| {
defer allocator.free(node_path);
const Tag = @TagType(nds.fs.Nitro.File);
switch (Fs) {
nds.fs.Nitro => switch (f.*) {
Tag.Binary => |bin| {
var file = try os.File.openWrite(node_path);
defer file.close();
try file.write(bin.data);
},
Tag.Narc => |narc| {
try os.makePath(allocator, node_path);
try writeFs(nds.fs.Narc, node_path, narc, allocator);
},
},
nds.fs.Narc => {
var file = try os.File.openWrite(node_path);
defer file.close();
try file.write(f.data);
},
else => comptime unreachable,
}
},
Fs.Node.Kind.Folder => |f| {
try os.makePath(allocator, node_path);
try stack.append(State{
.path = node_path,
.folder = f,
});
},
}
}
}
}
fn writeOverlays(folder: []const u8, overlays: []const nds.Overlay, files: []const []const u8, allocator: *mem.Allocator) !void {
const overlay_folder_path = try path.join(allocator, folder, "overlay");
defer allocator.free(overlay_folder_path);
for (overlays) |overlay, i| {
const overlay_path = try fmt.allocPrint(allocator, "{}{}", overlay_folder_path, i);
defer allocator.free(overlay_path);
try writeToFile(overlay_path, mem.toBytes(overlay), allocator);
}
const file_folder_path = try path.join(allocator, folder, "file");
defer allocator.free(file_folder_path);
for (files) |file, i| {
const file_path = try fmt.allocPrint(allocator, "{}{}", file_folder_path, i);
defer allocator.free(file_path);
try writeToFile(file_path, file, allocator);
}
}
fn writeToFileInFolder(folder_path: []const u8, file: []const u8, data: []const u8, allocator: *mem.Allocator) !void {
const joined_path = try path.join(allocator, folder_path, file);
defer allocator.free(joined_path);
try writeToFile(joined_path, data, allocator);
}
fn writeToFile(file_path: []const u8, data: []const u8, allocator: *mem.Allocator) !void {
var file = try os.File.openWrite(file_path);
defer file.close();
try file.write(data);
} | tools/nds-util/main.zig |
const xcb = @import("../xcb.zig");
/// @brief CHAR2B
pub const CHAR2B = struct {
@"byte1": u8,
@"byte2": u8,
};
pub const WINDOW = u32;
pub const PIXMAP = u32;
pub const CURSOR = u32;
pub const FONT = u32;
pub const GCONTEXT = u32;
pub const COLORMAP = u32;
pub const ATOM = u32;
pub const DRAWABLE = u32;
pub const FONTABLE = u32;
pub const BOOL32 = u32;
pub const VISUALID = u32;
pub const TIMESTAMP = u32;
pub const KEYSYM = u32;
pub const KEYCODE = u8;
pub const KEYCODE32 = u32;
pub const BUTTON = u8;
/// @brief POINT
pub const POINT = struct {
@"x": i16,
@"y": i16,
};
/// @brief RECTANGLE
pub const RECTANGLE = struct {
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
};
/// @brief ARC
pub const ARC = struct {
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"angle1": i16,
@"angle2": i16,
};
/// @brief FORMAT
pub const FORMAT = struct {
@"depth": u8,
@"bits_per_pixel": u8,
@"scanline_pad": u8,
@"pad0": [5]u8,
};
pub const VisualClass = extern enum(c_uint) {
@"StaticGray" = 0,
@"GrayScale" = 1,
@"StaticColor" = 2,
@"PseudoColor" = 3,
@"TrueColor" = 4,
@"DirectColor" = 5,
};
/// @brief VISUALTYPE
pub const VISUALTYPE = struct {
@"visual_id": xcb.VISUALID,
@"class": u8,
@"bits_per_rgb_value": u8,
@"colormap_entries": u16,
@"red_mask": u32,
@"green_mask": u32,
@"blue_mask": u32,
@"pad0": [4]u8,
};
/// @brief DEPTH
pub const DEPTH = struct {
@"depth": u8,
@"pad0": u8,
@"visuals_len": u16,
@"pad1": [4]u8,
@"visuals": []xcb.VISUALTYPE,
};
pub const EventMask = extern enum(c_uint) {
@"NoEvent" = 0,
@"KeyPress" = 1,
@"KeyRelease" = 2,
@"ButtonPress" = 4,
@"ButtonRelease" = 8,
@"EnterWindow" = 16,
@"LeaveWindow" = 32,
@"PointerMotion" = 64,
@"PointerMotionHint" = 128,
@"Button1Motion" = 256,
@"Button2Motion" = 512,
@"Button3Motion" = 1024,
@"Button4Motion" = 2048,
@"Button5Motion" = 4096,
@"ButtonMotion" = 8192,
@"KeymapState" = 16384,
@"Exposure" = 32768,
@"VisibilityChange" = 65536,
@"StructureNotify" = 131072,
@"ResizeRedirect" = 262144,
@"SubstructureNotify" = 524288,
@"SubstructureRedirect" = 1048576,
@"FocusChange" = 2097152,
@"PropertyChange" = 4194304,
@"ColorMapChange" = 8388608,
@"OwnerGrabButton" = 16777216,
};
pub const BackingStore = extern enum(c_uint) {
@"NotUseful" = 0,
@"WhenMapped" = 1,
@"Always" = 2,
};
/// @brief SCREEN
pub const SCREEN = struct {
@"root": xcb.WINDOW,
@"default_colormap": xcb.COLORMAP,
@"white_pixel": u32,
@"black_pixel": u32,
@"current_input_masks": u32,
@"width_in_pixels": u16,
@"height_in_pixels": u16,
@"width_in_millimeters": u16,
@"height_in_millimeters": u16,
@"min_installed_maps": u16,
@"max_installed_maps": u16,
@"root_visual": xcb.VISUALID,
@"backing_stores": u8,
@"save_unders": u8,
@"root_depth": u8,
@"allowed_depths_len": u8,
@"allowed_depths": []xcb.DEPTH,
};
/// @brief SetupRequest
pub const SetupRequest = struct {
@"byte_order": u8,
@"pad0": u8,
@"protocol_major_version": u16,
@"protocol_minor_version": u16,
@"authorization_protocol_name_len": u16,
@"authorization_protocol_data_len": u16,
@"pad1": [2]u8,
@"authorization_protocol_name": []u8,
@"authorization_protocol_data": []u8,
};
/// @brief SetupFailed
pub const SetupFailed = struct {
@"status": u8,
@"reason_len": u8,
@"protocol_major_version": u16,
@"protocol_minor_version": u16,
@"length": u16,
@"reason": []u8,
};
/// @brief SetupAuthenticate
pub const SetupAuthenticate = struct {
@"status": u8,
@"pad0": [5]u8,
@"length": u16,
@"reason": []u8,
};
pub const ImageOrder = extern enum(c_uint) {
@"LSBFirst" = 0,
@"MSBFirst" = 1,
};
/// @brief Setup
pub const Setup = struct {
@"status": u8,
@"pad0": u8,
@"protocol_major_version": u16,
@"protocol_minor_version": u16,
@"length": u16,
@"release_number": u32,
@"resource_id_base": u32,
@"resource_id_mask": u32,
@"motion_buffer_size": u32,
@"vendor_len": u16,
@"maximum_request_length": u16,
@"roots_len": u8,
@"pixmap_formats_len": u8,
@"image_byte_order": u8,
@"bitmap_format_bit_order": u8,
@"bitmap_format_scanline_unit": u8,
@"bitmap_format_scanline_pad": u8,
@"min_keycode": xcb.KEYCODE,
@"max_keycode": xcb.KEYCODE,
@"pad1": [4]u8,
@"vendor": []u8,
@"pixmap_formats": []xcb.FORMAT,
@"roots": []xcb.SCREEN,
};
pub const ModMask = extern enum(c_uint) {
@"Shift" = 1,
@"Lock" = 2,
@"Control" = 4,
@"1" = 8,
@"2" = 16,
@"3" = 32,
@"4" = 64,
@"5" = 128,
@"Any" = 32768,
};
pub const KeyButMask = extern enum(c_uint) {
@"Shift" = 1,
@"Lock" = 2,
@"Control" = 4,
@"Mod1" = 8,
@"Mod2" = 16,
@"Mod3" = 32,
@"Mod4" = 64,
@"Mod5" = 128,
@"Button1" = 256,
@"Button2" = 512,
@"Button3" = 1024,
@"Button4" = 2048,
@"Button5" = 4096,
};
pub const Window = extern enum(c_uint) {
@"None" = 0,
};
/// Opcode for KeyPress.
pub const KeyPressOpcode = 2;
/// @brief KeyPressEvent
pub const KeyPressEvent = struct {
@"response_type": u8,
@"detail": xcb.KEYCODE,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"root": xcb.WINDOW,
@"event": xcb.WINDOW,
@"child": xcb.WINDOW,
@"root_x": i16,
@"root_y": i16,
@"event_x": i16,
@"event_y": i16,
@"state": u16,
@"same_screen": u8,
@"pad0": u8,
};
/// Opcode for KeyRelease.
pub const KeyReleaseOpcode = 3;
pub const KeyReleaseEvent = xcb.KeyPressEvent;
pub const ButtonMask = extern enum(c_uint) {
@"1" = 256,
@"2" = 512,
@"3" = 1024,
@"4" = 2048,
@"5" = 4096,
@"Any" = 32768,
};
/// Opcode for ButtonPress.
pub const ButtonPressOpcode = 4;
/// @brief ButtonPressEvent
pub const ButtonPressEvent = struct {
@"response_type": u8,
@"detail": xcb.BUTTON,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"root": xcb.WINDOW,
@"event": xcb.WINDOW,
@"child": xcb.WINDOW,
@"root_x": i16,
@"root_y": i16,
@"event_x": i16,
@"event_y": i16,
@"state": u16,
@"same_screen": u8,
@"pad0": u8,
};
/// Opcode for ButtonRelease.
pub const ButtonReleaseOpcode = 5;
pub const ButtonReleaseEvent = xcb.ButtonPressEvent;
pub const Motion = extern enum(c_uint) {
@"Normal" = 0,
@"Hint" = 1,
};
/// Opcode for MotionNotify.
pub const MotionNotifyOpcode = 6;
/// @brief MotionNotifyEvent
pub const MotionNotifyEvent = struct {
@"response_type": u8,
@"detail": u8,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"root": xcb.WINDOW,
@"event": xcb.WINDOW,
@"child": xcb.WINDOW,
@"root_x": i16,
@"root_y": i16,
@"event_x": i16,
@"event_y": i16,
@"state": u16,
@"same_screen": u8,
@"pad0": u8,
};
pub const NotifyDetail = extern enum(c_uint) {
@"Ancestor" = 0,
@"Virtual" = 1,
@"Inferior" = 2,
@"Nonlinear" = 3,
@"NonlinearVirtual" = 4,
@"Pointer" = 5,
@"PointerRoot" = 6,
@"None" = 7,
};
pub const NotifyMode = extern enum(c_uint) {
@"Normal" = 0,
@"Grab" = 1,
@"Ungrab" = 2,
@"WhileGrabbed" = 3,
};
/// Opcode for EnterNotify.
pub const EnterNotifyOpcode = 7;
/// @brief EnterNotifyEvent
pub const EnterNotifyEvent = struct {
@"response_type": u8,
@"detail": u8,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"root": xcb.WINDOW,
@"event": xcb.WINDOW,
@"child": xcb.WINDOW,
@"root_x": i16,
@"root_y": i16,
@"event_x": i16,
@"event_y": i16,
@"state": u16,
@"mode": u8,
@"same_screen_focus": u8,
};
/// Opcode for LeaveNotify.
pub const LeaveNotifyOpcode = 8;
pub const LeaveNotifyEvent = xcb.EnterNotifyEvent;
/// Opcode for FocusIn.
pub const FocusInOpcode = 9;
/// @brief FocusInEvent
pub const FocusInEvent = struct {
@"response_type": u8,
@"detail": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"mode": u8,
@"pad0": [3]u8,
};
/// Opcode for FocusOut.
pub const FocusOutOpcode = 10;
pub const FocusOutEvent = xcb.FocusInEvent;
/// Opcode for KeymapNotify.
pub const KeymapNotifyOpcode = 11;
/// @brief KeymapNotifyEvent
pub const KeymapNotifyEvent = struct {
@"response_type": u8,
@"keys": [31]u8,
};
/// Opcode for Expose.
pub const ExposeOpcode = 12;
/// @brief ExposeEvent
pub const ExposeEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"x": u16,
@"y": u16,
@"width": u16,
@"height": u16,
@"count": u16,
@"pad1": [2]u8,
};
/// Opcode for GraphicsExposure.
pub const GraphicsExposureOpcode = 13;
/// @brief GraphicsExposureEvent
pub const GraphicsExposureEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"drawable": xcb.DRAWABLE,
@"x": u16,
@"y": u16,
@"width": u16,
@"height": u16,
@"minor_opcode": u16,
@"count": u16,
@"major_opcode": u8,
@"pad1": [3]u8,
};
/// Opcode for NoExposure.
pub const NoExposureOpcode = 14;
/// @brief NoExposureEvent
pub const NoExposureEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"drawable": xcb.DRAWABLE,
@"minor_opcode": u16,
@"major_opcode": u8,
@"pad1": u8,
};
pub const Visibility = extern enum(c_uint) {
@"Unobscured" = 0,
@"PartiallyObscured" = 1,
@"FullyObscured" = 2,
};
/// Opcode for VisibilityNotify.
pub const VisibilityNotifyOpcode = 15;
/// @brief VisibilityNotifyEvent
pub const VisibilityNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"state": u8,
@"pad1": [3]u8,
};
/// Opcode for CreateNotify.
pub const CreateNotifyOpcode = 16;
/// @brief CreateNotifyEvent
pub const CreateNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"parent": xcb.WINDOW,
@"window": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"border_width": u16,
@"override_redirect": u8,
@"pad1": u8,
};
/// Opcode for DestroyNotify.
pub const DestroyNotifyOpcode = 17;
/// @brief DestroyNotifyEvent
pub const DestroyNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
};
/// Opcode for UnmapNotify.
pub const UnmapNotifyOpcode = 18;
/// @brief UnmapNotifyEvent
pub const UnmapNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"from_configure": u8,
@"pad1": [3]u8,
};
/// Opcode for MapNotify.
pub const MapNotifyOpcode = 19;
/// @brief MapNotifyEvent
pub const MapNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"override_redirect": u8,
@"pad1": [3]u8,
};
/// Opcode for MapRequest.
pub const MapRequestOpcode = 20;
/// @brief MapRequestEvent
pub const MapRequestEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"parent": xcb.WINDOW,
@"window": xcb.WINDOW,
};
/// Opcode for ReparentNotify.
pub const ReparentNotifyOpcode = 21;
/// @brief ReparentNotifyEvent
pub const ReparentNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"parent": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"override_redirect": u8,
@"pad1": [3]u8,
};
/// Opcode for ConfigureNotify.
pub const ConfigureNotifyOpcode = 22;
/// @brief ConfigureNotifyEvent
pub const ConfigureNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"above_sibling": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"border_width": u16,
@"override_redirect": u8,
@"pad1": u8,
};
/// Opcode for ConfigureRequest.
pub const ConfigureRequestOpcode = 23;
/// @brief ConfigureRequestEvent
pub const ConfigureRequestEvent = struct {
@"response_type": u8,
@"stack_mode": u8,
@"sequence": u16,
@"parent": xcb.WINDOW,
@"window": xcb.WINDOW,
@"sibling": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"border_width": u16,
@"value_mask": u16,
};
/// Opcode for GravityNotify.
pub const GravityNotifyOpcode = 24;
/// @brief GravityNotifyEvent
pub const GravityNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"x": i16,
@"y": i16,
};
/// Opcode for ResizeRequest.
pub const ResizeRequestOpcode = 25;
/// @brief ResizeRequestEvent
pub const ResizeRequestEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"width": u16,
@"height": u16,
};
pub const Place = extern enum(c_uint) {
/// The window is now on top of all siblings.
@"OnTop" = 0,
/// The window is now below all siblings.
@"OnBottom" = 1,
};
/// Opcode for CirculateNotify.
pub const CirculateNotifyOpcode = 26;
/// @brief CirculateNotifyEvent
pub const CirculateNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"event": xcb.WINDOW,
@"window": xcb.WINDOW,
@"pad1": [4]u8,
@"place": u8,
@"pad2": [3]u8,
};
/// Opcode for CirculateRequest.
pub const CirculateRequestOpcode = 27;
pub const CirculateRequestEvent = xcb.CirculateNotifyEvent;
pub const Property = extern enum(c_uint) {
@"NewValue" = 0,
@"Delete" = 1,
};
/// Opcode for PropertyNotify.
pub const PropertyNotifyOpcode = 28;
/// @brief PropertyNotifyEvent
pub const PropertyNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"atom": xcb.ATOM,
@"time": xcb.TIMESTAMP,
@"state": u8,
@"pad1": [3]u8,
};
/// Opcode for SelectionClear.
pub const SelectionClearOpcode = 29;
/// @brief SelectionClearEvent
pub const SelectionClearEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"owner": xcb.WINDOW,
@"selection": xcb.ATOM,
};
pub const Time = extern enum(c_uint) {
@"CurrentTime" = 0,
};
pub const Atom = extern enum(c_uint) {
@"None" = 0,
@"Any" = 0,
@"PRIMARY" = 1,
@"SECONDARY" = 2,
@"ARC" = 3,
@"ATOM" = 4,
@"BITMAP" = 5,
@"CARDINAL" = 6,
@"COLORMAP" = 7,
@"CURSOR" = 8,
@"CUT_BUFFER0" = 9,
@"CUT_BUFFER1" = 10,
@"CUT_BUFFER2" = 11,
@"CUT_BUFFER3" = 12,
@"CUT_BUFFER4" = 13,
@"CUT_BUFFER5" = 14,
@"CUT_BUFFER6" = 15,
@"CUT_BUFFER7" = 16,
@"DRAWABLE" = 17,
@"FONT" = 18,
@"INTEGER" = 19,
@"PIXMAP" = 20,
@"POINT" = 21,
@"RECTANGLE" = 22,
@"RESOURCE_MANAGER" = 23,
@"RGB_COLOR_MAP" = 24,
@"RGB_BEST_MAP" = 25,
@"RGB_BLUE_MAP" = 26,
@"RGB_DEFAULT_MAP" = 27,
@"RGB_GRAY_MAP" = 28,
@"RGB_GREEN_MAP" = 29,
@"RGB_RED_MAP" = 30,
@"STRING" = 31,
@"VISUALID" = 32,
@"WINDOW" = 33,
@"WM_COMMAND" = 34,
@"WM_HINTS" = 35,
@"WM_CLIENT_MACHINE" = 36,
@"WM_ICON_NAME" = 37,
@"WM_ICON_SIZE" = 38,
@"WM_NAME" = 39,
@"WM_NORMAL_HINTS" = 40,
@"WM_SIZE_HINTS" = 41,
@"WM_ZOOM_HINTS" = 42,
@"MIN_SPACE" = 43,
@"NORM_SPACE" = 44,
@"MAX_SPACE" = 45,
@"END_SPACE" = 46,
@"SUPERSCRIPT_X" = 47,
@"SUPERSCRIPT_Y" = 48,
@"SUBSCRIPT_X" = 49,
@"SUBSCRIPT_Y" = 50,
@"UNDERLINE_POSITION" = 51,
@"UNDERLINE_THICKNESS" = 52,
@"STRIKEOUT_ASCENT" = 53,
@"STRIKEOUT_DESCENT" = 54,
@"ITALIC_ANGLE" = 55,
@"X_HEIGHT" = 56,
@"QUAD_WIDTH" = 57,
@"WEIGHT" = 58,
@"POINT_SIZE" = 59,
@"RESOLUTION" = 60,
@"COPYRIGHT" = 61,
@"NOTICE" = 62,
@"FONT_NAME" = 63,
@"FAMILY_NAME" = 64,
@"FULL_NAME" = 65,
@"CAP_HEIGHT" = 66,
@"WM_CLASS" = 67,
@"WM_TRANSIENT_FOR" = 68,
};
/// Opcode for SelectionRequest.
pub const SelectionRequestOpcode = 30;
/// @brief SelectionRequestEvent
pub const SelectionRequestEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"owner": xcb.WINDOW,
@"requestor": xcb.WINDOW,
@"selection": xcb.ATOM,
@"target": xcb.ATOM,
@"property": xcb.ATOM,
};
/// Opcode for SelectionNotify.
pub const SelectionNotifyOpcode = 31;
/// @brief SelectionNotifyEvent
pub const SelectionNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"time": xcb.TIMESTAMP,
@"requestor": xcb.WINDOW,
@"selection": xcb.ATOM,
@"target": xcb.ATOM,
@"property": xcb.ATOM,
};
pub const ColormapState = extern enum(c_uint) {
/// The colormap was uninstalled.
@"Uninstalled" = 0,
/// The colormap was installed.
@"Installed" = 1,
};
pub const Colormap = extern enum(c_uint) {
@"None" = 0,
};
/// Opcode for ColormapNotify.
pub const ColormapNotifyOpcode = 32;
/// @brief ColormapNotifyEvent
pub const ColormapNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"colormap": xcb.COLORMAP,
@"new": u8,
@"state": u8,
@"pad1": [2]u8,
};
/// @brief ClientMessageData
pub const ClientMessageData = union {
@"data8": [20]u8,
@"data16": [10]u16,
@"data32": [5]u32,
};
/// Opcode for ClientMessage.
pub const ClientMessageOpcode = 33;
/// @brief ClientMessageEvent
pub const ClientMessageEvent = struct {
@"response_type": u8,
@"format": u8,
@"sequence": u16,
@"window": xcb.WINDOW,
@"type": xcb.ATOM,
@"data": xcb.ClientMessageData,
};
pub const Mapping = extern enum(c_uint) {
@"Modifier" = 0,
@"Keyboard" = 1,
@"Pointer" = 2,
};
/// Opcode for MappingNotify.
pub const MappingNotifyOpcode = 34;
/// @brief MappingNotifyEvent
pub const MappingNotifyEvent = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"request": u8,
@"first_keycode": xcb.KEYCODE,
@"count": u8,
@"pad1": u8,
};
/// Opcode for GeGeneric.
pub const GeGenericOpcode = 35;
/// @brief GeGenericEvent
pub const GeGenericEvent = struct {
@"response_type": u8,
@"extension": u8,
@"sequence": u16,
@"length": u32,
@"event_type": u16,
@"pad0": [22]u8,
@"full_sequence": u32,
};
/// Opcode for Request.
pub const RequestOpcode = 1;
/// Opcode for Match.
pub const MatchOpcode = 8;
/// Opcode for Access.
pub const AccessOpcode = 10;
/// Opcode for Alloc.
pub const AllocOpcode = 11;
/// Opcode for Name.
pub const NameOpcode = 15;
/// Opcode for Length.
pub const LengthOpcode = 16;
/// Opcode for Implementation.
pub const ImplementationOpcode = 17;
/// @brief RequestError
pub const RequestError = struct {
@"response_type": u8,
@"error_code": u8,
@"sequence": u16,
@"bad_value": u32,
@"minor_opcode": u16,
@"major_opcode": u8,
@"pad0": u8,
};
/// Opcode for Value.
pub const ValueOpcode = 2;
/// Opcode for Window.
pub const WindowOpcode = 3;
/// Opcode for Pixmap.
pub const PixmapOpcode = 4;
/// Opcode for Atom.
pub const AtomOpcode = 5;
/// Opcode for Cursor.
pub const CursorOpcode = 6;
/// Opcode for Font.
pub const FontOpcode = 7;
/// Opcode for Drawable.
pub const DrawableOpcode = 9;
/// Opcode for Colormap.
pub const ColormapOpcode = 12;
/// Opcode for GContext.
pub const GContextOpcode = 13;
/// Opcode for IDChoice.
pub const IDChoiceOpcode = 14;
/// @brief ValueError
pub const ValueError = struct {
@"response_type": u8,
@"error_code": u8,
@"sequence": u16,
@"bad_value": u32,
@"minor_opcode": u16,
@"major_opcode": u8,
@"pad0": u8,
};
pub const WindowClass = extern enum(c_uint) {
@"CopyFromParent" = 0,
@"InputOutput" = 1,
@"InputOnly" = 2,
};
pub const CW = extern enum(c_uint) {
/// Overrides the default background-pixmap. The background pixmap and window must
/// have the same root and same depth. Any size pixmap can be used, although some
/// sizes may be faster than others.
///
/// If `XCB_BACK_PIXMAP_NONE` is specified, the window has no defined background.
/// The server may fill the contents with the previous screen contents or with
/// contents of its own choosing.
///
/// If `XCB_BACK_PIXMAP_PARENT_RELATIVE` is specified, the parent's background is
/// used, but the window must have the same depth as the parent (or a Match error
/// results). The parent's background is tracked, and the current version is
/// used each time the window background is required.
@"BackPixmap" = 1,
/// Overrides `BackPixmap`. A pixmap of undefined size filled with the specified
/// background pixel is used for the background. Range-checking is not performed,
/// the background pixel is truncated to the appropriate number of bits.
@"BackPixel" = 2,
/// Overrides the default border-pixmap. The border pixmap and window must have the
/// same root and the same depth. Any size pixmap can be used, although some sizes
/// may be faster than others.
///
/// The special value `XCB_COPY_FROM_PARENT` means the parent's border pixmap is
/// copied (subsequent changes to the parent's border attribute do not affect the
/// child), but the window must have the same depth as the parent.
@"BorderPixmap" = 4,
/// Overrides `BorderPixmap`. A pixmap of undefined size filled with the specified
/// border pixel is used for the border. Range checking is not performed on the
/// border-pixel value, it is truncated to the appropriate number of bits.
@"BorderPixel" = 8,
/// Defines which region of the window should be retained if the window is resized.
@"BitGravity" = 16,
/// Defines how the window should be repositioned if the parent is resized (see
/// `ConfigureWindow`).
@"WinGravity" = 32,
/// A backing-store of `WhenMapped` advises the server that maintaining contents of
/// obscured regions when the window is mapped would be beneficial. A backing-store
/// of `Always` advises the server that maintaining contents even when the window
/// is unmapped would be beneficial. In this case, the server may generate an
/// exposure event when the window is created. A value of `NotUseful` advises the
/// server that maintaining contents is unnecessary, although a server may still
/// choose to maintain contents while the window is mapped. Note that if the server
/// maintains contents, then the server should maintain complete contents not just
/// the region within the parent boundaries, even if the window is larger than its
/// parent. While the server maintains contents, exposure events will not normally
/// be generated, but the server may stop maintaining contents at any time.
@"BackingStore" = 64,
/// The backing-planes indicates (with bits set to 1) which bit planes of the
/// window hold dynamic data that must be preserved in backing-stores and during
/// save-unders.
@"BackingPlanes" = 128,
/// The backing-pixel specifies what value to use in planes not covered by
/// backing-planes. The server is free to save only the specified bit planes in the
/// backing-store or save-under and regenerate the remaining planes with the
/// specified pixel value. Any bits beyond the specified depth of the window in
/// these values are simply ignored.
@"BackingPixel" = 256,
/// The override-redirect specifies whether map and configure requests on this
/// window should override a SubstructureRedirect on the parent, typically to
/// inform a window manager not to tamper with the window.
@"OverrideRedirect" = 512,
/// If 1, the server is advised that when this window is mapped, saving the
/// contents of windows it obscures would be beneficial.
@"SaveUnder" = 1024,
/// The event-mask defines which events the client is interested in for this window
/// (or for some event types, inferiors of the window).
@"EventMask" = 2048,
/// The do-not-propagate-mask defines which events should not be propagated to
/// ancestor windows when no client has the event type selected in this window.
@"DontPropagate" = 4096,
/// The colormap specifies the colormap that best reflects the true colors of the window. Servers
/// capable of supporting multiple hardware colormaps may use this information, and window man-
/// agers may use it for InstallColormap requests. The colormap must have the same visual type
/// and root as the window (or a Match error results). If CopyFromParent is specified, the parent's
/// colormap is copied (subsequent changes to the parent's colormap attribute do not affect the child).
/// However, the window must have the same visual type as the parent (or a Match error results),
/// and the parent must not have a colormap of None (or a Match error results). For an explanation
/// of None, see FreeColormap request. The colormap is copied by sharing the colormap object
/// between the child and the parent, not by making a complete copy of the colormap contents.
@"Colormap" = 8192,
/// If a cursor is specified, it will be used whenever the pointer is in the window. If None is speci-
/// fied, the parent's cursor will be used when the pointer is in the window, and any change in the
/// parent's cursor will cause an immediate change in the displayed cursor.
@"Cursor" = 16384,
};
pub const BackPixmap = extern enum(c_uint) {
@"None" = 0,
@"ParentRelative" = 1,
};
pub const Gravity = extern enum(c_uint) {
@"BitForget" = 0,
@"WinUnmap" = 0,
@"NorthWest" = 1,
@"North" = 2,
@"NorthEast" = 3,
@"West" = 4,
@"Center" = 5,
@"East" = 6,
@"SouthWest" = 7,
@"South" = 8,
@"SouthEast" = 9,
@"Static" = 10,
};
/// @brief CreateWindowRequest
pub const CreateWindowRequest = struct {
@"major_opcode": u8,
@"depth": u8,
@"length": u16,
@"wid": xcb.WINDOW,
@"parent": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"border_width": u16,
@"class": u16,
@"visual": xcb.VISUALID,
@"value_mask": u32,
};
/// @brief ChangeWindowAttributesRequest
pub const ChangeWindowAttributesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"value_mask": u32,
};
pub const MapState = extern enum(c_uint) {
@"Unmapped" = 0,
@"Unviewable" = 1,
@"Viewable" = 2,
};
/// @brief GetWindowAttributescookie
pub const GetWindowAttributescookie = struct {
sequence: c_uint,
};
/// @brief GetWindowAttributesRequest
pub const GetWindowAttributesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief GetWindowAttributesReply
pub const GetWindowAttributesReply = struct {
@"response_type": u8,
@"backing_store": u8,
@"sequence": u16,
@"length": u32,
@"visual": xcb.VISUALID,
@"class": u16,
@"bit_gravity": u8,
@"win_gravity": u8,
@"backing_planes": u32,
@"backing_pixel": u32,
@"save_under": u8,
@"map_is_installed": u8,
@"map_state": u8,
@"override_redirect": u8,
@"colormap": xcb.COLORMAP,
@"all_event_masks": u32,
@"your_event_mask": u32,
@"do_not_propagate_mask": u16,
@"pad0": [2]u8,
};
/// @brief DestroyWindowRequest
pub const DestroyWindowRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief DestroySubwindowsRequest
pub const DestroySubwindowsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
pub const SetMode = extern enum(c_uint) {
@"Insert" = 0,
@"Delete" = 1,
};
/// @brief ChangeSaveSetRequest
pub const ChangeSaveSetRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief ReparentWindowRequest
pub const ReparentWindowRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"parent": xcb.WINDOW,
@"x": i16,
@"y": i16,
};
/// @brief MapWindowRequest
pub const MapWindowRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief MapSubwindowsRequest
pub const MapSubwindowsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief UnmapWindowRequest
pub const UnmapWindowRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief UnmapSubwindowsRequest
pub const UnmapSubwindowsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
pub const ConfigWindow = extern enum(c_uint) {
@"X" = 1,
@"Y" = 2,
@"Width" = 4,
@"Height" = 8,
@"BorderWidth" = 16,
@"Sibling" = 32,
@"StackMode" = 64,
};
pub const StackMode = extern enum(c_uint) {
@"Above" = 0,
@"Below" = 1,
@"TopIf" = 2,
@"BottomIf" = 3,
@"Opposite" = 4,
};
/// @brief ConfigureWindowRequest
pub const ConfigureWindowRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"value_mask": u16,
@"pad1": [2]u8,
};
pub const Circulate = extern enum(c_uint) {
@"RaiseLowest" = 0,
@"LowerHighest" = 1,
};
/// @brief CirculateWindowRequest
pub const CirculateWindowRequest = struct {
@"major_opcode": u8,
@"direction": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief GetGeometrycookie
pub const GetGeometrycookie = struct {
sequence: c_uint,
};
/// @brief GetGeometryRequest
pub const GetGeometryRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
};
/// @brief GetGeometryReply
pub const GetGeometryReply = struct {
@"response_type": u8,
@"depth": u8,
@"sequence": u16,
@"length": u32,
@"root": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"border_width": u16,
@"pad0": [2]u8,
};
/// @brief QueryTreecookie
pub const QueryTreecookie = struct {
sequence: c_uint,
};
/// @brief QueryTreeRequest
pub const QueryTreeRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief QueryTreeReply
pub const QueryTreeReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"root": xcb.WINDOW,
@"parent": xcb.WINDOW,
@"children_len": u16,
@"pad1": [14]u8,
@"children": []xcb.WINDOW,
};
/// @brief InternAtomcookie
pub const InternAtomcookie = struct {
sequence: c_uint,
};
/// @brief InternAtomRequest
pub const InternAtomRequest = struct {
@"major_opcode": u8,
@"only_if_exists": u8,
@"length": u16,
@"name_len": u16,
@"pad0": [2]u8,
@"name": []const u8,
};
/// @brief InternAtomReply
pub const InternAtomReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"atom": xcb.ATOM,
};
/// @brief GetAtomNamecookie
pub const GetAtomNamecookie = struct {
sequence: c_uint,
};
/// @brief GetAtomNameRequest
pub const GetAtomNameRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"atom": xcb.ATOM,
};
/// @brief GetAtomNameReply
pub const GetAtomNameReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"name_len": u16,
@"pad1": [22]u8,
@"name": []u8,
};
pub const PropMode = extern enum(c_uint) {
/// Discard the previous property value and store the new data.
@"Replace" = 0,
/// Insert the new data before the beginning of existing data. The `format` must
/// match existing property value. If the property is undefined, it is treated as
/// defined with the correct type and format with zero-length data.
@"Prepend" = 1,
/// Insert the new data after the beginning of existing data. The `format` must
/// match existing property value. If the property is undefined, it is treated as
/// defined with the correct type and format with zero-length data.
@"Append" = 2,
};
/// @brief ChangePropertyRequest
pub const ChangePropertyRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"property": xcb.ATOM,
@"type": xcb.ATOM,
@"format": u8,
@"pad0": [3]u8,
@"data_len": u32,
@"data": []const u8,
};
/// @brief DeletePropertyRequest
pub const DeletePropertyRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"property": xcb.ATOM,
};
pub const GetPropertyType = extern enum(c_uint) {
@"Any" = 0,
};
/// @brief GetPropertycookie
pub const GetPropertycookie = struct {
sequence: c_uint,
};
/// @brief GetPropertyRequest
pub const GetPropertyRequest = struct {
@"major_opcode": u8,
@"delete": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"property": xcb.ATOM,
@"type": xcb.ATOM,
@"long_offset": u32,
@"long_length": u32,
};
/// @brief GetPropertyReply
pub const GetPropertyReply = struct {
@"response_type": u8,
@"format": u8,
@"sequence": u16,
@"length": u32,
@"type": xcb.ATOM,
@"bytes_after": u32,
@"value_len": u32,
@"pad0": [12]u8,
@"value": []u8,
};
/// @brief ListPropertiescookie
pub const ListPropertiescookie = struct {
sequence: c_uint,
};
/// @brief ListPropertiesRequest
pub const ListPropertiesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief ListPropertiesReply
pub const ListPropertiesReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"atoms_len": u16,
@"pad1": [22]u8,
@"atoms": []xcb.ATOM,
};
/// @brief SetSelectionOwnerRequest
pub const SetSelectionOwnerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"owner": xcb.WINDOW,
@"selection": xcb.ATOM,
@"time": xcb.TIMESTAMP,
};
/// @brief GetSelectionOwnercookie
pub const GetSelectionOwnercookie = struct {
sequence: c_uint,
};
/// @brief GetSelectionOwnerRequest
pub const GetSelectionOwnerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"selection": xcb.ATOM,
};
/// @brief GetSelectionOwnerReply
pub const GetSelectionOwnerReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"owner": xcb.WINDOW,
};
/// @brief ConvertSelectionRequest
pub const ConvertSelectionRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"requestor": xcb.WINDOW,
@"selection": xcb.ATOM,
@"target": xcb.ATOM,
@"property": xcb.ATOM,
@"time": xcb.TIMESTAMP,
};
pub const SendEventDest = extern enum(c_uint) {
@"PointerWindow" = 0,
@"ItemFocus" = 1,
};
/// @brief SendEventRequest
pub const SendEventRequest = struct {
@"major_opcode": u8,
@"propagate": u8,
@"length": u16,
@"destination": xcb.WINDOW,
@"event_mask": u32,
@"event": [32]u8,
};
pub const GrabMode = extern enum(c_uint) {
/// The state of the keyboard appears to freeze: No further keyboard events are
/// generated by the server until the grabbing client issues a releasing
/// `AllowEvents` request or until the keyboard grab is released.
@"Sync" = 0,
/// Keyboard event processing continues normally.
@"Async" = 1,
};
pub const GrabStatus = extern enum(c_uint) {
@"Success" = 0,
@"AlreadyGrabbed" = 1,
@"InvalidTime" = 2,
@"NotViewable" = 3,
@"Frozen" = 4,
};
pub const Cursor = extern enum(c_uint) {
@"None" = 0,
};
/// @brief GrabPointercookie
pub const GrabPointercookie = struct {
sequence: c_uint,
};
/// @brief GrabPointerRequest
pub const GrabPointerRequest = struct {
@"major_opcode": u8,
@"owner_events": u8,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"event_mask": u16,
@"pointer_mode": u8,
@"keyboard_mode": u8,
@"confine_to": xcb.WINDOW,
@"cursor": xcb.CURSOR,
@"time": xcb.TIMESTAMP,
};
/// @brief GrabPointerReply
pub const GrabPointerReply = struct {
@"response_type": u8,
@"status": u8,
@"sequence": u16,
@"length": u32,
};
/// @brief UngrabPointerRequest
pub const UngrabPointerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"time": xcb.TIMESTAMP,
};
pub const ButtonIndex = extern enum(c_uint) {
/// Any of the following (or none):
@"Any" = 0,
/// The left mouse button.
@"1" = 1,
/// The right mouse button.
@"2" = 2,
/// The middle mouse button.
@"3" = 3,
/// Scroll wheel. TODO: direction?
@"4" = 4,
/// Scroll wheel. TODO: direction?
@"5" = 5,
};
/// @brief GrabButtonRequest
pub const GrabButtonRequest = struct {
@"major_opcode": u8,
@"owner_events": u8,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"event_mask": u16,
@"pointer_mode": u8,
@"keyboard_mode": u8,
@"confine_to": xcb.WINDOW,
@"cursor": xcb.CURSOR,
@"button": u8,
@"pad0": u8,
@"modifiers": u16,
};
/// @brief UngrabButtonRequest
pub const UngrabButtonRequest = struct {
@"major_opcode": u8,
@"button": u8,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"modifiers": u16,
@"pad0": [2]u8,
};
/// @brief ChangeActivePointerGrabRequest
pub const ChangeActivePointerGrabRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cursor": xcb.CURSOR,
@"time": xcb.TIMESTAMP,
@"event_mask": u16,
@"pad1": [2]u8,
};
/// @brief GrabKeyboardcookie
pub const GrabKeyboardcookie = struct {
sequence: c_uint,
};
/// @brief GrabKeyboardRequest
pub const GrabKeyboardRequest = struct {
@"major_opcode": u8,
@"owner_events": u8,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"time": xcb.TIMESTAMP,
@"pointer_mode": u8,
@"keyboard_mode": u8,
@"pad0": [2]u8,
};
/// @brief GrabKeyboardReply
pub const GrabKeyboardReply = struct {
@"response_type": u8,
@"status": u8,
@"sequence": u16,
@"length": u32,
};
/// @brief UngrabKeyboardRequest
pub const UngrabKeyboardRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"time": xcb.TIMESTAMP,
};
pub const Grab = extern enum(c_uint) {
@"Any" = 0,
};
/// @brief GrabKeyRequest
pub const GrabKeyRequest = struct {
@"major_opcode": u8,
@"owner_events": u8,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"modifiers": u16,
@"key": xcb.KEYCODE,
@"pointer_mode": u8,
@"keyboard_mode": u8,
@"pad0": [3]u8,
};
/// @brief UngrabKeyRequest
pub const UngrabKeyRequest = struct {
@"major_opcode": u8,
@"key": xcb.KEYCODE,
@"length": u16,
@"grab_window": xcb.WINDOW,
@"modifiers": u16,
@"pad0": [2]u8,
};
pub const Allow = extern enum(c_uint) {
/// For AsyncPointer, if the pointer is frozen by the client, pointer event
/// processing continues normally. If the pointer is frozen twice by the client on
/// behalf of two separate grabs, AsyncPointer thaws for both. AsyncPointer has no
/// effect if the pointer is not frozen by the client, but the pointer need not be
/// grabbed by the client.
///
/// TODO: rewrite this in more understandable terms.
@"AsyncPointer" = 0,
/// For SyncPointer, if the pointer is frozen and actively grabbed by the client,
/// pointer event processing continues normally until the next ButtonPress or
/// ButtonRelease event is reported to the client, at which time the pointer again
/// appears to freeze. However, if the reported event causes the pointer grab to be
/// released, then the pointer does not freeze. SyncPointer has no effect if the
/// pointer is not frozen by the client or if the pointer is not grabbed by the
/// client.
@"SyncPointer" = 1,
/// For ReplayPointer, if the pointer is actively grabbed by the client and is
/// frozen as the result of an event having been sent to the client (either from
/// the activation of a GrabButton or from a previous AllowEvents with mode
/// SyncPointer but not from a GrabPointer), then the pointer grab is released and
/// that event is completely reprocessed, this time ignoring any passive grabs at
/// or above (towards the root) the grab-window of the grab just released. The
/// request has no effect if the pointer is not grabbed by the client or if the
/// pointer is not frozen as the result of an event.
@"ReplayPointer" = 2,
/// For AsyncKeyboard, if the keyboard is frozen by the client, keyboard event
/// processing continues normally. If the keyboard is frozen twice by the client on
/// behalf of two separate grabs, AsyncKeyboard thaws for both. AsyncKeyboard has
/// no effect if the keyboard is not frozen by the client, but the keyboard need
/// not be grabbed by the client.
@"AsyncKeyboard" = 3,
/// For SyncKeyboard, if the keyboard is frozen and actively grabbed by the client,
/// keyboard event processing continues normally until the next KeyPress or
/// KeyRelease event is reported to the client, at which time the keyboard again
/// appears to freeze. However, if the reported event causes the keyboard grab to
/// be released, then the keyboard does not freeze. SyncKeyboard has no effect if
/// the keyboard is not frozen by the client or if the keyboard is not grabbed by
/// the client.
@"SyncKeyboard" = 4,
/// For ReplayKeyboard, if the keyboard is actively grabbed by the client and is
/// frozen as the result of an event having been sent to the client (either from
/// the activation of a GrabKey or from a previous AllowEvents with mode
/// SyncKeyboard but not from a GrabKeyboard), then the keyboard grab is released
/// and that event is completely reprocessed, this time ignoring any passive grabs
/// at or above (towards the root) the grab-window of the grab just released. The
/// request has no effect if the keyboard is not grabbed by the client or if the
/// keyboard is not frozen as the result of an event.
@"ReplayKeyboard" = 5,
/// For AsyncBoth, if the pointer and the keyboard are frozen by the client, event
/// processing for both devices continues normally. If a device is frozen twice by
/// the client on behalf of two separate grabs, AsyncBoth thaws for both. AsyncBoth
/// has no effect unless both pointer and keyboard are frozen by the client.
@"AsyncBoth" = 6,
/// For SyncBoth, if both pointer and keyboard are frozen by the client, event
/// processing (for both devices) continues normally until the next ButtonPress,
/// ButtonRelease, KeyPress, or KeyRelease event is reported to the client for a
/// grabbed device (button event for the pointer, key event for the keyboard), at
/// which time the devices again appear to freeze. However, if the reported event
/// causes the grab to be released, then the devices do not freeze (but if the
/// other device is still grabbed, then a subsequent event for it will still cause
/// both devices to freeze). SyncBoth has no effect unless both pointer and
/// keyboard are frozen by the client. If the pointer or keyboard is frozen twice
/// by the client on behalf of two separate grabs, SyncBoth thaws for both (but a
/// subsequent freeze for SyncBoth will only freeze each device once).
@"SyncBoth" = 7,
};
/// @brief AllowEventsRequest
pub const AllowEventsRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
@"time": xcb.TIMESTAMP,
};
/// @brief GrabServerRequest
pub const GrabServerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief UngrabServerRequest
pub const UngrabServerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief QueryPointercookie
pub const QueryPointercookie = struct {
sequence: c_uint,
};
/// @brief QueryPointerRequest
pub const QueryPointerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief QueryPointerReply
pub const QueryPointerReply = struct {
@"response_type": u8,
@"same_screen": u8,
@"sequence": u16,
@"length": u32,
@"root": xcb.WINDOW,
@"child": xcb.WINDOW,
@"root_x": i16,
@"root_y": i16,
@"win_x": i16,
@"win_y": i16,
@"mask": u16,
@"pad0": [2]u8,
};
/// @brief TIMECOORD
pub const TIMECOORD = struct {
@"time": xcb.TIMESTAMP,
@"x": i16,
@"y": i16,
};
/// @brief GetMotionEventscookie
pub const GetMotionEventscookie = struct {
sequence: c_uint,
};
/// @brief GetMotionEventsRequest
pub const GetMotionEventsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"start": xcb.TIMESTAMP,
@"stop": xcb.TIMESTAMP,
};
/// @brief GetMotionEventsReply
pub const GetMotionEventsReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"events_len": u32,
@"pad1": [20]u8,
@"events": []xcb.TIMECOORD,
};
/// @brief TranslateCoordinatescookie
pub const TranslateCoordinatescookie = struct {
sequence: c_uint,
};
/// @brief TranslateCoordinatesRequest
pub const TranslateCoordinatesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"src_window": xcb.WINDOW,
@"dst_window": xcb.WINDOW,
@"src_x": i16,
@"src_y": i16,
};
/// @brief TranslateCoordinatesReply
pub const TranslateCoordinatesReply = struct {
@"response_type": u8,
@"same_screen": u8,
@"sequence": u16,
@"length": u32,
@"child": xcb.WINDOW,
@"dst_x": i16,
@"dst_y": i16,
};
/// @brief WarpPointerRequest
pub const WarpPointerRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"src_window": xcb.WINDOW,
@"dst_window": xcb.WINDOW,
@"src_x": i16,
@"src_y": i16,
@"src_width": u16,
@"src_height": u16,
@"dst_x": i16,
@"dst_y": i16,
};
pub const InputFocus = extern enum(c_uint) {
/// The focus reverts to `XCB_NONE`, so no window will have the input focus.
@"None" = 0,
/// The focus reverts to `XCB_POINTER_ROOT` respectively. When the focus reverts,
/// FocusIn and FocusOut events are generated, but the last-focus-change time is
/// not changed.
@"PointerRoot" = 1,
/// The focus reverts to the parent (or closest viewable ancestor) and the new
/// revert_to value is `XCB_INPUT_FOCUS_NONE`.
@"Parent" = 2,
/// NOT YET DOCUMENTED. Only relevant for the xinput extension.
@"FollowKeyboard" = 3,
};
/// @brief SetInputFocusRequest
pub const SetInputFocusRequest = struct {
@"major_opcode": u8,
@"revert_to": u8,
@"length": u16,
@"focus": xcb.WINDOW,
@"time": xcb.TIMESTAMP,
};
/// @brief GetInputFocuscookie
pub const GetInputFocuscookie = struct {
sequence: c_uint,
};
/// @brief GetInputFocusRequest
pub const GetInputFocusRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetInputFocusReply
pub const GetInputFocusReply = struct {
@"response_type": u8,
@"revert_to": u8,
@"sequence": u16,
@"length": u32,
@"focus": xcb.WINDOW,
};
/// @brief QueryKeymapcookie
pub const QueryKeymapcookie = struct {
sequence: c_uint,
};
/// @brief QueryKeymapRequest
pub const QueryKeymapRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief QueryKeymapReply
pub const QueryKeymapReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"keys": [32]u8,
};
/// @brief OpenFontRequest
pub const OpenFontRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"fid": xcb.FONT,
@"name_len": u16,
@"pad1": [2]u8,
@"name": []const u8,
};
/// @brief CloseFontRequest
pub const CloseFontRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"font": xcb.FONT,
};
pub const FontDraw = extern enum(c_uint) {
@"LeftToRight" = 0,
@"RightToLeft" = 1,
};
/// @brief FONTPROP
pub const FONTPROP = struct {
@"name": xcb.ATOM,
@"value": u32,
};
/// @brief CHARINFO
pub const CHARINFO = struct {
@"left_side_bearing": i16,
@"right_side_bearing": i16,
@"character_width": i16,
@"ascent": i16,
@"descent": i16,
@"attributes": u16,
};
/// @brief QueryFontcookie
pub const QueryFontcookie = struct {
sequence: c_uint,
};
/// @brief QueryFontRequest
pub const QueryFontRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"font": xcb.FONTABLE,
};
/// @brief QueryFontReply
pub const QueryFontReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"min_bounds": xcb.CHARINFO,
@"pad1": [4]u8,
@"max_bounds": xcb.CHARINFO,
@"pad2": [4]u8,
@"min_char_or_byte2": u16,
@"max_char_or_byte2": u16,
@"default_char": u16,
@"properties_len": u16,
@"draw_direction": u8,
@"min_byte1": u8,
@"max_byte1": u8,
@"all_chars_exist": u8,
@"font_ascent": i16,
@"font_descent": i16,
@"char_infos_len": u32,
@"properties": []xcb.FONTPROP,
@"char_infos": []xcb.CHARINFO,
};
/// @brief QueryTextExtentscookie
pub const QueryTextExtentscookie = struct {
sequence: c_uint,
};
/// @brief QueryTextExtentsRequest
pub const QueryTextExtentsRequest = struct {
@"major_opcode": u8,
@"odd_length": u8,
@"length": u16,
@"font": xcb.FONTABLE,
@"string": []const xcb.CHAR2B,
};
/// @brief QueryTextExtentsReply
pub const QueryTextExtentsReply = struct {
@"response_type": u8,
@"draw_direction": u8,
@"sequence": u16,
@"length": u32,
@"font_ascent": i16,
@"font_descent": i16,
@"overall_ascent": i16,
@"overall_descent": i16,
@"overall_width": i32,
@"overall_left": i32,
@"overall_right": i32,
};
/// @brief STR
pub const STR = struct {
@"name_len": u8,
@"name": []u8,
};
/// @brief ListFontscookie
pub const ListFontscookie = struct {
sequence: c_uint,
};
/// @brief ListFontsRequest
pub const ListFontsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"max_names": u16,
@"pattern_len": u16,
@"pattern": []const u8,
};
/// @brief ListFontsReply
pub const ListFontsReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"names_len": u16,
@"pad1": [22]u8,
@"names": []xcb.STR,
};
/// @brief ListFontsWithInfocookie
pub const ListFontsWithInfocookie = struct {
sequence: c_uint,
};
/// @brief ListFontsWithInfoRequest
pub const ListFontsWithInfoRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"max_names": u16,
@"pattern_len": u16,
@"pattern": []const u8,
};
/// @brief ListFontsWithInfoReply
pub const ListFontsWithInfoReply = struct {
@"response_type": u8,
@"name_len": u8,
@"sequence": u16,
@"length": u32,
@"min_bounds": xcb.CHARINFO,
@"pad0": [4]u8,
@"max_bounds": xcb.CHARINFO,
@"pad1": [4]u8,
@"min_char_or_byte2": u16,
@"max_char_or_byte2": u16,
@"default_char": u16,
@"properties_len": u16,
@"draw_direction": u8,
@"min_byte1": u8,
@"max_byte1": u8,
@"all_chars_exist": u8,
@"font_ascent": i16,
@"font_descent": i16,
@"replies_hint": u32,
@"properties": []xcb.FONTPROP,
@"name": []u8,
};
/// @brief SetFontPathRequest
pub const SetFontPathRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"font_qty": u16,
@"pad1": [2]u8,
@"font": []const xcb.STR,
};
/// @brief GetFontPathcookie
pub const GetFontPathcookie = struct {
sequence: c_uint,
};
/// @brief GetFontPathRequest
pub const GetFontPathRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetFontPathReply
pub const GetFontPathReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"path_len": u16,
@"pad1": [22]u8,
@"path": []xcb.STR,
};
/// @brief CreatePixmapRequest
pub const CreatePixmapRequest = struct {
@"major_opcode": u8,
@"depth": u8,
@"length": u16,
@"pid": xcb.PIXMAP,
@"drawable": xcb.DRAWABLE,
@"width": u16,
@"height": u16,
};
/// @brief FreePixmapRequest
pub const FreePixmapRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"pixmap": xcb.PIXMAP,
};
pub const GC = extern enum(c_uint) {
/// TODO: Refer to GX
@"Function" = 1,
/// In graphics operations, given a source and destination pixel, the result is
/// computed bitwise on corresponding bits of the pixels; that is, a Boolean
/// operation is performed in each bit plane. The plane-mask restricts the
/// operation to a subset of planes, so the result is:
///
/// ((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask))
@"PlaneMask" = 2,
/// Foreground colorpixel.
@"Foreground" = 4,
/// Background colorpixel.
@"Background" = 8,
/// The line-width is measured in pixels and can be greater than or equal to one, a wide line, or the
/// special value zero, a thin line.
@"LineWidth" = 16,
/// The line-style defines which sections of a line are drawn:
/// Solid The full path of the line is drawn.
/// DoubleDash The full path of the line is drawn, but the even dashes are filled differently
/// than the odd dashes (see fill-style), with Butt cap-style used where even and
/// odd dashes meet.
/// OnOffDash Only the even dashes are drawn, and cap-style applies to all internal ends of
/// the individual dashes (except NotLast is treated as Butt).
@"LineStyle" = 32,
/// The cap-style defines how the endpoints of a path are drawn:
/// NotLast The result is equivalent to Butt, except that for a line-width of zero the final
/// endpoint is not drawn.
/// Butt The result is square at the endpoint (perpendicular to the slope of the line)
/// with no projection beyond.
/// Round The result is a circular arc with its diameter equal to the line-width, centered
/// on the endpoint; it is equivalent to Butt for line-width zero.
/// Projecting The result is square at the end, but the path continues beyond the endpoint for
/// a distance equal to half the line-width; it is equivalent to Butt for line-width
/// zero.
@"CapStyle" = 64,
/// The join-style defines how corners are drawn for wide lines:
/// Miter The outer edges of the two lines extend to meet at an angle. However, if the
/// angle is less than 11 degrees, a Bevel join-style is used instead.
/// Round The result is a circular arc with a diameter equal to the line-width, centered
/// on the joinpoint.
/// Bevel The result is Butt endpoint styles, and then the triangular notch is filled.
@"JoinStyle" = 128,
/// The fill-style defines the contents of the source for line, text, and fill requests. For all text and fill
/// requests (for example, PolyText8, PolyText16, PolyFillRectangle, FillPoly, and PolyFillArc)
/// as well as for line requests with line-style Solid, (for example, PolyLine, PolySegment,
/// PolyRectangle, PolyArc) and for the even dashes for line requests with line-style OnOffDash
/// or DoubleDash:
/// Solid Foreground
/// Tiled Tile
/// OpaqueStippled A tile with the same width and height as stipple but with background
/// everywhere stipple has a zero and with foreground everywhere stipple
/// has a one
/// Stippled Foreground masked by stipple
/// For the odd dashes for line requests with line-style DoubleDash:
/// Solid Background
/// Tiled Same as for even dashes
/// OpaqueStippled Same as for even dashes
/// Stippled Background masked by stipple
@"FillStyle" = 256,
@"FillRule" = 512,
/// The tile/stipple represents an infinite two-dimensional plane with the tile/stipple replicated in all
/// dimensions. When that plane is superimposed on the drawable for use in a graphics operation,
/// the upper-left corner of some instance of the tile/stipple is at the coordinates within the drawable
/// specified by the tile/stipple origin. The tile/stipple and clip origins are interpreted relative to the
/// origin of whatever destination drawable is specified in a graphics request.
/// The tile pixmap must have the same root and depth as the gcontext (or a Match error results).
/// The stipple pixmap must have depth one and must have the same root as the gcontext (or a
/// Match error results). For fill-style Stippled (but not fill-style
/// OpaqueStippled), the stipple pattern is tiled in a single plane and acts as an
/// additional clip mask to be ANDed with the clip-mask.
/// Any size pixmap can be used for tiling or stippling, although some sizes may be faster to use than
/// others.
@"Tile" = 1024,
/// The tile/stipple represents an infinite two-dimensional plane with the tile/stipple replicated in all
/// dimensions. When that plane is superimposed on the drawable for use in a graphics operation,
/// the upper-left corner of some instance of the tile/stipple is at the coordinates within the drawable
/// specified by the tile/stipple origin. The tile/stipple and clip origins are interpreted relative to the
/// origin of whatever destination drawable is specified in a graphics request.
/// The tile pixmap must have the same root and depth as the gcontext (or a Match error results).
/// The stipple pixmap must have depth one and must have the same root as the gcontext (or a
/// Match error results). For fill-style Stippled (but not fill-style
/// OpaqueStippled), the stipple pattern is tiled in a single plane and acts as an
/// additional clip mask to be ANDed with the clip-mask.
/// Any size pixmap can be used for tiling or stippling, although some sizes may be faster to use than
/// others.
@"Stipple" = 2048,
/// TODO
@"TileStippleOriginX" = 4096,
/// TODO
@"TileStippleOriginY" = 8192,
/// Which font to use for the `ImageText8` and `ImageText16` requests.
@"Font" = 16384,
/// For ClipByChildren, both source and destination windows are additionally
/// clipped by all viewable InputOutput children. For IncludeInferiors, neither
/// source nor destination window is
/// clipped by inferiors. This will result in including subwindow contents in the source and drawing
/// through subwindow boundaries of the destination. The use of IncludeInferiors with a source or
/// destination window of one depth with mapped inferiors of differing depth is not illegal, but the
/// semantics is undefined by the core protocol.
@"SubwindowMode" = 32768,
/// Whether ExposureEvents should be generated (1) or not (0).
///
/// The default is 1.
@"GraphicsExposures" = 65536,
/// TODO
@"ClipOriginX" = 131072,
/// TODO
@"ClipOriginY" = 262144,
/// The clip-mask restricts writes to the destination drawable. Only pixels where the clip-mask has
/// bits set to 1 are drawn. Pixels are not drawn outside the area covered by the clip-mask or where
/// the clip-mask has bits set to 0. The clip-mask affects all graphics requests, but it does not clip
/// sources. The clip-mask origin is interpreted relative to the origin of whatever destination drawable is specified in a graphics request. If a pixmap is specified as the clip-mask, it must have
/// depth 1 and have the same root as the gcontext (or a Match error results). If clip-mask is None,
/// then pixels are always drawn, regardless of the clip origin. The clip-mask can also be set with the
/// SetClipRectangles request.
@"ClipMask" = 524288,
/// TODO
@"DashOffset" = 1048576,
/// TODO
@"DashList" = 2097152,
/// TODO
@"ArcMode" = 4194304,
};
pub const GX = extern enum(c_uint) {
@"clear" = 0,
@"and" = 1,
@"andReverse" = 2,
@"copy" = 3,
@"andInverted" = 4,
@"noop" = 5,
@"xor" = 6,
@"or" = 7,
@"nor" = 8,
@"equiv" = 9,
@"invert" = 10,
@"orReverse" = 11,
@"copyInverted" = 12,
@"orInverted" = 13,
@"nand" = 14,
@"set" = 15,
};
pub const LineStyle = extern enum(c_uint) {
@"Solid" = 0,
@"OnOffDash" = 1,
@"DoubleDash" = 2,
};
pub const CapStyle = extern enum(c_uint) {
@"NotLast" = 0,
@"Butt" = 1,
@"Round" = 2,
@"Projecting" = 3,
};
pub const JoinStyle = extern enum(c_uint) {
@"Miter" = 0,
@"Round" = 1,
@"Bevel" = 2,
};
pub const FillStyle = extern enum(c_uint) {
@"Solid" = 0,
@"Tiled" = 1,
@"Stippled" = 2,
@"OpaqueStippled" = 3,
};
pub const FillRule = extern enum(c_uint) {
@"EvenOdd" = 0,
@"Winding" = 1,
};
pub const SubwindowMode = extern enum(c_uint) {
@"ClipByChildren" = 0,
@"IncludeInferiors" = 1,
};
pub const ArcMode = extern enum(c_uint) {
@"Chord" = 0,
@"PieSlice" = 1,
};
/// @brief CreateGCRequest
pub const CreateGCRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cid": xcb.GCONTEXT,
@"drawable": xcb.DRAWABLE,
@"value_mask": u32,
};
/// @brief ChangeGCRequest
pub const ChangeGCRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"gc": xcb.GCONTEXT,
@"value_mask": u32,
};
/// @brief CopyGCRequest
pub const CopyGCRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"src_gc": xcb.GCONTEXT,
@"dst_gc": xcb.GCONTEXT,
@"value_mask": u32,
};
/// @brief SetDashesRequest
pub const SetDashesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"gc": xcb.GCONTEXT,
@"dash_offset": u16,
@"dashes_len": u16,
@"dashes": []const u8,
};
pub const ClipOrdering = extern enum(c_uint) {
@"Unsorted" = 0,
@"YSorted" = 1,
@"YXSorted" = 2,
@"YXBanded" = 3,
};
/// @brief SetClipRectanglesRequest
pub const SetClipRectanglesRequest = struct {
@"major_opcode": u8,
@"ordering": u8,
@"length": u16,
@"gc": xcb.GCONTEXT,
@"clip_x_origin": i16,
@"clip_y_origin": i16,
@"rectangles": []const xcb.RECTANGLE,
};
/// @brief FreeGCRequest
pub const FreeGCRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"gc": xcb.GCONTEXT,
};
/// @brief ClearAreaRequest
pub const ClearAreaRequest = struct {
@"major_opcode": u8,
@"exposures": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
};
/// @brief CopyAreaRequest
pub const CopyAreaRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"src_drawable": xcb.DRAWABLE,
@"dst_drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"src_x": i16,
@"src_y": i16,
@"dst_x": i16,
@"dst_y": i16,
@"width": u16,
@"height": u16,
};
/// @brief CopyPlaneRequest
pub const CopyPlaneRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"src_drawable": xcb.DRAWABLE,
@"dst_drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"src_x": i16,
@"src_y": i16,
@"dst_x": i16,
@"dst_y": i16,
@"width": u16,
@"height": u16,
@"bit_plane": u32,
};
pub const CoordMode = extern enum(c_uint) {
/// Treats all coordinates as relative to the origin.
@"Origin" = 0,
/// Treats all coordinates after the first as relative to the previous coordinate.
@"Previous" = 1,
};
/// @brief PolyPointRequest
pub const PolyPointRequest = struct {
@"major_opcode": u8,
@"coordinate_mode": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"points": []const xcb.POINT,
};
/// @brief PolyLineRequest
pub const PolyLineRequest = struct {
@"major_opcode": u8,
@"coordinate_mode": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"points": []const xcb.POINT,
};
/// @brief SEGMENT
pub const SEGMENT = struct {
@"x1": i16,
@"y1": i16,
@"x2": i16,
@"y2": i16,
};
/// @brief PolySegmentRequest
pub const PolySegmentRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"segments": []const xcb.SEGMENT,
};
/// @brief PolyRectangleRequest
pub const PolyRectangleRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"rectangles": []const xcb.RECTANGLE,
};
/// @brief PolyArcRequest
pub const PolyArcRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"arcs": []const xcb.ARC,
};
pub const PolyShape = extern enum(c_uint) {
@"Complex" = 0,
@"Nonconvex" = 1,
@"Convex" = 2,
};
/// @brief FillPolyRequest
pub const FillPolyRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"shape": u8,
@"coordinate_mode": u8,
@"pad1": [2]u8,
@"points": []const xcb.POINT,
};
/// @brief PolyFillRectangleRequest
pub const PolyFillRectangleRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"rectangles": []const xcb.RECTANGLE,
};
/// @brief PolyFillArcRequest
pub const PolyFillArcRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"arcs": []const xcb.ARC,
};
pub const ImageFormat = extern enum(c_uint) {
@"XYBitmap" = 0,
@"XYPixmap" = 1,
@"ZPixmap" = 2,
};
/// @brief PutImageRequest
pub const PutImageRequest = struct {
@"major_opcode": u8,
@"format": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"width": u16,
@"height": u16,
@"dst_x": i16,
@"dst_y": i16,
@"left_pad": u8,
@"depth": u8,
@"pad0": [2]u8,
@"data": []const u8,
};
/// @brief GetImagecookie
pub const GetImagecookie = struct {
sequence: c_uint,
};
/// @brief GetImageRequest
pub const GetImageRequest = struct {
@"major_opcode": u8,
@"format": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"x": i16,
@"y": i16,
@"width": u16,
@"height": u16,
@"plane_mask": u32,
};
/// @brief GetImageReply
pub const GetImageReply = struct {
@"response_type": u8,
@"depth": u8,
@"sequence": u16,
@"length": u32,
@"visual": xcb.VISUALID,
@"pad0": [20]u8,
@"data": []u8,
};
/// @brief PolyText8Request
pub const PolyText8Request = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"x": i16,
@"y": i16,
@"items": []const u8,
};
/// @brief PolyText16Request
pub const PolyText16Request = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"x": i16,
@"y": i16,
@"items": []const u8,
};
/// @brief ImageText8Request
pub const ImageText8Request = struct {
@"major_opcode": u8,
@"string_len": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"x": i16,
@"y": i16,
@"string": []const u8,
};
/// @brief ImageText16Request
pub const ImageText16Request = struct {
@"major_opcode": u8,
@"string_len": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"gc": xcb.GCONTEXT,
@"x": i16,
@"y": i16,
@"string": []const xcb.CHAR2B,
};
pub const ColormapAlloc = extern enum(c_uint) {
@"None" = 0,
@"All" = 1,
};
/// @brief CreateColormapRequest
pub const CreateColormapRequest = struct {
@"major_opcode": u8,
@"alloc": u8,
@"length": u16,
@"mid": xcb.COLORMAP,
@"window": xcb.WINDOW,
@"visual": xcb.VISUALID,
};
/// @brief FreeColormapRequest
pub const FreeColormapRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
};
/// @brief CopyColormapAndFreeRequest
pub const CopyColormapAndFreeRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"mid": xcb.COLORMAP,
@"src_cmap": xcb.COLORMAP,
};
/// @brief InstallColormapRequest
pub const InstallColormapRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
};
/// @brief UninstallColormapRequest
pub const UninstallColormapRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
};
/// @brief ListInstalledColormapscookie
pub const ListInstalledColormapscookie = struct {
sequence: c_uint,
};
/// @brief ListInstalledColormapsRequest
pub const ListInstalledColormapsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
};
/// @brief ListInstalledColormapsReply
pub const ListInstalledColormapsReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"cmaps_len": u16,
@"pad1": [22]u8,
@"cmaps": []xcb.COLORMAP,
};
/// @brief AllocColorcookie
pub const AllocColorcookie = struct {
sequence: c_uint,
};
/// @brief AllocColorRequest
pub const AllocColorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"red": u16,
@"green": u16,
@"blue": u16,
@"pad1": [2]u8,
};
/// @brief AllocColorReply
pub const AllocColorReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"red": u16,
@"green": u16,
@"blue": u16,
@"pad1": [2]u8,
@"pixel": u32,
};
/// @brief AllocNamedColorcookie
pub const AllocNamedColorcookie = struct {
sequence: c_uint,
};
/// @brief AllocNamedColorRequest
pub const AllocNamedColorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"name_len": u16,
@"pad1": [2]u8,
@"name": []const u8,
};
/// @brief AllocNamedColorReply
pub const AllocNamedColorReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"pixel": u32,
@"exact_red": u16,
@"exact_green": u16,
@"exact_blue": u16,
@"visual_red": u16,
@"visual_green": u16,
@"visual_blue": u16,
};
/// @brief AllocColorCellscookie
pub const AllocColorCellscookie = struct {
sequence: c_uint,
};
/// @brief AllocColorCellsRequest
pub const AllocColorCellsRequest = struct {
@"major_opcode": u8,
@"contiguous": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"colors": u16,
@"planes": u16,
};
/// @brief AllocColorCellsReply
pub const AllocColorCellsReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"pixels_len": u16,
@"masks_len": u16,
@"pad1": [20]u8,
@"pixels": []u32,
@"masks": []u32,
};
/// @brief AllocColorPlanescookie
pub const AllocColorPlanescookie = struct {
sequence: c_uint,
};
/// @brief AllocColorPlanesRequest
pub const AllocColorPlanesRequest = struct {
@"major_opcode": u8,
@"contiguous": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"colors": u16,
@"reds": u16,
@"greens": u16,
@"blues": u16,
};
/// @brief AllocColorPlanesReply
pub const AllocColorPlanesReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"pixels_len": u16,
@"pad1": [2]u8,
@"red_mask": u32,
@"green_mask": u32,
@"blue_mask": u32,
@"pad2": [8]u8,
@"pixels": []u32,
};
/// @brief FreeColorsRequest
pub const FreeColorsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"plane_mask": u32,
@"pixels": []const u32,
};
pub const ColorFlag = extern enum(c_uint) {
@"Red" = 1,
@"Green" = 2,
@"Blue" = 4,
};
/// @brief COLORITEM
pub const COLORITEM = struct {
@"pixel": u32,
@"red": u16,
@"green": u16,
@"blue": u16,
@"flags": u8,
@"pad0": u8,
};
/// @brief StoreColorsRequest
pub const StoreColorsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"items": []const xcb.COLORITEM,
};
/// @brief StoreNamedColorRequest
pub const StoreNamedColorRequest = struct {
@"major_opcode": u8,
@"flags": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"pixel": u32,
@"name_len": u16,
@"pad0": [2]u8,
@"name": []const u8,
};
/// @brief RGB
pub const RGB = struct {
@"red": u16,
@"green": u16,
@"blue": u16,
@"pad0": [2]u8,
};
/// @brief QueryColorscookie
pub const QueryColorscookie = struct {
sequence: c_uint,
};
/// @brief QueryColorsRequest
pub const QueryColorsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"pixels": []const u32,
};
/// @brief QueryColorsReply
pub const QueryColorsReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"colors_len": u16,
@"pad1": [22]u8,
@"colors": []xcb.RGB,
};
/// @brief LookupColorcookie
pub const LookupColorcookie = struct {
sequence: c_uint,
};
/// @brief LookupColorRequest
pub const LookupColorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cmap": xcb.COLORMAP,
@"name_len": u16,
@"pad1": [2]u8,
@"name": []const u8,
};
/// @brief LookupColorReply
pub const LookupColorReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"exact_red": u16,
@"exact_green": u16,
@"exact_blue": u16,
@"visual_red": u16,
@"visual_green": u16,
@"visual_blue": u16,
};
pub const Pixmap = extern enum(c_uint) {
@"None" = 0,
};
/// @brief CreateCursorRequest
pub const CreateCursorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cid": xcb.CURSOR,
@"source": xcb.PIXMAP,
@"mask": xcb.PIXMAP,
@"fore_red": u16,
@"fore_green": u16,
@"fore_blue": u16,
@"back_red": u16,
@"back_green": u16,
@"back_blue": u16,
@"x": u16,
@"y": u16,
};
pub const Font = extern enum(c_uint) {
@"None" = 0,
};
/// @brief CreateGlyphCursorRequest
pub const CreateGlyphCursorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cid": xcb.CURSOR,
@"source_font": xcb.FONT,
@"mask_font": xcb.FONT,
@"source_char": u16,
@"mask_char": u16,
@"fore_red": u16,
@"fore_green": u16,
@"fore_blue": u16,
@"back_red": u16,
@"back_green": u16,
@"back_blue": u16,
};
/// @brief FreeCursorRequest
pub const FreeCursorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cursor": xcb.CURSOR,
};
/// @brief RecolorCursorRequest
pub const RecolorCursorRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"cursor": xcb.CURSOR,
@"fore_red": u16,
@"fore_green": u16,
@"fore_blue": u16,
@"back_red": u16,
@"back_green": u16,
@"back_blue": u16,
};
pub const QueryShapeOf = extern enum(c_uint) {
@"LargestCursor" = 0,
@"FastestTile" = 1,
@"FastestStipple" = 2,
};
/// @brief QueryBestSizecookie
pub const QueryBestSizecookie = struct {
sequence: c_uint,
};
/// @brief QueryBestSizeRequest
pub const QueryBestSizeRequest = struct {
@"major_opcode": u8,
@"class": u8,
@"length": u16,
@"drawable": xcb.DRAWABLE,
@"width": u16,
@"height": u16,
};
/// @brief QueryBestSizeReply
pub const QueryBestSizeReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"width": u16,
@"height": u16,
};
/// @brief QueryExtensioncookie
pub const QueryExtensioncookie = struct {
sequence: c_uint,
};
/// @brief QueryExtensionRequest
pub const QueryExtensionRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"name_len": u16,
@"pad1": [2]u8,
@"name": []const u8,
};
/// @brief QueryExtensionReply
pub const QueryExtensionReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"present": u8,
@"major_opcode": u8,
@"first_event": u8,
@"first_error": u8,
};
/// @brief ListExtensionscookie
pub const ListExtensionscookie = struct {
sequence: c_uint,
};
/// @brief ListExtensionsRequest
pub const ListExtensionsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief ListExtensionsReply
pub const ListExtensionsReply = struct {
@"response_type": u8,
@"names_len": u8,
@"sequence": u16,
@"length": u32,
@"pad0": [24]u8,
@"names": []xcb.STR,
};
/// @brief ChangeKeyboardMappingRequest
pub const ChangeKeyboardMappingRequest = struct {
@"major_opcode": u8,
@"keycode_count": u8,
@"length": u16,
@"first_keycode": xcb.KEYCODE,
@"keysyms_per_keycode": u8,
@"pad0": [2]u8,
@"keysyms": []const xcb.KEYSYM,
};
/// @brief GetKeyboardMappingcookie
pub const GetKeyboardMappingcookie = struct {
sequence: c_uint,
};
/// @brief GetKeyboardMappingRequest
pub const GetKeyboardMappingRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"first_keycode": xcb.KEYCODE,
@"count": u8,
};
/// @brief GetKeyboardMappingReply
pub const GetKeyboardMappingReply = struct {
@"response_type": u8,
@"keysyms_per_keycode": u8,
@"sequence": u16,
@"length": u32,
@"pad0": [24]u8,
@"keysyms": []xcb.KEYSYM,
};
pub const KB = extern enum(c_uint) {
@"KeyClickPercent" = 1,
@"BellPercent" = 2,
@"BellPitch" = 4,
@"BellDuration" = 8,
@"Led" = 16,
@"LedMode" = 32,
@"Key" = 64,
@"AutoRepeatMode" = 128,
};
pub const LedMode = extern enum(c_uint) {
@"Off" = 0,
@"On" = 1,
};
pub const AutoRepeatMode = extern enum(c_uint) {
@"Off" = 0,
@"On" = 1,
@"Default" = 2,
};
/// @brief ChangeKeyboardControlRequest
pub const ChangeKeyboardControlRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"value_mask": u32,
};
/// @brief GetKeyboardControlcookie
pub const GetKeyboardControlcookie = struct {
sequence: c_uint,
};
/// @brief GetKeyboardControlRequest
pub const GetKeyboardControlRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetKeyboardControlReply
pub const GetKeyboardControlReply = struct {
@"response_type": u8,
@"global_auto_repeat": u8,
@"sequence": u16,
@"length": u32,
@"led_mask": u32,
@"key_click_percent": u8,
@"bell_percent": u8,
@"bell_pitch": u16,
@"bell_duration": u16,
@"pad0": [2]u8,
@"auto_repeats": [32]u8,
};
/// @brief BellRequest
pub const BellRequest = struct {
@"major_opcode": u8,
@"percent": i8,
@"length": u16,
};
/// @brief ChangePointerControlRequest
pub const ChangePointerControlRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"acceleration_numerator": i16,
@"acceleration_denominator": i16,
@"threshold": i16,
@"do_acceleration": u8,
@"do_threshold": u8,
};
/// @brief GetPointerControlcookie
pub const GetPointerControlcookie = struct {
sequence: c_uint,
};
/// @brief GetPointerControlRequest
pub const GetPointerControlRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetPointerControlReply
pub const GetPointerControlReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"acceleration_numerator": u16,
@"acceleration_denominator": u16,
@"threshold": u16,
@"pad1": [18]u8,
};
pub const Blanking = extern enum(c_uint) {
@"NotPreferred" = 0,
@"Preferred" = 1,
@"Default" = 2,
};
pub const Exposures = extern enum(c_uint) {
@"NotAllowed" = 0,
@"Allowed" = 1,
@"Default" = 2,
};
/// @brief SetScreenSaverRequest
pub const SetScreenSaverRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"timeout": i16,
@"interval": i16,
@"prefer_blanking": u8,
@"allow_exposures": u8,
};
/// @brief GetScreenSavercookie
pub const GetScreenSavercookie = struct {
sequence: c_uint,
};
/// @brief GetScreenSaverRequest
pub const GetScreenSaverRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetScreenSaverReply
pub const GetScreenSaverReply = struct {
@"response_type": u8,
@"pad0": u8,
@"sequence": u16,
@"length": u32,
@"timeout": u16,
@"interval": u16,
@"prefer_blanking": u8,
@"allow_exposures": u8,
@"pad1": [18]u8,
};
pub const HostMode = extern enum(c_uint) {
@"Insert" = 0,
@"Delete" = 1,
};
pub const Family = extern enum(c_uint) {
@"Internet" = 0,
@"DECnet" = 1,
@"Chaos" = 2,
@"ServerInterpreted" = 5,
@"Internet6" = 6,
};
/// @brief ChangeHostsRequest
pub const ChangeHostsRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
@"family": u8,
@"pad0": u8,
@"address_len": u16,
@"address": []const u8,
};
/// @brief HOST
pub const HOST = struct {
@"family": u8,
@"pad0": u8,
@"address_len": u16,
@"address": []u8,
};
/// @brief ListHostscookie
pub const ListHostscookie = struct {
sequence: c_uint,
};
/// @brief ListHostsRequest
pub const ListHostsRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief ListHostsReply
pub const ListHostsReply = struct {
@"response_type": u8,
@"mode": u8,
@"sequence": u16,
@"length": u32,
@"hosts_len": u16,
@"pad0": [22]u8,
@"hosts": []xcb.HOST,
};
pub const AccessControl = extern enum(c_uint) {
@"Disable" = 0,
@"Enable" = 1,
};
/// @brief SetAccessControlRequest
pub const SetAccessControlRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
};
pub const CloseDown = extern enum(c_uint) {
@"DestroyAll" = 0,
@"RetainPermanent" = 1,
@"RetainTemporary" = 2,
};
/// @brief SetCloseDownModeRequest
pub const SetCloseDownModeRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
};
pub const Kill = extern enum(c_uint) {
@"AllTemporary" = 0,
};
/// @brief KillClientRequest
pub const KillClientRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"resource": u32,
};
/// @brief RotatePropertiesRequest
pub const RotatePropertiesRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
@"window": xcb.WINDOW,
@"atoms_len": u16,
@"delta": i16,
@"atoms": []const xcb.ATOM,
};
pub const ScreenSaver = extern enum(c_uint) {
@"Reset" = 0,
@"Active" = 1,
};
/// @brief ForceScreenSaverRequest
pub const ForceScreenSaverRequest = struct {
@"major_opcode": u8,
@"mode": u8,
@"length": u16,
};
pub const MappingStatus = extern enum(c_uint) {
@"Success" = 0,
@"Busy" = 1,
@"Failure" = 2,
};
/// @brief SetPointerMappingcookie
pub const SetPointerMappingcookie = struct {
sequence: c_uint,
};
/// @brief SetPointerMappingRequest
pub const SetPointerMappingRequest = struct {
@"major_opcode": u8,
@"map_len": u8,
@"length": u16,
@"map": []const u8,
};
/// @brief SetPointerMappingReply
pub const SetPointerMappingReply = struct {
@"response_type": u8,
@"status": u8,
@"sequence": u16,
@"length": u32,
};
/// @brief GetPointerMappingcookie
pub const GetPointerMappingcookie = struct {
sequence: c_uint,
};
/// @brief GetPointerMappingRequest
pub const GetPointerMappingRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetPointerMappingReply
pub const GetPointerMappingReply = struct {
@"response_type": u8,
@"map_len": u8,
@"sequence": u16,
@"length": u32,
@"pad0": [24]u8,
@"map": []u8,
};
pub const MapIndex = extern enum(c_uint) {
@"Shift" = 0,
@"Lock" = 1,
@"Control" = 2,
@"1" = 3,
@"2" = 4,
@"3" = 5,
@"4" = 6,
@"5" = 7,
};
/// @brief SetModifierMappingcookie
pub const SetModifierMappingcookie = struct {
sequence: c_uint,
};
/// @brief SetModifierMappingRequest
pub const SetModifierMappingRequest = struct {
@"major_opcode": u8,
@"keycodes_per_modifier": u8,
@"length": u16,
@"keycodes": []const xcb.KEYCODE,
};
/// @brief SetModifierMappingReply
pub const SetModifierMappingReply = struct {
@"response_type": u8,
@"status": u8,
@"sequence": u16,
@"length": u32,
};
/// @brief GetModifierMappingcookie
pub const GetModifierMappingcookie = struct {
sequence: c_uint,
};
/// @brief GetModifierMappingRequest
pub const GetModifierMappingRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
/// @brief GetModifierMappingReply
pub const GetModifierMappingReply = struct {
@"response_type": u8,
@"keycodes_per_modifier": u8,
@"sequence": u16,
@"length": u32,
@"pad0": [24]u8,
@"keycodes": []xcb.KEYCODE,
};
/// @brief NoOperationRequest
pub const NoOperationRequest = struct {
@"major_opcode": u8,
@"pad0": u8,
@"length": u16,
};
test "" {
@import("std").testing.refAllDecls(@This());
} | src/auto/xproto.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const List = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const int = i64;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day12.txt");
const Edge = struct {
a: u8,
b: u8,
};
const start_id = 0;
const end_id = 1;
pub fn main() !void {
var edges: []const Edge = undefined;
var names: []const Str = undefined;
{
var cave_ids = StrMap(u8).init(gpa);
defer cave_ids.deinit();
var cave_names = List(Str).init(gpa);
errdefer cave_names.deinit();
var edges_l = List(Edge).init(gpa);
errdefer edges_l.deinit();
try cave_ids.put("start", start_id);
try cave_ids.put("end", end_id);
try cave_names.append("start");
try cave_names.append("end");
var next_cave_id: u8 = 2; // after start and end id
var lines = tokenize(u8, data, "\r\n");
while (lines.next()) |line| {
var parts = split(u8, line, "-");
const a = parts.next().?;
const b = parts.next().?;
assert(parts.next() == null);
const a_id = cave_ids.get(a) orelse blk: {
const id = next_cave_id;
next_cave_id += 1;
try cave_ids.put(a, id);
try cave_names.append(a);
break :blk id;
};
const b_id = cave_ids.get(b) orelse blk: {
const id = next_cave_id;
next_cave_id += 1;
try cave_ids.put(b, id);
try cave_names.append(b);
break :blk id;
};
try edges_l.append(.{ .a = a_id, .b = b_id });
}
edges = edges_l.toOwnedSlice();
names = cave_names.toOwnedSlice();
}
defer gpa.free(edges);
defer gpa.free(names);
const part1_r = try countPathsRecursive(names, edges, false);
const part2_r = try countPathsRecursive(names, edges, true);
const part1_s = try countPathsStack(names, edges, false);
const part2_s = try countPathsStack(names, edges, true);
print("recur: part1={}, part2={}\n", .{part1_r, part2_r});
print("stack: part1={}, part2={}\n", .{part1_s, part2_s});
}
fn countPathsRecursive(names: []const Str, edges: []const Edge, in_allow_revisit: bool) !usize {
const Walk = struct {
already_hit: std.DynamicBitSet,
names: []const Str,
edges: []const Edge,
fn countPaths(self: *@This(), id: u8, allow_revisit: bool) usize {
if (id == end_id) return 1;
var is_double = false;
if (self.already_hit.isSet(id)) {
if (!allow_revisit or id == start_id) return 0;
is_double = true;
} else if (self.names[id][0] >= 'a') {
self.already_hit.set(id);
}
defer if (!is_double) {
self.already_hit.unset(id);
};
var paths: usize = 0;
next_edge: for (self.edges) |edge| {
const n = if (edge.a == id) edge.b
else if (edge.b == id) edge.a
else continue :next_edge;
paths += self.countPaths(n, allow_revisit and !is_double);
}
return paths;
}
};
var walk = Walk{
.edges = edges,
.names = names,
.already_hit = try std.DynamicBitSet.initEmpty(gpa, names.len),
};
defer walk.already_hit.deinit();
return walk.countPaths(start_id, in_allow_revisit);
}
fn countPathsStack(names: []const Str, edges: []const Edge, allow_revisit: bool) !usize {
const State = struct {
id: u8,
next_edge: u8 = 0,
is_double: bool,
};
var stack = std.ArrayList(State).init(gpa);
defer stack.deinit();
var already_hit = try std.DynamicBitSet.initEmpty(gpa, names.len);
defer already_hit.deinit();
already_hit.set(start_id);
try stack.append(.{
.id = start_id,
.is_double = false,
});
var total: usize = 0;
var did_double = false;
loop: while (stack.items.len > 0) {
const curr = &stack.items[stack.items.len - 1];
next_edge: while (curr.next_edge < edges.len) {
const e = edges[curr.next_edge];
curr.next_edge += 1;
const n = if (e.a == curr.id) e.b
else if (e.b == curr.id) e.a
else continue :next_edge;
// never move back to the start
if (n == start_id) {
continue :next_edge;
}
if (n == end_id) {
total += 1;
continue :next_edge;
}
var is_double: bool = false;
if (already_hit.isSet(n)) {
if (!allow_revisit or did_double) {
continue :next_edge;
}
did_double = true;
is_double = true;
} else {
const is_small = names[n][0] >= 'a';
if (is_small) already_hit.set(n);
}
try stack.append(.{
.id = n,
.is_double = is_double,
});
continue :loop;
}
if (curr.is_double) {
did_double = false;
} else {
already_hit.unset(curr.id);
}
_ = stack.pop();
}
return total;
}
// Useful stdlib functions
const tokenize = std.mem.tokenize;
const split = std.mem.split;
const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear;
const lastIndexOf = std.mem.lastIndexOfScalar;
const lastIndexOfAny = std.mem.lastIndexOfAny;
const lastIndexOfStr = std.mem.lastIndexOfLinear;
const trim = std.mem.trim;
const sliceMin = std.mem.min;
const sliceMax = std.mem.max;
const eql = std.mem.eql;
const parseEnum = std.meta.stringToEnum;
const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat;
const min = std.math.min;
const min3 = std.math.min3;
const max = std.math.max;
const max3 = std.math.max3;
const print = std.debug.print;
const assert = std.debug.assert;
const sort = std.sort.sort;
const asc = std.sort.asc;
const desc = std.sort.desc; | src/day12.zig |
const std = @import("std");
usingnamespace (@import("../machine.zig"));
usingnamespace (@import("../util.zig"));
const reg = Operand.register;
const regRm = Operand.registerRm;
const imm = Operand.immediate;
test "rotate and shift" {
const m32 = Machine.init(.x86_32);
const m64 = Machine.init(.x64);
debugPrint(false);
{
{
testOp2(m32, .RCL, regRm(.AL), reg(.CL), "D2 D0");
testOp2(m32, .RCR, regRm(.AL), reg(.CL), "D2 D8");
testOp2(m32, .ROL, regRm(.AL), reg(.CL), "D2 C0");
testOp2(m32, .ROR, regRm(.AL), reg(.CL), "D2 C8");
//
testOp2(m64, .RCL, regRm(.AL), reg(.CL), "D2 D0");
testOp2(m64, .RCR, regRm(.AL), reg(.CL), "D2 D8");
testOp2(m64, .ROL, regRm(.AL), reg(.CL), "D2 C0");
testOp2(m64, .ROR, regRm(.AL), reg(.CL), "D2 C8");
}
{
testOp2(m32, .RCL, reg(.AX), reg(.CL), "66 D3 D0");
testOp2(m32, .RCR, reg(.AX), reg(.CL), "66 D3 D8");
testOp2(m32, .ROL, reg(.AX), reg(.CL), "66 D3 C0");
testOp2(m32, .ROR, reg(.AX), reg(.CL), "66 D3 C8");
//
testOp2(m64, .RCL, reg(.AX), reg(.CL), "66 D3 D0");
testOp2(m64, .RCR, reg(.AX), reg(.CL), "66 D3 D8");
testOp2(m64, .ROL, reg(.AX), reg(.CL), "66 D3 C0");
testOp2(m64, .ROR, reg(.AX), reg(.CL), "66 D3 C8");
}
{
testOp2(m32, .RCL, reg(.EAX), reg(.CL), "D3 D0");
testOp2(m32, .RCR, reg(.EAX), reg(.CL), "D3 D8");
testOp2(m32, .ROL, reg(.EAX), reg(.CL), "D3 C0");
testOp2(m32, .ROR, reg(.EAX), reg(.CL), "D3 C8");
//
testOp2(m64, .RCL, reg(.EAX), reg(.CL), "D3 D0");
testOp2(m64, .RCR, reg(.EAX), reg(.CL), "D3 D8");
testOp2(m64, .ROL, reg(.EAX), reg(.CL), "D3 C0");
testOp2(m64, .ROR, reg(.EAX), reg(.CL), "D3 C8");
}
{
testOp2(m32, .RCL, reg(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .RCR, reg(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .ROL, reg(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .ROR, reg(.RAX), reg(.CL), AsmError.InvalidOperand);
//
testOp2(m64, .RCL, reg(.RAX), reg(.CL), "48 D3 D0");
testOp2(m64, .RCR, reg(.RAX), reg(.CL), "48 D3 D8");
testOp2(m64, .ROL, reg(.RAX), reg(.CL), "48 D3 C0");
testOp2(m64, .ROR, reg(.RAX), reg(.CL), "48 D3 C8");
}
}
{
{
testOp2(m32, .RCL, regRm(.AL), imm(1), "D0 D0");
testOp2(m32, .RCR, regRm(.AL), imm(1), "D0 D8");
testOp2(m32, .ROL, regRm(.AL), imm(1), "D0 C0");
testOp2(m32, .ROR, regRm(.AL), imm(1), "D0 C8");
//
testOp2(m64, .RCL, regRm(.AL), imm(1), "D0 D0");
testOp2(m64, .RCR, regRm(.AL), imm(1), "D0 D8");
testOp2(m64, .ROL, regRm(.AL), imm(1), "D0 C0");
testOp2(m64, .ROR, regRm(.AL), imm(1), "D0 C8");
}
{
testOp2(m32, .RCL, reg(.AX), imm(1), "66 D1 D0");
testOp2(m32, .RCR, reg(.AX), imm(1), "66 D1 D8");
testOp2(m32, .ROL, reg(.AX), imm(1), "66 D1 C0");
testOp2(m32, .ROR, reg(.AX), imm(1), "66 D1 C8");
//
testOp2(m64, .RCL, reg(.AX), imm(1), "66 D1 D0");
testOp2(m64, .RCR, reg(.AX), imm(1), "66 D1 D8");
testOp2(m64, .ROL, reg(.AX), imm(1), "66 D1 C0");
testOp2(m64, .ROR, reg(.AX), imm(1), "66 D1 C8");
}
{
testOp2(m32, .RCL, reg(.EAX), imm(1), "D1 D0");
testOp2(m32, .RCR, reg(.EAX), imm(1), "D1 D8");
testOp2(m32, .ROL, reg(.EAX), imm(1), "D1 C0");
testOp2(m32, .ROR, reg(.EAX), imm(1), "D1 C8");
//
testOp2(m64, .RCL, reg(.EAX), imm(1), "D1 D0");
testOp2(m64, .RCR, reg(.EAX), imm(1), "D1 D8");
testOp2(m64, .ROL, reg(.EAX), imm(1), "D1 C0");
testOp2(m64, .ROR, reg(.EAX), imm(1), "D1 C8");
}
{
testOp2(m32, .RCL, reg(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .RCR, reg(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .ROL, reg(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .ROR, reg(.RAX), imm(1), AsmError.InvalidOperand);
//
testOp2(m64, .RCL, reg(.RAX), imm(1), "48 D1 D0");
testOp2(m64, .RCR, reg(.RAX), imm(1), "48 D1 D8");
testOp2(m64, .ROL, reg(.RAX), imm(1), "48 D1 C0");
testOp2(m64, .ROR, reg(.RAX), imm(1), "48 D1 C8");
}
}
{
{
testOp2(m32, .RCL, regRm(.AL), imm(4), "C0 D0 04");
testOp2(m32, .RCR, regRm(.AL), imm(4), "C0 D8 04");
testOp2(m32, .ROL, regRm(.AL), imm(4), "C0 C0 04");
testOp2(m32, .ROR, regRm(.AL), imm(4), "C0 C8 04");
//
testOp2(m64, .RCL, regRm(.AL), imm(4), "C0 D0 04");
testOp2(m64, .RCR, regRm(.AL), imm(4), "C0 D8 04");
testOp2(m64, .ROL, regRm(.AL), imm(4), "C0 C0 04");
testOp2(m64, .ROR, regRm(.AL), imm(4), "C0 C8 04");
}
{
testOp2(m32, .RCL, reg(.AX), imm(4), "66 C1 D0 04");
testOp2(m32, .RCR, reg(.AX), imm(4), "66 C1 D8 04");
testOp2(m32, .ROL, reg(.AX), imm(4), "66 C1 C0 04");
testOp2(m32, .ROR, reg(.AX), imm(4), "66 C1 C8 04");
//
testOp2(m64, .RCL, reg(.AX), imm(4), "66 C1 D0 04");
testOp2(m64, .RCR, reg(.AX), imm(4), "66 C1 D8 04");
testOp2(m64, .ROL, reg(.AX), imm(4), "66 C1 C0 04");
testOp2(m64, .ROR, reg(.AX), imm(4), "66 C1 C8 04");
}
{
testOp2(m32, .RCL, reg(.EAX), imm(4), "C1 D0 04");
testOp2(m32, .RCR, reg(.EAX), imm(4), "C1 D8 04");
testOp2(m32, .ROL, reg(.EAX), imm(4), "C1 C0 04");
testOp2(m32, .ROR, reg(.EAX), imm(4), "C1 C8 04");
//
testOp2(m64, .RCL, reg(.EAX), imm(4), "C1 D0 04");
testOp2(m64, .RCR, reg(.EAX), imm(4), "C1 D8 04");
testOp2(m64, .ROL, reg(.EAX), imm(4), "C1 C0 04");
testOp2(m64, .ROR, reg(.EAX), imm(4), "C1 C8 04");
}
{
testOp2(m32, .RCL, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .RCR, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .ROL, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .ROR, reg(.RAX), imm(4), AsmError.InvalidOperand);
//
testOp2(m64, .RCL, reg(.RAX), imm(4), "48 C1 D0 04");
testOp2(m64, .RCR, reg(.RAX), imm(4), "48 C1 D8 04");
testOp2(m64, .ROL, reg(.RAX), imm(4), "48 C1 C0 04");
testOp2(m64, .ROR, reg(.RAX), imm(4), "48 C1 C8 04");
}
}
{
{
testOp2(m32, .SAL, regRm(.AL), reg(.CL), "D2 E0");
testOp2(m32, .SAR, regRm(.AL), reg(.CL), "D2 F8");
testOp2(m32, .SHL, regRm(.AL), reg(.CL), "D2 E0");
testOp2(m32, .SHR, regRm(.AL), reg(.CL), "D2 E8");
//
testOp2(m64, .SAL, regRm(.AL), reg(.CL), "D2 E0");
testOp2(m64, .SAR, regRm(.AL), reg(.CL), "D2 F8");
testOp2(m64, .SHL, regRm(.AL), reg(.CL), "D2 E0");
testOp2(m64, .SHR, regRm(.AL), reg(.CL), "D2 E8");
}
{
testOp2(m32, .SAL, reg(.AX), reg(.CL), "66 D3 E0");
testOp2(m32, .SAR, reg(.AX), reg(.CL), "66 D3 F8");
testOp2(m32, .SHL, reg(.AX), reg(.CL), "66 D3 E0");
testOp2(m32, .SHR, reg(.AX), reg(.CL), "66 D3 E8");
//
testOp2(m64, .SAL, reg(.AX), reg(.CL), "66 D3 E0");
testOp2(m64, .SAR, reg(.AX), reg(.CL), "66 D3 F8");
testOp2(m64, .SHL, reg(.AX), reg(.CL), "66 D3 E0");
testOp2(m64, .SHR, reg(.AX), reg(.CL), "66 D3 E8");
}
{
testOp2(m32, .SAL, regRm(.EAX), reg(.CL), "D3 E0");
testOp2(m32, .SAR, regRm(.EAX), reg(.CL), "D3 F8");
testOp2(m32, .SHL, regRm(.EAX), reg(.CL), "D3 E0");
testOp2(m32, .SHR, regRm(.EAX), reg(.CL), "D3 E8");
//
testOp2(m64, .SAL, regRm(.EAX), reg(.CL), "D3 E0");
testOp2(m64, .SAR, regRm(.EAX), reg(.CL), "D3 F8");
testOp2(m64, .SHL, regRm(.EAX), reg(.CL), "D3 E0");
testOp2(m64, .SHR, regRm(.EAX), reg(.CL), "D3 E8");
}
{
testOp2(m32, .SAL, regRm(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .SAR, regRm(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .SHL, regRm(.RAX), reg(.CL), AsmError.InvalidOperand);
testOp2(m32, .SHR, regRm(.RAX), reg(.CL), AsmError.InvalidOperand);
//
testOp2(m64, .SAL, regRm(.RAX), reg(.CL), "48 D3 E0");
testOp2(m64, .SAR, regRm(.RAX), reg(.CL), "48 D3 F8");
testOp2(m64, .SHL, regRm(.RAX), reg(.CL), "48 D3 E0");
testOp2(m64, .SHR, regRm(.RAX), reg(.CL), "48 D3 E8");
}
}
{
{
testOp2(m32, .SAL, regRm(.AL), imm(1), "D0 E0");
testOp2(m32, .SAR, regRm(.AL), imm(1), "D0 F8");
testOp2(m32, .SHL, regRm(.AL), imm(1), "D0 E0");
testOp2(m32, .SHR, regRm(.AL), imm(1), "D0 E8");
//
testOp2(m64, .SAL, regRm(.AL), imm(1), "D0 E0");
testOp2(m64, .SAR, regRm(.AL), imm(1), "D0 F8");
testOp2(m64, .SHL, regRm(.AL), imm(1), "D0 E0");
testOp2(m64, .SHR, regRm(.AL), imm(1), "D0 E8");
}
{
testOp2(m32, .SAL, regRm(.AX), imm(1), "66 D1 E0");
testOp2(m32, .SAR, regRm(.AX), imm(1), "66 D1 F8");
testOp2(m32, .SHL, regRm(.AX), imm(1), "66 D1 E0");
testOp2(m32, .SHR, regRm(.AX), imm(1), "66 D1 E8");
//
testOp2(m64, .SAL, regRm(.AX), imm(1), "66 D1 E0");
testOp2(m64, .SAR, regRm(.AX), imm(1), "66 D1 F8");
testOp2(m64, .SHL, regRm(.AX), imm(1), "66 D1 E0");
testOp2(m64, .SHR, regRm(.AX), imm(1), "66 D1 E8");
}
{
testOp2(m32, .SAL, regRm(.EAX), imm(1), "D1 E0");
testOp2(m32, .SAR, regRm(.EAX), imm(1), "D1 F8");
testOp2(m32, .SHL, regRm(.EAX), imm(1), "D1 E0");
testOp2(m32, .SHR, regRm(.EAX), imm(1), "D1 E8");
//
testOp2(m64, .SAL, regRm(.EAX), imm(1), "D1 E0");
testOp2(m64, .SAR, regRm(.EAX), imm(1), "D1 F8");
testOp2(m64, .SHL, regRm(.EAX), imm(1), "D1 E0");
testOp2(m64, .SHR, regRm(.EAX), imm(1), "D1 E8");
}
{
testOp2(m32, .SAL, regRm(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .SAR, regRm(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .SHL, regRm(.RAX), imm(1), AsmError.InvalidOperand);
testOp2(m32, .SHR, regRm(.RAX), imm(1), AsmError.InvalidOperand);
//
testOp2(m64, .SAL, regRm(.RAX), imm(1), "48 D1 E0");
testOp2(m64, .SAR, regRm(.RAX), imm(1), "48 D1 F8");
testOp2(m64, .SHL, regRm(.RAX), imm(1), "48 D1 E0");
testOp2(m64, .SHR, regRm(.RAX), imm(1), "48 D1 E8");
}
}
{
{
testOp2(m32, .SAL, reg(.AL), imm(4), "C0 E0 04");
testOp2(m32, .SAR, reg(.AL), imm(4), "C0 F8 04");
testOp2(m32, .SHL, reg(.AL), imm(4), "C0 E0 04");
testOp2(m32, .SHR, reg(.AL), imm(4), "C0 E8 04");
//
testOp2(m64, .SAL, reg(.AL), imm(4), "C0 E0 04");
testOp2(m64, .SAR, reg(.AL), imm(4), "C0 F8 04");
testOp2(m64, .SHL, reg(.AL), imm(4), "C0 E0 04");
testOp2(m64, .SHR, reg(.AL), imm(4), "C0 E8 04");
}
{
testOp2(m32, .SAL, reg(.AX), imm(4), "66 C1 E0 04");
testOp2(m32, .SAR, reg(.AX), imm(4), "66 C1 F8 04");
testOp2(m32, .SHL, reg(.AX), imm(4), "66 C1 E0 04");
testOp2(m32, .SHR, reg(.AX), imm(4), "66 C1 E8 04");
//
testOp2(m64, .SAL, reg(.AX), imm(4), "66 C1 E0 04");
testOp2(m64, .SAR, reg(.AX), imm(4), "66 C1 F8 04");
testOp2(m64, .SHL, reg(.AX), imm(4), "66 C1 E0 04");
testOp2(m64, .SHR, reg(.AX), imm(4), "66 C1 E8 04");
}
{
testOp2(m32, .SAL, reg(.EAX), imm(4), "C1 E0 04");
testOp2(m32, .SAR, reg(.EAX), imm(4), "C1 F8 04");
testOp2(m32, .SHL, reg(.EAX), imm(4), "C1 E0 04");
testOp2(m32, .SHR, reg(.EAX), imm(4), "C1 E8 04");
//
testOp2(m64, .SAL, reg(.EAX), imm(4), "C1 E0 04");
testOp2(m64, .SAR, reg(.EAX), imm(4), "C1 F8 04");
testOp2(m64, .SHL, reg(.EAX), imm(4), "C1 E0 04");
testOp2(m64, .SHR, reg(.EAX), imm(4), "C1 E8 04");
}
{
testOp2(m32, .SAL, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .SAR, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .SHL, reg(.RAX), imm(4), AsmError.InvalidOperand);
testOp2(m32, .SHR, reg(.RAX), imm(4), AsmError.InvalidOperand);
//
testOp2(m64, .SAL, reg(.RAX), imm(4), "48 C1 E0 04");
testOp2(m64, .SAR, reg(.RAX), imm(4), "48 C1 F8 04");
testOp2(m64, .SHL, reg(.RAX), imm(4), "48 C1 E0 04");
testOp2(m64, .SHR, reg(.RAX), imm(4), "48 C1 E8 04");
}
}
} | src/x86/tests/rotate.zig |
const std = @import("std");
const testing = std.testing;
const stderr = std.io.getStdErr().writer();
const hts = @cImport({
@cInclude("htslib_struct_access.h");
@cInclude("htslib/hts.h");
@cInclude("htslib/vcf.h");
@cInclude("htslib/tbx.h");
});
pub const Field = enum {
info,
format,
};
/// This stores the `bcf_hdr_t` and provides convenience mthods.
pub const Header = struct {
c: ?*hts.bcf_hdr_t,
pub fn deinit(self: *Header) void {
if (self.c != null) {
hts.bcf_hdr_destroy(self.c.?);
self.c = null;
}
}
inline fn sync(self: Header) !void {
const ret = hts.bcf_hdr_sync(self.c);
if (ret != 0) {
return ret_to_err(ret, "sync");
}
}
/// add a valid string to the Header. Must contain new-line or have null
/// terminator.
pub fn add_string(self: Header, str: []const u8) !void {
const ret = hts.bcf_hdr_append(self.c, &(str[0]));
if (ret != 0) {
return ret_to_err(ret, "header.add_string");
}
return self.sync();
}
pub fn set(self: *Header, c: *hts.bcf_hdr_t) void {
self.c = hts.bcf_hdr_dup(c);
}
/// create a new header from a string
pub fn from_string(self: *Header, str: []u8) !void {
const mode = "w";
self.c = hts.bcf_hdr_init(&(mode[0]));
var ret = hts.bcf_hdr_parse(self.c, &(str[0]));
if (ret != 0) {
return ret_to_err(ret, "header.from_string");
}
}
pub fn add(self: Header, allocator: *std.mem.Allocator, fld: Field, id: []const u8, number: []const u8, typ: []const u8, description: []const u8) !void {
// https://ziglearn.org/chapter-2/#formatting
const h = if (fld == Field.info)
"INFO"
else
"FORMAT";
const s = try std.fmt.allocPrint(allocator, "##{s}=<ID={s},Number={s},Type={s},Description=\"{s}\">\n", .{ h, id, number, typ, description });
defer allocator.free(s);
return self.add_string(s);
}
pub fn format(self: Header, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
_ = self;
try writer.writeAll("Header()");
}
pub fn tostring(self: Header, allocator: *std.mem.Allocator) ?[]u8 {
var str = hts.kstring_t{ .s = null, .l = 0, .m = 0 };
if (hts.bcf_hdr_format(self.c, 0, &str) != 0) {
return null;
}
defer hts.free(str.s);
defer str.s = null;
// TODO: <strings> need copy of this, not slice.
var sl = std.mem.sliceTo(str.s, 0);
var result = std.mem.dupe(allocator, u8, sl) catch |err| {
_ = err catch return "";
};
return result;
}
};
/// These are the possible return values from errors in htslib calls.
pub const HTSError = error{
IncorrectNumberOfValues,
NotFound,
UnexpectedType,
UndefinedTag,
UnknownError,
};
fn ret_to_err(
ret: c_int,
attr_name: []const u8,
) HTSError {
const retval = switch (ret) {
-10 => HTSError.IncorrectNumberOfValues,
-3 => HTSError.NotFound,
-2 => HTSError.UnexpectedType,
-1 => HTSError.UndefinedTag,
else => {
stderr.print("[zig-hts/vcf] unknown return ({s})\n", .{attr_name}) catch {};
return HTSError.UnknownError;
},
};
return retval;
}
inline fn allele_value(val: i32) i32 {
if (val < 0) {
return val;
}
return (val >> 1) - 1;
}
pub const Allele = struct {
val: i32,
pub inline fn phased(a: Allele) bool {
return (a.val & 1) == 1;
}
pub inline fn value(a: Allele) i32 {
if (a.val < 0) {
return a.val;
}
return (a.val >> 1) - 1;
}
pub fn format(self: Allele, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
const v = self.value();
if (v < 0) {
if (self.val == 0) {
try writer.writeAll("./");
} else {
try writer.writeAll("$");
}
} else {
try writer.print("{d}", .{v});
if (self.phased()) {
try writer.writeAll("|");
} else {
try writer.writeAll("/");
}
}
}
};
// A genotype is a sequence of alleles.
pub const Genotype = struct {
alleles: []i32,
pub fn format(self: Genotype, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
for (self.alleles) |allele| {
try (Allele{ .val = allele }).format(fmt, options, writer);
}
}
};
/// These are the int32 values used by htslib internally.
pub const Genotypes = struct {
gts: []i32,
ploidy: i32,
pub inline fn at(self: Genotypes, i: i32) Genotype {
var sub = self.gts[@intCast(usize, i * self.ploidy)..@intCast(usize, (i + 1) * self.ploidy)];
return Genotype{ .alleles = sub };
}
pub fn format(self: Genotypes, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.writeAll("[");
var i: i32 = 0;
while (i * self.ploidy < self.gts.len - 1) {
try (self.at(i)).format(fmt, options, writer);
i += 1;
if (i * self.ploidy < self.gts.len) {
try writer.writeAll(", ");
}
}
try writer.writeAll("]");
}
/// the number of alternate alleles in the genotype.
/// for bi-allelics can think of 0 => hom-ref, 1 => het, 2=> hom-alt, -1 =>unknown
/// ./1 == 1
/// 0/. == 0
/// ./. -> -1
/// 1/1 -> 2
/// 1/1/1 -> 3
/// 0/2 -> 1
/// 1/2 -> 2
pub fn alts(self: Genotypes, allocator: *std.mem.Allocator) ![]i8 {
var n_samples: i32 = @divTrunc(@intCast(i32, self.gts.len), self.ploidy);
var data = try allocator.alloc(i8, @intCast(usize, n_samples));
var i: usize = 0;
while (i < n_samples) {
var j: usize = 0;
data[i] = 0;
while (j < self.ploidy) {
var val = std.math.min(1, std.math.max(-1, allele_value(self.gts[@intCast(usize, i * @intCast(usize, self.ploidy) + j)])));
data[i] += @intCast(i8, val);
j += 1;
}
data[i] = std.math.max(data[i], -1);
i += 1;
}
return data;
}
};
/// This provides access to the fields in a genetic variant.
pub const Variant = struct {
c: ?*hts.bcf1_t,
vcf: VCF,
// deallocate memory (from htslib) for this variant. only needed if this is
// a copy of a variant from an iterator.
pub fn deinit(self: Variant) void {
if (self.c != null) {
hts.bcf_destroy(self.c);
}
}
/// the 0-based start position of the variant
pub inline fn start(self: Variant) i64 {
return @as(i64, hts.variant_pos(self.c));
}
/// create a copy of the variant and underlying pointer.
pub fn dup(self: Variant) Variant {
var result = Variant{ .c = hts.bcf_dup(self.c), .vcf = self.vcf };
_ = hts.bcf_unpack(result.c, 3);
return result;
}
/// the 1-based half-open close position of the variant
pub inline fn stop(self: Variant) i64 {
return self.start() + @as(i64, hts.variant_rlen(self.c));
}
/// the string chromosome of the variant.
pub inline fn CHROM(self: Variant) []const u8 {
_ = hts.bcf_unpack(self.c, 4);
var ccr = hts.bcf_hdr_id2name(self.vcf.header.c, hts.variant_rid(self.c));
return std.mem.sliceTo(ccr, 0);
}
/// the reference allele
pub fn REF(self: Variant) []const u8 {
return std.mem.sliceTo(hts.variant_REF(self.c), 0);
}
/// the first alternate allele
pub fn ALT0(self: Variant) []const u8 {
return self.ALT(0);
}
/// the ith alternate allele
pub fn ALT(self: Variant, i: i32) []const u8 {
return std.mem.sliceTo(hts.variant_ALT(self.c, i), 0);
}
/// this currently returns only the first filter
pub fn FILTER(self: Variant) []const u8 {
_ = hts.bcf_unpack(self.c, 4);
if (hts.variant_nflt(self.c) == 0) {
return "PASS";
}
return std.mem.sliceTo(hts.variant_flt0(self.c, self.vcf.header.c), 0);
}
/// the variant ID field
pub fn ID(self: Variant) []const u8 {
_ = hts.bcf_unpack(self.c, 4);
// note to self, this sliceTo is how to get []u8 from [*c]u8
// expected type '[]const u8', found '[*c]const u8'
return std.mem.sliceTo(hts.variant_id(self.c), 0);
}
/// the variant quality
pub inline fn QUAL(self: Variant) f32 {
return hts.variant_QUAL(self.c);
}
/// access float or int (T of i32 or f32) in the info or format field
/// values may be reallocated as needed.
pub fn get(self: *Variant, iof: Field, comptime T: type, values: *std.ArrayList(T), field_name: []const u8) !void {
// need pointer to variant because we use self.c_void_ptr;
// cfunc is bcf_get_{info,format}_values depending on `iof`.
var cfunc = switch (iof) {
Field.info => blk_info: {
_ = hts.bcf_unpack(self.c, hts.BCF_UN_INFO);
break :blk_info hts.bcf_get_info_values;
},
Field.format => blk_fmt: {
_ = hts.bcf_unpack(self.c, hts.BCF_UN_FMT);
break :blk_fmt hts.bcf_get_format_values;
},
};
var n: c_int = 0;
var typs = switch (@typeInfo(T)) {
.ComptimeInt, .Int => .{ hts.BCF_HT_INT, i32 },
.ComptimeFloat, .Float => .{ hts.BCF_HT_REAL, f32 },
else => @compileError("only ints (i32, i64) and floats accepted to get()"),
};
var ret = cfunc(self.vcf.header.c, self.c, &(field_name[0]), &self.vcf.c_void_ptr, &n, typs[0]);
if (ret < 0) {
return ret_to_err(ret, field_name);
}
// typs[1] is i32 or f32
var casted = @ptrCast([*c]u8, @alignCast(@alignOf(typs[1]), self.vcf.c_void_ptr));
try (values.*).resize(@intCast(usize, n));
@memcpy(@ptrCast([*]u8, &values.items[0]), casted, @intCast(usize, n * @sizeOf(typs[1])));
}
pub fn set(self: Variant, iof: Field, comptime T: type, vals: []T, field_name: []const u8) !void {
// cfunc is bcf_get_{info,format}_values depending on `iof`.
var cfunc = switch (iof) {
Field.info => blk_info: {
_ = hts.bcf_unpack(self.c, hts.BCF_UN_INFO);
break :blk_info hts.bcf_update_info;
},
Field.format => blk_fmt: {
_ = hts.bcf_unpack(self.c, hts.BCF_UN_FMT);
break :blk_fmt hts.bcf_update_format;
},
};
var typs = switch (@typeInfo(T)) {
.ComptimeInt, .Int => .{ hts.BCF_HT_INT, i32 },
.ComptimeFloat, .Float => .{ hts.BCF_HT_REAL, f32 },
else => @compileError("only ints (i32, i64) and floats accepted to get()"),
};
var ret = cfunc(self.vcf.header.c, self.c, &(field_name[0]), &(vals[0]), @intCast(c_int, vals.len), typs[0]);
if (ret < 0) {
return ret_to_err(ret, field_name);
}
}
/// number of samples in the variant
pub inline fn n_samples(self: Variant) i32 {
return hts.variant_n_samples(self.c);
}
/// Get the genotypes from the GT field for all samples.
pub fn genotypes(self: *Variant, gts: *std.ArrayList(i32)) !Genotypes {
try self.get(Field.format, i32, gts, "GT");
return Genotypes{ .gts = gts.items[0..gts.items.len], .ploidy = @floatToInt(i32, @intToFloat(f32, gts.items.len) / @intToFloat(f32, self.n_samples())) };
}
pub fn format(self: Variant, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.print("Variant({s}:{d}-{d} ({s}/{s}))", .{ self.CHROM(), self.start(), self.stop(), self.REF(), self.ALT0() });
}
/// return a string of the variant.
pub fn tostring(self: Variant, allocator: *std.mem.Allocator) ?[]u8 {
var str = hts.kstring_t{ .s = null, .l = 0, .m = 0 };
if (hts.vcf_format(self.vcf.header.c, self.c, &str) != 0) {
return null;
}
var sl = std.mem.sliceTo(str.s, 0);
defer hts.free(str.s);
defer str.s = null;
var result = std.mem.dupe(allocator, u8, sl) catch |err| {
_ = err catch return "";
};
return result;
}
};
/// Represents the variant (bcf or vcf) file.
/// has several convenience methods such as query and iteration.
pub const VCF = struct {
hts: ?*hts.htsFile,
fname: []const u8,
header: Header,
variant_c: ?*hts.bcf1_t,
idx_c: ?*hts.hts_idx_t,
tbx_c: ?*hts.tbx_t = null,
c_void_ptr: ?*c_void = null,
/// open a vcf for reading from the given path
pub fn open(path: []const u8) ?VCF {
return VCF.open_mode(path, "r");
}
/// open a file with the given mode. must use full mode, e.g. wb for writing bcf.
/// if opened for writing, the header must be set.
pub fn open_mode(path: []const u8, mode: []const u8) ?VCF {
const hf = hts.hts_open(&(path[0]), &(mode[0]));
if (hf == null) {
return null;
}
var h: Header = if (mode[0] == 'w') Header{ .c = null } else Header{ .c = hts.bcf_hdr_read(hf.?) };
return VCF{ .hts = hf.?, .header = h, .fname = path, .variant_c = hts.bcf_init().?, .idx_c = null };
}
pub fn write_header(self: VCF) void {
_ = hts.bcf_hdr_write(self.hts, self.header.c);
}
/// write the variant to the file.
pub fn write_variant(self: VCF, variant: Variant) !void {
const ret = hts.bcf_write(self.hts, self.header.c, variant.c);
// TODO: handle unknown contig as in hts-nim
if (ret < 0) {
return ret_to_err(ret, "error writing variant");
}
}
/// set the number of decompression threads
pub fn set_threads(self: VCF, threads: i32) void {
hts.hts_set_threads(self.hts, @as(c_int, threads));
}
/// number of samples in the VCF
pub inline fn n_samples(self: VCF) i32 {
return hts.header_n_samples(self.header.c);
}
// a zig iterator over variants in the file.
pub fn next(self: VCF) ?Variant {
if (hts.bcf_read(self.hts, self.header.c, self.variant_c) == -1) {
return null;
}
_ = hts.bcf_unpack(self.variant_c, 3);
return Variant{ .c = self.variant_c.?, .vcf = self };
}
pub fn query(self: *VCF, chrom: []const u8, start: i32, stop: i32) !RegionIterator {
if (self.idx_c == null) {
self.idx_c = hts.hts_idx_load(&(self.fname[0]), hts.HTS_FMT_CSI);
if (self.idx_c == null) {
try stderr.print("[hts-zig/vcf] index not found for {any}\n", .{self.fname});
return HTSError.NotFound;
}
}
const isVCF = hts.is_vcf(self.hts);
if (self.tbx_c == null and isVCF) {
self.tbx_c = hts.tbx_index_load(&(self.fname[0]));
}
const tid = hts.bcf_hdr_name2id(self.header.c, &chrom[0]);
if (tid == -1) {
try stderr.print("[hts-zig/vcf] region {s} not found not found for {s}\n", .{ chrom, self.fname });
return HTSError.NotFound;
}
const iter = if (isVCF) hts.hts_itr_query(self.idx_c, tid, start, stop, hts.tbx_readrec) else hts.hts_itr_query(self.idx_c, tid, start, stop, hts.bcf_readrec);
if (iter == null) {
try stderr.print("[hts-zig/vcf] region {s}:{any}-{any} not found not found for {s}\n", .{ chrom, start + 1, stop, self.fname });
return HTSError.NotFound;
}
return RegionIterator{ .tbx_c = self.tbx_c, .itr = iter.?, .variant = Variant{ .c = self.variant_c.?, .vcf = self.* }, .s = hts.kstring_t{ .s = null, .m = 0, .l = 0 } };
}
/// set the extracted samples, use null to ignore samples.
pub fn set_samples(self: VCF, samples: []const []const u8, allocator: *std.mem.Allocator) !void {
if (samples.len == 0) {
_ = hts.bcf_hdr_set_samples(self.header.c, null, 0);
try self.header.sync();
return;
}
const sample_str = try std.mem.joinZ(allocator, ",", samples);
defer allocator.free(sample_str);
var ret = hts.bcf_hdr_set_samples(self.header.c, &sample_str[0], 0);
if (ret < 0) {
try stderr.print("[hts-zig/vcf] error in vcf.set_samples: {d}", .{ret});
}
try self.header.sync();
}
/// call this to cleanup memory used by the underlying C
pub fn deinit(self: *VCF) void {
if (self.header.c != null) {
hts.bcf_hdr_destroy(self.header.c.?);
self.header.c = null;
}
if (self.variant_c != null) {
hts.bcf_destroy(self.variant_c.?);
self.variant_c = null;
}
if (self.hts != null and !std.mem.eql(u8, self.fname, "-") and !std.mem.eql(u8, self.fname, "/dev/stdin")) {
_ = hts.hts_close(self.hts);
self.hts = null;
}
if (self.idx_c != null) {
_ = hts.hts_idx_destroy(self.idx_c);
self.idx_c = null;
}
if (self.tbx_c != null) {
_ = hts.tbx_destroy(self.tbx_c);
self.tbx_c = null;
}
if (self.c_void_ptr != null) {
hts.free(self.c_void_ptr);
self.c_void_ptr = null;
}
}
};
pub const RegionIterator = struct {
itr: *hts.hts_itr_t,
variant: Variant,
tbx_c: ?*hts.tbx_t, // if this is is present, it's a vcf
s: hts.kstring_t,
pub fn next(self: *RegionIterator) ?Variant {
var ret: c_int = 0;
if (self.tbx_c != null) {
ret = hts.hts_itr_next(hts.fp_bgzf(self.variant.vcf.hts.?), self.itr, &self.s, self.tbx_c);
if (ret > 0) {
ret = hts.vcf_parse(&self.s, self.variant.vcf.header.c, self.variant.c);
}
} else {
ret = hts.hts_itr_next(hts.fp_bgzf(self.variant.vcf.hts.?), self.itr, self.variant.c, self.tbx_c);
}
const c = hts.variant_errcode(self.variant.c);
if (c != 0) {
stderr.print("[hts/vcf] bcf read error: {d}\n", .{c}) catch {};
}
if (ret < 0) {
hts.hts_itr_destroy(self.itr);
hts.free(self.s.s);
return null;
}
_ = hts.bcf_unpack(self.variant.c, 3);
if (self.tbx_c != null) {
if (hts.bcf_subset_format(self.variant.vcf.header.c, self.variant.c) != 0) {
stderr.writeAll("[hts-zig/vcf] error with bcf_subset_format\n") catch {};
return null;
}
}
return self.variant;
}
// it's not necessary to call this unless iteration is stopped early.
pub fn deinit(self: RegionIterator) void {
_ = hts.hts_itr_destroy(self.itr);
hts.free(self.s.s);
}
}; | zig-hts-zig/src/vcf.zig |
const c = @import("c.zig").c;
// -*- Solarized Light/Dark -*-
// http://www.zovirl.com/2011/07/22/solarized_cheat_sheet/
pub const base03 = c.ImVec4{ .x = 0.00, .y = 0.17, .z = 0.21, .w = 1.00 };
pub const base02 = c.ImVec4{ .x = 0.03, .y = 0.21, .z = 0.26, .w = 1.00 };
pub const base01 = c.ImVec4{ .x = 0.35, .y = 0.43, .z = 0.46, .w = 1.00 };
pub const base00 = c.ImVec4{ .x = 0.40, .y = 0.48, .z = 0.51, .w = 1.00 };
pub const base0 = c.ImVec4{ .x = 0.51, .y = 0.58, .z = 0.59, .w = 1.00 };
pub const base1 = c.ImVec4{ .x = 0.58, .y = 0.63, .z = 0.63, .w = 1.00 };
pub const base2 = c.ImVec4{ .x = 0.93, .y = 0.91, .z = 0.84, .w = 1.00 };
pub const base3 = c.ImVec4{ .x = 0.99, .y = 0.96, .z = 0.89, .w = 1.00 };
pub const yellow = c.ImVec4{ .x = 0.71, .y = 0.54, .z = 0.00, .w = 1.00 };
pub const orange = c.ImVec4{ .x = 0.80, .y = 0.29, .z = 0.09, .w = 1.00 };
pub const red = c.ImVec4{ .x = 0.86, .y = 0.20, .z = 0.18, .w = 1.00 };
pub const magenta = c.ImVec4{ .x = 0.83, .y = 0.21, .z = 0.51, .w = 1.00 };
pub const violet = c.ImVec4{ .x = 0.42, .y = 0.44, .z = 0.77, .w = 1.00 };
pub const blue = c.ImVec4{ .x = 0.15, .y = 0.55, .z = 0.82, .w = 1.00 };
pub const cyan = c.ImVec4{ .x = 0.16, .y = 0.63, .z = 0.60, .w = 1.00 };
pub const green = c.ImVec4{ .x = 0.52, .y = 0.60, .z = 0.00, .w = 1.00 };
pub fn setImguiTheme(cl: *[c.ImGuiCol_COUNT]c.ImVec4) void {
// light:
// base 01 - emphasized content
// base 00 - body text / primary content
// base 1 - comments / secondary content
// base 2 - background highlights
// base 3 - background
cl[c.ImGuiCol_Text] = base00;
cl[c.ImGuiCol_TextDisabled] = base1;
cl[c.ImGuiCol_WindowBg] = base3;
cl[c.ImGuiCol_ChildBg] = base3;
cl[c.ImGuiCol_PopupBg] = base3;
cl[c.ImGuiCol_Border] = base2;
cl[c.ImGuiCol_BorderShadow] = c.ImVec4{ .x = 0.00, .y = 0.00, .z = 0.00, .w = 0.00 };
cl[c.ImGuiCol_FrameBg] = base3;
cl[c.ImGuiCol_FrameBgHovered] = base3;
cl[c.ImGuiCol_FrameBgActive] = base3;
cl[c.ImGuiCol_TitleBg] = base2;
cl[c.ImGuiCol_TitleBgActive] = base2;
cl[c.ImGuiCol_TitleBgCollapsed] = base3;
cl[c.ImGuiCol_MenuBarBg] = base2;
cl[c.ImGuiCol_ScrollbarBg] = c.ImVec4{ .x = 0.98, .y = 0.98, .z = 0.98, .w = 0.53 };
cl[c.ImGuiCol_ScrollbarGrab] = c.ImVec4{ .x = 0.69, .y = 0.69, .z = 0.69, .w = 0.80 };
cl[c.ImGuiCol_ScrollbarGrabHovered] = c.ImVec4{ .x = 0.49, .y = 0.49, .z = 0.49, .w = 0.80 };
cl[c.ImGuiCol_ScrollbarGrabActive] = c.ImVec4{ .x = 0.49, .y = 0.49, .z = 0.49, .w = 1.00 };
cl[c.ImGuiCol_CheckMark] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 1.00 };
cl[c.ImGuiCol_SliderGrab] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.78 };
cl[c.ImGuiCol_SliderGrabActive] = c.ImVec4{ .x = 0.46, .y = 0.54, .z = 0.80, .w = 0.60 };
cl[c.ImGuiCol_Button] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.40 };
cl[c.ImGuiCol_ButtonHovered] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 1.00 };
cl[c.ImGuiCol_ButtonActive] = c.ImVec4{ .x = 0.06, .y = 0.53, .z = 0.98, .w = 1.00 };
cl[c.ImGuiCol_Header] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.31 };
cl[c.ImGuiCol_HeaderHovered] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.80 };
cl[c.ImGuiCol_HeaderActive] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 1.00 };
cl[c.ImGuiCol_Separator] = c.ImVec4{ .x = 0.39, .y = 0.39, .z = 0.39, .w = 0.62 };
cl[c.ImGuiCol_SeparatorHovered] = c.ImVec4{ .x = 0.14, .y = 0.44, .z = 0.80, .w = 0.78 };
cl[c.ImGuiCol_SeparatorActive] = c.ImVec4{ .x = 0.14, .y = 0.44, .z = 0.80, .w = 1.00 };
cl[c.ImGuiCol_ResizeGrip] = c.ImVec4{ .x = 0.35, .y = 0.35, .z = 0.35, .w = 0.17 };
cl[c.ImGuiCol_ResizeGripHovered] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.67 };
cl[c.ImGuiCol_ResizeGripActive] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.95 };
cl[c.ImGuiCol_Tab] = c.ImVec4{ .x = 0.76, .y = 0.80, .z = 0.84, .w = 0.93 };
cl[c.ImGuiCol_TabHovered] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.80 };
cl[c.ImGuiCol_TabActive] = c.ImVec4{ .x = 0.60, .y = 0.73, .z = 0.88, .w = 1.00 };
cl[c.ImGuiCol_TabUnfocused] = c.ImVec4{ .x = 0.92, .y = 0.93, .z = 0.94, .w = 0.99 };
cl[c.ImGuiCol_TabUnfocusedActive] = c.ImVec4{ .x = 0.74, .y = 0.82, .z = 0.91, .w = 1.00 };
cl[c.ImGuiCol_PlotLines] = c.ImVec4{ .x = 0.39, .y = 0.39, .z = 0.39, .w = 1.00 };
cl[c.ImGuiCol_PlotLinesHovered] = c.ImVec4{ .x = 1.00, .y = 0.43, .z = 0.35, .w = 1.00 };
cl[c.ImGuiCol_PlotHistogram] = c.ImVec4{ .x = 0.90, .y = 0.70, .z = 0.00, .w = 1.00 };
cl[c.ImGuiCol_PlotHistogramHovered] = c.ImVec4{ .x = 1.00, .y = 0.45, .z = 0.00, .w = 1.00 };
cl[c.ImGuiCol_TableHeaderBg] = c.ImVec4{ .x = 0.78, .y = 0.87, .z = 0.98, .w = 1.00 };
cl[c.ImGuiCol_TableBorderStrong] = c.ImVec4{ .x = 0.57, .y = 0.57, .z = 0.64, .w = 1.00 };
cl[c.ImGuiCol_TableBorderLight] = c.ImVec4{ .x = 0.68, .y = 0.68, .z = 0.74, .w = 1.00 };
cl[c.ImGuiCol_TableRowBg] = c.ImVec4{ .x = 0.00, .y = 0.00, .z = 0.00, .w = 0.00 };
cl[c.ImGuiCol_TableRowBgAlt] = c.ImVec4{ .x = 0.30, .y = 0.30, .z = 0.30, .w = 0.09 };
cl[c.ImGuiCol_TextSelectedBg] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.35 };
cl[c.ImGuiCol_DragDropTarget] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.95 };
cl[c.ImGuiCol_NavHighlight] = c.ImVec4{ .x = 0.26, .y = 0.59, .z = 0.98, .w = 0.80 };
cl[c.ImGuiCol_NavWindowingHighlight] = c.ImVec4{ .x = 0.70, .y = 0.70, .z = 0.70, .w = 0.70 };
cl[c.ImGuiCol_NavWindowingDimBg] = c.ImVec4{ .x = 0.20, .y = 0.20, .z = 0.20, .w = 0.20 };
cl[c.ImGuiCol_ModalWindowDimBg] = c.ImVec4{ .x = 0.20, .y = 0.20, .z = 0.20, .w = 0.35 };
} | src/theme.zig |
const std = @import("std");
pub const Error = error{ FailedtoAllocate, IsNotUnique, InvalidID, DataOverflow };
pub fn UniqueList(comptime generic_type: type) type {
return struct {
pub const T = generic_type;
const Self = @This();
pub const Item = struct {
data: ?T = null,
id: u64 = 0,
};
/// Iterator
pub const Iterator = struct {
parent: *const Self = undefined,
index: usize = undefined,
pub fn next(it: *Iterator) ?*Item {
if (it.index >= it.parent.items.len) return null;
const result = &it.parent.items[it.index];
it.index += 1;
return result;
}
/// Reset the iterator
pub fn reset(it: *Iterator) void {
it.index = 0;
}
};
alloc: *std.mem.Allocator = undefined,
items: []Item = undefined,
/// Initializes the UniqueList
pub fn init(alloc: *std.mem.Allocator, reserve: usize) Error!Self {
var self = Self{
.alloc = alloc,
};
self.items = self.alloc.alloc(Item, if (reserve == 0) 1 else reserve) catch return Error.FailedtoAllocate;
self.clear();
return self;
}
/// Deinitializes the UniqueList
pub fn deinit(self: Self) void {
self.alloc.free(self.items);
}
/// Clears the list
pub fn clear(self: *Self) void {
for (self.items) |*item| {
item.* = Item{.data = null, .id = 0};
}
}
/// Reserves memory
pub fn reserveSlots(self: *Self, reserve: usize) Error!void {
const temp = self.items;
self.items = self.alloc.alloc(Item, temp.len + reserve) catch return Error.FailedtoAllocate;
for (self.items) |*item, i| {
if (i < temp.len) {
item.* = temp[i];
}
else item.* = Item{.data = null, .id = 0};
}
self.alloc.free(temp);
}
/// Returns the end of the list
pub fn end(self: Self) usize {
return self.items.len;
}
/// Is the given id unique?
pub fn isUnique(self: Self, id: u64) bool {
for (self.items) |item| {
if (item.data != null and item.id == id) return false;
}
return true;
}
/// Returns an unique id
pub fn findUnique(self: Self) u64 {
var i: u64 = 0;
while (i < self.items.len + 1) : (i += 1) {
if (self.isUnique(i)) return i;
}
@panic("Probably integer overflow and how tf did you end up here anyways?");
}
/// Is the given item slot empty?
pub fn isEmpty(self: Self, index: u64) bool {
if (self.items[index].data != null) return false;
return true;
}
/// Inserts an item with given id and index
/// Can(& will) overwrite into existing index if id is unique
pub fn insertAt(self: *Self, id: u64, index: usize, data: T) Error!void {
if (!self.isUnique(id)) return Error.IsNotUnique;
self.items[index].data = data;
self.items[index].id = id;
}
/// Appends an item with given id
/// into appropriate item slot
pub fn append(self: *Self, id: u64, data: T) Error!void {
var i: usize = 0;
while (i < self.items.len) : (i += 1) {
if (self.isEmpty(i)) return self.insertAt(id, i, data);
}
try self.reserveSlots(2);
return self.insertAt(id, self.end() - 1, data);
}
/// Removes the item with given id
pub fn remove(self: *Self, id: u64) bool {
for (self.items) |*item| {
if (item.data != null and item.id == id) {
item.data = null;
item.id = undefined;
return true;
}
}
return false;
}
/// Returns the data with given id
pub fn get(self: Self, id: u64) Error!T {
for (self.items) |item| {
if (item.data != null and item.id == id) return item.data.?;
}
return Error.InvalidID;
}
/// Returns the ptr to the data with given id
pub fn getPtr(self: *Self, id: u64) Error!*T {
for (self.items) |*item| {
if (item.data != null and item.id == id) return &item.data.?;
}
return Error.InvalidID;
}
/// Returns the iterator
pub fn iterator(self: *const Self) Iterator {
return Iterator{
.parent = self,
.index = 0,
};
}
};
}
pub fn UniqueFixedList(comptime generic_type: type, comptime generic_max: usize) type {
return struct {
pub const T = generic_type;
pub const Tmax = generic_max;
const Self = @This();
pub const Item = struct {
data: ?T = null,
id: u64 = 0,
};
/// Iterator
pub const Iterator = struct {
parent: *const Self = undefined,
index: usize = undefined,
pub fn next(it: *Iterator) ?*Item {
if (it.index >= it.parent.items.len) return null;
const result = &it.parent.items[it.index];
it.index += 1;
return result;
}
/// Reset the iterator
pub fn reset(it: *Iterator) void {
it.index = 0;
}
};
items: [Tmax]Item = undefined,
/// Initializes the UniqueList
pub fn init() Self {
var self = Self{};
self.clear();
return self;
}
/// Clears the list
pub fn clear(self: *Self) void {
for (self.items) |*item| {
item.* = Item{.data = null, .id = 0};
}
}
/// Returns the end of the list
pub fn end(self: Self) usize {
return self.items.len;
}
/// Is the given id unique?
pub fn isUnique(self: Self, id: u64) bool {
for (self.items) |item| {
if (item.data != null and item.id == id) return false;
}
return true;
}
/// Returns an unique id
pub fn findUnique(self: Self) u64 {
var i: u64 = 0;
while (i < self.items.len + 1) : (i += 1) {
if (self.isUnique(i)) return i;
}
@panic("Probably integer overflow and how tf did you end up here anyways?");
}
/// Is the given item slot empty?
pub fn isEmpty(self: Self, index: u64) bool {
if (self.items[index].data != null) return false;
return true;
}
/// Inserts an item with given id and index
/// Can(& will) overwrite into existing index if id is unique
pub fn insertAt(self: *Self, id: u64, index: usize, data: T) Error!void {
if (!self.isUnique(id)) return Error.IsNotUnique;
self.items[index].data = data;
self.items[index].id = id;
}
/// Appends an item with given id
/// into appropriate item slot
pub fn append(self: *Self, id: u64, data: T) Error!void {
var i: usize = 0;
while (i < self.items.len) : (i += 1) {
if (self.isEmpty(i)) return self.insertAt(id, i, data);
}
return Error.DataOverflow;
}
/// Removes the item with given id
pub fn remove(self: *Self, id: u64) bool {
for (self.items) |*item| {
if (item.data != null and item.id == id) {
item.data = null;
item.id = undefined;
return true;
}
}
return false;
}
/// Returns the data with given id
pub fn get(self: Self, id: u64) Error!T {
for (self.items) |item| {
if (item.data != null and item.id == id) return item.data.?;
}
return Error.InvalidID;
}
/// Returns the ptr to the data with given id
pub fn getPtr(self: *Self, id: u64) Error!*T {
for (self.items) |*item| {
if (item.data != null and item.id == id) return &item.data.?;
}
return Error.InvalidID;
}
/// Returns the iterator
pub fn iterator(self: *const Self) Iterator {
return Iterator{
.parent = self,
.index = 0,
};
}
};
} | src/core/utils.zig |
const std = @import("std");
const math = std.math;
const assert = std.debug.assert;
const glfw = @import("glfw");
const gpu = @import("gpu");
const c = @cImport({
@cInclude("dawn/dawn_proc.h");
@cInclude("dawn_native_mach.h");
});
const objc = @cImport({
@cInclude("objc/message.h");
});
pub const cimgui = @cImport({
@cDefine("CIMGUI_DEFINE_ENUMS_AND_STRUCTS", "");
@cDefine("CIMGUI_NO_EXPORT", "");
@cInclude("imgui/cimgui.h");
});
const wgsl = @import("common_wgsl.zig");
pub const GraphicsContext = struct {
native_instance: gpu.NativeInstance,
adapter_type: gpu.Adapter.Type,
backend_type: gpu.Adapter.BackendType,
device: gpu.Device,
queue: gpu.Queue,
window: glfw.Window,
window_surface: gpu.Surface,
swapchain: gpu.SwapChain,
swapchain_descriptor: gpu.SwapChain.Descriptor,
stats: FrameStats = .{},
buffer_pool: BufferPool,
texture_pool: TexturePool,
texture_view_pool: TextureViewPool,
sampler_pool: SamplerPool,
render_pipeline_pool: RenderPipelinePool,
compute_pipeline_pool: ComputePipelinePool,
bind_group_pool: BindGroupPool,
bind_group_layout_pool: BindGroupLayoutPool,
pipeline_layout_pool: PipelineLayoutPool,
uniforms: struct {
offset: u32 = 0,
buffer: BufferHandle = .{},
stage: struct {
num: u32 = 0,
current: u32 = 0,
buffers: [uniforms_staging_pipeline_len]UniformsStagingBuffer =
[_]UniformsStagingBuffer{.{}} ** uniforms_staging_pipeline_len,
} = .{},
} = .{},
mipgens: std.AutoHashMap(gpu.Texture.Format, MipgenResources),
pub const swapchain_format = gpu.Texture.Format.bgra8_unorm;
// TODO: Adjust pool sizes.
const buffer_pool_size = 256;
const texture_pool_size = 256;
const texture_view_pool_size = 256;
const sampler_pool_size = 16;
const render_pipeline_pool_size = 128;
const compute_pipeline_pool_size = 128;
const bind_group_pool_size = 32;
const bind_group_layout_pool_size = 32;
const pipeline_layout_pool_size = 32;
pub fn init(allocator: std.mem.Allocator, window: glfw.Window) !*GraphicsContext {
c.dawnProcSetProcs(c.machDawnNativeGetProcs());
const instance = c.machDawnNativeInstance_init();
c.machDawnNativeInstance_discoverDefaultAdapters(instance);
var native_instance = gpu.NativeInstance.wrap(c.machDawnNativeInstance_get(instance).?);
const gpu_interface = native_instance.interface();
const backend_adapter = switch (gpu_interface.waitForAdapter(&.{
.power_preference = .high_performance,
})) {
.adapter => |v| v,
.err => |err| {
std.debug.print("[zgpu] Failed to get adapter: error={} {s}\n", .{ err.code, err.message });
return error.NoGraphicsAdapter;
},
};
const props = backend_adapter.properties;
std.debug.print("[zgpu] High-performance device has been selected:\n", .{});
std.debug.print("[zgpu] Name: {s}\n", .{props.name});
std.debug.print("[zgpu] Driver: {s}\n", .{props.driver_description});
std.debug.print("[zgpu] Adapter type: {s}\n", .{gpu.Adapter.typeName(props.adapter_type)});
std.debug.print("[zgpu] Backend type: {s}\n", .{gpu.Adapter.backendTypeName(props.backend_type)});
const device = switch (backend_adapter.waitForDevice(&.{})) {
.device => |v| v,
.err => |err| {
std.debug.print("[zgpu] Failed to get device: error={} {s}\n", .{ err.code, err.message });
return error.NoGraphicsDevice;
},
};
device.setUncapturedErrorCallback(&printUnhandledErrorCallback);
const window_surface = createSurfaceForWindow(
&native_instance,
window,
comptime detectGLFWOptions(),
);
const framebuffer_size = window.getFramebufferSize() catch unreachable;
const swapchain_descriptor = gpu.SwapChain.Descriptor{
.label = "main window swap chain",
.usage = .{ .render_attachment = true },
.format = swapchain_format,
.width = framebuffer_size.width,
.height = framebuffer_size.height,
.present_mode = .fifo,
.implementation = 0,
};
const swapchain = device.nativeCreateSwapChain(
window_surface,
&swapchain_descriptor,
);
const gctx = allocator.create(GraphicsContext) catch unreachable;
gctx.* = .{
.native_instance = native_instance,
.adapter_type = props.adapter_type,
.backend_type = props.backend_type,
.device = device,
.queue = device.getQueue(),
.window = window,
.window_surface = window_surface,
.swapchain = swapchain,
.swapchain_descriptor = swapchain_descriptor,
.buffer_pool = BufferPool.init(allocator, buffer_pool_size),
.texture_pool = TexturePool.init(allocator, texture_pool_size),
.texture_view_pool = TextureViewPool.init(allocator, texture_view_pool_size),
.sampler_pool = SamplerPool.init(allocator, sampler_pool_size),
.render_pipeline_pool = RenderPipelinePool.init(allocator, render_pipeline_pool_size),
.compute_pipeline_pool = ComputePipelinePool.init(allocator, compute_pipeline_pool_size),
.bind_group_pool = BindGroupPool.init(allocator, bind_group_pool_size),
.bind_group_layout_pool = BindGroupLayoutPool.init(allocator, bind_group_layout_pool_size),
.pipeline_layout_pool = PipelineLayoutPool.init(allocator, pipeline_layout_pool_size),
.mipgens = std.AutoHashMap(gpu.Texture.Format, MipgenResources).init(allocator),
};
gctx.queue.on_submitted_work_done = gpu.Queue.WorkDoneCallback.init(
*u64,
&gctx.stats.gpu_frame_number,
gpuWorkDone,
);
uniformsInit(gctx);
return gctx;
}
pub fn deinit(gctx: *GraphicsContext, allocator: std.mem.Allocator) void {
// TODO: How to release `native_instance`?
// Wait for the GPU to finish all encoded commands.
while (gctx.stats.cpu_frame_number != gctx.stats.gpu_frame_number) {
gctx.device.tick();
}
// Wait for all outstanding mapAsync() calls to complete.
wait_loop: while (true) {
gctx.device.tick();
var i: u32 = 0;
while (i < gctx.uniforms.stage.num) : (i += 1) {
if (gctx.uniforms.stage.buffers[i].slice == null) {
continue :wait_loop;
}
}
break;
}
gctx.mipgens.deinit();
gctx.pipeline_layout_pool.deinit(allocator);
gctx.bind_group_pool.deinit(allocator);
gctx.bind_group_layout_pool.deinit(allocator);
gctx.buffer_pool.deinit(allocator);
gctx.texture_view_pool.deinit(allocator);
gctx.texture_pool.deinit(allocator);
gctx.sampler_pool.deinit(allocator);
gctx.render_pipeline_pool.deinit(allocator);
gctx.compute_pipeline_pool.deinit(allocator);
gctx.window_surface.release();
gctx.swapchain.release();
gctx.queue.release();
gctx.device.release();
allocator.destroy(gctx);
}
//
// Uniform buffer pool
//
pub fn uniformsAllocate(
gctx: *GraphicsContext,
comptime T: type,
num_elements: u32,
) struct { slice: []T, offset: u32 } {
assert(num_elements > 0);
const size = num_elements * @sizeOf(T);
const offset = gctx.uniforms.offset;
const aligned_size = (size + (uniforms_alloc_alignment - 1)) & ~(uniforms_alloc_alignment - 1);
if ((offset + aligned_size) >= uniforms_buffer_size) {
// TODO: Better error handling; pool is full; flush it?
return .{ .slice = @as([*]T, undefined)[0..0], .offset = 0 };
}
const current = gctx.uniforms.stage.current;
const slice = (gctx.uniforms.stage.buffers[current].slice.?.ptr + offset)[0..size];
gctx.uniforms.offset += aligned_size;
return .{
.slice = std.mem.bytesAsSlice(T, @alignCast(@alignOf(T), slice)),
.offset = offset,
};
}
const UniformsStagingBuffer = struct {
slice: ?[]u8 = null,
buffer: gpu.Buffer = undefined,
callback: gpu.Buffer.MapCallback = undefined,
};
const uniforms_buffer_size = 4 * 1024 * 1024;
const uniforms_staging_pipeline_len = 8;
const uniforms_alloc_alignment: u32 = 256;
fn uniformsInit(gctx: *GraphicsContext) void {
gctx.uniforms.buffer = gctx.createBuffer(.{
.usage = .{ .copy_dst = true, .uniform = true },
.size = uniforms_buffer_size,
});
gctx.uniformsNextStagingBuffer();
}
fn uniformsMappedCallback(usb: *UniformsStagingBuffer, status: gpu.Buffer.MapAsyncStatus) void {
assert(usb.slice == null);
if (status == .success) {
usb.slice = usb.buffer.getMappedRange(u8, 0, uniforms_buffer_size);
} else {
std.debug.print("[zgpu] Failed to map buffer (code: {d})\n", .{@enumToInt(status)});
}
}
fn uniformsNextStagingBuffer(gctx: *GraphicsContext) void {
if (gctx.stats.cpu_frame_number > 0) {
// Map staging buffer which was used this frame.
const current = gctx.uniforms.stage.current;
assert(gctx.uniforms.stage.buffers[current].slice == null);
gctx.uniforms.stage.buffers[current].buffer.mapAsync(
.write,
0,
uniforms_buffer_size,
&gctx.uniforms.stage.buffers[current].callback,
);
}
gctx.uniforms.offset = 0;
var i: u32 = 0;
while (i < gctx.uniforms.stage.num) : (i += 1) {
if (gctx.uniforms.stage.buffers[i].slice != null) {
gctx.uniforms.stage.current = i;
return;
}
}
if (gctx.uniforms.stage.num >= uniforms_staging_pipeline_len) {
// Wait until one of the buffers is mapped and ready to use.
while (true) {
gctx.device.tick();
i = 0;
while (i < gctx.uniforms.stage.num) : (i += 1) {
if (gctx.uniforms.stage.buffers[i].slice != null) {
gctx.uniforms.stage.current = i;
return;
}
}
}
}
assert(gctx.uniforms.stage.num < uniforms_staging_pipeline_len);
const current = gctx.uniforms.stage.num;
gctx.uniforms.stage.current = current;
gctx.uniforms.stage.num += 1;
// Create new staging buffer.
const buffer_handle = gctx.createBuffer(.{
.usage = .{ .copy_src = true, .map_write = true },
.size = uniforms_buffer_size,
.mapped_at_creation = true,
});
// Add new (mapped) staging buffer to the buffer list.
gctx.uniforms.stage.buffers[current] = .{
.slice = gctx.lookupResource(buffer_handle).?.getMappedRange(u8, 0, uniforms_buffer_size),
.buffer = gctx.lookupResource(buffer_handle).?,
.callback = gpu.Buffer.MapCallback.init(
*UniformsStagingBuffer,
&gctx.uniforms.stage.buffers[current],
uniformsMappedCallback,
),
};
}
//
// Submit/Present
//
pub fn submit(gctx: *GraphicsContext, commands: []const gpu.CommandBuffer) void {
const stage_commands = stage_commands: {
const stage_encoder = gctx.device.createCommandEncoder(null);
defer stage_encoder.release();
const current = gctx.uniforms.stage.current;
assert(gctx.uniforms.stage.buffers[current].slice != null);
gctx.uniforms.stage.buffers[current].slice = null;
gctx.uniforms.stage.buffers[current].buffer.unmap();
if (gctx.uniforms.offset > 0) {
stage_encoder.copyBufferToBuffer(
gctx.uniforms.stage.buffers[current].buffer,
0,
gctx.lookupResource(gctx.uniforms.buffer).?,
0,
gctx.uniforms.offset,
);
}
break :stage_commands stage_encoder.finish(null);
};
defer stage_commands.release();
// TODO: We support up to 32 command buffers for now. Make it more robust.
var command_buffers = std.BoundedArray(gpu.CommandBuffer, 32).init(0) catch unreachable;
command_buffers.append(stage_commands) catch unreachable;
command_buffers.appendSlice(commands) catch unreachable;
gctx.queue.submit(command_buffers.slice());
gctx.stats.tick();
gctx.uniformsNextStagingBuffer();
}
fn gpuWorkDone(gpu_frame_number: *u64, status: gpu.Queue.WorkDoneStatus) void {
gpu_frame_number.* += 1;
if (status != .success) {
std.debug.print("[zgpu] Failed to complete GPU work (code: {d})\n", .{@enumToInt(status)});
}
}
pub fn present(gctx: *GraphicsContext) enum {
normal_execution,
swap_chain_resized,
} {
gctx.swapchain.present();
const fb_size = gctx.window.getFramebufferSize() catch unreachable;
if (gctx.swapchain_descriptor.width != fb_size.width or
gctx.swapchain_descriptor.height != fb_size.height)
{
gctx.swapchain_descriptor.width = fb_size.width;
gctx.swapchain_descriptor.height = fb_size.height;
gctx.swapchain.release();
gctx.swapchain = gctx.device.nativeCreateSwapChain(
gctx.window_surface,
&gctx.swapchain_descriptor,
);
std.debug.print(
"[zgpu] Window has been resized to: {d}x{d}\n",
.{ gctx.swapchain_descriptor.width, gctx.swapchain_descriptor.height },
);
return .swap_chain_resized;
}
return .normal_execution;
}
//
// Resources
//
pub fn createBuffer(gctx: *GraphicsContext, descriptor: gpu.Buffer.Descriptor) BufferHandle {
return gctx.buffer_pool.addResource(gctx.*, .{
.gpuobj = gctx.device.createBuffer(&descriptor),
.size = descriptor.size,
.usage = descriptor.usage,
});
}
pub fn createTexture(gctx: *GraphicsContext, descriptor: gpu.Texture.Descriptor) TextureHandle {
return gctx.texture_pool.addResource(gctx.*, .{
.gpuobj = gctx.device.createTexture(&descriptor),
.usage = descriptor.usage,
.dimension = descriptor.dimension,
.size = descriptor.size,
.format = descriptor.format,
.mip_level_count = descriptor.mip_level_count,
.sample_count = descriptor.sample_count,
});
}
pub fn createTextureView(
gctx: *GraphicsContext,
texture_handle: TextureHandle,
descriptor: gpu.TextureView.Descriptor,
) TextureViewHandle {
const texture = gctx.lookupResource(texture_handle).?;
const info = gctx.lookupResourceInfo(texture_handle).?;
return gctx.texture_view_pool.addResource(gctx.*, .{
.gpuobj = texture.createView(&descriptor),
.format = if (descriptor.format == .none) info.format else descriptor.format,
.dimension = if (descriptor.dimension == .dimension_none)
@intToEnum(gpu.TextureView.Dimension, @enumToInt(info.dimension))
else
descriptor.dimension,
.base_mip_level = descriptor.base_mip_level,
.mip_level_count = if (descriptor.mip_level_count == 0xffff_ffff)
info.mip_level_count
else
descriptor.mip_level_count,
.base_array_layer = descriptor.base_array_layer,
.array_layer_count = if (descriptor.array_layer_count == 0xffff_ffff)
info.size.depth_or_array_layers
else
descriptor.array_layer_count,
.aspect = descriptor.aspect,
.parent_texture_handle = texture_handle,
});
}
pub fn createSampler(gctx: *GraphicsContext, descriptor: gpu.Sampler.Descriptor) SamplerHandle {
return gctx.sampler_pool.addResource(gctx.*, .{
.gpuobj = gctx.device.createSampler(&descriptor),
.address_mode_u = descriptor.address_mode_u,
.address_mode_v = descriptor.address_mode_v,
.address_mode_w = descriptor.address_mode_w,
.mag_filter = descriptor.mag_filter,
.min_filter = descriptor.min_filter,
.mipmap_filter = descriptor.mipmap_filter,
.lod_min_clamp = descriptor.lod_min_clamp,
.lod_max_clamp = descriptor.lod_max_clamp,
.compare = descriptor.compare,
.max_anisotropy = descriptor.max_anisotropy,
});
}
pub fn createRenderPipeline(
gctx: *GraphicsContext,
pipeline_layout: PipelineLayoutHandle,
descriptor: gpu.RenderPipeline.Descriptor,
) RenderPipelineHandle {
var desc = descriptor;
desc.layout = gctx.lookupResource(pipeline_layout) orelse null;
return gctx.render_pipeline_pool.addResource(gctx.*, .{
.gpuobj = gctx.device.createRenderPipeline(&desc),
.pipeline_layout_handle = pipeline_layout,
});
}
const AsyncCreateOpRender = struct {
gctx: *GraphicsContext,
result: *RenderPipelineHandle,
pipeline_layout: PipelineLayoutHandle,
callback: gpu.RenderPipeline.CreateCallback,
allocator: std.mem.Allocator,
fn create(
op: *AsyncCreateOpRender,
status: gpu.RenderPipeline.CreateStatus,
pipeline: gpu.RenderPipeline,
message: [:0]const u8,
) void {
if (status == .success) {
op.result.* = op.gctx.render_pipeline_pool.addResource(
op.gctx.*,
.{ .gpuobj = pipeline, .pipeline_layout_handle = op.pipeline_layout },
);
} else {
std.debug.print(
"[zgpu] Failed to async create render pipeline (code: {d})\n{s}\n",
.{ status, message },
);
}
op.allocator.destroy(op);
}
};
pub fn createRenderPipelineAsync(
gctx: *GraphicsContext,
allocator: std.mem.Allocator,
pipeline_layout: PipelineLayoutHandle,
descriptor: gpu.RenderPipeline.Descriptor,
result: *RenderPipelineHandle,
) void {
var desc = descriptor;
desc.layout = gctx.lookupResource(pipeline_layout) orelse null;
const op = allocator.create(AsyncCreateOpRender) catch unreachable;
op.* = .{
.gctx = gctx,
.result = result,
.pipeline_layout = pipeline_layout,
.callback = gpu.RenderPipeline.CreateCallback.init(
*AsyncCreateOpRender,
op,
AsyncCreateOpRender.create,
),
.allocator = allocator,
};
gctx.device.createRenderPipelineAsync(&desc, &op.callback);
}
pub fn createComputePipeline(
gctx: *GraphicsContext,
pipeline_layout: PipelineLayoutHandle,
descriptor: gpu.ComputePipeline.Descriptor,
) ComputePipelineHandle {
var desc = descriptor;
desc.layout = gctx.lookupResource(pipeline_layout) orelse null;
return gctx.compute_pipeline_pool.addResource(gctx.*, .{
.gpuobj = gctx.device.createComputePipeline(&desc),
.pipeline_layout_handle = pipeline_layout,
});
}
const AsyncCreateOpCompute = struct {
gctx: *GraphicsContext,
result: *ComputePipelineHandle,
pipeline_layout: PipelineLayoutHandle,
callback: gpu.ComputePipeline.CreateCallback,
allocator: std.mem.Allocator,
fn create(
op: *AsyncCreateOpCompute,
status: gpu.ComputePipeline.CreateStatus,
pipeline: gpu.ComputePipeline,
message: [:0]const u8,
) void {
if (status == .success) {
op.result.* = op.gctx.compute_pipeline_pool.addResource(
op.gctx.*,
.{ .gpuobj = pipeline, .pipeline_layout_handle = op.pipeline_layout },
);
} else {
std.debug.print(
"[zgpu] Failed to async create compute pipeline (code: {d})\n{s}\n",
.{ status, message },
);
}
op.allocator.destroy(op);
}
};
pub fn createComputePipelineAsync(
gctx: *GraphicsContext,
allocator: std.mem.Allocator,
pipeline_layout: PipelineLayoutHandle,
descriptor: gpu.ComputePipeline.Descriptor,
result: *ComputePipelineHandle,
) void {
var desc = descriptor;
desc.layout = gctx.lookupResource(pipeline_layout) orelse null;
const op = allocator.create(AsyncCreateOpCompute) catch unreachable;
op.* = .{
.gctx = gctx,
.result = result,
.pipeline_layout = pipeline_layout,
.callback = gpu.ComputePipeline.CreateCallback.init(
*AsyncCreateOpCompute,
op,
AsyncCreateOpCompute.create,
),
.allocator = allocator,
};
gctx.device.createComputePipelineAsync(&desc, &op.callback);
}
pub fn createBindGroup(
gctx: *GraphicsContext,
layout: BindGroupLayoutHandle,
entries: []const BindGroupEntryInfo,
) BindGroupHandle {
assert(entries.len > 0 and entries.len <= max_num_bindings_per_group);
var bind_group_info = BindGroupInfo{ .num_entries = @intCast(u32, entries.len) };
var gpu_bind_group_entries: [max_num_bindings_per_group]gpu.BindGroup.Entry = undefined;
for (entries) |entry, i| {
bind_group_info.entries[i] = entry;
if (entries[i].buffer_handle) |handle| {
gpu_bind_group_entries[i] = .{
.binding = entries[i].binding,
.buffer = gctx.lookupResource(handle).?,
.offset = entries[i].offset,
.size = entries[i].size,
.sampler = null,
.texture_view = null,
};
} else if (entries[i].sampler_handle) |handle| {
gpu_bind_group_entries[i] = .{
.binding = entries[i].binding,
.buffer = null,
.offset = 0,
.size = 0,
.sampler = gctx.lookupResource(handle).?,
.texture_view = null,
};
} else if (entries[i].texture_view_handle) |handle| {
gpu_bind_group_entries[i] = .{
.binding = entries[i].binding,
.buffer = null,
.offset = 0,
.size = 0,
.sampler = null,
.texture_view = gctx.lookupResource(handle).?,
};
} else unreachable;
}
bind_group_info.gpuobj = gctx.device.createBindGroup(&.{
.layout = gctx.lookupResource(layout).?,
.entries = gpu_bind_group_entries[0..entries.len],
});
return gctx.bind_group_pool.addResource(gctx.*, bind_group_info);
}
pub fn createBindGroupLayout(
gctx: *GraphicsContext,
entries: []const gpu.BindGroupLayout.Entry,
) BindGroupLayoutHandle {
assert(entries.len > 0 and entries.len <= max_num_bindings_per_group);
var bind_group_layout_info = BindGroupLayoutInfo{
.gpuobj = gctx.device.createBindGroupLayout(&.{ .entries = entries }),
.num_entries = @intCast(u32, entries.len),
};
for (entries) |entry, i| {
bind_group_layout_info.entries[i] = entry;
bind_group_layout_info.entries[i].reserved = null;
bind_group_layout_info.entries[i].buffer.reserved = null;
bind_group_layout_info.entries[i].sampler.reserved = null;
bind_group_layout_info.entries[i].texture.reserved = null;
bind_group_layout_info.entries[i].storage_texture.reserved = null;
}
return gctx.bind_group_layout_pool.addResource(gctx.*, bind_group_layout_info);
}
pub fn createBindGroupLayoutAuto(
gctx: *GraphicsContext,
pipeline: anytype,
group_index: u32,
) BindGroupLayoutHandle {
const bgl = gctx.lookupResource(pipeline).?.getBindGroupLayout(group_index);
return gctx.bind_group_layout_pool.addResource(gctx.*, BindGroupLayoutInfo{ .gpuobj = bgl });
}
pub fn createPipelineLayout(
gctx: *GraphicsContext,
bind_group_layouts: []const BindGroupLayoutHandle,
) PipelineLayoutHandle {
assert(bind_group_layouts.len > 0);
var info: PipelineLayoutInfo = .{ .num_bind_group_layouts = @intCast(u32, bind_group_layouts.len) };
var gpu_bind_group_layouts: [max_num_bind_groups_per_pipeline]gpu.BindGroupLayout = undefined;
for (bind_group_layouts) |bgl, i| {
info.bind_group_layouts[i] = bgl;
gpu_bind_group_layouts[i] = gctx.lookupResource(bgl).?;
}
info.gpuobj = gctx.device.createPipelineLayout(&gpu.PipelineLayout.Descriptor{
.bind_group_layouts = gpu_bind_group_layouts[0..info.num_bind_group_layouts],
});
return gctx.pipeline_layout_pool.addResource(gctx.*, info);
}
pub fn lookupResource(gctx: GraphicsContext, handle: anytype) ?handleToGpuResourceType(@TypeOf(handle)) {
if (gctx.isResourceValid(handle)) {
const T = @TypeOf(handle);
return switch (T) {
BufferHandle => gctx.buffer_pool.getGpuObj(handle).?,
TextureHandle => gctx.texture_pool.getGpuObj(handle).?,
TextureViewHandle => gctx.texture_view_pool.getGpuObj(handle).?,
SamplerHandle => gctx.sampler_pool.getGpuObj(handle).?,
RenderPipelineHandle => gctx.render_pipeline_pool.getGpuObj(handle).?,
ComputePipelineHandle => gctx.compute_pipeline_pool.getGpuObj(handle).?,
BindGroupHandle => gctx.bind_group_pool.getGpuObj(handle).?,
BindGroupLayoutHandle => gctx.bind_group_layout_pool.getGpuObj(handle).?,
PipelineLayoutHandle => gctx.pipeline_layout_pool.getGpuObj(handle).?,
else => @compileError(
"[zgpu] GraphicsContext.lookupResource() not implemented for " ++ @typeName(T),
),
};
}
return null;
}
pub fn lookupResourceInfo(gctx: GraphicsContext, handle: anytype) ?handleToResourceInfoType(@TypeOf(handle)) {
if (gctx.isResourceValid(handle)) {
const T = @TypeOf(handle);
return switch (T) {
BufferHandle => gctx.buffer_pool.getInfo(handle),
TextureHandle => gctx.texture_pool.getInfo(handle),
TextureViewHandle => gctx.texture_view_pool.getInfo(handle),
SamplerHandle => gctx.sampler_pool.getInfo(handle),
RenderPipelineHandle => gctx.render_pipeline_pool.getInfo(handle),
ComputePipelineHandle => gctx.compute_pipeline_pool.getInfo(handle),
BindGroupHandle => gctx.bind_group_pool.getInfo(handle),
BindGroupLayoutHandle => gctx.bind_group_layout_pool.getInfo(handle),
PipelineLayoutHandle => gctx.pipeline_layout_pool.getInfo(handle),
else => @compileError(
"[zgpu] GraphicsContext.lookupResourceInfo() not implemented for " ++ @typeName(T),
),
};
}
return null;
}
pub fn releaseResource(gctx: *GraphicsContext, handle: anytype) void {
const T = @TypeOf(handle);
switch (T) {
BufferHandle => gctx.buffer_pool.destroyResource(handle, false),
TextureHandle => gctx.texture_pool.destroyResource(handle, false),
TextureViewHandle => gctx.texture_view_pool.destroyResource(handle, false),
SamplerHandle => gctx.sampler_pool.destroyResource(handle, false),
RenderPipelineHandle => gctx.render_pipeline_pool.destroyResource(handle, false),
ComputePipelineHandle => gctx.compute_pipeline_pool.destroyResource(handle, false),
BindGroupHandle => gctx.bind_group_pool.destroyResource(handle, false),
BindGroupLayoutHandle => gctx.bind_group_layout_pool.destroyResource(handle, false),
PipelineLayoutHandle => gctx.pipeline_layout_pool.destroyResource(handle, false),
else => @compileError("[zgpu] GraphicsContext.releaseResource() not implemented for " ++ @typeName(T)),
}
}
pub fn destroyResource(gctx: *GraphicsContext, handle: anytype) void {
const T = @TypeOf(handle);
switch (T) {
BufferHandle => gctx.buffer_pool.destroyResource(handle, true),
TextureHandle => gctx.texture_pool.destroyResource(handle, true),
else => @compileError("[zgpu] GraphicsContext.destroyResource() not implemented for " ++ @typeName(T)),
}
}
pub fn isResourceValid(gctx: GraphicsContext, handle: anytype) bool {
const T = @TypeOf(handle);
switch (T) {
BufferHandle => return gctx.buffer_pool.isHandleValid(handle),
TextureHandle => return gctx.texture_pool.isHandleValid(handle),
TextureViewHandle => {
if (gctx.texture_view_pool.isHandleValid(handle)) {
const texture = gctx.texture_view_pool.getInfoPtr(handle).parent_texture_handle;
return gctx.isResourceValid(texture);
}
return false;
},
SamplerHandle => return gctx.sampler_pool.isHandleValid(handle),
RenderPipelineHandle => return gctx.render_pipeline_pool.isHandleValid(handle),
ComputePipelineHandle => return gctx.compute_pipeline_pool.isHandleValid(handle),
BindGroupHandle => {
if (gctx.bind_group_pool.isHandleValid(handle)) {
const num_entries = gctx.bind_group_pool.getInfoPtr(handle).num_entries;
const entries = &gctx.bind_group_pool.getInfoPtr(handle).entries;
var i: u32 = 0;
while (i < num_entries) : (i += 1) {
if (entries[i].buffer_handle) |buffer| {
if (!gctx.isResourceValid(buffer))
return false;
} else if (entries[i].sampler_handle) |sampler| {
if (!gctx.isResourceValid(sampler))
return false;
} else if (entries[i].texture_view_handle) |texture_view| {
if (!gctx.isResourceValid(texture_view))
return false;
} else unreachable;
}
return true;
}
return false;
},
BindGroupLayoutHandle => return gctx.bind_group_layout_pool.isHandleValid(handle),
PipelineLayoutHandle => return gctx.pipeline_layout_pool.isHandleValid(handle),
else => @compileError("[zgpu] GraphicsContext.isResourceValid() not implemented for " ++ @typeName(T)),
}
}
//
// Mipmaps
//
const MipgenResources = struct {
pipeline: ComputePipelineHandle = .{},
scratch_texture: TextureHandle = .{},
scratch_texture_views: [max_levels_per_dispatch]TextureViewHandle =
[_]TextureViewHandle{.{}} ** max_levels_per_dispatch,
bind_group_layout: BindGroupLayoutHandle = .{},
const max_levels_per_dispatch = 4;
};
pub fn generateMipmaps(
gctx: *GraphicsContext,
arena: std.mem.Allocator,
encoder: gpu.CommandEncoder,
texture: TextureHandle,
) void {
const texture_info = gctx.lookupResourceInfo(texture) orelse return;
if (texture_info.mip_level_count == 1) return;
const max_size = 2048;
assert(texture_info.usage.copy_dst == true);
assert(texture_info.dimension == .dimension_2d);
assert(texture_info.size.width <= max_size and texture_info.size.height <= max_size);
assert(texture_info.size.width == texture_info.size.height);
assert(math.isPowerOfTwo(texture_info.size.width));
const format = texture_info.format;
const entry = gctx.mipgens.getOrPut(format) catch unreachable;
const mipgen = entry.value_ptr;
if (!entry.found_existing) {
mipgen.bind_group_layout = gctx.createBindGroupLayout(&.{
bglBuffer(0, .{ .compute = true }, .uniform, true, 0),
bglTexture(1, .{ .compute = true }, .unfilterable_float, .dimension_2d, false),
bglStorageTexture(2, .{ .compute = true }, .write_only, format, .dimension_2d),
bglStorageTexture(3, .{ .compute = true }, .write_only, format, .dimension_2d),
bglStorageTexture(4, .{ .compute = true }, .write_only, format, .dimension_2d),
bglStorageTexture(5, .{ .compute = true }, .write_only, format, .dimension_2d),
});
const pipeline_layout = gctx.createPipelineLayout(&.{
mipgen.bind_group_layout,
});
defer gctx.releaseResource(pipeline_layout);
const wgsl_src = wgsl.csGenerateMipmaps(arena, formatToShaderFormat(format));
const cs_module = gctx.device.createShaderModule(&gpu.ShaderModule.Descriptor{
.code = .{ .wgsl = wgsl_src.ptr },
});
defer {
arena.free(wgsl_src);
cs_module.release();
}
mipgen.pipeline = gctx.createComputePipeline(pipeline_layout, .{
.compute = .{
.label = "zgpu_cs_generate_mipmaps",
.module = cs_module,
.entry_point = "main",
},
});
mipgen.scratch_texture = gctx.createTexture(.{
.usage = .{ .copy_src = true, .storage_binding = true },
.dimension = .dimension_2d,
.size = .{ .width = max_size / 2, .height = max_size / 2, .depth_or_array_layers = 1 },
.format = format,
.mip_level_count = MipgenResources.max_levels_per_dispatch,
.sample_count = 1,
});
for (mipgen.scratch_texture_views) |*view, i| {
view.* = gctx.createTextureView(mipgen.scratch_texture, .{
.base_mip_level = @intCast(u32, i),
.mip_level_count = 1,
.base_array_layer = 0,
.array_layer_count = 1,
});
}
}
var array_layer: u32 = 0;
while (array_layer < texture_info.size.depth_or_array_layers) : (array_layer += 1) {
const texture_view = gctx.createTextureView(texture, .{
.dimension = .dimension_2d,
.base_array_layer = array_layer,
.array_layer_count = 1,
});
defer gctx.releaseResource(texture_view);
const bind_group = gctx.createBindGroup(mipgen.bind_group_layout, &[_]BindGroupEntryInfo{
.{ .binding = 0, .buffer_handle = gctx.uniforms.buffer, .offset = 0, .size = 8 },
.{ .binding = 1, .texture_view_handle = texture_view },
.{ .binding = 2, .texture_view_handle = mipgen.scratch_texture_views[0] },
.{ .binding = 3, .texture_view_handle = mipgen.scratch_texture_views[1] },
.{ .binding = 4, .texture_view_handle = mipgen.scratch_texture_views[2] },
.{ .binding = 5, .texture_view_handle = mipgen.scratch_texture_views[3] },
});
defer gctx.releaseResource(bind_group);
const MipgenUniforms = extern struct {
src_mip_level: i32,
num_mip_levels: u32,
};
var total_num_mips: u32 = texture_info.mip_level_count - 1;
var current_src_mip_level: u32 = 0;
while (true) {
const dispatch_num_mips = math.min(MipgenResources.max_levels_per_dispatch, total_num_mips);
{
const pass = encoder.beginComputePass(null);
defer {
pass.end();
pass.release();
}
pass.setPipeline(gctx.lookupResource(mipgen.pipeline).?);
const mem = gctx.uniformsAllocate(MipgenUniforms, 1);
mem.slice[0] = .{
.src_mip_level = @intCast(i32, current_src_mip_level),
.num_mip_levels = dispatch_num_mips,
};
pass.setBindGroup(0, gctx.lookupResource(bind_group).?, &.{mem.offset});
pass.dispatch(
math.max(texture_info.size.width >> @intCast(u5, 3 + current_src_mip_level), 1),
math.max(texture_info.size.height >> @intCast(u5, 3 + current_src_mip_level), 1),
1,
);
}
var mip_index: u32 = 0;
while (mip_index < dispatch_num_mips) : (mip_index += 1) {
const src_origin = gpu.Origin3D{ .x = 0, .y = 0, .z = 0 };
const dst_origin = gpu.Origin3D{ .x = 0, .y = 0, .z = array_layer };
encoder.copyTextureToTexture(
&.{
.texture = gctx.lookupResource(mipgen.scratch_texture).?,
.mip_level = mip_index,
.origin = src_origin,
},
&.{
.texture = gctx.lookupResource(texture).?,
.mip_level = mip_index + current_src_mip_level + 1,
.origin = dst_origin,
},
&.{
.width = texture_info.size.width >> @intCast(u5, mip_index + current_src_mip_level + 1),
.height = texture_info.size.height >> @intCast(u5, mip_index + current_src_mip_level + 1),
},
);
}
assert(total_num_mips >= dispatch_num_mips);
total_num_mips -= dispatch_num_mips;
if (total_num_mips == 0) {
break;
}
current_src_mip_level += dispatch_num_mips;
}
}
}
};
pub const util = struct {
/// You may disable async shader compilation for debugging purposes.
const enable_async_shader_compilation = true;
/// Helper function for creating render pipelines.
/// Supports: one vertex buffer, one non-blending render target,
/// one vertex shader module and one fragment shader module.
pub fn createRenderPipelineSimple(
allocator: std.mem.Allocator,
gctx: *GraphicsContext,
bgls: []const BindGroupLayoutHandle,
wgsl_vs: [:0]const u8,
wgsl_fs: [:0]const u8,
vertex_stride: ?u64,
vertex_attribs: ?[]const gpu.VertexAttribute,
primitive_state: gpu.PrimitiveState,
rt_format: gpu.Texture.Format,
depth_state: ?gpu.DepthStencilState,
out_pipe: *RenderPipelineHandle,
) void {
const pl = gctx.createPipelineLayout(bgls);
defer gctx.releaseResource(pl);
const vs_desc = gpu.ShaderModule.Descriptor{ .code = .{ .wgsl = wgsl_vs.ptr } };
const vs_mod = gctx.device.createShaderModule(&vs_desc);
defer vs_mod.release();
const fs_desc = gpu.ShaderModule.Descriptor{ .code = .{ .wgsl = wgsl_fs.ptr } };
const fs_mod = gctx.device.createShaderModule(&fs_desc);
defer fs_mod.release();
const color_target = gpu.ColorTargetState{ .format = rt_format };
const vertex_buffer_layout = if (vertex_stride) |vs| gpu.VertexBufferLayout{
.array_stride = vs,
.attribute_count = @intCast(u32, vertex_attribs.?.len),
.attributes = vertex_attribs.?.ptr,
} else null;
const pipe_desc = gpu.RenderPipeline.Descriptor{
.vertex = gpu.VertexState{
.module = vs_mod,
.entry_point = "main",
.buffers = if (vertex_buffer_layout != null) &.{vertex_buffer_layout.?} else null,
},
.fragment = &gpu.FragmentState{
.module = fs_mod,
.entry_point = "main",
.targets = &.{color_target},
},
.depth_stencil = if (depth_state) |ds| &ds else null,
.primitive = primitive_state,
};
if (enable_async_shader_compilation) {
gctx.createRenderPipelineAsync(allocator, pl, pipe_desc, out_pipe);
} else {
out_pipe.* = gctx.createRenderPipeline(pl, pipe_desc);
}
}
/// Helper function for creating render passes.
/// Supports: One color attachment and optional depth attachment.
pub fn beginRenderPassSimple(
encoder: gpu.CommandEncoder,
load_op: gpu.LoadOp,
color_texv: gpu.TextureView,
clear_color: ?gpu.Color,
depth_texv: ?gpu.TextureView,
clear_depth: ?f32,
) gpu.RenderPassEncoder {
if (depth_texv == null) {
assert(clear_depth == null);
}
const color_attachment = gpu.RenderPassColorAttachment{
.view = color_texv,
.load_op = load_op,
.store_op = .store,
.clear_value = if (clear_color) |cc| cc else .{ .r = 0, .g = 0, .b = 0, .a = 0 },
};
if (depth_texv) |dtexv| {
const depth_attachment = gpu.RenderPassDepthStencilAttachment{
.view = dtexv,
.depth_load_op = load_op,
.depth_store_op = .store,
.depth_clear_value = if (clear_depth) |cd| cd else 0.0,
};
return encoder.beginRenderPass(&gpu.RenderPassEncoder.Descriptor{
.color_attachments = &.{color_attachment},
.depth_stencil_attachment = &depth_attachment,
});
}
return encoder.beginRenderPass(&gpu.RenderPassEncoder.Descriptor{
.color_attachments = &.{color_attachment},
});
}
pub fn endRelease(pass: anytype) void {
pass.end();
pass.release();
}
};
pub const BufferInfo = struct {
gpuobj: ?gpu.Buffer = null,
size: usize = 0,
usage: gpu.BufferUsage = .{},
};
pub const TextureInfo = struct {
gpuobj: ?gpu.Texture = null,
usage: gpu.Texture.Usage = .{},
dimension: gpu.Texture.Dimension = .dimension_1d,
size: gpu.Extent3D = .{ .width = 0 },
format: gpu.Texture.Format = .none,
mip_level_count: u32 = 0,
sample_count: u32 = 0,
};
pub const TextureViewInfo = struct {
gpuobj: ?gpu.TextureView = null,
format: gpu.Texture.Format = .none,
dimension: gpu.TextureView.Dimension = .dimension_none,
base_mip_level: u32 = 0,
mip_level_count: u32 = 0,
base_array_layer: u32 = 0,
array_layer_count: u32 = 0,
aspect: gpu.Texture.Aspect = .all,
parent_texture_handle: TextureHandle = .{},
};
pub const SamplerInfo = struct {
gpuobj: ?gpu.Sampler = null,
address_mode_u: gpu.AddressMode = .repeat,
address_mode_v: gpu.AddressMode = .repeat,
address_mode_w: gpu.AddressMode = .repeat,
mag_filter: gpu.FilterMode = .nearest,
min_filter: gpu.FilterMode = .nearest,
mipmap_filter: gpu.FilterMode = .nearest,
lod_min_clamp: f32 = 0.0,
lod_max_clamp: f32 = 0.0,
compare: gpu.CompareFunction = .none,
max_anisotropy: u16 = 0,
};
pub const RenderPipelineInfo = struct {
gpuobj: ?gpu.RenderPipeline = null,
pipeline_layout_handle: PipelineLayoutHandle = .{},
};
pub const ComputePipelineInfo = struct {
gpuobj: ?gpu.ComputePipeline = null,
pipeline_layout_handle: PipelineLayoutHandle = .{},
};
pub const BindGroupEntryInfo = struct {
binding: u32 = 0,
buffer_handle: ?BufferHandle = null,
offset: u64 = 0,
size: u64 = 0,
sampler_handle: ?SamplerHandle = null,
texture_view_handle: ?TextureViewHandle = null,
};
const max_num_bindings_per_group = 10;
pub const BindGroupInfo = struct {
gpuobj: ?gpu.BindGroup = null,
num_entries: u32 = 0,
entries: [max_num_bindings_per_group]BindGroupEntryInfo =
[_]BindGroupEntryInfo{.{}} ** max_num_bindings_per_group,
};
pub const BindGroupLayoutInfo = struct {
gpuobj: ?gpu.BindGroupLayout = null,
num_entries: u32 = 0,
entries: [max_num_bindings_per_group]gpu.BindGroupLayout.Entry =
[_]gpu.BindGroupLayout.Entry{.{ .binding = 0, .visibility = .{} }} ** max_num_bindings_per_group,
};
const max_num_bind_groups_per_pipeline = 4;
pub const PipelineLayoutInfo = struct {
gpuobj: ?gpu.PipelineLayout = null,
num_bind_group_layouts: u32 = 0,
bind_group_layouts: [max_num_bind_groups_per_pipeline]BindGroupLayoutHandle =
[_]BindGroupLayoutHandle{.{}} ** max_num_bind_groups_per_pipeline,
};
pub const BufferHandle = BufferPool.Handle;
pub const TextureHandle = TexturePool.Handle;
pub const TextureViewHandle = TextureViewPool.Handle;
pub const SamplerHandle = SamplerPool.Handle;
pub const RenderPipelineHandle = RenderPipelinePool.Handle;
pub const ComputePipelineHandle = ComputePipelinePool.Handle;
pub const BindGroupHandle = BindGroupPool.Handle;
pub const BindGroupLayoutHandle = BindGroupLayoutPool.Handle;
pub const PipelineLayoutHandle = PipelineLayoutPool.Handle;
const BufferPool = ResourcePool(BufferInfo, gpu.Buffer);
const TexturePool = ResourcePool(TextureInfo, gpu.Texture);
const TextureViewPool = ResourcePool(TextureViewInfo, gpu.TextureView);
const SamplerPool = ResourcePool(SamplerInfo, gpu.Sampler);
const RenderPipelinePool = ResourcePool(RenderPipelineInfo, gpu.RenderPipeline);
const ComputePipelinePool = ResourcePool(ComputePipelineInfo, gpu.ComputePipeline);
const BindGroupPool = ResourcePool(BindGroupInfo, gpu.BindGroup);
const BindGroupLayoutPool = ResourcePool(BindGroupLayoutInfo, gpu.BindGroupLayout);
const PipelineLayoutPool = ResourcePool(PipelineLayoutInfo, gpu.PipelineLayout);
fn ResourcePool(comptime Info: type, comptime Resource: type) type {
const zpool = @import("zpool");
const Pool = zpool.Pool(16, 16, Resource, struct { info: Info });
return struct {
const Self = @This();
pub const Handle = Pool.Handle;
pool: Pool,
fn init(allocator: std.mem.Allocator, capacity: u32) Self {
const pool = Pool.initCapacity(allocator, capacity) catch unreachable;
return .{ .pool = pool };
}
fn deinit(self: *Self, allocator: std.mem.Allocator) void {
_ = allocator;
self.pool.deinit();
}
fn addResource(self: *Self, gctx: GraphicsContext, info: Info) Handle {
assert(info.gpuobj != null);
if (self.pool.addIfNotFull(.{ .info = info })) |handle| {
return handle;
}
// If pool is free, attempt to remove a resource that is now invalid
// because of dependent resources which have become invalid.
// For example, texture view becomes invalid when parent texture
// is destroyed.
//
// TODO: We could instead store a linked list in Info to track
// dependencies. The parent resource could "point" to the first
// dependent resource, and each dependent resource could "point" to
// the parent and the prev/next dependent resources of the same
// type (perhaps using handles instead of pointers).
// When a parent resource is destroyed, we could traverse that list
// to destroy dependent resources, and when a dependent resource
// is destroyed, we can remove it from the doubly-linked list.
//
// pub const TextureInfo = struct {
// ...
// // note generic name:
// first_dependent_handle: TextureViewHandle = .{}
// };
//
// pub const TextureViewInfo = struct {
// ...
// // note generic names:
// parent_handle: TextureHandle = .{},
// prev_dependent_handle: TextureViewHandle,
// next_dependent_handle: TextureViewHandle,
// };
if (self.removeResourceIfInvalid(gctx)) {
if (self.pool.addIfNotFull(.{ .info = info })) |handle| {
return handle;
}
}
// TODO: For now we just assert if pool is full - make it more roboust.
assert(false);
return Handle.nil;
}
fn removeResourceIfInvalid(self: *Self, gctx: GraphicsContext) bool {
var live_handles = self.pool.liveHandles();
while (live_handles.next()) |live_handle| {
if (!gctx.isResourceValid(live_handle)) {
self.destroyResource(live_handle, true);
return true;
}
}
return false;
}
fn destroyResource(self: *Self, handle: Handle, comptime call_destroy: bool) void {
if (!self.isHandleValid(handle))
return;
const resource_info = self.pool.getColumnPtrAssumeLive(handle, .info);
const gpuobj = resource_info.gpuobj.?;
if (call_destroy and @hasDecl(@TypeOf(gpuobj), "destroy")) {
gpuobj.destroy();
}
gpuobj.release();
resource_info.* = .{};
self.pool.removeAssumeLive(handle);
}
fn isHandleValid(self: Self, handle: Handle) bool {
return self.pool.isLiveHandle(handle);
}
fn getInfoPtr(self: Self, handle: Handle) *Info {
return self.pool.getColumnPtrAssumeLive(handle, .info);
}
fn getInfo(self: Self, handle: Handle) Info {
return self.pool.getColumnAssumeLive(handle, .info);
}
fn getGpuObj(self: Self, handle: Handle) ?Resource {
if (self.pool.getColumnPtrIfLive(handle, .info)) |info| {
return info.gpuobj;
}
return null;
}
};
}
pub fn checkSystem(comptime content_dir: []const u8) !void {
const local = struct {
fn impl() error{ GraphicsApiUnavailable, InvalidDataFiles }!void {
// TODO: On Windows we should check if DirectX 12 is supported (Windows 10+).
// On Linux we require Vulkan support.
if (@import("builtin").target.os.tag == .linux) {
if (!glfw.vulkanSupported()) {
return error.GraphicsApiUnavailable;
}
_ = glfw.getRequiredInstanceExtensions() catch return error.GraphicsApiUnavailable;
}
// Change directory to where an executable is located.
{
var exe_path_buffer: [1024]u8 = undefined;
const exe_path = std.fs.selfExeDirPath(exe_path_buffer[0..]) catch "./";
std.os.chdir(exe_path) catch {};
}
// Make sure font file is a valid data file and not just a Git LFS pointer.
{
const file = std.fs.cwd().openFile(
content_dir ++ "Roboto-Medium.ttf",
.{},
) catch return error.InvalidDataFiles;
defer file.close();
const size = @intCast(usize, file.getEndPos() catch return error.InvalidDataFiles);
if (size <= 1024) {
return error.InvalidDataFiles;
}
}
}
};
local.impl() catch |err| switch (err) {
error.GraphicsApiUnavailable => {
std.debug.print(
\\
\\GRAPHICS ERROR
\\
\\This program requires:
\\
\\ * DirectX 12 graphics driver on Windows
\\ * Vulkan graphics driver on Linux (OpenGL is NOT supported)
\\ * Metal graphics driver on MacOS
\\
\\Please install latest supported driver and try again.
\\
\\
, .{});
return err;
},
error.InvalidDataFiles => {
std.debug.print(
\\
\\DATA ERROR
\\
\\Invalid data files or missing content folder.
\\Please install Git LFS (Large File Support) and run (in the repo):
\\
\\git lfs install
\\git lfs pull
\\
\\For more info please see: https://git-lfs.github.com/
\\
\\
, .{});
return err;
},
else => unreachable,
};
}
const FrameStats = struct {
time: f64 = 0.0,
delta_time: f32 = 0.0,
fps_counter: u32 = 0,
fps: f64 = 0.0,
average_cpu_time: f64 = 0.0,
previous_time: f64 = 0.0,
fps_refresh_time: f64 = 0.0,
cpu_frame_number: u64 = 0,
gpu_frame_number: u64 = 0,
fn tick(stats: *FrameStats) void {
stats.time = glfw.getTime();
stats.delta_time = @floatCast(f32, stats.time - stats.previous_time);
stats.previous_time = stats.time;
if ((stats.time - stats.fps_refresh_time) >= 1.0) {
const t = stats.time - stats.fps_refresh_time;
const fps = @intToFloat(f64, stats.fps_counter) / t;
const ms = (1.0 / fps) * 1000.0;
stats.fps = fps;
stats.average_cpu_time = ms;
stats.fps_refresh_time = stats.time;
stats.fps_counter = 0;
}
stats.fps_counter += 1;
stats.cpu_frame_number += 1;
}
};
pub const gui = struct {
/// This call will install GLFW callbacks to handle GUI interactions.
/// Those callbacks will chain-call user's previously installed callbacks, if any.
/// This means that custom user's callbacks need to be installed *before* calling zgpu.gui.init().
pub fn init(
window: glfw.Window,
device: gpu.Device,
comptime content_dir: []const u8,
comptime font_name: [*:0]const u8,
font_size: f32,
) void {
assert(cimgui.igGetCurrentContext() == null);
_ = cimgui.igCreateContext(null);
if (!ImGui_ImplGlfw_InitForOther(window.handle, true)) {
unreachable;
}
const io = cimgui.igGetIO().?;
if (cimgui.ImFontAtlas_AddFontFromFileTTF(
io.*.Fonts,
content_dir ++ font_name,
font_size,
null,
null,
) == null) {
unreachable;
}
if (!ImGui_ImplWGPU_Init(
device.ptr,
1, // Number of `frames in flight`. One is enough because Dawn creates staging buffers internally.
@enumToInt(GraphicsContext.swapchain_format),
)) {
unreachable;
}
io.*.IniFilename = content_dir ++ "imgui.ini";
}
pub fn deinit() void {
assert(cimgui.igGetCurrentContext() != null);
ImGui_ImplWGPU_Shutdown();
ImGui_ImplGlfw_Shutdown();
cimgui.igDestroyContext(null);
}
pub fn newFrame(fb_width: u32, fb_height: u32) void {
ImGui_ImplWGPU_NewFrame();
ImGui_ImplGlfw_NewFrame();
{
const io = cimgui.igGetIO().?;
io.*.DisplaySize = .{
.x = @intToFloat(f32, fb_width),
.y = @intToFloat(f32, fb_height),
};
io.*.DisplayFramebufferScale = .{ .x = 1.0, .y = 1.0 };
}
cimgui.igNewFrame();
}
pub fn draw(pass: gpu.RenderPassEncoder) void {
cimgui.igRender();
ImGui_ImplWGPU_RenderDrawData(cimgui.igGetDrawData(), pass.ptr);
}
extern fn ImGui_ImplGlfw_InitForOther(window: *anyopaque, install_callbacks: bool) bool;
extern fn ImGui_ImplGlfw_NewFrame() void;
extern fn ImGui_ImplGlfw_Shutdown() void;
extern fn ImGui_ImplWGPU_Init(device: *anyopaque, num_frames_in_flight: u32, rt_format: u32) bool;
extern fn ImGui_ImplWGPU_NewFrame() void;
extern fn ImGui_ImplWGPU_RenderDrawData(draw_data: *anyopaque, pass_encoder: *anyopaque) void;
extern fn ImGui_ImplWGPU_Shutdown() void;
};
pub const stbi = struct {
pub fn Image(comptime ChannelType: type) type {
return struct {
const Self = @This();
data: []ChannelType,
width: u32,
height: u32,
bytes_per_row: u32,
channels_in_memory: u32,
channels_in_file: u32,
pub fn init(
filename: [*:0]const u8,
desired_channels: u32,
) !Self {
var x: c_int = undefined;
var y: c_int = undefined;
var ch: c_int = undefined;
var data = switch (ChannelType) {
u8 => stbi_load(filename, &x, &y, &ch, @intCast(c_int, desired_channels)),
f16 => @ptrCast(?[*]f16, stbi_loadf(filename, &x, &y, &ch, @intCast(c_int, desired_channels))),
f32 => stbi_loadf(filename, &x, &y, &ch, @intCast(c_int, desired_channels)),
else => @compileError("[zgpu] stbi.Image: ChannelType can be u8, f16 or f32."),
};
if (data == null)
return error.StbiLoadFailed;
const channels_in_memory = if (desired_channels == 0) @intCast(u32, ch) else desired_channels;
const width = @intCast(u32, x);
const height = @intCast(u32, y);
if (ChannelType == f16) {
var data_f32 = @ptrCast([*]f32, data.?);
const num = width * height * channels_in_memory;
var i: u32 = 0;
while (i < num) : (i += 1) {
data.?[i] = @floatCast(f16, data_f32[i]);
}
}
return Self{
.data = data.?[0 .. width * height * channels_in_memory],
.width = width,
.height = height,
.bytes_per_row = width * channels_in_memory * @sizeOf(ChannelType),
.channels_in_memory = channels_in_memory,
.channels_in_file = @intCast(u32, ch),
};
}
pub fn deinit(image: *Self) void {
stbi_image_free(image.data.ptr);
image.* = undefined;
}
};
}
pub const hdrToLdrScale = stbi_hdr_to_ldr_scale;
pub const hdrToLdrGamma = stbi_hdr_to_ldr_gamma;
pub const ldrToHdrScale = stbi_ldr_to_hdr_scale;
pub const ldrToHdrGamma = stbi_ldr_to_hdr_gamma;
pub fn isHdr(filename: [*:0]const u8) bool {
return stbi_is_hdr(filename) == 1;
}
pub fn setFlipVerticallyOnLoad(should_flip: bool) void {
stbi_set_flip_vertically_on_load(if (should_flip) 1 else 0);
}
extern fn stbi_load(
filename: [*:0]const u8,
x: *c_int,
y: *c_int,
channels_in_file: *c_int,
desired_channels: c_int,
) ?[*]u8;
extern fn stbi_loadf(
filename: [*:0]const u8,
x: *c_int,
y: *c_int,
channels_in_file: *c_int,
desired_channels: c_int,
) ?[*]f32;
extern fn stbi_image_free(image_data: ?*anyopaque) void;
extern fn stbi_hdr_to_ldr_scale(scale: f32) void;
extern fn stbi_hdr_to_ldr_gamma(gamma: f32) void;
extern fn stbi_ldr_to_hdr_scale(scale: f32) void;
extern fn stbi_ldr_to_hdr_gamma(gamma: f32) void;
extern fn stbi_is_hdr(filename: [*:0]const u8) c_int;
extern fn stbi_set_flip_vertically_on_load(flag_true_if_should_flip: c_int) void;
};
fn detectGLFWOptions() glfw.BackendOptions {
const target = @import("builtin").target;
if (target.isDarwin()) return .{ .cocoa = true };
return switch (target.os.tag) {
.windows => .{ .win32 = true },
.linux => .{ .x11 = true },
else => .{},
};
}
fn createSurfaceForWindow(
native_instance: *const gpu.NativeInstance,
window: glfw.Window,
comptime glfw_options: glfw.BackendOptions,
) gpu.Surface {
const glfw_native = glfw.Native(glfw_options);
const descriptor = if (glfw_options.win32) gpu.Surface.Descriptor{
.windows_hwnd = .{
.label = "basic surface",
.hinstance = std.os.windows.kernel32.GetModuleHandleW(null).?,
.hwnd = glfw_native.getWin32Window(window),
},
} else if (glfw_options.x11) gpu.Surface.Descriptor{
.xlib = .{
.label = "basic surface",
.display = glfw_native.getX11Display(),
.window = glfw_native.getX11Window(window),
},
} else if (glfw_options.cocoa) blk: {
const ns_window = glfw_native.getCocoaWindow(window);
const ns_view = msgSend(ns_window, "contentView", .{}, *anyopaque); // [nsWindow contentView]
// Create a CAMetalLayer that covers the whole window that will be passed to CreateSurface.
msgSend(ns_view, "setWantsLayer:", .{true}, void); // [view setWantsLayer:YES]
const layer = msgSend(objc.objc_getClass("CAMetalLayer"), "layer", .{}, ?*anyopaque); // [CAMetalLayer layer]
if (layer == null) @panic("failed to create Metal layer");
msgSend(ns_view, "setLayer:", .{layer.?}, void); // [view setLayer:layer]
// Use retina if the window was created with retina support.
const scale_factor = msgSend(ns_window, "backingScaleFactor", .{}, f64); // [ns_window backingScaleFactor]
msgSend(layer.?, "setContentsScale:", .{scale_factor}, void); // [layer setContentsScale:scale_factor]
break :blk gpu.Surface.Descriptor{
.metal_layer = .{
.label = "basic surface",
.layer = layer.?,
},
};
} else if (glfw_options.wayland) {
// bugs.chromium.org/p/dawn/issues/detail?id=1246&q=surface&can=2
@panic("Dawn does not yet have Wayland support");
} else unreachable;
return native_instance.createSurface(&descriptor);
}
// Borrowed from https://github.com/hazeycode/zig-objcrt
fn msgSend(obj: anytype, sel_name: [:0]const u8, args: anytype, comptime ReturnType: type) ReturnType {
const args_meta = @typeInfo(@TypeOf(args)).Struct.fields;
const FnType = switch (args_meta.len) {
0 => fn (@TypeOf(obj), objc.SEL) callconv(.C) ReturnType,
1 => fn (@TypeOf(obj), objc.SEL, args_meta[0].field_type) callconv(.C) ReturnType,
2 => fn (@TypeOf(obj), objc.SEL, args_meta[0].field_type, args_meta[1].field_type) callconv(.C) ReturnType,
3 => fn (
@TypeOf(obj),
objc.SEL,
args_meta[0].field_type,
args_meta[1].field_type,
args_meta[2].field_type,
) callconv(.C) ReturnType,
4 => fn (
@TypeOf(obj),
objc.SEL,
args_meta[0].field_type,
args_meta[1].field_type,
args_meta[2].field_type,
args_meta[3].field_type,
) callconv(.C) ReturnType,
else => @compileError("[zgpu] Unsupported number of args"),
};
// NOTE: `func` is a var because making it const causes a compile error which I believe is a compiler bug.
var func = @ptrCast(FnType, objc.objc_msgSend);
const sel = objc.sel_getUid(sel_name);
return @call(.{}, func, .{ obj, sel } ++ args);
}
fn printUnhandledError(_: void, typ: gpu.ErrorType, message: [*:0]const u8) void {
switch (typ) {
.validation => std.debug.print("[zgpu] Validation error: {s}\n", .{message}),
.out_of_memory => std.debug.print("[zgpu] Out of memory: {s}\n", .{message}),
.device_lost => std.debug.print("[zgpu] Device lost: {s}\n", .{message}),
.unknown => std.debug.print("[zgpu] Unknown error: {s}\n", .{message}),
else => unreachable,
}
// TODO: Do something better.
std.process.exit(1);
}
var printUnhandledErrorCallback = gpu.ErrorCallback.init(void, {}, printUnhandledError);
fn handleToGpuResourceType(comptime T: type) type {
return switch (T) {
BufferHandle => gpu.Buffer,
TextureHandle => gpu.Texture,
TextureViewHandle => gpu.TextureView,
SamplerHandle => gpu.Sampler,
RenderPipelineHandle => gpu.RenderPipeline,
ComputePipelineHandle => gpu.ComputePipeline,
BindGroupHandle => gpu.BindGroup,
BindGroupLayoutHandle => gpu.BindGroupLayout,
PipelineLayoutHandle => gpu.PipelineLayout,
else => @compileError("[zgpu] handleToGpuResourceType() not implemented for " ++ @typeName(T)),
};
}
fn handleToResourceInfoType(comptime T: type) type {
return switch (T) {
BufferHandle => BufferInfo,
TextureHandle => TextureInfo,
TextureViewHandle => TextureViewInfo,
SamplerHandle => SamplerInfo,
RenderPipelineHandle => RenderPipelineInfo,
ComputePipelineHandle => ComputePipelineInfo,
BindGroupHandle => BindGroupInfo,
BindGroupLayoutHandle => BindGroupLayoutInfo,
PipelineLayoutHandle => PipelineLayoutInfo,
else => @compileError("[zgpu] handleToResourceInfoType() not implemented for " ++ @typeName(T)),
};
}
fn formatToShaderFormat(format: gpu.Texture.Format) []const u8 {
// TODO: Add missing formats.
return switch (format) {
.rgba8_unorm => "rgba8unorm",
.rgba8_snorm => "rgba8snorm",
.rgba16_float => "rgba16float",
.rgba32_float => "rgba32float",
else => unreachable,
};
}
pub const bglBuffer = gpu.BindGroupLayout.Entry.buffer;
pub const bglTexture = gpu.BindGroupLayout.Entry.texture;
pub const bglSampler = gpu.BindGroupLayout.Entry.sampler;
pub const bglStorageTexture = gpu.BindGroupLayout.Entry.storageTexture; | libs/zgpu/src/zgpu.zig |
const std = @import("std");
const wots = @import("main.zig");
const expect = std.testing.expect;
const print = std.debug.print;
const ChaCha20Poly1305 = std.crypto.aead.chacha_poly.ChaCha20Poly1305;
const Sha = std.crypto.hash.sha2.Sha256;
const Timer = std.time.Timer;
test "PrivateKey" {
const n = Sha.digest_length;
const seed = [_]u8{0} ** n;
var rand = std.rand.DefaultCsprng.init(seed);
const foo = wots.PrivateKey(Sha).init(&rand.random);
expect(foo.forward_hash_key[0][0] == 196);
expect(foo.reverse_hash_key[31][31] == 179);
}
test "PublicKey" {
const n = Sha.digest_length;
const seed = [_]u8{0} ** n;
var rand = std.rand.DefaultCsprng.init(seed);
const foo = wots.PrivateKey(Sha).init(&rand.random);
const bar = wots.PublicKey(Sha).fromPrivateKey(&foo);
expect(bar.forward_hash_key[0][0] == 34);
expect(bar.reverse_hash_key[31][31] == 128);
var digest = [_]u8{0} ** n;
bar.compress(digest[0..]);
expect(digest[0] == 85);
}
test "Signature" {
const n = Sha.digest_length;
const seed = [_]u8{0} ** n;
var rand = std.rand.DefaultCsprng.init(seed);
const foo = wots.PrivateKey(Sha).init(&rand.random);
const bar = wots.PublicKey(Sha).fromPrivateKey(&foo);
var pkdigest1 = [_]u8{0} ** n;
bar.compress(pkdigest1[0..]);
const sig = wots.Signature(Sha).fromPrivateKey(&foo, "foo");
expect(sig.forward_hash_key[0][0] == 176);
expect(sig.reverse_hash_key[31][31] == 110);
const baz = wots.PublicKey(Sha).fromSignature(&sig);
expect(@TypeOf(bar) == @TypeOf(baz));
var pkdigest2 = [_]u8{0} ** n;
baz.compress(pkdigest2[0..]);
expect(std.mem.eql(u8, pkdigest1[0..], pkdigest2[0..]));
}
test "DRNG" {
const key_length = ChaCha20Poly1305.key_length;
const seed = [_]u8{0} ** (2*key_length);
var nonce = [_]u8{0} ** ChaCha20Poly1305.nonce_length;
var drng = wots.DRNG(ChaCha20Poly1305, key_length).init(seed, nonce);
var key = [_]u8{0} ** key_length;
// no-overflow
drng.generate(&key);
expect(key[0] == 159);
if (drng.next()) {
// pass
} else |err| {
expect(false);
}
drng.generate(&key);
expect(key[0] != 159);
// overflow
nonce = [_]u8{255} ** ChaCha20Poly1305.nonce_length;
drng = wots.DRNG(ChaCha20Poly1305, key_length).init(seed, nonce);
if (drng.next()) {
expect(false);
} else |err| {
// pass
}
}
test "DRNG Sanity" {
const key_length = ChaCha20Poly1305.key_length;
const seed = [_]u8{0} ** (2*key_length);
const nonce = [_]u8{0} ** ChaCha20Poly1305.nonce_length;
var drng = wots.DRNG(ChaCha20Poly1305, key_length).init(seed, nonce);
const iterations: u64 = 1000000;
var i: u64 = 0;
var key = [_]u8{0} ** key_length;
var accum: f128 = 0.0; // accumulate all random data
while (i < iterations) {
drng.generate(&key);
try drng.next();
for (key) |byte| {
accum += @intToFloat(f128, byte);
}
i += 1;
}
// make sure the average random byte converges to 127.5 as iterations goes to infinity.
const mean = accum / @intToFloat(f128, iterations * key_length);
const deviation = std.math.absFloat(1 - mean/127.5);
print("\nmean: {}, absolute deviation: {}\n", .{mean, deviation});
expect(deviation < 1e-4);
}
test "Benchmark" {
const n = Sha.digest_length;
const seed = [_]u8{0} ** n;
var rand = std.rand.DefaultCsprng.init(seed);
var timer = try Timer.start();
const iter1 = 10000;
var start: u64 = timer.lap();
{
var i: usize = 0;
while (i < iter1) : (i += 1) {
const tmp = wots.PrivateKey(Sha).init(&rand.random);
std.mem.doNotOptimizeAway(&tmp);
}
}
var end: u64 = timer.read();
var t = @intToFloat(f64, end - start) / std.time.ns_per_s / iter1;
print("\nPrivateKey.init: {}s\n", .{t});
const foo = wots.PrivateKey(Sha).init(&rand.random);
const iter2 = 100;
start = timer.lap();
{
var i: usize = 0;
while (i < iter2) : (i += 1) {
const tmp = wots.Signature(Sha).fromPrivateKey(&foo, "foo");
std.mem.doNotOptimizeAway(&tmp);
}
}
end = timer.read();
t = @intToFloat(f64, end - start) / std.time.ns_per_s / iter2;
print("\nSignature.fromPrivateKey: {}s\n", .{t});
start = timer.lap();
{
var i: usize = 0;
while (i < iter2) : (i += 1) {
const tmp = wots.PublicKey(Sha).fromPrivateKey(&foo);
std.mem.doNotOptimizeAway(&tmp);
}
}
end = timer.read();
t = @intToFloat(f64, end - start) / std.time.ns_per_s / iter2;
print("\nPublicKey.fromPrivateKey: {}s\n", .{t});
} | src/test.zig |
const std = @import("std");
const math = std.math;
const assert = std.debug.assert;
const L = std.unicode.utf8ToUtf16LeStringLiteral;
const zwin32 = @import("zwin32");
const w = zwin32.base;
const d2d1 = zwin32.d2d1;
const d3d12 = zwin32.d3d12;
const dwrite = zwin32.dwrite;
const hrPanicOnFail = zwin32.hrPanicOnFail;
const zd3d12 = @import("zd3d12");
const common = @import("common");
const GuiRenderer = common.GuiRenderer;
// We need to export below symbols for DirectX 12 Agility SDK.
pub export const D3D12SDKVersion: u32 = 4;
pub export const D3D12SDKPath: [*:0]const u8 = ".\\d3d12\\";
const content_dir = @import("build_options").content_dir;
const window_name = "zig-gamedev: intro 0";
const window_width = 1920;
const window_height = 1080;
const DemoState = struct {
gctx: zd3d12.GraphicsContext,
guictx: GuiRenderer,
frame_stats: common.FrameStats,
brush: *d2d1.ISolidColorBrush,
normal_tfmt: *dwrite.ITextFormat,
};
fn init(gpa_allocator: std.mem.Allocator) DemoState {
// Create application window and initialize dear imgui library.
const window = common.initWindow(gpa_allocator, window_name, window_width, window_height) catch unreachable;
// Create temporary memory allocator for use during initialization. We pass this allocator to all
// subsystems that need memory and then free everyting with a single deallocation.
var arena_allocator_state = std.heap.ArenaAllocator.init(gpa_allocator);
defer arena_allocator_state.deinit();
const arena_allocator = arena_allocator_state.allocator();
// Create DirectX 12 context.
var gctx = zd3d12.GraphicsContext.init(gpa_allocator, window);
// Enable vsync.
// gctx.present_flags = 0;
// gctx.present_interval = 1;
// Create Direct2D brush which will be needed to display text.
const brush = blk: {
var brush: ?*d2d1.ISolidColorBrush = null;
hrPanicOnFail(gctx.d2d.?.context.CreateSolidColorBrush(
&.{ .r = 1.0, .g = 0.0, .b = 0.0, .a = 0.5 },
null,
&brush,
));
break :blk brush.?;
};
// Create Direct2D text format which will be needed to display text.
const normal_tfmt = blk: {
var info_txtfmt: ?*dwrite.ITextFormat = null;
hrPanicOnFail(gctx.d2d.?.dwrite_factory.CreateTextFormat(
L("Verdana"),
null,
.BOLD,
.NORMAL,
.NORMAL,
96.0,
L("en-us"),
&info_txtfmt,
));
break :blk info_txtfmt.?;
};
hrPanicOnFail(normal_tfmt.SetTextAlignment(.CENTER));
hrPanicOnFail(normal_tfmt.SetParagraphAlignment(.CENTER));
// Open D3D12 command list, setup descriptor heap, etc. After this call we can upload resources to the GPU,
// draw 3D graphics etc.
gctx.beginFrame();
// Create and upload graphics resources for dear imgui renderer.
var guictx = GuiRenderer.init(arena_allocator, &gctx, 1, content_dir);
// This will send command list to the GPU, call 'Present' and do some other bookkeeping.
gctx.endFrame();
// Wait for the GPU to finish all commands.
gctx.finishGpuCommands();
return .{
.gctx = gctx,
.guictx = guictx,
.frame_stats = common.FrameStats.init(),
.brush = brush,
.normal_tfmt = normal_tfmt,
};
}
fn deinit(demo: *DemoState, gpa_allocator: std.mem.Allocator) void {
demo.gctx.finishGpuCommands();
_ = demo.brush.Release();
_ = demo.normal_tfmt.Release();
demo.guictx.deinit(&demo.gctx);
demo.gctx.deinit(gpa_allocator);
common.deinitWindow(gpa_allocator);
demo.* = undefined;
}
fn update(demo: *DemoState) void {
// Update frame counter and fps stats.
demo.frame_stats.update(demo.gctx.window, window_name);
const dt = demo.frame_stats.delta_time;
// Update dear imgui common. After this call we can define our widgets.
common.newImGuiFrame(dt);
}
fn draw(demo: *DemoState) void {
var gctx = &demo.gctx;
// Begin DirectX 12 rendering.
gctx.beginFrame();
// Get current back buffer resource and transition it to 'render target' state.
const back_buffer = gctx.getBackBuffer();
gctx.addTransitionBarrier(back_buffer.resource_handle, d3d12.RESOURCE_STATE_RENDER_TARGET);
gctx.flushResourceBarriers();
gctx.cmdlist.OMSetRenderTargets(
1,
&[_]d3d12.CPU_DESCRIPTOR_HANDLE{back_buffer.descriptor_handle},
w.TRUE,
null,
);
gctx.cmdlist.ClearRenderTargetView(
back_buffer.descriptor_handle,
&[4]f32{ 0.2, 0.4, 0.8, 1.0 },
0,
null,
);
// Draw dear imgui (not used in this demo).
demo.guictx.draw(gctx);
// Begin Direct2D rendering to the back buffer.
gctx.beginDraw2d();
{
// Display average fps and frame time.
const stats = &demo.frame_stats;
var buffer = [_]u8{0} ** 64;
const text = std.fmt.bufPrint(
buffer[0..],
"FPS: {d:.1}\nCPU time: {d:.3} ms\n\nmagic is everywhere",
.{ stats.fps, stats.average_cpu_time },
) catch unreachable;
demo.brush.SetColor(&.{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 });
common.drawText(
gctx.d2d.?.context,
text,
demo.normal_tfmt,
&d2d1.RECT_F{
.left = 0.0,
.top = 0.0,
.right = @intToFloat(f32, gctx.viewport_width),
.bottom = @intToFloat(f32, gctx.viewport_height),
},
@ptrCast(*d2d1.IBrush, demo.brush),
);
}
// End Direct2D rendering and transition back buffer to 'present' state.
gctx.endDraw2d();
// Call 'Present' and prepare for the next frame.
gctx.endFrame();
}
pub fn main() !void {
// Initialize some low-level Windows stuff (DPI awarness, COM), check Windows version and also check
// if DirectX 12 Agility SDK is supported.
common.init();
defer common.deinit();
// Create main memory allocator for our application.
var gpa_allocator_state = std.heap.GeneralPurposeAllocator(.{}){};
defer {
const leaked = gpa_allocator_state.deinit();
std.debug.assert(leaked == false);
}
const gpa_allocator = gpa_allocator_state.allocator();
var demo = init(gpa_allocator);
defer deinit(&demo, gpa_allocator);
while (true) {
var message = std.mem.zeroes(w.user32.MSG);
const has_message = w.user32.peekMessageA(&message, null, 0, 0, w.user32.PM_REMOVE) catch false;
if (has_message) {
_ = w.user32.translateMessage(&message);
_ = w.user32.dispatchMessageA(&message);
if (message.message == w.user32.WM_QUIT) {
break;
}
} else {
update(&demo);
draw(&demo);
}
}
} | samples/intro/src/intro0.zig |
const c = @import("../c.zig");
const math = @import("../math/math.zig");
const std = @import("std");
const Logger = @import("../logger.zig").Logger;
const Scene = @import("view/scene.zig").Scene;
const SdlError = error {
SDLInitializationFailed,
};
pub const Renderer = struct {
allocator: *std.mem.Allocator,
logger: *Logger,
window: *c.SDL_Window,
renderer: *c.SDL_Renderer,
glContext: c.SDL_GLContext,
scene: *Scene = undefined,
pub fn init(allocator: *std.mem.Allocator, logger: *Logger) SdlError!*Renderer {
if (c.SDL_Init(c.SDL_INIT_VIDEO) != 0) {
logger.debug("failed to init SDL..");
return error.SDLInitializationFailed;
}
errdefer {
c.SDL_Quit();
}
const window = c.SDL_CreateWindow(
"Deeper and Deeper (LD48)",
c.SDL_WINDOWPOS_UNDEFINED,
c.SDL_WINDOWPOS_UNDEFINED,
1024,
768,
c.SDL_WINDOW_OPENGL
) orelse {
logger.debug("failed to create window..");
return error.SDLInitializationFailed;
};
errdefer {
c.SDL_DestroyWindow(window);
}
const renderer = c.SDL_CreateRenderer(window, -1, 0) orelse {
logger.debug("failed to create renderer..");
return error.SDLInitializationFailed;
};
const glContext = c.SDL_GL_CreateContext(window) orelse {
logger.debug("failed to create gl context..");
return error.SDLInitializationFailed;
};
c.glewExperimental = c.GL_TRUE;
_ = c.glewInit();
var result = allocator.create(Renderer) catch unreachable;
result.allocator = allocator;
result.logger = logger;
result.window = window;
result.renderer = renderer;
result.glContext = glContext;
return result;
}
pub fn deinit(self: *Renderer) void {
c.SDL_GL_DeleteContext(self.glContext);
c.SDL_DestroyRenderer(self.renderer);
c.SDL_DestroyWindow(self.window);
c.SDL_Quit();
self.allocator.destroy(self);
}
pub fn addScene(self: *Renderer, scene: *Scene) void {
self.scene = scene;
}
pub fn draw(self: *Renderer) void {
c.glClearColor(0.0, 0.0, 0.0, 1.0);
c.glClear(c.GL_COLOR_BUFFER_BIT);
self.scene.draw();
c.SDL_GL_SwapWindow(self.window);
}
}; | src/gfx/renderer.zig |
pub usingnamespace @import("std").zig.c_builtins;
pub const __builtin_va_list = [*c]u8;
pub const va_list = __builtin_va_list;
pub const __gnuc_va_list = __builtin_va_list;
pub const ptrdiff_t = c_longlong;
pub const wchar_t = c_ushort;
pub const max_align_t = extern struct {
__clang_max_align_nonce1: c_longlong align(8),
__clang_max_align_nonce2: c_longdouble align(16),
}; // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:584:3: warning: TODO implement translation of stmt class GCCAsmStmtClass
// C:\Zig\lib\libc\include\any-windows-any\_mingw.h:581:36: warning: unable to translate function, demoted to extern
pub extern fn __debugbreak() callconv(.C) void;
pub extern fn __mingw_get_crt_info() [*c]const u8;
pub const rsize_t = usize;
pub const wint_t = c_ushort;
pub const wctype_t = c_ushort;
pub const errno_t = c_int;
pub const __time32_t = c_long;
pub const __time64_t = c_longlong;
pub const time_t = __time64_t;
pub const struct_tagLC_ID = extern struct {
wLanguage: c_ushort,
wCountry: c_ushort,
wCodePage: c_ushort,
};
pub const LC_ID = struct_tagLC_ID;
const struct_unnamed_1 = extern struct {
locale: [*c]u8,
wlocale: [*c]wchar_t,
refcount: [*c]c_int,
wrefcount: [*c]c_int,
};
pub const struct_lconv = opaque {};
pub const struct___lc_time_data = opaque {};
pub const struct_threadlocaleinfostruct = extern struct {
refcount: c_int,
lc_codepage: c_uint,
lc_collate_cp: c_uint,
lc_handle: [6]c_ulong,
lc_id: [6]LC_ID,
lc_category: [6]struct_unnamed_1,
lc_clike: c_int,
mb_cur_max: c_int,
lconv_intl_refcount: [*c]c_int,
lconv_num_refcount: [*c]c_int,
lconv_mon_refcount: [*c]c_int,
lconv: ?*struct_lconv,
ctype1_refcount: [*c]c_int,
ctype1: [*c]c_ushort,
pctype: [*c]const c_ushort,
pclmap: [*c]const u8,
pcumap: [*c]const u8,
lc_time_curr: ?*struct___lc_time_data,
};
pub const struct_threadmbcinfostruct = opaque {};
pub const pthreadlocinfo = [*c]struct_threadlocaleinfostruct;
pub const pthreadmbcinfo = ?*struct_threadmbcinfostruct;
pub const struct_localeinfo_struct = extern struct {
locinfo: pthreadlocinfo,
mbcinfo: pthreadmbcinfo,
};
pub const _locale_tstruct = struct_localeinfo_struct;
pub const _locale_t = [*c]struct_localeinfo_struct;
pub const LPLC_ID = [*c]struct_tagLC_ID;
pub const threadlocinfo = struct_threadlocaleinfostruct;
pub const struct__iobuf = extern struct {
_ptr: [*c]u8,
_cnt: c_int,
_base: [*c]u8,
_flag: c_int,
_file: c_int,
_charbuf: c_int,
_bufsiz: c_int,
_tmpfname: [*c]u8,
};
pub const FILE = struct__iobuf;
pub const _off_t = c_long;
pub const off32_t = c_long;
pub const _off64_t = c_longlong;
pub const off64_t = c_longlong;
pub const off_t = off32_t;
pub extern fn __acrt_iob_func(index: c_uint) [*c]FILE;
pub extern fn __iob_func() [*c]FILE;
pub const fpos_t = c_longlong;
pub extern fn __mingw_sscanf(noalias _Src: [*c]const u8, noalias _Format: [*c]const u8, ...) c_int;
pub extern fn __mingw_vsscanf(noalias _Str: [*c]const u8, noalias Format: [*c]const u8, argp: va_list) c_int;
pub extern fn __mingw_scanf(noalias _Format: [*c]const u8, ...) c_int;
pub extern fn __mingw_vscanf(noalias Format: [*c]const u8, argp: va_list) c_int;
pub extern fn __mingw_fscanf(noalias _File: [*c]FILE, noalias _Format: [*c]const u8, ...) c_int;
pub extern fn __mingw_vfscanf(noalias fp: [*c]FILE, noalias Format: [*c]const u8, argp: va_list) c_int;
pub extern fn __mingw_vsnprintf(noalias _DstBuf: [*c]u8, _MaxCount: usize, noalias _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn __mingw_snprintf(noalias s: [*c]u8, n: usize, noalias format: [*c]const u8, ...) c_int;
pub const __mingw_printf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:184:15
pub const __mingw_vprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:187:15
pub const __mingw_fprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:190:15
pub const __mingw_vfprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:193:15
pub const __mingw_sprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:196:15
pub const __mingw_vsprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:199:15
pub const __mingw_asprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:202:15
pub const __mingw_vasprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:205:15
pub extern fn __ms_sscanf(noalias _Src: [*c]const u8, noalias _Format: [*c]const u8, ...) c_int;
pub extern fn __ms_scanf(noalias _Format: [*c]const u8, ...) c_int;
pub extern fn __ms_fscanf(noalias _File: [*c]FILE, noalias _Format: [*c]const u8, ...) c_int;
pub const __ms_printf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:219:15
pub const __ms_vprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:222:15
pub const __ms_fprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:225:15
pub const __ms_vfprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:228:15
pub const __ms_sprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:231:15
pub const __ms_vsprintf = @compileError("unable to resolve function type TypeClass.MacroQualified"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:234:15
// C:\Zig\lib\libc\include\any-windows-any\stdio.h:290:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn sscanf(__source: [*c]const u8, __format: [*c]const u8, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:301:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn scanf(__format: [*c]const u8, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:312:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn fscanf(__stream: [*c]FILE, __format: [*c]const u8, ...) c_int;
pub fn vsscanf(arg___source: [*c]const u8, arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __source = arg___source;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vsscanf(__source, __format, __local_argv);
}
pub fn vscanf(arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfscanf(__acrt_iob_func(@bitCast(c_uint, @as(c_int, 0))), __format, __local_argv);
}
pub fn vfscanf(arg___stream: [*c]FILE, arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfscanf(__stream, __format, __local_argv);
} // C:\Zig\lib\libc\include\any-windows-any\stdio.h:357:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn fprintf(__stream: [*c]FILE, __format: [*c]const u8, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:368:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn printf(__format: [*c]const u8, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:396:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn sprintf(__stream: [*c]u8, __format: [*c]const u8, ...) c_int;
pub fn vfprintf(arg___stream: [*c]FILE, arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfprintf(__stream, __format, __local_argv);
}
pub fn vprintf(arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfprintf(__acrt_iob_func(@bitCast(c_uint, @as(c_int, 1))), __format, __local_argv);
}
pub fn vsprintf(arg___stream: [*c]u8, arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vsprintf(__stream, __format, __local_argv);
} // C:\Zig\lib\libc\include\any-windows-any\stdio.h:451:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn snprintf(__stream: [*c]u8, __n: usize, __format: [*c]const u8, ...) c_int;
pub fn vsnprintf(arg___stream: [*c]u8, arg___n: usize, arg___format: [*c]const u8, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __n = arg___n;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vsnprintf(__stream, __n, __format, __local_argv);
}
pub extern fn _filbuf(_File: [*c]FILE) c_int;
pub extern fn _flsbuf(_Ch: c_int, _File: [*c]FILE) c_int;
pub extern fn _fsopen(_Filename: [*c]const u8, _Mode: [*c]const u8, _ShFlag: c_int) [*c]FILE;
pub extern fn clearerr(_File: [*c]FILE) void;
pub extern fn fclose(_File: [*c]FILE) c_int;
pub extern fn _fcloseall() c_int;
pub extern fn _fdopen(_FileHandle: c_int, _Mode: [*c]const u8) [*c]FILE;
pub extern fn feof(_File: [*c]FILE) c_int;
pub extern fn ferror(_File: [*c]FILE) c_int;
pub extern fn fflush(_File: [*c]FILE) c_int;
pub extern fn fgetc(_File: [*c]FILE) c_int;
pub extern fn _fgetchar() c_int;
pub extern fn fgetpos(noalias _File: [*c]FILE, noalias _Pos: [*c]fpos_t) c_int;
pub extern fn fgetpos64(noalias _File: [*c]FILE, noalias _Pos: [*c]fpos_t) c_int;
pub extern fn fgets(noalias _Buf: [*c]u8, _MaxCount: c_int, noalias _File: [*c]FILE) [*c]u8;
pub extern fn _fileno(_File: [*c]FILE) c_int;
pub extern fn _tempnam(_DirName: [*c]const u8, _FilePrefix: [*c]const u8) [*c]u8;
pub extern fn _flushall() c_int;
pub extern fn fopen(_Filename: [*c]const u8, _Mode: [*c]const u8) [*c]FILE;
pub extern fn fopen64(noalias filename: [*c]const u8, noalias mode: [*c]const u8) [*c]FILE;
pub extern fn fputc(_Ch: c_int, _File: [*c]FILE) c_int;
pub extern fn _fputchar(_Ch: c_int) c_int;
pub extern fn fputs(noalias _Str: [*c]const u8, noalias _File: [*c]FILE) c_int;
pub extern fn fread(_DstBuf: ?*c_void, _ElementSize: c_ulonglong, _Count: c_ulonglong, _File: [*c]FILE) c_ulonglong;
pub extern fn freopen(noalias _Filename: [*c]const u8, noalias _Mode: [*c]const u8, noalias _File: [*c]FILE) [*c]FILE;
pub extern fn fsetpos(_File: [*c]FILE, _Pos: [*c]const fpos_t) c_int;
pub extern fn fsetpos64(_File: [*c]FILE, _Pos: [*c]const fpos_t) c_int;
pub extern fn fseek(_File: [*c]FILE, _Offset: c_long, _Origin: c_int) c_int;
pub extern fn ftell(_File: [*c]FILE) c_long;
pub extern fn _fseeki64(_File: [*c]FILE, _Offset: c_longlong, _Origin: c_int) c_int;
pub extern fn _ftelli64(_File: [*c]FILE) c_longlong;
pub extern fn fseeko64(stream: [*c]FILE, offset: _off64_t, whence: c_int) c_int;
pub extern fn fseeko(stream: [*c]FILE, offset: _off_t, whence: c_int) c_int;
pub extern fn ftello(stream: [*c]FILE) _off_t;
pub extern fn ftello64(stream: [*c]FILE) _off64_t;
pub extern fn fwrite(_Str: ?*const c_void, _Size: c_ulonglong, _Count: c_ulonglong, _File: [*c]FILE) c_ulonglong;
pub extern fn getc(_File: [*c]FILE) c_int;
pub extern fn getchar() c_int;
pub extern fn _getmaxstdio() c_int;
pub extern fn gets(_Buffer: [*c]u8) [*c]u8;
pub extern fn _getw(_File: [*c]FILE) c_int;
pub extern fn perror(_ErrMsg: [*c]const u8) void;
pub extern fn _pclose(_File: [*c]FILE) c_int;
pub extern fn _popen(_Command: [*c]const u8, _Mode: [*c]const u8) [*c]FILE;
pub extern fn putc(_Ch: c_int, _File: [*c]FILE) c_int;
pub extern fn putchar(_Ch: c_int) c_int;
pub extern fn puts(_Str: [*c]const u8) c_int;
pub extern fn _putw(_Word: c_int, _File: [*c]FILE) c_int;
pub extern fn remove(_Filename: [*c]const u8) c_int;
pub extern fn rename(_OldFilename: [*c]const u8, _NewFilename: [*c]const u8) c_int;
pub extern fn _unlink(_Filename: [*c]const u8) c_int;
pub extern fn unlink(_Filename: [*c]const u8) c_int;
pub extern fn rewind(_File: [*c]FILE) void;
pub extern fn _rmtmp() c_int;
pub extern fn setbuf(noalias _File: [*c]FILE, noalias _Buffer: [*c]u8) void;
pub extern fn _setmaxstdio(_Max: c_int) c_int;
pub extern fn _set_output_format(_Format: c_uint) c_uint;
pub extern fn _get_output_format() c_uint;
pub extern fn setvbuf(noalias _File: [*c]FILE, noalias _Buf: [*c]u8, _Mode: c_int, _Size: usize) c_int;
pub extern fn _scprintf(noalias _Format: [*c]const u8, ...) c_int;
pub extern fn _snscanf(noalias _Src: [*c]const u8, _MaxCount: usize, noalias _Format: [*c]const u8, ...) c_int;
pub extern fn tmpfile() [*c]FILE;
pub extern fn tmpnam(_Buffer: [*c]u8) [*c]u8;
pub extern fn ungetc(_Ch: c_int, _File: [*c]FILE) c_int;
pub extern fn _snprintf(noalias _Dest: [*c]u8, _Count: usize, noalias _Format: [*c]const u8, ...) c_int;
pub extern fn _vsnprintf(noalias _Dest: [*c]u8, _Count: usize, noalias _Format: [*c]const u8, _Args: va_list) c_int;
pub extern fn _vscprintf(noalias _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _set_printf_count_output(_Value: c_int) c_int;
pub extern fn _get_printf_count_output() c_int;
pub extern fn __mingw_swscanf(noalias _Src: [*c]const wchar_t, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vswscanf(noalias _Str: [*c]const wchar_t, noalias Format: [*c]const wchar_t, argp: va_list) c_int;
pub extern fn __mingw_wscanf(noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vwscanf(noalias Format: [*c]const wchar_t, argp: va_list) c_int;
pub extern fn __mingw_fwscanf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vfwscanf(noalias fp: [*c]FILE, noalias Format: [*c]const wchar_t, argp: va_list) c_int;
pub extern fn __mingw_fwprintf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_wprintf(noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vfwprintf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn __mingw_vwprintf(noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn __mingw_snwprintf(noalias s: [*c]wchar_t, n: usize, noalias format: [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vsnwprintf(noalias [*c]wchar_t, usize, noalias [*c]const wchar_t, va_list) c_int;
pub extern fn __mingw_swprintf(noalias [*c]wchar_t, noalias [*c]const wchar_t, ...) c_int;
pub extern fn __mingw_vswprintf(noalias [*c]wchar_t, noalias [*c]const wchar_t, va_list) c_int;
pub extern fn __ms_swscanf(noalias _Src: [*c]const wchar_t, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __ms_wscanf(noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __ms_fwscanf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __ms_fwprintf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __ms_wprintf(noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn __ms_vfwprintf(noalias _File: [*c]FILE, noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn __ms_vwprintf(noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn __ms_swprintf(noalias [*c]wchar_t, noalias [*c]const wchar_t, ...) c_int;
pub extern fn __ms_vswprintf(noalias [*c]wchar_t, noalias [*c]const wchar_t, va_list) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:996:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn swscanf(__source: [*c]const wchar_t, __format: [*c]const wchar_t, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1007:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn wscanf(__format: [*c]const wchar_t, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1018:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn fwscanf(__stream: [*c]FILE, __format: [*c]const wchar_t, ...) c_int;
pub fn vswscanf(noalias arg___source: [*c]const wchar_t, noalias arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __source = arg___source;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vswscanf(__source, __format, __local_argv);
}
pub fn vwscanf(arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfwscanf(__acrt_iob_func(@bitCast(c_uint, @as(c_int, 0))), __format, __local_argv);
}
pub fn vfwscanf(arg___stream: [*c]FILE, arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfwscanf(__stream, __format, __local_argv);
} // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1054:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn fwprintf(__stream: [*c]FILE, __format: [*c]const wchar_t, ...) c_int; // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1065:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn wprintf(__format: [*c]const wchar_t, ...) c_int;
pub fn vfwprintf(arg___stream: [*c]FILE, arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfwprintf(__stream, __format, __local_argv);
}
pub fn vwprintf(arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vfwprintf(__acrt_iob_func(@bitCast(c_uint, @as(c_int, 1))), __format, __local_argv);
} // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1104:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn snwprintf(__stream: [*c]wchar_t, __n: usize, __format: [*c]const wchar_t, ...) c_int;
pub fn vsnwprintf(arg___stream: [*c]wchar_t, arg___n: usize, arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __n = arg___n;
var __format = arg___format;
var __local_argv = arg___local_argv;
return __mingw_vsnwprintf(__stream, __n, __format, __local_argv);
}
pub extern fn _wfsopen(_Filename: [*c]const wchar_t, _Mode: [*c]const wchar_t, _ShFlag: c_int) [*c]FILE;
pub extern fn fgetwc(_File: [*c]FILE) wint_t;
pub extern fn _fgetwchar() wint_t;
pub extern fn fputwc(_Ch: wchar_t, _File: [*c]FILE) wint_t;
pub extern fn _fputwchar(_Ch: wchar_t) wint_t;
pub extern fn getwc(_File: [*c]FILE) wint_t;
pub extern fn getwchar() wint_t;
pub extern fn putwc(_Ch: wchar_t, _File: [*c]FILE) wint_t;
pub extern fn putwchar(_Ch: wchar_t) wint_t;
pub extern fn ungetwc(_Ch: wint_t, _File: [*c]FILE) wint_t;
pub extern fn fgetws(noalias _Dst: [*c]wchar_t, _SizeInWords: c_int, noalias _File: [*c]FILE) [*c]wchar_t;
pub extern fn fputws(noalias _Str: [*c]const wchar_t, noalias _File: [*c]FILE) c_int;
pub extern fn _getws(_String: [*c]wchar_t) [*c]wchar_t;
pub extern fn _putws(_Str: [*c]const wchar_t) c_int;
pub extern fn _scwprintf(noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _swprintf_c(noalias _DstBuf: [*c]wchar_t, _SizeInWords: usize, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vswprintf_c(noalias _DstBuf: [*c]wchar_t, _SizeInWords: usize, noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _snwprintf(noalias _Dest: [*c]wchar_t, _Count: usize, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vsnwprintf(noalias _Dest: [*c]wchar_t, _Count: usize, noalias _Format: [*c]const wchar_t, _Args: va_list) c_int;
pub extern fn _vscwprintf(noalias _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _swprintf(noalias _Dest: [*c]wchar_t, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vswprintf(noalias _Dest: [*c]wchar_t, noalias _Format: [*c]const wchar_t, _Args: va_list) c_int;
pub fn vswprintf(arg___stream: [*c]wchar_t, arg___count: usize, arg___format: [*c]const wchar_t, arg___local_argv: __builtin_va_list) callconv(.C) c_int {
var __stream = arg___stream;
var __count = arg___count;
var __format = arg___format;
var __local_argv = arg___local_argv;
return vsnwprintf(__stream, __count, __format, __local_argv);
} // C:\Zig\lib\libc\include\any-windows-any\swprintf.inl:34:5: warning: TODO unable to translate variadic function, demoted to extern
pub extern fn swprintf(__stream: [*c]wchar_t, __count: usize, __format: [*c]const wchar_t, ...) c_int;
pub extern fn _wtempnam(_Directory: [*c]const wchar_t, _FilePrefix: [*c]const wchar_t) [*c]wchar_t;
pub extern fn _snwscanf(noalias _Src: [*c]const wchar_t, _MaxCount: usize, noalias _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _wfdopen(_FileHandle: c_int, _Mode: [*c]const wchar_t) [*c]FILE;
pub extern fn _wfopen(noalias _Filename: [*c]const wchar_t, noalias _Mode: [*c]const wchar_t) [*c]FILE;
pub extern fn _wfreopen(noalias _Filename: [*c]const wchar_t, noalias _Mode: [*c]const wchar_t, noalias _OldFile: [*c]FILE) [*c]FILE;
pub extern fn _wperror(_ErrMsg: [*c]const wchar_t) void;
pub extern fn _wpopen(_Command: [*c]const wchar_t, _Mode: [*c]const wchar_t) [*c]FILE;
pub extern fn _wremove(_Filename: [*c]const wchar_t) c_int;
pub extern fn _wtmpnam(_Buffer: [*c]wchar_t) [*c]wchar_t;
pub extern fn _lock_file(_File: [*c]FILE) void;
pub extern fn _unlock_file(_File: [*c]FILE) void;
pub extern fn tempnam(_Directory: [*c]const u8, _FilePrefix: [*c]const u8) [*c]u8;
pub extern fn fcloseall() c_int;
pub extern fn fdopen(_FileHandle: c_int, _Format: [*c]const u8) [*c]FILE;
pub extern fn fgetchar() c_int;
pub extern fn fileno(_File: [*c]FILE) c_int;
pub extern fn flushall() c_int;
pub extern fn fputchar(_Ch: c_int) c_int;
pub extern fn getw(_File: [*c]FILE) c_int;
pub extern fn putw(_Ch: c_int, _File: [*c]FILE) c_int;
pub extern fn rmtmp() c_int;
pub extern fn __mingw_str_wide_utf8(wptr: [*c]const wchar_t, mbptr: [*c][*c]u8, buflen: [*c]usize) c_int;
pub extern fn __mingw_str_utf8_wide(mbptr: [*c]const u8, wptr: [*c][*c]wchar_t, buflen: [*c]usize) c_int;
pub extern fn __mingw_str_free(ptr: ?*c_void) void;
pub extern fn _wspawnl(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const wchar_t, ...) isize;
pub extern fn _wspawnle(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const wchar_t, ...) isize;
pub extern fn _wspawnlp(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const wchar_t, ...) isize;
pub extern fn _wspawnlpe(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const wchar_t, ...) isize;
pub extern fn _wspawnv(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const [*c]const wchar_t) isize;
pub extern fn _wspawnve(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const [*c]const wchar_t, _Env: [*c]const [*c]const wchar_t) isize;
pub extern fn _wspawnvp(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const [*c]const wchar_t) isize;
pub extern fn _wspawnvpe(_Mode: c_int, _Filename: [*c]const wchar_t, _ArgList: [*c]const [*c]const wchar_t, _Env: [*c]const [*c]const wchar_t) isize;
pub extern fn _spawnv(_Mode: c_int, _Filename: [*c]const u8, _ArgList: [*c]const [*c]const u8) isize;
pub extern fn _spawnve(_Mode: c_int, _Filename: [*c]const u8, _ArgList: [*c]const [*c]const u8, _Env: [*c]const [*c]const u8) isize;
pub extern fn _spawnvp(_Mode: c_int, _Filename: [*c]const u8, _ArgList: [*c]const [*c]const u8) isize;
pub extern fn _spawnvpe(_Mode: c_int, _Filename: [*c]const u8, _ArgList: [*c]const [*c]const u8, _Env: [*c]const [*c]const u8) isize;
pub extern fn clearerr_s(_File: [*c]FILE) errno_t;
pub extern fn fread_s(_DstBuf: ?*c_void, _DstSize: usize, _ElementSize: usize, _Count: usize, _File: [*c]FILE) usize;
pub extern fn fprintf_s(_File: [*c]FILE, _Format: [*c]const u8, ...) c_int;
pub extern fn _fscanf_s_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn fscanf_s(_File: [*c]FILE, _Format: [*c]const u8, ...) c_int;
pub extern fn printf_s(_Format: [*c]const u8, ...) c_int;
pub extern fn _scanf_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _scanf_s_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn scanf_s(_Format: [*c]const u8, ...) c_int;
pub extern fn _snprintf_c(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, ...) c_int;
pub extern fn _vsnprintf_c(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _fscanf_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _sscanf_l(_Src: [*c]const u8, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _sscanf_s_l(_Src: [*c]const u8, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn sscanf_s(_Src: [*c]const u8, _Format: [*c]const u8, ...) c_int;
pub extern fn _snscanf_s(_Src: [*c]const u8, _MaxCount: usize, _Format: [*c]const u8, ...) c_int;
pub extern fn _snscanf_l(_Src: [*c]const u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _snscanf_s_l(_Src: [*c]const u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn vfprintf_s(_File: [*c]FILE, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn vprintf_s(_Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn vsnprintf_s(_DstBuf: [*c]u8, _DstSize: usize, _MaxCount: usize, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _vsnprintf_s(_DstBuf: [*c]u8, _DstSize: usize, _MaxCount: usize, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn vsprintf_s(_DstBuf: [*c]u8, _Size: usize, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn sprintf_s(_DstBuf: [*c]u8, _DstSize: usize, _Format: [*c]const u8, ...) c_int;
pub extern fn _snprintf_s(_DstBuf: [*c]u8, _DstSize: usize, _MaxCount: usize, _Format: [*c]const u8, ...) c_int;
pub extern fn _fprintf_p(_File: [*c]FILE, _Format: [*c]const u8, ...) c_int;
pub extern fn _printf_p(_Format: [*c]const u8, ...) c_int;
pub extern fn _sprintf_p(_Dst: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, ...) c_int;
pub extern fn _vfprintf_p(_File: [*c]FILE, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _vprintf_p(_Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _vsprintf_p(_Dst: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _scprintf_p(_Format: [*c]const u8, ...) c_int;
pub extern fn _vscprintf_p(_Format: [*c]const u8, _ArgList: va_list) c_int;
pub extern fn _printf_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _printf_p_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vprintf_l(_Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vprintf_p_l(_Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fprintf_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _fprintf_p_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vfprintf_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vfprintf_p_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _sprintf_l(_DstBuf: [*c]u8, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _sprintf_p_l(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vsprintf_l(_DstBuf: [*c]u8, _Format: [*c]const u8, _locale_t, _ArgList: va_list) c_int;
pub extern fn _vsprintf_p_l(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _scprintf_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _scprintf_p_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vscprintf_l(_Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vscprintf_p_l(_Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _printf_s_l(_Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vprintf_s_l(_Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fprintf_s_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vfprintf_s_l(_File: [*c]FILE, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _sprintf_s_l(_DstBuf: [*c]u8, _DstSize: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vsprintf_s_l(_DstBuf: [*c]u8, _DstSize: usize, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _snprintf_s_l(_DstBuf: [*c]u8, _DstSize: usize, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vsnprintf_s_l(_DstBuf: [*c]u8, _DstSize: usize, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _snprintf_l(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _snprintf_c_l(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, ...) c_int;
pub extern fn _vsnprintf_l(_DstBuf: [*c]u8, _MaxCount: usize, _Format: [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vsnprintf_c_l(_DstBuf: [*c]u8, _MaxCount: usize, [*c]const u8, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn fopen_s(_File: [*c][*c]FILE, _Filename: [*c]const u8, _Mode: [*c]const u8) errno_t;
pub extern fn freopen_s(_File: [*c][*c]FILE, _Filename: [*c]const u8, _Mode: [*c]const u8, _Stream: [*c]FILE) errno_t;
pub extern fn gets_s([*c]u8, rsize_t) [*c]u8;
pub extern fn tmpnam_s([*c]u8, rsize_t) errno_t;
pub extern fn _getws_s(_Str: [*c]wchar_t, _SizeInWords: usize) [*c]wchar_t;
pub extern fn fwprintf_s(_File: [*c]FILE, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn wprintf_s(_Format: [*c]const wchar_t, ...) c_int;
pub extern fn vfwprintf_s(_File: [*c]FILE, _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn vwprintf_s(_Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn vswprintf_s(_Dst: [*c]wchar_t, _SizeInWords: usize, _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn swprintf_s(_Dst: [*c]wchar_t, _SizeInWords: usize, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vsnwprintf_s(_DstBuf: [*c]wchar_t, _DstSizeInWords: usize, _MaxCount: usize, _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _snwprintf_s(_DstBuf: [*c]wchar_t, _DstSizeInWords: usize, _MaxCount: usize, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _wprintf_s_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vwprintf_s_l(_Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fwprintf_s_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vfwprintf_s_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _swprintf_s_l(_DstBuf: [*c]wchar_t, _DstSize: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vswprintf_s_l(_DstBuf: [*c]wchar_t, _DstSize: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _snwprintf_s_l(_DstBuf: [*c]wchar_t, _DstSize: usize, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vsnwprintf_s_l(_DstBuf: [*c]wchar_t, _DstSize: usize, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fwscanf_s_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn fwscanf_s(_File: [*c]FILE, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _swscanf_s_l(_Src: [*c]const wchar_t, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn swscanf_s(_Src: [*c]const wchar_t, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _snwscanf_s(_Src: [*c]const wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _snwscanf_s_l(_Src: [*c]const wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _wscanf_s_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn wscanf_s(_Format: [*c]const wchar_t, ...) c_int;
pub extern fn _wfopen_s(_File: [*c][*c]FILE, _Filename: [*c]const wchar_t, _Mode: [*c]const wchar_t) errno_t;
pub extern fn _wfreopen_s(_File: [*c][*c]FILE, _Filename: [*c]const wchar_t, _Mode: [*c]const wchar_t, _OldFile: [*c]FILE) errno_t;
pub extern fn _wtmpnam_s(_DstBuf: [*c]wchar_t, _SizeInWords: usize) errno_t;
pub extern fn _fwprintf_p(_File: [*c]FILE, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _wprintf_p(_Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vfwprintf_p(_File: [*c]FILE, _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _vwprintf_p(_Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _swprintf_p(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vswprintf_p(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _scwprintf_p(_Format: [*c]const wchar_t, ...) c_int;
pub extern fn _vscwprintf_p(_Format: [*c]const wchar_t, _ArgList: va_list) c_int;
pub extern fn _wprintf_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _wprintf_p_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vwprintf_l(_Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vwprintf_p_l(_Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fwprintf_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _fwprintf_p_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vfwprintf_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vfwprintf_p_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _swprintf_c_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _swprintf_p_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vswprintf_c_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _vswprintf_p_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _scwprintf_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _scwprintf_p_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vscwprintf_p_l(_Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _snwprintf_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _vsnwprintf_l(_DstBuf: [*c]wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn __swprintf_l(_Dest: [*c]wchar_t, _Format: [*c]const wchar_t, _Plocinfo: _locale_t, ...) c_int;
pub extern fn __vswprintf_l(_Dest: [*c]wchar_t, _Format: [*c]const wchar_t, _Plocinfo: _locale_t, _Args: va_list) c_int;
pub extern fn _vscwprintf_l(_Format: [*c]const wchar_t, _Locale: _locale_t, _ArgList: va_list) c_int;
pub extern fn _fwscanf_l(_File: [*c]FILE, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _swscanf_l(_Src: [*c]const wchar_t, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _snwscanf_l(_Src: [*c]const wchar_t, _MaxCount: usize, _Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub extern fn _wscanf_l(_Format: [*c]const wchar_t, _Locale: _locale_t, ...) c_int;
pub const int_least8_t = i8;
pub const uint_least8_t = u8;
pub const int_least16_t = c_short;
pub const uint_least16_t = c_ushort;
pub const int_least32_t = c_int;
pub const uint_least32_t = c_uint;
pub const int_least64_t = c_longlong;
pub const uint_least64_t = c_ulonglong;
pub const int_fast8_t = i8;
pub const uint_fast8_t = u8;
pub const int_fast16_t = c_short;
pub const uint_fast16_t = c_ushort;
pub const int_fast32_t = c_int;
pub const uint_fast32_t = c_uint;
pub const int_fast64_t = c_longlong;
pub const uint_fast64_t = c_ulonglong;
pub const intmax_t = c_longlong;
pub const uintmax_t = c_ulonglong;
pub const chtype = u64;
pub const attr_t = chtype;
pub const PDC_PORT_X11: c_int = 0;
pub const PDC_PORT_WINCON: c_int = 1;
pub const PDC_PORT_WINGUI: c_int = 2;
pub const PDC_PORT_DOS: c_int = 3;
pub const PDC_PORT_OS2: c_int = 4;
pub const PDC_PORT_SDL1: c_int = 5;
pub const PDC_PORT_SDL2: c_int = 6;
pub const PDC_PORT_VT: c_int = 7;
pub const PDC_PORT_DOSVGA: c_int = 8;
pub const PDC_PORT_PLAN9: c_int = 9;
pub const PDC_PORT_LINUX_FB: c_int = 10;
pub const enum_PDC_port = c_uint;
pub const PDC_VERSION = extern struct {
flags: c_short,
build: c_short,
major: u8,
minor: u8,
change: u8,
csize: u8,
bsize: u8,
port: enum_PDC_port,
};
pub const PDC_VFLAG_DEBUG: c_int = 1;
pub const PDC_VFLAG_WIDE: c_int = 2;
pub const PDC_VFLAG_UTF8: c_int = 4;
pub const PDC_VFLAG_DLL: c_int = 8;
pub const PDC_VFLAG_RGB: c_int = 16;
const enum_unnamed_2 = c_uint;
pub const mmask_t = c_ulong;
pub const MOUSE_STATUS = extern struct {
x: c_int,
y: c_int,
button: [9]c_short,
changes: c_int,
};
pub const MEVENT = extern struct {
id: c_short,
x: c_int,
y: c_int,
z: c_int,
bstate: mmask_t,
};
pub const struct__win = extern struct {
_cury: c_int,
_curx: c_int,
_maxy: c_int,
_maxx: c_int,
_begy: c_int,
_begx: c_int,
_flags: c_int,
_attrs: chtype,
_bkgd: chtype,
_clear: bool,
_leaveit: bool,
_scroll: bool,
_nodelay: bool,
_immed: bool,
_sync: bool,
_use_keypad: bool,
_y: [*c][*c]chtype,
_firstch: [*c]c_int,
_lastch: [*c]c_int,
_tmarg: c_int,
_bmarg: c_int,
_delayms: c_int,
_parx: c_int,
_pary: c_int,
_parent: [*c]struct__win,
};
pub const WINDOW = struct__win;
pub const PDC_PAIR = extern struct {
f: c_int,
b: c_int,
count: c_int,
};
pub const SCREEN = extern struct {
alive: bool,
autocr: bool,
cbreak: bool,
echo: bool,
raw_inp: bool,
raw_out: bool,
audible: bool,
mono: bool,
resized: bool,
orig_attr: bool,
orig_fore: c_short,
orig_back: c_short,
cursrow: c_int,
curscol: c_int,
visibility: c_int,
orig_cursor: c_int,
lines: c_int,
cols: c_int,
_trap_mbe: mmask_t,
mouse_wait: c_int,
slklines: c_int,
slk_winptr: [*c]WINDOW,
linesrippedoff: c_int,
linesrippedoffontop: c_int,
delaytenths: c_int,
_preserve: bool,
_restore: c_int,
key_modifiers: c_ulong,
return_key_modifiers: bool,
unused_key_code: bool,
mouse_status: MOUSE_STATUS,
line_color: c_short,
termattrs: attr_t,
lastscr: [*c]WINDOW,
dbfp: [*c]FILE,
color_started: bool,
dirty: bool,
sel_start: c_int,
sel_end: c_int,
c_buffer: [*c]c_int,
c_pindex: c_int,
c_gindex: c_int,
c_ungch: [*c]c_int,
c_ungind: c_int,
c_ungmax: c_int,
atrtab: [*c]PDC_PAIR,
};
pub extern var LINES: c_int;
pub extern var COLS: c_int;
pub extern var stdscr: [*c]WINDOW;
pub extern var curscr: [*c]WINDOW;
pub extern var SP: [*c]SCREEN;
pub extern var Mouse_status: MOUSE_STATUS;
pub extern var COLORS: c_int;
pub extern var COLOR_PAIRS: c_int;
pub extern var TABSIZE: c_int;
pub extern var acs_map: [*c]chtype;
pub extern var ttytype: [*c]u8;
pub extern fn addch(chtype) c_int;
pub extern fn addchnstr([*c]const chtype, c_int) c_int;
pub extern fn addchstr([*c]const chtype) c_int;
pub extern fn addnstr([*c]const u8, c_int) c_int;
pub extern fn addstr([*c]const u8) c_int;
pub extern fn attroff(chtype) c_int;
pub extern fn attron(chtype) c_int;
pub extern fn attrset(chtype) c_int;
pub extern fn attr_get([*c]attr_t, [*c]c_short, ?*c_void) c_int;
pub extern fn attr_off(attr_t, ?*c_void) c_int;
pub extern fn attr_on(attr_t, ?*c_void) c_int;
pub extern fn attr_set(attr_t, c_short, ?*c_void) c_int;
pub extern fn baudrate() c_int;
pub extern fn beep() c_int;
pub extern fn bkgd(chtype) c_int;
pub extern fn bkgdset(chtype) void;
pub extern fn border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype) c_int;
pub extern fn box([*c]WINDOW, chtype, chtype) c_int;
pub extern fn can_change_color() bool;
pub extern fn cbreak() c_int;
pub extern fn chgat(c_int, attr_t, c_short, ?*const c_void) c_int;
pub extern fn clearok([*c]WINDOW, bool) c_int;
pub extern fn clear() c_int;
pub extern fn clrtobot() c_int;
pub extern fn clrtoeol() c_int;
pub extern fn color_content(c_short, [*c]c_short, [*c]c_short, [*c]c_short) c_int;
pub extern fn color_set(c_short, ?*c_void) c_int;
pub extern fn copywin([*c]const WINDOW, [*c]WINDOW, c_int, c_int, c_int, c_int, c_int, c_int, c_int) c_int;
pub extern fn curs_set(c_int) c_int;
pub extern fn def_prog_mode() c_int;
pub extern fn def_shell_mode() c_int;
pub extern fn delay_output(c_int) c_int;
pub extern fn delch() c_int;
pub extern fn deleteln() c_int;
pub extern fn delscreen([*c]SCREEN) void;
pub extern fn delwin([*c]WINDOW) c_int;
pub extern fn derwin([*c]WINDOW, c_int, c_int, c_int, c_int) [*c]WINDOW;
pub extern fn doupdate() c_int;
pub extern fn dupwin([*c]WINDOW) [*c]WINDOW;
pub extern fn echochar(chtype) c_int;
pub extern fn echo() c_int;
pub extern fn endwin() c_int;
pub extern fn erasechar() u8;
pub extern fn erase() c_int;
pub extern fn extended_color_content(c_int, [*c]c_int, [*c]c_int, [*c]c_int) c_int;
pub extern fn extended_pair_content(c_int, [*c]c_int, [*c]c_int) c_int;
pub extern fn filter() void;
pub extern fn flash() c_int;
pub extern fn flushinp() c_int;
pub extern fn getbkgd([*c]WINDOW) chtype;
pub extern fn getnstr([*c]u8, c_int) c_int;
pub extern fn getstr([*c]u8) c_int;
pub extern fn getwin([*c]FILE) [*c]WINDOW;
pub extern fn halfdelay(c_int) c_int;
pub extern fn has_colors() bool;
pub extern fn has_ic() bool;
pub extern fn has_il() bool;
pub extern fn hline(chtype, c_int) c_int;
pub extern fn idcok([*c]WINDOW, bool) void;
pub extern fn idlok([*c]WINDOW, bool) c_int;
pub extern fn immedok([*c]WINDOW, bool) void;
pub extern fn inchnstr([*c]chtype, c_int) c_int;
pub extern fn inchstr([*c]chtype) c_int;
pub extern fn inch() chtype;
pub extern fn init_color(c_short, c_short, c_short, c_short) c_int;
pub extern fn init_extended_color(c_int, c_int, c_int, c_int) c_int;
pub extern fn init_extended_pair(c_int, c_int, c_int) c_int;
pub extern fn init_pair(c_short, c_short, c_short) c_int;
pub extern fn initscr_x64() [*c]WINDOW;
pub extern fn innstr([*c]u8, c_int) c_int;
pub extern fn insch(chtype) c_int;
pub extern fn insdelln(c_int) c_int;
pub extern fn insertln() c_int;
pub extern fn insnstr([*c]const u8, c_int) c_int;
pub extern fn insstr([*c]const u8) c_int;
pub extern fn instr([*c]u8) c_int;
pub extern fn intrflush([*c]WINDOW, bool) c_int;
pub extern fn isendwin() bool;
pub extern fn is_linetouched([*c]WINDOW, c_int) bool;
pub extern fn is_wintouched([*c]WINDOW) bool;
pub extern fn keyname(c_int) [*c]u8;
pub extern fn keypad([*c]WINDOW, bool) c_int;
pub extern fn killchar() u8;
pub extern fn leaveok([*c]WINDOW, bool) c_int;
pub extern fn longname() [*c]u8;
pub extern fn meta([*c]WINDOW, bool) c_int;
pub extern fn move(c_int, c_int) c_int;
pub extern fn mvaddch(c_int, c_int, chtype) c_int;
pub extern fn mvaddchnstr(c_int, c_int, [*c]const chtype, c_int) c_int;
pub extern fn mvaddchstr(c_int, c_int, [*c]const chtype) c_int;
pub extern fn mvaddnstr(c_int, c_int, [*c]const u8, c_int) c_int;
pub extern fn mvaddstr(c_int, c_int, [*c]const u8) c_int;
pub extern fn mvchgat(c_int, c_int, c_int, attr_t, c_short, ?*const c_void) c_int;
pub extern fn mvcur(c_int, c_int, c_int, c_int) c_int;
pub extern fn mvdelch(c_int, c_int) c_int;
pub extern fn mvderwin([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvgetch(c_int, c_int) c_int;
pub extern fn mvgetnstr(c_int, c_int, [*c]u8, c_int) c_int;
pub extern fn mvgetstr(c_int, c_int, [*c]u8) c_int;
pub extern fn mvhline(c_int, c_int, chtype, c_int) c_int;
pub extern fn mvinch(c_int, c_int) chtype;
pub extern fn mvinchnstr(c_int, c_int, [*c]chtype, c_int) c_int;
pub extern fn mvinchstr(c_int, c_int, [*c]chtype) c_int;
pub extern fn mvinnstr(c_int, c_int, [*c]u8, c_int) c_int;
pub extern fn mvinsch(c_int, c_int, chtype) c_int;
pub extern fn mvinsnstr(c_int, c_int, [*c]const u8, c_int) c_int;
pub extern fn mvinsstr(c_int, c_int, [*c]const u8) c_int;
pub extern fn mvinstr(c_int, c_int, [*c]u8) c_int;
pub extern fn mvprintw(c_int, c_int, [*c]const u8, ...) c_int;
pub extern fn mvscanw(c_int, c_int, [*c]const u8, ...) c_int;
pub extern fn mvvline(c_int, c_int, chtype, c_int) c_int;
pub extern fn mvwaddchnstr([*c]WINDOW, c_int, c_int, [*c]const chtype, c_int) c_int;
pub extern fn mvwaddchstr([*c]WINDOW, c_int, c_int, [*c]const chtype) c_int;
pub extern fn mvwaddch([*c]WINDOW, c_int, c_int, chtype) c_int;
pub extern fn mvwaddnstr([*c]WINDOW, c_int, c_int, [*c]const u8, c_int) c_int;
pub extern fn mvwaddstr([*c]WINDOW, c_int, c_int, [*c]const u8) c_int;
pub extern fn mvwchgat([*c]WINDOW, c_int, c_int, c_int, attr_t, c_short, ?*const c_void) c_int;
pub extern fn mvwdelch([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvwgetch([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvwgetnstr([*c]WINDOW, c_int, c_int, [*c]u8, c_int) c_int;
pub extern fn mvwgetstr([*c]WINDOW, c_int, c_int, [*c]u8) c_int;
pub extern fn mvwhline([*c]WINDOW, c_int, c_int, chtype, c_int) c_int;
pub extern fn mvwinchnstr([*c]WINDOW, c_int, c_int, [*c]chtype, c_int) c_int;
pub extern fn mvwinchstr([*c]WINDOW, c_int, c_int, [*c]chtype) c_int;
pub extern fn mvwinch([*c]WINDOW, c_int, c_int) chtype;
pub extern fn mvwinnstr([*c]WINDOW, c_int, c_int, [*c]u8, c_int) c_int;
pub extern fn mvwinsch([*c]WINDOW, c_int, c_int, chtype) c_int;
pub extern fn mvwinsnstr([*c]WINDOW, c_int, c_int, [*c]const u8, c_int) c_int;
pub extern fn mvwinsstr([*c]WINDOW, c_int, c_int, [*c]const u8) c_int;
pub extern fn mvwinstr([*c]WINDOW, c_int, c_int, [*c]u8) c_int;
pub extern fn mvwin([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvwprintw([*c]WINDOW, c_int, c_int, [*c]const u8, ...) c_int;
pub extern fn mvwscanw([*c]WINDOW, c_int, c_int, [*c]const u8, ...) c_int;
pub extern fn mvwvline([*c]WINDOW, c_int, c_int, chtype, c_int) c_int;
pub extern fn napms(c_int) c_int;
pub extern fn newpad(c_int, c_int) [*c]WINDOW;
pub extern fn newterm([*c]const u8, [*c]FILE, [*c]FILE) [*c]SCREEN;
pub extern fn newwin(c_int, c_int, c_int, c_int) [*c]WINDOW;
pub extern fn nl() c_int;
pub extern fn nocbreak() c_int;
pub extern fn nodelay([*c]WINDOW, bool) c_int;
pub extern fn noecho() c_int;
pub extern fn nonl() c_int;
pub extern fn noqiflush() void;
pub extern fn noraw() c_int;
pub extern fn notimeout([*c]WINDOW, bool) c_int;
pub extern fn overlay([*c]const WINDOW, [*c]WINDOW) c_int;
pub extern fn overwrite([*c]const WINDOW, [*c]WINDOW) c_int;
pub extern fn pair_content(c_short, [*c]c_short, [*c]c_short) c_int;
pub extern fn pechochar([*c]WINDOW, chtype) c_int;
pub extern fn pnoutrefresh([*c]WINDOW, c_int, c_int, c_int, c_int, c_int, c_int) c_int;
pub extern fn prefresh([*c]WINDOW, c_int, c_int, c_int, c_int, c_int, c_int) c_int;
pub extern fn printw([*c]const u8, ...) c_int;
pub extern fn putwin([*c]WINDOW, [*c]FILE) c_int;
pub extern fn qiflush() void;
pub extern fn raw() c_int;
pub extern fn redrawwin([*c]WINDOW) c_int;
pub extern fn refresh() c_int;
pub extern fn reset_prog_mode() c_int;
pub extern fn reset_shell_mode() c_int;
pub extern fn resetty() c_int;
pub extern fn ripoffline(c_int, ?fn ([*c]WINDOW, c_int) callconv(.C) c_int) c_int;
pub extern fn savetty() c_int;
pub extern fn scanw([*c]const u8, ...) c_int;
pub extern fn scr_dump([*c]const u8) c_int;
pub extern fn scr_init([*c]const u8) c_int;
pub extern fn scr_restore([*c]const u8) c_int;
pub extern fn scr_set([*c]const u8) c_int;
pub extern fn scrl(c_int) c_int;
pub extern fn scroll([*c]WINDOW) c_int;
pub extern fn scrollok([*c]WINDOW, bool) c_int;
pub extern fn set_term([*c]SCREEN) [*c]SCREEN;
pub extern fn setscrreg(c_int, c_int) c_int;
pub extern fn slk_attroff(chtype) c_int;
pub extern fn slk_attr_off(attr_t, ?*c_void) c_int;
pub extern fn slk_attron(chtype) c_int;
pub extern fn slk_attr_on(attr_t, ?*c_void) c_int;
pub extern fn slk_attrset(chtype) c_int;
pub extern fn slk_attr_set(attr_t, c_short, ?*c_void) c_int;
pub extern fn slk_clear() c_int;
pub extern fn slk_color(c_short) c_int;
pub extern fn slk_init(c_int) c_int;
pub extern fn slk_label(c_int) [*c]u8;
pub extern fn slk_noutrefresh() c_int;
pub extern fn slk_refresh() c_int;
pub extern fn slk_restore() c_int;
pub extern fn slk_set(c_int, [*c]const u8, c_int) c_int;
pub extern fn slk_touch() c_int;
pub extern fn standend() c_int;
pub extern fn standout() c_int;
pub extern fn start_color() c_int;
pub extern fn subpad([*c]WINDOW, c_int, c_int, c_int, c_int) [*c]WINDOW;
pub extern fn subwin([*c]WINDOW, c_int, c_int, c_int, c_int) [*c]WINDOW;
pub extern fn syncok([*c]WINDOW, bool) c_int;
pub extern fn termattrs() chtype;
pub extern fn term_attrs() attr_t;
pub extern fn termname() [*c]u8;
pub extern fn timeout(c_int) void;
pub extern fn touchline([*c]WINDOW, c_int, c_int) c_int;
pub extern fn touchwin([*c]WINDOW) c_int;
pub extern fn typeahead(c_int) c_int;
pub extern fn untouchwin([*c]WINDOW) c_int;
pub extern fn use_env(bool) void;
pub extern fn vidattr(chtype) c_int;
pub extern fn vid_attr(attr_t, c_short, ?*c_void) c_int;
pub extern fn vidputs(chtype, ?fn (c_int) callconv(.C) c_int) c_int;
pub extern fn vid_puts(attr_t, c_short, ?*c_void, ?fn (c_int) callconv(.C) c_int) c_int;
pub extern fn vline(chtype, c_int) c_int;
pub extern fn vw_printw([*c]WINDOW, [*c]const u8, va_list) c_int;
pub extern fn vwprintw([*c]WINDOW, [*c]const u8, va_list) c_int;
pub extern fn vw_scanw([*c]WINDOW, [*c]const u8, va_list) c_int;
pub extern fn vwscanw([*c]WINDOW, [*c]const u8, va_list) c_int;
pub extern fn waddchnstr([*c]WINDOW, [*c]const chtype, c_int) c_int;
pub extern fn waddchstr([*c]WINDOW, [*c]const chtype) c_int;
pub extern fn waddch([*c]WINDOW, chtype) c_int;
pub extern fn waddnstr([*c]WINDOW, [*c]const u8, c_int) c_int;
pub extern fn waddstr([*c]WINDOW, [*c]const u8) c_int;
pub extern fn wattroff([*c]WINDOW, chtype) c_int;
pub extern fn wattron([*c]WINDOW, chtype) c_int;
pub extern fn wattrset([*c]WINDOW, chtype) c_int;
pub extern fn wattr_get([*c]WINDOW, [*c]attr_t, [*c]c_short, ?*c_void) c_int;
pub extern fn wattr_off([*c]WINDOW, attr_t, ?*c_void) c_int;
pub extern fn wattr_on([*c]WINDOW, attr_t, ?*c_void) c_int;
pub extern fn wattr_set([*c]WINDOW, attr_t, c_short, ?*c_void) c_int;
pub extern fn wbkgdset([*c]WINDOW, chtype) void;
pub extern fn wbkgd([*c]WINDOW, chtype) c_int;
pub extern fn wborder([*c]WINDOW, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype) c_int;
pub extern fn wchgat([*c]WINDOW, c_int, attr_t, c_short, ?*const c_void) c_int;
pub extern fn wclear([*c]WINDOW) c_int;
pub extern fn wclrtobot([*c]WINDOW) c_int;
pub extern fn wclrtoeol([*c]WINDOW) c_int;
pub extern fn wcolor_set([*c]WINDOW, c_short, ?*c_void) c_int;
pub extern fn wcursyncup([*c]WINDOW) void;
pub extern fn wdelch([*c]WINDOW) c_int;
pub extern fn wdeleteln([*c]WINDOW) c_int;
pub extern fn wechochar([*c]WINDOW, chtype) c_int;
pub extern fn werase([*c]WINDOW) c_int;
pub extern fn wgetch([*c]WINDOW) c_int;
pub extern fn wgetnstr([*c]WINDOW, [*c]u8, c_int) c_int;
pub extern fn wgetstr([*c]WINDOW, [*c]u8) c_int;
pub extern fn whline([*c]WINDOW, chtype, c_int) c_int;
pub extern fn winchnstr([*c]WINDOW, [*c]chtype, c_int) c_int;
pub extern fn winchstr([*c]WINDOW, [*c]chtype) c_int;
pub extern fn winch([*c]WINDOW) chtype;
pub extern fn winnstr([*c]WINDOW, [*c]u8, c_int) c_int;
pub extern fn winsch([*c]WINDOW, chtype) c_int;
pub extern fn winsdelln([*c]WINDOW, c_int) c_int;
pub extern fn winsertln([*c]WINDOW) c_int;
pub extern fn winsnstr([*c]WINDOW, [*c]const u8, c_int) c_int;
pub extern fn winsstr([*c]WINDOW, [*c]const u8) c_int;
pub extern fn winstr([*c]WINDOW, [*c]u8) c_int;
pub extern fn wmove([*c]WINDOW, c_int, c_int) c_int;
pub extern fn wnoutrefresh([*c]WINDOW) c_int;
pub extern fn wprintw([*c]WINDOW, [*c]const u8, ...) c_int;
pub extern fn wredrawln([*c]WINDOW, c_int, c_int) c_int;
pub extern fn wrefresh([*c]WINDOW) c_int;
pub extern fn wscanw([*c]WINDOW, [*c]const u8, ...) c_int;
pub extern fn wscrl([*c]WINDOW, c_int) c_int;
pub extern fn wsetscrreg([*c]WINDOW, c_int, c_int) c_int;
pub extern fn wstandend([*c]WINDOW) c_int;
pub extern fn wstandout([*c]WINDOW) c_int;
pub extern fn wsyncdown([*c]WINDOW) void;
pub extern fn wsyncup([*c]WINDOW) void;
pub extern fn wtimeout([*c]WINDOW, c_int) void;
pub extern fn wtouchln([*c]WINDOW, c_int, c_int, c_int) c_int;
pub extern fn wvline([*c]WINDOW, chtype, c_int) c_int;
pub extern fn getattrs([*c]WINDOW) chtype;
pub extern fn getbegx([*c]WINDOW) c_int;
pub extern fn getbegy([*c]WINDOW) c_int;
pub extern fn getmaxx([*c]WINDOW) c_int;
pub extern fn getmaxy([*c]WINDOW) c_int;
pub extern fn getparx([*c]WINDOW) c_int;
pub extern fn getpary([*c]WINDOW) c_int;
pub extern fn getcurx([*c]WINDOW) c_int;
pub extern fn getcury([*c]WINDOW) c_int;
pub extern fn traceoff() void;
pub extern fn traceon() void;
pub extern fn trace(c_uint) void;
pub extern fn curses_trace(c_uint) c_uint;
pub extern fn unctrl(chtype) [*c]u8;
pub extern fn crmode() c_int;
pub extern fn nocrmode() c_int;
pub extern fn draino(c_int) c_int;
pub extern fn resetterm() c_int;
pub extern fn fixterm() c_int;
pub extern fn saveterm() c_int;
pub extern fn setsyx(c_int, c_int) void;
pub extern fn mouse_set(mmask_t) c_int;
pub extern fn mouse_on(mmask_t) c_int;
pub extern fn mouse_off(mmask_t) c_int;
pub extern fn request_mouse_pos() c_int;
pub extern fn wmouse_position([*c]WINDOW, [*c]c_int, [*c]c_int) void;
pub extern fn getmouse() mmask_t;
pub extern fn alloc_pair(c_int, c_int) c_int;
pub extern fn assume_default_colors(c_int, c_int) c_int;
pub extern fn curses_version() [*c]const u8;
pub extern fn find_pair(c_int, c_int) c_int;
pub extern fn free_pair(c_int) c_int;
pub extern fn has_key(c_int) bool;
pub extern fn is_keypad([*c]const WINDOW) bool;
pub extern fn is_leaveok([*c]const WINDOW) bool;
pub extern fn is_pad([*c]const WINDOW) bool;
pub extern fn reset_color_pairs() void;
pub extern fn set_tabsize(c_int) c_int;
pub extern fn use_default_colors() c_int;
pub extern fn wresize([*c]WINDOW, c_int, c_int) c_int;
pub extern fn has_mouse() bool;
pub extern fn mouseinterval(c_int) c_int;
pub extern fn mousemask(mmask_t, [*c]mmask_t) mmask_t;
pub extern fn mouse_trafo([*c]c_int, [*c]c_int, bool) bool;
pub extern fn nc_getmouse([*c]MEVENT) c_int;
pub extern fn ungetmouse([*c]MEVENT) c_int;
pub extern fn wenclose([*c]const WINDOW, c_int, c_int) bool;
pub extern fn wmouse_trafo([*c]const WINDOW, [*c]c_int, [*c]c_int, bool) bool;
pub extern fn addrawch(chtype) c_int;
pub extern fn insrawch(chtype) c_int;
pub extern fn is_termresized() bool;
pub extern fn mvaddrawch(c_int, c_int, chtype) c_int;
pub extern fn mvdeleteln(c_int, c_int) c_int;
pub extern fn mvinsertln(c_int, c_int) c_int;
pub extern fn mvinsrawch(c_int, c_int, chtype) c_int;
pub extern fn mvwaddrawch([*c]WINDOW, c_int, c_int, chtype) c_int;
pub extern fn mvwdeleteln([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvwinsertln([*c]WINDOW, c_int, c_int) c_int;
pub extern fn mvwinsrawch([*c]WINDOW, c_int, c_int, chtype) c_int;
pub extern fn raw_output(bool) c_int;
pub extern fn resize_term(c_int, c_int) c_int;
pub extern fn resize_window([*c]WINDOW, c_int, c_int) [*c]WINDOW;
pub extern fn waddrawch([*c]WINDOW, chtype) c_int;
pub extern fn winsrawch([*c]WINDOW, chtype) c_int;
pub extern fn wordchar() u8;
pub extern fn PDC_debug([*c]const u8, ...) void;
pub extern fn _tracef([*c]const u8, ...) void;
pub extern fn PDC_get_version([*c]PDC_VERSION) void;
pub extern fn PDC_ungetch(c_int) c_int;
pub extern fn PDC_set_blink(bool) c_int;
pub extern fn PDC_set_bold(bool) c_int;
pub extern fn PDC_set_line_color(c_short) c_int;
pub extern fn PDC_set_title([*c]const u8) void;
pub extern fn PDC_set_box_type(box_type: c_int) c_int;
pub extern fn PDC_clearclipboard() c_int;
pub extern fn PDC_freeclipboard([*c]u8) c_int;
pub extern fn PDC_getclipboard([*c][*c]u8, [*c]c_long) c_int;
pub extern fn PDC_setclipboard([*c]const u8, c_long) c_int;
pub extern fn PDC_get_key_modifiers() c_ulong;
pub extern fn PDC_return_key_modifiers(bool) c_int;
pub extern fn PDC_set_resize_limits(new_min_lines: c_int, new_max_lines: c_int, new_min_cols: c_int, new_max_cols: c_int) void;
pub extern fn PDC_set_function_key(function: c_uint, new_key: c_int) c_int;
pub extern fn Xinitscr(c_int, [*c][*c]u8) [*c]WINDOW;
pub extern fn touchoverlap([*c]const WINDOW, [*c]WINDOW) c_int;
pub extern fn underend() c_int;
pub extern fn underscore() c_int;
pub extern fn wunderend([*c]WINDOW) c_int;
pub extern fn wunderscore([*c]WINDOW) c_int;
pub const PDC_STRINGIZE = @compileError("unable to translate C expr: unexpected token .Hash"); // ..\git\PDCursesMod\curses.h:45:9
pub const PDC_VERDOT = @compileError("unable to translate C expr: unexpected token .StringLiteral"); // ..\git\PDCursesMod\curses.h:48:9
pub const PDC_VER_YMD = @compileError("unable to translate C expr: unexpected token .StringLiteral"); // ..\git\PDCursesMod\curses.h:52:9
pub const va_start = @compileError("TODO implement function '__builtin_va_start' in std.zig.c_builtins"); // C:\Zig\lib\include\stdarg.h:17:9
pub const va_end = @compileError("TODO implement function '__builtin_va_end' in std.zig.c_builtins"); // C:\Zig\lib\include\stdarg.h:18:9
pub const va_arg = @compileError("TODO implement function '__builtin_va_arg' in std.zig.c_builtins"); // C:\Zig\lib\include\stdarg.h:19:9
pub const __va_copy = @compileError("TODO implement function '__builtin_va_copy' in std.zig.c_builtins"); // C:\Zig\lib\include\stdarg.h:24:9
pub const va_copy = @compileError("TODO implement function '__builtin_va_copy' in std.zig.c_builtins"); // C:\Zig\lib\include\stdarg.h:27:9
pub const offsetof = @compileError("TODO implement function '__builtin_offsetof' in std.zig.c_builtins"); // C:\Zig\lib\include\stddef.h:104:9
pub const __STRINGIFY = @compileError("unable to translate C expr: unexpected token .Hash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:10:9
pub const __MINGW64_VERSION_STR = @compileError("unable to translate C expr: unexpected token .StringLiteral"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:26:9
pub const __MINGW_IMP_SYMBOL = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:119:11
pub const __MINGW_IMP_LSYMBOL = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:120:11
pub const __MINGW_LSYMBOL = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:122:11
pub const __MINGW_POISON_NAME = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:203:11
pub const __MSABI_LONG = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:209:13
pub const __MINGW_ATTRIB_DEPRECATED_STR = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:247:11
pub const __mingw_ovr = @compileError("unable to translate C expr: unexpected token .Keyword_static"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_mac.h:289:11
pub const __MINGW_CRT_NAME_CONCAT2 = @compileError("unable to translate C expr: unexpected token .Colon"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_secapi.h:41:9
pub const __CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY_0_3_ = @compileError("unable to translate C expr: unexpected token .Identifier"); // C:\Zig\lib\libc\include\any-windows-any/_mingw_secapi.h:69:9
pub const __MINGW_IMPORT = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:51:12
pub const __CRT_INLINE = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:90:11
pub const __MINGW_INTRIN_INLINE = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:97:9
pub const __MINGW_PRAGMA_PARAM = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:215:9
pub const __MINGW_BROKEN_INTERFACE = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:218:9
pub const __forceinline = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:267:9
pub const _crt_va_start = @compileError("TODO implement function '__builtin_va_start' in std.zig.c_builtins"); // C:\Zig\lib\libc\include\any-windows-any\vadefs.h:48:9
pub const _crt_va_arg = @compileError("TODO implement function '__builtin_va_arg' in std.zig.c_builtins"); // C:\Zig\lib\libc\include\any-windows-any\vadefs.h:49:9
pub const _crt_va_end = @compileError("TODO implement function '__builtin_va_end' in std.zig.c_builtins"); // C:\Zig\lib\libc\include\any-windows-any\vadefs.h:50:9
pub const _crt_va_copy = @compileError("TODO implement function '__builtin_va_copy' in std.zig.c_builtins"); // C:\Zig\lib\libc\include\any-windows-any\vadefs.h:51:9
pub const __CRT_STRINGIZE = @compileError("unable to translate C expr: unexpected token .Hash"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:286:9
pub const __CRT_WIDE = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:291:9
pub const _CRT_INSECURE_DEPRECATE_MEMORY = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:353:9
pub const _CRT_INSECURE_DEPRECATE_GLOBALS = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:357:9
pub const _CRT_OBSOLETE = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:365:9
pub const _UNION_NAME = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:476:9
pub const _STRUCT_NAME = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:477:9
pub const __CRT_UUID_DECL = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\_mingw.h:564:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:267:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:268:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:269:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:270:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:271:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:272:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:273:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:274:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:275:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:276:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:277:9
pub const __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:278:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0 = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:282:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:284:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:286:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:288:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:290:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_EX = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:427:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:428:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_EX = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:429:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_EX = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:430:9
pub const __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4_EX = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:431:9
pub const __crt_typefix = @compileError("unable to translate C expr: unexpected token .Eof"); // C:\Zig\lib\libc\include\any-windows-any\corecrt.h:491:9
pub const _fgetc_nolock = @compileError("TODO unary inc/dec expr"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1432:9
pub const _fputc_nolock = @compileError("TODO unary inc/dec expr"); // C:\Zig\lib\libc\include\any-windows-any\stdio.h:1433:9
pub const INT64_C = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any\stdint.h:198:9
pub const UINT64_C = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any\stdint.h:203:9
pub const INTMAX_C = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any\stdint.h:206:9
pub const UINTMAX_C = @compileError("unable to translate C expr: unexpected token .HashHash"); // C:\Zig\lib\libc\include\any-windows-any\stdint.h:207:9
pub const PDCEX = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // ..\git\PDCursesMod\curses.h:445:10
pub const getbegyx = @compileError("unable to translate C expr: expected ')' instead got: Equal"); // ..\git\PDCursesMod\curses.h:1747:9
pub const getmaxyx = @compileError("unable to translate C expr: expected ')' instead got: Equal"); // ..\git\PDCursesMod\curses.h:1748:9
pub const getparyx = @compileError("unable to translate C expr: expected ')' instead got: Equal"); // ..\git\PDCursesMod\curses.h:1749:9
pub const getyx = @compileError("unable to translate C expr: expected ')' instead got: Equal"); // ..\git\PDCursesMod\curses.h:1750:9
pub const getsyx = @compileError("unable to translate C expr: unexpected token .LBrace"); // ..\git\PDCursesMod\curses.h:1752:9
pub const __llvm__ = @as(c_int, 1);
pub const __clang__ = @as(c_int, 1);
pub const __clang_major__ = @as(c_int, 12);
pub const __clang_minor__ = @as(c_int, 0);
pub const __clang_patchlevel__ = @as(c_int, 1);
pub const __clang_version__ = "12.0.1 (https://github.com/llvm/llvm-project 328a6ec955327c6d56b6bc3478c723dd3cd468ef)";
pub const __GNUC__ = @as(c_int, 4);
pub const __GNUC_MINOR__ = @as(c_int, 2);
pub const __GNUC_PATCHLEVEL__ = @as(c_int, 1);
pub const __GXX_ABI_VERSION = @as(c_int, 1002);
pub const __ATOMIC_RELAXED = @as(c_int, 0);
pub const __ATOMIC_CONSUME = @as(c_int, 1);
pub const __ATOMIC_ACQUIRE = @as(c_int, 2);
pub const __ATOMIC_RELEASE = @as(c_int, 3);
pub const __ATOMIC_ACQ_REL = @as(c_int, 4);
pub const __ATOMIC_SEQ_CST = @as(c_int, 5);
pub const __OPENCL_MEMORY_SCOPE_WORK_ITEM = @as(c_int, 0);
pub const __OPENCL_MEMORY_SCOPE_WORK_GROUP = @as(c_int, 1);
pub const __OPENCL_MEMORY_SCOPE_DEVICE = @as(c_int, 2);
pub const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = @as(c_int, 3);
pub const __OPENCL_MEMORY_SCOPE_SUB_GROUP = @as(c_int, 4);
pub const __PRAGMA_REDEFINE_EXTNAME = @as(c_int, 1);
pub const __VERSION__ = "Clang 12.0.1 (https://github.com/llvm/llvm-project 328a6ec955327c6d56b6bc3478c723dd3cd468ef)";
pub const __OBJC_BOOL_IS_BOOL = @as(c_int, 0);
pub const __CONSTANT_CFSTRINGS__ = @as(c_int, 1);
pub const __SEH__ = @as(c_int, 1);
pub const __OPTIMIZE__ = @as(c_int, 1);
pub const __ORDER_LITTLE_ENDIAN__ = @as(c_int, 1234);
pub const __ORDER_BIG_ENDIAN__ = @as(c_int, 4321);
pub const __ORDER_PDP_ENDIAN__ = @as(c_int, 3412);
pub const __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__;
pub const __LITTLE_ENDIAN__ = @as(c_int, 1);
pub const __CHAR_BIT__ = @as(c_int, 8);
pub const __SCHAR_MAX__ = @as(c_int, 127);
pub const __SHRT_MAX__ = @as(c_int, 32767);
pub const __INT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __LONG_MAX__ = @as(c_long, 2147483647);
pub const __LONG_LONG_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __WCHAR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __WINT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __INTMAX_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __SIZE_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __UINTMAX_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __PTRDIFF_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INTPTR_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __UINTPTR_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __SIZEOF_DOUBLE__ = @as(c_int, 8);
pub const __SIZEOF_FLOAT__ = @as(c_int, 4);
pub const __SIZEOF_INT__ = @as(c_int, 4);
pub const __SIZEOF_LONG__ = @as(c_int, 4);
pub const __SIZEOF_LONG_DOUBLE__ = @as(c_int, 16);
pub const __SIZEOF_LONG_LONG__ = @as(c_int, 8);
pub const __SIZEOF_POINTER__ = @as(c_int, 8);
pub const __SIZEOF_SHORT__ = @as(c_int, 2);
pub const __SIZEOF_PTRDIFF_T__ = @as(c_int, 8);
pub const __SIZEOF_SIZE_T__ = @as(c_int, 8);
pub const __SIZEOF_WCHAR_T__ = @as(c_int, 2);
pub const __SIZEOF_WINT_T__ = @as(c_int, 2);
pub const __SIZEOF_INT128__ = @as(c_int, 16);
pub const __INTMAX_TYPE__ = c_longlong;
pub const __INTMAX_FMTd__ = "lld";
pub const __INTMAX_FMTi__ = "lli";
pub const __INTMAX_C_SUFFIX__ = LL;
pub const __UINTMAX_TYPE__ = c_ulonglong;
pub const __UINTMAX_FMTo__ = "llo";
pub const __UINTMAX_FMTu__ = "llu";
pub const __UINTMAX_FMTx__ = "llx";
pub const __UINTMAX_FMTX__ = "llX";
pub const __UINTMAX_C_SUFFIX__ = ULL;
pub const __INTMAX_WIDTH__ = @as(c_int, 64);
pub const __PTRDIFF_TYPE__ = c_longlong;
pub const __PTRDIFF_FMTd__ = "lld";
pub const __PTRDIFF_FMTi__ = "lli";
pub const __PTRDIFF_WIDTH__ = @as(c_int, 64);
pub const __INTPTR_TYPE__ = c_longlong;
pub const __INTPTR_FMTd__ = "lld";
pub const __INTPTR_FMTi__ = "lli";
pub const __INTPTR_WIDTH__ = @as(c_int, 64);
pub const __SIZE_TYPE__ = c_ulonglong;
pub const __SIZE_FMTo__ = "llo";
pub const __SIZE_FMTu__ = "llu";
pub const __SIZE_FMTx__ = "llx";
pub const __SIZE_FMTX__ = "llX";
pub const __SIZE_WIDTH__ = @as(c_int, 64);
pub const __WCHAR_TYPE__ = c_ushort;
pub const __WCHAR_WIDTH__ = @as(c_int, 16);
pub const __WINT_TYPE__ = c_ushort;
pub const __WINT_WIDTH__ = @as(c_int, 16);
pub const __SIG_ATOMIC_WIDTH__ = @as(c_int, 32);
pub const __SIG_ATOMIC_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __CHAR16_TYPE__ = c_ushort;
pub const __CHAR32_TYPE__ = c_uint;
pub const __UINTMAX_WIDTH__ = @as(c_int, 64);
pub const __UINTPTR_TYPE__ = c_ulonglong;
pub const __UINTPTR_FMTo__ = "llo";
pub const __UINTPTR_FMTu__ = "llu";
pub const __UINTPTR_FMTx__ = "llx";
pub const __UINTPTR_FMTX__ = "llX";
pub const __UINTPTR_WIDTH__ = @as(c_int, 64);
pub const __FLT_DENORM_MIN__ = @as(f32, 1.40129846e-45);
pub const __FLT_HAS_DENORM__ = @as(c_int, 1);
pub const __FLT_DIG__ = @as(c_int, 6);
pub const __FLT_DECIMAL_DIG__ = @as(c_int, 9);
pub const __FLT_EPSILON__ = @as(f32, 1.19209290e-7);
pub const __FLT_HAS_INFINITY__ = @as(c_int, 1);
pub const __FLT_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __FLT_MANT_DIG__ = @as(c_int, 24);
pub const __FLT_MAX_10_EXP__ = @as(c_int, 38);
pub const __FLT_MAX_EXP__ = @as(c_int, 128);
pub const __FLT_MAX__ = @as(f32, 3.40282347e+38);
pub const __FLT_MIN_10_EXP__ = -@as(c_int, 37);
pub const __FLT_MIN_EXP__ = -@as(c_int, 125);
pub const __FLT_MIN__ = @as(f32, 1.17549435e-38);
pub const __DBL_DENORM_MIN__ = 4.9406564584124654e-324;
pub const __DBL_HAS_DENORM__ = @as(c_int, 1);
pub const __DBL_DIG__ = @as(c_int, 15);
pub const __DBL_DECIMAL_DIG__ = @as(c_int, 17);
pub const __DBL_EPSILON__ = 2.2204460492503131e-16;
pub const __DBL_HAS_INFINITY__ = @as(c_int, 1);
pub const __DBL_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __DBL_MANT_DIG__ = @as(c_int, 53);
pub const __DBL_MAX_10_EXP__ = @as(c_int, 308);
pub const __DBL_MAX_EXP__ = @as(c_int, 1024);
pub const __DBL_MAX__ = 1.7976931348623157e+308;
pub const __DBL_MIN_10_EXP__ = -@as(c_int, 307);
pub const __DBL_MIN_EXP__ = -@as(c_int, 1021);
pub const __DBL_MIN__ = 2.2250738585072014e-308;
pub const __LDBL_DENORM_MIN__ = @as(c_longdouble, 3.64519953188247460253e-4951);
pub const __LDBL_HAS_DENORM__ = @as(c_int, 1);
pub const __LDBL_DIG__ = @as(c_int, 18);
pub const __LDBL_DECIMAL_DIG__ = @as(c_int, 21);
pub const __LDBL_EPSILON__ = @as(c_longdouble, 1.08420217248550443401e-19);
pub const __LDBL_HAS_INFINITY__ = @as(c_int, 1);
pub const __LDBL_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __LDBL_MANT_DIG__ = @as(c_int, 64);
pub const __LDBL_MAX_10_EXP__ = @as(c_int, 4932);
pub const __LDBL_MAX_EXP__ = @as(c_int, 16384);
pub const __LDBL_MAX__ = @as(c_longdouble, 1.18973149535723176502e+4932);
pub const __LDBL_MIN_10_EXP__ = -@as(c_int, 4931);
pub const __LDBL_MIN_EXP__ = -@as(c_int, 16381);
pub const __LDBL_MIN__ = @as(c_longdouble, 3.36210314311209350626e-4932);
pub const __POINTER_WIDTH__ = @as(c_int, 64);
pub const __BIGGEST_ALIGNMENT__ = @as(c_int, 16);
pub const __WCHAR_UNSIGNED__ = @as(c_int, 1);
pub const __WINT_UNSIGNED__ = @as(c_int, 1);
pub const __INT8_TYPE__ = i8;
pub const __INT8_FMTd__ = "hhd";
pub const __INT8_FMTi__ = "hhi";
pub const __INT16_TYPE__ = c_short;
pub const __INT16_FMTd__ = "hd";
pub const __INT16_FMTi__ = "hi";
pub const __INT32_TYPE__ = c_int;
pub const __INT32_FMTd__ = "d";
pub const __INT32_FMTi__ = "i";
pub const __INT64_TYPE__ = c_longlong;
pub const __INT64_FMTd__ = "lld";
pub const __INT64_FMTi__ = "lli";
pub const __INT64_C_SUFFIX__ = LL;
pub const __UINT8_TYPE__ = u8;
pub const __UINT8_FMTo__ = "hho";
pub const __UINT8_FMTu__ = "hhu";
pub const __UINT8_FMTx__ = "hhx";
pub const __UINT8_FMTX__ = "hhX";
pub const __UINT8_MAX__ = @as(c_int, 255);
pub const __INT8_MAX__ = @as(c_int, 127);
pub const __UINT16_TYPE__ = c_ushort;
pub const __UINT16_FMTo__ = "ho";
pub const __UINT16_FMTu__ = "hu";
pub const __UINT16_FMTx__ = "hx";
pub const __UINT16_FMTX__ = "hX";
pub const __UINT16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __INT16_MAX__ = @as(c_int, 32767);
pub const __UINT32_TYPE__ = c_uint;
pub const __UINT32_FMTo__ = "o";
pub const __UINT32_FMTu__ = "u";
pub const __UINT32_FMTx__ = "x";
pub const __UINT32_FMTX__ = "X";
pub const __UINT32_C_SUFFIX__ = U;
pub const __UINT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __INT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __UINT64_TYPE__ = c_ulonglong;
pub const __UINT64_FMTo__ = "llo";
pub const __UINT64_FMTu__ = "llu";
pub const __UINT64_FMTx__ = "llx";
pub const __UINT64_FMTX__ = "llX";
pub const __UINT64_C_SUFFIX__ = ULL;
pub const __UINT64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __INT64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_LEAST8_TYPE__ = i8;
pub const __INT_LEAST8_MAX__ = @as(c_int, 127);
pub const __INT_LEAST8_FMTd__ = "hhd";
pub const __INT_LEAST8_FMTi__ = "hhi";
pub const __UINT_LEAST8_TYPE__ = u8;
pub const __UINT_LEAST8_MAX__ = @as(c_int, 255);
pub const __UINT_LEAST8_FMTo__ = "hho";
pub const __UINT_LEAST8_FMTu__ = "hhu";
pub const __UINT_LEAST8_FMTx__ = "hhx";
pub const __UINT_LEAST8_FMTX__ = "hhX";
pub const __INT_LEAST16_TYPE__ = c_short;
pub const __INT_LEAST16_MAX__ = @as(c_int, 32767);
pub const __INT_LEAST16_FMTd__ = "hd";
pub const __INT_LEAST16_FMTi__ = "hi";
pub const __UINT_LEAST16_TYPE__ = c_ushort;
pub const __UINT_LEAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __UINT_LEAST16_FMTo__ = "ho";
pub const __UINT_LEAST16_FMTu__ = "hu";
pub const __UINT_LEAST16_FMTx__ = "hx";
pub const __UINT_LEAST16_FMTX__ = "hX";
pub const __INT_LEAST32_TYPE__ = c_int;
pub const __INT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __INT_LEAST32_FMTd__ = "d";
pub const __INT_LEAST32_FMTi__ = "i";
pub const __UINT_LEAST32_TYPE__ = c_uint;
pub const __UINT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __UINT_LEAST32_FMTo__ = "o";
pub const __UINT_LEAST32_FMTu__ = "u";
pub const __UINT_LEAST32_FMTx__ = "x";
pub const __UINT_LEAST32_FMTX__ = "X";
pub const __INT_LEAST64_TYPE__ = c_longlong;
pub const __INT_LEAST64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_LEAST64_FMTd__ = "lld";
pub const __INT_LEAST64_FMTi__ = "lli";
pub const __UINT_LEAST64_TYPE__ = c_ulonglong;
pub const __UINT_LEAST64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __UINT_LEAST64_FMTo__ = "llo";
pub const __UINT_LEAST64_FMTu__ = "llu";
pub const __UINT_LEAST64_FMTx__ = "llx";
pub const __UINT_LEAST64_FMTX__ = "llX";
pub const __INT_FAST8_TYPE__ = i8;
pub const __INT_FAST8_MAX__ = @as(c_int, 127);
pub const __INT_FAST8_FMTd__ = "hhd";
pub const __INT_FAST8_FMTi__ = "hhi";
pub const __UINT_FAST8_TYPE__ = u8;
pub const __UINT_FAST8_MAX__ = @as(c_int, 255);
pub const __UINT_FAST8_FMTo__ = "hho";
pub const __UINT_FAST8_FMTu__ = "hhu";
pub const __UINT_FAST8_FMTx__ = "hhx";
pub const __UINT_FAST8_FMTX__ = "hhX";
pub const __INT_FAST16_TYPE__ = c_short;
pub const __INT_FAST16_MAX__ = @as(c_int, 32767);
pub const __INT_FAST16_FMTd__ = "hd";
pub const __INT_FAST16_FMTi__ = "hi";
pub const __UINT_FAST16_TYPE__ = c_ushort;
pub const __UINT_FAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __UINT_FAST16_FMTo__ = "ho";
pub const __UINT_FAST16_FMTu__ = "hu";
pub const __UINT_FAST16_FMTx__ = "hx";
pub const __UINT_FAST16_FMTX__ = "hX";
pub const __INT_FAST32_TYPE__ = c_int;
pub const __INT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __INT_FAST32_FMTd__ = "d";
pub const __INT_FAST32_FMTi__ = "i";
pub const __UINT_FAST32_TYPE__ = c_uint;
pub const __UINT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __UINT_FAST32_FMTo__ = "o";
pub const __UINT_FAST32_FMTu__ = "u";
pub const __UINT_FAST32_FMTx__ = "x";
pub const __UINT_FAST32_FMTX__ = "X";
pub const __INT_FAST64_TYPE__ = c_longlong;
pub const __INT_FAST64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_FAST64_FMTd__ = "lld";
pub const __INT_FAST64_FMTi__ = "lli";
pub const __UINT_FAST64_TYPE__ = c_ulonglong;
pub const __UINT_FAST64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __UINT_FAST64_FMTo__ = "llo";
pub const __UINT_FAST64_FMTu__ = "llu";
pub const __UINT_FAST64_FMTx__ = "llx";
pub const __UINT_FAST64_FMTX__ = "llX";
pub const __FINITE_MATH_ONLY__ = @as(c_int, 0);
pub const __GNUC_STDC_INLINE__ = @as(c_int, 1);
pub const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = @as(c_int, 1);
pub const __CLANG_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_INT_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_INT_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2);
pub const __PIC__ = @as(c_int, 2);
pub const __pic__ = @as(c_int, 2);
pub const __FLT_EVAL_METHOD__ = @as(c_int, 0);
pub const __FLT_RADIX__ = @as(c_int, 2);
pub const __DECIMAL_DIG__ = __LDBL_DECIMAL_DIG__;
pub const __SSP_STRONG__ = @as(c_int, 2);
pub const __GCC_ASM_FLAG_OUTPUTS__ = @as(c_int, 1);
pub const __code_model_small__ = @as(c_int, 1);
pub const __amd64__ = @as(c_int, 1);
pub const __amd64 = @as(c_int, 1);
pub const __x86_64 = @as(c_int, 1);
pub const __x86_64__ = @as(c_int, 1);
pub const __SEG_GS = @as(c_int, 1);
pub const __SEG_FS = @as(c_int, 1);
pub const __seg_gs = __attribute__(address_space(@as(c_int, 256)));
pub const __seg_fs = __attribute__(address_space(@as(c_int, 257)));
pub const __corei7 = @as(c_int, 1);
pub const __corei7__ = @as(c_int, 1);
pub const __tune_corei7__ = @as(c_int, 1);
pub const __NO_MATH_INLINES = @as(c_int, 1);
pub const __AES__ = @as(c_int, 1);
pub const __PCLMUL__ = @as(c_int, 1);
pub const __LAHF_SAHF__ = @as(c_int, 1);
pub const __LZCNT__ = @as(c_int, 1);
pub const __RDRND__ = @as(c_int, 1);
pub const __FSGSBASE__ = @as(c_int, 1);
pub const __BMI__ = @as(c_int, 1);
pub const __BMI2__ = @as(c_int, 1);
pub const __POPCNT__ = @as(c_int, 1);
pub const __RTM__ = @as(c_int, 1);
pub const __PRFCHW__ = @as(c_int, 1);
pub const __RDSEED__ = @as(c_int, 1);
pub const __ADX__ = @as(c_int, 1);
pub const __MOVBE__ = @as(c_int, 1);
pub const __FMA__ = @as(c_int, 1);
pub const __F16C__ = @as(c_int, 1);
pub const __FXSR__ = @as(c_int, 1);
pub const __XSAVE__ = @as(c_int, 1);
pub const __XSAVEOPT__ = @as(c_int, 1);
pub const __XSAVEC__ = @as(c_int, 1);
pub const __XSAVES__ = @as(c_int, 1);
pub const __CLFLUSHOPT__ = @as(c_int, 1);
pub const __SGX__ = @as(c_int, 1);
pub const __INVPCID__ = @as(c_int, 1);
pub const __AVX2__ = @as(c_int, 1);
pub const __AVX__ = @as(c_int, 1);
pub const __SSE4_2__ = @as(c_int, 1);
pub const __SSE4_1__ = @as(c_int, 1);
pub const __SSSE3__ = @as(c_int, 1);
pub const __SSE3__ = @as(c_int, 1);
pub const __SSE2__ = @as(c_int, 1);
pub const __SSE2_MATH__ = @as(c_int, 1);
pub const __SSE__ = @as(c_int, 1);
pub const __SSE_MATH__ = @as(c_int, 1);
pub const __MMX__ = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = @as(c_int, 1);
pub const __SIZEOF_FLOAT128__ = @as(c_int, 16);
pub const _WIN32 = @as(c_int, 1);
pub const _WIN64 = @as(c_int, 1);
pub const WIN32 = @as(c_int, 1);
pub const __WIN32 = @as(c_int, 1);
pub const __WIN32__ = @as(c_int, 1);
pub const WINNT = @as(c_int, 1);
pub const __WINNT = @as(c_int, 1);
pub const __WINNT__ = @as(c_int, 1);
pub const WIN64 = @as(c_int, 1);
pub const __WIN64 = @as(c_int, 1);
pub const __WIN64__ = @as(c_int, 1);
pub const __MINGW64__ = @as(c_int, 1);
pub const __MSVCRT__ = @as(c_int, 1);
pub const __MINGW32__ = @as(c_int, 1);
pub inline fn __declspec(a: anytype) @TypeOf(__attribute__(a)) {
return __attribute__(a);
}
pub const _cdecl = __attribute__(__cdecl__);
pub const __cdecl = __attribute__(__cdecl__);
pub const _stdcall = __attribute__(__stdcall__);
pub const __stdcall = __attribute__(__stdcall__);
pub const _fastcall = __attribute__(__fastcall__);
pub const __fastcall = __attribute__(__fastcall__);
pub const _thiscall = __attribute__(__thiscall__);
pub const __thiscall = __attribute__(__thiscall__);
pub const _pascal = __attribute__(__pascal__);
pub const __pascal = __attribute__(__pascal__);
pub const __STDC__ = @as(c_int, 1);
pub const __STDC_HOSTED__ = @as(c_int, 1);
pub const __STDC_VERSION__ = @as(c_long, 201710);
pub const __STDC_UTF_16__ = @as(c_int, 1);
pub const __STDC_UTF_32__ = @as(c_int, 1);
pub const _DEBUG = @as(c_int, 1);
pub const __PDCURSES__ = @as(c_int, 1);
pub const __PDCURSESMOD__ = @as(c_int, 1);
pub const PDCURSES = @as(c_int, 1);
pub const PDC_BUILD = ((PDC_VER_MAJOR * @as(c_int, 1000)) + (PDC_VER_MINOR * @as(c_int, 100))) + PDC_VER_CHANGE;
pub const PDC_VER_MAJOR = @as(c_int, 4);
pub const PDC_VER_MINOR = @as(c_int, 3);
pub const PDC_VER_CHANGE = @as(c_int, 0);
pub const PDC_VER_YEAR = @as(c_int, 2021);
pub const PDC_VER_MONTH = @as(c_int, 9);
pub const PDC_VER_DAY = @as(c_int, 19);
pub inline fn PDC_stringize(x: anytype) @TypeOf(PDC_STRINGIZE(x)) {
return PDC_STRINGIZE(x);
}
pub const PDC_99 = @as(c_int, 1);
pub const __GNUC_VA_LIST = @as(c_int, 1);
pub const NULL = @import("std").zig.c_translation.cast(?*c_void, @as(c_int, 0));
pub inline fn __MINGW64_STRINGIFY(x: anytype) @TypeOf(__STRINGIFY(x)) {
return __STRINGIFY(x);
}
pub const __MINGW64_VERSION_MAJOR = @as(c_int, 9);
pub const __MINGW64_VERSION_MINOR = @as(c_int, 0);
pub const __MINGW64_VERSION_BUGFIX = @as(c_int, 0);
pub const __MINGW64_VERSION_RC = @as(c_int, 0);
pub const __MINGW64_VERSION_STATE = "alpha";
pub const __MINGW32_MAJOR_VERSION = @as(c_int, 3);
pub const __MINGW32_MINOR_VERSION = @as(c_int, 11);
pub const _M_AMD64 = @as(c_int, 100);
pub const _M_X64 = @as(c_int, 100);
pub const @"_" = @as(c_int, 1);
pub const __MINGW_USE_UNDERSCORE_PREFIX = @as(c_int, 0);
pub inline fn __MINGW_USYMBOL(sym: anytype) @TypeOf(sym) {
return sym;
}
pub inline fn __MINGW_ASM_CALL(func: anytype) @TypeOf(__asm__(__MINGW64_STRINGIFY(__MINGW_USYMBOL(func)))) {
return __asm__(__MINGW64_STRINGIFY(__MINGW_USYMBOL(func)));
}
pub inline fn __MINGW_ASM_CRT_CALL(func: anytype) @TypeOf(__asm__(__STRINGIFY(func))) {
return __asm__(__STRINGIFY(func));
}
pub const __MINGW_EXTENSION = __extension__;
pub const __C89_NAMELESS = __MINGW_EXTENSION;
pub const __GNU_EXTENSION = __MINGW_EXTENSION;
pub const __MINGW_HAVE_ANSI_C99_PRINTF = @as(c_int, 1);
pub const __MINGW_HAVE_WIDE_C99_PRINTF = @as(c_int, 1);
pub const __MINGW_HAVE_ANSI_C99_SCANF = @as(c_int, 1);
pub const __MINGW_HAVE_WIDE_C99_SCANF = @as(c_int, 1);
pub const __MINGW_GCC_VERSION = ((__GNUC__ * @as(c_int, 10000)) + (__GNUC_MINOR__ * @as(c_int, 100))) + __GNUC_PATCHLEVEL__;
pub inline fn __MINGW_GNUC_PREREQ(major: anytype, minor: anytype) @TypeOf((__GNUC__ > major) or ((__GNUC__ == major) and (__GNUC_MINOR__ >= minor))) {
return (__GNUC__ > major) or ((__GNUC__ == major) and (__GNUC_MINOR__ >= minor));
}
pub inline fn __MINGW_MSC_PREREQ(major: anytype, minor: anytype) @TypeOf(@as(c_int, 0)) {
_ = major;
_ = minor;
return @as(c_int, 0);
}
pub const __MINGW_SEC_WARN_STR = "This function or variable may be unsafe, use _CRT_SECURE_NO_WARNINGS to disable deprecation";
pub const __MINGW_MSVC2005_DEPREC_STR = "This POSIX function is deprecated beginning in Visual C++ 2005, use _CRT_NONSTDC_NO_DEPRECATE to disable deprecation";
pub const __MINGW_ATTRIB_DEPRECATED_MSVC2005 = __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_MSVC2005_DEPREC_STR);
pub const __MINGW_ATTRIB_DEPRECATED_SEC_WARN = __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_SEC_WARN_STR);
pub inline fn __MINGW_MS_PRINTF(__format: anytype, __args: anytype) @TypeOf(__attribute__(__format__(ms_printf, __format, __args))) {
return __attribute__(__format__(ms_printf, __format, __args));
}
pub inline fn __MINGW_MS_SCANF(__format: anytype, __args: anytype) @TypeOf(__attribute__(__format__(ms_scanf, __format, __args))) {
return __attribute__(__format__(ms_scanf, __format, __args));
}
pub inline fn __MINGW_GNU_PRINTF(__format: anytype, __args: anytype) @TypeOf(__attribute__(__format__(gnu_printf, __format, __args))) {
return __attribute__(__format__(gnu_printf, __format, __args));
}
pub inline fn __MINGW_GNU_SCANF(__format: anytype, __args: anytype) @TypeOf(__attribute__(__format__(gnu_scanf, __format, __args))) {
return __attribute__(__format__(gnu_scanf, __format, __args));
}
pub const __mingw_static_ovr = __mingw_ovr;
pub const __MINGW_FORTIFY_LEVEL = @as(c_int, 0);
pub const __mingw_bos_ovr = __mingw_ovr;
pub const __MINGW_FORTIFY_VA_ARG = @as(c_int, 0);
pub const _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES = @as(c_int, 0);
pub const _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY = @as(c_int, 0);
pub const _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES = @as(c_int, 0);
pub const _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT = @as(c_int, 0);
pub const _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY = @as(c_int, 0);
pub const __LONG32 = c_long;
pub const __USE_CRTIMP = @as(c_int, 1);
pub const _CRTIMP = __attribute__(__dllimport__);
pub const USE___UUIDOF = @as(c_int, 0);
pub const _inline = __inline;
pub inline fn __UNUSED_PARAM(x: anytype) @TypeOf(x ++ __attribute__(__unused__)) {
return x ++ __attribute__(__unused__);
}
pub const __restrict_arr = __restrict;
pub const __MINGW_ATTRIB_NORETURN = __attribute__(__noreturn__);
pub const __MINGW_ATTRIB_CONST = __attribute__(__const__);
pub const __MINGW_ATTRIB_MALLOC = __attribute__(__malloc__);
pub const __MINGW_ATTRIB_PURE = __attribute__(__pure__);
pub inline fn __MINGW_ATTRIB_NONNULL(arg: anytype) @TypeOf(__attribute__(__nonnull__(arg))) {
return __attribute__(__nonnull__(arg));
}
pub const __MINGW_ATTRIB_UNUSED = __attribute__(__unused__);
pub const __MINGW_ATTRIB_USED = __attribute__(__used__);
pub const __MINGW_ATTRIB_DEPRECATED = __attribute__(__deprecated__);
pub inline fn __MINGW_ATTRIB_DEPRECATED_MSG(x: anytype) @TypeOf(__attribute__(__deprecated__(x))) {
return __attribute__(__deprecated__(x));
}
pub const __MINGW_NOTHROW = __attribute__(__nothrow__);
pub const __MSVCRT_VERSION__ = @as(c_int, 0x700);
pub const _WIN32_WINNT = @as(c_int, 0x0603);
pub const __int8 = u8;
pub const __int16 = c_short;
pub const __int32 = c_int;
pub const __int64 = c_longlong;
pub const MINGW_HAS_SECURE_API = @as(c_int, 1);
pub const __STDC_SECURE_LIB__ = @as(c_long, 200411);
pub const __GOT_SECURE_LIB__ = __STDC_SECURE_LIB__;
pub const MINGW_HAS_DDK_H = @as(c_int, 1);
pub const _CRT_PACKING = @as(c_int, 8);
pub inline fn _ADDRESSOF(v: anytype) @TypeOf(&v) {
return &v;
}
pub inline fn _CRT_STRINGIZE(_Value: anytype) @TypeOf(__CRT_STRINGIZE(_Value)) {
return __CRT_STRINGIZE(_Value);
}
pub inline fn _CRT_WIDE(_String: anytype) @TypeOf(__CRT_WIDE(_String)) {
return __CRT_WIDE(_String);
}
pub const _CRTIMP_NOIA64 = _CRTIMP;
pub const _CRTIMP2 = _CRTIMP;
pub const _CRTIMP_ALTERNATIVE = _CRTIMP;
pub const _MRTIMP2 = _CRTIMP;
pub const _MCRTIMP = _CRTIMP;
pub const _CRTIMP_PURE = _CRTIMP;
pub const _SECURECRT_FILL_BUFFER_PATTERN = @as(c_int, 0xFD);
pub inline fn _CRT_DEPRECATE_TEXT(_Text: anytype) @TypeOf(__declspec(deprecated)) {
_ = _Text;
return __declspec(deprecated);
}
pub const UNALIGNED = __unaligned;
pub inline fn _CRT_ALIGN(x: anytype) @TypeOf(__attribute__(__aligned__(x))) {
return __attribute__(__aligned__(x));
}
pub const __CRTDECL = __cdecl;
pub const _ARGMAX = @as(c_int, 100);
pub const _TRUNCATE = @import("std").zig.c_translation.cast(usize, -@as(c_int, 1));
pub inline fn _CRT_UNUSED(x: anytype) c_void {
return @import("std").zig.c_translation.cast(c_void, x);
}
pub const __USE_MINGW_ANSI_STDIO = @as(c_int, 1);
pub const _CRT_glob = _dowildcard;
pub const _ANONYMOUS_UNION = __MINGW_EXTENSION;
pub const _ANONYMOUS_STRUCT = __MINGW_EXTENSION;
pub const __MINGW_DEBUGBREAK_IMPL = !(__has_builtin(__debugbreak) != 0);
pub const _CRT_SECURE_CPP_NOTHROW = throw();
pub const _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION = @as(c_ulonglong, 0x0001);
pub const _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR = @as(c_ulonglong, 0x0002);
pub const _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS = @as(c_ulonglong, 0x0004);
pub const _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY = @as(c_ulonglong, 0x0008);
pub const _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS = @as(c_ulonglong, 0x0010);
pub const _CRT_INTERNAL_SCANF_SECURECRT = @as(c_ulonglong, 0x0001);
pub const _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS = @as(c_ulonglong, 0x0002);
pub const _CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY = @as(c_ulonglong, 0x0004);
pub const _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS = _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS;
pub const _CRT_INTERNAL_LOCAL_SCANF_OPTIONS = _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS;
pub const BUFSIZ = @as(c_int, 512);
pub const _NFILE = _NSTREAM_;
pub const _NSTREAM_ = @as(c_int, 512);
pub const _IOB_ENTRIES = @as(c_int, 20);
pub const EOF = -@as(c_int, 1);
pub const _P_tmpdir = "\\";
pub const _wP_tmpdir = "\\";
pub const L_tmpnam = @import("std").zig.c_translation.sizeof(_P_tmpdir) + @as(c_int, 12);
pub const SEEK_CUR = @as(c_int, 1);
pub const SEEK_END = @as(c_int, 2);
pub const SEEK_SET = @as(c_int, 0);
pub const STDIN_FILENO = @as(c_int, 0);
pub const STDOUT_FILENO = @as(c_int, 1);
pub const STDERR_FILENO = @as(c_int, 2);
pub const FILENAME_MAX = @as(c_int, 260);
pub const FOPEN_MAX = @as(c_int, 20);
pub const _SYS_OPEN = @as(c_int, 20);
pub const TMP_MAX = @as(c_int, 32767);
pub const _iob = __iob_func();
pub inline fn _FPOSOFF(fp: anytype) c_long {
return @import("std").zig.c_translation.cast(c_long, fp);
}
pub const stdin = __acrt_iob_func(@as(c_int, 0));
pub const stdout = __acrt_iob_func(@as(c_int, 1));
pub const stderr = __acrt_iob_func(@as(c_int, 2));
pub const _IOFBF = @as(c_int, 0x0000);
pub const _IOLBF = @as(c_int, 0x0040);
pub const _IONBF = @as(c_int, 0x0004);
pub const _IOREAD = @as(c_int, 0x0001);
pub const _IOWRT = @as(c_int, 0x0002);
pub const _IOMYBUF = @as(c_int, 0x0008);
pub const _IOEOF = @as(c_int, 0x0010);
pub const _IOERR = @as(c_int, 0x0020);
pub const _IOSTRG = @as(c_int, 0x0040);
pub const _IORW = @as(c_int, 0x0080);
pub const _TWO_DIGIT_EXPONENT = @as(c_int, 0x1);
pub const __MINGW_PRINTF_FORMAT = printf;
pub const __MINGW_SCANF_FORMAT = scanf;
pub const __builtin_vsnprintf = __mingw_vsnprintf;
pub const __builtin_vsprintf = __mingw_vsprintf;
pub const popen = _popen;
pub const pclose = _pclose;
pub const WEOF = @import("std").zig.c_translation.cast(wint_t, @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xFFFF, .hexadecimal));
pub const wpopen = _wpopen;
pub inline fn _getc_nolock(_stream: anytype) @TypeOf(_fgetc_nolock(_stream)) {
return _fgetc_nolock(_stream);
}
pub inline fn _putc_nolock(_c: anytype, _stream: anytype) @TypeOf(_fputc_nolock(_c, _stream)) {
return _fputc_nolock(_c, _stream);
}
pub inline fn _getchar_nolock() @TypeOf(_getc_nolock(stdin)) {
return _getc_nolock(stdin);
}
pub inline fn _putchar_nolock(_c: anytype) @TypeOf(_putc_nolock(_c, stdout)) {
return _putc_nolock(_c, stdout);
}
pub inline fn _getwchar_nolock() @TypeOf(_getwc_nolock(stdin)) {
return _getwc_nolock(stdin);
}
pub inline fn _putwchar_nolock(_c: anytype) @TypeOf(_putwc_nolock(_c, stdout)) {
return _putwc_nolock(_c, stdout);
}
pub const P_tmpdir = _P_tmpdir;
pub const SYS_OPEN = _SYS_OPEN;
pub const _P_WAIT = @as(c_int, 0);
pub const _P_NOWAIT = @as(c_int, 1);
pub const _OLD_P_OVERLAY = @as(c_int, 2);
pub const _P_NOWAITO = @as(c_int, 3);
pub const _P_DETACH = @as(c_int, 4);
pub const _P_OVERLAY = @as(c_int, 2);
pub const _WAIT_CHILD = @as(c_int, 0);
pub const _WAIT_GRANDCHILD = @as(c_int, 1);
pub const _SECIMP = __declspec(dllimport);
pub const L_tmpnam_s = L_tmpnam;
pub const TMP_MAX_S = TMP_MAX;
pub const @"bool" = bool;
pub const @"true" = @as(c_int, 1);
pub const @"false" = @as(c_int, 0);
pub const __bool_true_false_are_defined = @as(c_int, 1);
pub const INT8_MIN = -@as(c_int, 128);
pub const INT16_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 32768, .decimal);
pub const INT32_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1);
pub const INT64_MIN = -@as(c_longlong, 9223372036854775807) - @as(c_int, 1);
pub const INT8_MAX = @as(c_int, 127);
pub const INT16_MAX = @as(c_int, 32767);
pub const INT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const INT64_MAX = @as(c_longlong, 9223372036854775807);
pub const UINT8_MAX = @as(c_int, 255);
pub const UINT16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const UINT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0xffffffff, .hexadecimal);
pub const UINT64_MAX = @as(c_ulonglong, 0xffffffffffffffff);
pub const INT_LEAST8_MIN = INT8_MIN;
pub const INT_LEAST16_MIN = INT16_MIN;
pub const INT_LEAST32_MIN = INT32_MIN;
pub const INT_LEAST64_MIN = INT64_MIN;
pub const INT_LEAST8_MAX = INT8_MAX;
pub const INT_LEAST16_MAX = INT16_MAX;
pub const INT_LEAST32_MAX = INT32_MAX;
pub const INT_LEAST64_MAX = INT64_MAX;
pub const UINT_LEAST8_MAX = UINT8_MAX;
pub const UINT_LEAST16_MAX = UINT16_MAX;
pub const UINT_LEAST32_MAX = UINT32_MAX;
pub const UINT_LEAST64_MAX = UINT64_MAX;
pub const INT_FAST8_MIN = INT8_MIN;
pub const INT_FAST16_MIN = INT16_MIN;
pub const INT_FAST32_MIN = INT32_MIN;
pub const INT_FAST64_MIN = INT64_MIN;
pub const INT_FAST8_MAX = INT8_MAX;
pub const INT_FAST16_MAX = INT16_MAX;
pub const INT_FAST32_MAX = INT32_MAX;
pub const INT_FAST64_MAX = INT64_MAX;
pub const UINT_FAST8_MAX = UINT8_MAX;
pub const UINT_FAST16_MAX = UINT16_MAX;
pub const UINT_FAST32_MAX = UINT32_MAX;
pub const UINT_FAST64_MAX = UINT64_MAX;
pub const INTPTR_MIN = INT64_MIN;
pub const INTPTR_MAX = INT64_MAX;
pub const UINTPTR_MAX = UINT64_MAX;
pub const INTMAX_MIN = INT64_MIN;
pub const INTMAX_MAX = INT64_MAX;
pub const UINTMAX_MAX = UINT64_MAX;
pub const PTRDIFF_MIN = INT64_MIN;
pub const PTRDIFF_MAX = INT64_MAX;
pub const SIG_ATOMIC_MIN = INT32_MIN;
pub const SIG_ATOMIC_MAX = INT32_MAX;
pub const SIZE_MAX = UINT64_MAX;
pub const WCHAR_MIN = @as(c_uint, 0);
pub const WCHAR_MAX = @as(c_uint, 0xffff);
pub const WINT_MIN = @as(c_uint, 0);
pub const WINT_MAX = @as(c_uint, 0xffff);
pub inline fn INT8_C(val: anytype) @TypeOf((INT_LEAST8_MAX - INT_LEAST8_MAX) + val) {
return (INT_LEAST8_MAX - INT_LEAST8_MAX) + val;
}
pub inline fn INT16_C(val: anytype) @TypeOf((INT_LEAST16_MAX - INT_LEAST16_MAX) + val) {
return (INT_LEAST16_MAX - INT_LEAST16_MAX) + val;
}
pub inline fn INT32_C(val: anytype) @TypeOf((INT_LEAST32_MAX - INT_LEAST32_MAX) + val) {
return (INT_LEAST32_MAX - INT_LEAST32_MAX) + val;
}
pub inline fn UINT8_C(val: anytype) @TypeOf(val) {
return val;
}
pub inline fn UINT16_C(val: anytype) @TypeOf(val) {
return val;
}
pub const UINT32_C = @import("std").zig.c_translation.Macros.U_SUFFIX;
pub const FALSE = @as(c_int, 0);
pub const TRUE = @as(c_int, 1);
pub const ERR = -@as(c_int, 1);
pub const OK = @as(c_int, 0);
pub const PDC_MAX_MOUSE_BUTTONS = @as(c_int, 9);
pub const BUTTON_RELEASED = @as(c_int, 0x0000);
pub const BUTTON_PRESSED = @as(c_int, 0x0001);
pub const BUTTON_CLICKED = @as(c_int, 0x0002);
pub const BUTTON_DOUBLE_CLICKED = @as(c_int, 0x0003);
pub const BUTTON_TRIPLE_CLICKED = @as(c_int, 0x0004);
pub const BUTTON_MOVED = @as(c_int, 0x0005);
pub const WHEEL_SCROLLED = @as(c_int, 0x0006);
pub const BUTTON_ACTION_MASK = @as(c_int, 0x0007);
pub const PDC_BUTTON_SHIFT = @as(c_int, 0x0008);
pub const PDC_BUTTON_CONTROL = @as(c_int, 0x0010);
pub const PDC_BUTTON_ALT = @as(c_int, 0x0020);
pub const BUTTON_MODIFIER_MASK = @as(c_int, 0x0038);
pub const MOUSE_X_POS = Mouse_status.x;
pub const MOUSE_Y_POS = Mouse_status.y;
pub const PDC_MOUSE_MOVED = @as(c_int, 0x0008);
pub const PDC_MOUSE_POSITION = @as(c_int, 0x0010);
pub const PDC_MOUSE_WHEEL_UP = @as(c_int, 0x0020);
pub const PDC_MOUSE_WHEEL_DOWN = @as(c_int, 0x0040);
pub const PDC_MOUSE_WHEEL_LEFT = @as(c_int, 0x0080);
pub const PDC_MOUSE_WHEEL_RIGHT = @as(c_int, 0x0100);
pub const A_BUTTON_CHANGED = Mouse_status.changes & @as(c_int, 7);
pub const MOUSE_MOVED = Mouse_status.changes & PDC_MOUSE_MOVED;
pub const MOUSE_POS_REPORT = Mouse_status.changes & PDC_MOUSE_POSITION;
pub inline fn BUTTON_CHANGED(x: anytype) @TypeOf(Mouse_status.changes & (@as(c_int, 1) << (x - (if (x < @as(c_int, 4)) @as(c_int, 1) else -@as(c_int, 5))))) {
return Mouse_status.changes & (@as(c_int, 1) << (x - (if (x < @as(c_int, 4)) @as(c_int, 1) else -@as(c_int, 5))));
}
pub inline fn BUTTON_STATUS(x: anytype) @TypeOf(Mouse_status.button[x - @as(c_int, 1)]) {
return Mouse_status.button[x - @as(c_int, 1)];
}
pub const MOUSE_WHEEL_UP = Mouse_status.changes & PDC_MOUSE_WHEEL_UP;
pub const MOUSE_WHEEL_DOWN = Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN;
pub const MOUSE_WHEEL_LEFT = Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT;
pub const MOUSE_WHEEL_RIGHT = Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT;
pub const BUTTON1_RELEASED = @as(c_long, 0x00000001);
pub const BUTTON1_PRESSED = @as(c_long, 0x00000002);
pub const BUTTON1_CLICKED = @as(c_long, 0x00000004);
pub const BUTTON1_DOUBLE_CLICKED = @as(c_long, 0x00000008);
pub const BUTTON1_TRIPLE_CLICKED = @as(c_long, 0x00000010);
pub const BUTTON1_MOVED = @as(c_long, 0x00000010);
pub const BUTTON2_RELEASED = @as(c_long, 0x00000020);
pub const BUTTON2_PRESSED = @as(c_long, 0x00000040);
pub const BUTTON2_CLICKED = @as(c_long, 0x00000080);
pub const BUTTON2_DOUBLE_CLICKED = @as(c_long, 0x00000100);
pub const BUTTON2_TRIPLE_CLICKED = @as(c_long, 0x00000200);
pub const BUTTON2_MOVED = @as(c_long, 0x00000200);
pub const BUTTON3_RELEASED = @as(c_long, 0x00000400);
pub const BUTTON3_PRESSED = @as(c_long, 0x00000800);
pub const BUTTON3_CLICKED = @as(c_long, 0x00001000);
pub const BUTTON3_DOUBLE_CLICKED = @as(c_long, 0x00002000);
pub const BUTTON3_TRIPLE_CLICKED = @as(c_long, 0x00004000);
pub const BUTTON3_MOVED = @as(c_long, 0x00004000);
pub const BUTTON4_RELEASED = @as(c_long, 0x00008000);
pub const BUTTON4_PRESSED = @as(c_long, 0x00010000);
pub const BUTTON4_CLICKED = @as(c_long, 0x00020000);
pub const BUTTON4_DOUBLE_CLICKED = @as(c_long, 0x00040000);
pub const BUTTON4_TRIPLE_CLICKED = @as(c_long, 0x00080000);
pub const BUTTON5_RELEASED = @as(c_long, 0x00100000);
pub const BUTTON5_PRESSED = @as(c_long, 0x00200000);
pub const BUTTON5_CLICKED = @as(c_long, 0x00400000);
pub const BUTTON5_DOUBLE_CLICKED = @as(c_long, 0x00800000);
pub const BUTTON5_TRIPLE_CLICKED = @as(c_long, 0x01000000);
pub const MOUSE_WHEEL_SCROLL = @as(c_long, 0x02000000);
pub const BUTTON_MODIFIER_SHIFT = @as(c_long, 0x04000000);
pub const BUTTON_MODIFIER_CONTROL = @as(c_long, 0x08000000);
pub const BUTTON_MODIFIER_ALT = @as(c_long, 0x10000000);
pub const ALL_MOUSE_EVENTS = @as(c_long, 0x1fffffff);
pub const REPORT_MOUSE_POSITION = @as(c_long, 0x20000000);
pub const BUTTON_SHIFT = PDC_BUTTON_SHIFT;
pub const BUTTON_CONTROL = PDC_BUTTON_CONTROL;
pub const BUTTON_ALT = PDC_BUTTON_ALT;
pub const A_NORMAL = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0));
pub const PDC_CHARTEXT_BITS = @as(c_int, 21);
pub const A_CHARTEXT = @import("std").zig.c_translation.cast(chtype, (@import("std").zig.c_translation.cast(chtype, @as(c_int, 0x1)) << PDC_CHARTEXT_BITS) - @as(c_int, 1));
pub const A_ALTCHARSET = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x001)) << PDC_CHARTEXT_BITS;
pub const A_RIGHT = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x002)) << PDC_CHARTEXT_BITS;
pub const A_LEFT = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x004)) << PDC_CHARTEXT_BITS;
pub const A_INVIS = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x008)) << PDC_CHARTEXT_BITS;
pub const A_UNDERLINE = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x010)) << PDC_CHARTEXT_BITS;
pub const A_REVERSE = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x020)) << PDC_CHARTEXT_BITS;
pub const A_BLINK = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x040)) << PDC_CHARTEXT_BITS;
pub const A_BOLD = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x080)) << PDC_CHARTEXT_BITS;
pub const A_OVERLINE = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x100)) << PDC_CHARTEXT_BITS;
pub const A_STRIKEOUT = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x200)) << PDC_CHARTEXT_BITS;
pub const A_DIM = @import("std").zig.c_translation.cast(chtype, @as(c_int, 0x400)) << PDC_CHARTEXT_BITS;
pub const PDC_COLOR_SHIFT = PDC_CHARTEXT_BITS + @as(c_int, 12);
pub const A_COLOR = @import("std").zig.c_translation.cast(chtype, @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfffff, .hexadecimal)) << PDC_COLOR_SHIFT;
pub const A_ATTRIBUTES = (@import("std").zig.c_translation.cast(chtype, @as(c_int, 0xfff)) << PDC_CHARTEXT_BITS) | A_COLOR;
pub const A_ITALIC = A_INVIS;
pub const A_PROTECT = (A_UNDERLINE | A_LEFT) | A_RIGHT;
pub const A_STANDOUT = A_REVERSE | A_BOLD;
pub const CHR_MSK = A_CHARTEXT;
pub const ATR_MSK = A_ATTRIBUTES;
pub const ATR_NRM = A_NORMAL;
pub const A_LEFTLINE = A_LEFT;
pub const A_RIGHTLINE = A_RIGHT;
pub const WA_NORMAL = A_NORMAL;
pub const WA_ALTCHARSET = A_ALTCHARSET;
pub const WA_BLINK = A_BLINK;
pub const WA_BOLD = A_BOLD;
pub const WA_DIM = A_DIM;
pub const WA_INVIS = A_INVIS;
pub const WA_ITALIC = A_ITALIC;
pub const WA_LEFT = A_LEFT;
pub const WA_PROTECT = A_PROTECT;
pub const WA_REVERSE = A_REVERSE;
pub const WA_RIGHT = A_RIGHT;
pub const WA_STANDOUT = A_STANDOUT;
pub const WA_UNDERLINE = A_UNDERLINE;
pub const WA_HORIZONTAL = A_HORIZONTAL;
pub const WA_LOW = A_LOW;
pub const WA_TOP = A_TOP;
pub const WA_VERTICAL = A_VERTICAL;
pub const WA_ATTRIBUTES = A_ATTRIBUTES;
pub inline fn PDC_ACS(w: anytype) @TypeOf(@import("std").zig.c_translation.cast(chtype, w) | A_ALTCHARSET) {
return @import("std").zig.c_translation.cast(chtype, w) | A_ALTCHARSET;
}
pub const ACS_LRCORNER = PDC_ACS('V');
pub const ACS_URCORNER = PDC_ACS('W');
pub const ACS_ULCORNER = PDC_ACS('X');
pub const ACS_LLCORNER = PDC_ACS('Y');
pub const ACS_PLUS = PDC_ACS('Z');
pub const ACS_LTEE = PDC_ACS('[');
pub const ACS_RTEE = PDC_ACS('\\');
pub const ACS_BTEE = PDC_ACS(']');
pub const ACS_TTEE = PDC_ACS('^');
pub const ACS_HLINE = PDC_ACS('_');
pub const ACS_VLINE = PDC_ACS('`');
pub const ACS_CENT = PDC_ACS('{');
pub const ACS_YEN = PDC_ACS('|');
pub const ACS_PESETA = PDC_ACS('}');
pub const ACS_HALF = PDC_ACS('&');
pub const ACS_QUARTER = PDC_ACS('\'');
pub const ACS_LEFT_ANG_QU = PDC_ACS(')');
pub const ACS_RIGHT_ANG_QU = PDC_ACS('*');
pub const ACS_D_HLINE = PDC_ACS('a');
pub const ACS_D_VLINE = PDC_ACS('b');
pub const ACS_CLUB = PDC_ACS(@as(c_int, 11));
pub const ACS_HEART = PDC_ACS(@as(c_int, 12));
pub const ACS_SPADE = PDC_ACS(@as(c_int, 13));
pub const ACS_SMILE = PDC_ACS(@as(c_int, 14));
pub const ACS_REV_SMILE = PDC_ACS(@as(c_int, 15));
pub const ACS_MED_BULLET = PDC_ACS(@as(c_int, 16));
pub const ACS_WHITE_BULLET = PDC_ACS(@as(c_int, 17));
pub const ACS_PILCROW = PDC_ACS(@as(c_int, 18));
pub const ACS_SECTION = PDC_ACS(@as(c_int, 19));
pub const ACS_SUP2 = PDC_ACS(',');
pub const ACS_ALPHA = PDC_ACS('.');
pub const ACS_BETA = PDC_ACS('/');
pub const ACS_GAMMA = PDC_ACS('0');
pub const ACS_UP_SIGMA = PDC_ACS('1');
pub const ACS_LO_SIGMA = PDC_ACS('2');
pub const ACS_MU = PDC_ACS('4');
pub const ACS_TAU = PDC_ACS('5');
pub const ACS_UP_PHI = PDC_ACS('6');
pub const ACS_THETA = PDC_ACS('7');
pub const ACS_OMEGA = PDC_ACS('8');
pub const ACS_DELTA = PDC_ACS('9');
pub const ACS_INFINITY = PDC_ACS('-');
pub const ACS_LO_PHI = PDC_ACS(@as(c_int, 22));
pub const ACS_EPSILON = PDC_ACS(':');
pub const ACS_INTERSECT = PDC_ACS('e');
pub const ACS_TRIPLE_BAR = PDC_ACS('f');
pub const ACS_DIVISION = PDC_ACS('c');
pub const ACS_APPROX_EQ = PDC_ACS('d');
pub const ACS_SM_BULLET = PDC_ACS('g');
pub const ACS_SQUARE_ROOT = PDC_ACS('i');
pub const ACS_UBLOCK = PDC_ACS('p');
pub const ACS_BBLOCK = PDC_ACS('q');
pub const ACS_LBLOCK = PDC_ACS('r');
pub const ACS_RBLOCK = PDC_ACS('s');
pub const ACS_A_ORDINAL = PDC_ACS(@as(c_int, 20));
pub const ACS_O_ORDINAL = PDC_ACS(@as(c_int, 21));
pub const ACS_INV_QUERY = PDC_ACS(@as(c_int, 24));
pub const ACS_REV_NOT = PDC_ACS(@as(c_int, 25));
pub const ACS_NOT = PDC_ACS(@as(c_int, 26));
pub const ACS_INV_BANG = PDC_ACS(@as(c_int, 23));
pub const ACS_UP_INTEGRAL = PDC_ACS(@as(c_int, 27));
pub const ACS_LO_INTEGRAL = PDC_ACS(@as(c_int, 28));
pub const ACS_SUP_N = PDC_ACS(@as(c_int, 29));
pub const ACS_CENTER_SQU = PDC_ACS(@as(c_int, 30));
pub const ACS_F_WITH_HOOK = PDC_ACS(@as(c_int, 31));
pub const ACS_SD_LRCORNER = PDC_ACS(';');
pub const ACS_SD_URCORNER = PDC_ACS('<');
pub const ACS_SD_ULCORNER = PDC_ACS('=');
pub const ACS_SD_LLCORNER = PDC_ACS('>');
pub const ACS_SD_PLUS = PDC_ACS('?');
pub const ACS_SD_LTEE = PDC_ACS('@');
pub const ACS_SD_RTEE = PDC_ACS('A');
pub const ACS_SD_BTEE = PDC_ACS('B');
pub const ACS_SD_TTEE = PDC_ACS('C');
pub const ACS_D_LRCORNER = PDC_ACS('D');
pub const ACS_D_URCORNER = PDC_ACS('E');
pub const ACS_D_ULCORNER = PDC_ACS('F');
pub const ACS_D_LLCORNER = PDC_ACS('G');
pub const ACS_D_PLUS = PDC_ACS('H');
pub const ACS_D_LTEE = PDC_ACS('I');
pub const ACS_D_RTEE = PDC_ACS('J');
pub const ACS_D_BTEE = PDC_ACS('K');
pub const ACS_D_TTEE = PDC_ACS('L');
pub const ACS_DS_LRCORNER = PDC_ACS('M');
pub const ACS_DS_URCORNER = PDC_ACS('N');
pub const ACS_DS_ULCORNER = PDC_ACS('O');
pub const ACS_DS_LLCORNER = PDC_ACS('P');
pub const ACS_DS_PLUS = PDC_ACS('Q');
pub const ACS_DS_LTEE = PDC_ACS('R');
pub const ACS_DS_RTEE = PDC_ACS('S');
pub const ACS_DS_BTEE = PDC_ACS('T');
pub const ACS_DS_TTEE = PDC_ACS('U');
pub const ACS_S1 = PDC_ACS('l');
pub const ACS_S9 = PDC_ACS('o');
pub const ACS_DIAMOND = PDC_ACS('j');
pub const ACS_CKBOARD = PDC_ACS('k');
pub const ACS_DEGREE = PDC_ACS('w');
pub const ACS_PLMINUS = PDC_ACS('x');
pub const ACS_BULLET = PDC_ACS('h');
pub const ACS_LARROW = PDC_ACS('!');
pub const ACS_RARROW = PDC_ACS(' ');
pub const ACS_DARROW = PDC_ACS('#');
pub const ACS_UARROW = PDC_ACS('"');
pub const ACS_BOARD = PDC_ACS('+');
pub const ACS_LTBOARD = PDC_ACS('y');
pub const ACS_LANTERN = PDC_ACS('z');
pub const ACS_BLOCK = PDC_ACS('t');
pub const ACS_S3 = PDC_ACS('m');
pub const ACS_S7 = PDC_ACS('n');
pub const ACS_LEQUAL = PDC_ACS('u');
pub const ACS_GEQUAL = PDC_ACS('v');
pub const ACS_PI = PDC_ACS('$');
pub const ACS_NEQUAL = PDC_ACS('%');
pub const ACS_STERLING = PDC_ACS('~');
pub const ACS_BSSB = ACS_ULCORNER;
pub const ACS_SSBB = ACS_LLCORNER;
pub const ACS_BBSS = ACS_URCORNER;
pub const ACS_SBBS = ACS_LRCORNER;
pub const ACS_SBSS = ACS_RTEE;
pub const ACS_SSSB = ACS_LTEE;
pub const ACS_SSBS = ACS_BTEE;
pub const ACS_BSSS = ACS_TTEE;
pub const ACS_BSBS = ACS_HLINE;
pub const ACS_SBSB = ACS_VLINE;
pub const ACS_SSSS = ACS_PLUS;
pub const COLOR_BLACK = @as(c_int, 0);
pub const COLOR_BLUE = @as(c_int, 1);
pub const COLOR_GREEN = @as(c_int, 2);
pub const COLOR_RED = @as(c_int, 4);
pub const COLOR_CYAN = COLOR_BLUE | COLOR_GREEN;
pub const COLOR_MAGENTA = COLOR_RED | COLOR_BLUE;
pub const COLOR_YELLOW = COLOR_RED | COLOR_GREEN;
pub const COLOR_WHITE = @as(c_int, 7);
pub const KEY_OFFSET = @as(c_int, 0x100);
pub const KEY_CODE_YES = KEY_OFFSET + @as(c_int, 0x00);
pub const KEY_BREAK = KEY_OFFSET + @as(c_int, 0x01);
pub const KEY_DOWN = KEY_OFFSET + @as(c_int, 0x02);
pub const KEY_UP = KEY_OFFSET + @as(c_int, 0x03);
pub const KEY_LEFT = KEY_OFFSET + @as(c_int, 0x04);
pub const KEY_RIGHT = KEY_OFFSET + @as(c_int, 0x05);
pub const KEY_HOME = KEY_OFFSET + @as(c_int, 0x06);
pub const KEY_BACKSPACE = KEY_OFFSET + @as(c_int, 0x07);
pub const KEY_F0 = KEY_OFFSET + @as(c_int, 0x08);
pub const KEY_DL = KEY_OFFSET + @as(c_int, 0x48);
pub const KEY_IL = KEY_OFFSET + @as(c_int, 0x49);
pub const KEY_DC = KEY_OFFSET + @as(c_int, 0x4a);
pub const KEY_IC = KEY_OFFSET + @as(c_int, 0x4b);
pub const KEY_EIC = KEY_OFFSET + @as(c_int, 0x4c);
pub const KEY_CLEAR = KEY_OFFSET + @as(c_int, 0x4d);
pub const KEY_EOS = KEY_OFFSET + @as(c_int, 0x4e);
pub const KEY_EOL = KEY_OFFSET + @as(c_int, 0x4f);
pub const KEY_SF = KEY_OFFSET + @as(c_int, 0x50);
pub const KEY_SR = KEY_OFFSET + @as(c_int, 0x51);
pub const KEY_NPAGE = KEY_OFFSET + @as(c_int, 0x52);
pub const KEY_PPAGE = KEY_OFFSET + @as(c_int, 0x53);
pub const KEY_STAB = KEY_OFFSET + @as(c_int, 0x54);
pub const KEY_CTAB = KEY_OFFSET + @as(c_int, 0x55);
pub const KEY_CATAB = KEY_OFFSET + @as(c_int, 0x56);
pub const KEY_ENTER = KEY_OFFSET + @as(c_int, 0x57);
pub const KEY_SRESET = KEY_OFFSET + @as(c_int, 0x58);
pub const KEY_RESET = KEY_OFFSET + @as(c_int, 0x59);
pub const KEY_PRINT = KEY_OFFSET + @as(c_int, 0x5a);
pub const KEY_LL = KEY_OFFSET + @as(c_int, 0x5b);
pub const KEY_ABORT = KEY_OFFSET + @as(c_int, 0x5c);
pub const KEY_SHELP = KEY_OFFSET + @as(c_int, 0x5d);
pub const KEY_LHELP = KEY_OFFSET + @as(c_int, 0x5e);
pub const KEY_BTAB = KEY_OFFSET + @as(c_int, 0x5f);
pub const KEY_BEG = KEY_OFFSET + @as(c_int, 0x60);
pub const KEY_CANCEL = KEY_OFFSET + @as(c_int, 0x61);
pub const KEY_CLOSE = KEY_OFFSET + @as(c_int, 0x62);
pub const KEY_COMMAND = KEY_OFFSET + @as(c_int, 0x63);
pub const KEY_COPY = KEY_OFFSET + @as(c_int, 0x64);
pub const KEY_CREATE = KEY_OFFSET + @as(c_int, 0x65);
pub const KEY_END = KEY_OFFSET + @as(c_int, 0x66);
pub const KEY_EXIT = KEY_OFFSET + @as(c_int, 0x67);
pub const KEY_FIND = KEY_OFFSET + @as(c_int, 0x68);
pub const KEY_HELP = KEY_OFFSET + @as(c_int, 0x69);
pub const KEY_MARK = KEY_OFFSET + @as(c_int, 0x6a);
pub const KEY_MESSAGE = KEY_OFFSET + @as(c_int, 0x6b);
pub const KEY_MOVE = KEY_OFFSET + @as(c_int, 0x6c);
pub const KEY_NEXT = KEY_OFFSET + @as(c_int, 0x6d);
pub const KEY_OPEN = KEY_OFFSET + @as(c_int, 0x6e);
pub const KEY_OPTIONS = KEY_OFFSET + @as(c_int, 0x6f);
pub const KEY_PREVIOUS = KEY_OFFSET + @as(c_int, 0x70);
pub const KEY_REDO = KEY_OFFSET + @as(c_int, 0x71);
pub const KEY_REFERENCE = KEY_OFFSET + @as(c_int, 0x72);
pub const KEY_REFRESH = KEY_OFFSET + @as(c_int, 0x73);
pub const KEY_REPLACE = KEY_OFFSET + @as(c_int, 0x74);
pub const KEY_RESTART = KEY_OFFSET + @as(c_int, 0x75);
pub const KEY_RESUME = KEY_OFFSET + @as(c_int, 0x76);
pub const KEY_SAVE = KEY_OFFSET + @as(c_int, 0x77);
pub const KEY_SBEG = KEY_OFFSET + @as(c_int, 0x78);
pub const KEY_SCANCEL = KEY_OFFSET + @as(c_int, 0x79);
pub const KEY_SCOMMAND = KEY_OFFSET + @as(c_int, 0x7a);
pub const KEY_SCOPY = KEY_OFFSET + @as(c_int, 0x7b);
pub const KEY_SCREATE = KEY_OFFSET + @as(c_int, 0x7c);
pub const KEY_SDC = KEY_OFFSET + @as(c_int, 0x7d);
pub const KEY_SDL = KEY_OFFSET + @as(c_int, 0x7e);
pub const KEY_SELECT = KEY_OFFSET + @as(c_int, 0x7f);
pub const KEY_SEND = KEY_OFFSET + @as(c_int, 0x80);
pub const KEY_SEOL = KEY_OFFSET + @as(c_int, 0x81);
pub const KEY_SEXIT = KEY_OFFSET + @as(c_int, 0x82);
pub const KEY_SFIND = KEY_OFFSET + @as(c_int, 0x83);
pub const KEY_SHOME = KEY_OFFSET + @as(c_int, 0x84);
pub const KEY_SIC = KEY_OFFSET + @as(c_int, 0x85);
pub const KEY_SLEFT = KEY_OFFSET + @as(c_int, 0x87);
pub const KEY_SMESSAGE = KEY_OFFSET + @as(c_int, 0x88);
pub const KEY_SMOVE = KEY_OFFSET + @as(c_int, 0x89);
pub const KEY_SNEXT = KEY_OFFSET + @as(c_int, 0x8a);
pub const KEY_SOPTIONS = KEY_OFFSET + @as(c_int, 0x8b);
pub const KEY_SPREVIOUS = KEY_OFFSET + @as(c_int, 0x8c);
pub const KEY_SPRINT = KEY_OFFSET + @as(c_int, 0x8d);
pub const KEY_SREDO = KEY_OFFSET + @as(c_int, 0x8e);
pub const KEY_SREPLACE = KEY_OFFSET + @as(c_int, 0x8f);
pub const KEY_SRIGHT = KEY_OFFSET + @as(c_int, 0x90);
pub const KEY_SRSUME = KEY_OFFSET + @as(c_int, 0x91);
pub const KEY_SSAVE = KEY_OFFSET + @as(c_int, 0x92);
pub const KEY_SSUSPEND = KEY_OFFSET + @as(c_int, 0x93);
pub const KEY_SUNDO = KEY_OFFSET + @as(c_int, 0x94);
pub const KEY_SUSPEND = KEY_OFFSET + @as(c_int, 0x95);
pub const KEY_UNDO = KEY_OFFSET + @as(c_int, 0x96);
pub const ALT_0 = KEY_OFFSET + @as(c_int, 0x97);
pub const ALT_1 = KEY_OFFSET + @as(c_int, 0x98);
pub const ALT_2 = KEY_OFFSET + @as(c_int, 0x99);
pub const ALT_3 = KEY_OFFSET + @as(c_int, 0x9a);
pub const ALT_4 = KEY_OFFSET + @as(c_int, 0x9b);
pub const ALT_5 = KEY_OFFSET + @as(c_int, 0x9c);
pub const ALT_6 = KEY_OFFSET + @as(c_int, 0x9d);
pub const ALT_7 = KEY_OFFSET + @as(c_int, 0x9e);
pub const ALT_8 = KEY_OFFSET + @as(c_int, 0x9f);
pub const ALT_9 = KEY_OFFSET + @as(c_int, 0xa0);
pub const ALT_A = KEY_OFFSET + @as(c_int, 0xa1);
pub const ALT_B = KEY_OFFSET + @as(c_int, 0xa2);
pub const ALT_C = KEY_OFFSET + @as(c_int, 0xa3);
pub const ALT_D = KEY_OFFSET + @as(c_int, 0xa4);
pub const ALT_E = KEY_OFFSET + @as(c_int, 0xa5);
pub const ALT_F = KEY_OFFSET + @as(c_int, 0xa6);
pub const ALT_G = KEY_OFFSET + @as(c_int, 0xa7);
pub const ALT_H = KEY_OFFSET + @as(c_int, 0xa8);
pub const ALT_I = KEY_OFFSET + @as(c_int, 0xa9);
pub const ALT_J = KEY_OFFSET + @as(c_int, 0xaa);
pub const ALT_K = KEY_OFFSET + @as(c_int, 0xab);
pub const ALT_L = KEY_OFFSET + @as(c_int, 0xac);
pub const ALT_M = KEY_OFFSET + @as(c_int, 0xad);
pub const ALT_N = KEY_OFFSET + @as(c_int, 0xae);
pub const ALT_O = KEY_OFFSET + @as(c_int, 0xaf);
pub const ALT_P = KEY_OFFSET + @as(c_int, 0xb0);
pub const ALT_Q = KEY_OFFSET + @as(c_int, 0xb1);
pub const ALT_R = KEY_OFFSET + @as(c_int, 0xb2);
pub const ALT_S = KEY_OFFSET + @as(c_int, 0xb3);
pub const ALT_T = KEY_OFFSET + @as(c_int, 0xb4);
pub const ALT_U = KEY_OFFSET + @as(c_int, 0xb5);
pub const ALT_V = KEY_OFFSET + @as(c_int, 0xb6);
pub const ALT_W = KEY_OFFSET + @as(c_int, 0xb7);
pub const ALT_X = KEY_OFFSET + @as(c_int, 0xb8);
pub const ALT_Y = KEY_OFFSET + @as(c_int, 0xb9);
pub const ALT_Z = KEY_OFFSET + @as(c_int, 0xba);
pub const CTL_LEFT = KEY_OFFSET + @as(c_int, 0xbb);
pub const CTL_RIGHT = KEY_OFFSET + @as(c_int, 0xbc);
pub const CTL_PGUP = KEY_OFFSET + @as(c_int, 0xbd);
pub const CTL_PGDN = KEY_OFFSET + @as(c_int, 0xbe);
pub const CTL_HOME = KEY_OFFSET + @as(c_int, 0xbf);
pub const CTL_END = KEY_OFFSET + @as(c_int, 0xc0);
pub const KEY_A1 = KEY_OFFSET + @as(c_int, 0xc1);
pub const KEY_A2 = KEY_OFFSET + @as(c_int, 0xc2);
pub const KEY_A3 = KEY_OFFSET + @as(c_int, 0xc3);
pub const KEY_B1 = KEY_OFFSET + @as(c_int, 0xc4);
pub const KEY_B2 = KEY_OFFSET + @as(c_int, 0xc5);
pub const KEY_B3 = KEY_OFFSET + @as(c_int, 0xc6);
pub const KEY_C1 = KEY_OFFSET + @as(c_int, 0xc7);
pub const KEY_C2 = KEY_OFFSET + @as(c_int, 0xc8);
pub const KEY_C3 = KEY_OFFSET + @as(c_int, 0xc9);
pub const PADSLASH = KEY_OFFSET + @as(c_int, 0xca);
pub const PADENTER = KEY_OFFSET + @as(c_int, 0xcb);
pub const CTL_PADENTER = KEY_OFFSET + @as(c_int, 0xcc);
pub const ALT_PADENTER = KEY_OFFSET + @as(c_int, 0xcd);
pub const PADSTOP = KEY_OFFSET + @as(c_int, 0xce);
pub const PADSTAR = KEY_OFFSET + @as(c_int, 0xcf);
pub const PADMINUS = KEY_OFFSET + @as(c_int, 0xd0);
pub const PADPLUS = KEY_OFFSET + @as(c_int, 0xd1);
pub const CTL_PADSTOP = KEY_OFFSET + @as(c_int, 0xd2);
pub const CTL_PADCENTER = KEY_OFFSET + @as(c_int, 0xd3);
pub const CTL_PADPLUS = KEY_OFFSET + @as(c_int, 0xd4);
pub const CTL_PADMINUS = KEY_OFFSET + @as(c_int, 0xd5);
pub const CTL_PADSLASH = KEY_OFFSET + @as(c_int, 0xd6);
pub const CTL_PADSTAR = KEY_OFFSET + @as(c_int, 0xd7);
pub const ALT_PADPLUS = KEY_OFFSET + @as(c_int, 0xd8);
pub const ALT_PADMINUS = KEY_OFFSET + @as(c_int, 0xd9);
pub const ALT_PADSLASH = KEY_OFFSET + @as(c_int, 0xda);
pub const ALT_PADSTAR = KEY_OFFSET + @as(c_int, 0xdb);
pub const ALT_PADSTOP = KEY_OFFSET + @as(c_int, 0xdc);
pub const CTL_INS = KEY_OFFSET + @as(c_int, 0xdd);
pub const ALT_DEL = KEY_OFFSET + @as(c_int, 0xde);
pub const ALT_INS = KEY_OFFSET + @as(c_int, 0xdf);
pub const CTL_UP = KEY_OFFSET + @as(c_int, 0xe0);
pub const CTL_DOWN = KEY_OFFSET + @as(c_int, 0xe1);
pub const CTL_DN = KEY_OFFSET + @as(c_int, 0xe1);
pub const CTL_TAB = KEY_OFFSET + @as(c_int, 0xe2);
pub const ALT_TAB = KEY_OFFSET + @as(c_int, 0xe3);
pub const ALT_MINUS = KEY_OFFSET + @as(c_int, 0xe4);
pub const ALT_EQUAL = KEY_OFFSET + @as(c_int, 0xe5);
pub const ALT_HOME = KEY_OFFSET + @as(c_int, 0xe6);
pub const ALT_PGUP = KEY_OFFSET + @as(c_int, 0xe7);
pub const ALT_PGDN = KEY_OFFSET + @as(c_int, 0xe8);
pub const ALT_END = KEY_OFFSET + @as(c_int, 0xe9);
pub const ALT_UP = KEY_OFFSET + @as(c_int, 0xea);
pub const ALT_DOWN = KEY_OFFSET + @as(c_int, 0xeb);
pub const ALT_RIGHT = KEY_OFFSET + @as(c_int, 0xec);
pub const ALT_LEFT = KEY_OFFSET + @as(c_int, 0xed);
pub const ALT_ENTER = KEY_OFFSET + @as(c_int, 0xee);
pub const ALT_ESC = KEY_OFFSET + @as(c_int, 0xef);
pub const ALT_BQUOTE = KEY_OFFSET + @as(c_int, 0xf0);
pub const ALT_LBRACKET = KEY_OFFSET + @as(c_int, 0xf1);
pub const ALT_RBRACKET = KEY_OFFSET + @as(c_int, 0xf2);
pub const ALT_SEMICOLON = KEY_OFFSET + @as(c_int, 0xf3);
pub const ALT_FQUOTE = KEY_OFFSET + @as(c_int, 0xf4);
pub const ALT_COMMA = KEY_OFFSET + @as(c_int, 0xf5);
pub const ALT_STOP = KEY_OFFSET + @as(c_int, 0xf6);
pub const ALT_FSLASH = KEY_OFFSET + @as(c_int, 0xf7);
pub const ALT_BKSP = KEY_OFFSET + @as(c_int, 0xf8);
pub const CTL_BKSP = KEY_OFFSET + @as(c_int, 0xf9);
pub const PAD0 = KEY_OFFSET + @as(c_int, 0xfa);
pub const CTL_PAD0 = KEY_OFFSET + @as(c_int, 0xfb);
pub const CTL_PAD1 = KEY_OFFSET + @as(c_int, 0xfc);
pub const CTL_PAD2 = KEY_OFFSET + @as(c_int, 0xfd);
pub const CTL_PAD3 = KEY_OFFSET + @as(c_int, 0xfe);
pub const CTL_PAD4 = KEY_OFFSET + @as(c_int, 0xff);
pub const CTL_PAD5 = KEY_OFFSET + @as(c_int, 0x100);
pub const CTL_PAD6 = KEY_OFFSET + @as(c_int, 0x101);
pub const CTL_PAD7 = KEY_OFFSET + @as(c_int, 0x102);
pub const CTL_PAD8 = KEY_OFFSET + @as(c_int, 0x103);
pub const CTL_PAD9 = KEY_OFFSET + @as(c_int, 0x104);
pub const ALT_PAD0 = KEY_OFFSET + @as(c_int, 0x105);
pub const ALT_PAD1 = KEY_OFFSET + @as(c_int, 0x106);
pub const ALT_PAD2 = KEY_OFFSET + @as(c_int, 0x107);
pub const ALT_PAD3 = KEY_OFFSET + @as(c_int, 0x108);
pub const ALT_PAD4 = KEY_OFFSET + @as(c_int, 0x109);
pub const ALT_PAD5 = KEY_OFFSET + @as(c_int, 0x10a);
pub const ALT_PAD6 = KEY_OFFSET + @as(c_int, 0x10b);
pub const ALT_PAD7 = KEY_OFFSET + @as(c_int, 0x10c);
pub const ALT_PAD8 = KEY_OFFSET + @as(c_int, 0x10d);
pub const ALT_PAD9 = KEY_OFFSET + @as(c_int, 0x10e);
pub const CTL_DEL = KEY_OFFSET + @as(c_int, 0x10f);
pub const ALT_BSLASH = KEY_OFFSET + @as(c_int, 0x110);
pub const CTL_ENTER = KEY_OFFSET + @as(c_int, 0x111);
pub const SHF_PADENTER = KEY_OFFSET + @as(c_int, 0x112);
pub const SHF_PADSLASH = KEY_OFFSET + @as(c_int, 0x113);
pub const SHF_PADSTAR = KEY_OFFSET + @as(c_int, 0x114);
pub const SHF_PADPLUS = KEY_OFFSET + @as(c_int, 0x115);
pub const SHF_PADMINUS = KEY_OFFSET + @as(c_int, 0x116);
pub const SHF_UP = KEY_OFFSET + @as(c_int, 0x117);
pub const SHF_DOWN = KEY_OFFSET + @as(c_int, 0x118);
pub const SHF_IC = KEY_OFFSET + @as(c_int, 0x119);
pub const SHF_DC = KEY_OFFSET + @as(c_int, 0x11a);
pub const KEY_MOUSE = KEY_OFFSET + @as(c_int, 0x11b);
pub const KEY_SHIFT_L = KEY_OFFSET + @as(c_int, 0x11c);
pub const KEY_SHIFT_R = KEY_OFFSET + @as(c_int, 0x11d);
pub const KEY_CONTROL_L = KEY_OFFSET + @as(c_int, 0x11e);
pub const KEY_CONTROL_R = KEY_OFFSET + @as(c_int, 0x11f);
pub const KEY_ALT_L = KEY_OFFSET + @as(c_int, 0x120);
pub const KEY_ALT_R = KEY_OFFSET + @as(c_int, 0x121);
pub const KEY_RESIZE = KEY_OFFSET + @as(c_int, 0x122);
pub const KEY_SUP = KEY_OFFSET + @as(c_int, 0x123);
pub const KEY_SDOWN = KEY_OFFSET + @as(c_int, 0x124);
pub const KEY_APPS = KEY_OFFSET + @as(c_int, 0x125);
pub const KEY_PAUSE = KEY_OFFSET + @as(c_int, 0x126);
pub const KEY_PRINTSCREEN = KEY_OFFSET + @as(c_int, 0x127);
pub const KEY_SCROLLLOCK = KEY_OFFSET + @as(c_int, 0x128);
pub const KEY_BROWSER_BACK = KEY_OFFSET + @as(c_int, 0x129);
pub const KEY_BROWSER_FWD = KEY_OFFSET + @as(c_int, 0x12a);
pub const KEY_BROWSER_REF = KEY_OFFSET + @as(c_int, 0x12b);
pub const KEY_BROWSER_STOP = KEY_OFFSET + @as(c_int, 0x12c);
pub const KEY_SEARCH = KEY_OFFSET + @as(c_int, 0x12d);
pub const KEY_FAVORITES = KEY_OFFSET + @as(c_int, 0x12e);
pub const KEY_BROWSER_HOME = KEY_OFFSET + @as(c_int, 0x12f);
pub const KEY_VOLUME_MUTE = KEY_OFFSET + @as(c_int, 0x130);
pub const KEY_VOLUME_DOWN = KEY_OFFSET + @as(c_int, 0x131);
pub const KEY_VOLUME_UP = KEY_OFFSET + @as(c_int, 0x132);
pub const KEY_NEXT_TRACK = KEY_OFFSET + @as(c_int, 0x133);
pub const KEY_PREV_TRACK = KEY_OFFSET + @as(c_int, 0x134);
pub const KEY_MEDIA_STOP = KEY_OFFSET + @as(c_int, 0x135);
pub const KEY_PLAY_PAUSE = KEY_OFFSET + @as(c_int, 0x136);
pub const KEY_LAUNCH_MAIL = KEY_OFFSET + @as(c_int, 0x137);
pub const KEY_MEDIA_SELECT = KEY_OFFSET + @as(c_int, 0x138);
pub const KEY_LAUNCH_APP1 = KEY_OFFSET + @as(c_int, 0x139);
pub const KEY_LAUNCH_APP2 = KEY_OFFSET + @as(c_int, 0x13a);
pub const KEY_LAUNCH_APP3 = KEY_OFFSET + @as(c_int, 0x13b);
pub const KEY_LAUNCH_APP4 = KEY_OFFSET + @as(c_int, 0x13c);
pub const KEY_LAUNCH_APP5 = KEY_OFFSET + @as(c_int, 0x13d);
pub const KEY_LAUNCH_APP6 = KEY_OFFSET + @as(c_int, 0x13e);
pub const KEY_LAUNCH_APP7 = KEY_OFFSET + @as(c_int, 0x13f);
pub const KEY_LAUNCH_APP8 = KEY_OFFSET + @as(c_int, 0x140);
pub const KEY_LAUNCH_APP9 = KEY_OFFSET + @as(c_int, 0x141);
pub const KEY_LAUNCH_APP10 = KEY_OFFSET + @as(c_int, 0x142);
pub const KEY_MIN = KEY_BREAK;
pub const KEY_MAX = KEY_LAUNCH_APP10;
pub inline fn KEY_F(n: anytype) @TypeOf(KEY_F0 + n) {
return KEY_F0 + n;
}
pub const initscr = initscr_x64;
pub const FUNCTION_KEY_SHUT_DOWN = @as(c_int, 0);
pub const FUNCTION_KEY_PASTE = @as(c_int, 1);
pub const FUNCTION_KEY_ENLARGE_FONT = @as(c_int, 2);
pub const FUNCTION_KEY_SHRINK_FONT = @as(c_int, 3);
pub const FUNCTION_KEY_CHOOSE_FONT = @as(c_int, 4);
pub const FUNCTION_KEY_ABORT = @as(c_int, 5);
pub const PDC_MAX_FUNCTION_KEYS = @as(c_int, 6);
pub inline fn getch() @TypeOf(wgetch(stdscr)) {
return wgetch(stdscr);
}
pub inline fn ungetch(ch: anytype) @TypeOf(PDC_ungetch(ch)) {
return PDC_ungetch(ch);
}
pub inline fn COLOR_PAIR(n: anytype) @TypeOf((@import("std").zig.c_translation.cast(chtype, n) << PDC_COLOR_SHIFT) & A_COLOR) {
return (@import("std").zig.c_translation.cast(chtype, n) << PDC_COLOR_SHIFT) & A_COLOR;
}
pub inline fn PAIR_NUMBER(n: anytype) @TypeOf((n & A_COLOR) >> PDC_COLOR_SHIFT) {
return (n & A_COLOR) >> PDC_COLOR_SHIFT;
}
pub inline fn PDC_save_key_modifiers(x: anytype) @TypeOf(OK) {
_ = x;
return OK;
}
pub inline fn PDC_get_input_fd() @TypeOf(@as(c_int, 0)) {
return @as(c_int, 0);
}
pub const PDC_BOX_DOUBLED_V = @as(c_int, 1);
pub const PDC_BOX_DOUBLED_H = @as(c_int, 2);
pub const PDC_CLIP_SUCCESS = @as(c_int, 0);
pub const PDC_CLIP_ACCESS_ERROR = @as(c_int, 1);
pub const PDC_CLIP_EMPTY = @as(c_int, 2);
pub const PDC_CLIP_MEMORY_ERROR = @as(c_int, 3);
pub const PDC_KEY_MODIFIER_SHIFT = @as(c_int, 1);
pub const PDC_KEY_MODIFIER_CONTROL = @as(c_int, 2);
pub const PDC_KEY_MODIFIER_ALT = @as(c_int, 4);
pub const PDC_KEY_MODIFIER_NUMLOCK = @as(c_int, 8);
pub const PDC_KEY_MODIFIER_REPEAT = @as(c_int, 16);
pub const TRACE_DISABLE = @as(c_int, 0x0000);
pub const TRACE_TIMES = @as(c_int, 0x0001);
pub const TRACE_TPUTS = @as(c_int, 0x0002);
pub const TRACE_UPDATE = @as(c_int, 0x0004);
pub const TRACE_MOVE = @as(c_int, 0x0008);
pub const TRACE_CHARPUT = @as(c_int, 0x0010);
pub const TRACE_ORDINARY = @as(c_int, 0x001F);
pub const TRACE_CALLS = @as(c_int, 0x0020);
pub const TRACE_VIRTPUT = @as(c_int, 0x0040);
pub const TRACE_IEVENT = @as(c_int, 0x0080);
pub const TRACE_BITS = @as(c_int, 0x0100);
pub const TRACE_ICALLS = @as(c_int, 0x0200);
pub const TRACE_CCALLS = @as(c_int, 0x0400);
pub const TRACE_DATABASE = @as(c_int, 0x0800);
pub const TRACE_ATTRS = @as(c_int, 0x1000);
pub const TRACE_SHIFT = @as(c_int, 13);
pub const TRACE_MAXIMUM = (@as(c_uint, 1) << TRACE_SHIFT) - @as(c_uint, 1);
pub const tagLC_ID = struct_tagLC_ID;
pub const lconv = struct_lconv;
pub const __lc_time_data = struct___lc_time_data;
pub const threadlocaleinfostruct = struct_threadlocaleinfostruct;
pub const threadmbcinfostruct = struct_threadmbcinfostruct;
pub const localeinfo_struct = struct_localeinfo_struct;
pub const _iobuf = struct__iobuf;
pub const PDC_port = enum_PDC_port;
pub const _win = struct__win; | src/pdcurses.zig |
const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
const CharStream = struct {
string: []const u8,
i: usize = 0,
pub fn init(string: []const u8) CharStream {
return .{ .string = string };
}
pub fn next(self: *CharStream) ?u8 {
if (self.i < self.string.len) {
defer self.i += 1;
return self.string[self.i];
}
return null;
}
pub fn match(self: *CharStream, ch: u8) bool {
if (self.peek()) |c| {
if (c == ch) {
self.i += 1;
return true;
}
}
return false;
}
pub fn peek(self: CharStream) ?u8 {
if (self.i < self.string.len) {
return self.string[self.i];
}
return null;
}
pub fn eof(self: CharStream) bool {
return self.i >= self.string.len;
}
pub fn reset(self: *CharStream) void {
self.i = 0;
}
};
pub fn templ(allocator: Allocator, string: []const u8, data: anytype) ![]u8 {
const data_type = @TypeOf(data);
const type_info = @typeInfo(data_type);
const fields = switch (type_info) {
.Struct => |s| s.fields,
else => {
return error.InvalidDataType;
},
};
var len: i64 = 0;
var stream = CharStream.init(string);
var buffer: []u8 = undefined;
var wr: std.io.FixedBufferStream([]u8).Writer = undefined;
var i: usize = 0;
while (i < 2) : (i += 1) {
if (i == 1) {
buffer = try allocator.alloc(u8, @intCast(usize, len));
wr = std.io.fixedBufferStream(buffer).writer();
stream.reset();
}
while (stream.next()) |ch| {
if (ch == '$' and stream.match('{')) {
var annotation_len: usize = 2;
var annotation_name_start: usize = stream.i;
var annotation_name_end: usize = stream.i;
while (stream.next()) |ch3| {
annotation_len += 1;
if (ch3 == '}') {
annotation_name_end = stream.i - 1;
break;
}
}
var name = string[annotation_name_start..annotation_name_end];
inline for (fields) |field| {
if (std.mem.eql(u8, field.name, name)) {
const dat_field = @field(data, field.name);
const field_type = @TypeOf(dat_field);
if (i == 0) {
var final_len: usize = switch (@typeInfo(field_type)) {
.Int, .Float, .ComptimeInt, .ComptimeFloat => std.fmt.count("{}", .{dat_field}),
.Pointer => |p| switch (p.size) {
.Slice => dat_field.len,
.Many => @bitCast([]const u8, dat_field).len,
.One => switch (@typeInfo(p.child)) {
.Array => @as([]const u8, dat_field).len,
else => return error.InvalidFieldType,
},
.C => return error.InvalidFieldType,
},
else => return error.InvalidFieldType,
};
len += @intCast(i64, final_len) - 1;
} else {
// NOTE: I store the error here because if I try to return the error from inside the switch I get a compiler crash (bug).
var typeError: ?anyerror = null;
switch (@typeInfo(field_type)) {
.Int, .Float, .ComptimeInt, .ComptimeFloat => {
try wr.print("{}", .{dat_field});
},
.Pointer => |ptr| switch (ptr.size) {
.Slice => {
if (ptr.child == u8) {
try wr.writeAll(dat_field);
} else {
typeError = error.InvalidSliceChildType;
}
},
.Many => {
typeError = error.TypeNotImplemented;
},
.One => switch (@typeInfo(ptr.child)) {
.Array => |arr| {
if (arr.child == u8) {
try wr.writeAll(dat_field);
} else {
typeError = error.InvalidArrayChildType;
}
},
else => {
typeError = error.TypeNotImplemented;
},
},
.C => {
typeError = error.TypeNotImplemented;
},
},
else => {
typeError = error.TypeNotImplemented;
},
}
if (typeError != null) {
return typeError.?;
}
}
break;
}
}
} else if (i == 1) {
try wr.writeByte(ch);
}
if (i == 0) {
len += 1;
}
}
}
return buffer;
}
const expect = std.testing.expect;
const test_allocator = std.testing.allocator;
test "basic" {
var template = "My name is ${name}";
var output = try templ(test_allocator, template, .{ .name = "Daniel" });
defer test_allocator.free(output);
try expect(std.mem.eql(u8, output, "My name is Daniel"));
}
test "with numbers" {
var template = "Eath's average radius is ${radius} km";
var output = try templ(test_allocator, template, .{ .radius = 6371 });
defer test_allocator.free(output);
try expect(std.mem.eql(u8, output, "Eath's average radius is 6371 km"));
} | src/main.zig |
const std = @import("std");
pub const Interpreter = @import("spu-mk2/interpreter.zig").Interpreter;
pub const ExecutionCondition = enum(u3) {
always = 0,
when_zero = 1,
not_zero = 2,
greater_zero = 3,
less_than_zero = 4,
greater_or_equal_zero = 5,
less_or_equal_zero = 6,
overflow = 7,
};
pub const InputBehaviour = enum(u2) {
zero = 0,
immediate = 1,
peek = 2,
pop = 3,
};
pub const OutputBehaviour = enum(u2) {
discard = 0,
push = 1,
jump = 2,
jump_relative = 3,
};
pub const Command = enum(u5) {
copy = 0,
ipget = 1,
get = 2,
set = 3,
store8 = 4,
store16 = 5,
load8 = 6,
load16 = 7,
undefined0 = 8,
undefined1 = 9,
frget = 10,
frset = 11,
bpget = 12,
bpset = 13,
spget = 14,
spset = 15,
add = 16,
sub = 17,
mul = 18,
div = 19,
mod = 20,
@"and" = 21,
@"or" = 22,
xor = 23,
not = 24,
signext = 25,
rol = 26,
ror = 27,
bswap = 28,
asr = 29,
lsl = 30,
lsr = 31,
};
pub const Instruction = packed struct {
condition: ExecutionCondition,
input0: InputBehaviour,
input1: InputBehaviour,
modify_flags: bool,
output: OutputBehaviour,
command: Command,
reserved: u1 = 0,
pub fn format(instr: Instruction, comptime fmt: []const u8, options: std.fmt.FormatOptions, out: anytype) !void {
try std.fmt.format(out, "0x{x:0<4} ", .{@bitCast(u16, instr)});
try out.writeAll(switch (instr.condition) {
.always => " ",
.when_zero => "== 0",
.not_zero => "!= 0",
.greater_zero => " > 0",
.less_than_zero => " < 0",
.greater_or_equal_zero => ">= 0",
.less_or_equal_zero => "<= 0",
.overflow => "ovfl",
});
try out.writeAll(" ");
try out.writeAll(switch (instr.input0) {
.zero => "zero",
.immediate => "imm ",
.peek => "peek",
.pop => "pop ",
});
try out.writeAll(" ");
try out.writeAll(switch (instr.input1) {
.zero => "zero",
.immediate => "imm ",
.peek => "peek",
.pop => "pop ",
});
try out.writeAll(" ");
try out.writeAll(switch (instr.command) {
.copy => "copy ",
.ipget => "ipget ",
.get => "get ",
.set => "set ",
.store8 => "store8 ",
.store16 => "store16 ",
.load8 => "load8 ",
.load16 => "load16 ",
.undefined0 => "undefined",
.undefined1 => "undefined",
.frget => "frget ",
.frset => "frset ",
.bpget => "bpget ",
.bpset => "bpset ",
.spget => "spget ",
.spset => "spset ",
.add => "add ",
.sub => "sub ",
.mul => "mul ",
.div => "div ",
.mod => "mod ",
.@"and" => "and ",
.@"or" => "or ",
.xor => "xor ",
.not => "not ",
.signext => "signext ",
.rol => "rol ",
.ror => "ror ",
.bswap => "bswap ",
.asr => "asr ",
.lsl => "lsl ",
.lsr => "lsr ",
});
try out.writeAll(" ");
try out.writeAll(switch (instr.output) {
.discard => "discard",
.push => "push ",
.jump => "jmp ",
.jump_relative => "rjmp ",
});
try out.writeAll(" ");
try out.writeAll(if (instr.modify_flags)
"+ flags"
else
" ");
}
};
pub const FlagRegister = packed struct {
zero: bool,
negative: bool,
carry: bool,
carry_enabled: bool,
interrupt0_enabled: bool,
interrupt1_enabled: bool,
interrupt2_enabled: bool,
interrupt3_enabled: bool,
reserved: u8 = 0,
};
pub const Register = enum {
dummy,
pub fn allocIndex(self: Register) ?u4 {
return null;
}
};
pub const callee_preserved_regs = [_]Register{}; | src/codegen/spu-mk2.zig |
const std = @import("std");
usingnamespace (@import("../machine.zig"));
usingnamespace (@import("../util.zig"));
test "AVX" {
const m32 = Machine.init(.x86_32);
const m64 = Machine.init(.x64);
const reg = Operand.register;
const pred = Operand.registerPredicate;
const predRm = Operand.rmPredicate;
const sae = Operand.registerSae;
const regRm = Operand.registerRm;
const imm = Operand.immediate;
const vm32xl = Operand.memoryVecSib(.DefaultSeg, .DWORD, 8, .XMM7, .EAX, 0);
const vm32yl = Operand.memoryVecSib(.DefaultSeg, .DWORD, 8, .YMM7, .EAX, 0);
const vm64xl = Operand.memoryVecSib(.DefaultSeg, .QWORD, 8, .XMM7, .EAX, 0);
const vm64yl = Operand.memoryVecSib(.DefaultSeg, .QWORD, 8, .YMM7, .EAX, 0);
const vm32x = Operand.memoryVecSib(.DefaultSeg, .DWORD, 8, .XMM30, .EAX, 0);
const vm32y = Operand.memoryVecSib(.DefaultSeg, .DWORD, 8, .YMM30, .EAX, 0);
const vm32z = Operand.memoryVecSib(.DefaultSeg, .DWORD, 8, .ZMM30, .EAX, 0);
const vm64x = Operand.memoryVecSib(.DefaultSeg, .QWORD, 8, .XMM30, .EAX, 0);
const vm64y = Operand.memoryVecSib(.DefaultSeg, .QWORD, 8, .YMM30, .EAX, 0);
const vm64z = Operand.memoryVecSib(.DefaultSeg, .QWORD, 8, .ZMM30, .EAX, 0);
const rm8 = Operand.memoryRm(.DefaultSeg, .BYTE, .EAX, 0);
const rm16 = Operand.memoryRm(.DefaultSeg, .WORD, .EAX, 0);
const rm32 = Operand.memoryRm(.DefaultSeg, .DWORD, .EAX, 0);
const rm64 = Operand.memoryRm(.DefaultSeg, .QWORD, .EAX, 0);
const mem_64 = rm64;
const rm_mem8 = Operand.memoryRm(.DefaultSeg, .BYTE, .EAX, 0);
const rm_mem16 = Operand.memoryRm(.DefaultSeg, .WORD, .EAX, 0);
const rm_mem32 = Operand.memoryRm(.DefaultSeg, .DWORD, .EAX, 0);
const rm_mem64 = Operand.memoryRm(.DefaultSeg, .QWORD, .EAX, 0);
const rm_mem128 = Operand.memoryRm(.DefaultSeg, .XMM_WORD, .EAX, 0);
const rm_mem256 = Operand.memoryRm(.DefaultSeg, .YMM_WORD, .EAX, 0);
const rm_mem512 = Operand.memoryRm(.DefaultSeg, .ZMM_WORD, .EAX, 0);
const m32bcst = Operand.memoryRm(.DefaultSeg, .DWORD_BCST, .EAX, 0);
const m64bcst = Operand.memoryRm(.DefaultSeg, .QWORD_BCST, .EAX, 0);
debugPrint(false);
{
testOp0(m32, .VZEROALL, "c5 fc 77");
testOp0(m32, .VZEROUPPER, "c5 f8 77");
testOp1(m32, .VLDMXCSR, rm_mem32, "c5 f8 ae 10");
testOp1(m64, .VLDMXCSR, rm_mem32, "67 c5 f8 ae 10");
testOp1(m32, .VSTMXCSR, rm_mem32, "c5 f8 ae 18");
testOp1(m64, .VSTMXCSR, rm_mem32, "67 c5 f8 ae 18");
}
// test 4 operands
{
testOp4(m32, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4c c0 00");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4c c0 00");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM15), "c4 e3 79 4c c0 F0");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM31), AsmError.InvalidOperand);
}
{
testOp4(m32, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4c c0 00");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4c c0 00");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM15), "c4 e3 79 4c c0 F0");
testOp4(m64, .VPBLENDVB, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM31), AsmError.InvalidOperand);
}
// test VMOV
{
{
testOp2(m32, .VMOVD, reg(.XMM0), rm32, "c5 f9 6e 00");
testOp2(m32, .VMOVD, reg(.XMM7), rm32, "c5 f9 6e 38");
testOp2(m32, .VMOVD, reg(.XMM15), rm32, AsmError.InvalidMode);
testOp2(m32, .VMOVD, reg(.XMM31), rm32, AsmError.InvalidMode);
//
testOp2(m64, .VMOVD, reg(.XMM0), rm32, "67 c5 f9 6e 00");
testOp2(m64, .VMOVD, reg(.XMM7), rm32, "67 c5 f9 6e 38");
testOp2(m64, .VMOVD, reg(.XMM15), rm32, "67 c5 79 6e 38");
testOp2(m64, .VMOVD, reg(.XMM31), rm32, "67 62 61 7d 08 6e 38");
}
{
testOp2(m32, .VMOVD, reg(.XMM0), rm64, AsmError.InvalidOperand);
testOp2(m32, .VMOVD, reg(.XMM7), rm64, AsmError.InvalidOperand);
testOp2(m32, .VMOVD, reg(.XMM15), rm64, AsmError.InvalidOperand);
testOp2(m32, .VMOVD, reg(.XMM31), rm64, AsmError.InvalidOperand);
//
testOp2(m64, .VMOVD, reg(.XMM0), rm64, "67 c4 e1 f9 6e 00");
testOp2(m64, .VMOVD, reg(.XMM7), rm64, "67 c4 e1 f9 6e 38");
testOp2(m64, .VMOVD, reg(.XMM15), rm64, "67 c4 61 f9 6e 38");
testOp2(m64, .VMOVD, reg(.XMM31), rm64, "67 62 61 fd 08 6e 38");
}
{
testOp2(m32, .VMOVQ, reg(.XMM0), reg(.RAX), AsmError.InvalidOperand);
testOp2(m32, .VMOVQ, reg(.XMM15), reg(.RAX), AsmError.InvalidOperand);
//
testOp2(m64, .VMOVQ, reg(.XMM0), reg(.RAX), "c4 e1 f9 6e C0");
testOp2(m64, .VMOVQ, reg(.XMM15), reg(.RAX), "c4 61 f9 6e F8");
testOp2(m64, .VMOVQ, reg(.XMM31), reg(.RAX), "62 61 fd 08 6e f8");
}
{
testOp2(m32, .VMOVQ, reg(.RAX), reg(.XMM0), AsmError.InvalidOperand);
testOp2(m32, .VMOVQ, reg(.RAX), reg(.XMM15), AsmError.InvalidOperand);
//
testOp2(m64, .VMOVQ, reg(.RAX), reg(.XMM0), "c4 e1 f9 7e C0");
testOp2(m64, .VMOVQ, reg(.RAX), reg(.XMM15), "c4 61 f9 7e F8");
testOp2(m64, .VMOVQ, reg(.RAX), reg(.XMM31), "62 61 fd 08 7e f8");
}
{
testOp2(m32, .VMOVQ, reg(.XMM0), mem_64, "c5 fa 7e 00");
testOp2(m32, .VMOVQ, reg(.XMM7), mem_64, "c5 fa 7e 38");
testOp2(m32, .VMOVQ, reg(.XMM15), mem_64, AsmError.InvalidMode);
//
testOp2(m64, .VMOVQ, reg(.XMM0), mem_64, "67 c5 fa 7e 00");
testOp2(m64, .VMOVQ, reg(.XMM7), mem_64, "67 c5 fa 7e 38");
testOp2(m64, .VMOVQ, reg(.XMM15), mem_64, "67 c5 7a 7e 38");
testOp2(m64, .VMOVQ, reg(.XMM31), mem_64, "67 62 61 fe 08 7e 38");
//
testOp2(m64, .VMOVD, reg(.XMM0), mem_64, "67 c4 e1 f9 6e 00");
testOp2(m64, .VMOVD, reg(.XMM7), mem_64, "67 c4 e1 f9 6e 38");
testOp2(m64, .VMOVD, reg(.XMM15), mem_64, "67 c4 61 f9 6e 38");
testOp2(m64, .VMOVD, reg(.XMM31), mem_64, "67 62 61 fd 08 6e 38");
}
{
testOp2(m32, .VMOVQ, mem_64, reg(.XMM0), "c5 f9 d6 00");
testOp2(m32, .VMOVQ, mem_64, reg(.XMM7), "c5 f9 d6 38");
testOp2(m32, .VMOVQ, mem_64, reg(.XMM15), AsmError.InvalidMode);
//
testOp2(m64, .VMOVQ, mem_64, reg(.XMM0), "67 c5 f9 d6 00");
testOp2(m64, .VMOVQ, mem_64, reg(.XMM7), "67 c5 f9 d6 38");
testOp2(m64, .VMOVQ, mem_64, reg(.XMM15), "67 c5 79 d6 38");
testOp2(m64, .VMOVQ, mem_64, reg(.XMM31), "67 62 61 fd 08 d6 38");
//
testOp2(m64, .VMOVD, mem_64, reg(.XMM0), "67 c4 e1 f9 7e 00");
testOp2(m64, .VMOVD, mem_64, reg(.XMM7), "67 c4 e1 f9 7e 38");
testOp2(m64, .VMOVD, mem_64, reg(.XMM15), "67 c4 61 f9 7e 38");
testOp2(m64, .VMOVD, mem_64, reg(.XMM31), "67 62 61 fd 08 7e 38");
}
{
testOp2(m32, .VMOVQ, reg(.XMM0), reg(.XMM0), "c5 fa 7e c0");
testOp2(m32, .VMOVQ, reg(.XMM7), reg(.XMM7), "c5 fa 7e ff");
testOp2(m32, .VMOVQ, reg(.XMM15), reg(.XMM15), AsmError.InvalidMode);
//
testOp2(m32, .VMOVQ, regRm(.XMM0), reg(.XMM0), "c5 f9 d6 c0");
testOp2(m32, .VMOVQ, regRm(.XMM7), reg(.XMM7), "c5 f9 d6 ff");
testOp2(m32, .VMOVQ, regRm(.XMM15), reg(.XMM15), AsmError.InvalidMode);
//
testOp2(m64, .VMOVQ, reg(.XMM0), reg(.XMM0), "c5 fa 7e c0");
testOp2(m64, .VMOVQ, reg(.XMM7), reg(.XMM7), "c5 fa 7e ff");
testOp2(m64, .VMOVQ, reg(.XMM15), reg(.XMM15), "c4 41 7a 7e ff");
testOp2(m64, .VMOVQ, reg(.XMM31), reg(.XMM31), "62 01 fe 08 7e ff");
//
testOp2(m64, .VMOVQ, regRm(.XMM0), reg(.XMM0), "c5 f9 d6 c0");
testOp2(m64, .VMOVQ, regRm(.XMM7), reg(.XMM7), "c5 f9 d6 ff");
testOp2(m64, .VMOVQ, regRm(.XMM15), reg(.XMM15), "c4 41 79 d6 ff");
testOp2(m64, .VMOVQ, regRm(.XMM31), reg(.XMM31), "62 01 fd 08 d6 ff");
}
}
{
testOp4(m64, .VBLENDPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 79 0d c0 00");
testOp4(m64, .VBLENDPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c4 e3 7d 0d c0 00");
testOp4(m64, .VBLENDPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 79 0c c0 00");
testOp4(m64, .VBLENDPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c4 e3 7d 0c c0 00");
}
{
testOp4(m64, .VBLENDVPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4b c0 00");
testOp4(m64, .VBLENDVPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), reg(.YMM0), "c4 e3 7d 4b c0 00");
testOp4(m64, .VBLENDVPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e3 79 4a c0 00");
testOp4(m64, .VBLENDVPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), reg(.YMM0), "c4 e3 7d 4a c0 00");
}
{
testOp3(m64, .VANDPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 54 c0");
testOp3(m64, .VANDPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 54 c0");
testOp3(m64, .VANDPD, pred(.XMM0, .K7, .Merge), reg(.XMM0), reg(.XMM0), "62 f1 fd 0f 54 c0");
testOp3(m64, .VANDPD, pred(.YMM0, .K7, .Merge), reg(.YMM0), reg(.YMM0), "62 f1 fd 2f 54 c0");
testOp3(m64, .VANDPD, pred(.ZMM0, .K7, .Merge), reg(.ZMM0), reg(.ZMM0), "62 f1 fd 4f 54 c0");
//
testOp3(m64, .VANDPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f8 54 c0");
testOp3(m64, .VANDPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fc 54 c0");
testOp3(m64, .VANDPS, pred(.XMM0, .K7, .Merge), reg(.XMM0), reg(.XMM0), "62 f1 7c 0f 54 c0");
testOp3(m64, .VANDPS, pred(.YMM0, .K7, .Merge), reg(.YMM0), reg(.YMM0), "62 f1 7c 2f 54 c0");
testOp3(m64, .VANDPS, pred(.ZMM0, .K7, .Merge), reg(.ZMM0), reg(.ZMM0), "62 f1 7c 4f 54 c0");
}
{
testOp3(m64, .VANDNPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 55 c0");
testOp3(m64, .VANDNPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 55 c0");
testOp3(m64, .VANDNPD, pred(.XMM0, .K7, .Merge), reg(.XMM0), reg(.XMM0), "62 f1 fd 0f 55 c0");
testOp3(m64, .VANDNPD, pred(.YMM0, .K7, .Merge), reg(.YMM0), reg(.YMM0), "62 f1 fd 2f 55 c0");
testOp3(m64, .VANDNPD, pred(.ZMM0, .K7, .Merge), reg(.ZMM0), reg(.ZMM0), "62 f1 fd 4f 55 c0");
//
testOp3(m64, .VANDNPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f8 55 c0");
testOp3(m64, .VANDNPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fc 55 c0");
testOp3(m64, .VANDNPS, pred(.XMM0, .K7, .Merge), reg(.XMM0), reg(.XMM0), "62 f1 7c 0f 55 c0");
testOp3(m64, .VANDNPS, pred(.YMM0, .K7, .Merge), reg(.YMM0), reg(.YMM0), "62 f1 7c 2f 55 c0");
testOp3(m64, .VANDNPS, pred(.ZMM0, .K7, .Merge), reg(.ZMM0), reg(.ZMM0), "62 f1 7c 4f 55 c0");
}
{
testOp4(m64, .VCMPPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c5 f9 c2 c0 00");
testOp4(m64, .VCMPPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c5 fd c2 c0 00");
testOp4(m64, .VCMPPD, pred(.K0, .K7, .Merge), reg(.XMM0), reg(.XMM0), imm(0), "62 f1 fd 0f c2 c0 00");
testOp4(m64, .VCMPPD, pred(.K0, .K7, .Merge), reg(.YMM0), reg(.YMM0), imm(0), "62 f1 fd 2f c2 c0 00");
testOp4(m64, .VCMPPD, pred(.K0, .K7, .Merge), reg(.ZMM0), sae(.ZMM0, .SAE), imm(0), "62 f1 fd 5f c2 c0 00");
//
testOp4(m64, .VCMPPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c5 f8 c2 c0 00");
testOp4(m64, .VCMPPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c5 fc c2 c0 00");
testOp4(m64, .VCMPPS, pred(.K0, .K7, .Merge), reg(.XMM0), reg(.XMM0), imm(0), "62 f1 7c 0f c2 c0 00");
testOp4(m64, .VCMPPS, pred(.K0, .K7, .Merge), reg(.YMM0), reg(.YMM0), imm(0), "62 f1 7c 2f c2 c0 00");
testOp4(m64, .VCMPPS, pred(.K0, .K7, .Merge), reg(.ZMM0), sae(.ZMM0, .SAE), imm(0), "62 f1 7c 5f c2 c0 00");
}
{
testOp4(m64, .VCMPSD, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c5 fb c2 c0 00");
testOp4(m64, .VCMPSD, pred(.K0, .K7, .Merge), reg(.XMM0), sae(.XMM0, .SAE), imm(0), "62 f1 ff 1f c2 c0 00");
//
testOp4(m64, .VCMPSS, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c5 fa c2 c0 00");
testOp4(m64, .VCMPSS, pred(.K0, .K7, .Merge), reg(.XMM0), sae(.XMM0, .SAE), imm(0), "62 f1 7e 1f c2 c0 00");
}
{
// VCOMISD
testOp2(m64, .VCOMISD, reg(.XMM0), reg(.XMM0), "c5 f9 2f c0");
testOp2(m64, .VCOMISD, reg(.XMM0), sae(.XMM0, .SAE), "62 f1 fd 18 2f c0");
// VCOMISS
testOp2(m64, .VCOMISS, reg(.XMM0), reg(.XMM0), "c5 f8 2f c0");
testOp2(m64, .VCOMISS, reg(.XMM0), sae(.XMM0, .SAE), "62 f1 7c 18 2f c0");
}
{
// VCVTDQ2PD
testOp2(m64, .VCVTDQ2PD, reg(.XMM0), reg(.XMM0), "c5 fa e6 c0");
testOp2(m64, .VCVTDQ2PD, reg(.YMM0), reg(.XMM0), "c5 fe e6 c0");
testOp2(m64, .VCVTDQ2PD, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 7e 8f e6 c0");
testOp2(m64, .VCVTDQ2PD, pred(.YMM0, .K7, .Zero), reg(.XMM0), "62 f1 7e af e6 c0");
testOp2(m64, .VCVTDQ2PD, pred(.ZMM0, .K7, .Zero), reg(.YMM0), "62 f1 7e cf e6 c0");
// VCVTDQ2PS
testOp2(m64, .VCVTDQ2PS, reg(.XMM0), reg(.XMM0), "c5 f8 5b c0");
testOp2(m64, .VCVTDQ2PS, reg(.YMM0), reg(.YMM0), "c5 fc 5b c0");
testOp2(m64, .VCVTDQ2PS, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 7c 8f 5b c0");
testOp2(m64, .VCVTDQ2PS, pred(.YMM0, .K7, .Zero), reg(.YMM0), "62 f1 7c af 5b c0");
testOp2(m64, .VCVTDQ2PS, pred(.ZMM0, .K7, .Zero), sae(.ZMM0, .RN_SAE), "62 f1 7c 9f 5b c0");
// VCVTPD2DQ
testOp2(m64, .VCVTPD2DQ, reg(.XMM0), reg(.XMM0), "c5 fb e6 c0");
testOp2(m64, .VCVTPD2DQ, reg(.XMM0), reg(.YMM0), "c5 ff e6 c0");
testOp2(m64, .VCVTPD2DQ, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 ff 8f e6 c0");
testOp2(m64, .VCVTPD2DQ, pred(.XMM0, .K7, .Zero), reg(.YMM0), "62 f1 ff af e6 c0");
testOp2(m64, .VCVTPD2DQ, pred(.YMM0, .K7, .Zero), sae(.ZMM0, .RN_SAE), "62 f1 ff 9f e6 c0");
// VCVTPD2PS
testOp2(m64, .VCVTPD2PS, reg(.XMM0), reg(.XMM0), "c5 f9 5a c0");
testOp2(m64, .VCVTPD2PS, reg(.XMM0), reg(.YMM0), "c5 fd 5a c0");
testOp2(m64, .VCVTPD2PS, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 fd 8f 5a c0");
testOp2(m64, .VCVTPD2PS, pred(.XMM0, .K7, .Zero), reg(.YMM0), "62 f1 fd af 5a c0");
testOp2(m64, .VCVTPD2PS, pred(.YMM0, .K7, .Zero), sae(.ZMM0, .RN_SAE), "62 f1 fd 9f 5a c0");
// VCVTPS2DQ
testOp2(m64, .VCVTPS2DQ, reg(.XMM0), reg(.XMM0), "c5 f9 5b c0");
testOp2(m64, .VCVTPS2DQ, reg(.YMM0), reg(.YMM0), "c5 fd 5b c0");
testOp2(m64, .VCVTPS2DQ, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 7d 8f 5b c0");
testOp2(m64, .VCVTPS2DQ, pred(.YMM0, .K7, .Zero), reg(.YMM0), "62 f1 7d af 5b c0");
testOp2(m64, .VCVTPS2DQ, pred(.ZMM0, .K7, .Zero), sae(.ZMM0, .RN_SAE), "62 f1 7d 9f 5b c0");
// VCVTPS2PD
testOp2(m64, .VCVTPS2PD, reg(.XMM0), reg(.XMM0), "c5 f8 5a c0");
testOp2(m64, .VCVTPS2PD, reg(.YMM0), reg(.XMM0), "c5 fc 5a c0");
testOp2(m64, .VCVTPS2PD, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 7c 8f 5a c0");
testOp2(m64, .VCVTPS2PD, pred(.YMM0, .K7, .Zero), reg(.XMM0), "62 f1 7c af 5a c0");
testOp2(m64, .VCVTPS2PD, pred(.ZMM0, .K7, .Zero), sae(.YMM0, .SAE), "62 f1 7c df 5a c0");
// VCVTSD2SI
testOp2(m64, .VCVTSD2SI, reg(.EAX), reg(.XMM0), "c5 fb 2d c0");
testOp2(m64, .VCVTSD2SI, reg(.RAX), reg(.XMM0), "c4 e1 fb 2d c0");
testOp2(m64, .VCVTSD2SI, reg(.EAX), sae(.XMM0, .RN_SAE), "62 f1 7f 18 2d c0");
testOp2(m64, .VCVTSD2SI, reg(.RAX), sae(.XMM0, .RN_SAE), "62 f1 ff 18 2d c0");
// VCVTSD2SS
testOp3(m64, .VCVTSD2SS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 5a c0");
testOp3(m64, .VCVTSD2SS, pred(.XMM0, .K7, .Zero), reg(.XMM0), sae(.XMM0, .RN_SAE), "62 f1 ff 9f 5a c0");
// VCVTSI2SD
testOp3(m64, .VCVTSI2SD, reg(.XMM0), reg(.XMM0), rm32, "67 c5 fb 2a 00");
testOp3(m64, .VCVTSI2SD, reg(.XMM0), reg(.XMM0), rm64, "67 c4 e1 fb 2a 00");
testOp3(m64, .VCVTSI2SD, reg(.XMM0), reg(.XMM0), rm32, "67 c5 fb 2a 00");
testOp3(m64, .VCVTSI2SD, reg(.XMM0), reg(.XMM0), sae(.RAX, .RN_SAE), "62 f1 ff 18 2a c0");
// VCVTSI2SS
testOp3(m64, .VCVTSI2SS, reg(.XMM0), reg(.XMM0), rm32, "67 c5 fa 2a 00");
testOp3(m64, .VCVTSI2SS, reg(.XMM0), reg(.XMM0), rm64, "67 c4 e1 fa 2a 00");
testOp3(m64, .VCVTSI2SS, reg(.XMM0), reg(.XMM0), sae(.EAX, .RN_SAE), "62 f1 7e 18 2a c0");
testOp3(m64, .VCVTSI2SS, reg(.XMM0), reg(.XMM0), sae(.RAX, .RN_SAE), "62 f1 fe 18 2a c0");
// VCVTSS2SD
testOp3(m64, .VCVTSS2SD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fa 5a c0");
testOp3(m64, .VCVTSS2SD, pred(.XMM0, .K7, .Zero), reg(.XMM0), sae(.XMM0, .SAE), "62 f1 7e 9f 5a c0");
// VCVTSS2SI
testOp2(m64, .VCVTSS2SI, reg(.EAX), reg(.XMM0), "c5 fa 2d c0");
testOp2(m64, .VCVTSS2SI, reg(.RAX), reg(.XMM0), "c4 e1 fa 2d c0");
testOp2(m64, .VCVTSS2SI, reg(.EAX), sae(.XMM0, .RN_SAE), "62 f1 7e 18 2d c0");
testOp2(m64, .VCVTSS2SI, reg(.RAX), sae(.XMM0, .RN_SAE), "62 f1 fe 18 2d c0");
// VCVTTPD2DQ
testOp2(m64, .VCVTTPD2DQ, reg(.XMM0), reg(.XMM0), "c5 f9 e6 c0");
testOp2(m64, .VCVTTPD2DQ, reg(.XMM0), reg(.YMM0), "c5 fd e6 c0");
testOp2(m64, .VCVTTPD2DQ, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 fd 8f e6 c0");
testOp2(m64, .VCVTTPD2DQ, pred(.XMM0, .K7, .Zero), reg(.YMM0), "62 f1 fd af e6 c0");
testOp2(m64, .VCVTTPD2DQ, pred(.YMM0, .K7, .Zero), sae(.ZMM0, .SAE), "62 f1 fd df e6 c0");
// VCVTTPS2DQ
testOp2(m64, .VCVTTPS2DQ, reg(.XMM0), reg(.XMM0), "c5 fa 5b c0");
testOp2(m64, .VCVTTPS2DQ, reg(.YMM0), reg(.YMM0), "c5 fe 5b c0");
testOp2(m64, .VCVTTPS2DQ, pred(.XMM0, .K7, .Zero), reg(.XMM0), "62 f1 7e 8f 5b c0");
testOp2(m64, .VCVTTPS2DQ, pred(.YMM0, .K7, .Zero), reg(.YMM0), "62 f1 7e af 5b c0");
testOp2(m64, .VCVTTPS2DQ, pred(.ZMM0, .K7, .Zero), sae(.ZMM0, .SAE), "62 f1 7e df 5b c0");
// VCVTTSD2SI
testOp2(m64, .VCVTTSD2SI, reg(.EAX), reg(.XMM0), "c5 fb 2c c0");
testOp2(m64, .VCVTTSD2SI, reg(.RAX), reg(.XMM0), "c4 e1 fb 2c c0");
testOp2(m64, .VCVTTSD2SI, reg(.EAX), sae(.XMM0, .SAE), "62 f1 7f 18 2c c0");
testOp2(m64, .VCVTTSD2SI, reg(.RAX), sae(.XMM0, .SAE), "62 f1 ff 18 2c c0");
// VCVTTSS2SI
testOp2(m64, .VCVTTSS2SI, reg(.EAX), reg(.XMM0), "c5 fa 2c c0");
testOp2(m64, .VCVTTSS2SI, reg(.RAX), reg(.XMM0), "c4 e1 fa 2c c0");
testOp2(m64, .VCVTTSS2SI, reg(.EAX), sae(.XMM0, .SAE), "62 f1 7e 18 2c c0");
testOp2(m64, .VCVTTSS2SI, reg(.RAX), sae(.XMM0, .SAE), "62 f1 fe 18 2c c0");
}
{
// VDIVPD
testOp3(m64, .VDIVPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 5e c0");
testOp3(m64, .VDIVPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 5e c0");
testOp3(m64, .VDIVPD, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 85 87 5e ff");
testOp3(m64, .VDIVPD, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 85 a7 5e ff");
testOp3(m64, .VDIVPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .RN_SAE), "62 01 85 97 5e ff");
// VDIVPS
testOp3(m64, .VDIVPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f8 5e c0");
testOp3(m64, .VDIVPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fc 5e c0");
testOp3(m64, .VDIVPS, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 04 87 5e ff");
testOp3(m64, .VDIVPS, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 04 a7 5e ff");
testOp3(m64, .VDIVPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .RN_SAE), "62 01 04 97 5e ff");
// VDIVSD
testOp3(m64, .VDIVSD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 5e c0");
testOp3(m64, .VDIVSD, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .RN_SAE), "62 01 87 97 5e ff");
// VDIVSS
testOp3(m64, .VDIVSS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fa 5e c0");
testOp3(m64, .VDIVSS, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .RN_SAE), "62 01 06 97 5e ff");
// VDPPD
testOp4(m64, .VDPPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 79 41 c0 00");
// VDPPS
testOp4(m64, .VDPPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 79 40 c0 00");
testOp4(m64, .VDPPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c4 e3 7d 40 c0 00");
}
{
// VEXTRACTPS
testOp3(m64, .VEXTRACTPS, rm32, reg(.XMM0), imm(0), "67 c4 e3 79 17 00 00");
testOp3(m64, .VEXTRACTPS, reg(.EAX), reg(.XMM0), imm(0), "c4 e3 79 17 c0 00");
testOp3(m64, .VEXTRACTPS, reg(.RAX), reg(.XMM0), imm(0), "c4 e3 79 17 c0 00");
testOp3(m32, .VEXTRACTPS, rm32, reg(.XMM0), imm(0), "c4 e3 79 17 00 00");
testOp3(m32, .VEXTRACTPS, reg(.EAX), reg(.XMM0), imm(0), "c4 e3 79 17 c0 00");
testOp3(m32, .VEXTRACTPS, reg(.RAX), reg(.XMM0), imm(0), AsmError.InvalidOperand);
}
{ // GFNI
// VGF2P8AFFINEINVQB
testOp4(m64, .VGF2P8AFFINEINVQB, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 f9 cf c0 00 ");
testOp4(m64, .VGF2P8AFFINEINVQB, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c4 e3 fd cf c0 00 ");
testOp4(m64, .VGF2P8AFFINEINVQB, reg(.XMM31), reg(.XMM31), reg(.XMM31), imm(0), "62 03 85 00 cf ff 00");
testOp4(m64, .VGF2P8AFFINEINVQB, reg(.YMM31), reg(.YMM31), reg(.YMM31), imm(0), "62 03 85 20 cf ff 00");
testOp4(m64, .VGF2P8AFFINEINVQB, reg(.ZMM31), reg(.ZMM31), reg(.ZMM31), imm(0), "62 03 85 40 cf ff 00");
// VGF2P8AFFINEQB
testOp4(m64, .VGF2P8AFFINEQB, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 f9 ce c0 00 ");
testOp4(m64, .VGF2P8AFFINEQB, reg(.YMM0), reg(.YMM0), reg(.YMM0), imm(0), "c4 e3 fd ce c0 00 ");
testOp4(m64, .VGF2P8AFFINEQB, reg(.XMM31), reg(.XMM31), reg(.XMM31), imm(0), "62 03 85 00 ce ff 00 ");
testOp4(m64, .VGF2P8AFFINEQB, reg(.YMM31), reg(.YMM31), reg(.YMM31), imm(0), "62 03 85 20 ce ff 00 ");
testOp4(m64, .VGF2P8AFFINEQB, reg(.ZMM31), reg(.ZMM31), reg(.ZMM31), imm(0), "62 03 85 40 ce ff 00 ");
// VGF2P8MULB
testOp3(m64, .VGF2P8MULB, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c4 e2 79 cf c0 ");
testOp3(m64, .VGF2P8MULB, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c4 e2 7d cf c0 ");
testOp3(m64, .VGF2P8MULB, reg(.XMM31), reg(.XMM31), reg(.XMM31), "62 02 05 00 cf ff");
testOp3(m64, .VGF2P8MULB, reg(.YMM31), reg(.YMM31), reg(.YMM31), "62 02 05 20 cf ff");
testOp3(m64, .VGF2P8MULB, reg(.ZMM31), reg(.ZMM31), reg(.ZMM31), "62 02 05 40 cf ff");
}
{
// VHADDPD
testOp3(m64, .VHADDPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 7c c0");
testOp3(m64, .VHADDPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 7c c0");
// VHADDPS
testOp3(m64, .VHADDPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 7c c0");
testOp3(m64, .VHADDPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 ff 7c c0");
// VHSUBPD
testOp3(m64, .VHSUBPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 7d c0");
testOp3(m64, .VHSUBPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 7d c0");
// VHSUBPS
testOp3(m64, .VHSUBPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 7d c0");
testOp3(m64, .VHSUBPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 ff 7d c0");
}
{
// VINSERTPS
testOp4(m64, .VINSERTPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), imm(0), "c4 e3 79 21 c0 00");
testOp4(m64, .VINSERTPS, reg(.XMM31), reg(.XMM31), reg(.XMM31), imm(0), "62 03 05 00 21 ff 00");
}
{
// LDDQU
testOp2(m64, .VLDDQU, reg(.XMM0), rm_mem128, "67 c5 fb f0 00");
testOp2(m64, .VLDDQU, reg(.YMM0), rm_mem256, "67 c5 ff f0 00");
testOp2(m64, .VLDDQU, reg(.XMM0), rm_mem32, AsmError.InvalidOperand);
testOp2(m64, .VLDDQU, reg(.XMM0), rm_mem64, AsmError.InvalidOperand);
testOp2(m64, .VLDDQU, reg(.XMM0), rm_mem256, AsmError.InvalidOperand);
testOp2(m64, .VLDDQU, reg(.XMM0), rm_mem512, AsmError.InvalidOperand);
}
{
// VMASKMOVDQU
testOp2(m64, .VMASKMOVDQU,reg(.XMM0), reg(.XMM0), "c5f9f7c0");
}
{
// VMAXPD
testOp3(m64, .VMAXPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 5f c0");
testOp3(m64, .VMAXPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 5f c0");
testOp3(m64, .VMAXPD, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 85 87 5f ff");
testOp3(m64, .VMAXPD, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 85 a7 5f ff");
testOp3(m64, .VMAXPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .SAE), "62 01 85 d7 5f ff");
// VMAXPS
testOp3(m64, .VMAXPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f8 5f c0");
testOp3(m64, .VMAXPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fc 5f c0");
testOp3(m64, .VMAXPS, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 04 87 5f ff");
testOp3(m64, .VMAXPS, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 04 a7 5f ff");
testOp3(m64, .VMAXPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .SAE), "62 01 04 d7 5f ff");
// VMAXSD
testOp3(m64, .VMAXSD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 5f c0");
testOp3(m64, .VMAXSD, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .SAE), "62 01 87 97 5f ff");
// VMAXSS
testOp3(m64, .VMAXSS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fa 5f c0");
testOp3(m64, .VMAXSS, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .SAE), "62 01 06 97 5f ff");
// VMINPD
testOp3(m64, .VMINPD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f9 5d c0");
testOp3(m64, .VMINPD, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fd 5d c0");
testOp3(m64, .VMINPD, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 85 87 5d ff");
testOp3(m64, .VMINPD, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 85 a7 5d ff");
testOp3(m64, .VMINPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .SAE), "62 01 85 d7 5d ff");
// VMINPS
testOp3(m64, .VMINPS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 f8 5d c0");
testOp3(m64, .VMINPS, reg(.YMM0), reg(.YMM0), reg(.YMM0), "c5 fc 5d c0");
testOp3(m64, .VMINPS, pred(.XMM31, .K7, .Zero), reg(.XMM31), reg(.XMM31), "62 01 04 87 5d ff");
testOp3(m64, .VMINPS, pred(.YMM31, .K7, .Zero), reg(.YMM31), reg(.YMM31), "62 01 04 a7 5d ff");
testOp3(m64, .VMINPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), sae(.ZMM31, .SAE), "62 01 04 d7 5d ff");
// VMINSD
testOp3(m64, .VMINSD, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fb 5d c0");
testOp3(m64, .VMINSD, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .SAE), "62 01 87 97 5d ff");
// VMINSS
testOp3(m64, .VMINSS, reg(.XMM0), reg(.XMM0), reg(.XMM0), "c5 fa 5d c0");
testOp3(m64, .VMINSS, pred(.XMM31, .K7, .Zero), reg(.XMM31), sae(.XMM31, .SAE), "62 01 06 97 5d ff");
}
{
// VMOVAPD
testOp2(m64, .VMOVAPD, reg(.XMM0), reg(.XMM0), "c5 f9 28 c0");
testOp2(m64, .VMOVAPD, reg(.YMM0), reg(.YMM0), "c5 fd 28 c0");
testOp2(m64, .VMOVAPD, regRm(.XMM0), reg(.XMM0), "c5 f9 29 c0");
testOp2(m64, .VMOVAPD, regRm(.YMM0), reg(.YMM0), "c5 fd 29 c0");
testOp2(m64, .VMOVAPD, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 fd 8f 28 ff");
testOp2(m64, .VMOVAPD, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 fd af 28 ff");
testOp2(m64, .VMOVAPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 fd cf 28 ff");
testOp2(m64, .VMOVAPD, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 fd 8f 29 ff");
testOp2(m64, .VMOVAPD, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 fd af 29 ff");
testOp2(m64, .VMOVAPD, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 fd cf 29 ff");
testOp2(m64, .VMOVAPD, predRm(rm_mem128, .K7, .Zero), reg(.XMM31), "67 62 61 fd 8f 29 38");
testOp2(m64, .VMOVAPD, predRm(rm_mem256, .K7, .Zero), reg(.YMM31), "67 62 61 fd af 29 38");
testOp2(m64, .VMOVAPD, predRm(rm_mem512, .K7, .Zero), reg(.ZMM31), "67 62 61 fd cf 29 38");
testOp2(m64, .VMOVAPD, pred(.XMM31, .K7, .Zero), rm_mem128, "67 62 61 fd 8f 28 38");
testOp2(m64, .VMOVAPD, pred(.YMM31, .K7, .Zero), rm_mem256, "67 62 61 fd af 28 38");
testOp2(m64, .VMOVAPD, pred(.ZMM31, .K7, .Zero), rm_mem512, "67 62 61 fd cf 28 38");
//
testOp2(m64, .VMOVAPD, predRm(reg(.XMM31), .K7, .Zero), rm_mem128, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPD, predRm(reg(.YMM31), .K7, .Zero), rm_mem256, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPD, predRm(reg(.ZMM31), .K7, .Zero), rm_mem512, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPD, predRm(rm_mem128, .K7, .Zero), rm_mem128, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPD, predRm(rm_mem256, .K7, .Zero), rm_mem256, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPD, predRm(rm_mem512, .K7, .Zero), rm_mem512, AsmError.InvalidOperand);
}
{
// VMOVAPS
testOp2(m64, .VMOVAPS, reg(.XMM0), reg(.XMM0), "c5 f8 28 c0");
testOp2(m64, .VMOVAPS, reg(.YMM0), reg(.YMM0), "c5 fc 28 c0");
testOp2(m64, .VMOVAPS, regRm(.XMM0), reg(.XMM0), "c5 f8 29 c0");
testOp2(m64, .VMOVAPS, regRm(.YMM0), reg(.YMM0), "c5 fc 29 c0");
testOp2(m64, .VMOVAPS, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 7c 8f 28 ff");
testOp2(m64, .VMOVAPS, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 7c af 28 ff");
testOp2(m64, .VMOVAPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 7c cf 28 ff");
testOp2(m64, .VMOVAPS, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 7c 8f 29 ff");
testOp2(m64, .VMOVAPS, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 7c af 29 ff");
testOp2(m64, .VMOVAPS, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 7c cf 29 ff");
testOp2(m64, .VMOVAPS, predRm(rm_mem128, .K7, .Zero), reg(.XMM31), "67 62 61 7c 8f 29 38");
testOp2(m64, .VMOVAPS, predRm(rm_mem256, .K7, .Zero), reg(.YMM31), "67 62 61 7c af 29 38");
testOp2(m64, .VMOVAPS, predRm(rm_mem512, .K7, .Zero), reg(.ZMM31), "67 62 61 7c cf 29 38");
testOp2(m64, .VMOVAPS, pred(.XMM31, .K7, .Zero), rm_mem128, "67 62 61 7c 8f 28 38");
testOp2(m64, .VMOVAPS, pred(.YMM31, .K7, .Zero), rm_mem256, "67 62 61 7c af 28 38");
testOp2(m64, .VMOVAPS, pred(.ZMM31, .K7, .Zero), rm_mem512, "67 62 61 7c cf 28 38");
//
testOp2(m64, .VMOVAPS, predRm(reg(.XMM31), .K7, .Zero), rm_mem128, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPS, predRm(reg(.YMM31), .K7, .Zero), rm_mem256, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPS, predRm(reg(.ZMM31), .K7, .Zero), rm_mem512, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPS, predRm(rm_mem128, .K7, .Zero), rm_mem128, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPS, predRm(rm_mem256, .K7, .Zero), rm_mem256, AsmError.InvalidOperand);
testOp2(m64, .VMOVAPS, predRm(rm_mem512, .K7, .Zero), rm_mem512, AsmError.InvalidOperand);
}
{
testOp2(m64, .VMOVDDUP, reg(.XMM0), reg(.XMM0), "c5 fb 12 c0");
testOp2(m64, .VMOVDDUP, reg(.YMM0), reg(.YMM0), "c5 ff 12 c0");
testOp2(m64, .VMOVDDUP, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 ff 8f 12 ff");
testOp2(m64, .VMOVDDUP, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 ff af 12 ff");
testOp2(m64, .VMOVDDUP, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 ff cf 12 ff");
}
{
// VMOVDQA / VMOVDQA32 / VMOVDQA64
testOp2(m64, .VMOVDQA, reg(.XMM0), reg(.XMM0), "c5 f9 6f c0");
testOp2(m64, .VMOVDQA, reg(.YMM0), reg(.YMM0), "c5 fd 6f c0");
testOp2(m64, .VMOVDQA, regRm(.XMM0), reg(.XMM0), "c5 f9 7f c0");
testOp2(m64, .VMOVDQA, regRm(.YMM0), reg(.YMM0), "c5 fd 7f c0");
// VMOVDQA32
testOp2(m64, .VMOVDQA32, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 7d 8f 6f ff");
testOp2(m64, .VMOVDQA32, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 7d af 6f ff");
testOp2(m64, .VMOVDQA32, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 7d cf 6f ff");
testOp2(m64, .VMOVDQA32, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 7d 8f 7f ff");
testOp2(m64, .VMOVDQA32, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 7d af 7f ff");
testOp2(m64, .VMOVDQA32, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 7d cf 7f ff");
// VMOVDQA64
testOp2(m64, .VMOVDQA64, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 fd 8f 6f ff");
testOp2(m64, .VMOVDQA64, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 fd af 6f ff");
testOp2(m64, .VMOVDQA64, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 fd cf 6f ff");
testOp2(m64, .VMOVDQA64, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 fd 8f 7f ff");
testOp2(m64, .VMOVDQA64, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 fd af 7f ff");
testOp2(m64, .VMOVDQA64, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 fd cf 7f ff");
}
{
testOp2(m64, .VMOVDQU, reg(.XMM0), reg(.XMM0), "c5 fa 6f c0");
testOp2(m64, .VMOVDQU, reg(.YMM0), reg(.YMM0), "c5 fe 6f c0");
testOp2(m64, .VMOVDQU, reg(.XMM0), reg(.XMM0), "c5 fa 6f c0");
testOp2(m64, .VMOVDQU, reg(.YMM0), reg(.YMM0), "c5 fe 6f c0");
// VMOVDQU8
testOp2(m64, .VMOVDQU8, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 7f 8f 6f ff");
testOp2(m64, .VMOVDQU8, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 7f af 6f ff");
testOp2(m64, .VMOVDQU8, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 7f cf 6f ff");
testOp2(m64, .VMOVDQU8, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 7f 8f 7f ff");
testOp2(m64, .VMOVDQU8, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 7f af 7f ff");
testOp2(m64, .VMOVDQU8, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 7f cf 7f ff");
// VMOVDQU16
testOp2(m64, .VMOVDQU16, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 ff 8f 6f ff");
testOp2(m64, .VMOVDQU16, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 ff af 6f ff");
testOp2(m64, .VMOVDQU16, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 ff cf 6f ff");
testOp2(m64, .VMOVDQU16, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 ff 8f 7f ff");
testOp2(m64, .VMOVDQU16, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 ff af 7f ff");
testOp2(m64, .VMOVDQU16, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 ff cf 7f ff");
// VMOVDQU32
testOp2(m64, .VMOVDQU32, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 7e 8f 6f ff");
testOp2(m64, .VMOVDQU32, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 7e af 6f ff");
testOp2(m64, .VMOVDQU32, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 7e cf 6f ff");
testOp2(m64, .VMOVDQU32, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 7e 8f 7f ff");
testOp2(m64, .VMOVDQU32, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 7e af 7f ff");
testOp2(m64, .VMOVDQU32, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 7e cf 7f ff");
// VMOVDQU64
testOp2(m64, .VMOVDQU64, pred(.XMM31, .K7, .Zero), reg(.XMM31), "62 01 fe 8f 6f ff");
testOp2(m64, .VMOVDQU64, pred(.YMM31, .K7, .Zero), reg(.YMM31), "62 01 fe af 6f ff");
testOp2(m64, .VMOVDQU64, pred(.ZMM31, .K7, .Zero), reg(.ZMM31), "62 01 fe cf 6f ff");
testOp2(m64, .VMOVDQU64, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM31), "62 01 fe 8f 7f ff");
testOp2(m64, .VMOVDQU64, predRm(reg(.YMM31), .K7, .Zero), reg(.YMM31), "62 01 fe af 7f ff");
testOp2(m64, .VMOVDQU64, predRm(reg(.ZMM31), .K7, .Zero), reg(.ZMM31), "62 01 fe cf 7f ff");
}
{
// VMOVHLPS
testOp3(m64, .VMOVHLPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), "c5 e8 12 cb");
testOp3(m64, .VMOVHLPS, reg(.XMM21), reg(.XMM22), reg(.XMM23), "62 a1 4c 00 12 ef");
// VMOVHPD
testOp3(m64, .VMOVHPD, reg(.XMM1), reg(.XMM2), rm_mem64, "67 c5 e9 16 08");
testOp2(m64, .VMOVHPD, rm_mem64, reg(.XMM1), "67 c5 f9 17 08");
testOp3(m64, .VMOVHPD, reg(.XMM21), reg(.XMM22), rm_mem64, "67 62 e1 cd 00 16 28");
testOp2(m64, .VMOVHPD, rm_mem64, reg(.XMM21), "67 62 e1 fd 08 17 28");
// VMOVHPS
testOp3(m64, .VMOVHPS, reg(.XMM1), reg(.XMM2), rm_mem64, "67 c5 e8 16 08");
testOp2(m64, .VMOVHPS, rm_mem64, reg(.XMM1), "67 c5 f8 17 08");
testOp3(m64, .VMOVHPS, reg(.XMM21), reg(.XMM22), rm_mem64, "67 62 e1 4c 00 16 28");
testOp2(m64, .VMOVHPS, rm_mem64, reg(.XMM21), "67 62 e1 7c 08 17 28");
// VMOVLHPS
testOp3(m64, .VMOVLHPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), "c5 e8 16 cb");
testOp3(m64, .VMOVLHPS, reg(.XMM21), reg(.XMM22), reg(.XMM23), "62 a1 4c 00 16 ef");
// VMOVLPD
testOp3(m64, .VMOVLPD, reg(.XMM1), reg(.XMM2), rm_mem64, "67 c5 e9 12 08");
testOp2(m64, .VMOVLPD, rm_mem64, reg(.XMM1), "67 c5 f9 13 08");
testOp3(m64, .VMOVLPD, reg(.XMM21), reg(.XMM22), rm_mem64, "67 62 e1 cd 00 12 28");
testOp2(m64, .VMOVLPD, rm_mem64, reg(.XMM21), "67 62 e1 fd 08 13 28");
// VMOVLPS
testOp3(m64, .VMOVLPS, reg(.XMM1), reg(.XMM2), rm_mem64, "67 c5 e8 12 08");
testOp2(m64, .VMOVLPS, rm_mem64, reg(.XMM1), "67 c5 f8 13 08");
testOp3(m64, .VMOVLPS, reg(.XMM21), reg(.XMM22), rm_mem64, "67 62 e1 4c 00 12 28");
testOp2(m64, .VMOVLPS, rm_mem64, reg(.XMM21), "67 62 e1 7c 08 13 28");
// VMOVMSKPD
testOp2(m64, .VMOVMSKPD, reg(.EAX), reg(.XMM1), "c5 f9 50 c1");
testOp2(m64, .VMOVMSKPD, reg(.RAX), reg(.XMM1), "c5 f9 50 c1");
testOp2(m64, .VMOVMSKPD, reg(.EAX), reg(.YMM1), "c5 fd 50 c1");
testOp2(m64, .VMOVMSKPD, reg(.RAX), reg(.YMM1), "c5 fd 50 c1");
// VMOVMSKPS
testOp2(m64, .VMOVMSKPS, reg(.EAX), reg(.XMM1), "c5 f8 50 c1");
testOp2(m64, .VMOVMSKPS, reg(.RAX), reg(.XMM1), "c5 f8 50 c1");
testOp2(m64, .VMOVMSKPS, reg(.EAX), reg(.YMM1), "c5 fc 50 c1");
testOp2(m64, .VMOVMSKPS, reg(.RAX), reg(.YMM1), "c5 fc 50 c1");
// VMOVNTDQA
testOp2(m64, .VMOVNTDQA, reg(.XMM1), rm_mem128, "67 c4 e2 79 2a 08");
testOp2(m64, .VMOVNTDQA, reg(.YMM1), rm_mem256, "67 c4 e2 7d 2a 08");
testOp2(m64, .VMOVNTDQA, reg(.XMM21), rm_mem128, "67 62 e2 7d 08 2a 28");
testOp2(m64, .VMOVNTDQA, reg(.YMM21), rm_mem256, "67 62 e2 7d 28 2a 28");
testOp2(m64, .VMOVNTDQA, reg(.ZMM21), rm_mem512, "67 62 e2 7d 48 2a 28");
// VMOVNTDQ
testOp2(m64, .VMOVNTDQ, rm_mem128, reg(.XMM1), "67 c5 f9 e7 08");
testOp2(m64, .VMOVNTDQ, rm_mem256, reg(.YMM1), "67 c5 fd e7 08");
testOp2(m64, .VMOVNTDQ, rm_mem128, reg(.XMM21), "67 62 e1 7d 08 e7 28");
testOp2(m64, .VMOVNTDQ, rm_mem256, reg(.YMM21), "67 62 e1 7d 28 e7 28");
testOp2(m64, .VMOVNTDQ, rm_mem512, reg(.ZMM21), "67 62 e1 7d 48 e7 28");
// VMOVNTPD
testOp2(m64, .VMOVNTPD, rm_mem128, reg(.XMM1), "67 c5 f9 2b 08");
testOp2(m64, .VMOVNTPD, rm_mem256, reg(.YMM1), "67 c5 fd 2b 08");
testOp2(m64, .VMOVNTPD, rm_mem128, reg(.XMM21), "67 62 e1 fd 08 2b 28");
testOp2(m64, .VMOVNTPD, rm_mem256, reg(.YMM21), "67 62 e1 fd 28 2b 28");
testOp2(m64, .VMOVNTPD, rm_mem512, reg(.ZMM21), "67 62 e1 fd 48 2b 28");
// VMOVNTPS
testOp2(m64, .VMOVNTPS, rm_mem128, reg(.XMM1), "67 c5 f8 2b 08");
testOp2(m64, .VMOVNTPS, rm_mem256, reg(.YMM1), "67 c5 fc 2b 08");
testOp2(m64, .VMOVNTPS, rm_mem128, reg(.XMM21), "67 62 e1 7c 08 2b 28");
testOp2(m64, .VMOVNTPS, rm_mem256, reg(.YMM21), "67 62 e1 7c 28 2b 28");
testOp2(m64, .VMOVNTPS, rm_mem512, reg(.ZMM21), "67 62 e1 7c 48 2b 28");
// VMOVSD
testOp3(m64, .VMOVSD, reg(.XMM1), reg(.XMM2), reg(.XMM3), "c5 eb 10 cb");
testOp2(m64, .VMOVSD, reg(.XMM1), rm_mem64, "67 c5 fb 10 08");
testOp3(m64, .VMOVSD, regRm(.XMM1), reg(.XMM2), reg(.XMM3), "c5 eb 11 d9");
testOp2(m64, .VMOVSD, rm_mem64, reg(.XMM1), "67 c5 fb 11 08");
testOp3(m64, .VMOVSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), reg(.XMM22), "62 21 d7 87 10 fe");
testOp2(m64, .VMOVSD, pred(.XMM31, .K7, .Zero), rm_mem64, "67 62 61 ff 8f 10 38");
testOp3(m64, .VMOVSD, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM21), reg(.XMM22), "62 81 d7 87 11 f7");
testOp2(m64, .VMOVSD, predRm(rm_mem64, .K7, .Zero), reg(.XMM21), "67 62 e1 ff 8f 11 28");
// VMOVSHDUP
testOp2(m64, .VMOVSHDUP, reg(.XMM1), reg(.XMM0), "c5 fa 16 c8");
testOp2(m64, .VMOVSHDUP, reg(.YMM1), reg(.YMM0), "c5 fe 16 c8");
testOp2(m64, .VMOVSHDUP, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7e 8f 16 fc");
testOp2(m64, .VMOVSHDUP, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7e af 16 fc");
testOp2(m64, .VMOVSHDUP, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 21 7e cf 16 fc");
// VMOVSLDUP
testOp2(m64, .VMOVSLDUP, reg(.XMM1), reg(.XMM0), "c5 fa 12 c8");
testOp2(m64, .VMOVSLDUP, reg(.YMM1), reg(.YMM0), "c5 fe 12 c8");
testOp2(m64, .VMOVSLDUP, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7e 8f 12 fc");
testOp2(m64, .VMOVSLDUP, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7e af 12 fc");
testOp2(m64, .VMOVSLDUP, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 21 7e cf 12 fc");
// VMOVSS
testOp3(m64, .VMOVSS, reg(.XMM1), reg(.XMM2), reg(.XMM3), "c5 ea 10 cb");
testOp2(m64, .VMOVSS, reg(.XMM1), rm_mem64, "67 c5 fa 10 08");
testOp3(m64, .VMOVSS, regRm(.XMM1), reg(.XMM2), reg(.XMM3), "c5 ea 11 d9");
testOp2(m64, .VMOVSS, rm_mem64, reg(.XMM1), "67 c5 fa 11 08");
testOp3(m64, .VMOVSS, pred(.XMM31, .K7, .Zero), reg(.XMM21), reg(.XMM22), "62 21 56 87 10 fe");
testOp2(m64, .VMOVSS, pred(.XMM31, .K7, .Zero), rm_mem64, "67 62 61 7e 8f 10 38");
testOp3(m64, .VMOVSS, predRm(reg(.XMM31), .K7, .Zero), reg(.XMM21), reg(.XMM22), "62 81 56 87 11 f7");
testOp2(m64, .VMOVSS, predRm(rm_mem64, .K7, .Zero), reg(.XMM21), "67 62 e1 7e 8f 11 28");
// VMOVUPD
testOp2(m64, .VMOVUPD, reg(.XMM1), regRm(.XMM0), "c5 f9 10 c8");
testOp2(m64, .VMOVUPD, reg(.YMM1), regRm(.YMM0), "c5 fd 10 c8");
testOp2(m64, .VMOVUPD, regRm(.XMM0), reg(.XMM1), "c5 f9 11 c8");
testOp2(m64, .VMOVUPD, regRm(.YMM0), reg(.YMM1), "c5 fd 11 c8");
testOp2(m64, .VMOVUPD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 10 fc");
testOp2(m64, .VMOVUPD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 10 fc");
testOp2(m64, .VMOVUPD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 21 fd cf 10 fc");
testOp2(m64, .VMOVUPD, reg(.XMM20), regRm(.XMM21), "62 a1 fd 08 10 e5");
testOp2(m64, .VMOVUPD, reg(.YMM20), regRm(.YMM21), "62 a1 fd 28 10 e5");
testOp2(m64, .VMOVUPD, reg(.ZMM20), regRm(.ZMM21), "62 a1 fd 48 10 e5");
testOp2(m64, .VMOVUPD, regRm(.XMM20), reg(.XMM21), "62 a1 fd 08 11 ec");
testOp2(m64, .VMOVUPD, regRm(.YMM20), reg(.YMM21), "62 a1 fd 28 11 ec");
testOp2(m64, .VMOVUPD, regRm(.ZMM20), reg(.ZMM21), "62 a1 fd 48 11 ec");
// VMOVUPS
testOp2(m64, .VMOVUPS, reg(.XMM1), regRm(.XMM0), "c5 f8 10 c8");
testOp2(m64, .VMOVUPS, reg(.YMM1), regRm(.YMM0), "c5 fc 10 c8");
testOp2(m64, .VMOVUPS, regRm(.XMM0), reg(.XMM1), "c5 f8 11 c8");
testOp2(m64, .VMOVUPS, regRm(.YMM0), reg(.YMM1), "c5 fc 11 c8");
testOp2(m64, .VMOVUPS, pred(.XMM31, .K7, .Zero), reg(.XMM20), "62 21 7c 8f 10 fc");
testOp2(m64, .VMOVUPS, pred(.YMM31, .K7, .Zero), reg(.YMM20), "62 21 7c af 10 fc");
testOp2(m64, .VMOVUPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM20), "62 21 7c cf 10 fc");
testOp2(m64, .VMOVUPS, reg(.XMM20), regRm(.XMM21), "62 a1 7c 08 10 e5");
testOp2(m64, .VMOVUPS, reg(.YMM20), regRm(.YMM21), "62 a1 7c 28 10 e5");
testOp2(m64, .VMOVUPS, reg(.ZMM20), regRm(.ZMM21), "62 a1 7c 48 10 e5");
testOp2(m64, .VMOVUPS, regRm(.XMM20), reg(.XMM21), "62 a1 7c 08 11 ec");
testOp2(m64, .VMOVUPS, regRm(.YMM20), reg(.YMM21), "62 a1 7c 28 11 ec");
testOp2(m64, .VMOVUPS, regRm(.ZMM20), reg(.ZMM21), "62 a1 7c 48 11 ec");
}
{
// VMPSADBW
testOp4(m64, .VMPSADBW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 42 c8 00");
testOp4(m64, .VMPSADBW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), imm(0), "c4 e3 6d 42 c8 00");
// VMULPD
testOp3(m64, .VMULPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 59 c8");
testOp3(m64, .VMULPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 59 c8");
testOp3(m64, .VMULPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 59 fc");
testOp3(m64, .VMULPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 59 fc");
testOp3(m64, .VMULPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), sae(.ZMM30, .RN_SAE), "62 01 d5 97 59 fe");
// VMULPS
testOp3(m64, .VMULPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 59 c8");
testOp3(m64, .VMULPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 59 c8");
testOp3(m64, .VMULPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 59 fc");
testOp3(m64, .VMULPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 59 fc");
testOp3(m64, .VMULPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), sae(.ZMM30, .RN_SAE), "62 01 54 97 59 fe");
// VMULSD
testOp3(m64, .VMULSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 eb 59 c8");
testOp3(m64, .VMULSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 d7 97 59 fe");
// VMULSS
testOp3(m64, .VMULSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 ea 59 c8");
testOp3(m64, .VMULSS, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 56 97 59 fe");
}
{
// VORPD
testOp3(m64, .VORPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 56 c8");
testOp3(m64, .VORPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 56 c8");
testOp3(m64, .VORPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 56 fc");
testOp3(m64, .VORPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 56 fc");
testOp3(m64, .VORPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 56 fc");
// VORPS
testOp3(m64, .VORPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 56 c8");
testOp3(m64, .VORPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 56 c8");
testOp3(m64, .VORPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 56 fc");
testOp3(m64, .VORPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 56 fc");
testOp3(m64, .VORPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 54 c7 56 fc");
}
//
// VPxxxxx
//
{
// VPABSB / VPABSW / VPABSD / VPABSQ
testOp2(m64, .VPABSB, reg(.XMM1), regRm(.XMM0), "c4 e2 79 1c c8");
testOp2(m64, .VPABSB, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 1c c8");
testOp2(m64, .VPABSB, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 1c fc");
testOp2(m64, .VPABSB, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 1c fc");
testOp2(m64, .VPABSB, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 1c fc");
// VPABSW
testOp2(m64, .VPABSW, reg(.XMM1), regRm(.XMM0), "c4 e2 79 1d c8");
testOp2(m64, .VPABSW, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 1d c8");
testOp2(m64, .VPABSW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 1d fc");
testOp2(m64, .VPABSW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 1d fc");
testOp2(m64, .VPABSW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 1d fc");
// VPABSD
testOp2(m64, .VPABSD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 1e c8");
testOp2(m64, .VPABSD, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 1e c8");
testOp2(m64, .VPABSD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 1e fc");
testOp2(m64, .VPABSD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 1e fc");
testOp2(m64, .VPABSD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 1e fc");
// VPABSQ
testOp2(m64, .VPABSQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 1f fc");
testOp2(m64, .VPABSQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 1f fc");
testOp2(m64, .VPABSQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 1f fc");
// VPACKSSWB / PACKSSDW
// VPACKSSWB
testOp3(m64, .VPACKSSWB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 63 c8");
testOp3(m64, .VPACKSSWB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 63 c8");
testOp3(m64, .VPACKSSWB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 63 fc");
testOp3(m64, .VPACKSSWB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 63 fc");
testOp3(m64, .VPACKSSWB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 63 fc");
// VPACKSSDW
testOp3(m64, .VPACKSSDW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 6b c8");
testOp3(m64, .VPACKSSDW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 6b c8");
testOp3(m64, .VPACKSSDW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 6b fc");
testOp3(m64, .VPACKSSDW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 6b fc");
testOp3(m64, .VPACKSSDW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 6b fc");
// VPACKUSWB
testOp3(m64, .VPACKUSWB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 67 c8");
testOp3(m64, .VPACKUSWB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 67 c8");
testOp3(m64, .VPACKUSWB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 67 fc");
testOp3(m64, .VPACKUSWB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 67 fc");
testOp3(m64, .VPACKUSWB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 67 fc");
// VPACKUSDW
testOp3(m64, .VPACKUSDW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 2b c8");
testOp3(m64, .VPACKUSDW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 2b c8");
testOp3(m64, .VPACKUSDW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 2b fc");
testOp3(m64, .VPACKUSDW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 2b fc");
testOp3(m64, .VPACKUSDW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 2b fc");
// VPADDB / PADDW / PADDD / PADDQ
testOp3(m64, .VPADDB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 fc c8");
testOp3(m64, .VPADDB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed fc c8");
testOp3(m64, .VPADDB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 fc fc");
testOp3(m64, .VPADDB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 fc fc");
testOp3(m64, .VPADDB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 fc fc");
// VPADDW
testOp3(m64, .VPADDW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 fd c8");
testOp3(m64, .VPADDW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed fd c8");
testOp3(m64, .VPADDW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 fd fc");
testOp3(m64, .VPADDW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 fd fc");
testOp3(m64, .VPADDW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 fd fc");
// VPADDD
testOp3(m64, .VPADDD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 fe c8");
testOp3(m64, .VPADDD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed fe c8");
testOp3(m64, .VPADDD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 fe fc");
testOp3(m64, .VPADDD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 fe fc");
testOp3(m64, .VPADDD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 fe fc");
// VPADDQ
testOp3(m64, .VPADDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 d4 c8");
testOp3(m64, .VPADDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed d4 c8");
testOp3(m64, .VPADDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 d4 fc");
testOp3(m64, .VPADDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 d4 fc");
testOp3(m64, .VPADDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 d4 fc");
// VPADDSB / PADDSW
testOp3(m64, .VPADDSB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 ec c8");
testOp3(m64, .VPADDSB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed ec c8");
testOp3(m64, .VPADDSB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 ec fc");
testOp3(m64, .VPADDSB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 ec fc");
testOp3(m64, .VPADDSB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 ec fc");
//
testOp3(m64, .VPADDSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 ed c8");
testOp3(m64, .VPADDSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed ed c8");
testOp3(m64, .VPADDSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 ed fc");
testOp3(m64, .VPADDSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 ed fc");
testOp3(m64, .VPADDSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 ed fc");
// VPADDUSB / PADDUSW
testOp3(m64, .VPADDUSB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 dc c8");
testOp3(m64, .VPADDUSB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed dc c8");
testOp3(m64, .VPADDUSB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 dc fc");
testOp3(m64, .VPADDUSB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 dc fc");
testOp3(m64, .VPADDUSB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 dc fc");
//
testOp3(m64, .VPADDUSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 dd c8");
testOp3(m64, .VPADDUSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed dd c8");
testOp3(m64, .VPADDUSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 dd fc");
testOp3(m64, .VPADDUSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 dd fc");
testOp3(m64, .VPADDUSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 dd fc");
// VPALIGNR
testOp4(m64, .VPALIGNR, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 0f c8 00");
testOp4(m64, .VPALIGNR, reg(.YMM1), reg(.YMM2), regRm(.YMM0), imm(0), "c4 e3 6d 0f c8 00");
testOp4(m64, .VPALIGNR, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), imm(0), "62 23 55 87 0f fc 00");
testOp4(m64, .VPALIGNR, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), imm(0), "62 23 55 a7 0f fc 00");
testOp4(m64, .VPALIGNR, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), imm(0), "62 23 55 c7 0f fc 00");
}
{
// VPAND
testOp3(m64, .VPAND, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 db c8");
testOp3(m64, .VPAND, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed db c8");
testOp3(m64, .VPANDD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 db fc");
testOp3(m64, .VPANDD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 db fc");
testOp3(m64, .VPANDD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 db fc");
testOp3(m64, .VPANDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 db fc");
testOp3(m64, .VPANDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 db fc");
testOp3(m64, .VPANDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 db fc");
// VPANDN
testOp3(m64, .VPANDN, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 df c8");
testOp3(m64, .VPANDN, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed df c8");
testOp3(m64, .VPANDND, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 df fc");
testOp3(m64, .VPANDND, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 df fc");
testOp3(m64, .VPANDND, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 df fc");
testOp3(m64, .VPANDNQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 df fc");
testOp3(m64, .VPANDNQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 df fc");
testOp3(m64, .VPANDNQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 df fc");
// VPAVGB / VPAVGW
testOp3(m64, .VPAVGB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e0 c8");
testOp3(m64, .VPAVGB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed e0 c8");
testOp3(m64, .VPAVGB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e0 fc");
testOp3(m64, .VPAVGB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 e0 fc");
testOp3(m64, .VPAVGB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 e0 fc");
//
testOp3(m64, .VPAVGW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e3 c8");
testOp3(m64, .VPAVGW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed e3 c8");
testOp3(m64, .VPAVGW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e3 fc");
testOp3(m64, .VPAVGW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 e3 fc");
testOp3(m64, .VPAVGW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 e3 fc");
// VPBLENDVB
testOp4(m64, .VPBLENDVB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 4c c8 30");
testOp4(m64, .VPBLENDVB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 4c c8 30");
// VPBLENDDW
testOp4(m64, .VPBLENDW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 0e c8 00");
testOp4(m64, .VPBLENDW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), imm(0), "c4 e3 6d 0e c8 00");
// VPCLMULQDQ
testOp4(m64, .VPCLMULQDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 44 c8 00");
testOp4(m64, .VPCLMULQDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), imm(0), "c4 e3 6d 44 c8 00");
testOp4(m64, .VPCLMULQDQ, reg(.XMM21), reg(.XMM22), regRm(.XMM20), imm(0), "62 a3 4d 00 44 ec 00");
testOp4(m64, .VPCLMULQDQ, reg(.YMM21), reg(.YMM22), regRm(.YMM20), imm(0), "62 a3 4d 20 44 ec 00");
testOp4(m64, .VPCLMULQDQ, reg(.ZMM21), reg(.ZMM22), regRm(.ZMM20), imm(0), "62 a3 4d 40 44 ec 00");
}
{
// VPCMPEQB / VPCMPEQW / VPCMPEQD
testOp3(m64, .VPCMPEQB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 74 c8");
testOp3(m64, .VPCMPEQB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 74 c8");
testOp3(m64, .VPCMPEQB, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b1 55 07 74 c4");
testOp3(m64, .VPCMPEQB, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b1 55 27 74 c4");
testOp3(m64, .VPCMPEQB, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b1 55 47 74 c4");
// VPCMPEQW
testOp3(m64, .VPCMPEQW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 75 c8");
testOp3(m64, .VPCMPEQW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 75 c8");
testOp3(m64, .VPCMPEQW, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b1 55 07 75 c4");
testOp3(m64, .VPCMPEQW, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b1 55 27 75 c4");
testOp3(m64, .VPCMPEQW, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b1 55 47 75 c4");
// VPCMPEQD
testOp3(m64, .VPCMPEQD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 76 c8");
testOp3(m64, .VPCMPEQD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 76 c8");
testOp3(m64, .VPCMPEQD, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b1 55 07 76 c4");
testOp3(m64, .VPCMPEQD, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b1 55 27 76 c4");
testOp3(m64, .VPCMPEQD, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b1 55 47 76 c4");
// VPCMPEQQ
testOp3(m64, .VPCMPEQQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 29 c8");
testOp3(m64, .VPCMPEQQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 29 c8");
testOp3(m64, .VPCMPEQQ, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 d5 07 29 c4");
testOp3(m64, .VPCMPEQQ, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 d5 27 29 c4");
testOp3(m64, .VPCMPEQQ, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 d5 47 29 c4");
// VPCMPESTRI
testOp3(m64, .VPCMPESTRI, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 61 c8 00");
// VPCMPESTRM
testOp3(m64, .VPCMPESTRM, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 60 c8 00");
// VPCMPGTB / VPCMPGTW / VPCMPGTD
testOp3(m64, .VPCMPGTB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 64 c8");
testOp3(m64, .VPCMPGTB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 64 c8");
testOp3(m64, .VPCMPGTB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 64 fc");
testOp3(m64, .VPCMPGTB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 64 fc");
testOp3(m64, .VPCMPGTB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 64 fc");
// VPCMPGTW
testOp3(m64, .VPCMPGTW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 65 c8");
testOp3(m64, .VPCMPGTW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 65 c8");
testOp3(m64, .VPCMPGTW, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20), "62 b1 55 07 65 c4");
testOp3(m64, .VPCMPGTW, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20), "62 b1 55 27 65 c4");
testOp3(m64, .VPCMPGTW, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20), "62 b1 55 47 65 c4");
// VPCMPGTD
testOp3(m64, .VPCMPGTD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 66 c8");
testOp3(m64, .VPCMPGTD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 66 c8");
testOp3(m64, .VPCMPGTD, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20), "62 b1 55 07 66 c4");
testOp3(m64, .VPCMPGTD, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20), "62 b1 55 27 66 c4");
testOp3(m64, .VPCMPGTD, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20), "62 b1 55 47 66 c4");
// VPCMPGTQ
testOp3(m64, .VPCMPGTQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 37 c8");
testOp3(m64, .VPCMPGTQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 37 c8");
testOp3(m64, .VPCMPGTQ, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20), "62 b2 d5 07 37 c4");
testOp3(m64, .VPCMPGTQ, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20), "62 b2 d5 27 37 c4");
testOp3(m64, .VPCMPGTQ, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20), "62 b2 d5 47 37 c4");
// VPCMPISTRI
testOp3(m64, .VPCMPISTRI, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 63 c8 00");
// VPCMPISTRM
testOp3(m64, .VPCMPISTRM, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 62 c8 00");
}
{
// VPEXTRB / VPEXTRD / VPEXTRQ
testOp3(m64, .VPEXTRB, rm_mem8, reg(.XMM1), imm(0), "67 c4 e3 79 14 08 00");
testOp3(m64, .VPEXTRB, regRm(.EAX), reg(.XMM1), imm(0), "c4 e3 79 14 c8 00");
testOp3(m64, .VPEXTRB, regRm(.RAX), reg(.XMM1), imm(0), "c4 e3 79 14 c8 00");
testOp3(m64, .VPEXTRB, rm_mem8, reg(.XMM21), imm(0), "67 62 e3 7d 08 14 28 00");
testOp3(m64, .VPEXTRB, reg(.EAX), reg(.XMM21), imm(0), "62 e3 7d 08 14 e8 00");
testOp3(m64, .VPEXTRB, reg(.RAX), reg(.XMM21), imm(0), "62 e3 7d 08 14 e8 00");
//
testOp3(m64, .VPEXTRD, rm32, reg(.XMM1), imm(0), "67 c4 e3 79 16 08 00");
testOp3(m64, .VPEXTRD, rm32, reg(.XMM21), imm(0), "67 62 e3 7d 08 16 28 00");
//
testOp3(m64, .VPEXTRQ, rm64, reg(.XMM1), imm(0), "67 c4 e3 f9 16 08 00");
testOp3(m64, .VPEXTRQ, rm64, reg(.XMM21), imm(0), "67 62 e3 fd 08 16 28 00");
// VPEXTRW
testOp3(m64, .VPEXTRW, reg(.EAX), reg(.XMM1), imm(0), "c5 f9 c5 c1 00");
testOp3(m64, .VPEXTRW, reg(.RAX), reg(.XMM1), imm(0), "c5 f9 c5 c1 00");
testOp3(m64, .VPEXTRW, rm_mem16, reg(.XMM1), imm(0), "67 c4 e3 79 15 08 00");
testOp3(m64, .VPEXTRW, regRm(.EAX), reg(.XMM1), imm(0), "c4 e3 79 15 c8 00");
testOp3(m64, .VPEXTRW, regRm(.RAX), reg(.XMM1), imm(0), "c4 e3 79 15 c8 00");
testOp3(m64, .VPEXTRW, reg(.EAX), reg(.XMM21), imm(0), "62 b1 7d 08 c5 c5 00");
testOp3(m64, .VPEXTRW, reg(.RAX), reg(.XMM21), imm(0), "62 b1 7d 08 c5 c5 00");
testOp3(m64, .VPEXTRW, rm_mem16, reg(.XMM21), imm(0), "67 62 e3 7d 08 15 28 00");
testOp3(m64, .VPEXTRW, regRm(.EAX), reg(.XMM21), imm(0), "62 e3 7d 08 15 e8 00");
testOp3(m64, .VPEXTRW, regRm(.RAX), reg(.XMM21), imm(0), "62 e3 7d 08 15 e8 00");
}
{
// VPHADDW / VPHADDD
testOp3(m64, .VPHADDW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 01 c8");
testOp3(m64, .VPHADDW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 01 c8");
//
testOp3(m64, .VPHADDD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 02 c8");
testOp3(m64, .VPHADDD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 02 c8");
// VPHADDSW
testOp3(m64, .VPHADDSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 03 c8");
testOp3(m64, .VPHADDSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 03 c8");
// VPHMINPOSUW
testOp2(m64, .VPHMINPOSUW,reg(.XMM1), regRm(.XMM0), "c4 e2 79 41 c8");
// VPHSUBW / VPHSUBD
testOp3(m64, .VPHSUBW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 05 c8");
testOp3(m64, .VPHSUBW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 05 c8");
//
testOp3(m64, .VPHSUBD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 06 c8");
testOp3(m64, .VPHSUBD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 06 c8");
// VPHSUBSW
testOp3(m64, .VPHSUBSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 07 c8");
testOp3(m64, .VPHSUBSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 07 c8");
// VPINSRB / VPINSRD / VPINSRQ
testOp4(m64, .VPINSRB, reg(.XMM1), reg(.XMM2), rm_mem8, imm(0), "67 c4 e3 69 20 08 00");
testOp4(m64, .VPINSRB, reg(.XMM1), reg(.XMM2), regRm(.EAX), imm(0), "c4 e3 69 20 c8 00");
testOp4(m64, .VPINSRB, reg(.XMM21), reg(.XMM22), rm_mem8, imm(0), "67 62 e3 4d 00 20 28 00");
testOp4(m64, .VPINSRB, reg(.XMM21), reg(.XMM22), regRm(.EAX), imm(0), "62 e3 4d 00 20 e8 00");
//
testOp4(m64, .VPINSRD, reg(.XMM1), reg(.XMM2), rm32, imm(0), "67 c4 e3 69 22 08 00");
testOp4(m64, .VPINSRD, reg(.XMM21), reg(.XMM22), rm32, imm(0), "67 62 e3 4d 00 22 28 00");
//
testOp4(m64, .VPINSRQ, reg(.XMM1), reg(.XMM2), rm64, imm(0), "67 c4 e3 e9 22 08 00");
testOp4(m64, .VPINSRQ, reg(.XMM21), reg(.XMM22), rm64, imm(0), "67 62 e3 cd 00 22 28 00");
// VPINSRW
testOp4(m64, .VPINSRW, reg(.XMM1), reg(.XMM2), rm_mem16, imm(0), "67 c5 e9 c4 08 00");
testOp4(m64, .VPINSRW, reg(.XMM1), reg(.XMM2), regRm(.EAX), imm(0), "c5 e9 c4 c8 00");
testOp4(m64, .VPINSRW, reg(.XMM1), reg(.XMM2), regRm(.RAX), imm(0), "c5 e9 c4 c8 00");
testOp4(m64, .VPINSRW, reg(.XMM21), reg(.XMM22), rm_mem16, imm(0), "67 62 e1 4d 00 c4 28 00");
testOp4(m64, .VPINSRW, reg(.XMM21), reg(.XMM22), regRm(.EAX), imm(0), "62 e1 4d 00 c4 e8 00");
testOp4(m64, .VPINSRW, reg(.XMM21), reg(.XMM22), regRm(.RAX), imm(0), "62 e1 4d 00 c4 e8 00");
// VPMADDUBSW
testOp3(m64, .VPMADDUBSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 04 c8");
testOp3(m64, .VPMADDUBSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 04 c8");
testOp3(m64, .VPMADDUBSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 04 fc");
testOp3(m64, .VPMADDUBSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 04 fc");
testOp3(m64, .VPMADDUBSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 04 fc");
// VPMADDWD
testOp3(m64, .VPMADDWD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f5 c8");
testOp3(m64, .VPMADDWD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed f5 c8");
testOp3(m64, .VPMADDWD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 f5 fc");
testOp3(m64, .VPMADDWD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 f5 fc");
testOp3(m64, .VPMADDWD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 f5 fc");
// VPMAXSB / VPMAXSW / VPMAXSD / VPMAXSQ
// VPMAXSB
testOp3(m64, .VPMAXSB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3c c8");
testOp3(m64, .VPMAXSB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3c c8");
testOp3(m64, .VPMAXSB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3c fc");
testOp3(m64, .VPMAXSB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3c fc");
testOp3(m64, .VPMAXSB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3c fc");
// VPMAXSW
testOp3(m64, .VPMAXSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 ee c8");
testOp3(m64, .VPMAXSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed ee c8");
testOp3(m64, .VPMAXSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 ee fc");
testOp3(m64, .VPMAXSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 ee fc");
testOp3(m64, .VPMAXSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 ee fc");
// VPMAXSD
testOp3(m64, .VPMAXSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3d c8");
testOp3(m64, .VPMAXSD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3d c8");
testOp3(m64, .VPMAXSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3d fc");
testOp3(m64, .VPMAXSD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3d fc");
testOp3(m64, .VPMAXSD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3d fc");
// VPMAXSQ
testOp3(m64, .VPMAXSQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 3d fc");
testOp3(m64, .VPMAXSQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 3d fc");
testOp3(m64, .VPMAXSQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 3d fc");
// VPMAXUB / VPMAXUW
// VPMAXUB
testOp3(m64, .VPMAXUB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 de c8");
testOp3(m64, .VPMAXUB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed de c8");
testOp3(m64, .VPMAXUB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 de fc");
testOp3(m64, .VPMAXUB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 de fc");
testOp3(m64, .VPMAXUB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 de fc");
// VPMAXUW
testOp3(m64, .VPMAXUW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3e c8");
testOp3(m64, .VPMAXUW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3e c8");
testOp3(m64, .VPMAXUW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3e fc");
testOp3(m64, .VPMAXUW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3e fc");
testOp3(m64, .VPMAXUW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3e fc");
// VPMAXUD / VPMAXUQ
// VPMAXUD
testOp3(m64, .VPMAXUD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3f c8");
testOp3(m64, .VPMAXUD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3f c8");
testOp3(m64, .VPMAXUD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3f fc");
testOp3(m64, .VPMAXUD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3f fc");
testOp3(m64, .VPMAXUD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3f fc");
// VPMAXUQ
testOp3(m64, .VPMAXUQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 3f fc");
testOp3(m64, .VPMAXUQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 3f fc");
testOp3(m64, .VPMAXUQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 3f fc");
// VPMINSB / VPMINSW
// VPMINSB
testOp3(m64, .VPMINSB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 38 c8");
testOp3(m64, .VPMINSB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 38 c8");
testOp3(m64, .VPMINSB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 38 fc");
testOp3(m64, .VPMINSB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 38 fc");
testOp3(m64, .VPMINSB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 38 fc");
// VPMINSW
testOp3(m64, .VPMINSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 ea c8");
testOp3(m64, .VPMINSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed ea c8");
testOp3(m64, .VPMINSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 ea fc");
testOp3(m64, .VPMINSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 ea fc");
testOp3(m64, .VPMINSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 ea fc");
// VPMINSD / VPMINSQ
// VPMINSD
testOp3(m64, .VPMINSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 39 c8");
testOp3(m64, .VPMINSD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 39 c8");
testOp3(m64, .VPMINSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 39 fc");
testOp3(m64, .VPMINSD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 39 fc");
testOp3(m64, .VPMINSD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 39 fc");
// VPMINSQ
testOp3(m64, .VPMINSQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 39 fc");
testOp3(m64, .VPMINSQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 39 fc");
testOp3(m64, .VPMINSQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 39 fc");
// VPMINUB / VPMINUW
// VPMINUB
testOp3(m64, .VPMINUB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 da c8");
testOp3(m64, .VPMINUB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed da c8");
testOp3(m64, .VPMINUB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 da fc");
testOp3(m64, .VPMINUB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 da fc");
testOp3(m64, .VPMINUB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 da fc");
// VPMINUW
testOp3(m64, .VPMINUW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3a c8");
testOp3(m64, .VPMINUW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3a c8");
testOp3(m64, .VPMINUW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3a fc");
testOp3(m64, .VPMINUW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3a fc");
testOp3(m64, .VPMINUW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3a fc");
// VPMINUD / VPMINUQ
// VPMINUD
testOp3(m64, .VPMINUD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 3b c8");
testOp3(m64, .VPMINUD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 3b c8");
testOp3(m64, .VPMINUD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 3b fc");
testOp3(m64, .VPMINUD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 3b fc");
testOp3(m64, .VPMINUD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 3b fc");
// VPMINUQ
testOp3(m64, .VPMINUQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 3b fc");
testOp3(m64, .VPMINUQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 3b fc");
testOp3(m64, .VPMINUQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 3b fc");
}
{
// VPMOVSX
// VPMOVSXBW
testOp2(m64, .VPMOVSXBW, reg(.XMM1), regRm(.XMM0), "c4 e2 79 20 c8");
testOp2(m64, .VPMOVSXBW, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 20 c8");
testOp2(m64, .VPMOVSXBW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 20 fc");
testOp2(m64, .VPMOVSXBW, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 20 fc");
testOp2(m64, .VPMOVSXBW, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 20 fc");
// VPMOVSXBD
testOp2(m64, .VPMOVSXBD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 21 c8");
testOp2(m64, .VPMOVSXBD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 21 c8");
testOp2(m64, .VPMOVSXBD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 21 fc");
testOp2(m64, .VPMOVSXBD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 21 fc");
testOp2(m64, .VPMOVSXBD, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 21 fc");
// VPMOVSXBQ
testOp2(m64, .VPMOVSXBQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 22 c8");
testOp2(m64, .VPMOVSXBQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 22 c8");
testOp2(m64, .VPMOVSXBQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 22 fc");
testOp2(m64, .VPMOVSXBQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 22 fc");
testOp2(m64, .VPMOVSXBQ, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 22 fc");
// VPMOVSXWD
testOp2(m64, .VPMOVSXWD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 23 c8");
testOp2(m64, .VPMOVSXWD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 23 c8");
testOp2(m64, .VPMOVSXWD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 23 fc");
testOp2(m64, .VPMOVSXWD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 23 fc");
testOp2(m64, .VPMOVSXWD, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 23 fc");
// VPMOVSXWQ
testOp2(m64, .VPMOVSXWQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 24 c8");
testOp2(m64, .VPMOVSXWQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 24 c8");
testOp2(m64, .VPMOVSXWQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 24 fc");
testOp2(m64, .VPMOVSXWQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 24 fc");
testOp2(m64, .VPMOVSXWQ, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 24 fc");
// VPMOVSXDQ
testOp2(m64, .VPMOVSXDQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 25 c8");
testOp2(m64, .VPMOVSXDQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 25 c8");
testOp2(m64, .VPMOVSXDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 25 fc");
testOp2(m64, .VPMOVSXDQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 25 fc");
testOp2(m64, .VPMOVSXDQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 25 fc");
}
{
// VPMOVZX
// VPMOVZXBW
testOp2(m64, .VPMOVZXBW, reg(.XMM1), regRm(.XMM0), "c4 e2 79 30 c8");
testOp2(m64, .VPMOVZXBW, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 30 c8");
testOp2(m64, .VPMOVZXBW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 30 fc");
testOp2(m64, .VPMOVZXBW, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 30 fc");
testOp2(m64, .VPMOVZXBW, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 30 fc");
// VPMOVZXBD
testOp2(m64, .VPMOVZXBD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 31 c8");
testOp2(m64, .VPMOVZXBD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 31 c8");
testOp2(m64, .VPMOVZXBD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 31 fc");
testOp2(m64, .VPMOVZXBD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 31 fc");
testOp2(m64, .VPMOVZXBD, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 31 fc");
// VPMOVZXBQ
testOp2(m64, .VPMOVZXBQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 32 c8");
testOp2(m64, .VPMOVZXBQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 32 c8");
testOp2(m64, .VPMOVZXBQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 32 fc");
testOp2(m64, .VPMOVZXBQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 32 fc");
testOp2(m64, .VPMOVZXBQ, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 32 fc");
// VPMOVZXWD
testOp2(m64, .VPMOVZXWD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 33 c8");
testOp2(m64, .VPMOVZXWD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 33 c8");
testOp2(m64, .VPMOVZXWD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 33 fc");
testOp2(m64, .VPMOVZXWD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 33 fc");
testOp2(m64, .VPMOVZXWD, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 33 fc");
// VPMOVZXWQ
testOp2(m64, .VPMOVZXWQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 34 c8");
testOp2(m64, .VPMOVZXWQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 34 c8");
testOp2(m64, .VPMOVZXWQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 34 fc");
testOp2(m64, .VPMOVZXWQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 34 fc");
testOp2(m64, .VPMOVZXWQ, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 34 fc");
// VPMOVZXDQ
testOp2(m64, .VPMOVZXDQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 35 c8");
testOp2(m64, .VPMOVZXDQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 35 c8");
testOp2(m64, .VPMOVZXDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 35 fc");
testOp2(m64, .VPMOVZXDQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 35 fc");
testOp2(m64, .VPMOVZXDQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 35 fc");
}
{
// VPMULDQ
testOp3(m64, .VPMULDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 28 c8");
testOp3(m64, .VPMULDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 28 c8");
testOp3(m64, .VPMULDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 28 fc");
testOp3(m64, .VPMULDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 28 fc");
testOp3(m64, .VPMULDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 28 fc");
// VPMULHRSW
testOp3(m64, .VPMULHRSW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 0b c8");
testOp3(m64, .VPMULHRSW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 0b c8");
testOp3(m64, .VPMULHRSW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 0b fc");
testOp3(m64, .VPMULHRSW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 0b fc");
testOp3(m64, .VPMULHRSW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 0b fc");
// VPMULHUW
testOp3(m64, .VPMULHUW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e4 c8");
testOp3(m64, .VPMULHUW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed e4 c8");
testOp3(m64, .VPMULHUW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e4 fc");
testOp3(m64, .VPMULHUW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 e4 fc");
testOp3(m64, .VPMULHUW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 e4 fc");
// VPMULHW
testOp3(m64, .VPMULHW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e5 c8");
testOp3(m64, .VPMULHW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed e5 c8");
testOp3(m64, .VPMULHW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e5 fc");
testOp3(m64, .VPMULHW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 e5 fc");
testOp3(m64, .VPMULHW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 e5 fc");
// VPMULLD / VPMULLQ
// VPMULLD
testOp3(m64, .VPMULLD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 40 c8");
testOp3(m64, .VPMULLD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 40 c8");
testOp3(m64, .VPMULLD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 40 fc");
testOp3(m64, .VPMULLD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 40 fc");
testOp3(m64, .VPMULLD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 40 fc");
// VPMULLQ
testOp3(m64, .VPMULLQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 40 fc");
testOp3(m64, .VPMULLQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 40 fc");
testOp3(m64, .VPMULLQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 40 fc");
// VPMULLW
testOp3(m64, .VPMULLW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 d5 c8");
testOp3(m64, .VPMULLW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed d5 c8");
testOp3(m64, .VPMULLW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 d5 fc");
testOp3(m64, .VPMULLW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 d5 fc");
testOp3(m64, .VPMULLW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 d5 fc");
// VPMULUDQ
testOp3(m64, .VPMULUDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f4 c8");
testOp3(m64, .VPMULUDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed f4 c8");
testOp3(m64, .VPMULUDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 f4 fc");
testOp3(m64, .VPMULUDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 f4 fc");
testOp3(m64, .VPMULUDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 f4 fc");
}
{
// VPOR
testOp3(m64, .VPOR, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 eb c8");
testOp3(m64, .VPOR, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed eb c8");
//
testOp3(m64, .VPORD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 eb fc");
testOp3(m64, .VPORD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 eb fc");
testOp3(m64, .VPORD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 eb fc");
//
testOp3(m64, .VPORQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 eb fc");
testOp3(m64, .VPORQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 eb fc");
testOp3(m64, .VPORQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 eb fc");
// VPSADBW
testOp3(m64, .VPSADBW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f6 c8");
testOp3(m64, .VPSADBW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed f6 c8");
testOp3(m64, .VPSADBW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 f6 fc");
testOp3(m64, .VPSADBW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 f6 fc");
testOp3(m64, .VPSADBW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 f6 fc");
// VPSHUFB
testOp3(m64, .VPSHUFB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 00 c8");
testOp3(m64, .VPSHUFB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 00 c8");
testOp3(m64, .VPSHUFB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 00 fc");
testOp3(m64, .VPSHUFB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 00 fc");
testOp3(m64, .VPSHUFB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 00 fc");
// VPSHUFD
testOp3(m64, .VPSHUFD, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f9 70 c8 00");
testOp3(m64, .VPSHUFD, reg(.YMM1), regRm(.YMM0), imm(0), "c5 fd 70 c8 00");
testOp3(m64, .VPSHUFD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 21 7d 8f 70 fc 00");
testOp3(m64, .VPSHUFD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 21 7d af 70 fc 00");
testOp3(m64, .VPSHUFD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 21 7d cf 70 fc 00");
// VPSHUFHW
testOp3(m64, .VPSHUFHW, reg(.XMM1), regRm(.XMM0), imm(0), "c5 fa 70 c8 00");
testOp3(m64, .VPSHUFHW, reg(.YMM1), regRm(.YMM0), imm(0), "c5 fe 70 c8 00");
testOp3(m64, .VPSHUFHW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 21 7e 8f 70 fc 00");
testOp3(m64, .VPSHUFHW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 21 7e af 70 fc 00");
testOp3(m64, .VPSHUFHW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 21 7e cf 70 fc 00");
// VPSHUFLW
testOp3(m64, .VPSHUFLW, reg(.XMM1), regRm(.XMM0), imm(0), "c5 fb 70 c8 00");
testOp3(m64, .VPSHUFLW, reg(.YMM1), regRm(.YMM0), imm(0), "c5 ff 70 c8 00");
testOp3(m64, .VPSHUFLW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 21 7f 8f 70 fc 00");
testOp3(m64, .VPSHUFLW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 21 7f af 70 fc 00");
testOp3(m64, .VPSHUFLW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 21 7f cf 70 fc 00");
}
{
// VPSIGNB / VPSIGNW / VPSIGND
// VPSIGNB
testOp3(m64, .VPSIGNB, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 08 c8");
testOp3(m64, .VPSIGNB, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 08 c8");
// VPSIGNW
testOp3(m64, .VPSIGNW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 09 c8");
testOp3(m64, .VPSIGNW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 09 c8");
// VPSIGND
testOp3(m64, .VPSIGND, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 0a c8");
testOp3(m64, .VPSIGND, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 0a c8");
}
{
// VPSLLDQ
testOp3(m64, .VPSLLDQ, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 73 f8 00");
testOp3(m64, .VPSLLDQ, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 73 f8 00");
testOp3(m64, .VPSLLDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 73 fc 00");
testOp3(m64, .VPSLLDQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 73 fc 00");
testOp3(m64, .VPSLLDQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 73 fc 00");
// VPSLLW / VPSLLD / VPSLLQ
// VPSLLW
testOp3(m64, .VPSLLW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f1 c8");
testOp3(m64, .VPSLLW, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 71 f0 00");
testOp3(m64, .VPSLLW, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed f1 c8");
testOp3(m64, .VPSLLW, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 71 f0 00");
testOp3(m64, .VPSLLW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 f1 fc");
testOp3(m64, .VPSLLW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 f1 fc");
testOp3(m64, .VPSLLW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 f1 fc");
testOp3(m64, .VPSLLW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 71 f4 00");
testOp3(m64, .VPSLLW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 71 f4 00");
testOp3(m64, .VPSLLW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 71 f4 00");
// VPSLLD
testOp3(m64, .VPSLLD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f2 c8");
testOp3(m64, .VPSLLD, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 72 f0 00");
testOp3(m64, .VPSLLD, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed f2 c8");
testOp3(m64, .VPSLLD, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 72 f0 00");
testOp3(m64, .VPSLLD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 f2 fc");
testOp3(m64, .VPSLLD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 f2 fc");
testOp3(m64, .VPSLLD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 f2 fc");
testOp3(m64, .VPSLLD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 72 f4 00");
testOp3(m64, .VPSLLD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 72 f4 00");
testOp3(m64, .VPSLLD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 72 f4 00");
// VPSLLQ
testOp3(m64, .VPSLLQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 f3 c8");
testOp3(m64, .VPSLLQ, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 73 f0 00");
testOp3(m64, .VPSLLQ, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed f3 c8");
testOp3(m64, .VPSLLQ, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 73 f0 00");
testOp3(m64, .VPSLLQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 f3 fc");
testOp3(m64, .VPSLLQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 d5 a7 f3 fc");
testOp3(m64, .VPSLLQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 d5 c7 f3 fc");
testOp3(m64, .VPSLLQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 85 87 73 f4 00");
testOp3(m64, .VPSLLQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 85 a7 73 f4 00");
testOp3(m64, .VPSLLQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 85 c7 73 f4 00");
// VPSRAW / VPSRAD / VPSRAQ
// VPSRAW
testOp3(m64, .VPSRAW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e1 c8");
testOp3(m64, .VPSRAW, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 71 e0 00");
testOp3(m64, .VPSRAW, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed e1 c8");
testOp3(m64, .VPSRAW, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 71 e0 00");
testOp3(m64, .VPSRAW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e1 fc");
testOp3(m64, .VPSRAW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 e1 fc");
testOp3(m64, .VPSRAW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 e1 fc");
testOp3(m64, .VPSRAW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 71 e4 00");
testOp3(m64, .VPSRAW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 71 e4 00");
testOp3(m64, .VPSRAW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 71 e4 00");
// VPSRAD
testOp3(m64, .VPSRAD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 e2 c8");
testOp3(m64, .VPSRAD, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 72 e0 00");
testOp3(m64, .VPSRAD, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed e2 c8");
testOp3(m64, .VPSRAD, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 72 e0 00");
testOp3(m64, .VPSRAD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 e2 fc");
testOp3(m64, .VPSRAD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 e2 fc");
testOp3(m64, .VPSRAD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 e2 fc");
testOp3(m64, .VPSRAD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 72 e4 00");
testOp3(m64, .VPSRAD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 72 e4 00");
testOp3(m64, .VPSRAD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 72 e4 00");
// VPSRAQ
testOp3(m64, .VPSRAQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 e2 fc");
testOp3(m64, .VPSRAQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 d5 a7 e2 fc");
testOp3(m64, .VPSRAQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 d5 c7 e2 fc");
testOp3(m64, .VPSRAQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 85 87 72 e4 00");
testOp3(m64, .VPSRAQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 85 a7 72 e4 00");
testOp3(m64, .VPSRAQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 85 c7 72 e4 00");
// VPSRLDQ
testOp3(m64, .VPSRLDQ, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 73 d8 00");
testOp3(m64, .VPSRLDQ, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 73 d8 00");
testOp3(m64, .VPSRLDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 73 dc 00");
testOp3(m64, .VPSRLDQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 73 dc 00");
testOp3(m64, .VPSRLDQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 73 dc 00");
// VPSRLW / VPSRLD / VPSRLQ
// VPSRLW
testOp3(m64, .VPSRLW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 d1 c8");
testOp3(m64, .VPSRLW, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 71 d0 00");
testOp3(m64, .VPSRLW, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed d1 c8");
testOp3(m64, .VPSRLW, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 71 d0 00");
testOp3(m64, .VPSRLW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 d1 fc");
testOp3(m64, .VPSRLW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 d1 fc");
testOp3(m64, .VPSRLW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 d1 fc");
testOp3(m64, .VPSRLW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 71 d4 00");
testOp3(m64, .VPSRLW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 71 d4 00");
testOp3(m64, .VPSRLW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 71 d4 00");
// VPSRLD
testOp3(m64, .VPSRLD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 d2 c8");
testOp3(m64, .VPSRLD, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 72 d0 00");
testOp3(m64, .VPSRLD, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed d2 c8");
testOp3(m64, .VPSRLD, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 72 d0 00");
testOp3(m64, .VPSRLD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 d2 fc");
testOp3(m64, .VPSRLD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 55 a7 d2 fc");
testOp3(m64, .VPSRLD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 55 c7 d2 fc");
testOp3(m64, .VPSRLD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 72 d4 00");
testOp3(m64, .VPSRLD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 72 d4 00");
testOp3(m64, .VPSRLD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 72 d4 00");
// VPSRLQ
testOp3(m64, .VPSRLQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 d3 c8");
testOp3(m64, .VPSRLQ, reg(.XMM1), regRm(.XMM0), imm(0), "c5 f1 73 d0 00");
testOp3(m64, .VPSRLQ, reg(.YMM1), reg(.YMM2), regRm(.XMM0), "c5 ed d3 c8");
testOp3(m64, .VPSRLQ, reg(.YMM1), regRm(.YMM0), imm(0), "c5 f5 73 d0 00");
testOp3(m64, .VPSRLQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 d3 fc");
testOp3(m64, .VPSRLQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.XMM20), "62 21 d5 a7 d3 fc");
testOp3(m64, .VPSRLQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.XMM20), "62 21 d5 c7 d3 fc");
testOp3(m64, .VPSRLQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 85 87 73 d4 00");
testOp3(m64, .VPSRLQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 85 a7 73 d4 00");
testOp3(m64, .VPSRLQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 85 c7 73 d4 00");
}
{
testOp2(m64, .VPTEST, reg(.XMM1), regRm(.XMM0), "c4 e2 79 17 c8");
testOp2(m64, .VPTEST, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 17 c8");
}
{
// VPUNPCKHBW / VPUNPCKHWD / VPUNPCKHDQ / VPUNPCKHQDQ
// VPUNPCKHBW
testOp3(m64, .VPUNPCKHBW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 68 c8");
testOp3(m64, .VPUNPCKHBW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 68 c8");
testOp3(m64, .VPUNPCKHBW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 68 fc");
testOp3(m64, .VPUNPCKHBW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 68 fc");
testOp3(m64, .VPUNPCKHBW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 68 fc");
// VPUNPCKHWD
testOp3(m64, .VPUNPCKHWD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 69 c8");
testOp3(m64, .VPUNPCKHWD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 69 c8");
testOp3(m64, .VPUNPCKHWD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 69 fc");
testOp3(m64, .VPUNPCKHWD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 69 fc");
testOp3(m64, .VPUNPCKHWD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 69 fc");
// VPUNPCKHDQ
testOp3(m64, .VPUNPCKHDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 6a c8");
testOp3(m64, .VPUNPCKHDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 6a c8");
testOp3(m64, .VPUNPCKHDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 6a fc");
testOp3(m64, .VPUNPCKHDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 6a fc");
testOp3(m64, .VPUNPCKHDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 6a fc");
// VPUNPCKHQDQ
testOp3(m64, .VPUNPCKHQDQ,reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 6d c8");
testOp3(m64, .VPUNPCKHQDQ,reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 6d c8");
testOp3(m64, .VPUNPCKHQDQ,pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 6d fc");
testOp3(m64, .VPUNPCKHQDQ,pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 6d fc");
testOp3(m64, .VPUNPCKHQDQ,pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 6d fc");
// VPUNPCKLBW / VPUNPCKLWD / VPUNPCKLDQ / VPUNPCKLQDQ
// VPUNPCKLBW
testOp3(m64, .VPUNPCKLBW, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 60 c8");
testOp3(m64, .VPUNPCKLBW, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 60 c8");
testOp3(m64, .VPUNPCKLBW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 60 fc");
testOp3(m64, .VPUNPCKLBW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 60 fc");
testOp3(m64, .VPUNPCKLBW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 60 fc");
// VPUNPCKLWD
testOp3(m64, .VPUNPCKLWD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 61 c8");
testOp3(m64, .VPUNPCKLWD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 61 c8");
testOp3(m64, .VPUNPCKLWD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 61 fc");
testOp3(m64, .VPUNPCKLWD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 61 fc");
testOp3(m64, .VPUNPCKLWD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 61 fc");
// VPUNPCKLDQ
testOp3(m64, .VPUNPCKLDQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 62 c8");
testOp3(m64, .VPUNPCKLDQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 62 c8");
testOp3(m64, .VPUNPCKLDQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 62 fc");
testOp3(m64, .VPUNPCKLDQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 62 fc");
testOp3(m64, .VPUNPCKLDQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 62 fc");
// VPUNPCKLQDQ
testOp3(m64, .VPUNPCKLQDQ,reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 6c c8");
testOp3(m64, .VPUNPCKLQDQ,reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 6c c8");
testOp3(m64, .VPUNPCKLQDQ,pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 6c fc");
testOp3(m64, .VPUNPCKLQDQ,pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 6c fc");
testOp3(m64, .VPUNPCKLQDQ,pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 6c fc");
}
{
// VPXOR
testOp3(m64, .VPXOR, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 ef c8");
testOp3(m64, .VPXOR, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed ef c8");
//
testOp3(m64, .VPXORD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 55 87 ef fc");
testOp3(m64, .VPXORD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 55 a7 ef fc");
testOp3(m64, .VPXORD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 55 c7 ef fc");
//
testOp3(m64, .VPXORQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 ef fc");
testOp3(m64, .VPXORQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 ef fc");
testOp3(m64, .VPXORQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 ef fc");
}
{
// VRCPPS
testOp2(m64, .VRCPPS, reg(.XMM1), regRm(.XMM0), "c5 f8 53 c8");
testOp2(m64, .VRCPPS, reg(.YMM1), regRm(.YMM0), "c5 fc 53 c8");
// VRCPSS
testOp3(m64, .VRCPSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 ea 53 c8");
// VROUNDPD
testOp3(m64, .VROUNDPD, reg(.XMM1), regRm(.XMM0), imm(0), "c4 e3 79 09 c8 00");
testOp3(m64, .VROUNDPD, reg(.YMM1), regRm(.YMM0), imm(0), "c4 e3 7d 09 c8 00");
// VROUNDPS
testOp3(m64, .VROUNDPS, reg(.XMM1), regRm(.XMM0), imm(0), "c4 e3 79 08 c8 00");
testOp3(m64, .VROUNDPS, reg(.YMM1), regRm(.YMM0), imm(0), "c4 e3 7d 08 c8 00");
// VROUNDSD
testOp4(m64, .VROUNDSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 0b c8 00");
// VROUNDSS
testOp4(m64, .VROUNDSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c4 e3 69 0a c8 00");
// VRSQRTPS
testOp2(m64, .VRSQRTPS, reg(.XMM1), regRm(.XMM0), "c5 f8 52 c8");
testOp2(m64, .VRSQRTPS, reg(.YMM1), regRm(.YMM0), "c5 fc 52 c8");
// VRSQRTSS
testOp3(m64, .VRSQRTSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 ea 52 c8");
}
{
// VSHUFPD
testOp4(m64, .VSHUFPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c5 e9 c6 c8 00");
testOp4(m64, .VSHUFPD, reg(.YMM1), reg(.XMM1), regRm(.YMM0), imm(0), "c5 f5 c6 c8 00");
testOp4(m64, .VSHUFPD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 21 d5 87 c6 fc 00");
testOp4(m64, .VSHUFPD, pred(.YMM31, .K7, .Zero),reg(.XMM21),regRm(.YMM20),imm(0), "62 21 d5 a7 c6 fc 00");
testOp4(m64, .VSHUFPD, pred(.ZMM31, .K7, .Zero),reg(.XMM21),regRm(.ZMM20),imm(0), "62 21 d5 c7 c6 fc 00");
// VSHUFPS
testOp4(m64, .VSHUFPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), imm(0), "c5 e8 c6 c8 00");
testOp4(m64, .VSHUFPS, reg(.YMM1), reg(.XMM1), regRm(.YMM0), imm(0), "c5 f4 c6 c8 00");
testOp4(m64, .VSHUFPS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 21 54 87 c6 fc 00");
testOp4(m64, .VSHUFPS, pred(.YMM31, .K7, .Zero),reg(.XMM21),regRm(.YMM20),imm(0), "62 21 54 a7 c6 fc 00");
testOp4(m64, .VSHUFPS, pred(.ZMM31, .K7, .Zero),reg(.XMM21),regRm(.ZMM20),imm(0), "62 21 54 c7 c6 fc 00");
// VSQRTPD
testOp2(m64, .VSQRTPD, reg(.XMM1), regRm(.XMM0), "c5 f9 51 c8");
testOp2(m64, .VSQRTPD, reg(.YMM1), regRm(.YMM0), "c5 fd 51 c8");
testOp2(m64, .VSQRTPD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 51 fc");
testOp2(m64, .VSQRTPD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 51 fc");
testOp2(m64, .VSQRTPD, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fd 9f 51 fe");
// VSQRTPS
testOp2(m64, .VSQRTPS, reg(.XMM1), regRm(.XMM0), "c5 f8 51 c8");
testOp2(m64, .VSQRTPS, reg(.YMM1), regRm(.YMM0), "c5 fc 51 c8");
testOp2(m64, .VSQRTPS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7c 8f 51 fc");
testOp2(m64, .VSQRTPS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7c af 51 fc");
testOp2(m64, .VSQRTPS, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 7c 9f 51 fe");
// VSQRTSD
testOp3(m64, .VSQRTSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 eb 51 c8");
testOp3(m64, .VSQRTSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 d7 97 51 fe");
// VSQRTSS
testOp3(m64, .VSQRTSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 ea 51 c8");
testOp3(m64, .VSQRTSS, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 56 97 51 fe");
// VSTMXCSR
testOp1(m64, .VSTMXCSR, rm_mem32, "67 c5 f8 ae 18");
}
{
// VSUBPD
testOp3(m64, .VSUBPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 5c c8");
testOp3(m64, .VSUBPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 5c c8");
testOp3(m64, .VSUBPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 5c fc");
testOp3(m64, .VSUBPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 5c fc");
testOp3(m64, .VSUBPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), sae(.ZMM30, .RN_SAE), "62 01 d5 97 5c fe");
// VSUBPS
testOp3(m64, .VSUBPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 5c c8");
testOp3(m64, .VSUBPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 5c c8");
testOp3(m64, .VSUBPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 5c fc");
testOp3(m64, .VSUBPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 5c fc");
testOp3(m64, .VSUBPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), sae(.ZMM30, .RN_SAE), "62 01 54 97 5c fe");
// VSUBSD
testOp3(m64, .VSUBSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 eb 5c c8");
testOp3(m64, .VSUBSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 d7 97 5c fe");
// VSUBSS
testOp3(m64, .VSUBSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 ea 5c c8");
testOp3(m64, .VSUBSS, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .RN_SAE), "62 01 56 97 5c fe");
}
{
// VUCOMISD
testOp2(m64, .VUCOMISD, reg(.XMM1), regRm(.XMM0), "c5 f9 2e c8");
testOp2(m64, .VUCOMISD, pred(.XMM31, .K7, .Zero), sae(.XMM30, .SAE), "62 01 fd 9f 2e fe");
// VUCOMISS
testOp2(m64, .VUCOMISS, reg(.XMM1), regRm(.XMM0), "c5 f8 2e c8");
testOp2(m64, .VUCOMISS, pred(.XMM31, .K7, .Zero), sae(.XMM30, .SAE), "62 01 7c 9f 2e fe");
}
{
// VUNPCKHPD
testOp3(m64, .VUNPCKHPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 15 c8");
testOp3(m64, .VUNPCKHPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 15 c8");
testOp3(m64, .VUNPCKHPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 15 fc");
testOp3(m64, .VUNPCKHPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 15 fc");
testOp3(m64, .VUNPCKHPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 15 fc");
// VUNPCKHPS
testOp3(m64, .VUNPCKHPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 15 c8");
testOp3(m64, .VUNPCKHPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 15 c8");
testOp3(m64, .VUNPCKHPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 15 fc");
testOp3(m64, .VUNPCKHPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 15 fc");
testOp3(m64, .VUNPCKHPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 54 c7 15 fc");
// VUNPCKLPD
testOp3(m64, .VUNPCKLPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 14 c8");
testOp3(m64, .VUNPCKLPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 14 c8");
testOp3(m64, .VUNPCKLPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 14 fc");
testOp3(m64, .VUNPCKLPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 14 fc");
testOp3(m64, .VUNPCKLPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 14 fc");
// VUNPCKLPS
testOp3(m64, .VUNPCKLPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 14 c8");
testOp3(m64, .VUNPCKLPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 14 c8");
testOp3(m64, .VUNPCKLPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 14 fc");
testOp3(m64, .VUNPCKLPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 14 fc");
testOp3(m64, .VUNPCKLPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 54 c7 14 fc");
}
//
// Instructions V-Z
//
{
// VALIGND / VALIGNQ
// VALIGND
testOp4(m64, .VALIGND, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 03 fc 00");
testOp4(m64, .VALIGND, pred(.YMM31, .K7, .Zero),reg(.XMM21),regRm(.YMM20),imm(0), "62 23 55 a7 03 fc 00");
testOp4(m64, .VALIGND, pred(.ZMM31, .K7, .Zero),reg(.XMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 03 fc 00");
// VALIGNQ
testOp4(m64, .VALIGNQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 03 fc 00");
testOp4(m64, .VALIGNQ, pred(.YMM31, .K7, .Zero),reg(.XMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 03 fc 00");
testOp4(m64, .VALIGNQ, pred(.ZMM31, .K7, .Zero),reg(.XMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 03 fc 00");
// VBLENDMPD / VBLENDMPS
// VBLENDMPD
testOp3(m64, .VBLENDMPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 65 fc");
testOp3(m64, .VBLENDMPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 65 fc");
testOp3(m64, .VBLENDMPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 65 fc");
// VBLENDMPS
testOp3(m64, .VBLENDMPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 65 fc");
testOp3(m64, .VBLENDMPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 65 fc");
testOp3(m64, .VBLENDMPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 65 fc");
}
{
// VBROADCAST
// VBROADCASTSS
testOp2(m64, .VBROADCASTSS, reg(.XMM1), rm_mem32, "67 c4 e2 79 18 08");
testOp2(m64, .VBROADCASTSS, reg(.YMM1), rm_mem32, "67 c4 e2 7d 18 08");
testOp2(m64, .VBROADCASTSS, reg(.XMM1), regRm(.XMM0), "c4 e2 79 18 c8");
testOp2(m64, .VBROADCASTSS, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 18 c8");
testOp2(m64, .VBROADCASTSS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 18 fc");
testOp2(m64, .VBROADCASTSS, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 18 fc");
testOp2(m64, .VBROADCASTSS, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 18 fc");
// VBROADCASTSD
testOp2(m64, .VBROADCASTSD, reg(.YMM1), rm_mem64, "67 c4 e2 7d 19 08");
testOp2(m64, .VBROADCASTSD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 19 c8");
testOp2(m64, .VBROADCASTSD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd af 19 fc");
testOp2(m64, .VBROADCASTSD, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd cf 19 fc");
// VBROADCASTF1 28
testOp2(m64, .VBROADCASTF128, reg(.YMM1), rm_mem128, "67 c4 e2 7d 1a 08");
// VBROADCASTF32X2
testOp2(m64, .VBROADCASTF32X2, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 19 fc");
testOp2(m64, .VBROADCASTF32X2, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 19 fc");
// VBROADCASTF32X4
testOp2(m64, .VBROADCASTF32X4, pred(.YMM31, .K7, .Zero), rm_mem128, "67 62 62 7d af 1a 38");
testOp2(m64, .VBROADCASTF32X4, pred(.ZMM31, .K7, .Zero), rm_mem128, "67 62 62 7d cf 1a 38");
// VBROADCASTF64X2
testOp2(m64, .VBROADCASTF64X2, pred(.YMM31, .K7, .Zero), rm_mem128, "67 62 62 fd af 1a 38");
testOp2(m64, .VBROADCASTF64X2, pred(.ZMM31, .K7, .Zero), rm_mem128, "67 62 62 fd cf 1a 38");
// VBROADCASTF32X8
testOp2(m64, .VBROADCASTF32X8, pred(.ZMM31, .K7, .Zero), rm_mem256, "67 62 62 7d cf 1b 38");
// VBROADCASTF64X4
testOp2(m64, .VBROADCASTF64X4, pred(.ZMM31, .K7, .Zero), rm_mem256, "67 62 62 fd cf 1b 38");
}
{
// VCOMPRESSPD
testOp2(m64, .VCOMPRESSPD, regRm(.XMM20), reg(.XMM21), "62 a2 fd 08 8a ec");
testOp2(m64, .VCOMPRESSPD, regRm(.YMM20), reg(.YMM21), "62 a2 fd 28 8a ec");
testOp2(m64, .VCOMPRESSPD, regRm(.ZMM20), reg(.ZMM21), "62 a2 fd 48 8a ec");
// VCOMPRESSPS
testOp2(m64, .VCOMPRESSPS, regRm(.XMM20), reg(.XMM21), "62 a2 7d 08 8a ec");
testOp2(m64, .VCOMPRESSPS, regRm(.YMM20), reg(.YMM21), "62 a2 7d 28 8a ec");
testOp2(m64, .VCOMPRESSPS, regRm(.ZMM20), reg(.ZMM21), "62 a2 7d 48 8a ec");
}
{
// VCVTPD2QQ
testOp2(m64, .VCVTPD2QQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 7b fc");
testOp2(m64, .VCVTPD2QQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 7b fc");
testOp2(m64, .VCVTPD2QQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fd 9f 7b fe");
// VCVTPD2UDQ
testOp2(m64, .VCVTPD2UDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fc 8f 79 fc");
testOp2(m64, .VCVTPD2UDQ, pred(.XMM31, .K7, .Zero), regRm(.YMM20), "62 21 fc af 79 fc");
testOp2(m64, .VCVTPD2UDQ, pred(.YMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fc 9f 79 fe");
// VCVTPD2UQQ
testOp2(m64, .VCVTPD2UQQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 79 fc");
testOp2(m64, .VCVTPD2UQQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 79 fc");
testOp2(m64, .VCVTPD2UQQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fd 9f 79 fe");
}
{
// VCVTPH2PS
testOp2(m64, .VCVTPH2PS, reg(.XMM1), regRm(.XMM0), "c4 e2 79 13 c8");
testOp2(m64, .VCVTPH2PS, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 13 c8");
testOp2(m64, .VCVTPH2PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 13 fc");
testOp2(m64, .VCVTPH2PS, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 13 fc");
testOp2(m64, .VCVTPH2PS, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d cf 13 fc");
// VCVTPS2PH
testOp3(m64, .VCVTPS2PH, regRm(.XMM0), reg(.XMM1), imm(0), "c4 e3 79 1d c8 00");
testOp3(m64, .VCVTPS2PH, regRm(.XMM0), reg(.YMM1), imm(0), "c4 e3 7d 1d c8 00");
testOp3(m64, .VCVTPS2PH, regRm(.XMM20), reg(.XMM21), imm(0), "62 a3 7d 08 1d ec 00");
testOp3(m64, .VCVTPS2PH, regRm(.XMM20), reg(.YMM21), imm(0), "62 a3 7d 28 1d ec 00");
testOp3(m64, .VCVTPS2PH, regRm(.YMM20), sae(.ZMM30, .SAE), imm(0), "62 23 7d 58 1d f4 00");
}
{
// VCVTPS2QQ
testOp2(m64, .VCVTPS2QQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d 8f 7b fc");
testOp2(m64, .VCVTPS2QQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d af 7b fc");
testOp2(m64, .VCVTPS2QQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 21 7d cf 7b fc");
// VCVTPS2UDQ
testOp2(m64, .VCVTPS2UDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7c 8f 79 fc");
testOp2(m64, .VCVTPS2UDQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7c af 79 fc");
testOp2(m64, .VCVTPS2UDQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 7c 9f 79 fe");
// VCVTPS2UQQ
testOp2(m64, .VCVTPS2UQQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d 8f 79 fc");
testOp2(m64, .VCVTPS2UQQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d af 79 fc");
testOp2(m64, .VCVTPS2UQQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 21 7d cf 79 fc");
}
{
// VCVTQQ2PD
testOp2(m64, .VCVTQQ2PD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fe 8f e6 fc");
testOp2(m64, .VCVTQQ2PD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fe af e6 fc");
testOp2(m64, .VCVTQQ2PD, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fe 9f e6 fe");
// VCVTQQ2PS
testOp2(m64, .VCVTQQ2PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fc 8f 5b fc");
testOp2(m64, .VCVTQQ2PS, pred(.XMM31, .K7, .Zero), regRm(.YMM20), "62 21 fc af 5b fc");
testOp2(m64, .VCVTQQ2PS, pred(.YMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fc 9f 5b fe");
}
{
// VCVTSD2USI
testOp2(m64, .VCVTSD2USI, reg(.EAX), sae(.XMM30, .RN_SAE), "62 91 7f 18 79 c6");
testOp2(m64, .VCVTSD2USI, reg(.RAX), sae(.XMM30, .RN_SAE), "62 91 ff 18 79 c6");
// VCVTSS2USI
testOp2(m64, .VCVTSS2USI, reg(.EAX), sae(.XMM30, .RN_SAE), "62 91 7e 18 79 c6");
testOp2(m64, .VCVTSS2USI, reg(.RAX), sae(.XMM30, .RN_SAE), "62 91 fe 18 79 c6");
}
{
// VCVTTPD2QQ
testOp2(m64, .VCVTTPD2QQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 7a fc");
testOp2(m64, .VCVTTPD2QQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 7a fc");
testOp2(m64, .VCVTTPD2QQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 01 fd df 7a fe");
// VCVTTPD2UDQ
testOp2(m64, .VCVTTPD2UDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fc 8f 78 fc");
testOp2(m64, .VCVTTPD2UDQ, pred(.XMM31, .K7, .Zero), regRm(.YMM20), "62 21 fc af 78 fc");
testOp2(m64, .VCVTTPD2UDQ, pred(.YMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 01 fc df 78 fe");
// VCVTTPD2UQQ
testOp2(m64, .VCVTTPD2UQQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fd 8f 78 fc");
testOp2(m64, .VCVTTPD2UQQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fd af 78 fc");
testOp2(m64, .VCVTTPD2UQQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 01 fd df 78 fe");
// VCVTTPS2QQ
testOp2(m64, .VCVTTPS2QQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d 8f 7a fc");
testOp2(m64, .VCVTTPS2QQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d af 7a fc");
testOp2(m64, .VCVTTPS2QQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 21 7d cf 7a fc");
// VCVTTPS2UDQ
testOp2(m64, .VCVTTPS2UDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7c 8f 78 fc");
testOp2(m64, .VCVTTPS2UDQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7c af 78 fc");
testOp2(m64, .VCVTTPS2UDQ, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 01 7c df 78 fe");
// VCVTTPS2UQQ
testOp2(m64, .VCVTTPS2UQQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d 8f 78 fc");
testOp2(m64, .VCVTTPS2UQQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 21 7d af 78 fc");
testOp2(m64, .VCVTTPS2UQQ, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 21 7d cf 78 fc");
// VCVTTSD2USI
testOp2(m64, .VCVTTSD2USI, reg(.EAX), sae(.XMM30, .SAE), "62 91 7f 18 78 c6");
testOp2(m64, .VCVTTSD2USI, reg(.RAX), sae(.XMM30, .SAE), "62 91 ff 18 78 c6");
// VCVTTSS2USI
testOp2(m64, .VCVTTSS2USI, reg(.EAX), sae(.XMM30, .SAE), "62 91 7e 18 78 c6");
testOp2(m64, .VCVTTSS2USI, reg(.RAX), sae(.XMM30, .SAE), "62 91 fe 18 78 c6");
}
{
// VCVTUDQ2PD
testOp2(m64, .VCVTUDQ2PD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7e 8f 7a fc");
testOp2(m64, .VCVTUDQ2PD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 21 7e af 7a fc");
testOp2(m64, .VCVTUDQ2PD, pred(.ZMM31, .K7, .Zero), regRm(.YMM20), "62 21 7e cf 7a fc");
// VCVTUDQ2PS
testOp2(m64, .VCVTUDQ2PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 7f 8f 7a fc");
testOp2(m64, .VCVTUDQ2PS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 7f af 7a fc");
testOp2(m64, .VCVTUDQ2PS, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 7f 9f 7a fe");
// VCVTUQQ2PD
testOp2(m64, .VCVTUQQ2PD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 fe 8f 7a fc");
testOp2(m64, .VCVTUQQ2PD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 21 fe af 7a fc");
testOp2(m64, .VCVTUQQ2PD, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 fe 9f 7a fe");
// VCVTUQQ2PS
testOp2(m64, .VCVTUQQ2PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 21 ff 8f 7a fc");
testOp2(m64, .VCVTUQQ2PS, pred(.XMM31, .K7, .Zero), regRm(.YMM20), "62 21 ff af 7a fc");
testOp2(m64, .VCVTUQQ2PS, pred(.YMM31, .K7, .Zero), sae(.ZMM30, .RN_SAE), "62 01 ff 9f 7a fe");
// VCVTUSI2SD
testOp3(m64, .VCVTUSI2SD, reg(.XMM21), reg(.XMM22), regRm(.EAX), "62 e1 4f 00 7b e8");
testOp3(m64, .VCVTUSI2SD, reg(.XMM21), reg(.XMM22), sae(.RAX, .RN_SAE), "62 e1 cf 10 7b e8");
testOp3(m64, .VCVTUSI2SD, reg(.XMM21), reg(.XMM22), rm64, "67 62 e1 cf 00 7b 28");
// VCVTUSI2SS
testOp3(m64, .VCVTUSI2SS, reg(.XMM21), reg(.XMM22), sae(.EAX, .RN_SAE), "62 e1 4e 10 7b e8");
testOp3(m64, .VCVTUSI2SS, reg(.XMM21), reg(.XMM22), sae(.RAX, .RN_SAE), "62 e1 ce 10 7b e8");
testOp3(m64, .VCVTUSI2SS, reg(.XMM21), reg(.XMM22), rm32, "67 62 e1 4e 00 7b 28");
testOp3(m64, .VCVTUSI2SS, reg(.XMM21), reg(.XMM22), rm64, "67 62 e1 ce 00 7b 28");
}
{
// VDBPSADBW
testOp4(m64, .VDBPSADBW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 42 fc 00");
testOp4(m64, .VDBPSADBW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 42 fc 00");
testOp4(m64, .VDBPSADBW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 42 fc 00");
}
{
// VEXPANDPD
testOp2(m64, .VEXPANDPD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 88 fc");
testOp2(m64, .VEXPANDPD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 88 fc");
testOp2(m64, .VEXPANDPD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 88 fc");
// VEXPANDPS
testOp2(m64, .VEXPANDPS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 88 fc");
testOp2(m64, .VEXPANDPS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 88 fc");
testOp2(m64, .VEXPANDPS, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 88 fc");
}
{
// VEXTRACTF (128, F32x4, 64x2, 32x8, 64x4)
// VEXTRACTF128
testOp3(m64, .VEXTRACTF128, regRm(.XMM0), reg(.YMM1), imm(0), "c4 e3 7d 19 c8 00");
// VEXTRACTF32X4
testOp3(m64, .VEXTRACTF32X4, regRm(.XMM20), reg(.YMM21), imm(0), "62 a3 7d 28 19 ec 00");
testOp3(m64, .VEXTRACTF32X4, regRm(.XMM20), reg(.ZMM21), imm(0), "62 a3 7d 48 19 ec 00");
// VEXTRACTF64X2
testOp3(m64, .VEXTRACTF64X2, regRm(.XMM20), reg(.YMM21), imm(0), "62 a3 fd 28 19 ec 00");
testOp3(m64, .VEXTRACTF64X2, regRm(.XMM20), reg(.ZMM21), imm(0), "62 a3 fd 48 19 ec 00");
// VEXTRACTF32X8
testOp3(m64, .VEXTRACTF32X8, regRm(.YMM20), reg(.ZMM21), imm(0), "62 a3 7d 48 1b ec 00");
// VEXTRACTF64X4
testOp3(m64, .VEXTRACTF64X4, regRm(.YMM20), reg(.ZMM21), imm(0), "62 a3 fd 48 1b ec 00");
// VEXTRACTI (128, F32x4, 64x2, 32x8, 64x4)
// VEXTRACTI128
testOp3(m64, .VEXTRACTI128, regRm(.XMM0), reg(.YMM1), imm(0), "c4 e3 7d 39 c8 00");
// VEXTRACTI32X4
testOp3(m64, .VEXTRACTI32X4, regRm(.XMM20), reg(.YMM21), imm(0), "62 a3 7d 28 39 ec 00");
testOp3(m64, .VEXTRACTI32X4, regRm(.XMM20), reg(.ZMM21), imm(0), "62 a3 7d 48 39 ec 00");
// VEXTRACTI64X2
testOp3(m64, .VEXTRACTI64X2, regRm(.XMM20), reg(.YMM21), imm(0), "62 a3 fd 28 39 ec 00");
testOp3(m64, .VEXTRACTI64X2, regRm(.XMM20), reg(.ZMM21), imm(0), "62 a3 fd 48 39 ec 00");
// VEXTRACTI32X8
testOp3(m64, .VEXTRACTI32X8, regRm(.YMM20), reg(.ZMM21), imm(0), "62 a3 7d 48 3b ec 00");
// VEXTRACTI64X4
testOp3(m64, .VEXTRACTI64X4, regRm(.YMM20), reg(.ZMM21), imm(0), "62 a3 fd 48 3b ec 00");
}
{
// VFIXUPIMMPD
testOp4(m64, .VFIXUPIMMPD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 54 fc 00");
testOp4(m64, .VFIXUPIMMPD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 54 fc 00");
testOp4(m64, .VFIXUPIMMPD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .SAE),imm(0), "62 03 d5 d7 54 fe 00");
// VFIXUPIMMPS
testOp4(m64, .VFIXUPIMMPS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 54 fc 00");
testOp4(m64, .VFIXUPIMMPS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 54 fc 00");
testOp4(m64, .VFIXUPIMMPS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .SAE),imm(0), "62 03 55 d7 54 fe 00");
// VFIXUPIMMSD
testOp4(m64, .VFIXUPIMMSD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 d5 97 55 fe 00");
// VFIXUPIMMSS
testOp4(m64, .VFIXUPIMMSS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 55 97 55 fe 00");
}
{
{
// VFMADDPD
testOp4(m64, .VFMADDPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 69 c8 30");
testOp4(m64, .VFMADDPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 69 c8 30");
testOp4(m64, .VFMADDPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 69 c8 30");
testOp4(m64, .VFMADDPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 69 c8 30");
// VFMADDPS
testOp4(m64, .VFMADDPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 68 c8 30");
testOp4(m64, .VFMADDPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 68 c8 30");
testOp4(m64, .VFMADDPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 68 c8 30");
testOp4(m64, .VFMADDPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 68 c8 30");
// VFMADDSD
testOp4(m64, .VFMADDSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6b c8 30");
testOp4(m64, .VFMADDSD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6b c8 30");
// VFMADDSS
testOp4(m64, .VFMADDSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6a c8 30");
testOp4(m64, .VFMADDSS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6a c8 30");
}
// VFMADD132PD / VFMADD213PD / VFMADD231PD
testOp3(m64, .VFMADD132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 98 c8");
testOp3(m64, .VFMADD132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 98 c8");
testOp3(m64, .VFMADD132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 98 fc");
testOp3(m64, .VFMADD132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 98 fc");
testOp3(m64, .VFMADD132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 98 fe");
//
testOp3(m64, .VFMADD213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 a8 c8");
testOp3(m64, .VFMADD213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed a8 c8");
testOp3(m64, .VFMADD213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 a8 fc");
testOp3(m64, .VFMADD213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 a8 fc");
testOp3(m64, .VFMADD213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 a8 fe");
//
testOp3(m64, .VFMADD231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 b8 c8");
testOp3(m64, .VFMADD231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed b8 c8");
testOp3(m64, .VFMADD231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 b8 fc");
testOp3(m64, .VFMADD231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 b8 fc");
testOp3(m64, .VFMADD231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 b8 fe");
// VFMADD132PS / VFMADD213PS / VFMADD231PS
testOp3(m64, .VFMADD132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 98 c8");
testOp3(m64, .VFMADD132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 98 c8");
testOp3(m64, .VFMADD132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 98 fc");
testOp3(m64, .VFMADD132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 98 fc");
testOp3(m64, .VFMADD132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 98 fe");
//
testOp3(m64, .VFMADD213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 a8 c8");
testOp3(m64, .VFMADD213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d a8 c8");
testOp3(m64, .VFMADD213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 a8 fc");
testOp3(m64, .VFMADD213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 a8 fc");
testOp3(m64, .VFMADD213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 a8 fe");
//
testOp3(m64, .VFMADD231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 b8 c8");
testOp3(m64, .VFMADD231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d b8 c8");
testOp3(m64, .VFMADD231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 b8 fc");
testOp3(m64, .VFMADD231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 b8 fc");
testOp3(m64, .VFMADD231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 b8 fe");
// VFMADD132SD / VFMADD213SD / VFMADD231SD
testOp3(m64, .VFMADD132SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 99 c8");
testOp3(m64, .VFMADD132SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 99 fe");
//
testOp3(m64, .VFMADD213SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 a9 c8");
testOp3(m64, .VFMADD213SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 a9 fe");
//
testOp3(m64, .VFMADD231SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 b9 c8");
testOp3(m64, .VFMADD231SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 b9 fe");
// VFMADD132SS / VFMADD213SS / VFMADD231SS
testOp3(m64, .VFMADD132SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 99 c8");
testOp3(m64, .VFMADD132SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 99 fe");
//
testOp3(m64, .VFMADD213SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 a9 c8");
testOp3(m64, .VFMADD213SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 a9 fe");
//
testOp3(m64, .VFMADD231SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 b9 c8");
testOp3(m64, .VFMADD231SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 b9 fe");
}
{
{
// VFMADDSUBPD
testOp4(m64, .VFMADDSUBPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 5d c8 30");
testOp4(m64, .VFMADDSUBPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 5d c8 30");
testOp4(m64, .VFMADDSUBPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 5d c8 30");
testOp4(m64, .VFMADDSUBPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 5d c8 30");
// VFMADDSUBPS
testOp4(m64, .VFMADDSUBPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 5c c8 30");
testOp4(m64, .VFMADDSUBPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 5c c8 30");
testOp4(m64, .VFMADDSUBPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 5c c8 30");
testOp4(m64, .VFMADDSUBPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 5c c8 30");
}
// VFMADDSUB132PD / VFMADDSUB213PD / VFMADDSUB231PD
testOp3(m64, .VFMADDSUB132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 96 c8");
testOp3(m64, .VFMADDSUB132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 96 c8");
testOp3(m64, .VFMADDSUB132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 96 fc");
testOp3(m64, .VFMADDSUB132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 96 fc");
testOp3(m64, .VFMADDSUB132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 96 fe");
//
testOp3(m64, .VFMADDSUB213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 a6 c8");
testOp3(m64, .VFMADDSUB213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed a6 c8");
testOp3(m64, .VFMADDSUB213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 a6 fc");
testOp3(m64, .VFMADDSUB213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 a6 fc");
testOp3(m64, .VFMADDSUB213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 a6 fe");
//
testOp3(m64, .VFMADDSUB231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 b6 c8");
testOp3(m64, .VFMADDSUB231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed b6 c8");
testOp3(m64, .VFMADDSUB231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 b6 fc");
testOp3(m64, .VFMADDSUB231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 b6 fc");
testOp3(m64, .VFMADDSUB231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 b6 fe");
// VFMADDSUB132PS / VFMADDSUB213PS / VFMADDSUB231PS
testOp3(m64, .VFMADDSUB132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 96 c8");
testOp3(m64, .VFMADDSUB132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 96 c8");
testOp3(m64, .VFMADDSUB132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 96 fc");
testOp3(m64, .VFMADDSUB132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 96 fc");
testOp3(m64, .VFMADDSUB132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 96 fe");
//
testOp3(m64, .VFMADDSUB213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 a6 c8");
testOp3(m64, .VFMADDSUB213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d a6 c8");
testOp3(m64, .VFMADDSUB213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 a6 fc");
testOp3(m64, .VFMADDSUB213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 a6 fc");
testOp3(m64, .VFMADDSUB213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 a6 fe");
//
testOp3(m64, .VFMADDSUB231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 b6 c8");
testOp3(m64, .VFMADDSUB231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d b6 c8");
testOp3(m64, .VFMADDSUB231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 b6 fc");
testOp3(m64, .VFMADDSUB231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 b6 fc");
testOp3(m64, .VFMADDSUB231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 b6 fe");
}
{
{
// VFMSUBADDPD
testOp4(m64, .VFMSUBADDPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 5f c8 30");
testOp4(m64, .VFMSUBADDPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 5f c8 30");
testOp4(m64, .VFMSUBADDPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 5f c8 30");
testOp4(m64, .VFMSUBADDPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 5f c8 30");
// VFMSUBADDPS
testOp4(m64, .VFMSUBADDPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 5e c8 30");
testOp4(m64, .VFMSUBADDPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 5e c8 30");
testOp4(m64, .VFMSUBADDPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 5e c8 30");
testOp4(m64, .VFMSUBADDPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 5e c8 30");
}
// VFMSUBADD132PD / VFMSUBADD213PD / VFMSUBADD231PD
testOp3(m64, .VFMSUBADD132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 97 c8");
testOp3(m64, .VFMSUBADD132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 97 c8");
testOp3(m64, .VFMSUBADD132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 97 fc");
testOp3(m64, .VFMSUBADD132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 97 fc");
testOp3(m64, .VFMSUBADD132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 97 fe");
//
testOp3(m64, .VFMSUBADD213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 a7 c8");
testOp3(m64, .VFMSUBADD213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed a7 c8");
testOp3(m64, .VFMSUBADD213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 a7 fc");
testOp3(m64, .VFMSUBADD213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 a7 fc");
testOp3(m64, .VFMSUBADD213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 a7 fe");
//
testOp3(m64, .VFMSUBADD231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 b7 c8");
testOp3(m64, .VFMSUBADD231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed b7 c8");
testOp3(m64, .VFMSUBADD231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 b7 fc");
testOp3(m64, .VFMSUBADD231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 b7 fc");
testOp3(m64, .VFMSUBADD231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 b7 fe");
// VFMSUBADD132PS / VFMSUBADD213PS / VFMSUBADD231PS
testOp3(m64, .VFMSUBADD132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 97 c8");
testOp3(m64, .VFMSUBADD132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 97 c8");
testOp3(m64, .VFMSUBADD132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 97 fc");
testOp3(m64, .VFMSUBADD132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 97 fc");
testOp3(m64, .VFMSUBADD132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 97 fe");
//
testOp3(m64, .VFMSUBADD213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 a7 c8");
testOp3(m64, .VFMSUBADD213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d a7 c8");
testOp3(m64, .VFMSUBADD213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 a7 fc");
testOp3(m64, .VFMSUBADD213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 a7 fc");
testOp3(m64, .VFMSUBADD213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 a7 fe");
//
testOp3(m64, .VFMSUBADD231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 b7 c8");
testOp3(m64, .VFMSUBADD231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d b7 c8");
testOp3(m64, .VFMSUBADD231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 b7 fc");
testOp3(m64, .VFMSUBADD231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 b7 fc");
testOp3(m64, .VFMSUBADD231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 b7 fe");
}
{
{
// VFMSUBPD
testOp4(m64, .VFMSUBPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6d c8 30");
testOp4(m64, .VFMSUBPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 6d c8 30");
testOp4(m64, .VFMSUBPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6d c8 30");
testOp4(m64, .VFMSUBPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 6d c8 30");
// VFMSUBPS
testOp4(m64, .VFMSUBPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6c c8 30");
testOp4(m64, .VFMSUBPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 6c c8 30");
testOp4(m64, .VFMSUBPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6c c8 30");
testOp4(m64, .VFMSUBPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 6c c8 30");
// VFMSUBSD
testOp4(m64, .VFMSUBSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6f c8 30");
testOp4(m64, .VFMSUBSD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6f c8 30");
// VFMSUBSS
testOp4(m64, .VFMSUBSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 6e c8 30");
testOp4(m64, .VFMSUBSS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 6e c8 30");
}
// VFMSUB132PD / VFMSUB213PD / VFMSUB231PD
testOp3(m64, .VFMSUB132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9a c8");
testOp3(m64, .VFMSUB132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 9a c8");
testOp3(m64, .VFMSUB132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 9a fc");
testOp3(m64, .VFMSUB132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 9a fc");
testOp3(m64, .VFMSUB132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 9a fe");
//
testOp3(m64, .VFMSUB213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 aa c8");
testOp3(m64, .VFMSUB213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed aa c8");
testOp3(m64, .VFMSUB213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 aa fc");
testOp3(m64, .VFMSUB213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 aa fc");
testOp3(m64, .VFMSUB213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 aa fe");
//
testOp3(m64, .VFMSUB231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 ba c8");
testOp3(m64, .VFMSUB231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed ba c8");
testOp3(m64, .VFMSUB231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 ba fc");
testOp3(m64, .VFMSUB231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 ba fc");
testOp3(m64, .VFMSUB231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 ba fe");
// VFMSUB132PS / VFMSUB213PS / VFMSUB231PS
testOp3(m64, .VFMSUB132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9a c8");
testOp3(m64, .VFMSUB132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 9a c8");
testOp3(m64, .VFMSUB132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 9a fc");
testOp3(m64, .VFMSUB132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 9a fc");
testOp3(m64, .VFMSUB132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 9a fe");
//
testOp3(m64, .VFMSUB213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 aa c8");
testOp3(m64, .VFMSUB213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d aa c8");
testOp3(m64, .VFMSUB213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 aa fc");
testOp3(m64, .VFMSUB213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 aa fc");
testOp3(m64, .VFMSUB213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 aa fe");
//
testOp3(m64, .VFMSUB231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 ba c8");
testOp3(m64, .VFMSUB231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d ba c8");
testOp3(m64, .VFMSUB231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 ba fc");
testOp3(m64, .VFMSUB231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 ba fc");
testOp3(m64, .VFMSUB231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 ba fe");
// VFMSUB132SD / VFMSUB213SD / VFMSUB231SD
testOp3(m64, .VFMSUB132SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9b c8");
testOp3(m64, .VFMSUB132SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 9b fe");
//
testOp3(m64, .VFMSUB213SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 ab c8");
testOp3(m64, .VFMSUB213SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 ab fe");
//
testOp3(m64, .VFMSUB231SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 bb c8");
testOp3(m64, .VFMSUB231SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 bb fe");
// VFMSUB132SS / VFMSUB213SS / VFMSUB231SS
testOp3(m64, .VFMSUB132SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9b c8");
testOp3(m64, .VFMSUB132SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 9b fe");
//
testOp3(m64, .VFMSUB213SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 ab c8");
testOp3(m64, .VFMSUB213SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 ab fe");
//
testOp3(m64, .VFMSUB231SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 bb c8");
testOp3(m64, .VFMSUB231SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 bb fe");
}
{
{
// VFNMADDPD
testOp4(m64, .VFNMADDPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 79 c8 30");
testOp4(m64, .VFNMADDPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 79 c8 30");
testOp4(m64, .VFNMADDPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 79 c8 30");
testOp4(m64, .VFNMADDPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 79 c8 30");
// VFNMADDPS
testOp4(m64, .VFNMADDPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 78 c8 30");
testOp4(m64, .VFNMADDPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 78 c8 30");
testOp4(m64, .VFNMADDPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 78 c8 30");
testOp4(m64, .VFNMADDPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 78 c8 30");
// VFNMADDSD
testOp4(m64, .VFNMADDSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7b c8 30");
testOp4(m64, .VFNMADDSD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7b c8 30");
// VFNMADDSS
testOp4(m64, .VFNMADDSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7a c8 30");
testOp4(m64, .VFNMADDSS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7a c8 30");
}
// VFNMADD132PD / VFNMADD213PD / VFNMADD231PD
testOp3(m64, .VFNMADD132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9c c8");
testOp3(m64, .VFNMADD132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 9c c8");
testOp3(m64, .VFNMADD132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 9c fc");
testOp3(m64, .VFNMADD132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 9c fc");
testOp3(m64, .VFNMADD132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 9c fe");
//
testOp3(m64, .VFNMADD213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 ac c8");
testOp3(m64, .VFNMADD213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed ac c8");
testOp3(m64, .VFNMADD213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 ac fc");
testOp3(m64, .VFNMADD213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 ac fc");
testOp3(m64, .VFNMADD213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 ac fe");
//
testOp3(m64, .VFNMADD231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 bc c8");
testOp3(m64, .VFNMADD231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed bc c8");
testOp3(m64, .VFNMADD231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 bc fc");
testOp3(m64, .VFNMADD231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 bc fc");
testOp3(m64, .VFNMADD231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 bc fe");
// VFNMADD132PS / VFNMADD213PS / VFNMADD231PS
testOp3(m64, .VFNMADD132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9c c8");
testOp3(m64, .VFNMADD132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 9c c8");
testOp3(m64, .VFNMADD132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 9c fc");
testOp3(m64, .VFNMADD132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 9c fc");
testOp3(m64, .VFNMADD132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 9c fe");
//
testOp3(m64, .VFNMADD213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 ac c8");
testOp3(m64, .VFNMADD213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d ac c8");
testOp3(m64, .VFNMADD213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 ac fc");
testOp3(m64, .VFNMADD213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 ac fc");
testOp3(m64, .VFNMADD213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 ac fe");
//
testOp3(m64, .VFNMADD231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 bc c8");
testOp3(m64, .VFNMADD231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d bc c8");
testOp3(m64, .VFNMADD231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 bc fc");
testOp3(m64, .VFNMADD231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 bc fc");
testOp3(m64, .VFNMADD231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 bc fe");
// VFNMADD132SD / VFNMADD213SD / VFNMADD231SD
testOp3(m64, .VFNMADD132SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9d c8");
testOp3(m64, .VFNMADD132SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 9d fe");
//
testOp3(m64, .VFNMADD213SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 ad c8");
testOp3(m64, .VFNMADD213SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 ad fe");
//
testOp3(m64, .VFNMADD231SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 bd c8");
testOp3(m64, .VFNMADD231SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 bd fe");
// VFNMADD132SS / VFNMADD213SS / VFNMADD231SS
testOp3(m64, .VFNMADD132SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9d c8");
testOp3(m64, .VFNMADD132SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 9d fe");
//
testOp3(m64, .VFNMADD213SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 ad c8");
testOp3(m64, .VFNMADD213SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 ad fe");
//
testOp3(m64, .VFNMADD231SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 bd c8");
testOp3(m64, .VFNMADD231SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 bd fe");
}
{
{
// VFNMSUBPD
testOp4(m64, .VFNMSUBPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7d c8 30");
testOp4(m64, .VFNMSUBPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 7d c8 30");
testOp4(m64, .VFNMSUBPD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7d c8 30");
testOp4(m64, .VFNMSUBPD, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 7d c8 30");
// VFNMSUBPS
testOp4(m64, .VFNMSUBPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7c c8 30");
testOp4(m64, .VFNMSUBPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), reg(.YMM3), "c4 e3 6d 7c c8 30");
testOp4(m64, .VFNMSUBPS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7c c8 30");
testOp4(m64, .VFNMSUBPS, reg(.YMM1), reg(.YMM2), reg(.YMM3), regRm(.YMM0), "c4 e3 ed 7c c8 30");
// VFNMSUBSD
testOp4(m64, .VFNMSUBSD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7f c8 30");
testOp4(m64, .VFNMSUBSD, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7f c8 30");
// VFNMSUBSS
testOp4(m64, .VFNMSUBSS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), reg(.XMM3), "c4 e3 69 7e c8 30");
testOp4(m64, .VFNMSUBSS, reg(.XMM1), reg(.XMM2), reg(.XMM3), regRm(.XMM0), "c4 e3 e9 7e c8 30");
}
// VFNMSUB132PD / VFNMSUB213PD / VFNMSUB231PD
testOp3(m64, .VFNMSUB132PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9e c8");
testOp3(m64, .VFNMSUB132PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 9e c8");
testOp3(m64, .VFNMSUB132PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 9e fc");
testOp3(m64, .VFNMSUB132PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 9e fc");
testOp3(m64, .VFNMSUB132PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 9e fe");
//
testOp3(m64, .VFNMSUB213PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 ae c8");
testOp3(m64, .VFNMSUB213PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed ae c8");
testOp3(m64, .VFNMSUB213PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 ae fc");
testOp3(m64, .VFNMSUB213PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 ae fc");
testOp3(m64, .VFNMSUB213PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 ae fe");
//
testOp3(m64, .VFNMSUB231PD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 be c8");
testOp3(m64, .VFNMSUB231PD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed be c8");
testOp3(m64, .VFNMSUB231PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 be fc");
testOp3(m64, .VFNMSUB231PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 be fc");
testOp3(m64, .VFNMSUB231PD, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 be fe");
// VFNMSUB132PS / VFNMSUB213PS / VFNMSUB231PS
testOp3(m64, .VFNMSUB132PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9e c8");
testOp3(m64, .VFNMSUB132PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 9e c8");
testOp3(m64, .VFNMSUB132PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 9e fc");
testOp3(m64, .VFNMSUB132PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 9e fc");
testOp3(m64, .VFNMSUB132PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 9e fe");
//
testOp3(m64, .VFNMSUB213PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 ae c8");
testOp3(m64, .VFNMSUB213PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d ae c8");
testOp3(m64, .VFNMSUB213PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 ae fc");
testOp3(m64, .VFNMSUB213PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 ae fc");
testOp3(m64, .VFNMSUB213PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 ae fe");
//
testOp3(m64, .VFNMSUB231PS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 be c8");
testOp3(m64, .VFNMSUB231PS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d be c8");
testOp3(m64, .VFNMSUB231PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 be fc");
testOp3(m64, .VFNMSUB231PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 be fc");
testOp3(m64, .VFNMSUB231PS, pred(.ZMM31, .K7, .Zero),reg(.YMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 be fe");
// VFNMSUB132SD / VFNMSUB213SD / VFNMSUB231SD
testOp3(m64, .VFNMSUB132SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 9f c8");
testOp3(m64, .VFNMSUB132SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 9f fe");
//
testOp3(m64, .VFNMSUB213SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 af c8");
testOp3(m64, .VFNMSUB213SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 af fe");
//
testOp3(m64, .VFNMSUB231SD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 bf c8");
testOp3(m64, .VFNMSUB231SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 bf fe");
// VFNMSUB132SS / VFNMSUB213SS / VFNMSUB231SS
testOp3(m64, .VFNMSUB132SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 9f c8");
testOp3(m64, .VFNMSUB132SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 9f fe");
//
testOp3(m64, .VFNMSUB213SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 af c8");
testOp3(m64, .VFNMSUB213SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 af fe");
//
testOp3(m64, .VFNMSUB231SS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 bf c8");
testOp3(m64, .VFNMSUB231SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 bf fe");
}
{
// VFPCLASSPD
testOp3(m64, .VFPCLASSPD, pred(.K0, .K7, .Merge),regRm(.XMM20),imm(0), "62 b3 fd 0f 66 c4 00");
testOp3(m64, .VFPCLASSPD, pred(.K0, .K7, .Merge),regRm(.YMM20),imm(0), "62 b3 fd 2f 66 c4 00");
testOp3(m64, .VFPCLASSPD, pred(.K0, .K7, .Merge),regRm(.ZMM20),imm(0), "62 b3 fd 4f 66 c4 00");
// VFPCLASSPS
testOp3(m64, .VFPCLASSPS, pred(.K0, .K7, .Merge),regRm(.XMM20),imm(0), "62 b3 7d 0f 66 c4 00");
testOp3(m64, .VFPCLASSPS, pred(.K0, .K7, .Merge),regRm(.YMM20),imm(0), "62 b3 7d 2f 66 c4 00");
testOp3(m64, .VFPCLASSPS, pred(.K0, .K7, .Merge),regRm(.ZMM20),imm(0), "62 b3 7d 4f 66 c4 00");
// VFPCLASSSD
testOp3(m64, .VFPCLASSSD, pred(.K0, .K7, .Merge),regRm(.XMM20),imm(0), "62 b3 fd 0f 67 c4 00");
// VFPCLASSSS
testOp3(m64, .VFPCLASSSS, pred(.K0, .K7, .Merge),regRm(.XMM20),imm(0), "62 b3 7d 0f 67 c4 00");
}
{
// VGATHERDPD / VGATHERQPD
testOp3(m64, .VGATHERDPD, reg(.XMM1), vm32xl, reg(.XMM2), "67 c4 e2 e9 92 0c f8");
testOp3(m64, .VGATHERDPD, reg(.YMM1), vm32xl, reg(.YMM2), "67 c4 e2 ed 92 0c f8");
testOp2(m64, .VGATHERDPD, pred(.XMM31, .K7, .Zero), vm32x, "67 62 22 fd 87 92 3c f0");
testOp2(m64, .VGATHERDPD, pred(.YMM31, .K7, .Zero), vm32x, "67 62 22 fd a7 92 3c f0");
testOp2(m64, .VGATHERDPD, pred(.ZMM31, .K7, .Zero), vm32y, "67 62 22 fd c7 92 3c f0");
//
testOp3(m64, .VGATHERQPD, reg(.XMM1), vm64xl, reg(.XMM2), "67 c4 e2 e9 93 0c f8");
testOp3(m64, .VGATHERQPD, reg(.YMM1), vm64yl, reg(.YMM2), "67 c4 e2 ed 93 0c f8");
testOp2(m64, .VGATHERQPD, pred(.XMM31, .K7, .Zero), vm64x, "67 62 22 fd 87 93 3c f0");
testOp2(m64, .VGATHERQPD, pred(.YMM31, .K7, .Zero), vm64y, "67 62 22 fd a7 93 3c f0");
testOp2(m64, .VGATHERQPD, pred(.ZMM31, .K7, .Zero), vm64z, "67 62 22 fd c7 93 3c f0");
// VGATHERDPS / VGATHERQPS
testOp3(m64, .VGATHERDPS, reg(.XMM1), vm32xl, reg(.XMM2), "67 c4 e2 69 92 0c f8");
testOp3(m64, .VGATHERDPS, reg(.YMM1), vm32yl, reg(.YMM2), "67 c4 e2 6d 92 0c f8");
testOp2(m64, .VGATHERDPS, pred(.XMM31, .K7, .Zero), vm32x, "67 62 22 7d 87 92 3c f0");
testOp2(m64, .VGATHERDPS, pred(.YMM31, .K7, .Zero), vm32y, "67 62 22 7d a7 92 3c f0");
testOp2(m64, .VGATHERDPS, pred(.ZMM31, .K7, .Zero), vm32z, "67 62 22 7d c7 92 3c f0");
//
testOp3(m64, .VGATHERQPS, reg(.XMM1), vm64xl, reg(.XMM2), "67 c4 e2 69 93 0c f8");
testOp3(m64, .VGATHERQPS, reg(.XMM1), vm64yl, reg(.XMM2), "67 c4 e2 6d 93 0c f8");
testOp2(m64, .VGATHERQPS, pred(.XMM31, .K7, .Zero), vm64x, "67 62 22 7d 87 93 3c f0");
testOp2(m64, .VGATHERQPS, pred(.XMM31, .K7, .Zero), vm64y, "67 62 22 7d a7 93 3c f0");
testOp2(m64, .VGATHERQPS, pred(.YMM31, .K7, .Zero), vm64z, "67 62 22 7d c7 93 3c f0");
}
{
// VGETEXPPD
testOp2(m64, .VGETEXPPD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 42 fc");
testOp2(m64, .VGETEXPPD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 42 fc");
testOp2(m64, .VGETEXPPD, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 02 fd df 42 fe");
// VGETEXPPS
testOp2(m64, .VGETEXPPS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 42 fc");
testOp2(m64, .VGETEXPPS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 42 fc");
testOp2(m64, .VGETEXPPS, pred(.ZMM31, .K7, .Zero), sae(.ZMM30, .SAE), "62 02 7d df 42 fe");
// VGETEXPSD
testOp3(m64, .VGETEXPSD, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .SAE), "62 02 d5 97 43 fe");
// VGETEXPSS
testOp3(m64, .VGETEXPSS, pred(.XMM31, .K7, .Zero), reg(.XMM21), sae(.XMM30, .SAE), "62 02 55 97 43 fe");
// VGETMANTPD
testOp3(m64, .VGETMANTPD, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 fd 8f 26 fc 00");
testOp3(m64, .VGETMANTPD, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 26 fc 00");
testOp3(m64, .VGETMANTPD, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 fd df 26 fe 00");
// VGETMANTPS
testOp3(m64, .VGETMANTPS, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 7d 8f 26 fc 00");
testOp3(m64, .VGETMANTPS, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 7d af 26 fc 00");
testOp3(m64, .VGETMANTPS, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 7d df 26 fe 00");
// VGETMANTSD
testOp4(m64, .VGETMANTSD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 d5 97 27 fe 00");
// VGETMANTSS
testOp4(m64, .VGETMANTSS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 55 97 27 fe 00");
}
{
// VINSERTF (128, F32x4, 64x2, 32x8, 64x4)
testOp4(m64, .VINSERTF128, reg(.YMM1),reg(.YMM2),regRm(.XMM0),imm(0), "c4 e3 6d 18 c8 00");
// VINSERTF32X4
testOp4(m64, .VINSERTF32X4, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.XMM20),imm(0), "62 23 55 a7 18 fc 00");
testOp4(m64, .VINSERTF32X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.XMM20),imm(0), "62 23 55 c7 18 fc 00");
// VINSERTF64X2
testOp4(m64, .VINSERTF64X2, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.XMM20),imm(0), "62 23 d5 a7 18 fc 00");
testOp4(m64, .VINSERTF64X2, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.XMM20),imm(0), "62 23 d5 c7 18 fc 00");
// VINSERTF32X8
testOp4(m64, .VINSERTF32X8, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.YMM20),imm(0), "62 23 55 c7 1a fc 00");
// VINSERTF64X4
testOp4(m64, .VINSERTF64X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.YMM20),imm(0), "62 23 d5 c7 1a fc 00");
// VINSERTI (128, F32x4, 64x2, 32x8, 64x4)
testOp4(m64, .VINSERTI128, reg(.YMM1),reg(.YMM2),regRm(.XMM0),imm(0), "c4 e3 6d 18 c8 00");
// VINSERTI32X4
testOp4(m64, .VINSERTI32X4, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.XMM20),imm(0), "62 23 55 a7 18 fc 00");
testOp4(m64, .VINSERTI32X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.XMM20),imm(0), "62 23 55 c7 18 fc 00");
// VINSERTI64X2
testOp4(m64, .VINSERTI64X2, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.XMM20),imm(0), "62 23 d5 a7 18 fc 00");
testOp4(m64, .VINSERTI64X2, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.XMM20),imm(0), "62 23 d5 c7 18 fc 00");
// VINSERTI32X8
testOp4(m64, .VINSERTI32X8, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.YMM20),imm(0), "62 23 55 c7 1a fc 00");
// VINSERTI64X4
testOp4(m64, .VINSERTI64X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.YMM20),imm(0), "62 23 d5 c7 1a fc 00");
}
{
// VMASKMOV
// VMASKMOVPD
testOp3(m64, .VMASKMOVPD, reg(.XMM1),reg(.XMM2),rm_mem128, "67 c4 e2 69 2d 08");
testOp3(m64, .VMASKMOVPD, reg(.YMM1),reg(.YMM2),rm_mem256, "67 c4 e2 6d 2d 08");
testOp3(m64, .VMASKMOVPD, rm_mem128,reg(.XMM1),reg(.XMM2), "67 c4 e2 71 2f 10");
testOp3(m64, .VMASKMOVPD, rm_mem256,reg(.YMM1),reg(.YMM2), "67 c4 e2 75 2f 10");
// VMASKMOVPS
testOp3(m64, .VMASKMOVPS, reg(.XMM1),reg(.XMM2),rm_mem128, "67 c4 e2 69 2c 08");
testOp3(m64, .VMASKMOVPS, reg(.YMM1),reg(.YMM2),rm_mem256, "67 c4 e2 6d 2c 08");
testOp3(m64, .VMASKMOVPS, rm_mem128,reg(.XMM1),reg(.XMM2), "67 c4 e2 71 2e 10");
testOp3(m64, .VMASKMOVPS, rm_mem256,reg(.YMM1),reg(.YMM2), "67 c4 e2 75 2e 10");
}
{
// VPBLENDD
testOp4(m64, .VPBLENDD, reg(.XMM1),reg(.XMM2),regRm(.XMM0),imm(0), "c4 e3 69 02 c8 00");
testOp4(m64, .VPBLENDD, reg(.YMM1),reg(.YMM2),regRm(.YMM0),imm(0), "c4 e3 6d 02 c8 00");
// VPBLENDMB / VPBLENDMW
// VPBLENDMB
testOp3(m64, .VPBLENDMB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 66 fc");
testOp3(m64, .VPBLENDMB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 66 fc");
testOp3(m64, .VPBLENDMB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 66 fc");
// VPBLENDMW
testOp3(m64, .VPBLENDMW, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 66 fc");
testOp3(m64, .VPBLENDMW, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 66 fc");
testOp3(m64, .VPBLENDMW, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 66 fc");
// VPBLENDMD / VPBLENDMQ
// VPBLENDMD
testOp3(m64, .VPBLENDMD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 64 fc");
testOp3(m64, .VPBLENDMD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 64 fc");
testOp3(m64, .VPBLENDMD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 64 fc");
// VPBLENDMQ
testOp3(m64, .VPBLENDMQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 64 fc");
testOp3(m64, .VPBLENDMQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 64 fc");
testOp3(m64, .VPBLENDMQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 64 fc");
}
{
// VPBROADCASTB / VPBROADCASTW / VPBROADCASTD / VPBROADCASTQ
// VPBROADCASTB
testOp2(m64, .VPBROADCASTB, reg(.XMM1), regRm(.XMM0), "c4 e2 79 78 c8");
testOp2(m64, .VPBROADCASTB, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 78 c8");
testOp2(m64, .VPBROADCASTB, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 78 fc");
testOp2(m64, .VPBROADCASTB, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 78 fc");
testOp2(m64, .VPBROADCASTB, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 78 fc");
testOp2(m64, .VPBROADCASTB, pred(.XMM31, .K7, .Zero), regRm(.AL), "62 62 7d 8f 7a f8");
testOp2(m64, .VPBROADCASTB, pred(.YMM31, .K7, .Zero), regRm(.AL), "62 62 7d af 7a f8");
testOp2(m64, .VPBROADCASTB, pred(.ZMM31, .K7, .Zero), regRm(.AL), "62 62 7d cf 7a f8");
// VPBROADCASTW
testOp2(m64, .VPBROADCASTW, reg(.XMM1), regRm(.XMM0), "c4 e2 79 79 c8");
testOp2(m64, .VPBROADCASTW, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 79 c8");
testOp2(m64, .VPBROADCASTW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 79 fc");
testOp2(m64, .VPBROADCASTW, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 79 fc");
testOp2(m64, .VPBROADCASTW, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 79 fc");
testOp2(m64, .VPBROADCASTW, pred(.XMM31, .K7, .Zero), regRm(.AX), "62 62 7d 8f 7b f8");
testOp2(m64, .VPBROADCASTW, pred(.YMM31, .K7, .Zero), regRm(.AX), "62 62 7d af 7b f8");
testOp2(m64, .VPBROADCASTW, pred(.ZMM31, .K7, .Zero), regRm(.AX), "62 62 7d cf 7b f8");
// VPBROADCASTD
testOp2(m64, .VPBROADCASTD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 58 c8");
testOp2(m64, .VPBROADCASTD, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 58 c8");
testOp2(m64, .VPBROADCASTD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 58 fc");
testOp2(m64, .VPBROADCASTD, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 58 fc");
testOp2(m64, .VPBROADCASTD, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 58 fc");
testOp2(m64, .VPBROADCASTD, pred(.XMM31, .K7, .Zero), regRm(.EAX), "62 62 7d 8f 7c f8");
testOp2(m64, .VPBROADCASTD, pred(.YMM31, .K7, .Zero), regRm(.EAX), "62 62 7d af 7c f8");
testOp2(m64, .VPBROADCASTD, pred(.ZMM31, .K7, .Zero), regRm(.EAX), "62 62 7d cf 7c f8");
// VPBROADCASTQ
testOp2(m64, .VPBROADCASTQ, reg(.XMM1), regRm(.XMM0), "c4 e2 79 59 c8");
testOp2(m64, .VPBROADCASTQ, reg(.YMM1), regRm(.XMM0), "c4 e2 7d 59 c8");
testOp2(m64, .VPBROADCASTQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 59 fc");
testOp2(m64, .VPBROADCASTQ, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd af 59 fc");
testOp2(m64, .VPBROADCASTQ, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd cf 59 fc");
testOp2(m64, .VPBROADCASTQ, pred(.XMM31, .K7, .Zero), regRm(.RAX), "62 62 fd 8f 7c f8");
testOp2(m64, .VPBROADCASTQ, pred(.YMM31, .K7, .Zero), regRm(.RAX), "62 62 fd af 7c f8");
testOp2(m64, .VPBROADCASTQ, pred(.ZMM31, .K7, .Zero), regRm(.RAX), "62 62 fd cf 7c f8");
// VPBROADCASTI32X2
testOp2(m64, .VPBROADCASTI32X2, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 59 fc");
testOp2(m64, .VPBROADCASTI32X2, pred(.YMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d af 59 fc");
testOp2(m64, .VPBROADCASTI32X2, pred(.ZMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d cf 59 fc");
// VPBROADCASTI128
testOp2(m64, .VPBROADCASTI128, reg(.YMM1), rm_mem128, "67 c4 e2 7d 5a 08");
// VPBROADCASTI32X4
testOp2(m64, .VPBROADCASTI32X4, pred(.YMM31, .K7, .Zero), rm_mem128, "67 62 62 7d af 5a 38");
testOp2(m64, .VPBROADCASTI32X4, pred(.ZMM31, .K7, .Zero), rm_mem128, "67 62 62 7d cf 5a 38");
// VPBROADCASTI64X2
testOp2(m64, .VPBROADCASTI64X2, pred(.YMM31, .K7, .Zero), rm_mem128, "67 62 62 fd af 5a 38");
testOp2(m64, .VPBROADCASTI64X2, pred(.ZMM31, .K7, .Zero), rm_mem128, "67 62 62 fd cf 5a 38");
// VPBROADCASTI32X8
testOp2(m64, .VPBROADCASTI32X8, pred(.ZMM31, .K7, .Zero), rm_mem256, "67 62 62 7d cf 5b 38");
// VPBROADCASTI64X4
testOp2(m64, .VPBROADCASTI64X4, pred(.ZMM31, .K7, .Zero), rm_mem256, "67 62 62 fd cf 5b 38");
// VPBROADCASTM
// VPBROADCASTMB2Q
testOp2(m64, .VPBROADCASTMB2Q, pred(.XMM31, .K7, .Zero), regRm(.K0), "62 62 fe 8f 2a f8");
testOp2(m64, .VPBROADCASTMB2Q, pred(.YMM31, .K7, .Zero), regRm(.K0), "62 62 fe af 2a f8");
testOp2(m64, .VPBROADCASTMB2Q, pred(.ZMM31, .K7, .Zero), regRm(.K0), "62 62 fe cf 2a f8");
// VPBROADCASTMW2D
testOp2(m64, .VPBROADCASTMW2D, pred(.XMM31, .K7, .Zero), regRm(.K0), "62 62 7e 8f 3a f8");
testOp2(m64, .VPBROADCASTMW2D, pred(.YMM31, .K7, .Zero), regRm(.K0), "62 62 7e af 3a f8");
testOp2(m64, .VPBROADCASTMW2D, pred(.ZMM31, .K7, .Zero), regRm(.K0), "62 62 7e cf 3a f8");
}
{
// VPCMPB / VPCMPUB
// VPCMPB
testOp4(m64, .VPCMPB, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 55 07 3f c4 00");
testOp4(m64, .VPCMPB, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 55 27 3f c4 00");
testOp4(m64, .VPCMPB, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 55 47 3f c4 00");
// VPCMPUB
testOp4(m64, .VPCMPUB, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 55 07 3e c4 00");
testOp4(m64, .VPCMPUB, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 55 27 3e c4 00");
testOp4(m64, .VPCMPUB, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 55 47 3e c4 00");
// VPCMPD / VPCMPUD
// VPCMPD
testOp4(m64, .VPCMPD, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 55 07 1f c4 00");
testOp4(m64, .VPCMPD, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 55 27 1f c4 00");
testOp4(m64, .VPCMPD, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 55 47 1f c4 00");
// VPCMPUD
testOp4(m64, .VPCMPUD, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 55 07 1e c4 00");
testOp4(m64, .VPCMPUD, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 55 27 1e c4 00");
testOp4(m64, .VPCMPUD, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 55 47 1e c4 00");
// VPCMPQ / VPCMPUQ
// VPCMPQ
testOp4(m64, .VPCMPQ, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 d5 07 1f c4 00");
testOp4(m64, .VPCMPQ, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 d5 27 1f c4 00");
testOp4(m64, .VPCMPQ, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 d5 47 1f c4 00");
// VPCMPUQ
testOp4(m64, .VPCMPUQ, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 d5 07 1e c4 00");
testOp4(m64, .VPCMPUQ, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 d5 27 1e c4 00");
testOp4(m64, .VPCMPUQ, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 d5 47 1e c4 00");
// VPCMPW / VPCMPUW
// VPCMPW
testOp4(m64, .VPCMPW, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 d5 07 3f c4 00");
testOp4(m64, .VPCMPW, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 d5 27 3f c4 00");
testOp4(m64, .VPCMPW, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 d5 47 3f c4 00");
// VPCMPUW
testOp4(m64, .VPCMPUW, pred(.K0, .K7, .Merge),reg(.XMM21),regRm(.XMM20),imm(0), "62 b3 d5 07 3e c4 00");
testOp4(m64, .VPCMPUW, pred(.K0, .K7, .Merge),reg(.YMM21),regRm(.YMM20),imm(0), "62 b3 d5 27 3e c4 00");
testOp4(m64, .VPCMPUW, pred(.K0, .K7, .Merge),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 b3 d5 47 3e c4 00");
}
{
// VPCOMPRESSB / VPCOMPRESSW
// VPCOMPRESSB
testOp2(m64, .VPCOMPRESSB, predRm(rm_mem128, .K7, .Merge), reg(.XMM21), "67 62 e2 7d 0f 63 28");
testOp2(m64, .VPCOMPRESSB, predRm(reg(.XMM20), .K7, .Zero), reg(.XMM21), "62 a2 7d 8f 63 ec");
testOp2(m64, .VPCOMPRESSB, predRm(rm_mem256, .K7, .Merge), reg(.YMM21), "67 62 e2 7d 2f 63 28");
testOp2(m64, .VPCOMPRESSB, predRm(reg(.YMM20), .K7, .Zero), reg(.YMM21), "62 a2 7d af 63 ec");
testOp2(m64, .VPCOMPRESSB, predRm(rm_mem512, .K7, .Merge), reg(.ZMM21), "67 62 e2 7d 4f 63 28");
testOp2(m64, .VPCOMPRESSB, predRm(reg(.ZMM20), .K7, .Zero), reg(.ZMM21), "62 a2 7d cf 63 ec");
// VPCOMPRESSW
testOp2(m64, .VPCOMPRESSW, predRm(rm_mem128, .K7, .Merge), reg(.XMM21), "67 62 e2 fd 0f 63 28");
testOp2(m64, .VPCOMPRESSW, predRm(reg(.XMM20), .K7, .Zero), reg(.XMM21), "62 a2 fd 8f 63 ec");
testOp2(m64, .VPCOMPRESSW, predRm(rm_mem256, .K7, .Merge), reg(.YMM21), "67 62 e2 fd 2f 63 28");
testOp2(m64, .VPCOMPRESSW, predRm(reg(.YMM20), .K7, .Zero), reg(.YMM21), "62 a2 fd af 63 ec");
testOp2(m64, .VPCOMPRESSW, predRm(rm_mem512, .K7, .Merge), reg(.ZMM21), "67 62 e2 fd 4f 63 28");
testOp2(m64, .VPCOMPRESSW, predRm(reg(.ZMM20), .K7, .Zero), reg(.ZMM21), "62 a2 fd cf 63 ec");
// VPCOMPRESSD
testOp2(m64, .VPCOMPRESSD, regRm(.XMM20), reg(.XMM21), "62 a2 7d 08 8b ec");
testOp2(m64, .VPCOMPRESSD, regRm(.YMM20), reg(.YMM21), "62 a2 7d 28 8b ec");
testOp2(m64, .VPCOMPRESSD, regRm(.ZMM20), reg(.ZMM21), "62 a2 7d 48 8b ec");
// VPCOMPRESSQ
testOp2(m64, .VPCOMPRESSQ, regRm(.XMM20), reg(.XMM21), "62 a2 fd 08 8b ec");
testOp2(m64, .VPCOMPRESSQ, regRm(.YMM20), reg(.YMM21), "62 a2 fd 28 8b ec");
testOp2(m64, .VPCOMPRESSQ, regRm(.ZMM20), reg(.ZMM21), "62 a2 fd 48 8b ec");
}
{
// VPCONFLICTD / VPCONFLICTQ
// VPCONFLICTD
testOp2(m64, .VPCONFLICTD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f c4 fc");
testOp2(m64, .VPCONFLICTD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af c4 fc");
testOp2(m64, .VPCONFLICTD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf c4 fc");
// VPCONFLICTQ
testOp2(m64, .VPCONFLICTQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f c4 fc");
testOp2(m64, .VPCONFLICTQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af c4 fc");
testOp2(m64, .VPCONFLICTQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf c4 fc");
}
{
// VPDPBUSD
testOp3(m64, .VPDPBUSD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 50 fc");
testOp3(m64, .VPDPBUSD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 50 fc");
testOp3(m64, .VPDPBUSD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 50 fc");
// VPDPBUSDS
testOp3(m64, .VPDPBUSDS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 51 fc");
testOp3(m64, .VPDPBUSDS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 51 fc");
testOp3(m64, .VPDPBUSDS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 51 fc");
// VPDPWSSD
testOp3(m64, .VPDPWSSD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 52 fc");
testOp3(m64, .VPDPWSSD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 52 fc");
testOp3(m64, .VPDPWSSD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 52 fc");
// VPDPWSSDS
testOp3(m64, .VPDPWSSDS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 53 fc");
testOp3(m64, .VPDPWSSDS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 53 fc");
testOp3(m64, .VPDPWSSDS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 53 fc");
}
{
// VPERM2F128
testOp4(m64, .VPERM2F128, reg(.YMM1),reg(.YMM2),regRm(.YMM0),imm(0), "c4 e3 6d 06 c8 00");
// VPERM2I128
testOp4(m64, .VPERM2I128, reg(.YMM1),reg(.YMM2),regRm(.YMM0),imm(0), "c4 e3 6d 46 c8 00");
// VPERMB
testOp3(m64, .VPERMB, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 8d fc");
testOp3(m64, .VPERMB, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 8d fc");
testOp3(m64, .VPERMB, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 8d fc");
// VPERMD / VPERMW
// VPERMD
testOp3(m64, .VPERMD, reg(.YMM1),reg(.YMM2),regRm(.YMM0), "c4 e2 6d 36 c8");
testOp3(m64, .VPERMD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 36 fc");
testOp3(m64, .VPERMD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 36 fc");
// VPERMW
testOp3(m64, .VPERMW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 8d fc");
testOp3(m64, .VPERMW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 8d fc");
testOp3(m64, .VPERMW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 8d fc");
}
{
// VPERMI2B
testOp3(m64, .VPERMI2B, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 75 fc");
testOp3(m64, .VPERMI2B, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 75 fc");
testOp3(m64, .VPERMI2B, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 75 fc");
// VPERMI2W / VPERMI2D / VPERMI2Q / VPERMI2PS / VPERMI2PD
// VPERMI2W
testOp3(m64, .VPERMI2W, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 75 fc");
testOp3(m64, .VPERMI2W, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 75 fc");
testOp3(m64, .VPERMI2W, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 75 fc");
// VPERMI2D
testOp3(m64, .VPERMI2D, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 76 fc");
testOp3(m64, .VPERMI2D, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 76 fc");
testOp3(m64, .VPERMI2D, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 76 fc");
// VPERMI2Q
testOp3(m64, .VPERMI2Q, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 76 fc");
testOp3(m64, .VPERMI2Q, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 76 fc");
testOp3(m64, .VPERMI2Q, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 76 fc");
// VPERMI2PS
testOp3(m64, .VPERMI2PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 77 fc");
testOp3(m64, .VPERMI2PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 77 fc");
testOp3(m64, .VPERMI2PS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 77 fc");
// VPERMI2PD
testOp3(m64, .VPERMI2PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 77 fc");
testOp3(m64, .VPERMI2PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 77 fc");
testOp3(m64, .VPERMI2PD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 77 fc");
}
{
// VPERMILPD
testOp3(m64, .VPERMILPD, reg(.XMM1),reg(.XMM2),regRm(.XMM0), "c4 e2 69 0d c8");
testOp3(m64, .VPERMILPD, reg(.YMM1),reg(.YMM2),regRm(.YMM0), "c4 e2 6d 0d c8");
testOp3(m64, .VPERMILPD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 0d fc");
testOp3(m64, .VPERMILPD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 0d fc");
testOp3(m64, .VPERMILPD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 0d fc");
testOp3(m64, .VPERMILPD, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 05 c8 00");
testOp3(m64, .VPERMILPD, reg(.YMM1),regRm(.YMM0),imm(0), "c4 e3 7d 05 c8 00");
testOp3(m64, .VPERMILPD, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 fd 8f 05 fc 00");
testOp3(m64, .VPERMILPD, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 05 fc 00");
testOp3(m64, .VPERMILPD, pred(.ZMM31, .K7, .Zero),regRm(.ZMM20),imm(0), "62 23 fd cf 05 fc 00");
// VPERMILPS
testOp3(m64, .VPERMILPS, reg(.XMM1),reg(.XMM2),regRm(.XMM0), "c4 e2 69 0c c8");
testOp3(m64, .VPERMILPS, reg(.YMM1),reg(.YMM2),regRm(.YMM0), "c4 e2 6d 0c c8");
testOp3(m64, .VPERMILPS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 0c fc");
testOp3(m64, .VPERMILPS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 0c fc");
testOp3(m64, .VPERMILPS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 0c fc");
testOp3(m64, .VPERMILPS, reg(.XMM1),regRm(.XMM0),imm(0), "c4 e3 79 04 c8 00");
testOp3(m64, .VPERMILPS, reg(.YMM1),regRm(.YMM0),imm(0), "c4 e3 7d 04 c8 00");
testOp3(m64, .VPERMILPS, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 7d 8f 04 fc 00");
testOp3(m64, .VPERMILPS, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 7d af 04 fc 00");
testOp3(m64, .VPERMILPS, pred(.ZMM31, .K7, .Zero),regRm(.ZMM20),imm(0), "62 23 7d cf 04 fc 00");
// VPERMPD
testOp3(m64, .VPERMPD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 16 fc");
testOp3(m64, .VPERMPD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 16 fc");
testOp3(m64, .VPERMPD, reg(.YMM1),regRm(.YMM0),imm(0), "c4 e3 fd 01 c8 00");
testOp3(m64, .VPERMPD, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 01 fc 00");
testOp3(m64, .VPERMPD, pred(.ZMM31, .K7, .Zero),regRm(.ZMM20),imm(0), "62 23 fd cf 01 fc 00");
// VPERMPS
testOp3(m64, .VPERMPS, reg(.YMM1),reg(.YMM2),regRm(.YMM0), "c4 e2 6d 16 c8");
testOp3(m64, .VPERMPS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 16 fc");
testOp3(m64, .VPERMPS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 16 fc");
// VPERMQ
testOp3(m64, .VPERMQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 36 fc");
testOp3(m64, .VPERMQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 36 fc");
testOp3(m64, .VPERMQ, reg(.YMM1),regRm(.YMM0),imm(0), "c4 e3 fd 00 c8 00");
testOp3(m64, .VPERMQ, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 00 fc 00");
testOp3(m64, .VPERMQ, pred(.ZMM31, .K7, .Zero),regRm(.ZMM20),imm(0), "62 23 fd cf 00 fc 00");
}
{
// VPERMT2B
testOp3(m64, .VPERMT2B, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 7d fc");
testOp3(m64, .VPERMT2B, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 7d fc");
testOp3(m64, .VPERMT2B, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 7d fc");
// VPERMT2W / VPERMT2D / VPERMT2Q / VPERMT2PS / VPERMT2PD
// VPERMT2W
testOp3(m64, .VPERMT2W, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 7d fc");
testOp3(m64, .VPERMT2W, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 7d fc");
testOp3(m64, .VPERMT2W, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 7d fc");
// VPERMT2D
testOp3(m64, .VPERMT2D, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 7e fc");
testOp3(m64, .VPERMT2D, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 7e fc");
testOp3(m64, .VPERMT2D, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 7e fc");
// VPERMT2Q
testOp3(m64, .VPERMT2Q, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 7e fc");
testOp3(m64, .VPERMT2Q, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 7e fc");
testOp3(m64, .VPERMT2Q, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 7e fc");
// VPERMT2PS
testOp3(m64, .VPERMT2PS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 7f fc");
testOp3(m64, .VPERMT2PS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 7f fc");
testOp3(m64, .VPERMT2PS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 7f fc");
// VPERMT2PD
testOp3(m64, .VPERMT2PD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 7f fc");
testOp3(m64, .VPERMT2PD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 7f fc");
testOp3(m64, .VPERMT2PD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 7f fc");
}
{
// VPEXPANDB / VPEXPANDW
// VPEXPANDB
testOp2(m64, .VPEXPANDB, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62227d8f62fc");
testOp2(m64, .VPEXPANDB, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62227daf62fc");
testOp2(m64, .VPEXPANDB, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62227dcf62fc");
// VPEXPANDW
testOp2(m64, .VPEXPANDW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "6222fd8f62fc");
testOp2(m64, .VPEXPANDW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "6222fdaf62fc");
testOp2(m64, .VPEXPANDW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "6222fdcf62fc");
// VPEXPANDD
testOp2(m64, .VPEXPANDD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62227d8f89fc");
testOp2(m64, .VPEXPANDD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62227daf89fc");
testOp2(m64, .VPEXPANDD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62227dcf89fc");
// VPEXPANDQ
testOp2(m64, .VPEXPANDQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "6222fd8f89fc");
testOp2(m64, .VPEXPANDQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "6222fdaf89fc");
testOp2(m64, .VPEXPANDQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "6222fdcf89fc");
}
{
// VPGATHERDD / VPGATHERQD / VPGATHERDQ / VPGATHERQQ
// VPGATHERDD
testOp3(m64, .VPGATHERDD, reg(.XMM1), vm32xl, reg(.XMM2), "67 c4 e2 69 90 0c f8");
testOp3(m64, .VPGATHERDD, reg(.YMM1), vm32yl, reg(.YMM2), "67 c4 e2 6d 90 0c f8");
testOp2(m64, .VPGATHERDD, pred(.XMM31, .K7, .Merge), vm32x, "67 62 22 7d 07 90 3c f0");
testOp2(m64, .VPGATHERDD, pred(.YMM31, .K7, .Merge), vm32y, "67 62 22 7d 27 90 3c f0");
testOp2(m64, .VPGATHERDD, pred(.ZMM31, .K7, .Merge), vm32z, "67 62 22 7d 47 90 3c f0");
// VPGATHERDQ
testOp3(m64, .VPGATHERDQ, reg(.XMM1), vm32xl, reg(.XMM2), "67 c4 e2 e9 90 0c f8");
testOp3(m64, .VPGATHERDQ, reg(.YMM1), vm32xl, reg(.YMM2), "67 c4 e2 ed 90 0c f8");
testOp2(m64, .VPGATHERDQ, pred(.XMM31, .K7, .Merge), vm32x, "67 62 22 fd 07 90 3c f0");
testOp2(m64, .VPGATHERDQ, pred(.YMM31, .K7, .Merge), vm32x, "67 62 22 fd 27 90 3c f0");
testOp2(m64, .VPGATHERDQ, pred(.ZMM31, .K7, .Merge), vm32y, "67 62 22 fd 47 90 3c f0");
// VPGATHERQD
testOp3(m64, .VPGATHERQD, reg(.XMM1), vm64xl, reg(.XMM2), "67 c4 e2 69 91 0c f8");
testOp3(m64, .VPGATHERQD, reg(.XMM1), vm64yl, reg(.XMM2), "67 c4 e2 6d 91 0c f8");
testOp2(m64, .VPGATHERQD, pred(.XMM31, .K7, .Merge), vm64x, "67 62 22 7d 07 91 3c f0");
testOp2(m64, .VPGATHERQD, pred(.XMM31, .K7, .Merge), vm64y, "67 62 22 7d 27 91 3c f0");
testOp2(m64, .VPGATHERQD, pred(.YMM31, .K7, .Merge), vm64z, "67 62 22 7d 47 91 3c f0");
// VPGATHERQQ
testOp3(m64, .VPGATHERQQ, reg(.XMM1), vm64xl, reg(.XMM2), "67 c4 e2 e9 91 0c f8");
testOp3(m64, .VPGATHERQQ, reg(.YMM1), vm64yl, reg(.YMM2), "67 c4 e2 ed 91 0c f8");
testOp2(m64, .VPGATHERQQ, pred(.XMM31, .K7, .Merge), vm64x, "67 62 22 fd 07 91 3c f0");
testOp2(m64, .VPGATHERQQ, pred(.YMM31, .K7, .Merge), vm64y, "67 62 22 fd 27 91 3c f0");
testOp2(m64, .VPGATHERQQ, pred(.ZMM31, .K7, .Merge), vm64z, "67 62 22 fd 47 91 3c f0");
}
{
// VPLZCNTD / VPLZCNTQ
// VPLZCNTD
testOp2(m64, .VPLZCNTD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 44 fc");
testOp2(m64, .VPLZCNTD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 44 fc");
testOp2(m64, .VPLZCNTD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 44 fc");
// VPLZCNTQ
testOp2(m64, .VPLZCNTQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 44 fc");
testOp2(m64, .VPLZCNTQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 44 fc");
testOp2(m64, .VPLZCNTQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 44 fc");
}
{
// VPMADD52HUQ
testOp3(m64, .VPMADD52HUQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 b5 fc");
testOp3(m64, .VPMADD52HUQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 b5 fc");
testOp3(m64, .VPMADD52HUQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 b5 fc");
// VPMADD52LUQ
testOp3(m64, .VPMADD52LUQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 b4 fc");
testOp3(m64, .VPMADD52LUQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 b4 fc");
testOp3(m64, .VPMADD52LUQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 b4 fc");
}
{
// VPMASKMOV
// VMASKMOVD
testOp3(m64, .VMASKMOVD, reg(.XMM1), reg(.XMM2), rm_mem128, "67 c4 e2 69 8c 08");
testOp3(m64, .VMASKMOVD, reg(.YMM1), reg(.YMM2), rm_mem256, "67 c4 e2 6d 8c 08");
testOp3(m64, .VMASKMOVD, rm_mem128, reg(.XMM1), reg(.XMM2), "67 c4 e2 71 8e 10");
testOp3(m64, .VMASKMOVD, rm_mem256, reg(.YMM1), reg(.YMM2), "67 c4 e2 75 8e 10");
// VMASKMOVQ
testOp3(m64, .VMASKMOVQ, reg(.XMM1), reg(.XMM2), rm_mem128, "67 c4 e2 e9 8c 08");
testOp3(m64, .VMASKMOVQ, reg(.YMM1), reg(.YMM2), rm_mem256, "67 c4 e2 ed 8c 08");
testOp3(m64, .VMASKMOVQ, rm_mem128, reg(.XMM1), reg(.XMM2), "67 c4 e2 f1 8e 10");
testOp3(m64, .VMASKMOVQ, rm_mem256, reg(.YMM1), reg(.YMM2), "67 c4 e2 f5 8e 10");
}
{
// VPMOVB2M / VPMOVW2M / VPMOVD2M / VPMOVQ2M
// VPMOVB2M
testOp2(m64, .VPMOVB2M, reg(.K0), regRm(.XMM20), "62 b2 7e 08 29 c4");
testOp2(m64, .VPMOVB2M, reg(.K0), regRm(.YMM20), "62 b2 7e 28 29 c4");
testOp2(m64, .VPMOVB2M, reg(.K0), regRm(.ZMM20), "62 b2 7e 48 29 c4");
// VPMOVW2M
testOp2(m64, .VPMOVW2M, reg(.K0), regRm(.XMM20), "62 b2 fe 08 29 c4");
testOp2(m64, .VPMOVW2M, reg(.K0), regRm(.YMM20), "62 b2 fe 28 29 c4");
testOp2(m64, .VPMOVW2M, reg(.K0), regRm(.ZMM20), "62 b2 fe 48 29 c4");
// VPMOVD2M
testOp2(m64, .VPMOVD2M, reg(.K0), regRm(.XMM20), "62 b2 7e 08 39 c4");
testOp2(m64, .VPMOVD2M, reg(.K0), regRm(.YMM20), "62 b2 7e 28 39 c4");
testOp2(m64, .VPMOVD2M, reg(.K0), regRm(.ZMM20), "62 b2 7e 48 39 c4");
// VPMOVQ2M
testOp2(m64, .VPMOVQ2M, reg(.K0), regRm(.XMM20), "62 b2 fe 08 39 c4");
testOp2(m64, .VPMOVQ2M, reg(.K0), regRm(.YMM20), "62 b2 fe 28 39 c4");
testOp2(m64, .VPMOVQ2M, reg(.K0), regRm(.ZMM20), "62 b2 fe 48 39 c4");
}
{
// VPMOVDB / VPMOVSDB / VPMOVUSDB
// VPMOVDB
testOp2(m64, .VPMOVDB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 31 ec");
testOp2(m64, .VPMOVDB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 31 ec");
testOp2(m64, .VPMOVDB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 31 ec");
// VPMOVSDB
testOp2(m64, .VPMOVSDB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 21 ec");
testOp2(m64, .VPMOVSDB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 21 ec");
testOp2(m64, .VPMOVSDB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 21 ec");
// VPMOVUSDB
testOp2(m64, .VPMOVUSDB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 11 ec");
testOp2(m64, .VPMOVUSDB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 11 ec");
testOp2(m64, .VPMOVUSDB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 11 ec");
}
{
// VPMOVDW / VPMOVSDB / VPMOVUSDB
// VPMOVDW
testOp2(m64, .VPMOVDW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 33 ec");
testOp2(m64, .VPMOVDW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 33 ec");
testOp2(m64, .VPMOVDW, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 33 ec");
// VPMOVSDB
testOp2(m64, .VPMOVSDW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 23 ec");
testOp2(m64, .VPMOVSDW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 23 ec");
testOp2(m64, .VPMOVSDW, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 23 ec");
// VPMOVUSDB
testOp2(m64, .VPMOVUSDW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 13 ec");
testOp2(m64, .VPMOVUSDW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 13 ec");
testOp2(m64, .VPMOVUSDW, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 13 ec");
}
{
// VPMOVM2B / VPMOVM2W / VPMOVM2D / VPMOVM2Q
// VPMOVM2B
testOp2(m64, .VPMOVM2B, reg(.XMM21), regRm(.K0), "62 e2 7e 08 28 e8");
testOp2(m64, .VPMOVM2B, reg(.YMM21), regRm(.K0), "62 e2 7e 28 28 e8");
testOp2(m64, .VPMOVM2B, reg(.ZMM21), regRm(.K0), "62 e2 7e 48 28 e8");
// VPMOVM2W
testOp2(m64, .VPMOVM2W, reg(.XMM21), regRm(.K0), "62 e2 fe 08 28 e8");
testOp2(m64, .VPMOVM2W, reg(.YMM21), regRm(.K0), "62 e2 fe 28 28 e8");
testOp2(m64, .VPMOVM2W, reg(.ZMM21), regRm(.K0), "62 e2 fe 48 28 e8");
// VPMOVM2D
testOp2(m64, .VPMOVM2D, reg(.XMM21), regRm(.K0), "62 e2 7e 08 38 e8");
testOp2(m64, .VPMOVM2D, reg(.YMM21), regRm(.K0), "62 e2 7e 28 38 e8");
testOp2(m64, .VPMOVM2D, reg(.ZMM21), regRm(.K0), "62 e2 7e 48 38 e8");
// VPMOVM2Q
testOp2(m64, .VPMOVM2Q, reg(.XMM21), regRm(.K0), "62 e2 fe 08 38 e8");
testOp2(m64, .VPMOVM2Q, reg(.YMM21), regRm(.K0), "62 e2 fe 28 38 e8");
testOp2(m64, .VPMOVM2Q, reg(.ZMM21), regRm(.K0), "62 e2 fe 48 38 e8");
}
{
// VPMOVQB / VPMOVSQB / VPMOVUSQB
// VPMOVQB
testOp2(m64, .VPMOVQB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 32 ec");
testOp2(m64, .VPMOVQB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 32 ec");
testOp2(m64, .VPMOVQB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 32 ec");
// VPMOVSQB
testOp2(m64, .VPMOVSQB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 22 ec");
testOp2(m64, .VPMOVSQB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 22 ec");
testOp2(m64, .VPMOVSQB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 22 ec");
// VPMOVUSQB
testOp2(m64, .VPMOVUSQB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 12 ec");
testOp2(m64, .VPMOVUSQB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 12 ec");
testOp2(m64, .VPMOVUSQB, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 12 ec");
}
{
// VPMOVQD / VPMOVSQD / VPMOVUSQD
// VPMOVQD
testOp2(m64, .VPMOVQD, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 35 ec");
testOp2(m64, .VPMOVQD, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 35 ec");
testOp2(m64, .VPMOVQD, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 35 ec");
// VPMOVSQD
testOp2(m64, .VPMOVSQD, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 25 ec");
testOp2(m64, .VPMOVSQD, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 25 ec");
testOp2(m64, .VPMOVSQD, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 25 ec");
// VPMOVUSQD
testOp2(m64, .VPMOVUSQD, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 15 ec");
testOp2(m64, .VPMOVUSQD, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 15 ec");
testOp2(m64, .VPMOVUSQD, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 15 ec");
// VPMOVQD / VPMOVSQD / VPMOVUSQD
// VPMOVQD
testOp2(m64, .VPMOVQD, predRm(rm_mem64, .K7, .Zero), reg(.XMM21), "67 62 e2 7e 8f 35 28");
testOp2(m64, .VPMOVQD, predRm(rm_mem128, .K7, .Zero), reg(.YMM21), "67 62 e2 7e af 35 28");
testOp2(m64, .VPMOVQD, predRm(rm_mem256, .K7, .Zero), reg(.ZMM21), "67 62 e2 7e cf 35 28");
// VPMOVSQD
testOp2(m64, .VPMOVSQD, predRm(rm_mem64, .K7, .Zero), reg(.XMM21), "67 62 e2 7e 8f 25 28");
testOp2(m64, .VPMOVSQD, predRm(rm_mem128, .K7, .Zero), reg(.YMM21), "67 62 e2 7e af 25 28");
testOp2(m64, .VPMOVSQD, predRm(rm_mem256, .K7, .Zero), reg(.ZMM21), "67 62 e2 7e cf 25 28");
// VPMOVUSQD
testOp2(m64, .VPMOVUSQD, predRm(rm_mem64, .K7, .Zero), reg(.XMM21), "67 62 e2 7e 8f 15 28");
testOp2(m64, .VPMOVUSQD, predRm(rm_mem128, .K7, .Zero), reg(.YMM21), "67 62 e2 7e af 15 28");
testOp2(m64, .VPMOVUSQD, predRm(rm_mem256, .K7, .Zero), reg(.ZMM21), "67 62 e2 7e cf 15 28");
}
{
// VPMOVQW / VPMOVSQW / VPMOVUSQW
// VPMOVQW
testOp2(m64, .VPMOVQW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 34 ec");
testOp2(m64, .VPMOVQW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 34 ec");
testOp2(m64, .VPMOVQW, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 34 ec");
// VPMOVSQW
testOp2(m64, .VPMOVSQW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 24 ec");
testOp2(m64, .VPMOVSQW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 24 ec");
testOp2(m64, .VPMOVSQW, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 24 ec");
// VPMOVUSQW
testOp2(m64, .VPMOVUSQW, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 14 ec");
testOp2(m64, .VPMOVUSQW, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 14 ec");
testOp2(m64, .VPMOVUSQW, regRm(.XMM20), reg(.ZMM21), "62 a2 7e 48 14 ec");
}
{
// VPMOVWB / VPMOVSWB / VPMOVUSWB
// VPMOVWB
testOp2(m64, .VPMOVWB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 30 ec");
testOp2(m64, .VPMOVWB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 30 ec");
testOp2(m64, .VPMOVWB, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 30 ec");
// VPMOVSWB
testOp2(m64, .VPMOVSWB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 20 ec");
testOp2(m64, .VPMOVSWB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 20 ec");
testOp2(m64, .VPMOVSWB, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 20 ec");
// VPMOVUSWB
testOp2(m64, .VPMOVUSWB, regRm(.XMM20), reg(.XMM21), "62 a2 7e 08 10 ec");
testOp2(m64, .VPMOVUSWB, regRm(.XMM20), reg(.YMM21), "62 a2 7e 28 10 ec");
testOp2(m64, .VPMOVUSWB, regRm(.YMM20), reg(.ZMM21), "62 a2 7e 48 10 ec");
}
{
// VPMULTISHIFTQB
testOp3(m64, .VPMULTISHIFTQB, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 83 fc");
testOp3(m64, .VPMULTISHIFTQB, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 83 fc");
testOp3(m64, .VPMULTISHIFTQB, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 83 fc");
}
{
// VPOPCNT
// VPOPCNTB
testOp2(m64, .VPOPCNTB, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 54 fc");
testOp2(m64, .VPOPCNTB, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 54 fc");
testOp2(m64, .VPOPCNTB, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 54 fc");
// VPOPCNTW
testOp2(m64, .VPOPCNTW, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 54 fc");
testOp2(m64, .VPOPCNTW, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 54 fc");
testOp2(m64, .VPOPCNTW, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 54 fc");
// VPOPCNTD
testOp2(m64, .VPOPCNTD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 55 fc");
testOp2(m64, .VPOPCNTD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 55 fc");
testOp2(m64, .VPOPCNTD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 55 fc");
// VPOPCNTQ
testOp2(m64, .VPOPCNTQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 55 fc");
testOp2(m64, .VPOPCNTQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 55 fc");
testOp2(m64, .VPOPCNTQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 55 fc");
}
{
// VPROLD / VPROLVD / VPROLQ / VPROLVQ
// VPROLD
testOp3(m64, .VPROLD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 72 cc 00");
testOp3(m64, .VPROLD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 72 cc 00");
testOp3(m64, .VPROLD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 72 cc 00");
// VPROLVD
testOp3(m64, .VPROLVD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 15 fc");
testOp3(m64, .VPROLVD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 15 fc");
testOp3(m64, .VPROLVD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 15 fc");
// VPROLQ
testOp3(m64, .VPROLQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 85 87 72 cc 00");
testOp3(m64, .VPROLQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 85 a7 72 cc 00");
testOp3(m64, .VPROLQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 85 c7 72 cc 00");
// VPROLVQ
testOp3(m64, .VPROLVQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 15 fc");
testOp3(m64, .VPROLVQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 15 fc");
testOp3(m64, .VPROLVQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 15 fc");
}
{
// VPRORD / VPRORVD / VPRORQ / VPRORVQ
// VPRORD
testOp3(m64, .VPRORD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 05 87 72 c4 00");
testOp3(m64, .VPRORD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 05 a7 72 c4 00");
testOp3(m64, .VPRORD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 05 c7 72 c4 00");
// VPRORVD
testOp3(m64, .VPRORVD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 55 87 14 fc");
testOp3(m64, .VPRORVD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 55 a7 14 fc");
testOp3(m64, .VPRORVD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 55 c7 14 fc");
// VPRORQ
testOp3(m64, .VPRORQ, pred(.XMM31, .K7, .Zero), regRm(.XMM20), imm(0), "62 b1 85 87 72 c4 00");
testOp3(m64, .VPRORQ, pred(.YMM31, .K7, .Zero), regRm(.YMM20), imm(0), "62 b1 85 a7 72 c4 00");
testOp3(m64, .VPRORQ, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), imm(0), "62 b1 85 c7 72 c4 00");
// VPRORVQ
testOp3(m64, .VPRORVQ, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 22 d5 87 14 fc");
testOp3(m64, .VPRORVQ, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 22 d5 a7 14 fc");
testOp3(m64, .VPRORVQ, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 22 d5 c7 14 fc");
}
{
// VPSCATTERDD / VPSCATTERDQ / VPSCATTERQD / VPSCATTERQQ
// VPSCATTERDD
testOp2(m64, .VPSCATTERDD, predRm(vm32x, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 07 a0 2c f0");
testOp2(m64, .VPSCATTERDD, predRm(vm32y, .K7, .Merge), reg(.YMM21), "67 62 a2 7d 27 a0 2c f0");
testOp2(m64, .VPSCATTERDD, predRm(vm32z, .K7, .Merge), reg(.ZMM21), "67 62 a2 7d 47 a0 2c f0");
// VPSCATTERDQ
testOp2(m64, .VPSCATTERDQ, predRm(vm32x, .K7, .Merge), reg(.XMM21), "67 62 a2 fd 07 a0 2c f0");
testOp2(m64, .VPSCATTERDQ, predRm(vm32x, .K7, .Merge), reg(.YMM21), "67 62 a2 fd 27 a0 2c f0");
testOp2(m64, .VPSCATTERDQ, predRm(vm32y, .K7, .Merge), reg(.ZMM21), "67 62 a2 fd 47 a0 2c f0");
// VPSCATTERQD
testOp2(m64, .VPSCATTERQD, predRm(vm64x, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 07 a1 2c f0");
testOp2(m64, .VPSCATTERQD, predRm(vm64y, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 27 a1 2c f0");
testOp2(m64, .VPSCATTERQD, predRm(vm64z, .K7, .Merge), reg(.YMM21), "67 62 a2 7d 47 a1 2c f0");
// VPSCATTERQQ
testOp2(m64, .VPSCATTERQQ, predRm(vm64x, .K7, .Merge), reg(.XMM21), "67 62 a2 fd 07 a1 2c f0");
testOp2(m64, .VPSCATTERQQ, predRm(vm64y, .K7, .Merge), reg(.YMM21), "67 62 a2 fd 27 a1 2c f0");
testOp2(m64, .VPSCATTERQQ, predRm(vm64z, .K7, .Merge), reg(.ZMM21), "67 62 a2 fd 47 a1 2c f0");
}
{
// VPSHLD
// VPSHLDW
testOp4(m64, .VPSHLDW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 70 fc 00");
testOp4(m64, .VPSHLDW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 70 fc 00");
testOp4(m64, .VPSHLDW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 70 fc 00");
// VPSHLDD
testOp4(m64, .VPSHLDD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 71 fc 00");
testOp4(m64, .VPSHLDD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 71 fc 00");
testOp4(m64, .VPSHLDD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 71 fc 00");
// VPSHLDQ
testOp4(m64, .VPSHLDQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 71 fc 00");
testOp4(m64, .VPSHLDQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 71 fc 00");
testOp4(m64, .VPSHLDQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 71 fc 00");
// VPSHLDV
// VPSHLDVW
testOp3(m64, .VPSHLDVW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 70 fc");
testOp3(m64, .VPSHLDVW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 70 fc");
testOp3(m64, .VPSHLDVW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 70 fc");
// VPSHLDVD
testOp3(m64, .VPSHLDVD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 71 fc");
testOp3(m64, .VPSHLDVD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 71 fc");
testOp3(m64, .VPSHLDVD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 71 fc");
// VPSHLDVQ
testOp3(m64, .VPSHLDVQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 71 fc");
testOp3(m64, .VPSHLDVQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 71 fc");
testOp3(m64, .VPSHLDVQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 71 fc");
}
{
// VPSHRD
// VPSHRDW
testOp4(m64, .VPSHRDW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 72 fc 00");
testOp4(m64, .VPSHRDW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 72 fc 00");
testOp4(m64, .VPSHRDW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 72 fc 00");
// VPSHRDD
testOp4(m64, .VPSHRDD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 73 fc 00");
testOp4(m64, .VPSHRDD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 73 fc 00");
testOp4(m64, .VPSHRDD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 73 fc 00");
// VPSHRDQ
testOp4(m64, .VPSHRDQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 73 fc 00");
testOp4(m64, .VPSHRDQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 73 fc 00");
testOp4(m64, .VPSHRDQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 73 fc 00");
// VPSHRDV
// VPSHRDVW
testOp3(m64, .VPSHRDVW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 72 fc");
testOp3(m64, .VPSHRDVW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 72 fc");
testOp3(m64, .VPSHRDVW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 72 fc");
// VPSHRDVD
testOp3(m64, .VPSHRDVD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 73 fc");
testOp3(m64, .VPSHRDVD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 73 fc");
testOp3(m64, .VPSHRDVD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 73 fc");
// VPSHRDVQ
testOp3(m64, .VPSHRDVQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 73 fc");
testOp3(m64, .VPSHRDVQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 73 fc");
testOp3(m64, .VPSHRDVQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 73 fc");
}
{
// VPSHUFBITQMB
testOp3(m64, .VPSHUFBITQMB, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 55 07 8f c4");
testOp3(m64, .VPSHUFBITQMB, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 55 27 8f c4");
testOp3(m64, .VPSHUFBITQMB, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 55 47 8f c4");
}
{
// VPSLLVW / VPSLLVD / VPSLLVQ
// VPSLLVW
testOp3(m64, .VPSLLVW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 12 fc");
testOp3(m64, .VPSLLVW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 12 fc");
testOp3(m64, .VPSLLVW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 12 fc");
// VPSLLVD
testOp3(m64, .VPSLLVD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 47 c8");
testOp3(m64, .VPSLLVD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 47 c8");
testOp3(m64, .VPSLLVD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 47 fc");
testOp3(m64, .VPSLLVD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 47 fc");
testOp3(m64, .VPSLLVD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 47 fc");
// VPSLLVQ
testOp3(m64, .VPSLLVQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 47 c8");
testOp3(m64, .VPSLLVQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 47 c8");
testOp3(m64, .VPSLLVQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 47 fc");
testOp3(m64, .VPSLLVQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 47 fc");
testOp3(m64, .VPSLLVQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 47 fc");
}
{
// VPSRAVW / VPSRAVD / VPSRAVQ
// VPSRAVW
testOp3(m64, .VPSRAVW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 11 fc");
testOp3(m64, .VPSRAVW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 11 fc");
testOp3(m64, .VPSRAVW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 11 fc");
// VPSRAVD
testOp3(m64, .VPSRAVD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 46 c8");
testOp3(m64, .VPSRAVD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 46 c8");
testOp3(m64, .VPSRAVD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 46 fc");
testOp3(m64, .VPSRAVD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 46 fc");
testOp3(m64, .VPSRAVD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 46 fc");
// VPSRAVQ
testOp3(m64, .VPSRAVQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 46 fc");
testOp3(m64, .VPSRAVQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 46 fc");
testOp3(m64, .VPSRAVQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 46 fc");
}
{
// VPSRLVW / VPSRLVD / VPSRLVQ
// VPSRLVW
testOp3(m64, .VPSRLVW, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 10 fc");
testOp3(m64, .VPSRLVW, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 10 fc");
testOp3(m64, .VPSRLVW, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 10 fc");
// VPSRLVD
testOp3(m64, .VPSRLVD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 69 45 c8");
testOp3(m64, .VPSRLVD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 6d 45 c8");
testOp3(m64, .VPSRLVD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 45 fc");
testOp3(m64, .VPSRLVD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 45 fc");
testOp3(m64, .VPSRLVD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 55 c7 45 fc");
// VPSRLVQ
testOp3(m64, .VPSRLVQ, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c4 e2 e9 45 c8");
testOp3(m64, .VPSRLVQ, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c4 e2 ed 45 c8");
testOp3(m64, .VPSRLVQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 45 fc");
testOp3(m64, .VPSRLVQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 45 fc");
testOp3(m64, .VPSRLVQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20), "62 22 d5 c7 45 fc");
}
{
// VPTERNLOGD / VPTERNLOGQ
// VPTERNLOGD
testOp4(m64, .VPTERNLOGD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 25 fc 00");
testOp4(m64, .VPTERNLOGD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 25 fc 00");
testOp4(m64, .VPTERNLOGD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 25 fc 00");
// VPTERNLOGQ
testOp4(m64, .VPTERNLOGQ, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 25 fc 00");
testOp4(m64, .VPTERNLOGQ, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 25 fc 00");
testOp4(m64, .VPTERNLOGQ, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 25 fc 00");
}
{
// VPTESTMB / VPTESTMW / VPTESTMD / VPTESTMQ
// VPTESTMB
testOp3(m64, .VPTESTMB, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 55 07 26 c4");
testOp3(m64, .VPTESTMB, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 55 27 26 c4");
testOp3(m64, .VPTESTMB, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 55 47 26 c4");
// VPTESTMW
testOp3(m64, .VPTESTMW, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 d5 07 26 c4");
testOp3(m64, .VPTESTMW, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 d5 27 26 c4");
testOp3(m64, .VPTESTMW, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 d5 47 26 c4");
// VPTESTMD
testOp3(m64, .VPTESTMD, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 55 07 27 c4");
testOp3(m64, .VPTESTMD, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 55 27 27 c4");
testOp3(m64, .VPTESTMD, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 55 47 27 c4");
// VPTESTMQ
testOp3(m64, .VPTESTMQ, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 d5 07 27 c4");
testOp3(m64, .VPTESTMQ, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 d5 27 27 c4");
testOp3(m64, .VPTESTMQ, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 d5 47 27 c4");
}
{
// VPTESTNMB / VPTESTNMW / VPTESTNMD / VPTESTNMQ
// VPTESTNMB
testOp3(m64, .VPTESTNMB, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 56 07 26 c4");
testOp3(m64, .VPTESTNMB, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 56 27 26 c4");
testOp3(m64, .VPTESTNMB, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 56 47 26 c4");
// VPTESTNMW
testOp3(m64, .VPTESTNMW, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 d6 07 26 c4");
testOp3(m64, .VPTESTNMW, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 d6 27 26 c4");
testOp3(m64, .VPTESTNMW, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 d6 47 26 c4");
// VPTESTNMD
testOp3(m64, .VPTESTNMD, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 56 07 27 c4");
testOp3(m64, .VPTESTNMD, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 56 27 27 c4");
testOp3(m64, .VPTESTNMD, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 56 47 27 c4");
// VPTESTNMQ
testOp3(m64, .VPTESTNMQ, pred(.K0, .K7, .Merge), reg(.XMM21), regRm(.XMM20), "62 b2 d6 07 27 c4");
testOp3(m64, .VPTESTNMQ, pred(.K0, .K7, .Merge), reg(.YMM21), regRm(.YMM20), "62 b2 d6 27 27 c4");
testOp3(m64, .VPTESTNMQ, pred(.K0, .K7, .Merge), reg(.ZMM21), regRm(.ZMM20), "62 b2 d6 47 27 c4");
}
{
// VRANGEPD / VRANGEPS / VRANGESD / VRANGESS
// VRANGEPD
testOp4(m64, .VRANGEPD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 d5 87 50 fc 00");
testOp4(m64, .VRANGEPD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 50 fc 00");
testOp4(m64, .VRANGEPD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),sae(.ZMM30, .SAE),imm(0), "62 03 d5 d7 50 fe 00");
// VRANGEPS
testOp4(m64, .VRANGEPS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20),imm(0), "62 23 55 87 50 fc 00");
testOp4(m64, .VRANGEPS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 50 fc 00");
testOp4(m64, .VRANGEPS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),sae(.ZMM30, .SAE),imm(0), "62 03 55 d7 50 fe 00");
// VRANGESD
testOp4(m64, .VRANGESD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE), imm(0), "62 03 d5 97 51 fe 00");
// VRANGESS
testOp4(m64, .VRANGESS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE), imm(0), "62 03 55 97 51 fe 00");
}
{
// VRCP14PD / VRCP14PS / VRCP14SD / VRCP14SS
// VRCP14PD
testOp2(m64, .VRCP14PD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 4c fc");
testOp2(m64, .VRCP14PD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 4c fc");
testOp2(m64, .VRCP14PD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 4c fc");
// VRCP14PS
testOp2(m64, .VRCP14PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 4c fc");
testOp2(m64, .VRCP14PS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 4c fc");
testOp2(m64, .VRCP14PS, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 4c fc");
// VRCP14SD
testOp3(m64, .VRCP14SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 4d fc");
// VRCP14SS
testOp3(m64, .VRCP14SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 4d fc");
}
{
// VREDUCEPD / VREDUCEPS / VREDUCESD / VREDUCESS
// VREDUCEPD
testOp3(m64, .VREDUCEPD, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 fd 8f 56 fc 00");
testOp3(m64, .VREDUCEPD, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 56 fc 00");
testOp3(m64, .VREDUCEPD, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 fd df 56 fe 00");
// VREDUCEPS
testOp3(m64, .VREDUCEPS, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 7d 8f 56 fc 00");
testOp3(m64, .VREDUCEPS, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 7d af 56 fc 00");
testOp3(m64, .VREDUCEPS, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 7d df 56 fe 00");
// VREDUCESD
testOp4(m64, .VREDUCESD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 d5 97 57 fe 00");
// VREDUCESS
testOp4(m64, .VREDUCESS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 55 97 57 fe 00");
}
{
// VRNDSCALEPD / VRNDSCALEPS / VRNDSCALESD / VRNDSCALESS
// VRNDSCALEPD
testOp3(m64, .VRNDSCALEPD, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 fd 8f 09 fc 00");
testOp3(m64, .VRNDSCALEPD, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 fd af 09 fc 00");
testOp3(m64, .VRNDSCALEPD, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 fd df 09 fe 00");
// VRNDSCALEPS
testOp3(m64, .VRNDSCALEPS, pred(.XMM31, .K7, .Zero),regRm(.XMM20),imm(0), "62 23 7d 8f 08 fc 00");
testOp3(m64, .VRNDSCALEPS, pred(.YMM31, .K7, .Zero),regRm(.YMM20),imm(0), "62 23 7d af 08 fc 00");
testOp3(m64, .VRNDSCALEPS, pred(.ZMM31, .K7, .Zero),sae(.ZMM30, .SAE),imm(0), "62 03 7d df 08 fe 00");
// VRNDSCALESD
testOp4(m64, .VRNDSCALESD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 d5 97 0b fe 00");
// VRNDSCALESS
testOp4(m64, .VRNDSCALESS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .SAE),imm(0), "62 03 55 97 0a fe 00");
}
{
// VRSQRT14PD
testOp2(m64, .VRSQRT14PD, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 fd 8f 4e fc");
testOp2(m64, .VRSQRT14PD, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 fd af 4e fc");
testOp2(m64, .VRSQRT14PD, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 fd cf 4e fc");
// VRSQRT14PS
testOp2(m64, .VRSQRT14PS, pred(.XMM31, .K7, .Zero), regRm(.XMM20), "62 22 7d 8f 4e fc");
testOp2(m64, .VRSQRT14PS, pred(.YMM31, .K7, .Zero), regRm(.YMM20), "62 22 7d af 4e fc");
testOp2(m64, .VRSQRT14PS, pred(.ZMM31, .K7, .Zero), regRm(.ZMM20), "62 22 7d cf 4e fc");
// VRSQRT14SD
testOp3(m64, .VRSQRT14SD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 4f fc");
// VRSQRT14SS
testOp3(m64, .VRSQRT14SS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 4f fc");
}
{
// VSCALEFPD / VSCALEFPS / VSCALEFSD / VSCALEFSS
// VSCALEFPD
testOp3(m64, .VSCALEFPD, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 d5 87 2c fc");
testOp3(m64, .VSCALEFPD, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 d5 a7 2c fc");
testOp3(m64, .VSCALEFPD, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),sae(.ZMM30, .RN_SAE), "62 02 d5 97 2c fe");
// VSCALEFPS
testOp3(m64, .VSCALEFPS, pred(.XMM31, .K7, .Zero),reg(.XMM21),regRm(.XMM20), "62 22 55 87 2c fc");
testOp3(m64, .VSCALEFPS, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20), "62 22 55 a7 2c fc");
testOp3(m64, .VSCALEFPS, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),sae(.ZMM30, .RN_SAE), "62 02 55 97 2c fe");
// VSCALEFSD
testOp3(m64, .VSCALEFSD, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 d5 97 2d fe");
// VSCALEFSS
testOp3(m64, .VSCALEFSS, pred(.XMM31, .K7, .Zero),reg(.XMM21),sae(.XMM30, .RN_SAE), "62 02 55 97 2d fe");
}
{
// VSCATTERDPS / VSCATTERDPD / VSCATTERQPS / VSCATTERQPD
// VSCATTERDPS
testOp2(m64, .VSCATTERDPS, predRm(vm32x, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 07 a2 2c f0");
testOp2(m64, .VSCATTERDPS, predRm(vm32y, .K7, .Merge), reg(.YMM21), "67 62 a2 7d 27 a2 2c f0");
testOp2(m64, .VSCATTERDPS, predRm(vm32z, .K7, .Merge), reg(.ZMM21), "67 62 a2 7d 47 a2 2c f0");
// VSCATTERDPD
testOp2(m64, .VSCATTERDPD, predRm(vm32x, .K7, .Merge), reg(.XMM21), "67 62 a2 fd 07 a2 2c f0");
testOp2(m64, .VSCATTERDPD, predRm(vm32x, .K7, .Merge), reg(.YMM21), "67 62 a2 fd 27 a2 2c f0");
testOp2(m64, .VSCATTERDPD, predRm(vm32y, .K7, .Merge), reg(.ZMM21), "67 62 a2 fd 47 a2 2c f0");
// VSCATTERQPS
testOp2(m64, .VSCATTERQPS, predRm(vm64x, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 07 a3 2c f0");
testOp2(m64, .VSCATTERQPS, predRm(vm64y, .K7, .Merge), reg(.XMM21), "67 62 a2 7d 27 a3 2c f0");
testOp2(m64, .VSCATTERQPS, predRm(vm64z, .K7, .Merge), reg(.YMM21), "67 62 a2 7d 47 a3 2c f0");
// VSCATTERQPD
testOp2(m64, .VSCATTERQPD, predRm(vm64x, .K7, .Merge), reg(.XMM21), "67 62 a2 fd 07 a3 2c f0");
testOp2(m64, .VSCATTERQPD, predRm(vm64y, .K7, .Merge), reg(.YMM21), "67 62 a2 fd 27 a3 2c f0");
testOp2(m64, .VSCATTERQPD, predRm(vm64z, .K7, .Merge), reg(.ZMM21), "67 62 a2 fd 47 a3 2c f0");
}
{
// VSHUFF 32X4 / VSHUFF 64X2 / VSHUFI32X4 / VSHUFI64X2
// VSHUFF 32X4
testOp4(m64, .VSHUFF32X4, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 23 fc 00");
testOp4(m64, .VSHUFF32X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 23 fc 00");
// VSHUFF 64X2
testOp4(m64, .VSHUFF64X2, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 23 fc 00");
testOp4(m64, .VSHUFF64X2, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 23 fc 00");
// VSHUFI32X4
testOp4(m64, .VSHUFI32X4, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 55 a7 43 fc 00");
testOp4(m64, .VSHUFI32X4, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 55 c7 43 fc 00");
// VSHUFI64X2
testOp4(m64, .VSHUFI64X2, pred(.YMM31, .K7, .Zero),reg(.YMM21),regRm(.YMM20),imm(0), "62 23 d5 a7 43 fc 00");
testOp4(m64, .VSHUFI64X2, pred(.ZMM31, .K7, .Zero),reg(.ZMM21),regRm(.ZMM20),imm(0), "62 23 d5 c7 43 fc 00");
}
{
// VTESTPD / VTESTPS
// VTESTPS
testOp2(m64, .VTESTPS, reg(.XMM1), regRm(.XMM0), "c4 e2 79 0e c8");
testOp2(m64, .VTESTPS, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 0e c8");
// VTESTPD
testOp2(m64, .VTESTPD, reg(.XMM1), regRm(.XMM0), "c4 e2 79 0f c8");
testOp2(m64, .VTESTPD, reg(.YMM1), regRm(.YMM0), "c4 e2 7d 0f c8");
}
{
// VXORPD
testOp3(m64, .VXORPD, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e9 57 c8");
testOp3(m64, .VXORPD, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ed 57 c8");
testOp3(m64, .VXORPD, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 d5 87 57 fc");
testOp3(m64, .VXORPD, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 d5 a7 57 fc");
testOp3(m64, .VXORPD, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 d5 c7 57 fc");
// VXXORPS
testOp3(m64, .VXORPS, reg(.XMM1), reg(.XMM2), regRm(.XMM0), "c5 e8 57 c8");
testOp3(m64, .VXORPS, reg(.YMM1), reg(.YMM2), regRm(.YMM0), "c5 ec 57 c8");
testOp3(m64, .VXORPS, pred(.XMM31, .K7, .Zero), reg(.XMM21), regRm(.XMM20), "62 21 54 87 57 fc");
testOp3(m64, .VXORPS, pred(.YMM31, .K7, .Zero), reg(.YMM21), regRm(.YMM20), "62 21 54 a7 57 fc");
testOp3(m64, .VXORPS, pred(.ZMM31, .K7, .Zero), reg(.ZMM21), regRm(.ZMM20), "62 21 54 c7 57 fc");
}
} | src/x86/tests/avx.zig |
usingnamespace @import("root").preamble;
/// We are exporting Node from non-atomic queue module, since we want the same Node type to be used
/// both for atomic and non-atomic queues
pub const Node = lib.containers.queue.Node;
/// Multi producer single consumer unbounded atomic queue.
/// NOTE: Consumer is responsible for managing memory for nodes.
pub fn MPSCUnboundedQueue(comptime T: type, comptime member_name: []const u8) type {
return struct {
/// Head of the queue
head: ?*Node = null,
/// Tail of the queue
tail: ?*Node = null,
/// Dummy node
dummy: Node = .{ .next = null },
/// Convert reference to T to reference to atomic queue node
fn refToNode(ref: *T) *Node {
return &@field(ref, member_name);
}
/// Convert reference to atomic queue node to reference to T
fn nodeToRef(node: *Node) *T {
return @fieldParentPtr(T, member_name, node);
}
/// Enqueue element by reference to the node
pub fn enqueueImpl(self: *@This(), node: *Node) void {
node.next = null;
const prev = @atomicRmw(?*Node, &self.head, .Xchg, node, .AcqRel) orelse &self.dummy;
@atomicStore(?*Node, &prev.next, node, .Release);
}
/// Enqueue element
pub fn enqueue(self: *@This(), elem: *T) void {
self.enqueueImpl(refToNode(elem));
}
/// Try to dequeue
pub fn dequeue(self: *@This()) ?*T {
// Consumer thread will always have consistent view of tail, as its the one that reads
// it / writes to it
var tail: *Node = undefined;
if (self.tail) |node| {
tail = node;
} else {
tail = &self.dummy;
self.tail = tail;
}
// Load next with acquire, as we don't want that to be reordered
var next = @atomicLoad(?*Node, &tail.next, .Acquire);
// Make sure that queue tail is not pointing at dummy element
if (tail == &self.dummy) {
if (next) |next_nonnull| {
// Skip dummy element. At this point, there is not a single pointer to dummy
self.tail = next_nonnull;
tail = next_nonnull;
next = @atomicLoad(?*Node, &tail.next, .Acquire);
} else {
// No nodes in the queue =(
// (at least they were not visible to us)
return null;
}
}
if (next) |next_nonnull| {
// Tail exists (and not dummy), and next exists
// Tail can be returned without worrying
// about updates (they may only take place for the next node)
self.tail = next_nonnull;
return nodeToRef(tail);
}
// Tail exists, but next has not existed (it may now as code is lock free)
// Check if head points to the same element as tail
// (there is actually only one element)
var head = @atomicLoad(?*Node, &self.head, .Acquire) orelse &self.dummy;
// If tail != head, update is going on, as head was not linked with
// next pointer
// Condvar should pick up push event
if (tail != head) {
return null;
}
// Dummy node is not referenced by anything
// and we have only one node left
// Reinsert it as a marker for as to know
// Where current queue ends
self.enqueueImpl(&self.dummy);
next = @atomicLoad(?*Node, &tail.next, .Acquire);
if (next) |next_nonnull| {
self.tail = next_nonnull;
return nodeToRef(tail);
}
return null;
}
};
}
test "insertion tests" {
const TestNode = struct {
hook: Node = undefined,
val: u64,
};
var queue: MPSCUnboundedQueue(TestNode, "hook") = .{};
var elems = [_]TestNode{
.{ .val = 1 },
.{ .val = 2 },
.{ .val = 3 },
};
queue.enqueue(&elems[0]);
queue.enqueue(&elems[1]);
queue.enqueue(&elems[2]);
try std.testing.expect(queue.dequeue() == &elems[0]);
try std.testing.expect(queue.dequeue() == &elems[1]);
try std.testing.expect(queue.dequeue() == &elems[2]);
try std.testing.expect(queue.dequeue() == null);
} | lib/containers/atomic_queue.zig |
const std = @import("std");
const io = std.io;
const mem = std.mem;
const fs = std.fs;
const process = std.process;
const Allocator = mem.Allocator;
const ArrayList = std.ArrayList;
const ArrayListSentineled = std.ArrayListSentineled;
const Target = std.Target;
const CrossTarget = std.zig.CrossTarget;
const self_hosted_main = @import("main.zig");
const errmsg = @import("errmsg.zig");
const DepTokenizer = @import("dep_tokenizer.zig").Tokenizer;
const assert = std.debug.assert;
const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
var stderr_file: fs.File = undefined;
var stderr: fs.File.OutStream = undefined;
var stdout: fs.File.OutStream = undefined;
comptime {
_ = @import("dep_tokenizer.zig");
}
// ABI warning
export fn stage2_zen(ptr: *[*]const u8, len: *usize) void {
const info_zen = @import("main.zig").info_zen;
ptr.* = info_zen;
len.* = info_zen.len;
}
// ABI warning
export fn stage2_panic(ptr: [*]const u8, len: usize) void {
@panic(ptr[0..len]);
}
// ABI warning
const Error = extern enum {
None,
OutOfMemory,
InvalidFormat,
SemanticAnalyzeFail,
AccessDenied,
Interrupted,
SystemResources,
FileNotFound,
FileSystem,
FileTooBig,
DivByZero,
Overflow,
PathAlreadyExists,
Unexpected,
ExactDivRemainder,
NegativeDenominator,
ShiftedOutOneBits,
CCompileErrors,
EndOfFile,
IsDir,
NotDir,
UnsupportedOperatingSystem,
SharingViolation,
PipeBusy,
PrimitiveTypeNotFound,
CacheUnavailable,
PathTooLong,
CCompilerCannotFindFile,
NoCCompilerInstalled,
ReadingDepFile,
InvalidDepFile,
MissingArchitecture,
MissingOperatingSystem,
UnknownArchitecture,
UnknownOperatingSystem,
UnknownABI,
InvalidFilename,
DiskQuota,
DiskSpace,
UnexpectedWriteFailure,
UnexpectedSeekFailure,
UnexpectedFileTruncationFailure,
Unimplemented,
OperationAborted,
BrokenPipe,
NoSpaceLeft,
NotLazy,
IsAsync,
ImportOutsidePkgPath,
UnknownCpuModel,
UnknownCpuFeature,
InvalidCpuFeatures,
InvalidLlvmCpuFeaturesFormat,
UnknownApplicationBinaryInterface,
ASTUnitFailure,
BadPathName,
SymLinkLoop,
ProcessFdQuotaExceeded,
SystemFdQuotaExceeded,
NoDevice,
DeviceBusy,
UnableToSpawnCCompiler,
CCompilerExitCode,
CCompilerCrashed,
CCompilerCannotFindHeaders,
LibCRuntimeNotFound,
LibCStdLibHeaderNotFound,
LibCKernel32LibNotFound,
UnsupportedArchitecture,
WindowsSdkNotFound,
UnknownDynamicLinkerPath,
TargetHasNoDynamicLinker,
InvalidAbiVersion,
InvalidOperatingSystemVersion,
UnknownClangOption,
NestedResponseFile,
ZigIsTheCCompiler,
FileBusy,
Locked,
};
const FILE = std.c.FILE;
const ast = std.zig.ast;
const translate_c = @import("translate_c.zig");
/// Args should have a null terminating last arg.
export fn stage2_translate_c(
out_ast: **ast.Tree,
out_errors_ptr: *[*]translate_c.ClangErrMsg,
out_errors_len: *usize,
args_begin: [*]?[*]const u8,
args_end: [*]?[*]const u8,
resources_path: [*:0]const u8,
) Error {
var errors: []translate_c.ClangErrMsg = &[0]translate_c.ClangErrMsg{};
out_ast.* = translate_c.translate(std.heap.c_allocator, args_begin, args_end, &errors, resources_path) catch |err| switch (err) {
error.SemanticAnalyzeFail => {
out_errors_ptr.* = errors.ptr;
out_errors_len.* = errors.len;
return .CCompileErrors;
},
error.ASTUnitFailure => return .ASTUnitFailure,
error.OutOfMemory => return .OutOfMemory,
};
return .None;
}
export fn stage2_free_clang_errors(errors_ptr: [*]translate_c.ClangErrMsg, errors_len: usize) void {
translate_c.freeErrors(errors_ptr[0..errors_len]);
}
export fn stage2_render_ast(tree: *ast.Tree, output_file: *FILE) Error {
const c_out_stream = std.io.cOutStream(output_file);
_ = std.zig.render(std.heap.c_allocator, c_out_stream, tree) catch |e| switch (e) {
error.WouldBlock => unreachable, // stage1 opens stuff in exclusively blocking mode
error.SystemResources => return .SystemResources,
error.OperationAborted => return .OperationAborted,
error.BrokenPipe => return .BrokenPipe,
error.DiskQuota => return .DiskQuota,
error.FileTooBig => return .FileTooBig,
error.NoSpaceLeft => return .NoSpaceLeft,
error.AccessDenied => return .AccessDenied,
error.OutOfMemory => return .OutOfMemory,
error.Unexpected => return .Unexpected,
error.InputOutput => return .FileSystem,
};
return .None;
}
// TODO: just use the actual self-hosted zig fmt. Until https://github.com/ziglang/zig/issues/2377,
// we use a blocking implementation.
export fn stage2_fmt(argc: c_int, argv: [*]const [*:0]const u8) c_int {
if (std.debug.runtime_safety) {
fmtMain(argc, argv) catch unreachable;
} else {
fmtMain(argc, argv) catch |e| {
std.debug.warn("{}\n", .{@errorName(e)});
return -1;
};
}
return 0;
}
fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
const allocator = std.heap.c_allocator;
var args_list = std.ArrayList([]const u8).init(allocator);
const argc_usize = @intCast(usize, argc);
var arg_i: usize = 0;
while (arg_i < argc_usize) : (arg_i += 1) {
try args_list.append(mem.spanZ(argv[arg_i]));
}
stdout = std.io.getStdOut().outStream();
stderr_file = std.io.getStdErr();
stderr = stderr_file.outStream();
const args = args_list.span()[2..];
var color: errmsg.Color = .Auto;
var stdin_flag: bool = false;
var check_flag: bool = false;
var input_files = ArrayList([]const u8).init(allocator);
{
var i: usize = 0;
while (i < args.len) : (i += 1) {
const arg = args[i];
if (mem.startsWith(u8, arg, "-")) {
if (mem.eql(u8, arg, "--help")) {
try stdout.writeAll(self_hosted_main.usage_fmt);
process.exit(0);
} else if (mem.eql(u8, arg, "--color")) {
if (i + 1 >= args.len) {
try stderr.writeAll("expected [auto|on|off] after --color\n");
process.exit(1);
}
i += 1;
const next_arg = args[i];
if (mem.eql(u8, next_arg, "auto")) {
color = .Auto;
} else if (mem.eql(u8, next_arg, "on")) {
color = .On;
} else if (mem.eql(u8, next_arg, "off")) {
color = .Off;
} else {
try stderr.print("expected [auto|on|off] after --color, found '{}'\n", .{next_arg});
process.exit(1);
}
} else if (mem.eql(u8, arg, "--stdin")) {
stdin_flag = true;
} else if (mem.eql(u8, arg, "--check")) {
check_flag = true;
} else {
try stderr.print("unrecognized parameter: '{}'", .{arg});
process.exit(1);
}
} else {
try input_files.append(arg);
}
}
}
if (stdin_flag) {
if (input_files.items.len != 0) {
try stderr.writeAll("cannot use --stdin with positional arguments\n");
process.exit(1);
}
const stdin_file = io.getStdIn();
var stdin = stdin_file.inStream();
const source_code = try stdin.readAllAlloc(allocator, self_hosted_main.max_src_size);
defer allocator.free(source_code);
const tree = std.zig.parse(allocator, source_code) catch |err| {
try stderr.print("error parsing stdin: {}\n", .{err});
process.exit(1);
};
defer tree.deinit();
var error_it = tree.errors.iterator(0);
while (error_it.next()) |parse_error| {
try printErrMsgToFile(allocator, parse_error, tree, "<stdin>", stderr_file, color);
}
if (tree.errors.len != 0) {
process.exit(1);
}
if (check_flag) {
const anything_changed = try std.zig.render(allocator, io.null_out_stream, tree);
const code = if (anything_changed) @as(u8, 1) else @as(u8, 0);
process.exit(code);
}
_ = try std.zig.render(allocator, stdout, tree);
return;
}
if (input_files.items.len == 0) {
try stderr.writeAll("expected at least one source file argument\n");
process.exit(1);
}
var fmt = Fmt{
.seen = Fmt.SeenMap.init(allocator),
.any_error = false,
.color = color,
.allocator = allocator,
};
for (input_files.span()) |file_path| {
try fmtPath(&fmt, file_path, check_flag);
}
if (fmt.any_error) {
process.exit(1);
}
}
const FmtError = error{
SystemResources,
OperationAborted,
IoPending,
BrokenPipe,
Unexpected,
WouldBlock,
FileClosed,
DestinationAddressRequired,
DiskQuota,
FileTooBig,
InputOutput,
NoSpaceLeft,
AccessDenied,
OutOfMemory,
RenameAcrossMountPoints,
ReadOnlyFileSystem,
LinkQuotaExceeded,
FileBusy,
} || fs.File.OpenError;
fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void {
// get the real path here to avoid Windows failing on relative file paths with . or .. in them
var real_path = fs.realpathAlloc(fmt.allocator, file_path) catch |err| {
try stderr.print("unable to open '{}': {}\n", .{ file_path, err });
fmt.any_error = true;
return;
};
defer fmt.allocator.free(real_path);
if (fmt.seen.exists(real_path)) return;
try fmt.seen.put(real_path);
const source_code = fs.cwd().readFileAlloc(fmt.allocator, real_path, self_hosted_main.max_src_size) catch |err| switch (err) {
error.IsDir, error.AccessDenied => {
// TODO make event based (and dir.next())
var dir = try fs.cwd().openDir(file_path, .{ .iterate = true });
defer dir.close();
var dir_it = dir.iterate();
while (try dir_it.next()) |entry| {
if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) {
const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ file_path, entry.name });
try fmtPath(fmt, full_path, check_mode);
}
}
return;
},
else => {
// TODO lock stderr printing
try stderr.print("unable to open '{}': {}\n", .{ file_path, err });
fmt.any_error = true;
return;
},
};
defer fmt.allocator.free(source_code);
const tree = std.zig.parse(fmt.allocator, source_code) catch |err| {
try stderr.print("error parsing file '{}': {}\n", .{ file_path, err });
fmt.any_error = true;
return;
};
defer tree.deinit();
var error_it = tree.errors.iterator(0);
while (error_it.next()) |parse_error| {
try printErrMsgToFile(fmt.allocator, parse_error, tree, file_path, stderr_file, fmt.color);
}
if (tree.errors.len != 0) {
fmt.any_error = true;
return;
}
if (check_mode) {
const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree);
if (anything_changed) {
try stderr.print("{}\n", .{file_path});
fmt.any_error = true;
}
} else {
const baf = try io.BufferedAtomicFile.create(fmt.allocator, fs.cwd(), real_path, .{});
defer baf.destroy();
const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree);
if (anything_changed) {
try stderr.print("{}\n", .{file_path});
try baf.finish();
}
}
}
const Fmt = struct {
seen: SeenMap,
any_error: bool,
color: errmsg.Color,
allocator: *mem.Allocator,
const SeenMap = std.BufSet;
};
fn printErrMsgToFile(
allocator: *mem.Allocator,
parse_error: *const ast.Error,
tree: *ast.Tree,
path: []const u8,
file: fs.File,
color: errmsg.Color,
) !void {
const color_on = switch (color) {
.Auto => file.isTty(),
.On => true,
.Off => false,
};
const lok_token = parse_error.loc();
const span = errmsg.Span{
.first = lok_token,
.last = lok_token,
};
const first_token = tree.tokens.at(span.first);
const last_token = tree.tokens.at(span.last);
const start_loc = tree.tokenLocationPtr(0, first_token);
const end_loc = tree.tokenLocationPtr(first_token.end, last_token);
var text_buf = std.ArrayList(u8).init(allocator);
defer text_buf.deinit();
const out_stream = text_buf.outStream();
try parse_error.render(&tree.tokens, out_stream);
const text = text_buf.span();
const stream = file.outStream();
try stream.print("{}:{}:{}: error: {}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
if (!color_on) return;
// Print \r and \t as one space each so that column counts line up
for (tree.source[start_loc.line_start..start_loc.line_end]) |byte| {
try stream.writeByte(switch (byte) {
'\r', '\t' => ' ',
else => byte,
});
}
try stream.writeByte('\n');
try stream.writeByteNTimes(' ', start_loc.column);
try stream.writeByteNTimes('~', last_token.end - first_token.start);
try stream.writeByte('\n');
}
export fn stage2_DepTokenizer_init(input: [*]const u8, len: usize) stage2_DepTokenizer {
const t = std.heap.c_allocator.create(DepTokenizer) catch @panic("failed to create .d tokenizer");
t.* = DepTokenizer.init(std.heap.c_allocator, input[0..len]);
return stage2_DepTokenizer{
.handle = t,
};
}
export fn stage2_DepTokenizer_deinit(self: *stage2_DepTokenizer) void {
self.handle.deinit();
}
export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextResult {
const otoken = self.handle.next() catch {
const textz = std.ArrayListSentineled(u8, 0).init(&self.handle.arena.allocator, self.handle.error_text) catch @panic("failed to create .d tokenizer error text");
return stage2_DepNextResult{
.type_id = .error_,
.textz = textz.span().ptr,
};
};
const token = otoken orelse {
return stage2_DepNextResult{
.type_id = .null_,
.textz = undefined,
};
};
const textz = std.ArrayListSentineled(u8, 0).init(&self.handle.arena.allocator, token.bytes) catch @panic("failed to create .d tokenizer token text");
return stage2_DepNextResult{
.type_id = switch (token.id) {
.target => .target,
.prereq => .prereq,
},
.textz = textz.span().ptr,
};
}
const stage2_DepTokenizer = extern struct {
handle: *DepTokenizer,
};
const stage2_DepNextResult = extern struct {
type_id: TypeId,
// when type_id == error --> error text
// when type_id == null --> undefined
// when type_id == target --> target pathname
// when type_id == prereq --> prereq pathname
textz: [*]const u8,
const TypeId = extern enum {
error_,
null_,
target,
prereq,
};
};
// ABI warning
export fn stage2_attach_segfault_handler() void {
if (std.debug.runtime_safety and std.debug.have_segfault_handling_support) {
std.debug.attachSegfaultHandler();
}
}
// ABI warning
export fn stage2_progress_create() *std.Progress {
const ptr = std.heap.c_allocator.create(std.Progress) catch @panic("out of memory");
ptr.* = std.Progress{};
return ptr;
}
// ABI warning
export fn stage2_progress_destroy(progress: *std.Progress) void {
std.heap.c_allocator.destroy(progress);
}
// ABI warning
export fn stage2_progress_start_root(
progress: *std.Progress,
name_ptr: [*]const u8,
name_len: usize,
estimated_total_items: usize,
) *std.Progress.Node {
return progress.start(
name_ptr[0..name_len],
if (estimated_total_items == 0) null else estimated_total_items,
) catch @panic("timer unsupported");
}
// ABI warning
export fn stage2_progress_disable_tty(progress: *std.Progress) void {
progress.terminal = null;
}
// ABI warning
export fn stage2_progress_start(
node: *std.Progress.Node,
name_ptr: [*]const u8,
name_len: usize,
estimated_total_items: usize,
) *std.Progress.Node {
const child_node = std.heap.c_allocator.create(std.Progress.Node) catch @panic("out of memory");
child_node.* = node.start(
name_ptr[0..name_len],
if (estimated_total_items == 0) null else estimated_total_items,
);
child_node.activate();
return child_node;
}
// ABI warning
export fn stage2_progress_end(node: *std.Progress.Node) void {
node.end();
if (&node.context.root != node) {
std.heap.c_allocator.destroy(node);
}
}
// ABI warning
export fn stage2_progress_complete_one(node: *std.Progress.Node) void {
node.completeOne();
}
// ABI warning
export fn stage2_progress_update_node(node: *std.Progress.Node, done_count: usize, total_count: usize) void {
node.completed_items = done_count;
node.estimated_total_items = total_count;
node.activate();
node.context.maybeRefresh();
}
fn detectNativeCpuWithLLVM(
arch: Target.Cpu.Arch,
llvm_cpu_name_z: ?[*:0]const u8,
llvm_cpu_features_opt: ?[*:0]const u8,
) !Target.Cpu {
var result = Target.Cpu.baseline(arch);
if (llvm_cpu_name_z) |cpu_name_z| {
const llvm_cpu_name = mem.spanZ(cpu_name_z);
for (arch.allCpuModels()) |model| {
const this_llvm_name = model.llvm_name orelse continue;
if (mem.eql(u8, this_llvm_name, llvm_cpu_name)) {
// Here we use the non-dependencies-populated set,
// so that subtracting features later in this function
// affect the prepopulated set.
result = Target.Cpu{
.arch = arch,
.model = model,
.features = model.features,
};
break;
}
}
}
const all_features = arch.allFeaturesList();
if (llvm_cpu_features_opt) |llvm_cpu_features| {
var it = mem.tokenize(mem.spanZ(llvm_cpu_features), ",");
while (it.next()) |decorated_llvm_feat| {
var op: enum {
add,
sub,
} = undefined;
var llvm_feat: []const u8 = undefined;
if (mem.startsWith(u8, decorated_llvm_feat, "+")) {
op = .add;
llvm_feat = decorated_llvm_feat[1..];
} else if (mem.startsWith(u8, decorated_llvm_feat, "-")) {
op = .sub;
llvm_feat = decorated_llvm_feat[1..];
} else {
return error.InvalidLlvmCpuFeaturesFormat;
}
for (all_features) |feature, index_usize| {
const this_llvm_name = feature.llvm_name orelse continue;
if (mem.eql(u8, llvm_feat, this_llvm_name)) {
const index = @intCast(Target.Cpu.Feature.Set.Index, index_usize);
switch (op) {
.add => result.features.addFeature(index),
.sub => result.features.removeFeature(index),
}
break;
}
}
}
}
result.features.populateDependencies(all_features);
return result;
}
// ABI warning
export fn stage2_cmd_targets(
zig_triple: ?[*:0]const u8,
mcpu: ?[*:0]const u8,
dynamic_linker: ?[*:0]const u8,
) c_int {
cmdTargets(zig_triple, mcpu, dynamic_linker) catch |err| {
std.debug.warn("unable to list targets: {}\n", .{@errorName(err)});
return -1;
};
return 0;
}
fn cmdTargets(
zig_triple_oz: ?[*:0]const u8,
mcpu_oz: ?[*:0]const u8,
dynamic_linker_oz: ?[*:0]const u8,
) !void {
const cross_target = try stage2CrossTarget(zig_triple_oz, mcpu_oz, dynamic_linker_oz);
var dynamic_linker: ?[*:0]u8 = null;
const target = try crossTargetToTarget(cross_target, &dynamic_linker);
return @import("print_targets.zig").cmdTargets(
std.heap.c_allocator,
&[0][]u8{},
std.io.getStdOut().outStream(),
target,
);
}
// ABI warning
export fn stage2_target_parse(
target: *Stage2Target,
zig_triple: ?[*:0]const u8,
mcpu: ?[*:0]const u8,
dynamic_linker: ?[*:0]const u8,
) Error {
stage2TargetParse(target, zig_triple, mcpu, dynamic_linker) catch |err| switch (err) {
error.OutOfMemory => return .OutOfMemory,
error.UnknownArchitecture => return .UnknownArchitecture,
error.UnknownOperatingSystem => return .UnknownOperatingSystem,
error.UnknownApplicationBinaryInterface => return .UnknownApplicationBinaryInterface,
error.MissingOperatingSystem => return .MissingOperatingSystem,
error.InvalidLlvmCpuFeaturesFormat => return .InvalidLlvmCpuFeaturesFormat,
error.UnexpectedExtraField => return .SemanticAnalyzeFail,
error.InvalidAbiVersion => return .InvalidAbiVersion,
error.InvalidOperatingSystemVersion => return .InvalidOperatingSystemVersion,
error.FileSystem => return .FileSystem,
error.SymLinkLoop => return .SymLinkLoop,
error.SystemResources => return .SystemResources,
error.ProcessFdQuotaExceeded => return .ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded => return .SystemFdQuotaExceeded,
error.DeviceBusy => return .DeviceBusy,
};
return .None;
}
fn stage2CrossTarget(
zig_triple_oz: ?[*:0]const u8,
mcpu_oz: ?[*:0]const u8,
dynamic_linker_oz: ?[*:0]const u8,
) !CrossTarget {
const mcpu = mem.spanZ(mcpu_oz);
const dynamic_linker = mem.spanZ(dynamic_linker_oz);
var diags: CrossTarget.ParseOptions.Diagnostics = .{};
const target: CrossTarget = CrossTarget.parse(.{
.arch_os_abi = mem.spanZ(zig_triple_oz) orelse "native",
.cpu_features = mcpu,
.dynamic_linker = dynamic_linker,
.diagnostics = &diags,
}) catch |err| switch (err) {
error.UnknownCpuModel => {
std.debug.warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{
diags.cpu_name.?,
@tagName(diags.arch.?),
});
for (diags.arch.?.allCpuModels()) |cpu| {
std.debug.warn(" {}\n", .{cpu.name});
}
process.exit(1);
},
error.UnknownCpuFeature => {
std.debug.warn(
\\Unknown CPU feature: '{}'
\\Available CPU features for architecture '{}':
\\
, .{
diags.unknown_feature_name,
@tagName(diags.arch.?),
});
for (diags.arch.?.allFeaturesList()) |feature| {
std.debug.warn(" {}: {}\n", .{ feature.name, feature.description });
}
process.exit(1);
},
else => |e| return e,
};
return target;
}
fn stage2TargetParse(
stage1_target: *Stage2Target,
zig_triple_oz: ?[*:0]const u8,
mcpu_oz: ?[*:0]const u8,
dynamic_linker_oz: ?[*:0]const u8,
) !void {
const target = try stage2CrossTarget(zig_triple_oz, mcpu_oz, dynamic_linker_oz);
try stage1_target.fromTarget(target);
}
// ABI warning
const Stage2LibCInstallation = extern struct {
include_dir: [*]const u8,
include_dir_len: usize,
sys_include_dir: [*]const u8,
sys_include_dir_len: usize,
crt_dir: [*]const u8,
crt_dir_len: usize,
msvc_lib_dir: [*]const u8,
msvc_lib_dir_len: usize,
kernel32_lib_dir: [*]const u8,
kernel32_lib_dir_len: usize,
fn initFromStage2(self: *Stage2LibCInstallation, libc: LibCInstallation) void {
if (libc.include_dir) |s| {
self.include_dir = s.ptr;
self.include_dir_len = s.len;
} else {
self.include_dir = "";
self.include_dir_len = 0;
}
if (libc.sys_include_dir) |s| {
self.sys_include_dir = s.ptr;
self.sys_include_dir_len = s.len;
} else {
self.sys_include_dir = "";
self.sys_include_dir_len = 0;
}
if (libc.crt_dir) |s| {
self.crt_dir = s.ptr;
self.crt_dir_len = s.len;
} else {
self.crt_dir = "";
self.crt_dir_len = 0;
}
if (libc.msvc_lib_dir) |s| {
self.msvc_lib_dir = s.ptr;
self.msvc_lib_dir_len = s.len;
} else {
self.msvc_lib_dir = "";
self.msvc_lib_dir_len = 0;
}
if (libc.kernel32_lib_dir) |s| {
self.kernel32_lib_dir = s.ptr;
self.kernel32_lib_dir_len = s.len;
} else {
self.kernel32_lib_dir = "";
self.kernel32_lib_dir_len = 0;
}
}
fn toStage2(self: Stage2LibCInstallation) LibCInstallation {
var libc: LibCInstallation = .{};
if (self.include_dir_len != 0) {
libc.include_dir = self.include_dir[0..self.include_dir_len];
}
if (self.sys_include_dir_len != 0) {
libc.sys_include_dir = self.sys_include_dir[0..self.sys_include_dir_len];
}
if (self.crt_dir_len != 0) {
libc.crt_dir = self.crt_dir[0..self.crt_dir_len];
}
if (self.msvc_lib_dir_len != 0) {
libc.msvc_lib_dir = self.msvc_lib_dir[0..self.msvc_lib_dir_len];
}
if (self.kernel32_lib_dir_len != 0) {
libc.kernel32_lib_dir = self.kernel32_lib_dir[0..self.kernel32_lib_dir_len];
}
return libc;
}
};
// ABI warning
export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [*:0]const u8) Error {
stderr_file = std.io.getStdErr();
stderr = stderr_file.outStream();
const libc_file = mem.spanZ(libc_file_z);
var libc = LibCInstallation.parse(std.heap.c_allocator, libc_file, stderr) catch |err| switch (err) {
error.ParseError => return .SemanticAnalyzeFail,
error.DiskQuota => return .DiskQuota,
error.FileTooBig => return .FileTooBig,
error.InputOutput => return .FileSystem,
error.NoSpaceLeft => return .NoSpaceLeft,
error.AccessDenied => return .AccessDenied,
error.BrokenPipe => return .BrokenPipe,
error.SystemResources => return .SystemResources,
error.OperationAborted => return .OperationAborted,
error.WouldBlock => unreachable,
error.Unexpected => return .Unexpected,
error.EndOfStream => return .EndOfFile,
error.IsDir => return .IsDir,
error.ConnectionResetByPeer => unreachable,
error.OutOfMemory => return .OutOfMemory,
error.Unseekable => unreachable,
error.SharingViolation => return .SharingViolation,
error.PathAlreadyExists => unreachable,
error.FileNotFound => return .FileNotFound,
error.PipeBusy => return .PipeBusy,
error.NameTooLong => return .PathTooLong,
error.InvalidUtf8 => return .BadPathName,
error.BadPathName => return .BadPathName,
error.SymLinkLoop => return .SymLinkLoop,
error.ProcessFdQuotaExceeded => return .ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded => return .SystemFdQuotaExceeded,
error.NoDevice => return .NoDevice,
error.NotDir => return .NotDir,
error.DeviceBusy => return .DeviceBusy,
error.FileLocksNotSupported => unreachable,
};
stage1_libc.initFromStage2(libc);
return .None;
}
// ABI warning
export fn stage2_libc_find_native(stage1_libc: *Stage2LibCInstallation) Error {
var libc = LibCInstallation.findNative(.{
.allocator = std.heap.c_allocator,
.verbose = true,
}) catch |err| switch (err) {
error.OutOfMemory => return .OutOfMemory,
error.FileSystem => return .FileSystem,
error.UnableToSpawnCCompiler => return .UnableToSpawnCCompiler,
error.CCompilerExitCode => return .CCompilerExitCode,
error.CCompilerCrashed => return .CCompilerCrashed,
error.CCompilerCannotFindHeaders => return .CCompilerCannotFindHeaders,
error.LibCRuntimeNotFound => return .LibCRuntimeNotFound,
error.LibCStdLibHeaderNotFound => return .LibCStdLibHeaderNotFound,
error.LibCKernel32LibNotFound => return .LibCKernel32LibNotFound,
error.UnsupportedArchitecture => return .UnsupportedArchitecture,
error.WindowsSdkNotFound => return .WindowsSdkNotFound,
error.ZigIsTheCCompiler => return .ZigIsTheCCompiler,
};
stage1_libc.initFromStage2(libc);
return .None;
}
// ABI warning
export fn stage2_libc_render(stage1_libc: *Stage2LibCInstallation, output_file: *FILE) Error {
var libc = stage1_libc.toStage2();
const c_out_stream = std.io.cOutStream(output_file);
libc.render(c_out_stream) catch |err| switch (err) {
error.WouldBlock => unreachable, // stage1 opens stuff in exclusively blocking mode
error.SystemResources => return .SystemResources,
error.OperationAborted => return .OperationAborted,
error.BrokenPipe => return .BrokenPipe,
error.DiskQuota => return .DiskQuota,
error.FileTooBig => return .FileTooBig,
error.NoSpaceLeft => return .NoSpaceLeft,
error.AccessDenied => return .AccessDenied,
error.Unexpected => return .Unexpected,
error.InputOutput => return .FileSystem,
};
return .None;
}
fn enumToString(value: var, type_name: []const u8) ![]const u8 {
switch (@typeInfo(@TypeOf(value))) {
.Enum => |e| {
if (e.is_exhaustive) {
return std.fmt.allocPrint(std.heap.c_allocator, ".{}", .{@tagName(value)});
} else {
return std.fmt.allocPrint(
std.heap.c_allocator,
"@intToEnum({}, {})",
.{ type_name, @enumToInt(value) },
);
}
},
else => unreachable,
}
}
// ABI warning
const Stage2Target = extern struct {
arch: c_int,
vendor: c_int,
abi: c_int,
os: c_int,
is_native_os: bool,
is_native_cpu: bool,
glibc_or_darwin_version: ?*Stage2SemVer,
llvm_cpu_name: ?[*:0]const u8,
llvm_cpu_features: ?[*:0]const u8,
cpu_builtin_str: ?[*:0]const u8,
cache_hash: ?[*:0]const u8,
cache_hash_len: usize,
os_builtin_str: ?[*:0]const u8,
dynamic_linker: ?[*:0]const u8,
standard_dynamic_linker_path: ?[*:0]const u8,
llvm_cpu_features_asm_ptr: [*]const [*:0]const u8,
llvm_cpu_features_asm_len: usize,
fn fromTarget(self: *Stage2Target, cross_target: CrossTarget) !void {
const allocator = std.heap.c_allocator;
var dynamic_linker: ?[*:0]u8 = null;
const target = try crossTargetToTarget(cross_target, &dynamic_linker);
var cache_hash = try std.ArrayListSentineled(u8, 0).allocPrint(allocator, "{}\n{}\n", .{
target.cpu.model.name,
target.cpu.features.asBytes(),
});
defer cache_hash.deinit();
const generic_arch_name = target.cpu.arch.genericName();
var cpu_builtin_str_buffer = try std.ArrayListSentineled(u8, 0).allocPrint(allocator,
\\Cpu{{
\\ .arch = .{},
\\ .model = &Target.{}.cpu.{},
\\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{
\\
, .{
@tagName(target.cpu.arch),
generic_arch_name,
target.cpu.model.name,
generic_arch_name,
generic_arch_name,
});
defer cpu_builtin_str_buffer.deinit();
var llvm_features_buffer = try std.ArrayListSentineled(u8, 0).initSize(allocator, 0);
defer llvm_features_buffer.deinit();
// Unfortunately we have to do the work twice, because Clang does not support
// the same command line parameters for CPU features when assembling code as it does
// when compiling C code.
var asm_features_list = std.ArrayList([*:0]const u8).init(allocator);
defer asm_features_list.deinit();
for (target.cpu.arch.allFeaturesList()) |feature, index_usize| {
const index = @intCast(Target.Cpu.Feature.Set.Index, index_usize);
const is_enabled = target.cpu.features.isEnabled(index);
if (feature.llvm_name) |llvm_name| {
const plus_or_minus = "-+"[@boolToInt(is_enabled)];
try llvm_features_buffer.append(plus_or_minus);
try llvm_features_buffer.appendSlice(llvm_name);
try llvm_features_buffer.appendSlice(",");
}
if (is_enabled) {
// TODO some kind of "zig identifier escape" function rather than
// unconditionally using @"" syntax
try cpu_builtin_str_buffer.appendSlice(" .@\"");
try cpu_builtin_str_buffer.appendSlice(feature.name);
try cpu_builtin_str_buffer.appendSlice("\",\n");
}
}
switch (target.cpu.arch) {
.riscv32, .riscv64 => {
if (std.Target.riscv.featureSetHas(target.cpu.features, .relax)) {
try asm_features_list.append("-mrelax");
} else {
try asm_features_list.append("-mno-relax");
}
},
else => {
// TODO
// Argh, why doesn't the assembler accept the list of CPU features?!
// I don't see a way to do this other than hard coding everything.
},
}
try cpu_builtin_str_buffer.appendSlice(
\\ }),
\\};
\\
);
assert(mem.endsWith(u8, llvm_features_buffer.span(), ","));
llvm_features_buffer.shrink(llvm_features_buffer.len() - 1);
var os_builtin_str_buffer = try std.ArrayListSentineled(u8, 0).allocPrint(allocator,
\\Os{{
\\ .tag = .{},
\\ .version_range = .{{
, .{@tagName(target.os.tag)});
defer os_builtin_str_buffer.deinit();
// We'll re-use the OS version range builtin string for the cache hash.
const os_builtin_str_ver_start_index = os_builtin_str_buffer.len();
@setEvalBranchQuota(2000);
switch (target.os.tag) {
.freestanding,
.ananas,
.cloudabi,
.dragonfly,
.fuchsia,
.ios,
.kfreebsd,
.lv2,
.solaris,
.haiku,
.minix,
.rtems,
.nacl,
.cnk,
.aix,
.cuda,
.nvcl,
.amdhsa,
.ps4,
.elfiamcu,
.tvos,
.watchos,
.mesa3d,
.contiki,
.amdpal,
.hermit,
.hurd,
.wasi,
.emscripten,
.uefi,
.other,
=> try os_builtin_str_buffer.appendSlice(" .none = {} }\n"),
.freebsd,
.macosx,
.netbsd,
.openbsd,
=> try os_builtin_str_buffer.outStream().print(
\\ .semver = .{{
\\ .min = .{{
\\ .major = {},
\\ .minor = {},
\\ .patch = {},
\\ }},
\\ .max = .{{
\\ .major = {},
\\ .minor = {},
\\ .patch = {},
\\ }},
\\ }}}},
\\
, .{
target.os.version_range.semver.min.major,
target.os.version_range.semver.min.minor,
target.os.version_range.semver.min.patch,
target.os.version_range.semver.max.major,
target.os.version_range.semver.max.minor,
target.os.version_range.semver.max.patch,
}),
.linux => try os_builtin_str_buffer.outStream().print(
\\ .linux = .{{
\\ .range = .{{
\\ .min = .{{
\\ .major = {},
\\ .minor = {},
\\ .patch = {},
\\ }},
\\ .max = .{{
\\ .major = {},
\\ .minor = {},
\\ .patch = {},
\\ }},
\\ }},
\\ .glibc = .{{
\\ .major = {},
\\ .minor = {},
\\ .patch = {},
\\ }},
\\ }}}},
\\
, .{
target.os.version_range.linux.range.min.major,
target.os.version_range.linux.range.min.minor,
target.os.version_range.linux.range.min.patch,
target.os.version_range.linux.range.max.major,
target.os.version_range.linux.range.max.minor,
target.os.version_range.linux.range.max.patch,
target.os.version_range.linux.glibc.major,
target.os.version_range.linux.glibc.minor,
target.os.version_range.linux.glibc.patch,
}),
.windows => try os_builtin_str_buffer.outStream().print(
\\ .windows = .{{
\\ .min = {},
\\ .max = {},
\\ }}}},
\\
, .{
try enumToString(target.os.version_range.windows.min, "Target.Os.WindowsVersion"),
try enumToString(target.os.version_range.windows.max, "Target.Os.WindowsVersion"),
}),
}
try os_builtin_str_buffer.appendSlice("};\n");
try cache_hash.appendSlice(
os_builtin_str_buffer.span()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],
);
const glibc_or_darwin_version = blk: {
if (target.isGnuLibC()) {
const stage1_glibc = try std.heap.c_allocator.create(Stage2SemVer);
const stage2_glibc = target.os.version_range.linux.glibc;
stage1_glibc.* = .{
.major = stage2_glibc.major,
.minor = stage2_glibc.minor,
.patch = stage2_glibc.patch,
};
break :blk stage1_glibc;
} else if (target.isDarwin()) {
const stage1_semver = try std.heap.c_allocator.create(Stage2SemVer);
const stage2_semver = target.os.version_range.semver.min;
stage1_semver.* = .{
.major = stage2_semver.major,
.minor = stage2_semver.minor,
.patch = stage2_semver.patch,
};
break :blk stage1_semver;
} else {
break :blk null;
}
};
const std_dl = target.standardDynamicLinkerPath();
const std_dl_z = if (std_dl.get()) |dl|
(try mem.dupeZ(std.heap.c_allocator, u8, dl)).ptr
else
null;
const cache_hash_slice = cache_hash.toOwnedSlice();
const asm_features = asm_features_list.toOwnedSlice();
self.* = .{
.arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch
.vendor = 0,
.os = @enumToInt(target.os.tag),
.abi = @enumToInt(target.abi),
.llvm_cpu_name = if (target.cpu.model.llvm_name) |s| s.ptr else null,
.llvm_cpu_features = llvm_features_buffer.toOwnedSlice().ptr,
.llvm_cpu_features_asm_ptr = asm_features.ptr,
.llvm_cpu_features_asm_len = asm_features.len,
.cpu_builtin_str = cpu_builtin_str_buffer.toOwnedSlice().ptr,
.os_builtin_str = os_builtin_str_buffer.toOwnedSlice().ptr,
.cache_hash = cache_hash_slice.ptr,
.cache_hash_len = cache_hash_slice.len,
.is_native_os = cross_target.isNativeOs(),
.is_native_cpu = cross_target.isNativeCpu(),
.glibc_or_darwin_version = glibc_or_darwin_version,
.dynamic_linker = dynamic_linker,
.standard_dynamic_linker_path = std_dl_z,
};
}
};
fn enumInt(comptime Enum: type, int: c_int) Enum {
return @intToEnum(Enum, @intCast(@TagType(Enum), int));
}
fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8) !Target {
var info = try std.zig.system.NativeTargetInfo.detect(std.heap.c_allocator, cross_target);
if (info.cpu_detection_unimplemented) {
// TODO We want to just use detected_info.target but implementing
// CPU model & feature detection is todo so here we rely on LLVM.
const llvm = @import("llvm.zig");
const llvm_cpu_name = llvm.GetHostCPUName();
const llvm_cpu_features = llvm.GetNativeFeatures();
const arch = std.Target.current.cpu.arch;
info.target.cpu = try detectNativeCpuWithLLVM(arch, llvm_cpu_name, llvm_cpu_features);
cross_target.updateCpuFeatures(&info.target.cpu.features);
info.target.cpu.arch = cross_target.getCpuArch();
}
if (info.dynamic_linker.get()) |dl| {
dynamic_linker_ptr.* = try mem.dupeZ(std.heap.c_allocator, u8, dl);
} else {
dynamic_linker_ptr.* = null;
}
return info.target;
}
// ABI warning
const Stage2SemVer = extern struct {
major: u32,
minor: u32,
patch: u32,
};
// ABI warning
const Stage2NativePaths = extern struct {
include_dirs_ptr: [*][*:0]u8,
include_dirs_len: usize,
lib_dirs_ptr: [*][*:0]u8,
lib_dirs_len: usize,
rpaths_ptr: [*][*:0]u8,
rpaths_len: usize,
warnings_ptr: [*][*:0]u8,
warnings_len: usize,
};
// ABI warning
export fn stage2_detect_native_paths(stage1_paths: *Stage2NativePaths) Error {
stage2DetectNativePaths(stage1_paths) catch |err| switch (err) {
error.OutOfMemory => return .OutOfMemory,
};
return .None;
}
fn stage2DetectNativePaths(stage1_paths: *Stage2NativePaths) !void {
var paths = try std.zig.system.NativePaths.detect(std.heap.c_allocator);
errdefer paths.deinit();
try convertSlice(paths.include_dirs.span(), &stage1_paths.include_dirs_ptr, &stage1_paths.include_dirs_len);
try convertSlice(paths.lib_dirs.span(), &stage1_paths.lib_dirs_ptr, &stage1_paths.lib_dirs_len);
try convertSlice(paths.rpaths.span(), &stage1_paths.rpaths_ptr, &stage1_paths.rpaths_len);
try convertSlice(paths.warnings.span(), &stage1_paths.warnings_ptr, &stage1_paths.warnings_len);
}
fn convertSlice(slice: [][:0]u8, ptr: *[*][*:0]u8, len: *usize) !void {
len.* = slice.len;
const new_slice = try std.heap.c_allocator.alloc([*:0]u8, slice.len);
for (slice) |item, i| {
new_slice[i] = item.ptr;
}
ptr.* = new_slice.ptr;
}
const clang_args = @import("clang_options.zig").list;
// ABI warning
pub const ClangArgIterator = extern struct {
has_next: bool,
zig_equivalent: ZigEquivalent,
only_arg: [*:0]const u8,
second_arg: [*:0]const u8,
other_args_ptr: [*]const [*:0]const u8,
other_args_len: usize,
argv_ptr: [*]const [*:0]const u8,
argv_len: usize,
next_index: usize,
root_args: ?*Args,
// ABI warning
pub const ZigEquivalent = extern enum {
target,
o,
c,
other,
positional,
l,
ignore,
driver_punt,
pic,
no_pic,
nostdlib,
nostdlib_cpp,
shared,
rdynamic,
wl,
pp_or_asm,
optimize,
debug,
sanitize,
linker_script,
verbose_cmds,
for_linker,
linker_input_z,
lib_dir,
mcpu,
dep_file,
framework_dir,
framework,
nostdlibinc,
};
const Args = struct {
next_index: usize,
argv_ptr: [*]const [*:0]const u8,
argv_len: usize,
};
pub fn init(argv: []const [*:0]const u8) ClangArgIterator {
return .{
.next_index = 2, // `zig cc foo` this points to `foo`
.has_next = argv.len > 2,
.zig_equivalent = undefined,
.only_arg = undefined,
.second_arg = undefined,
.other_args_ptr = undefined,
.other_args_len = undefined,
.argv_ptr = argv.ptr,
.argv_len = argv.len,
.root_args = null,
};
}
pub fn next(self: *ClangArgIterator) !void {
assert(self.has_next);
assert(self.next_index < self.argv_len);
// In this state we know that the parameter we are looking at is a root parameter
// rather than an argument to a parameter.
self.other_args_ptr = self.argv_ptr + self.next_index;
self.other_args_len = 1; // We adjust this value below when necessary.
var arg = mem.span(self.argv_ptr[self.next_index]);
self.incrementArgIndex();
if (mem.startsWith(u8, arg, "@")) {
if (self.root_args != null) return error.NestedResponseFile;
// This is a "compiler response file". We must parse the file and treat its
// contents as command line parameters.
const allocator = std.heap.c_allocator;
const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit
const resp_file_path = arg[1..];
const resp_contents = fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes) catch |err| {
std.debug.warn("unable to read response file '{}': {}\n", .{ resp_file_path, @errorName(err) });
process.exit(1);
};
defer allocator.free(resp_contents);
// TODO is there a specification for this file format? Let's find it and make this parsing more robust
// at the very least I'm guessing this needs to handle quotes and `#` comments.
var it = mem.tokenize(resp_contents, " \t\r\n");
var resp_arg_list = std.ArrayList([*:0]const u8).init(allocator);
defer resp_arg_list.deinit();
{
errdefer {
for (resp_arg_list.span()) |item| {
allocator.free(mem.span(item));
}
}
while (it.next()) |token| {
const dupe_token = try mem.dupeZ(allocator, u8, token);
errdefer allocator.free(dupe_token);
try resp_arg_list.append(dupe_token);
}
const args = try allocator.create(Args);
errdefer allocator.destroy(args);
args.* = .{
.next_index = self.next_index,
.argv_ptr = self.argv_ptr,
.argv_len = self.argv_len,
};
self.root_args = args;
}
const resp_arg_slice = resp_arg_list.toOwnedSlice();
self.next_index = 0;
self.argv_ptr = resp_arg_slice.ptr;
self.argv_len = resp_arg_slice.len;
if (resp_arg_slice.len == 0) {
self.resolveRespFileArgs();
return;
}
self.has_next = true;
self.other_args_ptr = self.argv_ptr + self.next_index;
self.other_args_len = 1; // We adjust this value below when necessary.
arg = mem.span(self.argv_ptr[self.next_index]);
self.incrementArgIndex();
}
if (!mem.startsWith(u8, arg, "-")) {
self.zig_equivalent = .positional;
self.only_arg = arg.ptr;
return;
}
find_clang_arg: for (clang_args) |clang_arg| switch (clang_arg.syntax) {
.flag => {
const prefix_len = clang_arg.matchEql(arg);
if (prefix_len > 0) {
self.zig_equivalent = clang_arg.zig_equivalent;
self.only_arg = arg.ptr + prefix_len;
break :find_clang_arg;
}
},
.joined, .comma_joined => {
// joined example: --target=foo
// comma_joined example: -Wl,-soname,libsoundio.so.2
const prefix_len = clang_arg.matchStartsWith(arg);
if (prefix_len != 0) {
self.zig_equivalent = clang_arg.zig_equivalent;
self.only_arg = arg.ptr + prefix_len; // This will skip over the "--target=" part.
break :find_clang_arg;
}
},
.joined_or_separate => {
// Examples: `-lfoo`, `-l foo`
const prefix_len = clang_arg.matchStartsWith(arg);
if (prefix_len == arg.len) {
if (self.next_index >= self.argv_len) {
std.debug.warn("Expected parameter after '{}'\n", .{arg});
process.exit(1);
}
self.only_arg = self.argv_ptr[self.next_index];
self.incrementArgIndex();
self.other_args_len += 1;
self.zig_equivalent = clang_arg.zig_equivalent;
break :find_clang_arg;
} else if (prefix_len != 0) {
self.zig_equivalent = clang_arg.zig_equivalent;
self.only_arg = arg.ptr + prefix_len;
break :find_clang_arg;
}
},
.joined_and_separate => {
// Example: `-Xopenmp-target=riscv64-linux-unknown foo`
const prefix_len = clang_arg.matchStartsWith(arg);
if (prefix_len != 0) {
self.only_arg = arg.ptr + prefix_len;
if (self.next_index >= self.argv_len) {
std.debug.warn("Expected parameter after '{}'\n", .{arg});
process.exit(1);
}
self.second_arg = self.argv_ptr[self.next_index];
self.incrementArgIndex();
self.other_args_len += 1;
self.zig_equivalent = clang_arg.zig_equivalent;
break :find_clang_arg;
}
},
.separate => if (clang_arg.matchEql(arg) > 0) {
if (self.next_index >= self.argv_len) {
std.debug.warn("Expected parameter after '{}'\n", .{arg});
process.exit(1);
}
self.only_arg = self.argv_ptr[self.next_index];
self.incrementArgIndex();
self.other_args_len += 1;
self.zig_equivalent = clang_arg.zig_equivalent;
break :find_clang_arg;
},
.remaining_args_joined => {
const prefix_len = clang_arg.matchStartsWith(arg);
if (prefix_len != 0) {
@panic("TODO");
}
},
.multi_arg => if (clang_arg.matchEql(arg) > 0) {
@panic("TODO");
},
}
else {
std.debug.warn("Unknown Clang option: '{}'\n", .{arg});
process.exit(1);
}
}
fn incrementArgIndex(self: *ClangArgIterator) void {
self.next_index += 1;
self.resolveRespFileArgs();
}
fn resolveRespFileArgs(self: *ClangArgIterator) void {
const allocator = std.heap.c_allocator;
if (self.next_index >= self.argv_len) {
if (self.root_args) |root_args| {
self.next_index = root_args.next_index;
self.argv_ptr = root_args.argv_ptr;
self.argv_len = root_args.argv_len;
allocator.destroy(root_args);
self.root_args = null;
}
if (self.next_index >= self.argv_len) {
self.has_next = false;
}
}
}
};
export fn stage2_clang_arg_iterator(
result: *ClangArgIterator,
argc: usize,
argv: [*]const [*:0]const u8,
) void {
result.* = ClangArgIterator.init(argv[0..argc]);
}
export fn stage2_clang_arg_next(it: *ClangArgIterator) Error {
it.next() catch |err| switch (err) {
error.NestedResponseFile => return .NestedResponseFile,
error.OutOfMemory => return .OutOfMemory,
};
return .None;
} | src-self-hosted/stage2.zig |
const std = @import("std");
const mem = std.mem;
const expect = std.testing.expect;
const builtin = @import("builtin");
test "implicit cast vector to array - bool" {
const S = struct {
fn doTheTest() void {
const a: @Vector(4, bool) = [_]bool{ true, false, true, false };
const result_array: [4]bool = a;
expect(mem.eql(bool, result_array, [4]bool{ true, false, true, false }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector wrap operators" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };
expect(mem.eql(i32, @as([4]i32, v +% x), [4]i32{ -2147483648, 2147483645, 33, 44 }));
expect(mem.eql(i32, @as([4]i32, v -% x), [4]i32{ 2147483646, 2147483647, 27, 36 }));
expect(mem.eql(i32, @as([4]i32, v *% x), [4]i32{ 2147483647, 2, 90, 160 }));
var z: @Vector(4, i32) = [4]i32{ 1, 2, 3, -2147483648 };
expect(mem.eql(i32, @as([4]i32, -%z), [4]i32{ -1, -2, -3, -2147483648 }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector bin compares with mem.eql" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 30, 4 };
expect(mem.eql(bool, @as([4]bool, v == x), [4]bool{ false, false, true, false }));
expect(mem.eql(bool, @as([4]bool, v != x), [4]bool{ true, true, false, true }));
expect(mem.eql(bool, @as([4]bool, v < x), [4]bool{ false, true, false, false }));
expect(mem.eql(bool, @as([4]bool, v > x), [4]bool{ true, false, false, true }));
expect(mem.eql(bool, @as([4]bool, v <= x), [4]bool{ false, true, true, false }));
expect(mem.eql(bool, @as([4]bool, v >= x), [4]bool{ true, false, true, true }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector int operators" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [4]i32{ 10, 20, 30, 40 };
var x: @Vector(4, i32) = [4]i32{ 1, 2, 3, 4 };
expect(mem.eql(i32, @as([4]i32, v + x), [4]i32{ 11, 22, 33, 44 }));
expect(mem.eql(i32, @as([4]i32, v - x), [4]i32{ 9, 18, 27, 36 }));
expect(mem.eql(i32, @as([4]i32, v * x), [4]i32{ 10, 40, 90, 160 }));
expect(mem.eql(i32, @as([4]i32, -v), [4]i32{ -10, -20, -30, -40 }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector float operators" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, f32) = [4]f32{ 10, 20, 30, 40 };
var x: @Vector(4, f32) = [4]f32{ 1, 2, 3, 4 };
expect(mem.eql(f32, @as([4]f32, v + x), [4]f32{ 11, 22, 33, 44 }));
expect(mem.eql(f32, @as([4]f32, v - x), [4]f32{ 9, 18, 27, 36 }));
expect(mem.eql(f32, @as([4]f32, v * x), [4]f32{ 10, 40, 90, 160 }));
expect(mem.eql(f32, @as([4]f32, -x), [4]f32{ -1, -2, -3, -4 }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector bit operators" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, u8) = [4]u8{ 0b10101010, 0b10101010, 0b10101010, 0b10101010 };
var x: @Vector(4, u8) = [4]u8{ 0b11110000, 0b00001111, 0b10101010, 0b01010101 };
expect(mem.eql(u8, @as([4]u8, v ^ x), [4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 }));
expect(mem.eql(u8, @as([4]u8, v | x), [4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 }));
expect(mem.eql(u8, @as([4]u8, v & x), [4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "implicit cast vector to array" {
const S = struct {
fn doTheTest() void {
var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
var result_array: [4]i32 = a;
result_array = a;
expect(mem.eql(i32, result_array, [4]i32{ 1, 2, 3, 4 }));
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "array to vector" {
var foo: f32 = 3.14;
var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };
var vec: @Vector(4, f32) = arr;
}
test "vector casts of sizes not divisable by 8" {
// https://github.com/ziglang/zig/issues/3563
if (builtin.os == .dragonfly) return error.SkipZigTest;
const S = struct {
fn doTheTest() void {
{
var v: @Vector(4, u3) = [4]u3{ 5, 2, 3, 0 };
var x: [4]u3 = v;
expect(mem.eql(u3, x, @as([4]u3, v)));
}
{
var v: @Vector(4, u2) = [4]u2{ 1, 2, 3, 0 };
var x: [4]u2 = v;
expect(mem.eql(u2, x, @as([4]u2, v)));
}
{
var v: @Vector(4, u1) = [4]u1{ 1, 0, 1, 0 };
var x: [4]u1 = v;
expect(mem.eql(u1, x, @as([4]u1, v)));
}
{
var v: @Vector(4, bool) = [4]bool{ false, false, true, false };
var x: [4]bool = v;
expect(mem.eql(bool, x, @as([4]bool, v)));
}
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "vector @splat" {
const S = struct {
fn doTheTest() void {
var v: u32 = 5;
var x = @splat(4, v);
expect(@typeOf(x) == @Vector(4, u32));
var array_x: [4]u32 = x;
expect(array_x[0] == 5);
expect(array_x[1] == 5);
expect(array_x[2] == 5);
expect(array_x[3] == 5);
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "load vector elements via comptime index" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };
expect(v[0] == 1);
expect(v[1] == 2);
expect(loadv(&v[2]) == 3);
}
fn loadv(ptr: var) i32 {
return ptr.*;
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "store vector elements via comptime index" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
v[2] = 42;
expect(v[1] == 5);
v[3] = -364;
expect(v[2] == 42);
expect(-364 == v[3]);
storev(&v[0], 100);
expect(v[0] == 100);
}
fn storev(ptr: var, x: i32) void {
ptr.* = x;
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "load vector elements via runtime index" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };
var i: u32 = 0;
expect(v[i] == 1);
i += 1;
expect(v[i] == 2);
i += 1;
expect(v[i] == 3);
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "store vector elements via runtime index" {
const S = struct {
fn doTheTest() void {
var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
var i: u32 = 2;
v[i] = 1;
expect(v[1] == 5);
expect(v[2] == 1);
i += 1;
v[i] = -364;
expect(-364 == v[3]);
}
};
S.doTheTest();
comptime S.doTheTest();
}
test "initialize vector which is a struct field" {
const Vec4Obj = struct {
data: @Vector(4, f32),
};
const S = struct {
fn doTheTest() void {
var foo = Vec4Obj{
.data = [_]f32{ 1, 2, 3, 4 },
};
}
};
S.doTheTest();
comptime S.doTheTest();
} | test/stage1/behavior/vector.zig |
const std = @import("std");
const types = @import("types.zig");
const ast = std.zig.ast;
pub const Encoding = enum {
utf8,
utf16,
};
pub const DocumentPosition = struct {
line: []const u8,
line_index: usize,
absolute_index: usize,
};
pub fn documentPosition(doc: types.TextDocument, position: types.Position, encoding: Encoding) !DocumentPosition {
var split_iterator = std.mem.split(doc.text, "\n");
var line_idx: i64 = 0;
var line: []const u8 = "";
while (line_idx < position.line) : (line_idx += 1) {
line = split_iterator.next() orelse return error.InvalidParams;
}
const line_start_idx = split_iterator.index.?;
line = split_iterator.next() orelse return error.InvalidParams;
if (encoding == .utf8) {
const index = @intCast(i64, line_start_idx) + position.character;
if (index < 0 or index > @intCast(i64, doc.text.len)) {
return error.InvalidParams;
}
return DocumentPosition{ .line = line, .absolute_index = @intCast(usize, index), .line_index = @intCast(usize, position.character) };
} else {
const utf8 = doc.text[line_start_idx..];
var utf8_idx: usize = 0;
var utf16_idx: usize = 0;
while (utf16_idx < position.character) {
if (utf8_idx > utf8.len) {
return error.InvalidParams;
}
const n = try std.unicode.utf8ByteSequenceLength(utf8[utf8_idx]);
const next_utf8_idx = utf8_idx + n;
const codepoint = try std.unicode.utf8Decode(utf8[utf8_idx..next_utf8_idx]);
if (codepoint < 0x10000) {
utf16_idx += 1;
} else {
utf16_idx += 2;
}
utf8_idx = next_utf8_idx;
}
return DocumentPosition{ .line = line, .absolute_index = line_start_idx + utf8_idx, .line_index = utf8_idx };
}
}
pub const TokenLocation = struct {
line: usize,
column: usize,
offset: usize,
pub fn add(lhs: TokenLocation, rhs: TokenLocation) TokenLocation {
return .{
.line = lhs.line + rhs.line,
.column = if (rhs.line == 0)
lhs.column + rhs.column
else
rhs.column,
.offset = rhs.offset,
};
}
};
pub fn tokenRelativeLocation(tree: ast.Tree, start_index: usize, next_token_index: usize, encoding: Encoding) !TokenLocation {
const start = next_token_index;
var loc = TokenLocation{
.line = 0,
.column = 0,
.offset = 0,
};
const token_start = start;
const source = tree.source[start_index..];
var i: usize = 0;
while (i + start_index < token_start) {
const c = source[i];
if (c == '\n') {
loc.line += 1;
loc.column = 0;
i += 1;
} else {
if (encoding == .utf16) {
const n = try std.unicode.utf8ByteSequenceLength(c);
const codepoint = try std.unicode.utf8Decode(source[i .. i + n]);
if (codepoint < 0x10000) {
loc.column += 1;
} else {
loc.column += 2;
}
i += n;
} else {
loc.column += 1;
i += 1;
}
}
}
loc.offset = i + start_index;
return loc;
}
/// Asserts the token is comprised of valid utf8
pub fn tokenLength(tree: ast.Tree, token: ast.TokenIndex, encoding: Encoding) usize {
const token_loc = tokenLocation(tree, token);
if (encoding == .utf8)
return token_loc.end - token_loc.start;
var i: usize = token_loc.start;
var utf16_len: usize = 0;
while (i < token_loc.end) {
const n = std.unicode.utf8ByteSequenceLength(tree.source[i]) catch unreachable;
const codepoint = std.unicode.utf8Decode(tree.source[i .. i + n]) catch unreachable;
if (codepoint < 0x10000) {
utf16_len += 1;
} else {
utf16_len += 2;
}
i += n;
}
return utf16_len;
}
/// Token location inside source
pub const Loc = struct {
start: usize,
end: usize,
};
pub fn tokenLocation(tree: ast.Tree, token_index: ast.TokenIndex) Loc {
const start = tree.tokens.items(.start)[token_index];
const tag = tree.tokens.items(.tag)[token_index];
// For some tokens, re-tokenization is needed to find the end.
var tokenizer: std.zig.Tokenizer = .{
.buffer = tree.source,
.index = start,
.pending_invalid_token = null,
};
const token = tokenizer.next();
std.debug.assert(token.tag == tag);
return .{ .start = token.loc.start, .end = token.loc.end };
}
pub fn documentRange(doc: types.TextDocument, encoding: Encoding) !types.Range {
var line_idx: i64 = 0;
var curr_line: []const u8 = doc.text;
var split_iterator = std.mem.split(doc.text, "\n");
while (split_iterator.next()) |line| : (line_idx += 1) {
curr_line = line;
}
if (encoding == .utf8) {
return types.Range{
.start = .{
.line = 0,
.character = 0,
},
.end = .{
.line = line_idx,
.character = @intCast(i64, curr_line.len),
},
};
} else {
var utf16_len: usize = 0;
var line_utf8_idx: usize = 0;
while (line_utf8_idx < curr_line.len) {
const n = try std.unicode.utf8ByteSequenceLength(curr_line[line_utf8_idx]);
const codepoint = try std.unicode.utf8Decode(curr_line[line_utf8_idx .. line_utf8_idx + n]);
if (codepoint < 0x10000) {
utf16_len += 1;
} else {
utf16_len += 2;
}
line_utf8_idx += n;
}
return types.Range{
.start = .{
.line = 0,
.character = 0,
},
.end = .{
.line = line_idx,
.character = @intCast(i64, utf16_len),
},
};
}
} | src/offsets.zig |
const builtin = @import("builtin");
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
/// Returns x raised to the power of y (x^y).
///
/// Special Cases:
/// - pow(x, +-0) = 1 for any x
/// - pow(1, y) = 1 for any y
/// - pow(x, 1) = x for any x
/// - pow(nan, y) = nan
/// - pow(x, nan) = nan
/// - pow(+-0, y) = +-inf for y an odd integer < 0
/// - pow(+-0, -inf) = +inf
/// - pow(+-0, +inf) = +0
/// - pow(+-0, y) = +inf for finite y < 0 and not an odd integer
/// - pow(+-0, y) = +-0 for y an odd integer > 0
/// - pow(+-0, y) = +0 for finite y > 0 and not an odd integer
/// - pow(-1, +-inf) = 1
/// - pow(x, +inf) = +inf for |x| > 1
/// - pow(x, -inf) = +0 for |x| > 1
/// - pow(x, +inf) = +0 for |x| < 1
/// - pow(x, -inf) = +inf for |x| < 1
/// - pow(+inf, y) = +inf for y > 0
/// - pow(+inf, y) = +0 for y < 0
/// - pow(-inf, y) = pow(-0, -y)
/// - pow(x, y) = nan for finite x < 0 and finite non-integer y
pub fn pow(comptime T: type, x: T, y: T) T {
if (@typeInfo(T) == .Int) {
return math.powi(T, x, y) catch unreachable;
}
if (T != f32 and T != f64) {
@compileError("pow not implemented for " ++ @typeName(T));
}
// pow(x, +-0) = 1 for all x
// pow(1, y) = 1 for all y
if (y == 0 or x == 1) {
return 1;
}
// pow(nan, y) = nan for all y
// pow(x, nan) = nan for all x
if (math.isNan(x) or math.isNan(y)) {
return math.nan(T);
}
// pow(x, 1) = x for all x
if (y == 1) {
return x;
}
if (x == 0) {
if (y < 0) {
// pow(+-0, y) = +- 0 for y an odd integer
if (isOddInteger(y)) {
return math.copysign(T, math.inf(T), x);
}
// pow(+-0, y) = +inf for y an even integer
else {
return math.inf(T);
}
} else {
if (isOddInteger(y)) {
return x;
} else {
return 0;
}
}
}
if (math.isInf(y)) {
// pow(-1, inf) = 1 for all x
if (x == -1) {
return 1.0;
}
// pow(x, +inf) = +0 for |x| < 1
// pow(x, -inf) = +0 for |x| > 1
else if ((math.fabs(x) < 1) == math.isPositiveInf(y)) {
return 0;
}
// pow(x, -inf) = +inf for |x| < 1
// pow(x, +inf) = +inf for |x| > 1
else {
return math.inf(T);
}
}
if (math.isInf(x)) {
if (math.isNegativeInf(x)) {
return pow(T, 1 / x, -y);
}
// pow(+inf, y) = +0 for y < 0
else if (y < 0) {
return 0;
}
// pow(+inf, y) = +0 for y > 0
else if (y > 0) {
return math.inf(T);
}
}
// special case sqrt
if (y == 0.5) {
return math.sqrt(x);
}
if (y == -0.5) {
return 1 / math.sqrt(x);
}
const r1 = math.modf(math.fabs(y));
var yi = r1.ipart;
var yf = r1.fpart;
if (yf != 0 and x < 0) {
return math.nan(T);
}
if (yi >= 1 << (@typeInfo(T).Float.bits - 1)) {
return math.exp(y * math.ln(x));
}
// a = a1 * 2^ae
var a1: T = 1.0;
var ae: i32 = 0;
// a *= x^yf
if (yf != 0) {
if (yf > 0.5) {
yf -= 1;
yi += 1;
}
a1 = math.exp(yf * math.ln(x));
}
// a *= x^yi
const r2 = math.frexp(x);
var xe = r2.exponent;
var x1 = r2.significand;
var i = @floatToInt(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi);
while (i != 0) : (i >>= 1) {
const overflow_shift = math.floatExponentBits(T) + 1;
if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
// catch xe before it overflows the left shift below
// Since i != 0 it has at least one bit still set, so ae will accumulate xe
// on at least one more iteration, ae += xe is a lower bound on ae
// the lower bound on ae exceeds the size of a float exp
// so the final call to Ldexp will produce under/overflow (0/Inf)
ae += xe;
break;
}
if (i & 1 == 1) {
a1 *= x1;
ae += xe;
}
x1 *= x1;
xe <<= 1;
if (x1 < 0.5) {
x1 += x1;
xe -= 1;
}
}
// a *= a1 * 2^ae
if (y < 0) {
a1 = 1 / a1;
ae = -ae;
}
return math.scalbn(a1, ae);
}
fn isOddInteger(x: f64) bool {
const r = math.modf(x);
return r.fpart == 0.0 and @floatToInt(i64, r.ipart) & 1 == 1;
}
test "math.pow" {
const epsilon = 0.000001;
try expect(math.approxEqAbs(f32, pow(f32, 0.0, 3.3), 0.0, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, 0.8923, 3.3), 0.686572, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, 0.2, 3.3), 0.004936, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, 1.5, 3.3), 3.811546, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, 37.45, 3.3), 155736.703125, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, 89.123, 3.3), 2722489.5, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 0.0, 3.3), 0.0, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 0.8923, 3.3), 0.686572, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 0.2, 3.3), 0.004936, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 1.5, 3.3), 3.811546, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 37.45, 3.3), 155736.7160616, epsilon));
try expect(math.approxEqAbs(f64, pow(f64, 89.123, 3.3), 2722490.231436, epsilon));
}
test "math.pow.special" {
const epsilon = 0.000001;
try expect(pow(f32, 4, 0.0) == 1.0);
try expect(pow(f32, 7, -0.0) == 1.0);
try expect(pow(f32, 45, 1.0) == 45);
try expect(pow(f32, -45, 1.0) == -45);
try expect(math.isNan(pow(f32, math.nan(f32), 5.0)));
try expect(math.isPositiveInf(pow(f32, -math.inf(f32), 0.5)));
try expect(math.isPositiveInf(pow(f32, -0, -0.5)));
try expect(pow(f32, -0, 0.5) == 0);
try expect(math.isNan(pow(f32, 5.0, math.nan(f32))));
try expect(math.isPositiveInf(pow(f32, 0.0, -1.0)));
//expect(math.isNegativeInf(pow(f32, -0.0, -3.0))); TODO is this required?
try expect(math.isPositiveInf(pow(f32, 0.0, -math.inf(f32))));
try expect(math.isPositiveInf(pow(f32, -0.0, -math.inf(f32))));
try expect(pow(f32, 0.0, math.inf(f32)) == 0.0);
try expect(pow(f32, -0.0, math.inf(f32)) == 0.0);
try expect(math.isPositiveInf(pow(f32, 0.0, -2.0)));
try expect(math.isPositiveInf(pow(f32, -0.0, -2.0)));
try expect(pow(f32, 0.0, 1.0) == 0.0);
try expect(pow(f32, -0.0, 1.0) == -0.0);
try expect(pow(f32, 0.0, 2.0) == 0.0);
try expect(pow(f32, -0.0, 2.0) == 0.0);
try expect(math.approxEqAbs(f32, pow(f32, -1.0, math.inf(f32)), 1.0, epsilon));
try expect(math.approxEqAbs(f32, pow(f32, -1.0, -math.inf(f32)), 1.0, epsilon));
try expect(math.isPositiveInf(pow(f32, 1.2, math.inf(f32))));
try expect(math.isPositiveInf(pow(f32, -1.2, math.inf(f32))));
try expect(pow(f32, 1.2, -math.inf(f32)) == 0.0);
try expect(pow(f32, -1.2, -math.inf(f32)) == 0.0);
try expect(pow(f32, 0.2, math.inf(f32)) == 0.0);
try expect(pow(f32, -0.2, math.inf(f32)) == 0.0);
try expect(math.isPositiveInf(pow(f32, 0.2, -math.inf(f32))));
try expect(math.isPositiveInf(pow(f32, -0.2, -math.inf(f32))));
try expect(math.isPositiveInf(pow(f32, math.inf(f32), 1.0)));
try expect(pow(f32, math.inf(f32), -1.0) == 0.0);
//expect(pow(f32, -math.inf(f32), 5.0) == pow(f32, -0.0, -5.0)); TODO support negative 0?
try expect(pow(f32, -math.inf(f32), -5.2) == pow(f32, -0.0, 5.2));
try expect(math.isNan(pow(f32, -1.0, 1.2)));
try expect(math.isNan(pow(f32, -12.4, 78.5)));
}
test "math.pow.overflow" {
try expect(math.isPositiveInf(pow(f64, 2, 1 << 32)));
try expect(pow(f64, 2, -(1 << 32)) == 0);
try expect(math.isNegativeInf(pow(f64, -2, (1 << 32) + 1)));
try expect(pow(f64, 0.5, 1 << 45) == 0);
try expect(math.isPositiveInf(pow(f64, 0.5, -(1 << 45))));
} | lib/std/math/pow.zig |
const std = @import("std");
const mach = @import("mach");
const gpu = @import("gpu");
const glfw = @import("glfw");
const zm = @import("zmath");
const Vec = zm.Vec;
const Mat = zm.Mat;
const Quat = zm.Quat;
const App = @This();
queue: gpu.Queue,
cube: Cube,
camera: Camera,
light: Light,
depth: ?Texture,
keys: u8 = 0,
const Dir = struct {
const up: u8 = 0b0001;
const down: u8 = 0b0010;
const left: u8 = 0b0100;
const right: u8 = 0b1000;
};
pub fn init(app: *App, engine: *mach.Engine) !void {
try engine.core.setSizeLimits(.{ .width = 20, .height = 20 }, .{ .width = null, .height = null });
const eye = vec3(5.0, 7.0, 5.0);
const target = vec3(0.0, 0.0, 0.0);
const size = engine.core.getFramebufferSize();
const aspect_ratio = @intToFloat(f32, size.width) / @intToFloat(f32, size.height);
app.queue = engine.gpu_driver.device.getQueue();
app.cube = Cube.init(engine);
app.light = Light.init(engine);
app.depth = null;
app.camera = Camera.init(engine.gpu_driver.device, eye, target, vec3(0.0, 1.0, 0.0), aspect_ratio, 45.0, 0.1, 100.0);
}
pub fn deinit(app: *App, _: *mach.Engine) void {
app.depth.?.release();
}
pub fn update(app: *App, engine: *mach.Engine) !bool {
while (engine.core.pollEvent()) |event| {
switch (event) {
.key_press => |ev| switch (ev.key) {
.q, .escape, .space => engine.core.setShouldClose(true),
.w, .up => {
app.keys |= Dir.up;
},
.s, .down => {
app.keys |= Dir.down;
},
.a, .left => {
app.keys |= Dir.left;
},
.d, .right => {
app.keys |= Dir.right;
},
else => {},
},
.key_release => |ev| switch (ev.key) {
.w, .up => {
app.keys &= ~Dir.up;
},
.s, .down => {
app.keys &= ~Dir.down;
},
.a, .left => {
app.keys &= ~Dir.left;
},
.d, .right => {
app.keys &= ~Dir.right;
},
else => {},
},
}
}
// move camera
const speed = zm.f32x4s(@floatCast(f32, engine.delta_time * 5));
const fwd = zm.normalize3(app.camera.target - app.camera.eye);
const right = zm.normalize3(zm.cross3(fwd, app.camera.up));
if (app.keys & Dir.up != 0)
app.camera.eye += fwd * speed;
if (app.keys & Dir.down != 0)
app.camera.eye -= fwd * speed;
if (app.keys & Dir.right != 0) app.camera.eye += right * speed else if (app.keys & Dir.left != 0) app.camera.eye -= right * speed else app.camera.eye += right * (speed * @Vector(4, f32){ 0.5, 0.5, 0.5, 0.5 });
app.camera.update(app.queue);
// move light
const light_speed = @floatCast(f32, engine.delta_time * 2.5);
app.light.update(app.queue, light_speed);
const back_buffer_view = engine.gpu_driver.swap_chain.?.getCurrentTextureView();
defer back_buffer_view.release();
const encoder = engine.gpu_driver.device.createCommandEncoder(null);
defer encoder.release();
const color_attachment = gpu.RenderPassColorAttachment{
.view = back_buffer_view,
.clear_value = gpu.Color{ .r = 0.0, .g = 0.0, .b = 0.4, .a = 1.0 },
.load_op = .clear,
.store_op = .store,
};
const render_pass_descriptor = gpu.RenderPassEncoder.Descriptor{
.color_attachments = &.{color_attachment},
.depth_stencil_attachment = &.{
.view = app.depth.?.view,
.depth_load_op = .clear,
.depth_store_op = .store,
.stencil_load_op = .none,
.stencil_store_op = .none,
.depth_clear_value = 1.0,
},
};
const pass = encoder.beginRenderPass(&render_pass_descriptor);
defer pass.release();
// brick cubes
pass.setPipeline(app.cube.pipeline);
pass.setBindGroup(0, app.camera.bind_group, &.{});
pass.setBindGroup(1, app.cube.texture.bind_group, &.{});
pass.setBindGroup(2, app.light.bind_group, &.{});
pass.setVertexBuffer(0, app.cube.mesh.buffer, 0, app.cube.mesh.size);
pass.setVertexBuffer(1, app.cube.instance.buffer, 0, app.cube.instance.size);
pass.draw(4, app.cube.instance.len, 0, 0);
pass.draw(4, app.cube.instance.len, 4, 0);
pass.draw(4, app.cube.instance.len, 8, 0);
pass.draw(4, app.cube.instance.len, 12, 0);
pass.draw(4, app.cube.instance.len, 16, 0);
pass.draw(4, app.cube.instance.len, 20, 0);
// light source
pass.setPipeline(app.light.pipeline);
pass.setBindGroup(0, app.camera.bind_group, &.{});
pass.setBindGroup(1, app.light.bind_group, &.{});
pass.setVertexBuffer(0, app.cube.mesh.buffer, 0, app.cube.mesh.size);
pass.draw(4, 1, 0, 0);
pass.draw(4, 1, 4, 0);
pass.draw(4, 1, 8, 0);
pass.draw(4, 1, 12, 0);
pass.draw(4, 1, 16, 0);
pass.draw(4, 1, 20, 0);
pass.end();
var command = encoder.finish(null);
defer command.release();
app.queue.submit(&.{command});
engine.gpu_driver.swap_chain.?.present();
return true;
}
pub fn resize(app: *App, engine: *mach.Engine, width: u32, height: u32) !void {
// If window is resized, recreate depth buffer otherwise we cannot use it.
if (app.depth != null) {
app.depth.?.release();
}
// It also recreates the sampler, which is a waste, but for an example it's ok
app.depth = Texture.depth(engine.gpu_driver.device, width, height);
}
const Camera = struct {
const Self = @This();
eye: Vec,
target: Vec,
up: Vec,
aspect: f32,
fovy: f32,
near: f32,
far: f32,
bind_group: gpu.BindGroup,
buffer: Buffer,
const Uniform = struct {
pos: Vec,
mat: Mat,
};
fn init(device: gpu.Device, eye: Vec, target: Vec, up: Vec, aspect: f32, fovy: f32, near: f32, far: f32) Self {
var self: Self = .{
.eye = eye,
.target = target,
.up = up,
.aspect = aspect,
.near = near,
.far = far,
.fovy = fovy,
.buffer = undefined,
.bind_group = undefined,
};
const view = self.buildViewProjMatrix();
const uniform = .{
.pos = self.eye,
.mat = view,
};
const buffer = .{
.buffer = initBuffer(device, .{ .uniform = true }, &@bitCast([20]f32, uniform)),
.size = @sizeOf(@TypeOf(uniform)),
};
const bind_group = device.createBindGroup(&gpu.BindGroup.Descriptor{
.layout = Self.bindGroupLayout(device),
.entries = &[_]gpu.BindGroup.Entry{
gpu.BindGroup.Entry.buffer(0, buffer.buffer, 0, buffer.size),
},
});
self.buffer = buffer;
self.bind_group = bind_group;
return self;
}
fn update(self: *Self, queue: gpu.Queue) void {
const mat = self.buildViewProjMatrix();
const uniform = .{
.pos = self.eye,
.mat = mat,
};
queue.writeBuffer(self.buffer.buffer, 0, Uniform, &.{uniform});
}
inline fn buildViewProjMatrix(s: *const Camera) Mat {
const view = zm.lookAtRh(s.eye, s.target, s.up);
const proj = zm.perspectiveFovRh(s.fovy, s.aspect, s.near, s.far);
return zm.mul(view, proj);
}
inline fn bindGroupLayout(device: gpu.Device) gpu.BindGroupLayout {
const visibility = .{ .vertex = true, .fragment = true };
return device.createBindGroupLayout(&gpu.BindGroupLayout.Descriptor{
.entries = &[_]gpu.BindGroupLayout.Entry{
gpu.BindGroupLayout.Entry.buffer(0, visibility, .uniform, false, 0),
},
});
}
};
const Buffer = struct {
buffer: gpu.Buffer,
size: usize,
len: u32 = 0,
};
const Cube = struct {
const Self = @This();
pipeline: gpu.RenderPipeline,
mesh: Buffer,
instance: Buffer,
texture: Texture,
const IPR = 20; // instances per row
const SPACING = 2; // spacing between cubes
const DISPLACEMENT = vec3u(IPR * SPACING / 2, 0, IPR * SPACING / 2);
fn init(engine: *mach.Engine) Self {
const device = engine.gpu_driver.device;
const texture = Brick.texture(device);
// instance buffer
var ibuf: [IPR * IPR * 16]f32 = undefined;
var z: usize = 0;
while (z < IPR) : (z += 1) {
var x: usize = 0;
while (x < IPR) : (x += 1) {
const pos = vec3u(x * SPACING, 0, z * SPACING) - DISPLACEMENT;
const rot = blk: {
if (pos[0] == 0 and pos[2] == 0) {
break :blk zm.quatFromAxisAngle(vec3u(0, 0, 1), 0.0);
} else {
break :blk zm.quatFromAxisAngle(zm.normalize3(pos), 45.0);
}
};
const index = z * IPR + x;
const inst = Instance{
.position = pos,
.rotation = rot,
};
zm.storeMat(ibuf[index * 16 ..], inst.toMat());
}
}
const instance = Buffer{
.buffer = initBuffer(device, .{ .vertex = true }, &ibuf),
.len = IPR * IPR,
.size = @sizeOf(@TypeOf(ibuf)),
};
return Self{
.mesh = mesh(device),
.texture = texture,
.instance = instance,
.pipeline = pipeline(engine),
};
}
fn pipeline(engine: *mach.Engine) gpu.RenderPipeline {
const device = engine.gpu_driver.device;
const layout_descriptor = gpu.PipelineLayout.Descriptor{
.bind_group_layouts = &.{
Camera.bindGroupLayout(device),
Texture.bindGroupLayout(device),
Light.bindGroupLayout(device),
},
};
const layout = device.createPipelineLayout(&layout_descriptor);
defer layout.release();
const shader = device.createShaderModule(&.{
.code = .{ .wgsl = @embedFile("cube.wgsl") },
});
defer shader.release();
const blend = gpu.BlendState{
.color = .{
.operation = .add,
.src_factor = .one,
.dst_factor = .zero,
},
.alpha = .{
.operation = .add,
.src_factor = .one,
.dst_factor = .zero,
},
};
const color_target = gpu.ColorTargetState{
.format = engine.gpu_driver.swap_chain_format,
.write_mask = gpu.ColorWriteMask.all,
.blend = &blend,
};
const fragment = gpu.FragmentState{
.module = shader,
.entry_point = "fs_main",
.targets = &.{color_target},
.constants = null,
};
const descriptor = gpu.RenderPipeline.Descriptor{
.layout = layout,
.fragment = &fragment,
.vertex = .{
.module = shader,
.entry_point = "vs_main",
.buffers = &.{
Self.vertexBufferLayout(),
Self.instanceLayout(),
},
},
.depth_stencil = &.{
.format = Texture.DEPTH_FORMAT,
.depth_write_enabled = true,
.depth_compare = .less,
},
.primitive = .{
.front_face = .ccw,
.cull_mode = .back,
// .cull_mode = .none,
.topology = .triangle_strip,
.strip_index_format = .none,
},
};
return device.createRenderPipeline(&descriptor);
}
fn mesh(device: gpu.Device) Buffer {
// generated texture has aspect ratio of 1:2
// `h` reflects that ratio
// `v` sets how many times texture repeats across surface
const v = 2;
const h = v * 2;
const buf = asFloats(.{
// z+ face
0, 0, 1, 0, 0, 1, 0, h,
1, 0, 1, 0, 0, 1, v, h,
0, 1, 1, 0, 0, 1, 0, 0,
1, 1, 1, 0, 0, 1, v, 0,
// z- face
1, 0, 0, 0, 0, -1, 0, h,
0, 0, 0, 0, 0, -1, v, h,
1, 1, 0, 0, 0, -1, 0, 0,
0, 1, 0, 0, 0, -1, v, 0,
// x+ face
1, 0, 1, 1, 0, 0, 0, h,
1, 0, 0, 1, 0, 0, v, h,
1, 1, 1, 1, 0, 0, 0, 0,
1, 1, 0, 1, 0, 0, v, 0,
// x- face
0, 0, 0, -1, 0, 0, 0, h,
0, 0, 1, -1, 0, 0, v, h,
0, 1, 0, -1, 0, 0, 0, 0,
0, 1, 1, -1, 0, 0, v, 0,
// y+ face
1, 1, 0, 0, 1, 0, 0, h,
0, 1, 0, 0, 1, 0, v, h,
1, 1, 1, 0, 1, 0, 0, 0,
0, 1, 1, 0, 1, 0, v, 0,
// y- face
0, 0, 0, 0, -1, 0, 0, h,
1, 0, 0, 0, -1, 0, v, h,
0, 0, 1, 0, -1, 0, 0, 0,
1, 0, 1, 0, -1, 0, v, 0,
});
return Buffer{
.buffer = initBuffer(device, .{ .vertex = true }, &buf),
.size = @sizeOf(@TypeOf(buf)),
};
}
fn vertexBufferLayout() gpu.VertexBufferLayout {
const attributes = [_]gpu.VertexAttribute{
.{
.format = .float32x3,
.offset = 0,
.shader_location = 0,
},
.{
.format = .float32x3,
.offset = @sizeOf([3]f32),
.shader_location = 1,
},
.{
.format = .float32x2,
.offset = @sizeOf([6]f32),
.shader_location = 2,
},
};
return gpu.VertexBufferLayout{
.array_stride = @sizeOf([8]f32),
.step_mode = .vertex,
.attribute_count = attributes.len,
.attributes = &attributes,
};
}
fn instanceLayout() gpu.VertexBufferLayout {
const attributes = [_]gpu.VertexAttribute{
.{
.format = .float32x4,
.offset = 0,
.shader_location = 3,
},
.{
.format = .float32x4,
.offset = @sizeOf([4]f32),
.shader_location = 4,
},
.{
.format = .float32x4,
.offset = @sizeOf([8]f32),
.shader_location = 5,
},
.{
.format = .float32x4,
.offset = @sizeOf([12]f32),
.shader_location = 6,
},
};
return gpu.VertexBufferLayout{
.array_stride = @sizeOf([16]f32),
.step_mode = .instance,
.attribute_count = attributes.len,
.attributes = &attributes,
};
}
};
fn asFloats(comptime arr: anytype) [arr.len]f32 {
comptime var len = arr.len;
comptime var out: [len]f32 = undefined;
comptime var i = 0;
inline while (i < len) : (i += 1) {
out[i] = @intToFloat(f32, arr[i]);
}
return out;
}
const Brick = struct {
const W = 12;
const H = 6;
fn texture(device: gpu.Device) Texture {
const slice: []const u8 = &data();
return Texture.fromData(device, W, H, u8, slice);
}
fn data() [W * H * 4]u8 {
comptime var out: [W * H * 4]u8 = undefined;
// fill all the texture with brick color
comptime var i = 0;
inline while (i < H) : (i += 1) {
comptime var j = 0;
inline while (j < W * 4) : (j += 4) {
out[i * W * 4 + j + 0] = 210;
out[i * W * 4 + j + 1] = 30;
out[i * W * 4 + j + 2] = 30;
out[i * W * 4 + j + 3] = 0;
}
}
const f = 10;
// fill the cement lines
inline for ([_]comptime_int{ 0, 1 }) |k| {
inline for ([_]comptime_int{ 5 * 4, 11 * 4 }) |m| {
out[k * W * 4 + m + 0] = f;
out[k * W * 4 + m + 1] = f;
out[k * W * 4 + m + 2] = f;
out[k * W * 4 + m + 3] = 0;
}
}
inline for ([_]comptime_int{ 3, 4 }) |k| {
inline for ([_]comptime_int{ 2 * 4, 8 * 4 }) |m| {
out[k * W * 4 + m + 0] = f;
out[k * W * 4 + m + 1] = f;
out[k * W * 4 + m + 2] = f;
out[k * W * 4 + m + 3] = 0;
}
}
inline for ([_]comptime_int{ 2, 5 }) |k| {
comptime var m = 0;
inline while (m < W * 4) : (m += 4) {
out[k * W * 4 + m + 0] = f;
out[k * W * 4 + m + 1] = f;
out[k * W * 4 + m + 2] = f;
out[k * W * 4 + m + 3] = 0;
}
}
return out;
}
};
// don't confuse with gpu.Texture
const Texture = struct {
const Self = @This();
texture: gpu.Texture,
view: gpu.TextureView,
sampler: gpu.Sampler,
bind_group: gpu.BindGroup,
const DEPTH_FORMAT = .depth32_float;
const FORMAT = .rgba8_unorm;
fn release(self: *Self) void {
self.texture.release();
self.view.release();
self.sampler.release();
}
fn fromData(device: gpu.Device, width: u32, height: u32, comptime T: type, data: []const T) Self {
const extent = gpu.Extent3D{
.width = width,
.height = height,
};
const texture = device.createTexture(&gpu.Texture.Descriptor{
.size = extent,
.mip_level_count = 1,
.sample_count = 1,
.dimension = .dimension_2d,
.format = FORMAT,
.usage = .{ .copy_dst = true, .texture_binding = true },
});
const view = texture.createView(&gpu.TextureView.Descriptor{
.aspect = .all,
.format = FORMAT,
.dimension = .dimension_2d,
.base_array_layer = 0,
.array_layer_count = 1,
.mip_level_count = 1,
.base_mip_level = 0,
});
const sampler = device.createSampler(&gpu.Sampler.Descriptor{
.address_mode_u = .repeat,
.address_mode_v = .repeat,
.address_mode_w = .repeat,
.mag_filter = .linear,
.min_filter = .linear,
.mipmap_filter = .linear,
.compare = .none,
.lod_min_clamp = 0.0,
.lod_max_clamp = std.math.f32_max,
.max_anisotropy = 1, // 1,2,4,8,16
});
device.getQueue().writeTexture(
&gpu.ImageCopyTexture{
.texture = texture,
},
&gpu.Texture.DataLayout{
.bytes_per_row = 4 * width,
.rows_per_image = height,
},
&extent,
T,
data,
);
const bind_group_layout = Self.bindGroupLayout(device);
const bind_group = device.createBindGroup(&gpu.BindGroup.Descriptor{
.layout = bind_group_layout,
.entries = &[_]gpu.BindGroup.Entry{
gpu.BindGroup.Entry.textureView(0, view),
gpu.BindGroup.Entry.sampler(1, sampler),
},
});
return Self{
.view = view,
.texture = texture,
.sampler = sampler,
.bind_group = bind_group,
};
}
fn depth(device: gpu.Device, width: u32, height: u32) Self {
const extent = gpu.Extent3D{
.width = width,
.height = height,
};
const texture = device.createTexture(&gpu.Texture.Descriptor{
.size = extent,
.mip_level_count = 1,
.sample_count = 1,
.dimension = .dimension_2d,
.format = DEPTH_FORMAT,
.usage = .{
.render_attachment = true,
.texture_binding = true,
},
});
const view = texture.createView(&gpu.TextureView.Descriptor{
.aspect = .all,
.format = .none,
.dimension = .dimension_2d,
.base_array_layer = 0,
.array_layer_count = 1,
.mip_level_count = 1,
.base_mip_level = 0,
});
const sampler = device.createSampler(&gpu.Sampler.Descriptor{
.address_mode_u = .clamp_to_edge,
.address_mode_v = .clamp_to_edge,
.address_mode_w = .clamp_to_edge,
.mag_filter = .linear,
.min_filter = .nearest,
.mipmap_filter = .nearest,
.compare = .less_equal,
.lod_min_clamp = 0.0,
.lod_max_clamp = std.math.f32_max,
.max_anisotropy = 1,
});
return Self{
.texture = texture,
.view = view,
.sampler = sampler,
.bind_group = undefined, // not used
};
}
inline fn bindGroupLayout(device: gpu.Device) gpu.BindGroupLayout {
const visibility = .{ .fragment = true };
const Entry = gpu.BindGroupLayout.Entry;
return device.createBindGroupLayout(&gpu.BindGroupLayout.Descriptor{
.entries = &[_]Entry{
Entry.texture(0, visibility, .float, .dimension_2d, false),
Entry.sampler(1, visibility, .filtering),
},
});
}
};
const Light = struct {
const Self = @This();
uniform: Uniform,
buffer: Buffer,
bind_group: gpu.BindGroup,
pipeline: gpu.RenderPipeline,
const Uniform = struct {
position: Vec,
color: Vec,
};
fn init(engine: *mach.Engine) Self {
const device = engine.gpu_driver.device;
const uniform = .{
.color = vec3u(1, 1, 1),
.position = vec3u(3, 7, 2),
};
const buffer = .{
.buffer = initBuffer(device, .{ .uniform = true }, &@bitCast([8]f32, uniform)),
.size = @sizeOf(@TypeOf(uniform)),
};
const bind_group = device.createBindGroup(&gpu.BindGroup.Descriptor{
.layout = Self.bindGroupLayout(device),
.entries = &[_]gpu.BindGroup.Entry{
gpu.BindGroup.Entry.buffer(0, buffer.buffer, 0, buffer.size),
},
});
return Self{
.buffer = buffer,
.uniform = uniform,
.bind_group = bind_group,
.pipeline = Self.pipeline(engine),
};
}
fn update(self: *Self, queue: gpu.Queue, delta: f32) void {
const old = self.uniform;
const new = Light.Uniform{
.position = zm.qmul(zm.quatFromAxisAngle(vec3u(0, 1, 0), delta), old.position),
.color = old.color,
};
queue.writeBuffer(self.buffer.buffer, 0, Light.Uniform, &.{new});
self.uniform = new;
}
inline fn bindGroupLayout(device: gpu.Device) gpu.BindGroupLayout {
const visibility = .{ .vertex = true, .fragment = true };
const Entry = gpu.BindGroupLayout.Entry;
return device.createBindGroupLayout(&gpu.BindGroupLayout.Descriptor{
.entries = &[_]Entry{
Entry.buffer(0, visibility, .uniform, false, 0),
},
});
}
fn pipeline(engine: *mach.Engine) gpu.RenderPipeline {
const device = engine.gpu_driver.device;
const layout_descriptor = gpu.PipelineLayout.Descriptor{
.bind_group_layouts = &.{
Camera.bindGroupLayout(device),
Light.bindGroupLayout(device),
},
};
const layout = device.createPipelineLayout(&layout_descriptor);
defer layout.release();
const shader = device.createShaderModule(&.{
.code = .{ .wgsl = @embedFile("light.wgsl") },
});
defer shader.release();
const blend = gpu.BlendState{
.color = .{
.operation = .add,
.src_factor = .one,
.dst_factor = .zero,
},
.alpha = .{
.operation = .add,
.src_factor = .one,
.dst_factor = .zero,
},
};
const color_target = gpu.ColorTargetState{
.format = engine.gpu_driver.swap_chain_format,
.write_mask = gpu.ColorWriteMask.all,
.blend = &blend,
};
const fragment = gpu.FragmentState{
.module = shader,
.entry_point = "fs_main",
.targets = &.{color_target},
.constants = null,
};
const descriptor = gpu.RenderPipeline.Descriptor{
.layout = layout,
.fragment = &fragment,
.vertex = .{
.module = shader,
.entry_point = "vs_main",
.buffers = &.{
Cube.vertexBufferLayout(),
},
},
.depth_stencil = &.{
.format = Texture.DEPTH_FORMAT,
.depth_write_enabled = true,
.depth_compare = .less,
},
.primitive = .{
.front_face = .ccw,
.cull_mode = .back,
// .cull_mode = .none,
.topology = .triangle_strip,
.strip_index_format = .none,
},
};
return device.createRenderPipeline(&descriptor);
}
};
inline fn initBuffer(device: gpu.Device, usage: gpu.BufferUsage, data: anytype) gpu.Buffer {
std.debug.assert(@typeInfo(@TypeOf(data)) == .Pointer);
const T = std.meta.Elem(@TypeOf(data));
var u = usage;
u.copy_dst = true;
const buffer = device.createBuffer(&.{
.size = @sizeOf(T) * data.len,
.usage = u,
.mapped_at_creation = true,
});
var mapped = buffer.getMappedRange(T, 0, data.len);
std.mem.copy(T, mapped, data);
buffer.unmap();
return buffer;
}
fn vec3i(x: isize, y: isize, z: isize) Vec {
return zm.f32x4(@intToFloat(f32, x), @intToFloat(f32, y), @intToFloat(f32, z), 0.0);
}
fn vec3u(x: usize, y: usize, z: usize) Vec {
return zm.f32x4(@intToFloat(f32, x), @intToFloat(f32, y), @intToFloat(f32, z), 0.0);
}
fn vec3(x: f32, y: f32, z: f32) Vec {
return zm.f32x4(x, y, z, 0.0);
}
fn vec4(x: f32, y: f32, z: f32, w: f32) Vec {
return zm.f32x4(x, y, z, w);
}
// todo indside Cube
const Instance = struct {
const Self = @This();
position: Vec,
rotation: Quat,
fn toMat(self: *const Self) Mat {
return zm.mul(zm.quatToMat(self.rotation), zm.translationV(self.position));
}
}; | examples/advanced-gen-texture-light/main.zig |
const aoc = @import("../aoc.zig");
const std = @import("std");
pub fn run(problem: *aoc.Problem) !aoc.Solution {
var easy_digs: usize = 0;
var sum: usize = 0;
while (problem.line()) |line| {
var unprocessed_digits = [_]u7 {0} ** 6;
var definite_digits = [_]u7 {0} ** 10;
var tokens = std.mem.tokenize(u8, line, " ");
var unprocessed_digits_idx: u8 = 0;
while (tokens.next()) |token| {
if (token[0] == '|') {
break;
}
const bitmask = segmentToBitmask(token);
switch (token.len) {
2 => definite_digits[1] = bitmask,
3 => definite_digits[7] = bitmask,
4 => definite_digits[4] = bitmask,
7 => definite_digits[8] = bitmask,
else => {
unprocessed_digits[unprocessed_digits_idx] = bitmask;
unprocessed_digits_idx += 1;
}
}
}
blk: while (true) {
unprocessed_digits_idx = 0;
while (unprocessed_digits_idx < unprocessed_digits.len) : (unprocessed_digits_idx += 1) {
const dig = unprocessed_digits[unprocessed_digits_idx];
if (dig == 0) {
continue;
}
if (definite_digits[9] != 0) {
if (@popCount(u7, dig) == 5) {
if (dig & definite_digits[9] != dig) {
definite_digits[2] = dig;
}
else if (dig & definite_digits[1] == definite_digits[1]) {
definite_digits[3] = dig;
}
else {
definite_digits[5] = dig;
}
unprocessed_digits[unprocessed_digits_idx] = 0;
continue :blk;
}
if (definite_digits[5] != 0) {
if (dig & definite_digits[5] == definite_digits[5]) {
definite_digits[6] = dig;
}
else {
definite_digits[0] = dig;
}
unprocessed_digits[unprocessed_digits_idx] = 0;
continue :blk;
}
}
else {
const four_seven = definite_digits[4] | definite_digits[7];
if (four_seven & dig == four_seven) {
definite_digits[9] = dig;
unprocessed_digits[unprocessed_digits_idx] = 0;
continue :blk;
}
}
}
break;
}
var output: usize = 0;
while (tokens.next()) |token| {
const bitmask = segmentToBitmask(token);
const n = blk: {
for (definite_digits) |dd, idx| {
if (bitmask == dd) {
break :blk idx;
}
}
unreachable;
};
output = output * 10 + n;
switch (token.len) {
2, 3, 4, 7 => easy_digs += 1,
else => {}
}
}
sum += output;
}
return problem.solution(easy_digs, sum);
}
fn segmentToBitmask(segment: []const u8) u7 {
var bitmask: u7 = 0;
for (segment) |s| {
bitmask |= @intCast(u7, 1) << @intCast(u3, s - 'a');
}
return bitmask;
} | src/main/zig/2021/day08.zig |
const os = @cImport({
@cInclude("FreeRTOS.h");
@cInclude("task.h");
});
const tzmcfi = @cImport(@cInclude("TZmCFI/Gateway.h"));
const port = @import("../ports/" ++ @import("build_options").BOARD ++ "/common.zig");
export const SystemCoreClock: u32 = port.system_core_clock;
// `SecureContext_LoadContext`
comptime {
if (@import("build_options").HAS_TZMCFI_CTX) {
// Call `TCActivateThread` to switch contexts. This has to be a tail
// call so that we don't need to spill `lr`. The reason is that we
// must not have shadow stack entries for the current interrupt
// handling context at the point of calling `TCActivateThread`,
// because the destination shadow stack does not have those entries and
// subsequent shadow assert operations will fail.
asm (
\\ .syntax unified
\\ .thumb
\\ .cpu cortex-m33
\\ .type SecureContext_LoadContext function
\\ .global SecureContext_LoadContext
\\ SecureContext_LoadContext:
\\ b TCActivateThread
\\ // result is ignored, sad
);
} else {
// TZmCFI is disabled, ignore the call
asm (
\\ .syntax unified
\\ .thumb
\\ .cpu cortex-m33
\\ .type SecureContext_LoadContext function
\\ .global SecureContext_LoadContext
\\ SecureContext_LoadContext:
\\ bx lr
);
}
}
export fn SecureContext_SaveContext() void {}
export fn SecureContext_Init() void {}
export fn SecureContext_FreeContext(contextId: i32) void {
// Can't delete a thread for now :(
}
export fn SecureContext_AllocateContext(contextId: u32, taskPrivileged: u32, pc: usize, lr: usize, exc_return: usize, frame: usize) u32 {
if (!@import("build_options").HAS_TZMCFI_CTX) {
// TZmCFI is disabled, ignore the call
return 0;
}
_ = taskPrivileged;
const create_info = tzmcfi.TCThreadCreateInfo{
.flags = .None,
.stackSize = 4, // unused for now
.initialPC = pc,
.initialLR = lr,
.excReturn = exc_return,
.exceptionFrame = frame,
};
var thread: tzmcfi.TCThread = undefined;
const result = tzmcfi.TCCreateThread(&create_info, &thread);
if (result != .TC_RESULT_SUCCESS) {
@panic("TCCreateThread failed");
}
return thread;
}
export fn SecureInit_DePrioritizeNSExceptions() void {}
/// Stack overflow hook.
export fn vApplicationStackOverflowHook(xTask: os.TaskHandle_t, pcTaskName: *[*]const u8) void {
@panic("stack overflow");
} | examples/nonsecure-common/oshooks.zig |
const std = @import("std");
const c = @import("c.zig");
// The Debounce struct is triggered with update(dt). After dt milliseconds,
// a call to check() returns true. Intermediate calls to update() will restart
// the timer and change the value which will eventually be returned by check().
pub const Debounce = struct {
const Self = @This();
thread: ?std.Thread,
// The mutex protects all of the variables below
mutex: std.Thread.Mutex,
end_time_ms: i64,
thread_running: bool,
done: bool,
pub fn init() Self {
return Self{
.mutex = std.Thread.Mutex{},
.end_time_ms = 0,
.thread = null,
.thread_running = false,
.done = false,
};
}
fn run(self: *Self) void {
while (true) {
const lock = self.mutex.acquire();
const now_time = std.time.milliTimestamp();
if (now_time >= self.end_time_ms) {
self.done = true;
self.thread_running = false;
lock.release();
break;
} else {
const dt = self.end_time_ms - now_time;
lock.release();
std.time.sleep(@intCast(u64, dt) * 1000 * 1000);
}
}
c.glfwPostEmptyEvent();
}
// After dt nanoseconds have elapsed, a call to check() will return
// the value v (unless another call to update happens, which will
// reset the timer).
pub fn update(self: *Self, dt_ms: i64) !void {
const lock = self.mutex.acquire();
defer lock.release();
self.done = false;
self.end_time_ms = std.time.milliTimestamp() + dt_ms;
if (!self.thread_running) {
if (self.thread) |thread| {
thread.join();
}
self.thread = try std.Thread.spawn(.{}, Self.run, .{self});
self.thread_running = true;
} else {
// The already-running thread will handle it
}
}
pub fn check(self: *Self) bool {
const lock = self.mutex.acquire();
defer lock.release();
const out = self.done;
self.done = false;
return out;
}
}; | src/debounce.zig |
const std = @import("std");
const mem = std.mem;
allocator: *mem.Allocator,
map: std.AutoHashMap(u21, u8),
const CccMap = @This();
pub fn init(allocator: *mem.Allocator) !CccMap {
var instance = CccMap{
.allocator = allocator,
.map = std.AutoHashMap(u21, u8).init(allocator),
};
var index: u21 = 0;
index = 0x0334;
while (index <= 0x0338) : (index += 1) {
try instance.map.put(index, 1);
}
try instance.map.put(0x1CD4, 1);
index = 0x1CE2;
while (index <= 0x1CE8) : (index += 1) {
try instance.map.put(index, 1);
}
index = 0x20D2;
while (index <= 0x20D3) : (index += 1) {
try instance.map.put(index, 1);
}
index = 0x20D8;
while (index <= 0x20DA) : (index += 1) {
try instance.map.put(index, 1);
}
index = 0x20E5;
while (index <= 0x20E6) : (index += 1) {
try instance.map.put(index, 1);
}
index = 0x20EA;
while (index <= 0x20EB) : (index += 1) {
try instance.map.put(index, 1);
}
try instance.map.put(0x10A39, 1);
index = 0x16AF0;
while (index <= 0x16AF4) : (index += 1) {
try instance.map.put(index, 1);
}
try instance.map.put(0x1BC9E, 1);
index = 0x1D167;
while (index <= 0x1D169) : (index += 1) {
try instance.map.put(index, 1);
}
index = 0x16FF0;
while (index <= 0x16FF1) : (index += 1) {
try instance.map.put(index, 6);
}
try instance.map.put(0x093C, 7);
try instance.map.put(0x09BC, 7);
try instance.map.put(0x0A3C, 7);
try instance.map.put(0x0ABC, 7);
try instance.map.put(0x0B3C, 7);
try instance.map.put(0x0CBC, 7);
try instance.map.put(0x1037, 7);
try instance.map.put(0x1B34, 7);
try instance.map.put(0x1BE6, 7);
try instance.map.put(0x1C37, 7);
try instance.map.put(0xA9B3, 7);
try instance.map.put(0x110BA, 7);
try instance.map.put(0x11173, 7);
try instance.map.put(0x111CA, 7);
try instance.map.put(0x11236, 7);
try instance.map.put(0x112E9, 7);
index = 0x1133B;
while (index <= 0x1133C) : (index += 1) {
try instance.map.put(index, 7);
}
try instance.map.put(0x11446, 7);
try instance.map.put(0x114C3, 7);
try instance.map.put(0x115C0, 7);
try instance.map.put(0x116B7, 7);
try instance.map.put(0x1183A, 7);
try instance.map.put(0x11943, 7);
try instance.map.put(0x11D42, 7);
try instance.map.put(0x1E94A, 7);
index = 0x3099;
while (index <= 0x309A) : (index += 1) {
try instance.map.put(index, 8);
}
try instance.map.put(0x094D, 9);
try instance.map.put(0x09CD, 9);
try instance.map.put(0x0A4D, 9);
try instance.map.put(0x0ACD, 9);
try instance.map.put(0x0B4D, 9);
try instance.map.put(0x0BCD, 9);
try instance.map.put(0x0C4D, 9);
try instance.map.put(0x0CCD, 9);
index = 0x0D3B;
while (index <= 0x0D3C) : (index += 1) {
try instance.map.put(index, 9);
}
try instance.map.put(0x0D4D, 9);
try instance.map.put(0x0DCA, 9);
try instance.map.put(0x0E3A, 9);
try instance.map.put(0x0EBA, 9);
try instance.map.put(0x0F84, 9);
index = 0x1039;
while (index <= 0x103A) : (index += 1) {
try instance.map.put(index, 9);
}
try instance.map.put(0x1714, 9);
try instance.map.put(0x1734, 9);
try instance.map.put(0x17D2, 9);
try instance.map.put(0x1A60, 9);
try instance.map.put(0x1B44, 9);
try instance.map.put(0x1BAA, 9);
try instance.map.put(0x1BAB, 9);
index = 0x1BF2;
while (index <= 0x1BF3) : (index += 1) {
try instance.map.put(index, 9);
}
try instance.map.put(0x2D7F, 9);
try instance.map.put(0xA806, 9);
try instance.map.put(0xA82C, 9);
try instance.map.put(0xA8C4, 9);
try instance.map.put(0xA953, 9);
try instance.map.put(0xA9C0, 9);
try instance.map.put(0xAAF6, 9);
try instance.map.put(0xABED, 9);
try instance.map.put(0x10A3F, 9);
try instance.map.put(0x11046, 9);
try instance.map.put(0x1107F, 9);
try instance.map.put(0x110B9, 9);
index = 0x11133;
while (index <= 0x11134) : (index += 1) {
try instance.map.put(index, 9);
}
try instance.map.put(0x111C0, 9);
try instance.map.put(0x11235, 9);
try instance.map.put(0x112EA, 9);
try instance.map.put(0x1134D, 9);
try instance.map.put(0x11442, 9);
try instance.map.put(0x114C2, 9);
try instance.map.put(0x115BF, 9);
try instance.map.put(0x1163F, 9);
try instance.map.put(0x116B6, 9);
try instance.map.put(0x1172B, 9);
try instance.map.put(0x11839, 9);
try instance.map.put(0x1193D, 9);
try instance.map.put(0x1193E, 9);
try instance.map.put(0x119E0, 9);
try instance.map.put(0x11A34, 9);
try instance.map.put(0x11A47, 9);
try instance.map.put(0x11A99, 9);
try instance.map.put(0x11C3F, 9);
index = 0x11D44;
while (index <= 0x11D45) : (index += 1) {
try instance.map.put(index, 9);
}
try instance.map.put(0x11D97, 9);
try instance.map.put(0x05B0, 10);
try instance.map.put(0x05B1, 11);
try instance.map.put(0x05B2, 12);
try instance.map.put(0x05B3, 13);
try instance.map.put(0x05B4, 14);
try instance.map.put(0x05B5, 15);
try instance.map.put(0x05B6, 16);
try instance.map.put(0x05B7, 17);
try instance.map.put(0x05B8, 18);
try instance.map.put(0x05C7, 18);
index = 0x05B9;
while (index <= 0x05BA) : (index += 1) {
try instance.map.put(index, 19);
}
try instance.map.put(0x05BB, 20);
try instance.map.put(0x05BC, 21);
try instance.map.put(0x05BD, 22);
try instance.map.put(0x05BF, 23);
try instance.map.put(0x05C1, 24);
try instance.map.put(0x05C2, 25);
try instance.map.put(0xFB1E, 26);
try instance.map.put(0x064B, 27);
try instance.map.put(0x08F0, 27);
try instance.map.put(0x064C, 28);
try instance.map.put(0x08F1, 28);
try instance.map.put(0x064D, 29);
try instance.map.put(0x08F2, 29);
try instance.map.put(0x0618, 30);
try instance.map.put(0x064E, 30);
try instance.map.put(0x0619, 31);
try instance.map.put(0x064F, 31);
try instance.map.put(0x061A, 32);
try instance.map.put(0x0650, 32);
try instance.map.put(0x0651, 33);
try instance.map.put(0x0652, 34);
try instance.map.put(0x0670, 35);
try instance.map.put(0x0711, 36);
try instance.map.put(0x0C55, 84);
try instance.map.put(0x0C56, 91);
index = 0x0E38;
while (index <= 0x0E39) : (index += 1) {
try instance.map.put(index, 103);
}
index = 0x0E48;
while (index <= 0x0E4B) : (index += 1) {
try instance.map.put(index, 107);
}
index = 0x0EB8;
while (index <= 0x0EB9) : (index += 1) {
try instance.map.put(index, 118);
}
index = 0x0EC8;
while (index <= 0x0ECB) : (index += 1) {
try instance.map.put(index, 122);
}
try instance.map.put(0x0F71, 129);
try instance.map.put(0x0F72, 130);
index = 0x0F7A;
while (index <= 0x0F7D) : (index += 1) {
try instance.map.put(index, 130);
}
try instance.map.put(0x0F80, 130);
try instance.map.put(0x0F74, 132);
index = 0x0321;
while (index <= 0x0322) : (index += 1) {
try instance.map.put(index, 202);
}
index = 0x0327;
while (index <= 0x0328) : (index += 1) {
try instance.map.put(index, 202);
}
try instance.map.put(0x1DD0, 202);
try instance.map.put(0x1DCE, 214);
try instance.map.put(0x031B, 216);
try instance.map.put(0x0F39, 216);
index = 0x1D165;
while (index <= 0x1D166) : (index += 1) {
try instance.map.put(index, 216);
}
index = 0x1D16E;
while (index <= 0x1D172) : (index += 1) {
try instance.map.put(index, 216);
}
try instance.map.put(0x302A, 218);
index = 0x0316;
while (index <= 0x0319) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x031C;
while (index <= 0x0320) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0323;
while (index <= 0x0326) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0329;
while (index <= 0x0333) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0339;
while (index <= 0x033C) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0347;
while (index <= 0x0349) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x034D;
while (index <= 0x034E) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0353;
while (index <= 0x0356) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x0359;
while (index <= 0x035A) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x0591, 220);
try instance.map.put(0x0596, 220);
try instance.map.put(0x059B, 220);
index = 0x05A2;
while (index <= 0x05A7) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x05AA, 220);
try instance.map.put(0x05C5, 220);
index = 0x0655;
while (index <= 0x0656) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x065C, 220);
try instance.map.put(0x065F, 220);
try instance.map.put(0x06E3, 220);
try instance.map.put(0x06EA, 220);
try instance.map.put(0x06ED, 220);
try instance.map.put(0x0731, 220);
try instance.map.put(0x0734, 220);
index = 0x0737;
while (index <= 0x0739) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x073B;
while (index <= 0x073C) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x073E, 220);
try instance.map.put(0x0742, 220);
try instance.map.put(0x0744, 220);
try instance.map.put(0x0746, 220);
try instance.map.put(0x0748, 220);
try instance.map.put(0x07F2, 220);
try instance.map.put(0x07FD, 220);
index = 0x0859;
while (index <= 0x085B) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x08D3, 220);
try instance.map.put(0x08E3, 220);
try instance.map.put(0x08E6, 220);
try instance.map.put(0x08E9, 220);
index = 0x08ED;
while (index <= 0x08EF) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x08F6, 220);
index = 0x08F9;
while (index <= 0x08FA) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x0952, 220);
index = 0x0F18;
while (index <= 0x0F19) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x0F35, 220);
try instance.map.put(0x0F37, 220);
try instance.map.put(0x0FC6, 220);
try instance.map.put(0x108D, 220);
try instance.map.put(0x193B, 220);
try instance.map.put(0x1A18, 220);
try instance.map.put(0x1A7F, 220);
index = 0x1AB5;
while (index <= 0x1ABA) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x1ABD, 220);
index = 0x1ABF;
while (index <= 0x1AC0) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x1B6C, 220);
index = 0x1CD5;
while (index <= 0x1CD9) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x1CDC;
while (index <= 0x1CDF) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x1CED, 220);
try instance.map.put(0x1DC2, 220);
try instance.map.put(0x1DCA, 220);
try instance.map.put(0x1DCF, 220);
try instance.map.put(0x1DF9, 220);
try instance.map.put(0x1DFD, 220);
try instance.map.put(0x1DFF, 220);
try instance.map.put(0x20E8, 220);
index = 0x20EC;
while (index <= 0x20EF) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0xA92B;
while (index <= 0xA92D) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0xAAB4, 220);
index = 0xFE27;
while (index <= 0xFE2D) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x101FD, 220);
try instance.map.put(0x102E0, 220);
try instance.map.put(0x10A0D, 220);
try instance.map.put(0x10A3A, 220);
try instance.map.put(0x10AE6, 220);
index = 0x10F46;
while (index <= 0x10F47) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x10F4B, 220);
index = 0x10F4D;
while (index <= 0x10F50) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x1D17B;
while (index <= 0x1D182) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x1D18A;
while (index <= 0x1D18B) : (index += 1) {
try instance.map.put(index, 220);
}
index = 0x1E8D0;
while (index <= 0x1E8D6) : (index += 1) {
try instance.map.put(index, 220);
}
try instance.map.put(0x059A, 222);
try instance.map.put(0x05AD, 222);
try instance.map.put(0x1939, 222);
try instance.map.put(0x302D, 222);
index = 0x302E;
while (index <= 0x302F) : (index += 1) {
try instance.map.put(index, 224);
}
try instance.map.put(0x1D16D, 226);
try instance.map.put(0x05AE, 228);
try instance.map.put(0x18A9, 228);
index = 0x1DF7;
while (index <= 0x1DF8) : (index += 1) {
try instance.map.put(index, 228);
}
try instance.map.put(0x302B, 228);
index = 0x0300;
while (index <= 0x0314) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x033D;
while (index <= 0x0344) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0346, 230);
index = 0x034A;
while (index <= 0x034C) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0350;
while (index <= 0x0352) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0357, 230);
try instance.map.put(0x035B, 230);
index = 0x0363;
while (index <= 0x036F) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0483;
while (index <= 0x0487) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0592;
while (index <= 0x0595) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0597;
while (index <= 0x0599) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x059C;
while (index <= 0x05A1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x05A8;
while (index <= 0x05A9) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x05AB;
while (index <= 0x05AC) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x05AF, 230);
try instance.map.put(0x05C4, 230);
index = 0x0610;
while (index <= 0x0617) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0653;
while (index <= 0x0654) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0657;
while (index <= 0x065B) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x065D;
while (index <= 0x065E) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x06D6;
while (index <= 0x06DC) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x06DF;
while (index <= 0x06E2) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x06E4, 230);
index = 0x06E7;
while (index <= 0x06E8) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x06EB;
while (index <= 0x06EC) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0730, 230);
index = 0x0732;
while (index <= 0x0733) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0735;
while (index <= 0x0736) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x073A, 230);
try instance.map.put(0x073D, 230);
index = 0x073F;
while (index <= 0x0741) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0743, 230);
try instance.map.put(0x0745, 230);
try instance.map.put(0x0747, 230);
index = 0x0749;
while (index <= 0x074A) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x07EB;
while (index <= 0x07F1) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x07F3, 230);
index = 0x0816;
while (index <= 0x0819) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x081B;
while (index <= 0x0823) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0825;
while (index <= 0x0827) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0829;
while (index <= 0x082D) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08D4;
while (index <= 0x08E1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08E4;
while (index <= 0x08E5) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08E7;
while (index <= 0x08E8) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08EA;
while (index <= 0x08EC) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08F3;
while (index <= 0x08F5) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08F7;
while (index <= 0x08F8) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x08FB;
while (index <= 0x08FF) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0951, 230);
index = 0x0953;
while (index <= 0x0954) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x09FE, 230);
index = 0x0F82;
while (index <= 0x0F83) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x0F86;
while (index <= 0x0F87) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x135D;
while (index <= 0x135F) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x17DD, 230);
try instance.map.put(0x193A, 230);
try instance.map.put(0x1A17, 230);
index = 0x1A75;
while (index <= 0x1A7C) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1AB0;
while (index <= 0x1AB4) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1ABB;
while (index <= 0x1ABC) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x1B6B, 230);
index = 0x1B6D;
while (index <= 0x1B73) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1CD0;
while (index <= 0x1CD2) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1CDA;
while (index <= 0x1CDB) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x1CE0, 230);
try instance.map.put(0x1CF4, 230);
index = 0x1CF8;
while (index <= 0x1CF9) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1DC0;
while (index <= 0x1DC1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1DC3;
while (index <= 0x1DC9) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1DCB;
while (index <= 0x1DCC) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1DD1;
while (index <= 0x1DF5) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x1DFB, 230);
try instance.map.put(0x1DFE, 230);
index = 0x20D0;
while (index <= 0x20D1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x20D4;
while (index <= 0x20D7) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x20DB;
while (index <= 0x20DC) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x20E1, 230);
try instance.map.put(0x20E7, 230);
try instance.map.put(0x20E9, 230);
try instance.map.put(0x20F0, 230);
index = 0x2CEF;
while (index <= 0x2CF1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x2DE0;
while (index <= 0x2DFF) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0xA66F, 230);
index = 0xA674;
while (index <= 0xA67D) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xA69E;
while (index <= 0xA69F) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xA6F0;
while (index <= 0xA6F1) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xA8E0;
while (index <= 0xA8F1) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0xAAB0, 230);
index = 0xAAB2;
while (index <= 0xAAB3) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xAAB7;
while (index <= 0xAAB8) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xAABE;
while (index <= 0xAABF) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0xAAC1, 230);
index = 0xFE20;
while (index <= 0xFE26) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0xFE2E;
while (index <= 0xFE2F) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x10376;
while (index <= 0x1037A) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x10A0F, 230);
try instance.map.put(0x10A38, 230);
try instance.map.put(0x10AE5, 230);
index = 0x10D24;
while (index <= 0x10D27) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x10EAB;
while (index <= 0x10EAC) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x10F48;
while (index <= 0x10F4A) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x10F4C, 230);
index = 0x11100;
while (index <= 0x11102) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x11366;
while (index <= 0x1136C) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x11370;
while (index <= 0x11374) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x1145E, 230);
index = 0x16B30;
while (index <= 0x16B36) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1D185;
while (index <= 0x1D189) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1D1AA;
while (index <= 0x1D1AD) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1D242;
while (index <= 0x1D244) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E000;
while (index <= 0x1E006) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E008;
while (index <= 0x1E018) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E01B;
while (index <= 0x1E021) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E023;
while (index <= 0x1E024) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E026;
while (index <= 0x1E02A) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E130;
while (index <= 0x1E136) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E2EC;
while (index <= 0x1E2EF) : (index += 1) {
try instance.map.put(index, 230);
}
index = 0x1E944;
while (index <= 0x1E949) : (index += 1) {
try instance.map.put(index, 230);
}
try instance.map.put(0x0315, 232);
try instance.map.put(0x031A, 232);
try instance.map.put(0x0358, 232);
try instance.map.put(0x1DF6, 232);
try instance.map.put(0x302C, 232);
try instance.map.put(0x035C, 233);
try instance.map.put(0x035F, 233);
try instance.map.put(0x0362, 233);
try instance.map.put(0x1DFC, 233);
index = 0x035D;
while (index <= 0x035E) : (index += 1) {
try instance.map.put(index, 234);
}
index = 0x0360;
while (index <= 0x0361) : (index += 1) {
try instance.map.put(index, 234);
}
try instance.map.put(0x1DCD, 234);
try instance.map.put(0x0345, 240);
return instance;
}
const Self = @This();
pub fn deinit(self: *Self) void {
self.map.deinit();
}
/// combiningClass maps the code point to its combining class value.
pub fn combiningClass(self: Self, cp: u21) u8 {
return if (self.map.get(cp)) |cc| cc else 0;
} | src/components/autogen/DerivedCombiningClass/CccMap.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.