mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 00:33:51 +00:00
Add BGL Deduplication Index Test (#4914)
This commit is contained in:
parent
87ecc089dd
commit
79e5169255
@ -1,8 +1,10 @@
|
||||
use wgpu_test::{gpu_test, GpuTestConfiguration};
|
||||
use wgpu_test::{gpu_test, GpuTestConfiguration, TestingContext};
|
||||
|
||||
#[gpu_test]
|
||||
static BIND_GROUP_LAYOUT_DEDUPLICATION: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
.run_sync(|ctx| {
|
||||
static BIND_GROUP_LAYOUT_DEDUPLICATION: GpuTestConfiguration =
|
||||
GpuTestConfiguration::new().run_sync(bgl_dedupe);
|
||||
|
||||
fn bgl_dedupe(ctx: TestingContext) {
|
||||
let entries_1 = &[];
|
||||
|
||||
let entries_2 = &[wgpu::BindGroupLayoutEntry {
|
||||
@ -16,6 +18,8 @@ static BIND_GROUP_LAYOUT_DEDUPLICATION: GpuTestConfiguration = GpuTestConfigurat
|
||||
count: None,
|
||||
}];
|
||||
|
||||
// Block so we can force all resource to die.
|
||||
{
|
||||
let bgl_1a = ctx
|
||||
.device
|
||||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
@ -23,7 +27,7 @@ static BIND_GROUP_LAYOUT_DEDUPLICATION: GpuTestConfiguration = GpuTestConfigurat
|
||||
entries: entries_1,
|
||||
});
|
||||
|
||||
let _bgl_2 = ctx
|
||||
let bgl_2 = ctx
|
||||
.device
|
||||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: None,
|
||||
@ -135,8 +139,44 @@ static BIND_GROUP_LAYOUT_DEDUPLICATION: GpuTestConfiguration = GpuTestConfigurat
|
||||
}
|
||||
|
||||
ctx.queue.submit(Some(encoder.finish()));
|
||||
|
||||
// Abuse the fact that global_id is really just the bitpacked ids when targeting wgpu-core.
|
||||
if ctx.adapter_info.backend != wgt::Backend::BrowserWebGpu {
|
||||
let bgl_1a_idx = bgl_1a.global_id().inner() & 0xFFFF_FFFF;
|
||||
assert_eq!(bgl_1a_idx, 0);
|
||||
let bgl_2_idx = bgl_2.global_id().inner() & 0xFFFF_FFFF;
|
||||
assert_eq!(bgl_2_idx, 1);
|
||||
let bgl_1b_idx = bgl_1b.global_id().inner() & 0xFFFF_FFFF;
|
||||
assert_eq!(bgl_1b_idx, 2);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.device.poll(wgpu::Maintain::Wait);
|
||||
|
||||
if ctx.adapter_info.backend != wgt::Backend::BrowserWebGpu {
|
||||
// Now all of the BGL ids should be dead, so we should get the same ids again.
|
||||
for i in 0..=2 {
|
||||
let test_bgl = ctx
|
||||
.device
|
||||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: None,
|
||||
entries: entries_1,
|
||||
});
|
||||
|
||||
let test_bgl_idx = test_bgl.global_id().inner() & 0xFFFF_FFFF;
|
||||
|
||||
// https://github.com/gfx-rs/wgpu/issues/4912
|
||||
//
|
||||
// ID 2 is the deduplicated ID, which is never properly recycled.
|
||||
if i == 2 {
|
||||
assert_eq!(test_bgl_idx, 3);
|
||||
} else {
|
||||
assert_eq!(test_bgl_idx, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const SHADER_SRC: &str = "
|
||||
@vertex fn vs_main() -> @builtin(position) vec4<f32> { return vec4<f32>(1.0); }
|
||||
@fragment fn fs_main() -> @location(0) vec4<f32> { return vec4<f32>(1.0); }
|
||||
|
Loading…
Reference in New Issue
Block a user