fixing descriptor sets population
This commit is contained in:
@@ -64,7 +64,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
// Zig sandbox setup
|
// Zig sandbox setup
|
||||||
|
|
||||||
const sandbox_exe = b.addExecutable(.{
|
const sandbox_exe = b.addExecutable(.{
|
||||||
.name = "spirv_interpreter_sandbpx",
|
.name = "spirv_interpreter_sandbox",
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("sandbox/main.zig"),
|
.root_source_file = b.path("sandbox/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|||||||
@@ -26,24 +26,21 @@ pub fn main() !void {
|
|||||||
|
|
||||||
var ssbo: SSBO = .{};
|
var ssbo: SSBO = .{};
|
||||||
|
|
||||||
try rt.writeDescriptorSet(allocator, std.mem.asBytes(&ssbo), 0, 0);
|
|
||||||
|
|
||||||
for (0..16) |i| {
|
for (0..16) |i| {
|
||||||
for (0..16) |x| {
|
for (0..16) |x| {
|
||||||
for (0..16) |y| {
|
const global_invocation_indices = [3]i32{
|
||||||
const global_invocation_indices = [3]i32{
|
@as(i32, @intCast(i * 16 + x)),
|
||||||
@as(i32, @intCast(i * 16 + x)),
|
1,
|
||||||
@as(i32, @intCast(y)),
|
1,
|
||||||
1,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
try rt.writeBuiltIn(std.mem.asBytes(&global_invocation_indices), .GlobalInvocationId);
|
try rt.writeBuiltIn(std.mem.asBytes(&global_invocation_indices), .GlobalInvocationId);
|
||||||
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
|
try rt.writeDescriptorSet(allocator, std.mem.asBytes(&ssbo), 0, 0);
|
||||||
spv.Runtime.RuntimeError.OutOfBounds => continue,
|
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
|
||||||
else => return err,
|
spv.Runtime.RuntimeError.OutOfBounds => continue,
|
||||||
};
|
else => return err,
|
||||||
try rt.readDescriptorSet(std.mem.asBytes(&ssbo), 0, 0);
|
};
|
||||||
}
|
try rt.readDescriptorSet(std.mem.asBytes(&ssbo), 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ external
|
|||||||
}
|
}
|
||||||
|
|
||||||
[entry(compute)]
|
[entry(compute)]
|
||||||
[workgroup(16, 16, 1)]
|
[workgroup(16, 1, 1)]
|
||||||
fn main(input: Input)
|
fn main(input: Input)
|
||||||
{
|
{
|
||||||
ssbo.data[input.indices.x * input.indices.y] = i32(input.indices.x * input.indices.y);
|
ssbo.data[input.indices.x] = i32(input.indices.x);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,11 +1,11 @@
|
|||||||
Version 1.0
|
Version 1.0
|
||||||
Generator: 2560130
|
Generator: 2560130
|
||||||
Bound: 41
|
Bound: 32
|
||||||
Schema: 0
|
Schema: 0
|
||||||
OpCapability Capability(Shader)
|
OpCapability Capability(Shader)
|
||||||
OpMemoryModel AddressingModel(Logical) MemoryModel(GLSL450)
|
OpMemoryModel AddressingModel(Logical) MemoryModel(GLSL450)
|
||||||
OpEntryPoint ExecutionModel(GLCompute) %18 "main" %11
|
OpEntryPoint ExecutionModel(GLCompute) %17 "main" %11
|
||||||
OpExecutionMode %18 ExecutionMode(LocalSize) 16 16 1
|
OpExecutionMode %17 ExecutionMode(LocalSize) 16 1 1
|
||||||
OpSource SourceLanguage(NZSL) 4198400
|
OpSource SourceLanguage(NZSL) 4198400
|
||||||
OpSourceExtension "Version: 1.1"
|
OpSourceExtension "Version: 1.1"
|
||||||
OpName %3 "SSBO"
|
OpName %3 "SSBO"
|
||||||
@@ -14,7 +14,7 @@ Schema: 0
|
|||||||
OpMemberName %14 0 "indices"
|
OpMemberName %14 0 "indices"
|
||||||
OpName %5 "ssbo"
|
OpName %5 "ssbo"
|
||||||
OpName %11 "global_invocation_indices"
|
OpName %11 "global_invocation_indices"
|
||||||
OpName %18 "main"
|
OpName %17 "main"
|
||||||
OpDecorate %5 Decoration(Binding) 0
|
OpDecorate %5 Decoration(Binding) 0
|
||||||
OpDecorate %5 Decoration(DescriptorSet) 0
|
OpDecorate %5 Decoration(DescriptorSet) 0
|
||||||
OpDecorate %11 Decoration(BuiltIn) BuiltIn(GlobalInvocationId)
|
OpDecorate %11 Decoration(BuiltIn) BuiltIn(GlobalInvocationId)
|
||||||
@@ -36,33 +36,24 @@ Schema: 0
|
|||||||
%14 = OpTypeStruct %9
|
%14 = OpTypeStruct %9
|
||||||
%15 = OpTypePointer StorageClass(Function) %14
|
%15 = OpTypePointer StorageClass(Function) %14
|
||||||
%16 = OpTypeRuntimeArray %1
|
%16 = OpTypeRuntimeArray %1
|
||||||
%17 = OpConstant %1 i32(1)
|
%26 = OpTypePointer StorageClass(Uniform) %2
|
||||||
%31 = OpTypePointer StorageClass(Uniform) %2
|
%31 = OpTypePointer StorageClass(Uniform) %1
|
||||||
%40 = OpTypePointer StorageClass(Uniform) %1
|
|
||||||
%5 = OpVariable %4 StorageClass(Uniform)
|
%5 = OpVariable %4 StorageClass(Uniform)
|
||||||
%11 = OpVariable %10 StorageClass(Input)
|
%11 = OpVariable %10 StorageClass(Input)
|
||||||
%18 = OpFunction %6 FunctionControl(0) %7
|
%17 = OpFunction %6 FunctionControl(0) %7
|
||||||
%19 = OpLabel
|
%18 = OpLabel
|
||||||
%20 = OpVariable %15 StorageClass(Function)
|
%19 = OpVariable %15 StorageClass(Function)
|
||||||
%21 = OpAccessChain %13 %20 %12
|
%20 = OpAccessChain %13 %19 %12
|
||||||
OpCopyMemory %21 %11
|
OpCopyMemory %20 %11
|
||||||
%22 = OpAccessChain %13 %20 %12
|
%21 = OpAccessChain %13 %19 %12
|
||||||
%23 = OpLoad %9 %22
|
%22 = OpLoad %9 %21
|
||||||
%24 = OpCompositeExtract %8 %23 0
|
%23 = OpCompositeExtract %8 %22 0
|
||||||
%25 = OpAccessChain %13 %20 %12
|
%24 = OpBitcast %1 %23
|
||||||
%26 = OpLoad %9 %25
|
%25 = OpAccessChain %26 %5 %12
|
||||||
%27 = OpCompositeExtract %8 %26 1
|
%27 = OpAccessChain %13 %19 %12
|
||||||
%28 = OpIMul %8 %24 %27
|
%28 = OpLoad %9 %27
|
||||||
%29 = OpBitcast %1 %28
|
%29 = OpCompositeExtract %8 %28 0
|
||||||
%30 = OpAccessChain %31 %5 %12
|
%30 = OpAccessChain %31 %25 %29
|
||||||
%32 = OpAccessChain %13 %20 %12
|
OpStore %30 %24
|
||||||
%33 = OpLoad %9 %32
|
|
||||||
%34 = OpCompositeExtract %8 %33 0
|
|
||||||
%35 = OpAccessChain %13 %20 %12
|
|
||||||
%36 = OpLoad %9 %35
|
|
||||||
%37 = OpCompositeExtract %8 %36 1
|
|
||||||
%38 = OpIMul %8 %34 %37
|
|
||||||
%39 = OpAccessChain %40 %30 %38
|
|
||||||
OpStore %39 %29
|
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|||||||
@@ -212,7 +212,8 @@ fn populateMaps(self: *Self) ModuleError!void {
|
|||||||
if (result.variant == null or std.meta.activeTag(result.variant.?) != .Variable)
|
if (result.variant == null or std.meta.activeTag(result.variant.?) != .Variable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var current_set: usize = 0;
|
var set: ?usize = null;
|
||||||
|
var binding: ?usize = null;
|
||||||
|
|
||||||
for (result.decorations.items) |decoration| {
|
for (result.decorations.items) |decoration| {
|
||||||
switch (result.variant.?.Variable.storage_class) {
|
switch (result.variant.?.Variable.storage_class) {
|
||||||
@@ -235,14 +236,17 @@ fn populateMaps(self: *Self) ModuleError!void {
|
|||||||
.UniformConstant,
|
.UniformConstant,
|
||||||
=> {
|
=> {
|
||||||
switch (decoration.rtype) {
|
switch (decoration.rtype) {
|
||||||
.Binding => self.bindings[current_set][decoration.literal_1] = @intCast(id),
|
.Binding => binding = decoration.literal_1,
|
||||||
.DescriptorSet => current_set = decoration.literal_1,
|
.DescriptorSet => set = decoration.literal_1,
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (set != null and binding != null) {
|
||||||
|
self.bindings[set.?][binding.?] = @intCast(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user