From 9058f3ba62a89d2e673f4a7ec5bc42a561489d25 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Tue, 23 Mar 2021 00:48:42 -0230 Subject: [PATCH] Rename copy views and layout to match spec --- wgpu-core/src/command/transfer.rs | 22 +++++++++++----------- wgpu-core/src/device/queue.rs | 6 +++--- wgpu-core/src/device/trace.rs | 16 ++++++++-------- wgpu-types/src/lib.rs | 10 +++++----- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs index 87eefd8082..c54360c702 100644 --- a/wgpu-core/src/command/transfer.rs +++ b/wgpu-core/src/command/transfer.rs @@ -23,8 +23,8 @@ use std::iter; pub(crate) const BITS_PER_BYTE: u32 = 8; -pub type BufferCopyView = wgt::BufferCopyView; -pub type TextureCopyView = wgt::TextureCopyView; +pub type ImageCopyBuffer = wgt::ImageCopyBuffer; +pub type ImageCopyTexture = wgt::ImageCopyTexture; #[derive(Clone, Debug)] pub enum CopySide { @@ -106,7 +106,7 @@ pub enum CopyError { //TODO: we currently access each texture twice for a transfer, // once only to get the aspect flags, which is unfortunate. pub(crate) fn texture_copy_view_to_hal( - view: &TextureCopyView, + view: &ImageCopyTexture, size: &Extent3d, texture_guard: &Storage, TextureId>, ) -> Result< @@ -155,7 +155,7 @@ pub(crate) fn texture_copy_view_to_hal( /// Function copied with some modifications from webgpu standard /// If successful, returns number of buffer bytes required for this copy. pub(crate) fn validate_linear_texture_data( - layout: &wgt::TextureDataLayout, + layout: &wgt::ImageDataLayout, format: wgt::TextureFormat, buffer_size: BufferAddress, buffer_side: CopySide, @@ -248,7 +248,7 @@ pub(crate) fn validate_linear_texture_data( /// Function copied with minor modifications from webgpu standard pub(crate) fn validate_texture_copy_range( - texture_copy_view: &TextureCopyView, + texture_copy_view: &ImageCopyTexture, texture_format: wgt::TextureFormat, texture_dimension: hal::image::Kind, texture_side: CopySide, @@ -468,8 +468,8 @@ impl Global { pub fn command_encoder_copy_buffer_to_texture( &self, command_encoder_id: CommandEncoderId, - source: &BufferCopyView, - destination: &TextureCopyView, + source: &ImageCopyBuffer, + destination: &ImageCopyTexture, copy_size: &Extent3d, ) -> Result<(), CopyError> { profiling::scope!("CommandEncoder::copy_buffer_to_texture"); @@ -618,8 +618,8 @@ impl Global { pub fn command_encoder_copy_texture_to_buffer( &self, command_encoder_id: CommandEncoderId, - source: &TextureCopyView, - destination: &BufferCopyView, + source: &ImageCopyTexture, + destination: &ImageCopyBuffer, copy_size: &Extent3d, ) -> Result<(), CopyError> { profiling::scope!("CommandEncoder::copy_texture_to_buffer"); @@ -771,8 +771,8 @@ impl Global { pub fn command_encoder_copy_texture_to_texture( &self, command_encoder_id: CommandEncoderId, - source: &TextureCopyView, - destination: &TextureCopyView, + source: &ImageCopyTexture, + destination: &ImageCopyTexture, copy_size: &Extent3d, ) -> Result<(), CopyError> { profiling::scope!("CommandEncoder::copy_texture_to_texture"); diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index e26c9a4eba..be019a5177 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -7,7 +7,7 @@ use crate::device::trace::Action; use crate::{ command::{ texture_copy_view_to_hal, validate_linear_texture_data, validate_texture_copy_range, - CommandAllocator, CommandBuffer, CopySide, TextureCopyView, TransferError, BITS_PER_BYTE, + CommandAllocator, CommandBuffer, CopySide, ImageCopyTexture, TransferError, BITS_PER_BYTE, }, conv, device::{alloc, DeviceError, WaitIdleError}, @@ -294,9 +294,9 @@ impl Global { pub fn queue_write_texture( &self, queue_id: id::QueueId, - destination: &TextureCopyView, + destination: &ImageCopyTexture, data: &[u8], - data_layout: &wgt::TextureDataLayout, + data_layout: &wgt::ImageDataLayout, size: &wgt::Extent3d, ) -> Result<(), QueueWriteError> { profiling::scope!("Queue::write_texture"); diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index 0269a8280e..af38f8f41e 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -108,9 +108,9 @@ pub enum Action<'a> { queued: bool, }, WriteTexture { - to: crate::command::TextureCopyView, + to: crate::command::ImageCopyTexture, data: FileName, - layout: wgt::TextureDataLayout, + layout: wgt::ImageDataLayout, size: wgt::Extent3d, }, Submit(crate::SubmissionIndex, Vec), @@ -128,18 +128,18 @@ pub enum Command { size: wgt::BufferAddress, }, CopyBufferToTexture { - src: crate::command::BufferCopyView, - dst: crate::command::TextureCopyView, + src: crate::command::ImageCopyBuffer, + dst: crate::command::ImageCopyTexture, size: wgt::Extent3d, }, CopyTextureToBuffer { - src: crate::command::TextureCopyView, - dst: crate::command::BufferCopyView, + src: crate::command::ImageCopyTexture, + dst: crate::command::ImageCopyBuffer, size: wgt::Extent3d, }, CopyTextureToTexture { - src: crate::command::TextureCopyView, - dst: crate::command::TextureCopyView, + src: crate::command::ImageCopyTexture, + dst: crate::command::ImageCopyTexture, size: wgt::Extent3d, }, WriteTimestamp { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index fd231571a4..cbe390d53c 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -34,7 +34,7 @@ pub type DynamicOffset = u32; /// /// This doesn't apply to [`Queue::write_texture`]. /// -/// [`bytes_per_row`]: TextureDataLayout::bytes_per_row +/// [`bytes_per_row`]: ImageDataLayout::bytes_per_row pub const COPY_BYTES_PER_ROW_ALIGNMENT: u32 = 256; /// Bound uniform/storage buffer offsets must be aligned to this number. pub const BIND_BUFFER_ALIGNMENT: BufferAddress = 256; @@ -2502,7 +2502,7 @@ impl Default for RenderBundleDescriptor> { #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "trace", derive(serde::Serialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))] -pub struct TextureDataLayout { +pub struct ImageDataLayout { /// Offset into the buffer that is the start of the texture. Must be a multiple of texture block size. /// For non-compressed textures, this is 1. pub offset: BufferAddress, @@ -2765,11 +2765,11 @@ pub struct BindGroupLayoutEntry { #[derive(Clone, Debug)] #[cfg_attr(feature = "trace", derive(serde::Serialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))] -pub struct BufferCopyView { +pub struct ImageCopyBuffer { /// The buffer to be copied to/from. pub buffer: B, /// The layout of the texture data in this buffer. - pub layout: TextureDataLayout, + pub layout: ImageDataLayout, } /// View of a texture which can be used to copy to/from a buffer/texture. @@ -2777,7 +2777,7 @@ pub struct BufferCopyView { #[derive(Clone, Debug)] #[cfg_attr(feature = "trace", derive(serde::Serialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))] -pub struct TextureCopyView { +pub struct ImageCopyTexture { /// The texture to be copied to/from. pub texture: T, /// The target mip level of the texture.