Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #320 to v0.18 #321

Merged
merged 1 commit into from
Nov 23, 2023
Merged
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
41 changes: 28 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub struct WGPUComputePassEncoderImpl {
pub struct WGPUComputePipelineImpl {
context: Arc<Context>,
id: id::ComputePipelineId,
error_sink: ErrorSink,
}
impl Drop for WGPUComputePipelineImpl {
fn drop(&mut self) {
Expand Down Expand Up @@ -245,6 +246,7 @@ pub struct WGPURenderPassEncoderImpl {
pub struct WGPURenderPipelineImpl {
context: Arc<Context>,
id: id::RenderPipelineId,
error_sink: ErrorSink,
}
impl Drop for WGPURenderPipelineImpl {
fn drop(&mut self) {
Expand Down Expand Up @@ -1680,17 +1682,21 @@ pub unsafe extern "C" fn wgpuComputePipelineGetBindGroupLayout(
pipeline: native::WGPUComputePipeline,
group_index: u32,
) -> native::WGPUBindGroupLayout {
let (pipeline_id, context) = {
let (pipeline_id, context, error_sink) = {
let pipeline = pipeline.as_ref().expect("invalid pipeline");
(pipeline.id, &pipeline.context)
(pipeline.id, &pipeline.context, &pipeline.error_sink)
};

let (bind_group_layout_id, error) = gfx_select!(pipeline_id => context.compute_pipeline_get_bind_group_layout(pipeline_id, group_index, ()));
if let Some(cause) = error {
panic!(
"Error in wgpuComputePipelineGetBindGroupLayout: Error reflecting bind group {group_index}: {f}",
f = format_error(context, &cause)
);
handle_error(
context,
error_sink,
cause,
"",
None,
"wgpuComputePipelineGetBindGroupLayout",
)
}

Arc::into_raw(Arc::new(WGPUBindGroupLayoutImpl {
Expand Down Expand Up @@ -1945,6 +1951,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateComputePipeline(
Arc::into_raw(Arc::new(WGPUComputePipelineImpl {
context: context.clone(),
id: compute_pipeline_id,
error_sink: error_sink.clone(),
}))
}

Expand Down Expand Up @@ -2227,6 +2234,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline(
Arc::into_raw(Arc::new(WGPURenderPipelineImpl {
context: context.clone(),
id: render_pipeline_id,
error_sink: error_sink.clone(),
}))
}

Expand Down Expand Up @@ -3500,17 +3508,24 @@ pub unsafe extern "C" fn wgpuRenderPipelineGetBindGroupLayout(
render_pipeline: native::WGPURenderPipeline,
group_index: u32,
) -> native::WGPUBindGroupLayout {
let (render_pipeline_id, context) = {
let (render_pipeline_id, context, error_sink) = {
let render_pipeline = render_pipeline.as_ref().expect("invalid render pipeline");
(render_pipeline.id, &render_pipeline.context)
(
render_pipeline.id,
&render_pipeline.context,
&render_pipeline.error_sink,
)
};

let (bind_group_layout_id, error) = gfx_select!(render_pipeline_id => context.render_pipeline_get_bind_group_layout(render_pipeline_id, group_index, ()));
if let Some(cause) = error {
panic!(
"Error in wgpuRenderPipelineGetBindGroupLayout: Error reflecting bind group {group_index}: {f}",
f = format_error(context, &cause)
);
handle_error(
context,
error_sink,
cause,
"",
None,
"wgpuRenderPipelineGetBindGroupLayout",
)
}

Arc::into_raw(Arc::new(WGPUBindGroupLayoutImpl {
Expand Down
Loading