Skip to content
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,37 @@ jobs:
name: iOS Stable
channel: stable
build_command: rustup target add aarch64-apple-ios; cargo clippy --target aarch64-apple-ios
additional_core_features:
- os: macos-10.15
name: MacOS Stable
channel: stable
build_command: cargo clippy
additional_core_features: trace
- os: macos-10.15
name: MacOS Nightly
channel: nightly
build_command: cargo test
additional_core_features:
- os: ubuntu-18.04
name: Ubuntu Stable
channel: stable
build_command: cargo clippy
additional_core_features: trace,replay
- os: ubuntu-18.04
name: Ubuntu Nightly
channel: nightly
build_command: cargo test
additional_core_features:
- os: windows-2019
name: Windows Stable
channel: stable
build_command: rustup default stable-msvc; cargo clippy
additional_core_features: replay
- os: windows-2019
name: Windows Nightly
channel: nightly
build_command: rustup default nightly-msvc; cargo test
additional_core_features:
steps:
- uses: actions/checkout@v2
- if: matrix.channel == 'nightly'
Expand All @@ -63,3 +70,5 @@ jobs:
run: rustup component add clippy
- name: cargo clippy/test
run: ${{ matrix.build_command }}
- if: matrix.additional_core_features != ''
run: cargo check --manifest-path wgpu-core/Cargo.toml --features ${{ matrix.additional_core_features }}
11 changes: 4 additions & 7 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ license = "MPL-2.0"

[features]
default = []
trace = ["ron", "serde", "wgt/trace"]
replay = ["serde", "wgt/replay"]
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
serde = ["wgt/serde", "serde_crate"]
#NOTE: glutin feature is not stable, use at your own risk
#glutin = ["gfx-backend-gl/glutin"]

Expand All @@ -33,15 +34,11 @@ gfx-descriptor = "0.1"
gfx-memory = "0.1"
parking_lot = "0.10"
peek-poke = "0.2"
ron = { version = "0.5", optional = true }
serde = { version = "1.0", features = ["serde_derive"], optional = true }
smallvec = "1"
vec_map = "0.8"

[dependencies.serde_crate]
package = "serde"
version = "1.0"
features = ["serde_derive"]
optional = true

[dependencies.wgt]
path = "../wgpu-types"
package = "wgpu-types"
Expand Down
41 changes: 14 additions & 27 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ use arrayvec::ArrayVec;
use gfx_descriptor::{DescriptorCounts, DescriptorSet};
use wgt::{BufferAddress, TextureComponentType};

#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
#[cfg(feature = "replay")]
use serde::Deserialize;
#[cfg(feature = "trace")]
use serde::Serialize;
use std::borrow::Borrow;

#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum BindingType {
UniformBuffer = 0,
StorageBuffer = 1,
Expand All @@ -36,11 +35,8 @@ pub enum BindingType {

#[repr(C)]
#[derive(Clone, Debug, Hash, PartialEq)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct BindGroupLayoutEntry {
pub binding: u32,
pub visibility: wgt::ShaderStage,
Expand Down Expand Up @@ -86,11 +82,8 @@ pub struct PipelineLayout<B: hal::Backend> {

#[repr(C)]
#[derive(Debug)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct BufferBinding {
pub buffer: BufferId,
pub offset: BufferAddress,
Expand All @@ -99,11 +92,8 @@ pub struct BufferBinding {

#[repr(C)]
#[derive(Debug)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum BindingResource {
Buffer(BufferBinding),
Sampler(SamplerId),
Expand All @@ -112,11 +102,8 @@ pub enum BindingResource {

#[repr(C)]
#[derive(Debug)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct BindGroupEntry {
pub binding: u32,
pub resource: BindingResource,
Expand Down
9 changes: 6 additions & 3 deletions wgpu-core/src/command/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use super::CommandBuffer;
use crate::{
hub::GfxBackend, id::DeviceId, track::TrackerSet, Features, LifeGuard, Stored, SubmissionIndex,
hub::GfxBackend, id::DeviceId, track::TrackerSet, LifeGuard, PrivateFeatures, Stored,
SubmissionIndex,
};

use hal::{command::CommandBuffer as _, device::Device as _, pool::CommandPool as _};
Expand Down Expand Up @@ -76,7 +77,8 @@ impl<B: GfxBackend> CommandAllocator<B> {
&self,
device_id: Stored<DeviceId>,
device: &B::Device,
features: Features,
limits: wgt::Limits,
private_features: PrivateFeatures,
lowest_active_index: SubmissionIndex,
) -> CommandBuffer<B> {
//debug_assert_eq!(device_id.backend(), B::VARIANT);
Expand Down Expand Up @@ -108,7 +110,8 @@ impl<B: GfxBackend> CommandAllocator<B> {
life_guard: LifeGuard::new(),
trackers: TrackerSet::new(B::VARIANT),
used_swap_chain: None,
features,
limits,
private_features,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
let cmb = &mut cmb_guard[encoder_id];
let raw = cmb.raw.last_mut().unwrap();
let mut binder = Binder::new(cmb.features.max_bind_groups);
let mut binder = Binder::new(cmb.limits.max_bind_groups);

let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
Expand Down
5 changes: 3 additions & 2 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
id,
resource::{Buffer, Texture},
track::TrackerSet,
Features, LifeGuard, Stored,
LifeGuard, PrivateFeatures, Stored,
};

use peek_poke::PeekPoke;
Expand Down Expand Up @@ -138,7 +138,8 @@ pub struct CommandBuffer<B: hal::Backend> {
pub(crate) life_guard: LifeGuard,
pub(crate) trackers: TrackerSet,
pub(crate) used_swap_chain: Option<(Stored<id::SwapChainId>, B::Framebuffer)>,
pub(crate) features: Features,
limits: wgt::Limits,
private_features: PrivateFeatures,
}

impl<B: GfxBackend> CommandBuffer<B> {
Expand Down
17 changes: 13 additions & 4 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};

Some(hal::pass::Attachment {
format: Some(conv::map_texture_format(view.format, device.features)),
format: Some(conv::map_texture_format(
view.format,
device.private_features,
)),
samples: view.samples,
ops: conv::map_load_store_ops(at.depth_load_op, at.depth_store_op),
stencil_ops: conv::map_load_store_ops(
Expand Down Expand Up @@ -495,7 +498,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};

colors.push(hal::pass::Attachment {
format: Some(conv::map_texture_format(view.format, device.features)),
format: Some(conv::map_texture_format(
view.format,
device.private_features,
)),
samples: view.samples,
ops: conv::map_load_store_ops(at.load_op, at.store_op),
stencil_ops: hal::pass::AttachmentOps::DONT_CARE,
Expand Down Expand Up @@ -541,7 +547,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};

resolves.push(hal::pass::Attachment {
format: Some(conv::map_texture_format(view.format, device.features)),
format: Some(conv::map_texture_format(
view.format,
device.private_features,
)),
samples: view.samples,
ops: hal::pass::AttachmentOps::new(
hal::pass::AttachmentLoadOp::DontCare,
Expand Down Expand Up @@ -788,7 +797,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
};

let mut state = State {
binder: Binder::new(cmb.features.max_bind_groups),
binder: Binder::new(cmb.limits.max_bind_groups),
blend_color: OptionalState::Unused,
stencil_reference: OptionalState::Unused,
pipeline: OptionalState::Required,
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
assert!(dst_texture.usage.contains(TextureUsage::COPY_DST));
let dst_barriers = dst_pending.map(|pending| pending.into_hal(dst_texture));

let bytes_per_texel = conv::map_texture_format(dst_texture.format, cmb.features)
let bytes_per_texel = conv::map_texture_format(dst_texture.format, cmb.private_features)
.surface_desc()
.bits as u32
/ BITS_PER_BYTE;
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
assert!(dst_buffer.usage.contains(BufferUsage::COPY_DST));
let dst_barrier = dst_barriers.map(|pending| pending.into_hal(dst_buffer));

let bytes_per_texel = conv::map_texture_format(src_texture.format, cmb.features)
let bytes_per_texel = conv::map_texture_format(src_texture.format, cmb.private_features)
.surface_desc()
.bits as u32
/ BITS_PER_BYTE;
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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::{binding_model, resource, Features};
use crate::{binding_model, resource, PrivateFeatures};

pub fn map_buffer_usage(usage: wgt::BufferUsage) -> (hal::buffer::Usage, hal::memory::Properties) {
use hal::buffer::Usage as U;
Expand Down Expand Up @@ -321,7 +321,7 @@ fn map_stencil_operation(stencil_operation: wgt::StencilOperation) -> hal::pso::

pub(crate) fn map_texture_format(
texture_format: wgt::TextureFormat,
features: Features,
private_features: PrivateFeatures,
) -> hal::format::Format {
use hal::format::Format as H;
use wgt::TextureFormat as Tf;
Expand Down Expand Up @@ -376,14 +376,14 @@ pub(crate) fn map_texture_format(
// Depth and stencil formats
Tf::Depth32Float => H::D32Sfloat,
Tf::Depth24Plus => {
if features.supports_texture_d24_s8 {
if private_features.supports_texture_d24_s8 {
H::D24UnormS8Uint
} else {
H::D32Sfloat
}
}
Tf::Depth24PlusStencil8 => {
if features.supports_texture_d24_s8 {
if private_features.supports_texture_d24_s8 {
H::D24UnormS8Uint
} else {
H::D32SfloatS8Uint
Expand Down
Loading