Skip to content

Commit 7184973

Browse files
committed
Move enum Command from device::trace to command::encoder_command.
1 parent c0c1607 commit 7184973

File tree

10 files changed

+98
-94
lines changed

10 files changed

+98
-94
lines changed

player/src/lib.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
extern crate wgpu_core as wgc;
77
extern crate wgpu_types as wgt;
88

9-
use wgc::{device::trace, identity::IdentityManager};
9+
use wgc::{command::Command, device::trace, identity::IdentityManager};
1010

1111
use std::{borrow::Cow, fs, path::Path};
1212

1313
pub trait GlobalPlay {
1414
fn encode_commands(
1515
&self,
1616
encoder: wgc::id::CommandEncoderId,
17-
commands: Vec<trace::Command>,
17+
commands: Vec<Command>,
1818
command_buffer_id_manager: &mut IdentityManager<wgc::id::markers::CommandBuffer>,
1919
) -> wgc::id::CommandBufferId;
2020
fn process(
@@ -32,12 +32,12 @@ impl GlobalPlay for wgc::global::Global {
3232
fn encode_commands(
3333
&self,
3434
encoder: wgc::id::CommandEncoderId,
35-
commands: Vec<trace::Command>,
35+
commands: Vec<Command>,
3636
command_buffer_id_manager: &mut IdentityManager<wgc::id::markers::CommandBuffer>,
3737
) -> wgc::id::CommandBufferId {
3838
for command in commands {
3939
match command {
40-
trace::Command::CopyBufferToBuffer {
40+
Command::CopyBufferToBuffer {
4141
src,
4242
src_offset,
4343
dst,
@@ -48,31 +48,31 @@ impl GlobalPlay for wgc::global::Global {
4848
encoder, src, src_offset, dst, dst_offset, size,
4949
)
5050
.unwrap(),
51-
trace::Command::CopyBufferToTexture { src, dst, size } => self
51+
Command::CopyBufferToTexture { src, dst, size } => self
5252
.command_encoder_copy_buffer_to_texture(encoder, &src, &dst, &size)
5353
.unwrap(),
54-
trace::Command::CopyTextureToBuffer { src, dst, size } => self
54+
Command::CopyTextureToBuffer { src, dst, size } => self
5555
.command_encoder_copy_texture_to_buffer(encoder, &src, &dst, &size)
5656
.unwrap(),
57-
trace::Command::CopyTextureToTexture { src, dst, size } => self
57+
Command::CopyTextureToTexture { src, dst, size } => self
5858
.command_encoder_copy_texture_to_texture(encoder, &src, &dst, &size)
5959
.unwrap(),
60-
trace::Command::ClearBuffer { dst, offset, size } => self
60+
Command::ClearBuffer { dst, offset, size } => self
6161
.command_encoder_clear_buffer(encoder, dst, offset, size)
6262
.unwrap(),
63-
trace::Command::ClearTexture {
63+
Command::ClearTexture {
6464
dst,
6565
subresource_range,
6666
} => self
6767
.command_encoder_clear_texture(encoder, dst, &subresource_range)
6868
.unwrap(),
69-
trace::Command::WriteTimestamp {
69+
Command::WriteTimestamp {
7070
query_set_id,
7171
query_index,
7272
} => self
7373
.command_encoder_write_timestamp(encoder, query_set_id, query_index)
7474
.unwrap(),
75-
trace::Command::ResolveQuerySet {
75+
Command::ResolveQuerySet {
7676
query_set_id,
7777
start_query,
7878
query_count,
@@ -88,16 +88,14 @@ impl GlobalPlay for wgc::global::Global {
8888
destination_offset,
8989
)
9090
.unwrap(),
91-
trace::Command::PushDebugGroup(marker) => self
91+
Command::PushDebugGroup(marker) => self
9292
.command_encoder_push_debug_group(encoder, &marker)
9393
.unwrap(),
94-
trace::Command::PopDebugGroup => {
95-
self.command_encoder_pop_debug_group(encoder).unwrap()
96-
}
97-
trace::Command::InsertDebugMarker(marker) => self
94+
Command::PopDebugGroup => self.command_encoder_pop_debug_group(encoder).unwrap(),
95+
Command::InsertDebugMarker(marker) => self
9896
.command_encoder_insert_debug_marker(encoder, &marker)
9997
.unwrap(),
100-
trace::Command::RunComputePass {
98+
Command::RunComputePass {
10199
base,
102100
timestamp_writes,
103101
} => {
@@ -107,7 +105,7 @@ impl GlobalPlay for wgc::global::Global {
107105
timestamp_writes.as_ref(),
108106
);
109107
}
110-
trace::Command::RunRenderPass {
108+
Command::RunRenderPass {
111109
base,
112110
target_colors,
113111
target_depth_stencil,
@@ -123,7 +121,7 @@ impl GlobalPlay for wgc::global::Global {
123121
occlusion_query_set_id,
124122
);
125123
}
126-
trace::Command::BuildAccelerationStructures { blas, tlas } => {
124+
Command::BuildAccelerationStructures { blas, tlas } => {
127125
let blas_iter = blas.iter().map(|x| {
128126
let geometries = match &x.geometries {
129127
wgc::ray_tracing::TraceBlasGeometries::TriangleGeometries(

wgpu-core/src/command/clear.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use alloc::{sync::Arc, vec::Vec};
22
use core::ops::Range;
33

44
#[cfg(feature = "trace")]
5-
use crate::device::trace::Command as TraceCommand;
5+
use crate::command::Command as TraceCommand;
66
use crate::{
77
api_log,
88
command::EncoderStateError,

wgpu-core/src/command/compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl Global {
438438
let cmd_buf_data = cmd_buf_data.get_inner();
439439

440440
if let Some(ref mut list) = cmd_buf_data.commands {
441-
list.push(crate::device::trace::Command::RunComputePass {
441+
list.push(crate::command::Command::RunComputePass {
442442
base: BasePass {
443443
label: base.label.clone(),
444444
error: None,
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use core::convert::Infallible;
2+
3+
use alloc::{string::String, vec::Vec};
4+
5+
use crate::id;
6+
7+
#[derive(Clone, Debug)]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9+
pub enum Command {
10+
CopyBufferToBuffer {
11+
src: id::BufferId,
12+
src_offset: wgt::BufferAddress,
13+
dst: id::BufferId,
14+
dst_offset: wgt::BufferAddress,
15+
size: Option<wgt::BufferAddress>,
16+
},
17+
CopyBufferToTexture {
18+
src: crate::command::TexelCopyBufferInfo,
19+
dst: crate::command::TexelCopyTextureInfo,
20+
size: wgt::Extent3d,
21+
},
22+
CopyTextureToBuffer {
23+
src: crate::command::TexelCopyTextureInfo,
24+
dst: crate::command::TexelCopyBufferInfo,
25+
size: wgt::Extent3d,
26+
},
27+
CopyTextureToTexture {
28+
src: crate::command::TexelCopyTextureInfo,
29+
dst: crate::command::TexelCopyTextureInfo,
30+
size: wgt::Extent3d,
31+
},
32+
ClearBuffer {
33+
dst: id::BufferId,
34+
offset: wgt::BufferAddress,
35+
size: Option<wgt::BufferAddress>,
36+
},
37+
ClearTexture {
38+
dst: id::TextureId,
39+
subresource_range: wgt::ImageSubresourceRange,
40+
},
41+
WriteTimestamp {
42+
query_set_id: id::QuerySetId,
43+
query_index: u32,
44+
},
45+
ResolveQuerySet {
46+
query_set_id: id::QuerySetId,
47+
start_query: u32,
48+
query_count: u32,
49+
destination: id::BufferId,
50+
destination_offset: wgt::BufferAddress,
51+
},
52+
PushDebugGroup(String),
53+
PopDebugGroup,
54+
InsertDebugMarker(String),
55+
RunComputePass {
56+
base: crate::command::BasePass<crate::command::ComputeCommand, Infallible>,
57+
timestamp_writes: Option<crate::command::PassTimestampWrites>,
58+
},
59+
RunRenderPass {
60+
base: crate::command::BasePass<crate::command::RenderCommand, Infallible>,
61+
target_colors: Vec<Option<crate::command::RenderPassColorAttachment>>,
62+
target_depth_stencil: Option<crate::command::RenderPassDepthStencilAttachment>,
63+
timestamp_writes: Option<crate::command::PassTimestampWrites>,
64+
occlusion_query_set_id: Option<id::QuerySetId>,
65+
},
66+
BuildAccelerationStructures {
67+
blas: Vec<crate::ray_tracing::TraceBlasBuildEntry>,
68+
tlas: Vec<crate::ray_tracing::TraceTlasPackage>,
69+
},
70+
}

wgpu-core/src/command/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod compute;
66
mod compute_command;
77
mod draw;
88
mod encoder;
9+
mod encoder_command;
910
mod memory_init;
1011
mod pass;
1112
mod query;
@@ -22,8 +23,8 @@ use core::ops;
2223

2324
pub(crate) use self::clear::clear_texture;
2425
pub use self::{
25-
bundle::*, clear::ClearError, compute::*, compute_command::ComputeCommand, draw::*, query::*,
26-
render::*, render_command::RenderCommand, transfer::*,
26+
bundle::*, clear::ClearError, compute::*, compute_command::ComputeCommand, draw::*,
27+
encoder_command::Command, query::*, render::*, render_command::RenderCommand, transfer::*,
2728
};
2829
pub(crate) use allocator::CommandAllocator;
2930

@@ -55,7 +56,7 @@ use wgt::error::{ErrorType, WebGpuError};
5556
use thiserror::Error;
5657

5758
#[cfg(feature = "trace")]
58-
use crate::device::trace::Command as TraceCommand;
59+
type TraceCommand = Command;
5960

6061
const PUSH_CONSTANT_CLEAR_ARRAY: &[u32] = &[0_u32; 64];
6162

wgpu-core/src/command/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use alloc::{sync::Arc, vec, vec::Vec};
22
use core::{iter, mem};
33

44
#[cfg(feature = "trace")]
5-
use crate::device::trace::Command as TraceCommand;
5+
use crate::command::Command as TraceCommand;
66
use crate::{
77
command::{CommandEncoder, EncoderStateError},
88
device::{DeviceError, MissingFeatures},

wgpu-core/src/command/ray_tracing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl Global {
201201
cmd_buf_data.record_with(|cmd_buf_data| {
202202
#[cfg(feature = "trace")]
203203
if let Some(ref mut list) = cmd_buf_data.commands {
204-
list.push(crate::device::trace::Command::BuildAccelerationStructures {
204+
list.push(crate::command::Command::BuildAccelerationStructures {
205205
blas: trace_blas.clone(),
206206
tlas: trace_tlas.clone(),
207207
});

wgpu-core/src/command/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ impl Global {
17531753
let cmd_buf_data = cmd_buf_data.get_inner();
17541754

17551755
if let Some(ref mut list) = cmd_buf_data.commands {
1756-
list.push(crate::device::trace::Command::RunRenderPass {
1756+
list.push(crate::command::Command::RunRenderPass {
17571757
base: BasePass {
17581758
label: base.label.clone(),
17591759
error: None,

wgpu-core/src/command/transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use wgt::{
99
};
1010

1111
#[cfg(feature = "trace")]
12-
use crate::device::trace::Command as TraceCommand;
12+
use crate::command::Command as TraceCommand;
1313
use crate::{
1414
api_log,
1515
command::{clear_texture, CommandEncoderError, EncoderStateError},

wgpu-core/src/device/trace.rs

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{convert::Infallible, ops::Range};
44
#[cfg(feature = "trace")]
55
use {alloc::borrow::Cow, std::io::Write as _};
66

7-
use crate::id;
7+
use crate::{command::Command, id};
88

99
//TODO: consider a readable Id that doesn't include the backend
1010

@@ -159,71 +159,6 @@ pub enum Action<'a> {
159159
DestroyTlas(id::TlasId),
160160
}
161161

162-
#[derive(Debug)]
163-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
164-
pub enum Command {
165-
CopyBufferToBuffer {
166-
src: id::BufferId,
167-
src_offset: wgt::BufferAddress,
168-
dst: id::BufferId,
169-
dst_offset: wgt::BufferAddress,
170-
size: Option<wgt::BufferAddress>,
171-
},
172-
CopyBufferToTexture {
173-
src: crate::command::TexelCopyBufferInfo,
174-
dst: crate::command::TexelCopyTextureInfo,
175-
size: wgt::Extent3d,
176-
},
177-
CopyTextureToBuffer {
178-
src: crate::command::TexelCopyTextureInfo,
179-
dst: crate::command::TexelCopyBufferInfo,
180-
size: wgt::Extent3d,
181-
},
182-
CopyTextureToTexture {
183-
src: crate::command::TexelCopyTextureInfo,
184-
dst: crate::command::TexelCopyTextureInfo,
185-
size: wgt::Extent3d,
186-
},
187-
ClearBuffer {
188-
dst: id::BufferId,
189-
offset: wgt::BufferAddress,
190-
size: Option<wgt::BufferAddress>,
191-
},
192-
ClearTexture {
193-
dst: id::TextureId,
194-
subresource_range: wgt::ImageSubresourceRange,
195-
},
196-
WriteTimestamp {
197-
query_set_id: id::QuerySetId,
198-
query_index: u32,
199-
},
200-
ResolveQuerySet {
201-
query_set_id: id::QuerySetId,
202-
start_query: u32,
203-
query_count: u32,
204-
destination: id::BufferId,
205-
destination_offset: wgt::BufferAddress,
206-
},
207-
PushDebugGroup(String),
208-
PopDebugGroup,
209-
InsertDebugMarker(String),
210-
RunComputePass {
211-
base: crate::command::BasePass<crate::command::ComputeCommand, Infallible>,
212-
timestamp_writes: Option<crate::command::PassTimestampWrites>,
213-
},
214-
RunRenderPass {
215-
base: crate::command::BasePass<crate::command::RenderCommand, Infallible>,
216-
target_colors: Vec<Option<crate::command::RenderPassColorAttachment>>,
217-
target_depth_stencil: Option<crate::command::RenderPassDepthStencilAttachment>,
218-
timestamp_writes: Option<crate::command::PassTimestampWrites>,
219-
occlusion_query_set_id: Option<id::QuerySetId>,
220-
},
221-
BuildAccelerationStructures {
222-
blas: Vec<crate::ray_tracing::TraceBlasBuildEntry>,
223-
tlas: Vec<crate::ray_tracing::TraceTlasPackage>,
224-
},
225-
}
226-
227162
#[cfg(feature = "trace")]
228163
#[derive(Debug)]
229164
pub struct Trace {

0 commit comments

Comments
 (0)