diff --git a/src/Image.zig b/src/Image.zig index e69de29..0ec3a80 100644 --- a/src/Image.zig +++ b/src/Image.zig @@ -0,0 +1,13 @@ +const std = @import("std"); +const spv = @import("spv.zig"); + +const SpvVoid = spv.SpvVoid; +const SpvByte = spv.SpvByte; +const SpvWord = spv.SpvWord; +const SpvBool = spv.SpvBool; + +width: u32, +height: u32, +depth: u32, +layers: u32, +levels: u32, diff --git a/src/Result.zig b/src/Result.zig index 2d34419..07cc93d 100644 --- a/src/Result.zig +++ b/src/Result.zig @@ -129,7 +129,15 @@ pub const TypeData = union(Type) { return_type: SpvWord, params: []const SpvWord, }, - Image: struct {}, + Image: struct { + dim: spv.SpvDim, + depth: SpvByte, + arrayed: SpvByte, + ms: SpvByte, + sampled: SpvByte, + format: spv.SpvImageFormat, + access: ?spv.SpvAccessQualifier, + }, Sampler: struct {}, SampledImage: struct {}, Pointer: struct { diff --git a/src/opcodes.zig b/src/opcodes.zig index 970904b..09465da 100644 --- a/src/opcodes.zig +++ b/src/opcodes.zig @@ -144,6 +144,7 @@ pub const SetupDispatcher = block: { .IAdd = autoSetupConstant, .IAddCarry = autoSetupConstant, .IEqual = autoSetupConstant, + .ImageRead = autoSetupConstant, .IMul = autoSetupConstant, .INotEqual = autoSetupConstant, .ISub = autoSetupConstant, @@ -190,6 +191,7 @@ pub const SetupDispatcher = block: { .TypeBool = opTypeBool, .TypeFloat = opTypeFloat, .TypeFunction = opTypeFunction, + .TypeImage = opTypeImage, .TypeInt = opTypeInt, .TypeMatrix = opTypeMatrix, .TypePointer = opTypePointer, @@ -2371,6 +2373,26 @@ fn opTypeFunction(allocator: std.mem.Allocator, word_count: SpvWord, rt: *Runtim }; } +fn opTypeImage(_: std.mem.Allocator, word_count: SpvWord, rt: *Runtime) RuntimeError!void { + const id = try rt.it.next(); + rt.results[id].variant = .{ + .Type = .{ + .Image = .{ + .dim = try rt.it.nextAs(spv.SpvDim), + .depth = @truncate(try rt.it.next()), + .arrayed = @truncate(try rt.it.next()), + .ms = @truncate(try rt.it.next()), + .sampled = @truncate(try rt.it.next()), + .format = try rt.it.nextAs(spv.SpvImageFormat), + .access = null, + }, + }, + }; + if (word_count > 8) { + rt.results[id].variant.?.Type.Image.access = try rt.it.nextAs(spv.SpvAccessQualifier); + } +} + fn opTypeInt(_: std.mem.Allocator, _: SpvWord, rt: *Runtime) RuntimeError!void { const id = try rt.it.next(); rt.results[id].variant = .{