Skip to content

Commit 2b48772

Browse files
fix(dx12): discard cmd. enc. buf. on drop
1 parent d4fe193 commit 2b48772

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

tests/tests/bind_group_layout_dedup.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use std::num::NonZeroU64;
22

3-
use wgpu_test::{
4-
fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters, TestingContext,
5-
};
6-
use wgt::Backends;
3+
use wgpu_test::{fail, gpu_test, GpuTestConfiguration, TestParameters, TestingContext};
74

85
const SHADER_SRC: &str = "
96
@group(0) @binding(0)
@@ -307,18 +304,10 @@ fn bgl_dedupe_derived(ctx: TestingContext) {
307304
ctx.queue.submit(Some(encoder.finish()));
308305
}
309306

310-
const DX12_VALIDATION_ERROR: &str = "The command allocator cannot be reset because a command list is currently being recorded with the allocator.";
311-
312307
#[gpu_test]
313308
static SEPARATE_PROGRAMS_HAVE_INCOMPATIBLE_DERIVED_BGLS: GpuTestConfiguration =
314309
GpuTestConfiguration::new()
315-
.parameters(
316-
TestParameters::default()
317-
.test_features_limits()
318-
.expect_fail(
319-
FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR),
320-
),
321-
)
310+
.parameters(TestParameters::default().test_features_limits())
322311
.run_sync(separate_programs_have_incompatible_derived_bgls);
323312

324313
fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) {
@@ -376,13 +365,7 @@ fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) {
376365
#[gpu_test]
377366
static DERIVED_BGLS_INCOMPATIBLE_WITH_REGULAR_BGLS: GpuTestConfiguration =
378367
GpuTestConfiguration::new()
379-
.parameters(
380-
TestParameters::default()
381-
.test_features_limits()
382-
.expect_fail(
383-
FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR),
384-
),
385-
)
368+
.parameters(TestParameters::default().test_features_limits())
386369
.run_sync(derived_bgls_incompatible_with_regular_bgls);
387370

388371
fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) {

tests/tests/encoder.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,9 @@ static DROP_QUEUE_BEFORE_CREATING_COMMAND_ENCODER: GpuTestConfiguration =
2121
device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
2222
});
2323

24-
// This test crashes on DX12 with the exception:
25-
//
26-
// ID3D12CommandAllocator::Reset: The command allocator cannot be reset because a
27-
// command list is currently being recorded with the allocator. [ EXECUTION ERROR
28-
// #543: COMMAND_ALLOCATOR_CANNOT_RESET]
29-
//
30-
// For now, we mark the test as failing on DX12.
3124
#[gpu_test]
3225
static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::new()
33-
.parameters(TestParameters::default().expect_fail(FailureCase::backend(wgpu::Backends::DX12)))
26+
.parameters(TestParameters::default())
3427
.run_sync(|ctx| {
3528
let mut encoder = ctx
3629
.device

wgpu-hal/src/dx12/command.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ impl super::Temp {
5656
}
5757
}
5858

59+
impl Drop for super::CommandEncoder {
60+
fn drop(&mut self) {
61+
use crate::CommandEncoder;
62+
unsafe { self.discard_encoding() }
63+
}
64+
}
65+
5966
impl super::CommandEncoder {
6067
unsafe fn begin_pass(&mut self, kind: super::PassKind, label: crate::Label) {
6168
let list = self.list.as_ref().unwrap();

wgpu-hal/src/dx12/device.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,7 @@ impl crate::Device<super::Api> for super::Device {
663663
end_of_pass_timer_query: None,
664664
})
665665
}
666-
unsafe fn destroy_command_encoder(&self, encoder: super::CommandEncoder) {
667-
if let Some(list) = encoder.list {
668-
list.close();
669-
}
670-
}
666+
unsafe fn destroy_command_encoder(&self, _encoder: super::CommandEncoder) {}
671667

672668
unsafe fn create_bind_group_layout(
673669
&self,

0 commit comments

Comments
 (0)