diff --git a/wgpu-core-remote-types/src/encoders.rs b/wgpu-core-remote-types/src/encoders.rs index 4a3cb3313..2fb4b593b 100644 --- a/wgpu-core-remote-types/src/encoders.rs +++ b/wgpu-core-remote-types/src/encoders.rs @@ -8,6 +8,33 @@ pub type TexelCopyTextureInfo = wgt::TexelCopyTextureInfo; pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor>; pub type CommandBufferDescriptor<'a> = wgt::CommandBufferDescriptor>; +/// Describes a `RenderBundleEncoder`. +/// +/// Corresponds to [WebGPU `GPURenderBundleEncoderDescriptor`](https://gpuweb.github.io/gpuweb/#dictdef-gpurenderbundleencoderdescriptor). +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] +pub struct RenderBundleEncoderDescriptor<'a> { + /// Debug label of the render bundle encoder. + /// + /// This will show up in graphics debuggers for easy identification. + pub label: Label<'a>, + /// The formats of the color attachments that this render bundle is capable + /// to rendering to. + /// + /// This must match the formats of the color attachments in the + /// renderpass this render bundle is executed in. + pub color_formats: Cow<'a, [Option]>, + /// Information about the depth attachment that this render bundle is + /// capable to rendering to. + /// + /// The format must match the format of the depth attachments in the + /// renderpass this render bundle is executed in. + pub depth_stencil: Option, + /// Sample count this render bundle is capable of rendering to. + /// + /// This must match the pipelines and the renderpasses it is used in. + pub sample_count: u32, +} + /// Operation to perform to the output attachment at the start of a render pass. /// /// Corresponds to [WebGPU `GPULoadOp`](https://gpuweb.github.io/gpuweb/#enumdef-gpuloadop), diff --git a/wgpu-core-remote/src/global/device.rs b/wgpu-core-remote/src/global/device.rs index 4b66f7324..dd96760d0 100644 --- a/wgpu-core-remote/src/global/device.rs +++ b/wgpu-core-remote/src/global/device.rs @@ -2,7 +2,7 @@ use alloc::{borrow::Cow, boxed::Box, sync::Arc, vec::Vec}; use core::ops::Deref; use core::ptr::NonNull; use wgpu_core_remote_types::{ - encoders::RenderBundleDescriptor, + encoders::{RenderBundleDescriptor, RenderBundleEncoderDescriptor}, pipelines::{ComputePipelineDescriptor, RenderPipelineDescriptor}, BufferDescriptor, ExternalTextureDescriptor, PipelineLayoutDescriptor, SamplerDescriptor, ShaderModuleDescriptor, TextureDescriptor, TextureViewDescriptor, @@ -678,7 +678,7 @@ impl Global { pub fn device_create_render_bundle_encoder( &self, device_id: DeviceId, - desc: &command::RenderBundleEncoderDescriptor, + desc: &RenderBundleEncoderDescriptor, id_in: id::RenderBundleEncoderId, ) -> Result<(), MissingFeatures> { let mut hub = self.hub.borrow_mut(); @@ -689,7 +689,16 @@ impl Global { } = &mut *hub; let device = devices.get(device_id); - let render_bundle_encoder = device.create_render_bundle_encoder(desc)?; + + let desc = command::RenderBundleEncoderDescriptor { + label: desc.label.as_ref().map(|l| Cow::Borrowed(l.as_ref())), + color_formats: Cow::Borrowed(&desc.color_formats), + depth_stencil: desc.depth_stencil, + sample_count: desc.sample_count, + multiview: None, + }; + + let render_bundle_encoder = device.create_render_bundle_encoder(&desc)?; render_bundle_encoders.assign(id_in, *render_bundle_encoder);