| ... | @@ -296,9 +296,8 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void { | ... | @@ -296,9 +296,8 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void { |
| 296 | // TODO: Integrate with a hypothetical feature system | 296 | // TODO: Integrate with a hypothetical feature system |
| 297 | const caps: []const spec.Capability = switch (target.os.tag) { | 297 | const caps: []const spec.Capability = switch (target.os.tag) { |
| 298 | .opencl => &.{ .Kernel, .Addresses, .Int8, .Int16, .Int64, .Float64, .Float16, .Vector16, .GenericPointer }, | 298 | .opencl => &.{ .Kernel, .Addresses, .Int8, .Int16, .Int64, .Float64, .Float16, .Vector16, .GenericPointer }, |
| 299 | .opengl => &.{.Shader}, | 299 | .vulkan => &.{ .Shader, .PhysicalStorageBufferAddresses, .StoragePushConstant16, .Int8, .Int16, .Int64, .Float64, .Float16 }, |
| 300 | .vulkan => &.{ .Shader, .VariablePointersStorageBuffer, .Int8, .Int16, .Int64, .Float64, .Float16 }, | 300 | else => unreachable, |
| 301 | else => unreachable, // TODO | | |
| 302 | }; | 301 | }; |
| 303 | | 302 | |
| 304 | for (caps) |cap| { | 303 | for (caps) |cap| { |
| ... | @@ -306,19 +305,32 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void { | ... | @@ -306,19 +305,32 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void { |
| 306 | .capability = cap, | 305 | .capability = cap, |
| 307 | }); | 306 | }); |
| 308 | } | 307 | } |
| | 308 | |
| | 309 | switch (target.os.tag) { |
| | 310 | .vulkan => { |
| | 311 | try spv.sections.extensions.emit(gpa, .OpExtension, .{ |
| | 312 | .name = "SPV_KHR_physical_storage_buffer", |
| | 313 | }); |
| | 314 | }, |
| | 315 | else => {}, |
| | 316 | } |
| 309 | } | 317 | } |
| 310 | | 318 | |
| 311 | fn writeMemoryModel(spv: *SpvModule, target: std.Target) !void { | 319 | fn writeMemoryModel(spv: *SpvModule, target: std.Target) !void { |
| 312 | const gpa = spv.gpa; | 320 | const gpa = spv.gpa; |
| 313 | | 321 | |
| 314 | const addressing_model = switch (target.os.tag) { | 322 | const addressing_model: spec.AddressingModel = switch (target.os.tag) { |
| 315 | .opencl => switch (target.cpu.arch) { | 323 | .opencl => switch (target.cpu.arch) { |
| 316 | .spirv32 => spec.AddressingModel.Physical32, | 324 | .spirv32 => .Physical32, |
| 317 | .spirv64 => spec.AddressingModel.Physical64, | 325 | .spirv64 => .Physical64, |
| 318 | else => unreachable, // TODO | 326 | else => unreachable, |
| | 327 | }, |
| | 328 | .opengl, .vulkan => switch (target.cpu.arch) { |
| | 329 | .spirv32 => .Logical, // TODO: I don't think this will ever be implemented. |
| | 330 | .spirv64 => .PhysicalStorageBuffer64, |
| | 331 | else => unreachable, |
| 319 | }, | 332 | }, |
| 320 | .opengl, .vulkan => spec.AddressingModel.Logical, | 333 | else => unreachable, |
| 321 | else => unreachable, // TODO | | |
| 322 | }; | 334 | }; |
| 323 | | 335 | |
| 324 | const memory_model: spec.MemoryModel = switch (target.os.tag) { | 336 | const memory_model: spec.MemoryModel = switch (target.os.tag) { |