From f3bb6eb23088017e8f751ce85fc2230ea5b47a23 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Fri, 27 Mar 2020 23:25:04 -0230 Subject: [PATCH] Move more types to wgpu-types --- wgpu-core/src/binding_model.rs | 11 +---------- wgpu-core/src/command/compute.rs | 4 ++-- wgpu-core/src/command/render.rs | 2 +- wgpu-core/src/device/mod.rs | 6 +----- wgpu-core/src/instance.rs | 4 ++-- wgpu-types/src/lib.rs | 12 ++++++++++++ 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 42d061ef7..a919b1bf9 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -11,7 +11,7 @@ use crate::{ Stored, }; -use wgt::BufferAddress; +use wgt::{BufferAddress, TextureComponentType}; use arrayvec::ArrayVec; use gfx_descriptor::{DescriptorCounts, DescriptorSet}; @@ -33,15 +33,6 @@ pub enum BindingType { WriteonlyStorageTexture = 7, } -#[repr(C)] -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] -pub enum TextureComponentType { - Float, - Sint, - Uint, -} - #[repr(C)] #[derive(Clone, Debug, Hash, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 5de9c410c..26b370e64 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -8,12 +8,12 @@ use crate::{ CommandBuffer, PhantomSlice, }, - device::{all_buffer_stages, BIND_BUFFER_ALIGNMENT}, + device::all_buffer_stages, hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token}, id, }; -use wgt::{BufferAddress, BufferUsage, DynamicOffset}; +use wgt::{BufferAddress, BufferUsage, DynamicOffset, BIND_BUFFER_ALIGNMENT}; use hal::command::CommandBuffer as _; use peek_poke::{Peek, PeekCopy, Poke}; diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index bb0e94548..e6dde232e 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -14,7 +14,6 @@ use crate::{ FramebufferKey, RenderPassContext, RenderPassKey, - BIND_BUFFER_ALIGNMENT, MAX_VERTEX_BUFFERS, MAX_COLOR_TARGETS, }, @@ -37,6 +36,7 @@ use wgt::{ RenderPassColorAttachmentDescriptorBase, RenderPassDepthStencilAttachmentDescriptorBase, TextureUsage, + BIND_BUFFER_ALIGNMENT }; use arrayvec::ArrayVec; use hal::command::CommandBuffer as _; diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index ac9e92cf1..22a60a22f 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -18,8 +18,7 @@ use crate::{ Stored, }; -use wgt::{BufferAddress, InputStepMode, TextureDimension, TextureFormat}; - +use wgt::{BufferAddress, InputStepMode, TextureDimension, TextureFormat, BIND_BUFFER_ALIGNMENT}; use arrayvec::ArrayVec; use copyless::VecHelper as _; use gfx_descriptor::DescriptorAllocator; @@ -50,9 +49,6 @@ pub const MAX_COLOR_TARGETS: usize = 4; pub const MAX_MIP_LEVELS: usize = 16; pub const MAX_VERTEX_BUFFERS: usize = 8; -/// Bound uniform/storage buffer offsets must be aligned to this number. -pub const BIND_BUFFER_ALIGNMENT: hal::buffer::Offset = 256; - pub fn all_buffer_stages() -> hal::pso::PipelineStage { use hal::pso::PipelineStage as Ps; Ps::DRAW_INDIRECT diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 5c6f68cc1..5d531ffca 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -4,13 +4,13 @@ use crate::{ backend, - device::{Device, BIND_BUFFER_ALIGNMENT}, + device::Device, hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Input, Token}, id::{AdapterId, DeviceId}, power, }; -use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, RequestAdapterOptions}; +use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, RequestAdapterOptions, BIND_BUFFER_ALIGNMENT}; #[cfg(feature = "serde")] use serde_crate::{Deserialize, Serialize}; diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 6ac090958..b894388d2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -825,3 +825,15 @@ pub struct SamplerDescriptor<'a> { pub struct CommandBufferDescriptor { pub todo: u32, } + +#[repr(C)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum TextureComponentType { + Float, + Sint, + Uint, +} + +/// Bound uniform/storage buffer offsets must be aligned to this number. +pub const BIND_BUFFER_ALIGNMENT: u64 = 256;