diff --git a/CHANGELOG.md b/CHANGELOG.md index eb121071..efc4cfbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,9 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/ ## Unreleased -### Changed +### Changed +- Immediates no longer uses `WGPUPipelineLayoutExtras` chain, the `WGPUPipelineLayoutDescriptor` takes `uint32_t immediateSize` directily. By @Vipitis in [#583](https://github.com/gfx-rs/wgpu-native/pull/583). - Updated all wgpu crates to v29 - MSRV bumped from 1.82 to 1.87. - **Push constants renamed to immediates.** This matches the upstream wgpu rename. diff --git a/examples/immediates/main.c b/examples/immediates/main.c index e23f3e5b..178eedaa 100644 --- a/examples/immediates/main.c +++ b/examples/immediates/main.c @@ -100,14 +100,6 @@ int main(int argc, char *argv[]) { }); assert(staging_buffer); - WGPUPipelineLayoutExtras pipeline_layout_extras = { - .chain = - { - .sType = WGPUSType_PipelineLayoutExtras, - }, - .immediateDataSize = sizeof(uint32_t), - }; - WGPUBindGroupLayoutEntry bind_group_layout_entries[] = { { .binding = 0, @@ -130,9 +122,10 @@ int main(int argc, char *argv[]) { WGPUPipelineLayoutDescriptor pipeline_layout_desc = { .label = {"pipeline_layout", WGPU_STRLEN}, - .nextInChain = &pipeline_layout_extras.chain, + .nextInChain = NULL, .bindGroupLayouts = &bind_group_layout, .bindGroupLayoutCount = 1, + .immediateSize = sizeof(uint32_t), }; WGPUPipelineLayout pipeline_layout = wgpuDeviceCreatePipelineLayout(device, &pipeline_layout_desc); @@ -187,7 +180,7 @@ int main(int argc, char *argv[]) { for (uint32_t i = 0; i < numbers_length; i++) { uint32_t immediate = i; wgpuComputePassEncoderSetImmediates(compute_pass_encoder, 0, - sizeof(uint32_t), &immediate); + &immediate, sizeof(uint32_t)); wgpuComputePassEncoderDispatchWorkgroups(compute_pass_encoder, numbers_length, 1, 1); diff --git a/ffi/webgpu-headers b/ffi/webgpu-headers index 7d3186c3..673658bc 160000 --- a/ffi/webgpu-headers +++ b/ffi/webgpu-headers @@ -1 +1 @@ -Subproject commit 7d3186c3dd2c708703524027b46b8703534ab3cc +Subproject commit 673658bc2bd70ec39fc55ebe6bb0173cf6d0a603 diff --git a/ffi/wgpu.h b/ffi/wgpu.h index e370ea4e..3275a4da 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -21,24 +21,22 @@ typedef enum WGPUNativeSType WGPUSType_DeviceExtras = 0x00030001, /** Identifies @ref WGPUNativeLimits. */ WGPUSType_NativeLimits = 0x00030002, - /** Identifies @ref WGPUPipelineLayoutExtras. */ - WGPUSType_PipelineLayoutExtras = 0x00030003, /** Identifies @ref WGPUShaderSourceGLSL. */ - WGPUSType_ShaderSourceGLSL = 0x00030004, + WGPUSType_ShaderSourceGLSL = 0x00030003, /** Identifies @ref WGPUInstanceExtras. */ - WGPUSType_InstanceExtras = 0x00030006, + WGPUSType_InstanceExtras = 0x00030004, /** Identifies @ref WGPUBindGroupEntryExtras. */ - WGPUSType_BindGroupEntryExtras = 0x00030007, + WGPUSType_BindGroupEntryExtras = 0x00030005, /** Identifies @ref WGPUBindGroupLayoutEntryExtras. */ - WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, + WGPUSType_BindGroupLayoutEntryExtras = 0x00030006, /** Identifies @ref WGPUQuerySetDescriptorExtras. */ - WGPUSType_QuerySetDescriptorExtras = 0x00030009, + WGPUSType_QuerySetDescriptorExtras = 0x00030007, /** Identifies @ref WGPUSurfaceConfigurationExtras. */ - WGPUSType_SurfaceConfigurationExtras = 0x0003000A, + WGPUSType_SurfaceConfigurationExtras = 0x00030008, /** Identifies @ref WGPUSurfaceSourceSwapChainPanel. */ - WGPUSType_SurfaceSourceSwapChainPanel = 0x0003000B, + WGPUSType_SurfaceSourceSwapChainPanel = 0x00030009, /** Identifies @ref WGPUPrimitiveStateExtras. */ - WGPUSType_PrimitiveStateExtras = 0x0003000C, + WGPUSType_PrimitiveStateExtras = 0x0003000A, WGPUNativeSType_Force32 = 0x7FFFFFFF } WGPUNativeSType; @@ -96,8 +94,8 @@ typedef enum WGPUNativeFeature * Enables @ref wgpuRenderPassEncoderSetImmediates, * @ref wgpuComputePassEncoderSetImmediates, * @ref wgpuRenderBundleEncoderSetImmediates, - * non-zero @c immediateDataSize in @ref WGPUPipelineLayoutExtras, - * and non-zero @c maxImmediateSize in @ref WGPUNativeLimits. + * non-zero @c immediateSize in @ref WGPUPipelineLayout, + * and non-zero @c maxImmediateSize in @ref WGPULimits. * * A block of immediate data can be declared in WGSL with * @c var: @@ -1224,20 +1222,6 @@ typedef struct WGPUNativeLimits /*.maxMultiviewViewCount=*/WGPU_LIMIT_U32_UNDEFINED _wgpu_COMMA \ }) -typedef struct WGPUPipelineLayoutExtras -{ - WGPUChainedStruct chain; - /** - * The number of bytes of immediate data allocated for use in shaders - * attached to this pipeline. - * - * The @c var declarations in the shader must be equal or - * smaller than this size. If this value is non-zero, - * @ref WGPUNativeFeature_Immediates must be enabled. - */ - uint32_t immediateDataSize; -} WGPUPipelineLayoutExtras; - /** * Identifier for a particular call to @ref wgpuQueueSubmitForIndex. * @@ -1504,10 +1488,6 @@ extern "C" */ void *wgpuTextureGetNativeMetalTexture(WGPUTexture texture); - void wgpuRenderPassEncoderSetImmediates(WGPURenderPassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); - void wgpuComputePassEncoderSetImmediates(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const *data); - void wgpuRenderBundleEncoderSetImmediates(WGPURenderBundleEncoder encoder, 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); diff --git a/src/conv.rs b/src/conv.rs index 2a241d9f..c03b11bd 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -495,7 +495,6 @@ pub(crate) unsafe fn map_device_descriptor<'a>( #[inline] pub unsafe fn map_pipeline_layout_descriptor<'a>( des: &native::WGPUPipelineLayoutDescriptor, - extras: Option<&native::WGPUPipelineLayoutExtras>, ) -> wgc::binding_model::PipelineLayoutDescriptor<'a> { let bind_group_layouts = make_slice(des.bindGroupLayouts, des.bindGroupLayoutCount) .iter() @@ -509,7 +508,7 @@ pub unsafe fn map_pipeline_layout_descriptor<'a>( }) .collect::>(); - let immediate_size = extras.map_or(0, |extras| extras.immediateDataSize); + let immediate_size = des.immediateSize; wgc::binding_model::PipelineLayoutDescriptor { label: string_view_into_label(des.label), diff --git a/src/lib.rs b/src/lib.rs index 7488e584..9c2e6f32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2071,11 +2071,7 @@ pub unsafe extern "C" fn wgpuDeviceCreatePipelineLayout( }; let descriptor = descriptor.expect("invalid descriptor"); - let desc = follow_chain!( - map_pipeline_layout_descriptor( - (descriptor), - WGPUSType_PipelineLayoutExtras => native::WGPUPipelineLayoutExtras) - ); + let desc = map_pipeline_layout_descriptor(descriptor); let (pipeline_layout_id, error) = context.device_create_pipeline_layout(device_id, &desc, None); if let Some(cause) = error { handle_error( @@ -4503,8 +4499,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateShaderModuleSpirV( pub unsafe extern "C" fn wgpuRenderPassEncoderSetImmediates( pass: native::WGPURenderPassEncoder, offset: u32, - size_bytes: u32, data: *const u8, + size: u32, ) { let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().expect("invalid compute pass encoder"); @@ -4512,7 +4508,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetImmediates( match pass.context.render_pass_set_immediates( encoder, offset, - make_slice(data, size_bytes as usize), + make_slice(data, size as usize), ) { Ok(()) => (), Err(cause) => handle_error( @@ -4528,8 +4524,8 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetImmediates( pub unsafe extern "C" fn wgpuComputePassEncoderSetImmediates( pass: native::WGPUComputePassEncoder, offset: u32, - size_bytes: u32, data: *const u8, + size: u32, ) { let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().expect("invalid compute pass encoder"); @@ -4537,7 +4533,7 @@ pub unsafe extern "C" fn wgpuComputePassEncoderSetImmediates( match pass.context.compute_pass_set_immediates( encoder, offset, - make_slice(data, size_bytes as usize), + make_slice(data, size as usize), ) { Ok(()) => (), Err(cause) => handle_error( @@ -4553,15 +4549,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderSetImmediates( pub unsafe extern "C" fn wgpuRenderBundleEncoderSetImmediates( bundle: native::WGPURenderBundleEncoder, offset: u32, - size_bytes: u32, data: *const u8, + size: u32, ) { let bundle = bundle.as_ref().expect("invalid render bundle"); let encoder = bundle.encoder.as_mut().expect("invalid render bundle"); let encoder = encoder.expect("invalid render bundle"); let encoder = encoder.as_mut().unwrap(); - bundle_ffi::wgpu_render_bundle_set_immediates(encoder, offset, size_bytes, data); + bundle_ffi::wgpu_render_bundle_set_immediates(encoder, offset, size, data); } #[no_mangle]