Inline SPIR-V types (vk::SpirvType, vk::SpirvOpaqueType) and cooperative matrices

- A spirv type kind: opcode with type, constant and literal operands
  (vk::integral_constant, vk::Literal), sized (SpirvType) or opaque.
  Integer, float and pointer types map to zdxc's own; others are
  declared as spelled and deduplicated. Capabilities and extensions on
  aliases, fields and declarations travel with the type.
- vk::WorkgroupSpirvPointer and other inline pointers are values, never
  variables; passing one to a function adds VariablePointers (dxc
  inlines the call instead).
- __builtin_spv_CooperativeMatrixLengthKHR; template argument deduction
  through aliases of inline types and qualified patterns; function
  template instances keep their arguments.
- [[vk::ext_literal]] defaults, constants resolved where Sema saw them,
  static members through objects, enum-typed values in SPIR-V.
- [[vk::ext_decorate(_string)]] on struct members; capabilities from
  inline SPIR-V add the extensions they need; PhysicalStorageBuffer64
  addressing with physical storage buffer pointers.
- All vk::khr::CooperativeMatrix tests compile to valid SPIR-V.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Peter Li 2026-10-31 19:22:10 -07:00
parent 0ceb237938
commit 7a4649ed63
11 changed files with 686 additions and 51 deletions

View File

@ -285,7 +285,7 @@ pub const Decl = struct {
func: FuncDecl,
@"struct": StructDecl,
cbuffer: CBufferDecl,
typedef: struct { name: []const u8, type: *TypeRef, array_dims: []const ?*Expr, template_params: []const TemplateParam = &.{}, qual_words: []const QualWord = &.{} },
typedef: struct { name: []const u8, type: *TypeRef, array_dims: []const ?*Expr, template_params: []const TemplateParam = &.{}, qual_words: []const QualWord = &.{}, attrs: []const Attribute = &.{} },
@"enum": EnumDecl,
namespace: struct { name: []const u8, decls: []const *Decl },
/// `using namespace N;`

View File

@ -965,14 +965,14 @@ pub const Parser = struct {
return p.mk(ast.Decl, .{ .loc = kw.loc, .kind = .{ .using_decl = n } });
}
const name = try p.expectIdent("alias name");
_ = try p.parseAttributes(); // e.g. [[vk::ext_capability(...)]]
const attrs = try p.parseAttributes(); // e.g. [[vk::ext_capability(...)]]
_ = try p.expect(.equal, "'='");
_ = p.parseQualifiers();
const ty = try p.parseType();
const dims = try p.parseArrayDims();
_ = try p.expect(.semi, "';'");
try p.declareNameOuter(name.text, if (template_params.len > 0) .template_type else .type, template_params.len > 0);
return p.mk(ast.Decl, .{ .loc = kw.loc, .kind = .{ .typedef = .{ .name = name.text, .type = ty, .array_dims = dims, .template_params = template_params } } });
return p.mk(ast.Decl, .{ .loc = kw.loc, .kind = .{ .typedef = .{ .name = name.text, .type = ty, .array_dims = dims, .template_params = template_params, .attrs = attrs } } });
}
fn parseNamespace(p: *Parser) Error!*ast.Decl {

View File

@ -466,7 +466,7 @@ pub const SpirvInst = struct {
opcode: u32,
set: ?[]const u8 = null,
/// Values, pointers (`[[vk::ext_reference]]`) or literal words.
operands: []const union(enum) { value: Ref, literal: u32 },
operands: []const union(enum) { value: Ref, literal: u32, type: TypeId },
capabilities: []const u32 = &.{},
extensions: []const []const u8 = &.{},
};

View File

@ -99,6 +99,10 @@ const Lowerer = struct {
// Per function.
b: ir.Builder = undefined,
vars: std.AutoHashMapUnmanaged(*const Variable, Ref) = .empty,
/// Variables bound to values instead of storage: inline SPIR-V
/// pointers (`vk::WorkgroupSpirvPointer`), which Vulkan does not let
/// variables hold.
value_vars: std.AutoHashMapUnmanaged(*const Variable, Ref) = .empty,
loops: std.ArrayList(struct { brk: BlockId, cont: BlockId }) = .empty,
/// Geometry shaders: output elements registered before lowering (by
/// stream parameter), and each stream's element layout.
@ -403,6 +407,10 @@ const Lowerer = struct {
const space: ir.Space = if (mq.vertices or mq.indices or mq.primitives) .mesh else if (p.dir != .in) .function else .none;
const pv = try l.b.add(.{ .op = .{ .param = ir_index }, .ty = pty, .ptr = space });
ir_index += 1;
if (p.dir == .in and isSpirvPointer(&l.s.types, p.type)) {
if (i < f.param_vars.len) if (f.param_vars[i]) |v| try l.value_vars.put(l.arena, v, pv);
continue;
}
const storage = if (p.dir != .in) pv else blk: {
const local = try l.b.add(.{ .op = .local_var, .ty = pty, .ptr = .function });
try l.b.store(local, pv);
@ -666,6 +674,14 @@ const Lowerer = struct {
l.unsupported(d.loc, "uninitialized local resource '{s}' is not supported yet", .{variable.name});
return error.Unsupported;
}
if (isSpirvPointer(&l.s.types, variable.type)) {
const init_e = v.init orelse {
l.unsupported(d.loc, "uninitialized inline SPIR-V pointer '{s}' is not supported", .{variable.name});
return error.Unsupported;
};
try l.value_vars.put(l.arena, variable, try l.converted(init_e, variable.type));
return;
}
const local = try l.b.add(.{ .op = .local_var, .ty = variable.type, .ptr = .function });
try l.vars.put(l.arena, variable, local);
if (v.init) |init_e| {
@ -923,6 +939,7 @@ const Lowerer = struct {
return l.bitRead(try l.b.load(try l.bitStorage(l.this_ptr, bf)), bf);
},
.variable => |v| {
if (l.value_vars.get(v)) |val| return val;
if (l.isSpecConstant(v)) return l.specConstant(v);
// Integer `static const` scalars are constants.
if (v.storage == .constant and v.init != null and l.s.types.get(v.type) == .scalar and !l.s.types.get(v.type).scalar.isFloat()) {
@ -1194,6 +1211,14 @@ const Lowerer = struct {
},
.@"struct" => |info| {
const r = l.s.resolution(e) orelse return l.fail(e, "this member");
// A static member through an object.
if (r == .variable) {
const v = r.variable;
if (v.storage == .constant and v.init != null and l.s.types.get(v.type) == .scalar and !l.s.types.get(v.type).scalar.isFloat()) {
if (l.s.evalVarInt(v)) |val| return l.b.constInt(try l.concrete(e.ty), val);
}
return l.b.load(try l.variableLvalue(e, v));
}
if (r == .bitfield) {
const bf = r.bitfield;
const storage = if (isAddressable(l.s, base))
@ -1244,7 +1269,15 @@ const Lowerer = struct {
}
const Operand = @typeInfo(@TypeOf(inst.operands)).pointer.child;
var ops: std.ArrayList(Operand) = .empty;
for (args, 0..) |a, i| {
// Missing trailing arguments take the parameters' defaults.
var full = args;
if (args.len < f.decl.params.len) {
const all = try l.arena.alloc(*ast.Expr, f.decl.params.len);
@memcpy(all[0..args.len], args);
for (all[args.len..], f.decl.params[args.len..]) |*x, pd| x.* = pd.init orelse return l.fail(e, "this call");
full = all;
}
for (full, 0..) |a, i| {
const pd = if (i < f.decl.params.len) f.decl.params[i] else null;
const pattrs: []const ast.Attribute = if (pd) |x| x.attrs else &.{};
if (hasAttr(pattrs, "vk::ext_literal")) {
@ -1271,6 +1304,14 @@ const Lowerer = struct {
switch (r) {
.function => |f| {
if (!f.defined and hasAttr(f.decl.attrs, "vk::ext_instruction")) return l.spirvInstCall(e, f, args, ret_ty);
// OpCooperativeMatrixLengthKHR of the template argument.
if (!f.defined and std.mem.startsWith(u8, f.name, "__builtin_spv_CooperativeMatrixLengthKHR") and f.template_args.len == 1 and f.template_args[0] == .type and l.s.opts.spirv) {
const p = try l.arena.create(ir.SpirvInst);
const ops = try l.arena.alloc(@typeInfo(@TypeOf(p.operands)).pointer.child, 1);
ops[0] = .{ .type = f.template_args[0].type };
p.* = .{ .opcode = 4460, .operands = ops };
return l.b.add(.{ .op = .{ .spirv_inst = p }, .ty = ret_ty });
}
const fi = try l.functionIndex(f);
// Missing trailing arguments take the parameters' defaults.
var full = args;
@ -1466,6 +1507,40 @@ const Lowerer = struct {
}
/// Pointer to the storage `e` designates.
/// Storage of a variable that is not a local (locals are in `vars`).
fn variableLvalue(l: *Lowerer, e: *ast.Expr, v: *const Variable) Error!Ref {
const t = l.types();
if (l.vars.get(v)) |p| return p;
switch (v.storage) {
.local, .param, .local_static => return l.fail(e, "this variable"),
.global_uniform, .cbuffer => {
if (isObject(&l.s.types, v.type)) {
l.unsupported(e.loc, "resource '{s}' declared as a uniform is not supported yet", .{v.name});
return error.Unsupported;
}
if (l.isPushConstantStruct(v)) {
// A buffer of its own (SPIR-V push constants).
const g = l.globals.get(v) orelse blk: {
try l.m.globals.append(l.arena, .{ .name = v.name, .ty = v.type, .space = .cbuffer, .push_constant = true });
const gi: u32 = @intCast(l.m.globals.items.len - 1);
try l.globals.put(l.arena, v, gi);
break :blk gi;
};
return l.b.add(.{ .op = .{ .global = g }, .ty = v.type, .ptr = .cbuffer });
}
const cm = try l.cbufferMember(v);
const glob = l.m.globals.items[cm.global];
const base = try l.b.add(.{ .op = .{ .global = cm.global }, .ty = glob.ty, .ptr = .cbuffer });
const idx = try l.b.constInt(try t.scalar(.uint), cm.field);
return l.b.add(.{ .op = .{ .access = .{ .base = base, .indices = try l.arena.dupe(Ref, &.{idx}) } }, .ty = v.type, .ptr = .cbuffer });
},
else => {},
}
const g = try l.globalIndex(v);
const glob = l.m.globals.items[g];
return l.b.add(.{ .op = .{ .global = g }, .ty = glob.ty, .ptr = glob.space });
}
fn lvalue(l: *Lowerer, e: *ast.Expr) Error!Ref {
const t = l.types();
switch (e.kind) {
@ -1481,39 +1556,12 @@ const Lowerer = struct {
return l.b.add(.{ .op = .{ .access = .{ .base = l.this_ptr, .indices = try l.arena.dupe(Ref, &.{idx}) } }, .ty = e.ty, .ptr = l.b.f.inst(l.this_ptr).ptr });
}
if (r != .variable) return l.fail(e, "this name");
const v = r.variable;
if (l.vars.get(v)) |p| return p;
switch (v.storage) {
.local, .param, .local_static => return l.fail(e, "this variable"),
.global_uniform, .cbuffer => {
if (isObject(&l.s.types, v.type)) {
l.unsupported(e.loc, "resource '{s}' declared as a uniform is not supported yet", .{v.name});
return error.Unsupported;
}
if (l.isPushConstantStruct(v)) {
// A buffer of its own (SPIR-V push constants).
const g = l.globals.get(v) orelse blk: {
try l.m.globals.append(l.arena, .{ .name = v.name, .ty = v.type, .space = .cbuffer, .push_constant = true });
const gi: u32 = @intCast(l.m.globals.items.len - 1);
try l.globals.put(l.arena, v, gi);
break :blk gi;
};
return l.b.add(.{ .op = .{ .global = g }, .ty = v.type, .ptr = .cbuffer });
}
const cm = try l.cbufferMember(v);
const glob = l.m.globals.items[cm.global];
const base = try l.b.add(.{ .op = .{ .global = cm.global }, .ty = glob.ty, .ptr = .cbuffer });
const idx = try l.b.constInt(try t.scalar(.uint), cm.field);
return l.b.add(.{ .op = .{ .access = .{ .base = base, .indices = try l.arena.dupe(Ref, &.{idx}) } }, .ty = v.type, .ptr = .cbuffer });
},
else => {},
}
const g = try l.globalIndex(v);
const glob = l.m.globals.items[g];
return l.b.add(.{ .op = .{ .global = g }, .ty = glob.ty, .ptr = glob.space });
return l.variableLvalue(e, r.variable);
},
.member => |m| {
const r = l.s.resolution(e) orelse return l.fail(e, "this member");
// A static member through an object.
if (r == .variable) return l.variableLvalue(e, r.variable);
if (r != .field) return l.fail(e, "this member");
const idx = try l.b.constInt(try t.scalar(.uint), r.field);
if (t.get(m.base.ty) == .resource) {
@ -2266,6 +2314,11 @@ pub fn saturatingInt(f: f64) i64 {
/// Non-static member functions take their object as a hidden first
/// parameter.
/// `vk::SpirvOpaqueType<OpTypePointer, ...>` (WorkgroupSpirvPointer).
fn isSpirvPointer(t: *const TypeTable, ty: TypeId) bool {
return t.get(ty) == .spirv and t.get(ty).spirv.opcode == 32;
}
fn isMethod(f: *const semamod.Function) bool {
return f.owner != null and !f.decl.quals.static;
}

View File

@ -207,7 +207,7 @@ fn mapOp(a: Allocator, op: Op, ctx: anytype) Allocator.Error!Op {
const ops = try a.dupe(@typeInfo(@TypeOf(x.operands)).pointer.child, x.operands);
for (ops) |*o| switch (o.*) {
.value => |*v| v.* = ctx.map(v.*),
.literal => {},
.literal, .type => {},
};
const n = try a.create(ir.SpirvInst);
n.* = x.*;

View File

@ -107,6 +107,8 @@ pub const Function = struct {
/// The parameters' variables, created when the body is checked
/// (null for unnamed parameters).
param_vars: []?*Variable = &.{},
/// A function template instance's arguments.
template_args: []const Bound = &.{},
};
/// A bound template argument.
@ -616,8 +618,7 @@ pub const Sema = struct {
at = s.types.withComponent(at, c.concrete()) catch at;
};
const n = pt.name;
if (n.parts.len != 1) return;
const name = n.parts[0];
const name = n.last();
const bindName = struct {
fn f(ps: []const ast.TemplateParam, o: []?Bound, nm: []const u8, v: Bound) void {
for (ps, 0..) |p, i| if (eql(p.name, nm) and o[i] == null and ((p.value_type == null) == (v == .type))) {
@ -634,7 +635,7 @@ pub const Sema = struct {
}
}.f;
if (pt.args.len == 0) {
bindName(params, out, name, .{ .type = at });
if (n.parts.len == 1) bindName(params, out, name, .{ .type = at });
return;
}
// vector<T, N> / matrix<T, R, C>.
@ -663,6 +664,26 @@ pub const Sema = struct {
if (eql(r.name, name)) if (argName(pt.args[0])) |an| bindName(params, out, an, .{ .type = r.elem });
return;
}
// An alias of vk::SpirvOpaqueType / vk::SpirvType (such as
// vk::WorkgroupSpirvPointer<T>): type operands bind their alias
// parameters.
if (s.types.get(at) == .spirv) {
const x = s.types.get(at).spirv;
const sym = s.lookupName(pt.name) orelse return;
if (sym != .template or sym.template.decls.items.len == 0 or sym.template.decls.items[0].kind != .typedef) return;
const alias = sym.template.decls.items[0].kind.typedef;
const target = alias.type;
const fixed: usize = if (eql(target.name.last(), "SpirvType")) 3 else if (eql(target.name.last(), "SpirvOpaqueType")) 1 else return;
if (target.args.len != fixed + x.operands.len) return;
for (target.args[fixed..], x.operands) |ta, op| {
if (op != .type) continue;
const tn = argName(ta) orelse continue;
for (alias.template_params, 0..) |ap, pi| if (eql(ap.name, tn) and pi < pt.args.len) {
if (argName(pt.args[pi])) |an| bindName(params, out, an, .{ .type = op.type });
};
}
return;
}
// S<T, ...> against an instance of S.
const inst = s.struct_instances.get(at) orelse return;
const sym = s.lookupName(pt.name) orelse return;
@ -774,6 +795,7 @@ pub const Sema = struct {
s.current_struct = owner;
try s.funcDeclMode(cd, &cd.kind.func, owner, .both);
if (b.scope.syms.get(iname)) |sym| if (sym == .functions) {
for (sym.functions.funcs.items) |func| func.template_args = b.args;
try set.funcs.appendSlice(s.arena, sym.functions.funcs.items);
};
break :blk set;
@ -1188,6 +1210,9 @@ pub const Sema = struct {
};
return s.types.intern(.{ .resource = .{ .kind = vn[1], .elem = elem, .name = n } });
};
// vk::SpirvType<opcode, size, alignment, operands...> and
// vk::SpirvOpaqueType<opcode, operands...>.
if (s.opts.spirv and (eql(n, "SpirvType") or eql(n, "SpirvOpaqueType"))) return s.inlineSpirvType(t, eql(n, "SpirvType"));
// Any other builtin object (RayQuery, node records, vk:: types...).
// vk::ext_result_id<T>: a T (an inline instruction's result).
if (eql(n, "ext_result_id") and args.len == 1) return try s.typeArg(args[0]) orelse TypeTable.error_type;
@ -1209,6 +1234,104 @@ pub const Sema = struct {
return TypeTable.error_type;
}
fn inlineSpirvType(s: *Sema, t: *const ast.TypeRef, sized: bool) Allocator.Error!TypeId {
const args = t.args;
const fixed: usize = if (sized) 3 else 1;
if (args.len < fixed) {
s.err(t.loc, "too few template arguments for '{s}'", .{t.name.last()});
return TypeTable.error_type;
}
var head: [3]u32 = .{ 0, 0, 0 };
for (args[0..fixed], 0..) |a, k| {
const v = s.constArg(a) orelse {
s.err(templateArgLoc(a), "expression is not an integral constant expression", .{});
return TypeTable.error_type;
};
head[k] = @truncate(@as(u64, @bitCast(v)));
}
const ops = try s.arena.alloc(types.SpirvOperand, args.len - fixed);
for (args[fixed..], ops) |a, *op| op.* = (try s.spirvOperand(a)) orelse return TypeTable.error_type;
const info = try s.arena.create(types.SpirvTypeInfo);
info.* = .{ .opcode = head[0], .operands = ops, .size = head[1], .alignment = head[2] };
return s.types.intern(.{ .spirv = info });
}
/// `[[vk::ext_decorate(d, words...)]]` and
/// `[[vk::ext_decorate_string(d, strings...)]]` on a struct member.
fn memberDecorations(s: *Sema, attrs: []const ast.Attribute) Allocator.Error![]const types.MemberDecoration {
var out: std.ArrayList(types.MemberDecoration) = .empty;
for (attrs) |a| {
const string = eql(a.name, "vk::ext_decorate_string");
if (!(string or eql(a.name, "vk::ext_decorate")) or a.args.len == 0) continue;
const d: u32 = @intCast(s.evalInt(a.args[0]) orelse continue);
var ints: std.ArrayList(u32) = .empty;
var strs: std.ArrayList([]const u8) = .empty;
for (a.args[1..]) |x| {
if (string) {
if (x.kind == .string_lit) try strs.append(s.arena, x.kind.string_lit[1 .. x.kind.string_lit.len - 1]);
} else if (s.evalInt(x)) |v| try ints.append(s.arena, @truncate(@as(u64, @bitCast(v))));
}
try out.append(s.arena, .{ .decoration = d, .ints = ints.items, .strings = strs.items });
}
return out.items;
}
/// Adds the capabilities and extensions an alias or field declares
/// to an inline SPIR-V type.
fn spirvTypeWithAttrs(s: *Sema, ty: TypeId, attrs: []const ast.Attribute) Allocator.Error!TypeId {
const old: *types.SpirvTypeInfo = @constCast(s.types.get(ty).spirv);
var caps: std.ArrayList(u32) = .empty;
var exts: std.ArrayList([]const u8) = .empty;
try caps.appendSlice(s.arena, old.capabilities);
try exts.appendSlice(s.arena, old.extensions);
for (attrs) |a| {
if (eql(a.name, "vk::ext_capability")) for (a.args) |x| {
if (s.evalInt(x)) |v| try caps.append(s.arena, @intCast(v));
};
if (eql(a.name, "vk::ext_extension")) for (a.args) |x| if (x.kind == .string_lit) {
try exts.append(s.arena, x.kind.string_lit[1 .. x.kind.string_lit.len - 1]);
};
}
old.capabilities = caps.items;
old.extensions = exts.items;
return ty;
}
/// A type operand, `vk::integral_constant<T, v>` (a constant) or
/// `vk::Literal<vk::integral_constant<T, v>>` (a literal word).
fn spirvOperand(s: *Sema, a: ast.TemplateArg) Allocator.Error!?types.SpirvOperand {
if (a == .type) {
const t = a.type;
if (eql(t.name.last(), "Literal") and t.args.len == 1) {
const inner = (try s.spirvOperand(t.args[0])) orelse return null;
if (inner != .constant) {
s.err(t.loc, "The template argument to vk::Literal must be a vk::integral_constant", .{});
return null;
}
return .{ .literal = inner.constant.value };
}
if (eql(t.name.last(), "integral_constant") and t.args.len == 2) {
const ty = (try s.typeArg(t.args[0])) orelse TypeTable.error_type;
const v = s.constArg(t.args[1]) orelse {
s.err(templateArgLoc(t.args[1]), "expression is not an integral constant expression", .{});
return null;
};
// (Enumerations are their underlying integers.)
const cty = switch (s.types.get(ty)) {
.@"enum" => |en| try s.types.scalar(en.underlying),
.scalar => ty,
else => try s.types.scalar(.uint),
};
return .{ .constant = .{ .ty = cty, .value = v } };
}
}
const ty = (try s.typeArg(a)) orelse {
s.err(templateArgLoc(a), "operands of inline SPIR-V types must be types", .{});
return null;
};
return .{ .type = ty };
}
/// The string argument of attribute `name` (`[[vk::builtin("X")]]`).
pub fn vkAttrString(attrs: []const ast.Attribute, name: []const u8) ?[]const u8 {
for (attrs) |a| if (std.mem.eql(u8, a.name, name) and a.args.len == 1 and a.args[0].kind == .string_lit) {
@ -1319,7 +1442,22 @@ pub const Sema = struct {
.bool_lit => |b| .{ .bool = b },
.is_same => .{ .bool = e.info != 0 },
.call => |c| s.evalIntrinsic(c.callee, c.args),
// A static constant member through an object.
.member => if (s.resolution(e)) |r| switch (r) {
.variable => |v| if (v.quals.@"const" and v.init != null) s.evalVarConst(v) else null,
else => null,
} else null,
.name => |n| blk: {
// What Sema resolved the name to (lowering evaluates
// outside the name's scope, e.g. in template instances).
if (s.resolution(e)) |r| switch (r) {
.enumerator => |v| break :blk .{ .int = v },
.variable => |v| {
if (!v.quals.@"const" or v.init == null) break :blk null;
break :blk s.evalVarConst(v);
},
else => {},
};
const sym = s.lookupName(n) orelse break :blk null;
switch (sym) {
.enumerator => |en| break :blk .{ .int = en.value },
@ -1469,7 +1607,8 @@ pub const Sema = struct {
s.err(d.loc, "nested typedefs are not supported in HLSL", .{});
return;
}
const base = try s.resolveType(td.type);
var base = try s.resolveType(td.type);
if (s.types.get(base) == .spirv and td.attrs.len > 0) base = try s.spirvTypeWithAttrs(base, td.attrs);
const attrs = s.checkModifiers(.typedef, td.qual_words, d.loc, base, s.last_attrs);
const ty = try s.applyArrayDims(base, td.array_dims);
try s.declare(td.name, .{ .type = ty }, d.loc);
@ -1637,7 +1776,9 @@ pub const Sema = struct {
continue;
}
const fattrs = s.checkModifiers(.field, v.qual_words, start, fbase, s.last_attrs);
const ft = try s.applyArrayDims(fbase, v.array_dims);
var ft = try s.applyArrayDims(fbase, v.array_dims);
// `[[vk::ext_capability(...)]] SpirvType field;`
if (s.types.get(ft) == .spirv and v.attrs.len > 0) ft = try s.spirvTypeWithAttrs(ft, v.attrs);
s.checkSemantics(.field, v.semantics, ft, false);
if (s.types.get(fbase) == .string) s.err(v.name_loc, "string declaration may only appear in global scope", .{});
s.checkDuplicateMember(info, base_fields, v.name, v.name_loc);
@ -1648,7 +1789,7 @@ pub const Sema = struct {
if (s.opts.spirv) if (s.vkAttrInt(v.attrs, "vk::offset")) |vo| if (vo % 16 != 0 and s.types.get(ft) == .@"struct") {
s.warn(v.name_loc, null, "The offset provided in the attribute should be 16-byte aligned.", .{});
};
try info.fields.append(s.arena, .{ .name = v.name, .type = ft, .row_major = isRowMajor(fattrs), .semantic = fsem, .interp = interpOf(v.quals), .vk_location = s.vkAttrInt(v.attrs, "vk::location"), .vk_index = s.vkAttrInt(v.attrs, "vk::index"), .vk_offset = if (s.opts.spirv) s.vkAttrInt(v.attrs, "vk::offset") else null, .vk_builtin = vkAttrString(v.attrs, "vk::builtin") });
try info.fields.append(s.arena, .{ .name = v.name, .type = ft, .row_major = isRowMajor(fattrs), .semantic = fsem, .interp = interpOf(v.quals), .vk_location = s.vkAttrInt(v.attrs, "vk::location"), .vk_index = s.vkAttrInt(v.attrs, "vk::index"), .vk_offset = if (s.opts.spirv) s.vkAttrInt(v.attrs, "vk::offset") else null, .vk_builtin = vkAttrString(v.attrs, "vk::builtin"), .decorations = if (s.opts.spirv) try s.memberDecorations(v.attrs) else &.{} });
},
.func => {},
else => try s.decl(m, .member),
@ -2033,6 +2174,8 @@ pub const Sema = struct {
};
// Uniform globals and cbuffer members are read-only, as are consts.
const read_only = q.@"const" or storage == .cbuffer or storage == .global_uniform;
// `[[vk::ext_capability(...)]] SpirvType x;`
if (s.types.get(ty) == .spirv and v.attrs.len > 0) _ = try s.spirvTypeWithAttrs(ty, v.attrs);
// The variable is in scope in its own initializer (as in C++).
const variable = try s.arena.create(Variable);
variable.* = .{
@ -2317,7 +2460,13 @@ pub const Sema = struct {
defer s.popScope();
for (list) |c| try s.stmt(c);
},
.decl => |list| for (list) |d| try s.decl(d, .local),
.decl => |list| for (list) |d| {
try s.decl(d, .local);
// `[[vk::ext_capability(...)]] SpirvType x = ...;`
if (st.attrs.len > 0 and d.kind == .@"var") if (s.decl_vars.get(&d.kind.@"var")) |v| if (s.types.get(v.type) == .spirv) {
_ = try s.spirvTypeWithAttrs(v.type, st.attrs);
};
},
.expr => |e| _ = try s.expr(e),
.empty => {},
.@"if" => |x| {
@ -3072,7 +3221,10 @@ pub const Sema = struct {
const ss: *StructSema = @ptrCast(@alignCast(p));
if (structMember(ss, name)) |sym| switch (sym) {
.functions => return .{ .ty = TypeTable.error_type, .callee = .{ .method = .{ .object = b.ty, .name = name, .object_lvalue = b.lvalue } } },
.variable => |v| return .{ .ty = v.type, .lvalue = true, .read_only = v.read_only },
.variable => |v| {
s.record(e, .{ .variable = v });
return .{ .ty = v.type, .lvalue = true, .read_only = v.read_only };
},
.template => return .{ .ty = TypeTable.error_type, .callee = .{ .method = .{ .object = b.ty, .name = name, .object_lvalue = b.lvalue } } },
else => {},
};

View File

@ -349,8 +349,14 @@ pub const Field = struct {
vk_index: ?u32 = null,
vk_offset: ?u32 = null,
vk_builtin: ?[]const u8 = null,
/// [[vk::ext_decorate(...)]] / [[vk::ext_decorate_string(...)]].
decorations: []const MemberDecoration = &.{},
};
/// A decoration inline SPIR-V puts on a struct member: literal words or
/// strings.
pub const MemberDecoration = struct { decoration: u32, ints: []const u32 = &.{}, strings: []const []const u8 = &.{} };
/// A bitfield member: `width` bits at `offset` in storage field `storage`.
pub const Bitfield = struct {
name: []const u8,
@ -404,6 +410,30 @@ pub const StructInfo = struct {
}
};
/// An operand of a `vk::SpirvType` / `vk::SpirvOpaqueType`: a type, a
/// constant (`vk::integral_constant<T, v>`) or a literal word
/// (`vk::Literal<vk::integral_constant<T, v>>`).
pub const SpirvOperand = union(enum) {
type: TypeId,
constant: struct { ty: TypeId, value: i64 },
literal: i64,
};
/// `vk::SpirvType<opcode, size, alignment, operands...>` (sized) and
/// `vk::SpirvOpaqueType<opcode, operands...>`: a SPIR-V type spelled out.
pub const SpirvTypeInfo = struct {
opcode: u32,
operands: []const SpirvOperand,
/// Zero for opaque types (which cannot be in buffers).
size: u32 = 0,
alignment: u32 = 0,
/// `[[vk::ext_capability]]` / `[[vk::ext_extension]]` on an alias or
/// field of the type: declared wherever it is used (not part of its
/// identity).
capabilities: []const u32 = &.{},
extensions: []const []const u8 = &.{},
};
pub const EnumInfo = struct {
name: []const u8,
underlying: Scalar,
@ -436,6 +466,7 @@ pub const Type = union(enum) {
dynamic_resource,
/// `tex.mips` / `tex.sample` and their slices (`tex.mips[level]`).
texture_view: struct { texture: TypeId, kind: enum { mips, mips_slice, sample, sample_slice } },
spirv: *const SpirvTypeInfo,
};
/// Interns types. Ids 0 and 1 are `error` and `void`.
@ -483,6 +514,7 @@ pub const TypeTable = struct {
.descriptor_heap => |h| .{ .tag = 12, .a = @intFromBool(h.sampler), .b = 0 },
.dynamic_resource => .{ .tag = 13, .a = 0, .b = 0 },
.texture_view => |v| .{ .tag = 14, .a = v.texture, .b = @backingInt(v.kind) },
.spirv => |x| .{ .tag = 15, .a = (@as(u64, x.opcode) << 32) | x.size, .b = std.hash.Wyhash.hash(x.alignment, std.mem.sliceAsBytes(x.operands)) },
};
}
@ -670,6 +702,7 @@ pub const TypeTable = struct {
.sample => "sample_type",
.sample_slice => "sample_slice_type",
} }),
.spirv => |x| if (x.size == 0) "SpirvOpaqueType" else "SpirvType",
};
}
};

View File

@ -28,7 +28,7 @@ pub const Error = Allocator.Error || error{Unsupported};
/// Marks a binding that is a recipe (see Emitter.resourceBinding).
const recipe_tag: u32 = 0x8000_0000;
const StorageClass = enum(u32) { uniform_constant = 0, input = 1, uniform = 2, output = 3, workgroup = 4, private = 6, function = 7, image = 11, storage_buffer = 12, task_payload_workgroup = 5402, callable_data_khr = 5328, incoming_callable_data_khr = 5329, ray_payload_khr = 5338, hit_attribute_khr = 5339, incoming_ray_payload_khr = 5342, shader_record_buffer_khr = 5343, push_constant = 9 };
const StorageClass = enum(u32) { uniform_constant = 0, input = 1, uniform = 2, output = 3, workgroup = 4, private = 6, function = 7, image = 11, storage_buffer = 12, task_payload_workgroup = 5402, callable_data_khr = 5328, incoming_callable_data_khr = 5329, ray_payload_khr = 5338, hit_attribute_khr = 5339, incoming_ray_payload_khr = 5342, shader_record_buffer_khr = 5343, push_constant = 9, physical_storage_buffer = 5349 };
const Capability = enum(u32) {
shader = 1,
@ -94,6 +94,7 @@ const Capability = enum(u32) {
storage_buffer_array_non_uniform_indexing = 5308,
storage_image_array_non_uniform_indexing = 5309,
vulkan_memory_model = 5345,
variable_pointers = 4442,
/// (Inline SPIR-V may use any value.)
_,
};
@ -135,6 +136,9 @@ const Emitter = struct {
universal: bool = false,
value_types: std.AutoHashMapUnmanaged(TypeId, Id) = .empty,
/// Inline SPIR-V types by their instruction's operand words (equal
/// spellings are one type).
spirv_types: std.StringHashMapUnmanaged(Id) = .empty,
/// Explicitly laid out variants of arrays and structs (buffers).
layout_types: std.AutoHashMapUnmanaged(LayoutKey, Id) = .empty,
/// Per instruction (current function): the buffer layout its pointer
@ -281,6 +285,13 @@ const Emitter = struct {
try e.capabilities.put(e.arena, c, {});
}
/// A capability inline SPIR-V asks for, with the extension it needs
/// before it became core (as dxc adds it).
fn inlineCap(e: *Emitter, c: u32) Error!void {
try e.capabilities.put(e.arena, @enumFromInt(c), {});
if (op_caps.need(&op_caps.capabilities, c)) |n| if (n.core > 100 + @as(u32, e.spv_minor)) try e.extension(n.ext);
}
// ------------------------------------------------------------------
// Types and constants
@ -375,14 +386,74 @@ const Emitter = struct {
try e.b.emit(.types_globals, .type_struct, ops.items);
try e.b.emitWithString(.debug_names, .name, &.{id}, try std.fmt.allocPrint(e.arena, "struct.{s}", .{st.name}), &.{});
for (st.fields.items, 0..) |fld, k| try e.b.emitWithString(.debug_names, .member_name, &.{ id, @intCast(k) }, fld.name, &.{});
try e.memberDecorations(id, st, false);
break :blk id;
},
.spirv => |x| try e.inlineType(x),
.@"enum" => |en| try e.scalarType(en.underlying),
else => return e.unsupported("type '{s}' is not supported yet", .{try e.t.format(e.arena, ty)}),
};
try e.value_types.put(e.arena, ty, id);
return id;
}
/// `vk::SpirvType` / `vk::SpirvOpaqueType`. Integers, floats and
/// pointers are the types zdxc declares itself (SPIR-V allows one of
/// each); anything else is declared as spelled.
fn inlineType(e: *Emitter, x: *const types.SpirvTypeInfo) Error!Id {
const lit = struct {
fn f(o: types.SpirvOperand) ?u32 {
return if (o == .literal) @truncate(@as(u64, @bitCast(o.literal))) else null;
}
}.f;
const ops = x.operands;
for (x.capabilities) |c| try e.inlineCap(c);
for (x.extensions) |ext| try e.extension(ext);
switch (x.opcode) {
21 => if (ops.len == 2) if (lit(ops[0])) |w| if (lit(ops[1])) |signed| {
const sc: ?Scalar = switch (w) {
16 => if (signed != 0) .int16 else .uint16,
32 => if (signed != 0) .int else .uint,
64 => if (signed != 0) .int64 else .uint64,
else => null,
};
if (sc) |c| return e.scalarType(c);
},
22 => if (ops.len == 1) if (lit(ops[0])) |w| {
const sc: ?Scalar = switch (w) {
16 => .float16,
32 => .float,
64 => .double,
else => null,
};
if (sc) |c| return e.scalarType(c);
},
32 => if (ops.len == 2 and ops[1] == .type) if (lit(ops[0])) |c| if (std.enums.fromInt(StorageClass, c)) |sc| {
return e.pointerType(sc, try e.typeId(ops[1].type));
},
else => {},
}
var words: std.ArrayList(u32) = .empty;
for (ops) |o| try words.append(e.arena, switch (o) {
.type => |t| switch (e.t.get(t)) {
.resource, .sampler => (try e.resourcePointee(t)).ty,
else => try e.typeId(t),
},
.constant => |c| try e.constant(c.ty, .{ .int = c.value }),
.literal => lit(o).?,
});
var key: std.ArrayList(u8) = .empty;
try key.print(e.arena, "{d}:", .{x.opcode});
try key.appendSlice(e.arena, std.mem.sliceAsBytes(words.items));
if (e.spirv_types.get(key.items)) |id| return id;
const id = e.b.newId();
try words.insert(e.arena, 0, id);
try e.b.emit(.types_globals, @enumFromInt(x.opcode), words.items);
try e.b.emitWithString(.debug_names, .name, &.{id}, "spirvIntrinsicType", &.{});
try e.spirv_types.put(e.arena, key.items, id);
return id;
}
/// `ty` laid out for a buffer (`rules`): arrays carry ArrayStride,
/// structs member Offsets and matrix decorations; scalars, vectors and
/// float matrices are the plain types (bools become uints).
@ -460,10 +531,28 @@ const Emitter = struct {
try e.b.emitWithString(.debug_names, .member_name, &.{ id, mk }, fld.name, &.{});
}
try e.b.emitWithString(.debug_names, .name, &.{id}, name, &.{});
try e.memberDecorations(id, st, true);
}
}
}
/// Members' inline SPIR-V decorations (not Offset in buffer layouts,
/// which place members themselves).
fn memberDecorations(e: *Emitter, id: Id, st: *const types.StructInfo, laid_out: bool) Error!void {
for (st.fields.items, 0..) |fld, k| for (fld.decorations) |d| {
if (laid_out and d.decoration == 35) continue;
try e.requireNeed(op_caps.need(&op_caps.decorations, d.decoration));
if (d.strings.len > 0) {
for (d.strings) |str| try e.b.emitWithString(.annotations, @enumFromInt(5633), &.{ id, @intCast(k), d.decoration }, str, &.{}); // OpMemberDecorateString
} else {
var words: std.ArrayList(u32) = .empty;
try words.appendSlice(e.arena, &.{ id, @intCast(k), d.decoration });
try words.appendSlice(e.arena, d.ints);
try e.b.emit(.annotations, .member_decorate, words.items);
}
};
}
/// The block of TextureBuffer<S>: S's members, std430, read-only.
fn textureBufferBlock(e: *Emitter, s: TypeId) Error!Id {
if (e.tb_blocks.get(s)) |id| return id;
@ -628,7 +717,7 @@ const Emitter = struct {
/// Inline SPIR-V decorations, capabilities and extensions of a
/// declaration (decorations on `v` when non-zero).
fn applyExt(e: *Emitter, v: Id, x: ir.SpirvExt) Error!void {
for (x.capabilities) |c| try e.capabilities.put(e.arena, @enumFromInt(c), {});
for (x.capabilities) |c| try e.inlineCap(c);
for (x.extensions) |name| try e.extension(name);
if (v != 0) try e.extDecorate(v, x.decorations);
}
@ -640,7 +729,7 @@ const Emitter = struct {
// (Not kernel capabilities: Addresses, Linkage, Kernel,
// SubgroupDispatch.)
0, 4, 5, 6, 58 => {},
else => try e.capabilities.put(e.arena, @enumFromInt(x.cap), {}),
else => try e.inlineCap(x.cap),
}
if (x.ext.len > 0 and x.core > 100 + @as(u32, e.spv_minor)) try e.extension(x.ext);
}
@ -669,13 +758,14 @@ const Emitter = struct {
/// Inline SPIR-V: the instruction with its operands (OpExtInst for an
/// instruction set).
fn spirvInst(e: *Emitter, x: *const ir.SpirvInst, ty: TypeId) Error!Id {
for (x.capabilities) |c| try e.capabilities.put(e.arena, @enumFromInt(c), {});
for (x.capabilities) |c| try e.inlineCap(c);
for (x.extensions) |name| try e.extension(name);
// The capability the grammar gives the instruction (not ones for
// kernels).
if (x.set == null) if (op_caps.get(x.opcode)) |c| switch (c) {
4, 5, 6 => {},
else => try e.capabilities.put(e.arena, @enumFromInt(c), {}),
// (Matrix comes with Shader.)
0, 4, 5, 6 => {},
else => try e.inlineCap(c),
};
var words: std.ArrayList(u32) = .empty;
const has_result = ty != TypeTable.void_type or x.set != null;
@ -685,6 +775,7 @@ const Emitter = struct {
for (x.operands) |o| try words.append(e.arena, switch (o) {
.value => |r| e.val(r),
.literal => |w| w,
.type => |t| try e.typeId(t),
});
const op: Op = if (x.set != null) .ext_inst else @enumFromInt(@as(u16, @intCast(x.opcode)));
try e.b.emit(.functions, op, words.items);
@ -826,7 +917,9 @@ const Emitter = struct {
}
for (e.capabilities.keys()) |c| try e.b.emit(.capabilities, .capability, &.{@backingInt(c)});
if (e.glsl != 0) try e.b.emitWithString(.ext_inst_imports, .ext_inst_import, &.{e.glsl}, "GLSL.std.450", &.{});
try e.b.emit(.memory_model, .memory_model, &.{ 0, if (vulkan_mm) 3 else 1 }); // Logical Vulkan / GLSL450
// (PhysicalStorageBuffer64 addressing with physical pointers.)
const addressing: u32 = if (e.capabilities.contains(@enumFromInt(5347))) 5348 else 0;
try e.b.emit(.memory_model, .memory_model, &.{ addressing, if (vulkan_mm) 3 else 1 }); // Logical / PhysicalStorageBuffer64, Vulkan / GLSL450
for (m.entries.items, 0..) |*entry, k| {
e.setEntry(@intCast(k));
try e.entryPoint(entry);
@ -1843,6 +1936,12 @@ const Emitter = struct {
continue;
}
const t = try e.typeId(p.ty);
// An inline SPIR-V pointer passed to a function: dxc inlines
// the call; zdxc keeps it and needs variable pointers.
if (e.t.get(p.ty) == .spirv and e.t.get(p.ty).spirv.opcode == 32) {
try e.cap(.variable_pointers);
if (e.spv_minor < 3) try e.extension("SPV_KHR_variable_pointers");
}
try params.append(e.arena, if (p.by_ref) try e.pointerType(.function, t) else t);
}
const fn_ty = try e.functionType(ret, params.items);

View File

@ -1157,3 +1157,240 @@ pub fn resultLayout(opcode: u32) struct { ty: ?u32, id: ?u32 } {
fn order(a: u16, b: u16) std.math.Order {
return std.math.order(a, b);
}
/// Capabilities that need an extension (before the version that made
/// them core); KHR extensions preferred, as dxc does.
pub const capabilities = [_]Need{
.{ .value = 18, .cap = 18, .ext = "SPV_AMD_shader_ballot", .core = 100 }, // Groups
.{ .value = 4165, .cap = 4165, .ext = "SPV_ARM_core_builtins", .core = 999 }, // CoreBuiltinsARM
.{ .value = 4166, .cap = 4166, .ext = "SPV_EXT_shader_tile_image", .core = 999 }, // TileImageColorReadAccessEXT
.{ .value = 4167, .cap = 4167, .ext = "SPV_EXT_shader_tile_image", .core = 999 }, // TileImageDepthReadAccessEXT
.{ .value = 4168, .cap = 4168, .ext = "SPV_EXT_shader_tile_image", .core = 999 }, // TileImageStencilReadAccessEXT
.{ .value = 4174, .cap = 4174, .ext = "SPV_ARM_tensors", .core = 999 }, // TensorsARM
.{ .value = 4175, .cap = 4175, .ext = "SPV_ARM_tensors", .core = 999 }, // StorageTensorArrayDynamicIndexingARM
.{ .value = 4176, .cap = 4176, .ext = "SPV_ARM_tensors", .core = 999 }, // StorageTensorArrayNonUniformIndexingARM
.{ .value = 4191, .cap = 4191, .ext = "SPV_ARM_graph", .core = 999 }, // GraphARM
.{ .value = 4201, .cap = 4201, .ext = "SPV_ARM_cooperative_matrix_layouts", .core = 999 }, // CooperativeMatrixLayoutsARM
.{ .value = 4212, .cap = 4212, .ext = "SPV_EXT_float8", .core = 999 }, // Float8EXT
.{ .value = 4213, .cap = 4213, .ext = "SPV_EXT_float8", .core = 999 }, // Float8CooperativeMatrixEXT
.{ .value = 4228, .cap = 4228, .ext = "SPV_EXT_ocp_microscaling_types", .core = 999 }, // Float6EXT
.{ .value = 4229, .cap = 4229, .ext = "SPV_EXT_ocp_microscaling_types", .core = 999 }, // Float4EXT
.{ .value = 4230, .cap = 4230, .ext = "SPV_EXT_ocp_microscaling_types", .core = 999 }, // Float8UnsignedE8M0EXT
.{ .value = 4231, .cap = 4231, .ext = "SPV_EXT_ocp_microscaling_types", .core = 999 }, // MXInt8EXT
.{ .value = 4232, .cap = 4232, .ext = "SPV_EXT_ocp_microscaling_types", .core = 999 }, // BitcastExtractEXT
.{ .value = 4422, .cap = 4422, .ext = "SPV_KHR_fragment_shading_rate", .core = 999 }, // FragmentShadingRateKHR
.{ .value = 4423, .cap = 4423, .ext = "SPV_KHR_shader_ballot", .core = 999 }, // SubgroupBallotKHR
.{ .value = 4427, .cap = 4427, .ext = "SPV_KHR_shader_draw_parameters", .core = 103 }, // DrawParameters
.{ .value = 4428, .cap = 4428, .ext = "SPV_KHR_workgroup_memory_explicit_layout", .core = 999 }, // WorkgroupMemoryExplicitLayoutKHR
.{ .value = 4429, .cap = 4429, .ext = "SPV_KHR_workgroup_memory_explicit_layout", .core = 999 }, // WorkgroupMemoryExplicitLayout8BitAccessKHR
.{ .value = 4430, .cap = 4430, .ext = "SPV_KHR_workgroup_memory_explicit_layout", .core = 999 }, // WorkgroupMemoryExplicitLayout16BitAccessKHR
.{ .value = 4431, .cap = 4431, .ext = "SPV_KHR_subgroup_vote", .core = 999 }, // SubgroupVoteKHR
.{ .value = 4433, .cap = 4433, .ext = "SPV_KHR_16bit_storage", .core = 103 }, // StorageBuffer16BitAccess
.{ .value = 4434, .cap = 4434, .ext = "SPV_KHR_16bit_storage", .core = 103 }, // UniformAndStorageBuffer16BitAccess
.{ .value = 4435, .cap = 4435, .ext = "SPV_KHR_16bit_storage", .core = 103 }, // StoragePushConstant16
.{ .value = 4436, .cap = 4436, .ext = "SPV_KHR_16bit_storage", .core = 103 }, // StorageInputOutput16
.{ .value = 4437, .cap = 4437, .ext = "SPV_KHR_device_group", .core = 103 }, // DeviceGroup
.{ .value = 4439, .cap = 4439, .ext = "SPV_KHR_multiview", .core = 103 }, // MultiView
.{ .value = 4441, .cap = 4441, .ext = "SPV_KHR_variable_pointers", .core = 103 }, // VariablePointersStorageBuffer
.{ .value = 4442, .cap = 4442, .ext = "SPV_KHR_variable_pointers", .core = 103 }, // VariablePointers
.{ .value = 4445, .cap = 4445, .ext = "SPV_KHR_shader_atomic_counter_ops", .core = 999 }, // AtomicStorageOps
.{ .value = 4447, .cap = 4447, .ext = "SPV_KHR_post_depth_coverage", .core = 999 }, // SampleMaskPostDepthCoverage
.{ .value = 4448, .cap = 4448, .ext = "SPV_KHR_8bit_storage", .core = 105 }, // StorageBuffer8BitAccess
.{ .value = 4449, .cap = 4449, .ext = "SPV_KHR_8bit_storage", .core = 105 }, // UniformAndStorageBuffer8BitAccess
.{ .value = 4450, .cap = 4450, .ext = "SPV_KHR_8bit_storage", .core = 105 }, // StoragePushConstant8
.{ .value = 4464, .cap = 4464, .ext = "SPV_KHR_float_controls", .core = 104 }, // DenormPreserve
.{ .value = 4465, .cap = 4465, .ext = "SPV_KHR_float_controls", .core = 104 }, // DenormFlushToZero
.{ .value = 4466, .cap = 4466, .ext = "SPV_KHR_float_controls", .core = 104 }, // SignedZeroInfNanPreserve
.{ .value = 4467, .cap = 4467, .ext = "SPV_KHR_float_controls", .core = 104 }, // RoundingModeRTE
.{ .value = 4468, .cap = 4468, .ext = "SPV_KHR_float_controls", .core = 104 }, // RoundingModeRTZ
.{ .value = 4471, .cap = 4471, .ext = "SPV_KHR_ray_query", .core = 999 }, // RayQueryProvisionalKHR
.{ .value = 4472, .cap = 4472, .ext = "SPV_KHR_ray_query", .core = 999 }, // RayQueryKHR
.{ .value = 4473, .cap = 4473, .ext = "SPV_KHR_untyped_pointers", .core = 999 }, // UntypedPointersKHR
.{ .value = 4478, .cap = 4478, .ext = "SPV_KHR_ray_query", .core = 999 }, // RayTraversalPrimitiveCullingKHR
.{ .value = 4479, .cap = 4479, .ext = "SPV_KHR_ray_tracing", .core = 999 }, // RayTracingKHR
.{ .value = 4484, .cap = 4484, .ext = "SPV_QCOM_image_processing", .core = 999 }, // TextureSampleWeightedQCOM
.{ .value = 4485, .cap = 4485, .ext = "SPV_QCOM_image_processing", .core = 999 }, // TextureBoxFilterQCOM
.{ .value = 4486, .cap = 4486, .ext = "SPV_QCOM_image_processing", .core = 999 }, // TextureBlockMatchQCOM
.{ .value = 4495, .cap = 4495, .ext = "SPV_QCOM_tile_shading", .core = 999 }, // TileShadingQCOM
.{ .value = 4496, .cap = 4496, .ext = "SPV_QCOM_cooperative_matrix_conversion", .core = 999 }, // CooperativeMatrixConversionQCOM
.{ .value = 4498, .cap = 4498, .ext = "SPV_QCOM_image_processing2", .core = 999 }, // TextureBlockMatch2QCOM
.{ .value = 4539, .cap = 4539, .ext = "SPV_QCOM_multiple_wait_queues", .core = 999 }, // MultipleWaitQueuesQCOM
.{ .value = 4543, .cap = 4543, .ext = "SPV_QCOM_image_processing3", .core = 999 }, // ImageGatherLinearQCOM
.{ .value = 4544, .cap = 4544, .ext = "SPV_QCOM_image_processing3", .core = 999 }, // ImageGatherExtendedModesQCOM
.{ .value = 5008, .cap = 5008, .ext = "SPV_AMD_gpu_shader_half_float_fetch", .core = 999 }, // Float16ImageAMD
.{ .value = 5009, .cap = 5009, .ext = "SPV_AMD_texture_gather_bias_lod", .core = 999 }, // ImageGatherBiasLodAMD
.{ .value = 5010, .cap = 5010, .ext = "SPV_AMD_shader_fragment_mask", .core = 999 }, // FragmentMaskAMD
.{ .value = 5013, .cap = 5013, .ext = "SPV_EXT_shader_stencil_export", .core = 999 }, // StencilExportEXT
.{ .value = 5015, .cap = 5015, .ext = "SPV_AMD_shader_image_load_store_lod", .core = 999 }, // ImageReadWriteLodAMD
.{ .value = 5016, .cap = 5016, .ext = "SPV_EXT_shader_image_int64", .core = 999 }, // Int64ImageEXT
.{ .value = 5055, .cap = 5055, .ext = "SPV_KHR_shader_clock", .core = 999 }, // ShaderClockKHR
.{ .value = 5067, .cap = 5067, .ext = "SPV_AMDX_shader_enqueue", .core = 999 }, // ShaderEnqueueAMDX
.{ .value = 5087, .cap = 5087, .ext = "SPV_KHR_quad_control", .core = 999 }, // QuadControlKHR
.{ .value = 5112, .cap = 5112, .ext = "SPV_INTEL_int4", .core = 999 }, // Int4TypeINTEL
.{ .value = 5114, .cap = 5114, .ext = "SPV_INTEL_int4", .core = 999 }, // Int4CooperativeMatrixINTEL
.{ .value = 5116, .cap = 5116, .ext = "SPV_KHR_bfloat16", .core = 999 }, // BFloat16TypeKHR
.{ .value = 5117, .cap = 5117, .ext = "SPV_KHR_bfloat16", .core = 999 }, // BFloat16DotProductKHR
.{ .value = 5118, .cap = 5118, .ext = "SPV_KHR_bfloat16", .core = 999 }, // BFloat16CooperativeMatrixKHR
.{ .value = 5120, .cap = 5120, .ext = "SPV_KHR_abort", .core = 999 }, // AbortKHR
.{ .value = 5128, .cap = 5128, .ext = "SPV_EXT_descriptor_heap", .core = 999 }, // DescriptorHeapEXT
.{ .value = 5146, .cap = 5146, .ext = "SPV_KHR_constant_data", .core = 999 }, // ConstantDataKHR
.{ .value = 5156, .cap = 5156, .ext = "SPV_KHR_poison_freeze", .core = 999 }, // PoisonFreezeKHR
.{ .value = 5181, .cap = 5181, .ext = "SPV_AMD_weak_linkage", .core = 999 }, // WeakLinkageAMD
.{ .value = 5249, .cap = 5249, .ext = "SPV_NV_sample_mask_override_coverage", .core = 999 }, // SampleMaskOverrideCoverageNV
.{ .value = 5251, .cap = 5251, .ext = "SPV_NV_geometry_shader_passthrough", .core = 999 }, // GeometryShaderPassthroughNV
.{ .value = 5254, .cap = 5254, .ext = "SPV_EXT_shader_viewport_index_layer", .core = 999 }, // ShaderViewportIndexLayerEXT
.{ .value = 5255, .cap = 5255, .ext = "SPV_NV_viewport_array2", .core = 999 }, // ShaderViewportMaskNV
.{ .value = 5259, .cap = 5259, .ext = "SPV_NV_stereo_view_rendering", .core = 999 }, // ShaderStereoViewNV
.{ .value = 5260, .cap = 5260, .ext = "SPV_NVX_multiview_per_view_attributes", .core = 999 }, // PerViewAttributesNV
.{ .value = 5265, .cap = 5265, .ext = "SPV_EXT_fragment_fully_covered", .core = 999 }, // FragmentFullyCoveredEXT
.{ .value = 5266, .cap = 5266, .ext = "SPV_NV_mesh_shader", .core = 999 }, // MeshShadingNV
.{ .value = 5282, .cap = 5282, .ext = "SPV_NV_shader_image_footprint", .core = 999 }, // ImageFootprintNV
.{ .value = 5283, .cap = 5283, .ext = "SPV_EXT_mesh_shader", .core = 999 }, // MeshShadingEXT
.{ .value = 5284, .cap = 5284, .ext = "SPV_KHR_fragment_shader_barycentric", .core = 999 }, // FragmentBarycentricKHR
.{ .value = 5288, .cap = 5288, .ext = "SPV_KHR_compute_shader_derivatives", .core = 999 }, // ComputeDerivativeGroupQuadsKHR
.{ .value = 5291, .cap = 5291, .ext = "SPV_EXT_fragment_invocation_density", .core = 999 }, // FragmentDensityEXT
.{ .value = 5297, .cap = 5297, .ext = "SPV_NV_shader_subgroup_partitioned", .core = 999 }, // GroupNonUniformPartitionedEXT
.{ .value = 5301, .cap = 5301, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // ShaderNonUniform
.{ .value = 5302, .cap = 5302, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // RuntimeDescriptorArray
.{ .value = 5303, .cap = 5303, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // InputAttachmentArrayDynamicIndexing
.{ .value = 5304, .cap = 5304, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // UniformTexelBufferArrayDynamicIndexing
.{ .value = 5305, .cap = 5305, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // StorageTexelBufferArrayDynamicIndexing
.{ .value = 5306, .cap = 5306, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // UniformBufferArrayNonUniformIndexing
.{ .value = 5307, .cap = 5307, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // SampledImageArrayNonUniformIndexing
.{ .value = 5308, .cap = 5308, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // StorageBufferArrayNonUniformIndexing
.{ .value = 5309, .cap = 5309, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // StorageImageArrayNonUniformIndexing
.{ .value = 5310, .cap = 5310, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // InputAttachmentArrayNonUniformIndexing
.{ .value = 5311, .cap = 5311, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // UniformTexelBufferArrayNonUniformIndexing
.{ .value = 5312, .cap = 5312, .ext = "SPV_EXT_descriptor_indexing", .core = 105 }, // StorageTexelBufferArrayNonUniformIndexing
.{ .value = 5336, .cap = 5336, .ext = "SPV_KHR_ray_tracing_position_fetch", .core = 999 }, // RayTracingPositionFetchKHR
.{ .value = 5340, .cap = 5340, .ext = "SPV_NV_ray_tracing", .core = 999 }, // RayTracingNV
.{ .value = 5341, .cap = 5341, .ext = "SPV_NV_ray_tracing_motion_blur", .core = 999 }, // RayTracingMotionBlurNV
.{ .value = 5345, .cap = 5345, .ext = "SPV_KHR_vulkan_memory_model", .core = 105 }, // VulkanMemoryModel
.{ .value = 5346, .cap = 5346, .ext = "SPV_KHR_vulkan_memory_model", .core = 105 }, // VulkanMemoryModelDeviceScope
.{ .value = 5347, .cap = 5347, .ext = "SPV_KHR_physical_storage_buffer", .core = 105 }, // PhysicalStorageBufferAddresses
.{ .value = 5350, .cap = 5350, .ext = "SPV_KHR_compute_shader_derivatives", .core = 999 }, // ComputeDerivativeGroupLinearKHR
.{ .value = 5353, .cap = 5353, .ext = "SPV_KHR_ray_tracing", .core = 999 }, // RayTracingProvisionalKHR
.{ .value = 5357, .cap = 5357, .ext = "SPV_NV_cooperative_matrix", .core = 999 }, // CooperativeMatrixNV
.{ .value = 5363, .cap = 5363, .ext = "SPV_EXT_fragment_shader_interlock", .core = 999 }, // FragmentShaderSampleInterlockEXT
.{ .value = 5372, .cap = 5372, .ext = "SPV_EXT_fragment_shader_interlock", .core = 999 }, // FragmentShaderShadingRateInterlockEXT
.{ .value = 5373, .cap = 5373, .ext = "SPV_NV_shader_sm_builtins", .core = 999 }, // ShaderSMBuiltinsNV
.{ .value = 5378, .cap = 5378, .ext = "SPV_EXT_fragment_shader_interlock", .core = 999 }, // FragmentShaderPixelInterlockEXT
.{ .value = 5379, .cap = 5379, .ext = "SPV_EXT_demote_to_helper_invocation", .core = 106 }, // DemoteToHelperInvocation
.{ .value = 5380, .cap = 5380, .ext = "SPV_NV_displacement_micromap", .core = 999 }, // DisplacementMicromapNV
.{ .value = 5381, .cap = 5381, .ext = "SPV_KHR_opacity_micromap", .core = 999 }, // RayTracingOpacityMicromapKHR
.{ .value = 5383, .cap = 5383, .ext = "SPV_NV_shader_invocation_reorder", .core = 999 }, // ShaderInvocationReorderNV
.{ .value = 5388, .cap = 5388, .ext = "SPV_EXT_shader_invocation_reorder", .core = 999 }, // ShaderInvocationReorderEXT
.{ .value = 5390, .cap = 5390, .ext = "SPV_NV_bindless_texture", .core = 999 }, // BindlessTextureNV
.{ .value = 5391, .cap = 5391, .ext = "SPV_KHR_ray_tracing_position_fetch", .core = 999 }, // RayQueryPositionFetchKHR
.{ .value = 5394, .cap = 5394, .ext = "SPV_NV_cooperative_vector", .core = 999 }, // CooperativeVectorNV
.{ .value = 5404, .cap = 5404, .ext = "SPV_NV_shader_atomic_fp16_vector", .core = 999 }, // AtomicFloat16VectorNV
.{ .value = 5409, .cap = 5409, .ext = "SPV_NV_displacement_micromap", .core = 999 }, // RayTracingDisplacementMicromapNV
.{ .value = 5414, .cap = 5414, .ext = "SPV_NV_raw_access_chains", .core = 999 }, // RawAccessChainsNV
.{ .value = 5418, .cap = 5418, .ext = "SPV_NV_linear_swept_spheres", .core = 999 }, // RayTracingSpheresGeometryNV
.{ .value = 5419, .cap = 5419, .ext = "SPV_NV_linear_swept_spheres", .core = 999 }, // RayTracingLinearSweptSpheresGeometryNV
.{ .value = 5423, .cap = 5423, .ext = "SPV_NV_push_constant_bank", .core = 999 }, // PushConstantBanksNV
.{ .value = 5425, .cap = 5425, .ext = "SPV_EXT_long_vector", .core = 999 }, // LongVectorEXT
.{ .value = 5426, .cap = 5426, .ext = "SPV_EXT_shader_64bit_indexing", .core = 999 }, // Shader64BitIndexingEXT
.{ .value = 5430, .cap = 5430, .ext = "SPV_NV_cooperative_matrix2", .core = 999 }, // CooperativeMatrixReductionsNV
.{ .value = 5431, .cap = 5431, .ext = "SPV_NV_cooperative_matrix2", .core = 999 }, // CooperativeMatrixConversionsNV
.{ .value = 5432, .cap = 5432, .ext = "SPV_NV_cooperative_matrix2", .core = 999 }, // CooperativeMatrixPerElementOperationsNV
.{ .value = 5433, .cap = 5433, .ext = "SPV_NV_cooperative_matrix2", .core = 999 }, // CooperativeMatrixTensorAddressingNV
.{ .value = 5434, .cap = 5434, .ext = "SPV_NV_cooperative_matrix2", .core = 999 }, // CooperativeMatrixBlockLoadsNV
.{ .value = 5435, .cap = 5435, .ext = "SPV_NV_cooperative_vector", .core = 999 }, // CooperativeVectorTrainingNV
.{ .value = 5437, .cap = 5437, .ext = "SPV_NV_cluster_acceleration_structure", .core = 999 }, // RayTracingClusterAccelerationStructureNV
.{ .value = 5439, .cap = 5439, .ext = "SPV_NV_tensor_addressing", .core = 999 }, // TensorAddressingNV
.{ .value = 5447, .cap = 5447, .ext = "SPV_NV_cooperative_matrix_decode_vector", .core = 999 }, // CooperativeMatrixDecodeVectorNV
.{ .value = 5568, .cap = 5568, .ext = "SPV_INTEL_subgroups", .core = 999 }, // SubgroupShuffleINTEL
.{ .value = 5569, .cap = 5569, .ext = "SPV_INTEL_subgroups", .core = 999 }, // SubgroupBufferBlockIOINTEL
.{ .value = 5570, .cap = 5570, .ext = "SPV_INTEL_subgroups", .core = 999 }, // SubgroupImageBlockIOINTEL
.{ .value = 5579, .cap = 5579, .ext = "SPV_INTEL_media_block_io", .core = 999 }, // SubgroupImageMediaBlockIOINTEL
.{ .value = 5582, .cap = 5582, .ext = "SPV_INTEL_float_controls2", .core = 999 }, // RoundToInfinityINTEL
.{ .value = 5583, .cap = 5583, .ext = "SPV_INTEL_float_controls2", .core = 999 }, // FloatingPointModeINTEL
.{ .value = 5584, .cap = 5584, .ext = "SPV_INTEL_shader_integer_functions2", .core = 999 }, // IntegerFunctions2INTEL
.{ .value = 5603, .cap = 5603, .ext = "SPV_INTEL_function_pointers", .core = 999 }, // FunctionPointersINTEL
.{ .value = 5604, .cap = 5604, .ext = "SPV_INTEL_function_pointers", .core = 999 }, // IndirectReferencesINTEL
.{ .value = 5606, .cap = 5606, .ext = "SPV_INTEL_inline_assembly", .core = 999 }, // AsmINTEL
.{ .value = 5612, .cap = 5612, .ext = "SPV_EXT_shader_atomic_float_min_max", .core = 999 }, // AtomicFloat32MinMaxEXT
.{ .value = 5613, .cap = 5613, .ext = "SPV_EXT_shader_atomic_float_min_max", .core = 999 }, // AtomicFloat64MinMaxEXT
.{ .value = 5616, .cap = 5616, .ext = "SPV_EXT_shader_atomic_float_min_max", .core = 999 }, // AtomicFloat16MinMaxEXT
.{ .value = 5617, .cap = 5617, .ext = "SPV_INTEL_vector_compute", .core = 999 }, // VectorComputeINTEL
.{ .value = 5619, .cap = 5619, .ext = "SPV_INTEL_vector_compute", .core = 999 }, // VectorAnyINTEL
.{ .value = 5629, .cap = 5629, .ext = "SPV_KHR_expect_assume", .core = 999 }, // ExpectAssumeKHR
.{ .value = 5696, .cap = 5696, .ext = "SPV_INTEL_device_side_avc_motion_estimation", .core = 999 }, // SubgroupAvcMotionEstimationINTEL
.{ .value = 5697, .cap = 5697, .ext = "SPV_INTEL_device_side_avc_motion_estimation", .core = 999 }, // SubgroupAvcMotionEstimationIntraINTEL
.{ .value = 5698, .cap = 5698, .ext = "SPV_INTEL_device_side_avc_motion_estimation", .core = 999 }, // SubgroupAvcMotionEstimationChromaINTEL
.{ .value = 5817, .cap = 5817, .ext = "SPV_INTEL_variable_length_array", .core = 999 }, // VariableLengthArrayINTEL
.{ .value = 5821, .cap = 5821, .ext = "SPV_INTEL_float_controls2", .core = 999 }, // FunctionFloatControlINTEL
.{ .value = 5824, .cap = 5824, .ext = "SPV_ALTERA_fpga_memory_attributes", .core = 999 }, // FPGAMemoryAttributesALTERA
.{ .value = 5837, .cap = 5837, .ext = "SPV_INTEL_fp_fast_math_mode", .core = 999 }, // FPFastMathModeINTEL
.{ .value = 5844, .cap = 5844, .ext = "SPV_ALTERA_arbitrary_precision_integers", .core = 999 }, // ArbitraryPrecisionIntegersALTERA
.{ .value = 5845, .cap = 5845, .ext = "SPV_ALTERA_arbitrary_precision_floating_point", .core = 999 }, // ArbitraryPrecisionFloatingPointALTERA
.{ .value = 5886, .cap = 5886, .ext = "SPV_INTEL_unstructured_loop_controls", .core = 999 }, // UnstructuredLoopControlsINTEL
.{ .value = 5888, .cap = 5888, .ext = "SPV_ALTERA_fpga_loop_controls", .core = 999 }, // FPGALoopControlsALTERA
.{ .value = 5892, .cap = 5892, .ext = "SPV_INTEL_kernel_attributes", .core = 999 }, // KernelAttributesINTEL
.{ .value = 5897, .cap = 5897, .ext = "SPV_INTEL_kernel_attributes", .core = 999 }, // FPGAKernelAttributesINTEL
.{ .value = 5898, .cap = 5898, .ext = "SPV_ALTERA_fpga_memory_accesses", .core = 999 }, // FPGAMemoryAccessesALTERA
.{ .value = 5904, .cap = 5904, .ext = "SPV_ALTERA_fpga_cluster_attributes", .core = 999 }, // FPGAClusterAttributesALTERA
.{ .value = 5906, .cap = 5906, .ext = "SPV_ALTERA_loop_fuse", .core = 999 }, // LoopFuseALTERA
.{ .value = 5908, .cap = 5908, .ext = "SPV_ALTERA_fpga_dsp_control", .core = 999 }, // FPGADSPControlALTERA
.{ .value = 5910, .cap = 5910, .ext = "SPV_INTEL_memory_access_aliasing", .core = 999 }, // MemoryAccessAliasingINTEL
.{ .value = 5916, .cap = 5916, .ext = "SPV_ALTERA_fpga_invocation_pipelining_attributes", .core = 999 }, // FPGAInvocationPipeliningAttributesALTERA
.{ .value = 5920, .cap = 5920, .ext = "SPV_ALTERA_fpga_buffer_location", .core = 999 }, // FPGABufferLocationALTERA
.{ .value = 5922, .cap = 5922, .ext = "SPV_ALTERA_arbitrary_precision_fixed_point", .core = 999 }, // ArbitraryPrecisionFixedPointALTERA
.{ .value = 5935, .cap = 5935, .ext = "SPV_ALTERA_usm_storage_classes", .core = 999 }, // USMStorageClassesALTERA
.{ .value = 5939, .cap = 5939, .ext = "SPV_ALTERA_runtime_aligned", .core = 999 }, // RuntimeAlignedAttributeALTERA
.{ .value = 5943, .cap = 5943, .ext = "SPV_ALTERA_io_pipes", .core = 999 }, // IOPipesALTERA
.{ .value = 5945, .cap = 5945, .ext = "SPV_ALTERA_blocking_pipes", .core = 999 }, // BlockingPipesALTERA
.{ .value = 5948, .cap = 5948, .ext = "SPV_ALTERA_fpga_reg", .core = 999 }, // FPGARegALTERA
.{ .value = 6016, .cap = 6016, .ext = "SPV_KHR_integer_dot_product", .core = 106 }, // DotProductInputAll
.{ .value = 6017, .cap = 6017, .ext = "SPV_KHR_integer_dot_product", .core = 106 }, // DotProductInput4x8Bit
.{ .value = 6018, .cap = 6018, .ext = "SPV_KHR_integer_dot_product", .core = 106 }, // DotProductInput4x8BitPacked
.{ .value = 6019, .cap = 6019, .ext = "SPV_KHR_integer_dot_product", .core = 106 }, // DotProduct
.{ .value = 6020, .cap = 6020, .ext = "SPV_KHR_ray_cull_mask", .core = 999 }, // RayCullMaskKHR
.{ .value = 6022, .cap = 6022, .ext = "SPV_KHR_cooperative_matrix", .core = 999 }, // CooperativeMatrixKHR
.{ .value = 6024, .cap = 6024, .ext = "SPV_EXT_replicated_composites", .core = 999 }, // ReplicatedCompositesEXT
.{ .value = 6025, .cap = 6025, .ext = "SPV_KHR_bit_instructions", .core = 999 }, // BitInstructions
.{ .value = 6026, .cap = 6026, .ext = "SPV_KHR_subgroup_rotate", .core = 999 }, // GroupNonUniformRotateKHR
.{ .value = 6029, .cap = 6029, .ext = "SPV_KHR_float_controls2", .core = 999 }, // FloatControls2
.{ .value = 6030, .cap = 6030, .ext = "SPV_KHR_fma", .core = 999 }, // FMAKHR
.{ .value = 6032, .cap = 6032, .ext = "SPV_KHR_opacity_micromap", .core = 999 }, // RayTracingOpacityMicromapExecutionModeKHR
.{ .value = 6033, .cap = 6033, .ext = "SPV_EXT_shader_atomic_float_add", .core = 999 }, // AtomicFloat32AddEXT
.{ .value = 6034, .cap = 6034, .ext = "SPV_EXT_shader_atomic_float_add", .core = 999 }, // AtomicFloat64AddEXT
.{ .value = 6089, .cap = 6089, .ext = "SPV_INTEL_long_composites", .core = 999 }, // LongCompositesINTEL
.{ .value = 6094, .cap = 6094, .ext = "SPV_EXT_optnone", .core = 999 }, // OptNoneEXT
.{ .value = 6095, .cap = 6095, .ext = "SPV_EXT_shader_atomic_float16_add", .core = 999 }, // AtomicFloat16AddEXT
.{ .value = 6114, .cap = 6114, .ext = "SPV_INTEL_debug_module", .core = 999 }, // DebugInfoModuleINTEL
.{ .value = 6115, .cap = 6115, .ext = "SPV_INTEL_bfloat16_conversion", .core = 999 }, // BFloat16ConversionINTEL
.{ .value = 6141, .cap = 6141, .ext = "SPV_EXT_split_barrier", .core = 999 }, // SplitBarrierEXT
.{ .value = 6144, .cap = 6144, .ext = "SPV_EXT_arithmetic_fence", .core = 999 }, // ArithmeticFenceEXT
.{ .value = 6150, .cap = 6150, .ext = "SPV_ALTERA_fpga_cluster_attributes", .core = 999 }, // FPGAClusterAttributesV2ALTERA
.{ .value = 6161, .cap = 6161, .ext = "SPV_INTEL_kernel_attributes", .core = 999 }, // FPGAKernelAttributesv2INTEL
.{ .value = 6162, .cap = 6162, .ext = "SPV_ALTERA_task_sequence", .core = 999 }, // TaskSequenceALTERA
.{ .value = 6169, .cap = 6169, .ext = "SPV_INTEL_fp_max_error", .core = 999 }, // FPMaxErrorINTEL
.{ .value = 6171, .cap = 6171, .ext = "SPV_ALTERA_fpga_latency_control", .core = 999 }, // FPGALatencyControlALTERA
.{ .value = 6174, .cap = 6174, .ext = "SPV_ALTERA_fpga_argument_interfaces", .core = 999 }, // FPGAArgumentInterfacesALTERA
.{ .value = 6187, .cap = 6187, .ext = "SPV_INTEL_global_variable_host_access", .core = 999 }, // GlobalVariableHostAccessINTEL
.{ .value = 6189, .cap = 6189, .ext = "SPV_ALTERA_global_variable_fpga_decorations", .core = 999 }, // GlobalVariableFPGADecorationsALTERA
.{ .value = 6220, .cap = 6220, .ext = "SPV_INTEL_subgroup_buffer_prefetch", .core = 999 }, // SubgroupBufferPrefetchINTEL
.{ .value = 6228, .cap = 6228, .ext = "SPV_INTEL_2d_block_io", .core = 999 }, // Subgroup2DBlockIOINTEL
.{ .value = 6229, .cap = 6229, .ext = "SPV_INTEL_2d_block_io", .core = 999 }, // Subgroup2DBlockTransformINTEL
.{ .value = 6230, .cap = 6230, .ext = "SPV_INTEL_2d_block_io", .core = 999 }, // Subgroup2DBlockTransposeINTEL
.{ .value = 6236, .cap = 6236, .ext = "SPV_INTEL_subgroup_matrix_multiply_accumulate", .core = 999 }, // SubgroupMatrixMultiplyAccumulateINTEL
.{ .value = 6241, .cap = 6241, .ext = "SPV_INTEL_ternary_bitwise_function", .core = 999 }, // TernaryBitwiseFunctionINTEL
.{ .value = 6243, .cap = 6243, .ext = "SPV_INTEL_variable_length_array", .core = 999 }, // UntypedVariableLengthArrayINTEL
.{ .value = 6245, .cap = 6245, .ext = "SPV_INTEL_function_variants", .core = 999 }, // SpecConditionalINTEL
.{ .value = 6246, .cap = 6246, .ext = "SPV_INTEL_function_variants", .core = 999 }, // FunctionVariantsINTEL
.{ .value = 6257, .cap = 6257, .ext = "SPV_INTEL_predicated_io", .core = 999 }, // PredicatedIOINTEL
.{ .value = 6265, .cap = 6265, .ext = "SPV_INTEL_rounded_divide_sqrt", .core = 999 }, // RoundedDivideSqrtINTEL
.{ .value = 6400, .cap = 6400, .ext = "SPV_KHR_uniform_group_instructions", .core = 999 }, // GroupUniformArithmeticKHR
.{ .value = 6425, .cap = 6425, .ext = "SPV_INTEL_tensor_float32_conversion", .core = 999 }, // TensorFloat32RoundingINTEL
.{ .value = 6427, .cap = 6427, .ext = "SPV_INTEL_masked_gather_scatter", .core = 999 }, // MaskedGatherScatterINTEL
.{ .value = 6441, .cap = 6441, .ext = "SPV_INTEL_cache_controls", .core = 999 }, // CacheControlsINTEL
.{ .value = 6460, .cap = 6460, .ext = "SPV_INTEL_maximum_registers", .core = 999 }, // RegisterLimitsINTEL
.{ .value = 6528, .cap = 6528, .ext = "SPV_INTEL_bindless_images", .core = 999 }, // BindlessImagesINTEL
.{ .value = 6912, .cap = 6912, .ext = "SPV_VALVE_mixed_float_dot_product", .core = 999 }, // DotProductFloat16AccFloat32VALVE
.{ .value = 6913, .cap = 6913, .ext = "SPV_VALVE_mixed_float_dot_product", .core = 999 }, // DotProductFloat16AccFloat16VALVE
.{ .value = 6914, .cap = 6914, .ext = "SPV_VALVE_mixed_float_dot_product", .core = 999 }, // DotProductBFloat16AccVALVE
.{ .value = 6915, .cap = 6915, .ext = "SPV_VALVE_mixed_float_dot_product", .core = 999 }, // DotProductFloat8AccFloat32VALVE
.{ .value = 7041, .cap = 7041, .ext = "SPV_SAMSUNG_intrinsic", .core = 999 }, // IntrinsicSAMSUNG
};

View File

@ -0,0 +1,29 @@
// PROFILE: cs_6_0
// FLAGS: -E main
// ENV: vulkan1.3
// vk::khr::CooperativeMatrix (built on inline SPIR-V types and
// instructions): loads, arithmetic, length, multiply-add and stores.
// ZCHECK: OpCapability CooperativeMatrixKHR
// ZCHECK: OpExtension "SPV_KHR_cooperative_matrix"
// ZCHECK: OpMemoryModel Logical Vulkan
// ZCHECK: OpTypeCooperativeMatrixKHR %float %uint_3 %uint_16 %uint_4 %uint_0
// ZCHECK: OpCooperativeMatrixLoadKHR
// ZCHECK: OpCooperativeMatrixLengthKHR %uint
// ZCHECK: OpCooperativeMatrixMulAddKHR
// ZCHECK: OpCooperativeMatrixStoreKHR
#include <vk/khr/cooperative_matrix.h>
RWStructuredBuffer<float> data;
[numthreads(64, 1, 1)] void main() {
using MatA = vk::khr::CooperativeMatrixA<float, vk::ScopeSubgroup, 16, 4>;
using MatB = vk::khr::CooperativeMatrixB<float, vk::ScopeSubgroup, 4, 8>;
using MatC = vk::khr::CooperativeMatrixAccumulator<float, vk::ScopeSubgroup, 16, 8>;
MatA a = MatA::Load<vk::CooperativeMatrixLayoutRowMajorKHR>(data, 0, 4);
MatB b = MatB::Load<vk::CooperativeMatrixLayoutRowMajorKHR>(data, 64, 8);
MatC c = MatC::Splat(1.0);
a = a * 2.0 + a;
data[200] = a.GetLength();
c = cooperativeMatrixMultiplyAdd(a, b, c);
c.Store<vk::CooperativeMatrixLayoutRowMajorKHR>(data, 100, 8);
}

View File

@ -0,0 +1,32 @@
// PROFILE: cs_6_0
// FLAGS: -E main
// ENV: vulkan1.3
// Inline SPIR-V types: vk::SpirvType (sized, in a buffer layout) and
// vk::SpirvOpaqueType with type, constant and literal operands;
// capabilities on an alias; vk::WorkgroupSpirvPointer passed to a
// function (zdxc keeps the call, so it needs variable pointers).
// ZCHECK: OpCapability Int8
// ZCHECK: OpCapability VariablePointers
// ZCHECK: %spirvIntrinsicType = OpTypeInt 8 0
// ZCHECK: %spirvIntrinsicType_0 = OpTypeArray %{{.*}} %uint_4
// ZCHECK: OpCopyObject %_ptr_Workgroup_int
#include <vk/spirv.h>
using uint8_t [[vk::ext_capability(/* Int8 */ 39)]] = vk::SpirvType</* OpTypeInt */ 21, 1, 1, vk::Literal<vk::integral_constant<uint, 8> >, vk::Literal<vk::integral_constant<bool, false> > >;
typedef vk::SpirvOpaqueType</* OpTypeArray */ 28, Texture2D, vk::integral_constant<uint, 4> > ArrayTex2D;
RWStructuredBuffer<int> data;
groupshared int shared_data[64];
[[vk::ext_instruction(/* OpLoad */ 61)]] int Load(vk::WorkgroupSpirvPointer<int> p);
int read(vk::WorkgroupSpirvPointer<int> p) { return Load(p); }
[numthreads(64, 1, 1)] void main(uint i : SV_GroupIndex) {
uint8_t bytes[4];
ArrayTex2D images;
shared_data[i] = (int)i;
GroupMemoryBarrierWithGroupSync();
vk::WorkgroupSpirvPointer<int> p = vk::GetGroupSharedAddress(shared_data[63 - i]);
data[i] = read(p);
}