authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-03-09 06:42:38+03:30
committergravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-03-17 21:56:17+03:30
log78ad866dd1fc49cb826215002274991201cbb89e
treec220fd66f7560f1b116272f1840a3ced5a788315
parentc1977bf0fbe523afb4721bc8346ee6536e3c0aa2

target: split `addresses` and `physical_storage_buffer` features


2 files changed, 18 insertions(+), 13 deletions(-)

lib/std/Target/spirv.zig+13-7
...@@ -15,13 +15,14 @@ pub const Feature = enum {...@@ -15,13 +15,14 @@ pub const Feature = enum {
15 int64,15 int64,
16 float16,16 float16,
17 float64,17 float64,
18 addresses,
19 matrix,18 matrix,
20 storage_push_constant16,19 storage_push_constant16,
21 kernel,20 kernel,
21 addresses,
22 generic_pointer,22 generic_pointer,
23 vector16,23 vector16,
24 shader,24 shader,
25 physical_storage_buffer,
25};26};
2627
27pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet;28pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet;
...@@ -94,11 +95,6 @@ pub const all_features = blk: {...@@ -94,11 +95,6 @@ pub const all_features = blk: {
94 .description = "Enable Float64 capability",95 .description = "Enable Float64 capability",
95 .dependencies = featureSet(&[_]Feature{.v1_0}),96 .dependencies = featureSet(&[_]Feature{.v1_0}),
96 };97 };
97 result[@intFromEnum(Feature.addresses)] = .{
98 .llvm_name = null,
99 .description = "Enable either the Addresses capability or, SPV_KHR_physical_storage_buffer extension and the PhysicalStorageBufferAddresses capability",
100 .dependencies = featureSet(&[_]Feature{.v1_0}),
101 };
102 result[@intFromEnum(Feature.matrix)] = .{98 result[@intFromEnum(Feature.matrix)] = .{
103 .llvm_name = null,99 .llvm_name = null,
104 .description = "Enable Matrix capability",100 .description = "Enable Matrix capability",
...@@ -114,6 +110,11 @@ pub const all_features = blk: {...@@ -114,6 +110,11 @@ pub const all_features = blk: {
114 .description = "Enable Kernel capability",110 .description = "Enable Kernel capability",
115 .dependencies = featureSet(&[_]Feature{.v1_0}),111 .dependencies = featureSet(&[_]Feature{.v1_0}),
116 };112 };
113 result[@intFromEnum(Feature.addresses)] = .{
114 .llvm_name = null,
115 .description = "Enable Addresses capability",
116 .dependencies = featureSet(&[_]Feature{.v1_0}),
117 };
117 result[@intFromEnum(Feature.generic_pointer)] = .{118 result[@intFromEnum(Feature.generic_pointer)] = .{
118 .llvm_name = null,119 .llvm_name = null,
119 .description = "Enable GenericPointer capability",120 .description = "Enable GenericPointer capability",
...@@ -129,6 +130,11 @@ pub const all_features = blk: {...@@ -129,6 +130,11 @@ pub const all_features = blk: {
129 .description = "Enable Shader capability",130 .description = "Enable Shader capability",
130 .dependencies = featureSet(&[_]Feature{ .v1_0, .matrix }),131 .dependencies = featureSet(&[_]Feature{ .v1_0, .matrix }),
131 };132 };
133 result[@intFromEnum(Feature.physical_storage_buffer)] = .{
134 .llvm_name = null,
135 .description = "Enable SPV_KHR_physical_storage_buffer extension and the PhysicalStorageBufferAddresses capability",
136 .dependencies = featureSet(&[_]Feature{.v1_0}),
137 };
132 const ti = @typeInfo(Feature);138 const ti = @typeInfo(Feature);
133 for (&result, 0..) |*elem, i| {139 for (&result, 0..) |*elem, i| {
134 elem.index = i;140 elem.index = i;
...@@ -147,7 +153,7 @@ pub const cpu = struct {...@@ -147,7 +153,7 @@ pub const cpu = struct {
147 pub const vulkan_v1_2: CpuModel = .{153 pub const vulkan_v1_2: CpuModel = .{
148 .name = "vulkan_v1_2",154 .name = "vulkan_v1_2",
149 .llvm_name = null,155 .llvm_name = null,
150 .features = featureSet(&[_]Feature{ .v1_5, .shader, .addresses }),156 .features = featureSet(&[_]Feature{ .v1_5, .shader, .physical_storage_buffer }),
151 };157 };
152158
153 pub const opencl_v2: CpuModel = .{159 pub const opencl_v2: CpuModel = .{
src/codegen/spirv/Module.zig+5-6
...@@ -343,18 +343,17 @@ pub fn finalize(self: *Module, a: Allocator) ![]Word {...@@ -343,18 +343,17 @@ pub fn finalize(self: *Module, a: Allocator) ![]Word {
343 try self.addExtension("SPV_KHR_16bit_storage");343 try self.addExtension("SPV_KHR_16bit_storage");
344 try self.addCapability(.StoragePushConstant16);344 try self.addCapability(.StoragePushConstant16);
345 },345 },
346 .addresses => if (self.hasFeature(.shader)) {346 .addresses => try self.addCapability(.Addresses),
347 try self.addExtension("SPV_KHR_physical_storage_buffer");
348 try self.addCapability(.PhysicalStorageBufferAddresses);
349 } else {
350 try self.addCapability(.Addresses);
351 },
352 // Kernel347 // Kernel
353 .kernel => try self.addCapability(.Kernel),348 .kernel => try self.addCapability(.Kernel),
354 .generic_pointer => try self.addCapability(.GenericPointer),349 .generic_pointer => try self.addCapability(.GenericPointer),
355 .vector16 => try self.addCapability(.Vector16),350 .vector16 => try self.addCapability(.Vector16),
356 // Shader351 // Shader
357 .shader => try self.addCapability(.Shader),352 .shader => try self.addCapability(.Shader),
353 .physical_storage_buffer => {
354 try self.addExtension("SPV_KHR_physical_storage_buffer");
355 try self.addCapability(.PhysicalStorageBufferAddresses);
356 },
358 }357 }
359 }358 }
360 }359 }