diff --git a/Cargo.lock b/Cargo.lock index 4d6fb8f8..d75cbb26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1351,6 +1351,6 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "xml-rs" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" +checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7" diff --git a/examples/vendor/glfw b/examples/vendor/glfw index b35641f4..d11cb377 160000 --- a/examples/vendor/glfw +++ b/examples/vendor/glfw @@ -1 +1 @@ -Subproject commit b35641f4a3c62aa86a0b3c983d163bc0fe36026d +Subproject commit d11cb3779b828116af6391dfc07c147fa5e0a1c3 diff --git a/ffi/webgpu-headers b/ffi/webgpu-headers index bac52083..c8b371dd 160000 --- a/ffi/webgpu-headers +++ b/ffi/webgpu-headers @@ -1 +1 @@ -Subproject commit bac520839ff5ed2e2b648ed540bd9ec45edbccbc +Subproject commit c8b371dd2ff8a2b028fdc0206af5958521181ba8 diff --git a/ffi/wgpu.h b/ffi/wgpu.h index c5eabaa8..0f5a613d 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -156,7 +156,7 @@ typedef struct WGPUDeviceExtras { typedef struct WGPUNativeLimits { /** This struct chain is used as mutable in some places and immutable in others. */ - WGPUChainedStructOut chain; + WGPUChainedStruct chain; uint32_t maxPushConstantSize; uint32_t maxNonSamplerBindings; } WGPUNativeLimits; @@ -287,38 +287,38 @@ typedef enum WGPUNativeTextureFormat { extern "C" { #endif -void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report); -size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); +WGPU_EXPORT void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report); +WGPU_EXPORT size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); -WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); +WGPU_EXPORT WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); -WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); +WGPU_EXPORT WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); +WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); -void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); +WGPU_EXPORT void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); -void wgpuSetLogLevel(WGPULogLevel level); +WGPU_EXPORT void wgpuSetLogLevel(WGPULogLevel level); -uint32_t wgpuGetVersion(void); +WGPU_EXPORT uint32_t wgpuGetVersion(void); -void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); -void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data); -void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); +WGPU_EXPORT void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); +WGPU_EXPORT void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data); +WGPU_EXPORT void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); -void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); -void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); +WGPU_EXPORT void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); +WGPU_EXPORT void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); -void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); -void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); +WGPU_EXPORT void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); +WGPU_EXPORT void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count); -void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); -void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); +WGPU_EXPORT void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +WGPU_EXPORT void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder); +WGPU_EXPORT void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +WGPU_EXPORT void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); -void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); -void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +WGPU_EXPORT void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +WGPU_EXPORT void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); #ifdef __cplusplus } // extern "C" diff --git a/src/conv.rs b/src/conv.rs index 318462f6..d951becd 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -460,14 +460,14 @@ pub fn write_limits_struct(wgt_limits: wgt::Limits, limits: &mut native::WGPULim limits.maxComputeWorkgroupSizeZ = wgt_limits.max_compute_workgroup_size_z; limits.maxComputeWorkgroupsPerDimension = wgt_limits.max_compute_workgroups_per_dimension; - if let Some(native::WGPUChainedStructOut { + if let Some(native::WGPUChainedStruct { sType: native::WGPUSType_NativeLimits, .. }) = unsafe { limits.nextInChain.as_ref() } { unsafe { let native_limits = std::mem::transmute::< - *mut native::WGPUChainedStructOut, + *mut native::WGPUChainedStruct, *mut native::WGPUNativeLimits, >(limits.nextInChain); (*native_limits).maxPushConstantSize = wgt_limits.max_push_constant_size; diff --git a/src/lib.rs b/src/lib.rs index 0ead55b3..fd6cf986 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -643,8 +643,10 @@ pub unsafe extern "C" fn wgpuCreateInstance( ) -> native::WGPUInstance { let instance_desc = match descriptor { Some(descriptor) => { - if descriptor.features.timedWaitAnyEnable != 0 - || descriptor.features.timedWaitAnyMaxCount > 0 + let timed_wait_any_max_count = descriptor.requiredLimits.as_ref().map_or(0, |x| x.timedWaitAnyMaxCount); + let required_features = make_slice(descriptor.requiredFeatures, descriptor.requiredFeatureCount); + if required_features.contains(&native::WGPUInstanceFeatureName_TimedWaitAny) + || timed_wait_any_max_count > 0 { panic!("Unsupported timed WaitAny features specified"); } @@ -663,13 +665,22 @@ pub unsafe extern "C" fn wgpuCreateInstance( } #[no_mangle] -pub unsafe extern "C" fn wgpuGetInstanceCapabilities( - capabilities: Option<&mut native::WGPUInstanceCapabilities>, +pub unsafe extern "C" fn wgpuGetInstanceFeatures( + features: Option<&mut native::WGPUSupportedInstanceFeatures> +) { + let features = features.expect("invalid return pointer \"features\""); + // WaitAny is currently completely unsupported, so... + features.featureCount = 0; + features.features = std::ptr::null(); +} + +#[no_mangle] +pub unsafe extern "C" fn wgpuGetInstanceLimits( + limits: Option<&mut native::WGPUInstanceLimits>, ) -> native::WGPUStatus { - let capabilities = capabilities.expect("invalid return pointer \"capabilities\""); + let limits = limits.expect("invalid return pointer \"limits\""); // WaitAny is currently completely unsupported, so... - capabilities.timedWaitAnyEnable = false as native::WGPUBool; - capabilities.timedWaitAnyMaxCount = 0; + limits.timedWaitAnyMaxCount = 0; native::WGPUStatus_Success } @@ -2778,7 +2789,7 @@ pub unsafe extern "C" fn wgpuInstanceRequestAdapter( no_adapter_backends: _, incompatible_surface_backends: _, } => native::WGPURequestAdapterStatus_Unavailable, - _ => native::WGPURequestAdapterStatus_Unknown, + _ => native::WGPURequestAdapterStatus_Error, }, std::ptr::null_mut(), str_into_string_view(&message), @@ -2904,6 +2915,7 @@ pub unsafe extern "C" fn wgpuQueueOnSubmittedWorkDone( let closure: wgc::device::queue::SubmittedWorkDoneClosure = Box::new(move || { callback( native::WGPUQueueWorkDoneStatus_Success, + utils::null_string_view(), userdata.get_1(), userdata.get_2(), ); diff --git a/src/unimplemented.rs b/src/unimplemented.rs index 45edcb19..1d0909bc 100644 --- a/src/unimplemented.rs +++ b/src/unimplemented.rs @@ -229,3 +229,38 @@ pub extern "C" fn wgpuInstanceWaitAny( ) -> native::WGPUWaitStatus { unimplemented!(); } + +#[no_mangle] +pub extern "C" fn wgpuHasInstanceFeature( + _feature: native::WGPUInstanceFeatureName, +) -> native::WGPUBool { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn wgpuBufferReadMappedRange( + _buffer: native::WGPUBuffer, + _offset: usize, + _data: *mut ::std::os::raw::c_void, + _size: usize, +) -> native::WGPUStatus { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn wgpuBufferWriteMappedRange( + _buffer: native::WGPUBuffer, + _offset: usize, + _data: *const ::std::os::raw::c_void, + _size: usize, +) -> native::WGPUStatus { + unimplemented!(); +} + +#[no_mangle] +pub extern "C" fn wgpuSupportedInstanceFeaturesFreeMembers( + _supported_instance_features: native::WGPUSupportedInstanceFeatures, +) { + unimplemented!(); +} + diff --git a/src/utils.rs b/src/utils.rs index 0793b39e..256de9ef 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -365,6 +365,13 @@ pub unsafe fn drop_string_view(view: native::WGPUStringView) { ))) } +pub fn null_string_view() -> native::WGPUStringView { + native::WGPUStringView{ + data: std::ptr::null(), + length: crate::conv::WGPU_STRLEN, + } +} + #[test] pub fn test_string_view_into_str() { let str = "Hello, world!";