Web backend: call set_index_buffer with size as optional
Size must be passed to setIndexBuffer in Javascript as undefined in order for WebGGPU to use the default size, which is the full buffer size.
@@ -163,17 +163,24 @@ impl crate::RenderInner<Context> for RenderPass {
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) {
- let mapped_size = match size {
- Some(s) => s.get() as f64,
- None => 0f64,
- };
+ match size {
+ Some(s) => {
self.0.set_index_buffer_with_f64_and_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
- mapped_size,
+ s.get() as f64,
);
}
+ None => {
+ self.0.set_index_buffer_with_f64(
+ &buffer.0,
+ map_index_format(index_format),
+ offset as f64,
+ );
+ }
+ };
+ }
fn set_vertex_buffer(
&mut self,
slot: u32,
@@ -292,17 +299,24 @@ impl crate::RenderInner<Context> for RenderBundleEncoder {
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) {
- let mapped_size = match size {
- Some(s) => s.get() as f64,
- None => 0f64,
- };
+ match size {
+ Some(s) => {
self.0.set_index_buffer_with_f64_and_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
- mapped_size,
+ s.get() as f64,
);
}
+ None => {
+ self.0.set_index_buffer_with_f64(
+ &buffer.0,
+ map_index_format(index_format),
+ offset as f64,
+ );
+ }
+ };
+ }
fn set_vertex_buffer(
&mut self,
slot: u32,
