Skip to content

Commit 8bb34d0

Browse files
committed
Address review notes
1 parent 5578222 commit 8bb34d0

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

wgpu-hal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ It's a spiritual successor to [gfx-hal](https://github.com/gfx-rs/gfx),
33
but with reduced scope, and oriented towards WebGPU implementation goals.
44

55
It has no overhead for validation or tracking, and the API translation overhead is kept to the bare minimum by the design of WebGPU.
6-
This API can be used for resource-demaninging applications and engines.
6+
This API can be used for resource-demanding applications and engines.
77

88
# Usage notes
99

wgpu-hal/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub trait Queue<A: Api>: Send + Sync {
306306
) -> Result<(), SurfaceError>;
307307
}
308308

309-
/// Encoder for commands in a command buffers.
309+
/// Encoder for commands in command buffers.
310310
/// Serves as a parent for all the encoded command buffers.
311311
/// Works in bursts of action: one or more command buffers are recorded,
312312
/// then submitted to a queue, and then it needs to be `reset_all()`.
@@ -317,7 +317,7 @@ pub trait CommandEncoder<A: Api>: Send + Sync {
317317
unsafe fn discard_encoding(&mut self);
318318
unsafe fn end_encoding(&mut self) -> Result<A::CommandBuffer, DeviceError>;
319319
/// Reclaims all resources that are allocated for this encoder.
320-
/// Must be passed back all of the command buffers,
320+
/// Must get all of the produced command buffers back,
321321
/// and they must not be used by GPU at this moment.
322322
unsafe fn reset_all<I>(&mut self, command_buffers: I)
323323
where

wgpu-hal/src/vulkan/command.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -615,19 +615,27 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
615615
offset: wgt::BufferAddress,
616616
draw_count: u32,
617617
) {
618-
self.device
619-
.raw
620-
.cmd_draw_indirect(self.active, buffer.raw, offset, draw_count, 0);
618+
self.device.raw.cmd_draw_indirect(
619+
self.active,
620+
buffer.raw,
621+
offset,
622+
draw_count,
623+
mem::size_of::<wgt::DrawIndirectArgs>() as u64,
624+
);
621625
}
622626
unsafe fn draw_indexed_indirect(
623627
&mut self,
624628
buffer: &super::Buffer,
625629
offset: wgt::BufferAddress,
626630
draw_count: u32,
627631
) {
628-
self.device
629-
.raw
630-
.cmd_draw_indexed_indirect(self.active, buffer.raw, offset, draw_count, 0);
632+
self.device.raw.cmd_draw_indexed_indirect(
633+
self.active,
634+
buffer.raw,
635+
offset,
636+
draw_count,
637+
mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u64,
638+
);
631639
}
632640
unsafe fn draw_indirect_count(
633641
&mut self,
@@ -637,6 +645,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
637645
count_offset: wgt::BufferAddress,
638646
max_count: u32,
639647
) {
648+
let stride = mem::size_of::<wgt::DrawIndirectArgs>() as u64;
640649
match self.device.extension_fns.draw_indirect_count {
641650
Some(super::ExtensionFn::Extension(ref t)) => {
642651
t.cmd_draw_indirect_count(
@@ -646,7 +655,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
646655
count_buffer.raw,
647656
count_offset,
648657
max_count,
649-
0,
658+
stride,
650659
);
651660
}
652661
Some(super::ExtensionFn::Promoted) => {
@@ -657,7 +666,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
657666
count_buffer.raw,
658667
count_offset,
659668
max_count,
660-
0,
669+
stride,
661670
);
662671
}
663672
None => panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"),
@@ -671,6 +680,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
671680
count_offset: wgt::BufferAddress,
672681
max_count: u32,
673682
) {
683+
let stride = mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u64;
674684
match self.device.extension_fns.draw_indirect_count {
675685
Some(super::ExtensionFn::Extension(ref t)) => {
676686
t.cmd_draw_indexed_indirect_count(
@@ -680,7 +690,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
680690
count_buffer.raw,
681691
count_offset,
682692
max_count,
683-
0,
693+
stride,
684694
);
685695
}
686696
Some(super::ExtensionFn::Promoted) => {
@@ -691,7 +701,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
691701
count_buffer.raw,
692702
count_offset,
693703
max_count,
694-
0,
704+
stride,
695705
);
696706
}
697707
None => panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"),

0 commit comments

Comments
 (0)