Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add INDIRECT_FIRST_INSTANCE feature #2206

Merged
merged 1 commit into from
Nov 23, 2021
Merged
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/dx12/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl super::Adapter {

let mut features = wgt::Features::empty()
| wgt::Features::DEPTH_CLIP_CONTROL
| wgt::Features::INDIRECT_FIRST_INSTANCE
| wgt::Features::MAPPABLE_PRIMARY_BUFFERS
//TODO: Naga part
//| wgt::Features::TEXTURE_BINDING_ARRAY
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ impl super::PrivateCapabilities {

let mut features = F::empty()
| F::TEXTURE_COMPRESSION_BC
| F::INDIRECT_FIRST_INSTANCE
| F::MAPPABLE_PRIMARY_BUFFERS
| F::VERTEX_WRITABLE_STORAGE
| F::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
Expand Down
7 changes: 7 additions & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ impl PhysicalDeviceFeatures {
.image_cube_array(
downlevel_flags.contains(wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES),
)
.draw_indirect_first_instance(
requested_features.contains(wgt::Features::INDIRECT_FIRST_INSTANCE),
)
//.dual_src_blend(requested_features.contains(wgt::Features::DUAL_SRC_BLENDING))
.multi_draw_indirect(
requested_features.contains(wgt::Features::MULTI_DRAW_INDIRECT),
Expand Down Expand Up @@ -339,6 +342,10 @@ impl PhysicalDeviceFeatures {
self.core.fragment_stores_and_atomics != 0,
);

features.set(
F::INDIRECT_FIRST_INSTANCE,
self.core.draw_indirect_first_instance != 0,
);
//if self.core.dual_src_blend != 0
features.set(F::MULTI_DRAW_INDIRECT, self.core.multi_draw_indirect != 0);
features.set(F::POLYGON_MODE_LINE, self.core.fill_mode_non_solid != 0);
Expand Down
13 changes: 11 additions & 2 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ bitflags::bitflags! {
///
/// This is a web and native feature.
const TEXTURE_COMPRESSION_BC = 1 << 1;
/// Allows non-zero value for the "first instance" in indirect draw calls.
///
/// Supported Platforms:
/// - Vulkan (mostly)
/// - DX12
/// - Metal
///
/// This is a web and native feature.
const INDIRECT_FIRST_INSTANCE = 1 << 2;
/// Enables use of Timestamp Queries. These queries tell the current gpu timestamp when
/// all work before the query is finished. Call [`CommandEncoder::write_timestamp`],
/// [`RenderPassEncoder::write_timestamp`], or [`ComputePassEncoder::write_timestamp`] to
Expand All @@ -206,7 +215,7 @@ bitflags::bitflags! {
/// - DX12 (works)
///
/// This is a web and native feature.
const TIMESTAMP_QUERY = 1 << 2;
const TIMESTAMP_QUERY = 1 << 3;
/// Enables use of Pipeline Statistics Queries. These queries tell the count of various operations
/// performed between the start and stop call. Call [`RenderPassEncoder::begin_pipeline_statistics_query`] to start
/// a query, then call [`RenderPassEncoder::end_pipeline_statistics_query`] to stop one.
Expand All @@ -221,7 +230,7 @@ bitflags::bitflags! {
/// - DX12 (works)
///
/// This is a web and native feature.
const PIPELINE_STATISTICS_QUERY = 1 << 3;
const PIPELINE_STATISTICS_QUERY = 1 << 4;
/// Webgpu only allows the MAP_READ and MAP_WRITE buffer usage to be matched with
/// COPY_DST and COPY_SRC respectively. This removes this requirement.
///
Expand Down
10 changes: 6 additions & 4 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2591,8 +2591,9 @@ impl<'a> RenderPass<'a> {
/// struct DrawIndirect {
/// vertex_count: u32, // The number of vertices to draw.
/// instance_count: u32, // The number of instances to draw.
/// base_vertex: u32, // The Index of the first vertex to draw.
/// base_instance: u32, // The instance ID of the first instance to draw.
/// first_vertex: u32, // The Index of the first vertex to draw.
/// first_instance: u32, // The instance ID of the first instance to draw.
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
/// }
/// ```
pub fn draw_indirect(&mut self, indirect_buffer: &'a Buffer, indirect_offset: BufferAddress) {
Expand All @@ -2612,9 +2613,10 @@ impl<'a> RenderPass<'a> {
/// struct DrawIndexedIndirect {
/// vertex_count: u32, // The number of vertices to draw.
/// instance_count: u32, // The number of instances to draw.
/// base_index: u32, // The base index within the index buffer.
/// first_index: u32, // The base index within the index buffer.
/// vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
/// base_instance: u32, // The instance ID of the first instance to draw.
/// first_instance: u32, // The instance ID of the first instance to draw.
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled.
/// }
/// ```
pub fn draw_indexed_indirect(
Expand Down