Skip to content

Commit

Permalink
fix push constants extension api (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajveermalviya authored Jan 10, 2024
1 parent 4726b67 commit be9457e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ typedef struct WGPUPushConstantRange {

typedef struct WGPUPipelineLayoutExtras {
WGPUChainedStruct chain;
uint32_t pushConstantRangeCount;
WGPUPushConstantRange* pushConstantRanges;
size_t pushConstantRangeCount;
WGPUPushConstantRange const * pushConstantRanges;
} WGPUPipelineLayoutExtras;

typedef uint64_t WGPUSubmissionIndex;
Expand Down Expand Up @@ -238,7 +238,7 @@ void wgpuSetLogLevel(WGPULogLevel level);

uint32_t wgpuGetVersion(void);

void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void* const data);
void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags 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);
Expand Down
19 changes: 8 additions & 11 deletions src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,14 @@ pub unsafe fn map_pipeline_layout_descriptor<'a>(
.collect::<Vec<_>>();

let push_constant_ranges = extras.map_or(Vec::new(), |extras| {
make_slice(
extras.pushConstantRanges,
extras.pushConstantRangeCount as usize,
)
.iter()
.map(|range| wgt::PushConstantRange {
stages: wgt::ShaderStages::from_bits(range.stages)
.expect("invalid shader stage for push constant range"),
range: range.start..range.end,
})
.collect()
make_slice(extras.pushConstantRanges, extras.pushConstantRangeCount)
.iter()
.map(|range| wgt::PushConstantRange {
stages: wgt::ShaderStages::from_bits(range.stages)
.expect("invalid shader stage for push constant range"),
range: range.start..range.end,
})
.collect()
});

return wgc::binding_model::PipelineLayoutDescriptor {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4100,7 +4100,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPushConstants(
stages: native::WGPUShaderStageFlags,
offset: u32,
size_bytes: u32,
size: *const u8,
data: *const u8,
) {
let pass = pass.as_ref().expect("invalid render pass");
let mut encoder = pass.encoder.write();
Expand All @@ -4110,7 +4110,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPushConstants(
wgt::ShaderStages::from_bits(stages).expect("invalid shader stage"),
offset,
size_bytes,
size,
data,
);
}

Expand Down

0 comments on commit be9457e

Please sign in to comment.