Skip to content

Commit aaf52e9

Browse files
committed
Move some *Copy*Info types out of wgpu_core::command::transfer
In the future `transfer` will want to use the `Arc` versions of these types. I have exported them from `wgpu_core::command::ffi`, to document that these are used for FFI purposes, and from `wgpu_core::command`, for backwards compatibility, although I also change the in-tree uses to use them from `wgpu_types` instead of from `wgpu_core::command`.
1 parent d79a49a commit aaf52e9

File tree

7 files changed

+30
-17
lines changed

7 files changed

+30
-17
lines changed

wgpu-core/src/command/encoder_command.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ pub enum Command {
1515
size: Option<wgt::BufferAddress>,
1616
},
1717
CopyBufferToTexture {
18-
src: crate::command::TexelCopyBufferInfo,
19-
dst: crate::command::TexelCopyTextureInfo,
18+
src: wgt::TexelCopyBufferInfo<id::BufferId>,
19+
dst: wgt::TexelCopyTextureInfo<id::TextureId>,
2020
size: wgt::Extent3d,
2121
},
2222
CopyTextureToBuffer {
23-
src: crate::command::TexelCopyTextureInfo,
24-
dst: crate::command::TexelCopyBufferInfo,
23+
src: wgt::TexelCopyTextureInfo<id::TextureId>,
24+
dst: wgt::TexelCopyBufferInfo<id::BufferId>,
2525
size: wgt::Extent3d,
2626
},
2727
CopyTextureToTexture {
28-
src: crate::command::TexelCopyTextureInfo,
29-
dst: crate::command::TexelCopyTextureInfo,
28+
src: wgt::TexelCopyTextureInfo<id::TextureId>,
29+
dst: wgt::TexelCopyTextureInfo<id::TextureId>,
3030
size: wgt::Extent3d,
3131
},
3232
ClearBuffer {

wgpu-core/src/command/ffi.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Types that are useful for FFI bindings to `wgpu`.
2+
3+
use crate::id;
4+
5+
pub type TexelCopyBufferInfo = wgt::TexelCopyBufferInfo<id::BufferId>;
6+
pub type TexelCopyTextureInfo = wgt::TexelCopyTextureInfo<id::TextureId>;
7+
pub type CopyExternalImageDestInfo = wgt::CopyExternalImageDestInfo<id::TextureId>;

wgpu-core/src/command/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod compute_command;
77
mod draw;
88
mod encoder;
99
mod encoder_command;
10+
pub mod ffi;
1011
mod memory_init;
1112
mod pass;
1213
mod query;
@@ -58,6 +59,10 @@ use thiserror::Error;
5859
#[cfg(feature = "trace")]
5960
type TraceCommand = Command;
6061

62+
pub type TexelCopyBufferInfo = ffi::TexelCopyBufferInfo;
63+
pub type TexelCopyTextureInfo = ffi::TexelCopyTextureInfo;
64+
pub type CopyExternalImageDestInfo = ffi::CopyExternalImageDestInfo;
65+
6166
const PUSH_CONSTANT_CLEAR_ARRAY: &[u32] = &[0_u32; 64];
6267

6368
/// The current state of a command or pass encoder.

wgpu-core/src/command/transfer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
command::{clear_texture, CommandEncoderError, EncoderStateError},
1616
device::{Device, MissingDownlevelFlags},
1717
global::Global,
18-
id::{BufferId, CommandEncoderId, TextureId},
18+
id::{BufferId, CommandEncoderId},
1919
init_tracker::{
2020
has_copy_partial_init_tracker_coverage, MemoryInitKind, TextureInitRange,
2121
TextureInitTrackerAction,
@@ -29,9 +29,8 @@ use crate::{
2929

3030
use super::{ClearError, CommandBufferMutable};
3131

32-
pub type TexelCopyBufferInfo = wgt::TexelCopyBufferInfo<BufferId>;
33-
pub type TexelCopyTextureInfo = wgt::TexelCopyTextureInfo<TextureId>;
34-
pub type CopyExternalImageDestInfo = wgt::CopyExternalImageDestInfo<TextureId>;
32+
use super::TexelCopyBufferInfo;
33+
use super::TexelCopyTextureInfo;
3534

3635
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
3736
pub enum CopySide {

wgpu-core/src/device/queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
extract_texture_selector, validate_linear_texture_data, validate_texture_buffer_copy,
2323
validate_texture_copy_dst_format, validate_texture_copy_range, ClearError,
2424
CommandAllocator, CommandBuffer, CommandEncoder, CommandEncoderError, CopySide,
25-
TexelCopyTextureInfo, TransferError,
25+
TransferError,
2626
},
2727
device::{DeviceError, WaitIdleError},
2828
get_lowest_common_denom,
@@ -1617,7 +1617,7 @@ impl Global {
16171617
pub fn queue_write_texture(
16181618
&self,
16191619
queue_id: QueueId,
1620-
destination: &TexelCopyTextureInfo,
1620+
destination: &wgt::TexelCopyTextureInfo<id::TextureId>,
16211621
data: &[u8],
16221622
data_layout: &wgt::TexelCopyBufferLayout,
16231623
size: &wgt::Extent3d,

wgpu-core/src/device/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub enum Action<'a> {
140140
queued: bool,
141141
},
142142
WriteTexture {
143-
to: crate::command::TexelCopyTextureInfo,
143+
to: wgt::TexelCopyTextureInfo<id::TextureId>,
144144
data: FileName,
145145
layout: wgt::TexelCopyBufferLayout,
146146
size: wgt::Extent3d,

wgpu/src/backend/wgpu_core.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ impl ContextWgpuCore {
386386
}
387387
}
388388

389-
fn map_buffer_copy_view(view: crate::TexelCopyBufferInfo<'_>) -> wgc::command::TexelCopyBufferInfo {
390-
wgc::command::TexelCopyBufferInfo {
389+
fn map_buffer_copy_view(
390+
view: crate::TexelCopyBufferInfo<'_>,
391+
) -> wgt::TexelCopyBufferInfo<wgc::id::BufferId> {
392+
wgt::TexelCopyBufferInfo {
391393
buffer: view.buffer.inner.as_core().id,
392394
layout: view.layout,
393395
}
@@ -407,8 +409,8 @@ fn map_texture_copy_view(
407409
#[cfg_attr(not(webgl), expect(unused))]
408410
fn map_texture_tagged_copy_view(
409411
view: crate::CopyExternalImageDestInfo<&api::Texture>,
410-
) -> wgc::command::CopyExternalImageDestInfo {
411-
wgc::command::CopyExternalImageDestInfo {
412+
) -> wgt::CopyExternalImageDestInfo<wgc::id::TextureId> {
413+
wgt::CopyExternalImageDestInfo {
412414
texture: view.texture.inner.as_core().id,
413415
mip_level: view.mip_level,
414416
origin: view.origin,

0 commit comments

Comments
 (0)