Skip to content

Commit

Permalink
Expose missing native features up to v0.19.4 (#384)
Browse files Browse the repository at this point in the history
* Expose missing native features up to v0.19.4

* Comment out native features that require API change
  • Loading branch information
davnotdev authored May 7, 2024
1 parent d89e5a9 commit 85563e5
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ typedef enum WGPUNativeFeature {
WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008,
WGPUNativeFeature_StorageResourceBindingArray = 0x00030009,
WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A,
WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B,
WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C,
// TODO: requires wgpu.h api change
// WGPUNativeFeature_TimestampQueryInsidePasses = 0x0003000D,
WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E,
WGPUNativeFeature_BufferBindingArray = 0x0003000F,
WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010,
// TODO: requires wgpu.h api change
// WGPUNativeFeature_AddressModeClampToZero = 0x00030011,
// WGPUNativeFeature_AddressModeClampToBorder = 0x00030012,
// WGPUNativeFeature_PolygonModeLine = 0x00030013,
// WGPUNativeFeature_PolygonModePoint = 0x00030014,
// WGPUNativeFeature_ConservativeRasterization = 0x00030015,
// WGPUNativeFeature_ClearTexture = 0x00030016,
// WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017,
// WGPUNativeFeature_Multiview = 0x00030018,
WGPUNativeFeature_VertexAttribute64bit = 0x00030019,
WGPUNativeFeature_ShaderUnusedVertexOutput = 0x0003001A,
WGPUNativeFeature_TextureFormatNv12 = 0x0003001B,
WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001C,
WGPUNativeFeature_RayQuery = 0x0003001D,
WGPUNativeFeature_ShaderF64 = 0x0003001E,
WGPUNativeFeature_ShaderI16 = 0x0003001F,
WGPUNativeFeature_ShaderPrimitiveIndex = 0x00030020,
WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030021,
WGPUNativeFeature_Force32 = 0x7FFFFFFF
} WGPUNativeFeature;

Expand Down
97 changes: 97 additions & 0 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,79 @@ pub fn features_to_native(features: wgt::Features) -> Vec<native::WGPUFeatureNam
if features.contains(wgt::Features::PARTIALLY_BOUND_BINDING_ARRAY) {
temp.push(native::WGPUNativeFeature_PartiallyBoundBindingArray);
}
if features.contains(wgt::Features::TEXTURE_FORMAT_16BIT_NORM) {
temp.push(native::WGPUNativeFeature_TextureFormat16bitNorm);
}
if features.contains(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR) {
temp.push(native::WGPUNativeFeature_TextureCompressionAstcHdr);
}
// TODO: requires wgpu.h api change
// if features.contains(wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES) {
// temp.push(native::WGPUNativeFeature_TimestampQueryInsidePasses);
// }
if features.contains(wgt::Features::MAPPABLE_PRIMARY_BUFFERS) {
temp.push(native::WGPUNativeFeature_MappablePrimaryBuffers);
}
if features.contains(wgt::Features::BUFFER_BINDING_ARRAY) {
temp.push(native::WGPUNativeFeature_BufferBindingArray);
}
if features
.contains(wgt::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING)
{
temp.push(native::WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing);
}
// TODO: requires wgpu.h api change
// if features.contains(wgt::Features::ADDRESS_MODE_CLAMP_TO_ZERO) {
// temp.push(native::WGPUNativeFeature_AddressModeClampToZero);
// }
// if features.contains(wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER) {
// temp.push(native::WGPUNativeFeature_AddressModeClampToBorder);
// }
// if features.contains(wgt::Features::POLYGON_MODE_LINE) {
// temp.push(native::WGPUNativeFeature_PolygonModeLine);
// }
// if features.contains(wgt::Features::POLYGON_MODE_POINT) {
// temp.push(native::WGPUNativeFeature_PolygonModePoint);
// }
// if features.contains(wgt::Features::CONSERVATIVE_RASTERIZATION) {
// temp.push(native::WGPUNativeFeature_ConservativeRasterization);
// }
// if features.contains(wgt::Features::CLEAR_TEXTURE) {
// temp.push(native::WGPUNativeFeature_ClearTexture);
// }
// if features.contains(wgt::Features::SPIRV_SHADER_PASSTHROUGH) {
// temp.push(native::WGPUNativeFeature_SpirvShaderPassthrough);
// }
// if features.contains(wgt::Features::MULTIVIEW) {
// temp.push(native::WGPUNativeFeature_Multiview);
// }
if features.contains(wgt::Features::VERTEX_ATTRIBUTE_64BIT) {
temp.push(native::WGPUNativeFeature_VertexAttribute64bit);
}
if features.contains(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT) {
temp.push(native::WGPUNativeFeature_ShaderUnusedVertexOutput);
}
if features.contains(wgt::Features::TEXTURE_FORMAT_NV12) {
temp.push(native::WGPUNativeFeature_TextureFormatNv12);
}
if features.contains(wgt::Features::RAY_TRACING_ACCELERATION_STRUCTURE) {
temp.push(native::WGPUNativeFeature_RayTracingAccelerationStructure);
}
if features.contains(wgt::Features::RAY_QUERY) {
temp.push(native::WGPUNativeFeature_RayQuery);
}
if features.contains(wgt::Features::SHADER_F64) {
temp.push(native::WGPUNativeFeature_ShaderF64);
}
if features.contains(wgt::Features::SHADER_I16) {
temp.push(native::WGPUNativeFeature_ShaderI16);
}
if features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX) {
temp.push(native::WGPUNativeFeature_ShaderPrimitiveIndex);
}
if features.contains(wgt::Features::SHADER_EARLY_DEPTH_TEST) {
temp.push(native::WGPUNativeFeature_ShaderEarlyDepthTest);
}

temp
}
Expand Down Expand Up @@ -1148,6 +1221,30 @@ pub fn map_feature(feature: native::WGPUFeatureName) -> Option<wgt::Features> {
native::WGPUNativeFeature_PipelineStatisticsQuery => Some(Features::PIPELINE_STATISTICS_QUERY),
native::WGPUNativeFeature_StorageResourceBindingArray => Some(Features::STORAGE_RESOURCE_BINDING_ARRAY),
native::WGPUNativeFeature_PartiallyBoundBindingArray => Some(Features::PARTIALLY_BOUND_BINDING_ARRAY),
native::WGPUNativeFeature_TextureFormat16bitNorm => Some(Features::TEXTURE_FORMAT_16BIT_NORM),
native::WGPUNativeFeature_TextureCompressionAstcHdr => Some(Features::TEXTURE_COMPRESSION_ASTC_HDR),
// TODO: requires wgpu.h api change
// native::WGPUNativeFeature_TimestampQueryInsidePasses => Some(Features::TIMESTAMP_QUERY_INSIDE_PASSES),
native::WGPUNativeFeature_MappablePrimaryBuffers => Some(Features::MAPPABLE_PRIMARY_BUFFERS),
native::WGPUNativeFeature_BufferBindingArray => Some(Features::BUFFER_BINDING_ARRAY),
native::WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing => Some(Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING),
// TODO: requires wgpu.h api change
// native::WGPUNativeFeature_AddressModeClampToZero => Some(Features::ADDRESS_MODE_CLAMP_TO_ZERO),
// native::WGPUNativeFeature_AddressModeClampToBorder => Some(Features::ADDRESS_MODE_CLAMP_TO_BORDER),
// native::WGPUNativeFeature_PolygonModeLine => Some(Features::POLYGON_MODE_LINE),
// native::WGPUNativeFeature_PolygonModePoint => Some(Features::POLYGON_MODE_POINT),
// native::WGPUNativeFeature_ConservativeRasterization => Some(Features::CONSERVATIVE_RASTERIZATION),
// native::WGPUNativeFeature_ClearTexture => Some(Features::CLEAR_TEXTURE),
// native::WGPUNativeFeature_SpirvShaderPassthrough => Some(Features::SPIRV_SHADER_PASSTHROUGH),
// native::WGPUNativeFeature_Multiview => Some(Features::MULTIVIEW),
native::WGPUNativeFeature_VertexAttribute64bit => Some(Features::VERTEX_ATTRIBUTE_64BIT),
native::WGPUNativeFeature_ShaderUnusedVertexOutput => Some(Features::SHADER_UNUSED_VERTEX_OUTPUT),
native::WGPUNativeFeature_TextureFormatNv12 => Some(Features::TEXTURE_FORMAT_NV12),
native::WGPUNativeFeature_RayTracingAccelerationStructure => Some(Features::RAY_TRACING_ACCELERATION_STRUCTURE),
native::WGPUNativeFeature_RayQuery => Some(Features::RAY_QUERY),
native::WGPUNativeFeature_ShaderF64 => Some(Features::SHADER_F64),
native::WGPUNativeFeature_ShaderPrimitiveIndex => Some(Features::SHADER_PRIMITIVE_INDEX),
native::WGPUNativeFeature_ShaderEarlyDepthTest => Some(Features::SHADER_EARLY_DEPTH_TEST),
// fallback, probably not available in wgpu-core
_ => None,
}
Expand Down

0 comments on commit 85563e5

Please sign in to comment.