Skip to content

Commit

Permalink
implement SUBGROUP, SUBGROUP_VERTEX, SUBGROUP_BARRIER features (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackgomez authored Oct 11, 2024
1 parent 716b62c commit e3bbc26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ typedef enum WGPUNativeFeature {
WGPUNativeFeature_ShaderI16 = 0x0003001E,
WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F,
WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020,
WGPUNativeFeature_Subgroup = 0x00030021,
WGPUNativeFeature_SubgroupVertex = 0x00030022,
WGPUNativeFeature_SubgroupBarrier = 0x00030023,
WGPUNativeFeature_Force32 = 0x7FFFFFFF
} WGPUNativeFeature;

Expand Down
12 changes: 12 additions & 0 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,15 @@ pub fn features_to_native(features: wgt::Features) -> Vec<native::WGPUFeatureNam
if features.contains(wgt::Features::SHADER_EARLY_DEPTH_TEST) {
temp.push(native::WGPUNativeFeature_ShaderEarlyDepthTest);
}
if features.contains(wgt::Features::SUBGROUP) {
temp.push(native::WGPUNativeFeature_Subgroup);
}
if features.contains(wgt::Features::SUBGROUP_VERTEX) {
temp.push(native::WGPUNativeFeature_SubgroupVertex);
}
if features.contains(wgt::Features::SUBGROUP_BARRIER) {
temp.push(native::WGPUNativeFeature_SubgroupBarrier);
}

temp
}
Expand Down Expand Up @@ -1273,6 +1282,9 @@ pub fn map_feature(feature: native::WGPUFeatureName) -> Option<wgt::Features> {
native::WGPUNativeFeature_ShaderF64 => Some(Features::SHADER_F64),
native::WGPUNativeFeature_ShaderPrimitiveIndex => Some(Features::SHADER_PRIMITIVE_INDEX),
native::WGPUNativeFeature_ShaderEarlyDepthTest => Some(Features::SHADER_EARLY_DEPTH_TEST),
native::WGPUNativeFeature_Subgroup => Some(Features::SUBGROUP),
native::WGPUNativeFeature_SubgroupVertex => Some(Features::SUBGROUP_VERTEX),
native::WGPUNativeFeature_SubgroupBarrier => Some(Features::SUBGROUP_BARRIER),
// fallback, probably not available in wgpu-core
_ => None,
}
Expand Down

0 comments on commit e3bbc26

Please sign in to comment.