Skip to content

Commit

Permalink
Implemented create_render_bundle_encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
B1nus authored and MendyBerger committed Nov 15, 2024
1 parent 78612e1 commit 7d545cc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/wasi-webgpu-wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ wasmtime::component::bindgen!({
"wasi:webgpu/webgpu/gpu-compute-pass-encoder": ComputePass,
"wasi:webgpu/webgpu/gpu-shader-module": wgpu_core::id::ShaderModuleId,
"wasi:webgpu/webgpu/gpu-render-pipeline": wgpu_core::id::RenderPipelineId,
"wasi:webgpu/webgpu/gpu-render-bundle-encoder": wgpu_core::command::RenderBundleEncoder,
"wasi:webgpu/webgpu/gpu-command-buffer": wgpu_core::id::CommandBufferId,
"wasi:webgpu/webgpu/gpu-buffer": Buffer,
"wasi:webgpu/webgpu/non-standard-buffer": BufferPtr,
Expand Down Expand Up @@ -819,10 +820,12 @@ impl<T: WasiWebGpuView> webgpu::HostGpuDevice for WasiWebGpuImpl<T> {

fn create_render_bundle_encoder(
&mut self,
_device: Resource<webgpu::GpuDevice>,
_descriptor: webgpu::GpuRenderBundleEncoderDescriptor,
device: Resource<webgpu::GpuDevice>,
descriptor: webgpu::GpuRenderBundleEncoderDescriptor,
) -> Resource<webgpu::GpuRenderBundleEncoder> {
todo!()
let device = self.0.table().get(&device).unwrap().device;
let render_bundle_encoder = wgpu_core::command::RenderBundleEncoder::new(&descriptor.to_core(&self.0.table()), device, None).unwrap();
self.0.table().push(render_bundle_encoder).unwrap()
}

fn create_query_set(
Expand Down
28 changes: 28 additions & 0 deletions crates/wasi-webgpu-wasmtime/src/to_core_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,34 @@ impl ToCore<wgpu_types::ImageCopyBuffer<wgpu_core::id::BufferId>> for webgpu::Gp
}
}

impl<'a> ToCore<wgpu_core::command::RenderBundleEncoderDescriptor<'a>>
for webgpu::GpuRenderBundleEncoderDescriptor
{
fn to_core(
self,
_table: &ResourceTable,
) -> wgpu_core::command::RenderBundleEncoderDescriptor<'a> {
wgpu_core::command::RenderBundleEncoderDescriptor {
label: self.label.map(|l| l.into()),
color_formats: self
.color_formats
.iter()
.map(|f| f.map(|f| f.into()))
.collect::<Vec<_>>()
.into(),
depth_stencil: self.depth_stencil_format.map(|f| {
wgpu_types::RenderBundleDepthStencil {
format: f.into(),
depth_read_only: self.depth_read_only.unwrap_or(false),
stencil_read_only: self.stencil_read_only.unwrap_or(false),
}
}),
sample_count: self.sample_count.unwrap_or(1),
multiview: None,
}
}
}

impl<'a> ToCore<wgpu_types::QuerySetDescriptor<wgpu_core::Label<'a>>>
for webgpu::GpuQuerySetDescriptor
{
Expand Down

0 comments on commit 7d545cc

Please sign in to comment.