Skip to content

Commit c9a7cbb

Browse files
fix: discard cmd. enc. buf. on drop
1 parent 665c075 commit c9a7cbb

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
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-core/src/command/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<A: HalApi> CommandEncoder<A> {
7575
Ok(())
7676
}
7777

78-
fn discard(&mut self) {
78+
pub(crate) fn discard(&mut self) {
7979
if self.is_open {
8080
self.is_open = false;
8181
unsafe { self.raw.discard_encoding() };
@@ -112,7 +112,7 @@ pub(crate) struct DestroyedBufferError(pub id::BufferId);
112112
pub(crate) struct DestroyedTextureError(pub id::TextureId);
113113

114114
pub struct CommandBufferMutable<A: HalApi> {
115-
encoder: CommandEncoder<A>,
115+
pub(crate) encoder: CommandEncoder<A>,
116116
status: CommandEncoderStatus,
117117
pub(crate) trackers: Tracker<A>,
118118
buffer_memory_init_actions: Vec<BufferInitTrackerAction<A>>,

wgpu-core/src/device/global.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ impl Global {
13771377
.command_buffers
13781378
.unregister(command_encoder_id.transmute())
13791379
{
1380+
cmd_buf.data.lock().as_mut().unwrap().encoder.discard();
13801381
cmd_buf
13811382
.device
13821383
.untrack(&cmd_buf.data.lock().as_ref().unwrap().trackers);

0 commit comments

Comments
 (0)