Move TextureDataLayout to wgpu-types

This commit is contained in:
Dzmitry Malyshau
2020-05-23 21:57:08 -04:00
committed by Dzmitry Malyshau
parent fcf1d2762d
commit dff37bb65d
5 changed files with 21 additions and 24 deletions

View File

@@ -13,22 +13,12 @@ use crate::{
};
use hal::command::CommandBuffer as _;
use wgt::{BufferAddress, BufferUsage, Extent3d, Origin3d, TextureUsage};
use wgt::{BufferAddress, BufferUsage, Extent3d, Origin3d, TextureDataLayout, TextureUsage};
use std::iter;
pub(crate) const BITS_PER_BYTE: u32 = 8;
#[repr(C)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct TextureDataLayout {
pub offset: BufferAddress,
pub bytes_per_row: u32,
pub rows_per_image: u32,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]

View File

@@ -238,7 +238,7 @@ impl<B: GfxBackend> Device<B> {
};
#[cfg(not(feature = "trace"))]
match trace_path {
Some(_) => log::warn!("Tracing feature is not enabled"),
Some(_) => log::error!("Feature 'trace' is not enabled"),
None => (),
}
@@ -265,7 +265,7 @@ impl<B: GfxBackend> Device<B> {
Some(Mutex::new(trace))
}
Err(e) => {
log::warn!("Unable to start a trace in '{:?}': {:?}", path, e);
log::error!("Unable to start a trace in '{:?}': {:?}", path, e);
None
}
}),

View File

@@ -5,7 +5,7 @@
#[cfg(feature = "trace")]
use crate::device::trace::Action;
use crate::{
command::{CommandAllocator, CommandBuffer, TextureCopyView, TextureDataLayout, BITS_PER_BYTE},
command::{CommandAllocator, CommandBuffer, TextureCopyView, BITS_PER_BYTE},
conv,
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token},
id,
@@ -192,7 +192,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
queue_id: id::QueueId,
destination: &TextureCopyView,
data: &[u8],
data_layout: &TextureDataLayout,
data_layout: &wgt::TextureDataLayout,
size: wgt::Extent3d,
) {
let hub = B::hub(self);

View File

@@ -2,10 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use crate::{
command::{TextureCopyView, TextureDataLayout},
id,
};
use crate::{command::TextureCopyView, id};
#[cfg(feature = "trace")]
use std::io::Write as _;
use std::ops::Range;
@@ -171,7 +168,7 @@ pub enum Action {
WriteTexture {
to: TextureCopyView,
data: FileName,
layout: TextureDataLayout,
layout: wgt::TextureDataLayout,
size: wgt::Extent3d,
},
Submit(crate::SubmissionIndex, Vec<Command>),
@@ -190,14 +187,14 @@ pub enum Command {
},
CopyBufferToTexture {
src: id::BufferId,
src_layout: TextureDataLayout,
src_layout: wgt::TextureDataLayout,
dst: TextureCopyView,
size: wgt::Extent3d,
},
CopyTextureToBuffer {
src: TextureCopyView,
dst: id::BufferId,
dst_layout: TextureDataLayout,
dst_layout: wgt::TextureDataLayout,
size: wgt::Extent3d,
},
CopyTextureToTexture {

View File

@@ -10,6 +10,9 @@ use serde::Deserialize;
use serde::Serialize;
use std::{io, ptr, slice};
/// Bound uniform/storage buffer offsets must be aligned to this number.
pub const BIND_BUFFER_ALIGNMENT: u64 = 256;
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "trace", derive(Serialize))]
@@ -981,5 +984,12 @@ impl From<TextureFormat> for TextureComponentType {
}
}
/// Bound uniform/storage buffer offsets must be aligned to this number.
pub const BIND_BUFFER_ALIGNMENT: u64 = 256;
#[repr(C)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct TextureDataLayout {
pub offset: BufferAddress,
pub bytes_per_row: u32,
pub rows_per_image: u32,
}