Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 3 additions & 10 deletions examples/immediates/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ffi/webgpu-headers
Submodule webgpu-headers updated 3 files
+19 −0 webgpu.h
+70 −0 webgpu.json
+54 −0 webgpu.yml
40 changes: 10 additions & 30 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<immediate>:
Expand Down Expand Up @@ -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<immediate> 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.
*
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -509,7 +508,7 @@ pub unsafe fn map_pipeline_layout_descriptor<'a>(
})
.collect::<Vec<_>>();

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),
Expand Down
18 changes: 7 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -4503,16 +4499,16 @@ 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");

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(
Expand All @@ -4528,16 +4524,16 @@ 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");

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(
Expand All @@ -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]
Expand Down