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

Fixed: enabling PARTIALLY_BOUND_BINDING_ARRAY does not get enabled on vulkan backend #3772

Merged
merged 5 commits into from
Jul 23, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Bottom level categories:

## Unreleased

### Bug Fixes

#### Vulkan
- Fix enabling `wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY` not being actually enabled in vulkan backend. By @39ali in[#3772](https://github.com/gfx-rs/wgpu/pull/3772).

## v0.17.0 (2023-07-20)

This is the first release that featured `wgpu-info` as a binary crate for getting information about what devices wgpu sees in your system. It can dump the information in both human readable format and json.
Expand Down Expand Up @@ -118,6 +123,7 @@ By @fornwall in [#3904](https://github.com/gfx-rs/wgpu/pull/3904) and [#3905](ht

- Fix incorrect aspect in barriers when using emulated Stencil8 textures. By @cwfitzgerald in [#3833](https://github.com/gfx-rs/wgpu/pull/3833).
- Implement depth-clip-control using depthClamp instead of VK_EXT_depth_clip_enable. By @AlbinBernhardssonARM [#3892](https://github.com/gfx-rs/wgpu/pull/3892).
- Fix enabling `wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY` not being actually enabled in vulkan backend. By @39ali in[#3772](https://github.com/gfx-rs/wgpu/pull/3772).
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved

#### Metal

Expand Down
108 changes: 108 additions & 0 deletions tests/tests/partially_bounded_arrays/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
use std::{borrow::Cow, num::NonZeroU32};

use wasm_bindgen_test::*;
use wgpu_test::{image::ReadbackBuffers, initialize_test, TestParameters};

#[test]
#[wasm_bindgen_test]
fn partially_bounded_array() {
initialize_test(
TestParameters::default()
.features(
wgpu::Features::TEXTURE_BINDING_ARRAY
| wgpu::Features::STORAGE_RESOURCE_BINDING_ARRAY
| wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY
| wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
)
.limits(wgpu::Limits::downlevel_defaults()),
|ctx| {
let device = &ctx.device;

let texture_extent = wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
};
let storage_texture = device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: texture_extent,
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba32Float,
usage: wgpu::TextureUsages::TEXTURE_BINDING
| wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::STORAGE_BINDING
| wgpu::TextureUsages::COPY_SRC,
view_formats: &[],
});

let texture_view = storage_texture.create_view(&wgpu::TextureViewDescriptor::default());

let bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("bind group layout"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::StorageTexture {
access: wgpu::StorageTextureAccess::WriteOnly,
format: wgpu::TextureFormat::Rgba32Float,
view_dimension: wgpu::TextureViewDimension::D2,
},

count: NonZeroU32::new(4),
}],
});

let cs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: None,
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
});

let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("main"),
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[],
});

let compute_pipeline =
device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
module: &cs_module,
entry_point: "main",
});

let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureViewArray(&[&texture_view]),
}],
layout: &bind_group_layout,
label: Some("bind group"),
});

let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
{
let mut cpass =
encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
cpass.set_pipeline(&compute_pipeline);
cpass.set_bind_group(0, &bind_group, &[]);
cpass.dispatch_workgroups(1, 1, 1);
}

let readback_buffers = ReadbackBuffers::new(&ctx.device, &storage_texture);
readback_buffers.copy_from(&ctx.device, &mut encoder, &storage_texture);

ctx.queue.submit(Some(encoder.finish()));

assert!(
readback_buffers
.check_buffer_contents(device, bytemuck::bytes_of(&[4.0f32, 3.0, 2.0, 1.0])),
"texture storage values are incorrect!"
);
},
)
}
11 changes: 11 additions & 0 deletions tests/tests/partially_bounded_arrays/shader.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@group(0)
@binding(0)
var texture_array_storage: binding_array<texture_storage_2d<rgba32float,write>,1>;

@compute
@workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {

textureStore(texture_array_storage[0],vec2<i32>(0,0), vec4<f32>(4.0,3.0,2.0,1.0));

}
1 change: 1 addition & 0 deletions tests/tests/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod encoder;
mod example_wgsl;
mod external_texture;
mod instance;
mod partially_bounded_arrays;
mod poll;
mod queue_transfer;
mod resource_descriptor_accessor;
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn depth_stencil_required_flags() -> vk::FormatFeatureFlags {
fn indexing_features() -> wgt::Features {
wgt::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
| wgt::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
| wgt::Features::PARTIALLY_BOUND_BINDING_ARRAY
}

/// Aggregate of the `vk::PhysicalDevice*Features` structs used by `gfx`.
Expand Down