Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ impl super::Instance {
depth_stencil_required_flags(),
),
multi_draw_indirect: phd_features.core.multi_draw_indirect != 0,
max_draw_indirect_count: phd_capabilities.properties.limits.max_draw_indirect_count,
non_coherent_map_mask: phd_capabilities.properties.limits.non_coherent_atom_size - 1,
can_present: true,
//TODO: make configurable
Expand Down
48 changes: 36 additions & 12 deletions wgpu-hal/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,23 +1128,45 @@ impl crate::CommandEncoder for super::CommandEncoder {
offset: wgt::BufferAddress,
draw_count: u32,
) {
unsafe {
self.device.raw.cmd_draw_indirect(
self.active,
buffer.raw,
offset,
draw_count,
size_of::<wgt::DrawIndirectArgs>() as u32,
)
};
if draw_count >= 1
&& self.device.private_caps.multi_draw_indirect
&& draw_count <= self.device.private_caps.max_draw_indirect_count
{
unsafe {
self.device.raw.cmd_draw_indirect(
self.active,
buffer.raw,
offset,
draw_count,
size_of::<wgt::DrawIndirectArgs>() as u32,
)
};
} else {
for i in 0..draw_count {
unsafe {
self.device.raw.cmd_draw_indirect(
self.active,
buffer.raw,
offset
+ i as wgt::BufferAddress
* size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress,
1,
size_of::<wgt::DrawIndirectArgs>() as u32,
)
};
}
}
}
unsafe fn draw_indexed_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
if draw_count >= 1 && self.device.private_caps.multi_draw_indirect {
if draw_count >= 1
&& self.device.private_caps.multi_draw_indirect
&& draw_count <= self.device.private_caps.max_draw_indirect_count
{
unsafe {
self.device.raw.cmd_draw_indexed_indirect(
self.active,
Expand All @@ -1155,12 +1177,14 @@ impl crate::CommandEncoder for super::CommandEncoder {
)
};
} else {
for _ in 0..draw_count {
for i in 0..draw_count {
unsafe {
self.device.raw.cmd_draw_indexed_indirect(
self.active,
buffer.raw,
offset,
offset
+ i as wgt::BufferAddress
* size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress,
1,
size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
)
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct PrivateCapabilities {
can_present: bool,
non_coherent_map_mask: wgt::BufferAddress,
multi_draw_indirect: bool,
max_draw_indirect_count: u32,

/// True if this adapter advertises the [`robustBufferAccess`][vrba] feature.
///
Expand Down