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.
This commit is contained in:
Andy Fiedler 2021-11-20 14:32:04 -05:00 committed by Dzmitry Malyshau
parent ed7f8a84a3
commit 385d9caa8d

View File

@ -163,16 +163,23 @@ 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,
s.get() as f64,
);
}
None => {
self.0.set_index_buffer_with_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
);
}
};
self.0.set_index_buffer_with_f64_and_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
mapped_size,
);
}
fn set_vertex_buffer(
&mut self,
@ -292,16 +299,23 @@ 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,
s.get() as f64,
);
}
None => {
self.0.set_index_buffer_with_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
);
}
};
self.0.set_index_buffer_with_f64_and_f64(
&buffer.0,
map_index_format(index_format),
offset as f64,
mapped_size,
);
}
fn set_vertex_buffer(
&mut self,