Skip to content

Commit

Permalink
Address review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jun 17, 2021
1 parent 5578222 commit 8bb34d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion wgpu-hal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ It's a spiritual successor to [gfx-hal](https://github.com/gfx-rs/gfx),
but with reduced scope, and oriented towards WebGPU implementation goals.

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

# Usage notes

Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub trait Queue<A: Api>: Send + Sync {
) -> Result<(), SurfaceError>;
}

/// Encoder for commands in a command buffers.
/// Encoder for commands in command buffers.
/// Serves as a parent for all the encoded command buffers.
/// Works in bursts of action: one or more command buffers are recorded,
/// then submitted to a queue, and then it needs to be `reset_all()`.
Expand All @@ -317,7 +317,7 @@ pub trait CommandEncoder<A: Api>: Send + Sync {
unsafe fn discard_encoding(&mut self);
unsafe fn end_encoding(&mut self) -> Result<A::CommandBuffer, DeviceError>;
/// Reclaims all resources that are allocated for this encoder.
/// Must be passed back all of the command buffers,
/// Must get all of the produced command buffers back,
/// and they must not be used by GPU at this moment.
unsafe fn reset_all<I>(&mut self, command_buffers: I)
where
Expand Down
30 changes: 20 additions & 10 deletions wgpu-hal/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,19 +615,27 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
offset: wgt::BufferAddress,
draw_count: u32,
) {
self.device
.raw
.cmd_draw_indirect(self.active, buffer.raw, offset, draw_count, 0);
self.device.raw.cmd_draw_indirect(
self.active,
buffer.raw,
offset,
draw_count,
mem::size_of::<wgt::DrawIndirectArgs>() as u64,
);
}
unsafe fn draw_indexed_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
self.device
.raw
.cmd_draw_indexed_indirect(self.active, buffer.raw, offset, draw_count, 0);
self.device.raw.cmd_draw_indexed_indirect(
self.active,
buffer.raw,
offset,
draw_count,
mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u64,
);
}
unsafe fn draw_indirect_count(
&mut self,
Expand All @@ -637,6 +645,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_offset: wgt::BufferAddress,
max_count: u32,
) {
let stride = mem::size_of::<wgt::DrawIndirectArgs>() as u64;
match self.device.extension_fns.draw_indirect_count {
Some(super::ExtensionFn::Extension(ref t)) => {
t.cmd_draw_indirect_count(
Expand All @@ -646,7 +655,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_buffer.raw,
count_offset,
max_count,
0,
stride,
);
}
Some(super::ExtensionFn::Promoted) => {
Expand All @@ -657,7 +666,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_buffer.raw,
count_offset,
max_count,
0,
stride,
);
}
None => panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"),
Expand All @@ -671,6 +680,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_offset: wgt::BufferAddress,
max_count: u32,
) {
let stride = mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u64;
match self.device.extension_fns.draw_indirect_count {
Some(super::ExtensionFn::Extension(ref t)) => {
t.cmd_draw_indexed_indirect_count(
Expand All @@ -680,7 +690,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_buffer.raw,
count_offset,
max_count,
0,
stride,
);
}
Some(super::ExtensionFn::Promoted) => {
Expand All @@ -691,7 +701,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
count_buffer.raw,
count_offset,
max_count,
0,
stride,
);
}
None => panic!("Feature `DRAW_INDIRECT_COUNT` not enabled"),
Expand Down

0 comments on commit 8bb34d0

Please sign in to comment.