adding descriptor index to descriptor write
This commit is contained in:
@@ -26,6 +26,8 @@ pub fn main() !void {
|
|||||||
|
|
||||||
var ssbo: SSBO = .{};
|
var ssbo: SSBO = .{};
|
||||||
|
|
||||||
|
try rt.writeDescriptorSet(std.mem.asBytes(&ssbo), 0, 0, 0);
|
||||||
|
|
||||||
for (0..16) |i| {
|
for (0..16) |i| {
|
||||||
for (0..16) |x| {
|
for (0..16) |x| {
|
||||||
const global_invocation_indices = [3]i32{
|
const global_invocation_indices = [3]i32{
|
||||||
@@ -35,7 +37,6 @@ pub fn main() !void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try rt.writeBuiltIn(std.mem.asBytes(&global_invocation_indices), .GlobalInvocationId);
|
try rt.writeBuiltIn(std.mem.asBytes(&global_invocation_indices), .GlobalInvocationId);
|
||||||
try rt.writeDescriptorSet(std.mem.asBytes(&ssbo), 0, 0);
|
|
||||||
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
|
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
|
||||||
spv.Runtime.RuntimeError.OutOfBounds => continue,
|
spv.Runtime.RuntimeError.OutOfBounds => continue,
|
||||||
else => return err,
|
else => return err,
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ pub fn getResultByName(self: *const Self, name: []const u8) error{NotFound}!SpvW
|
|||||||
pub fn callEntryPoint(self: *Self, allocator: std.mem.Allocator, entry_point_index: SpvWord) RuntimeError!void {
|
pub fn callEntryPoint(self: *Self, allocator: std.mem.Allocator, entry_point_index: SpvWord) RuntimeError!void {
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
if (entry_point_index > self.mod.entry_points.items.len) return RuntimeError.InvalidEntryPoint;
|
if (entry_point_index > self.mod.entry_points.items.len)
|
||||||
|
return RuntimeError.InvalidEntryPoint;
|
||||||
|
|
||||||
{
|
{
|
||||||
const entry_point_desc = &self.mod.entry_points.items[entry_point_index];
|
const entry_point_desc = &self.mod.entry_points.items[entry_point_index];
|
||||||
@@ -151,9 +152,21 @@ pub fn callEntryPoint(self: *Self, allocator: std.mem.Allocator, entry_point_ind
|
|||||||
//}) catch return RuntimeError.OutOfMemory;
|
//}) catch return RuntimeError.OutOfMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn writeDescriptorSet(self: *const Self, input: []u8, set: SpvWord, binding: SpvWord) RuntimeError!void {
|
pub fn writeDescriptorSet(self: *const Self, input: []u8, set: SpvWord, binding: SpvWord, descriptor_index: SpvWord) RuntimeError!void {
|
||||||
if (set < lib.SPIRV_MAX_SET and binding < lib.SPIRV_MAX_SET_BINDINGS) {
|
if (set < lib.SPIRV_MAX_SET and binding < lib.SPIRV_MAX_SET_BINDINGS) {
|
||||||
_ = try self.results[self.mod.bindings[set][binding]].variant.?.Variable.value.write(input);
|
const value = &self.results[self.mod.bindings[set][binding]].variant.?.Variable.value;
|
||||||
|
switch (value.*) {
|
||||||
|
.Array => |arr| {
|
||||||
|
if (descriptor_index >= arr.len)
|
||||||
|
return RuntimeError.NotFound;
|
||||||
|
_ = try arr[descriptor_index].write(input);
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
if (descriptor_index != 0)
|
||||||
|
return RuntimeError.NotFound;
|
||||||
|
_ = try value.write(input);
|
||||||
|
},
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return RuntimeError.NotFound;
|
return RuntimeError.NotFound;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ pub const case = struct {
|
|||||||
|
|
||||||
for (config.descriptor_sets, 0..) |descriptor_set, set_index| {
|
for (config.descriptor_sets, 0..) |descriptor_set, set_index| {
|
||||||
for (descriptor_set, 0..) |descriptor_binding, binding_index| {
|
for (descriptor_set, 0..) |descriptor_binding, binding_index| {
|
||||||
try rt.writeDescriptorSet(descriptor_binding, @intCast(set_index), @intCast(binding_index));
|
try rt.writeDescriptorSet(descriptor_binding, @intCast(set_index), @intCast(binding_index), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user