Improve CI testing code

This commit is contained in:
Connor Fitzgerald 2021-09-13 21:27:50 -04:00
parent 300f7d2e8c
commit 7766ed194b
No known key found for this signature in database
GPG Key ID: 7D3FA445BAD3008D
15 changed files with 153 additions and 82 deletions

View File

@ -6,6 +6,9 @@ on:
tags: [v0.*]
pull_request:
env:
RUST_BACKTRACE: 1
jobs:
build:
strategy:
@ -18,6 +21,13 @@ jobs:
channel: stable
target: x86_64-pc-windows-msvc
kind: test
backends: dx12 # dx11
- name: Windows Nightly x86_64
os: windows-2019
channel: nightly
target: x86_64-pc-windows-msvc
kind: compile
# MacOS
@ -42,7 +52,8 @@ jobs:
os: ubuntu-20.04
channel: stable
target: x86_64-unknown-linux-gnu
kind: test
kind: compile
backends: # vulkan gl
- name: Linux Nightly x86_64
os: ubuntu-20.04
@ -71,7 +82,7 @@ jobs:
env:
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
RUSTDOCFLAGS: -Dwarnings
steps:
@ -87,6 +98,11 @@ jobs:
profile: minimal
components: clippy
- name: caching
uses: Swatinem/rust-cache@v1
with:
key: ${{ matrix.target }}-a # suffix for cache busting
- name: add android apk to path
if: matrix.os == 'ubuntu-20.04' && matrix.target == 'aarch64-linux-android'
run: |
@ -95,73 +111,69 @@ jobs:
- name: install llvmpipe and lavapipe
if: matrix.os == 'ubuntu-20.04' && matrix.kind == 'test'
run: |
echo "Installing Vulkan"
sudo apt-get update -y -qq
sudo add-apt-repository ppa:ubuntu-x-swat/updates -y
sudo apt-get update
sudo apt install -y libxcb-xfixes0-dev mesa-vulkan-drivers
# add libegl1-mesa libgl1-mesa-dri for egl
# We enable line numbers for panics, but that's it
- name: disable debug
shell: bash
run: |
mkdir .cargo
echo """[profile.dev]
debug = 1" > .cargo/config.toml
# This is separate for now because webgl isn't hooked up so we can't compile wgpu-core for wasm
- name: check web
if: matrix.kind == 'webgl'
run: |
cargo clippy --target ${{ matrix.target }} -p wgpu -- -D warnings
cargo clippy --target ${{ matrix.target }} -p wgpu
# build docs
cargo doc --target ${{ matrix.target }} -p wgpu --no-deps
- name: check native stable (fatal warnings)
if: (matrix.kind == 'compile' || matrix.kind == 'test') && matrix.channel == 'stable'
run: |
# check with no features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player -- -D warnings
# check with all features
# explicitly don't mention wgpu-hal so that --all-features don't apply to it
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features -- -D warnings
# build docs
cargo doc --target ${{ matrix.target }} --no-deps
cargo doc --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --all-features --no-deps
- name: check native nightly (non-fatal warnings)
if: (matrix.kind == 'compile' || matrix.kind == 'test') && matrix.channel != 'stable'
- name: check native
if: matrix.kind == 'compile' || matrix.kind == 'test'
run: |
# check with no features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player
# check with all features
# explicitly don't mention wgpu-hal so that --all-features don't apply to it
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features
- name: build tests
if: matrix.kind == 'test'
run: |
cargo build --target ${{ matrix.target }} --bin wgpu-info
cargo build --target ${{ matrix.target }} --tests -p wgpu-types -p wgpu-hal -p wgpu-core
cargo build --target ${{ matrix.target }} --examples --tests -p wgpu
# build docs
cargo doc --target ${{ matrix.target }} --no-deps
cargo doc --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --all-features --no-deps
- name: tests
if: matrix.kind == 'test' && matrix.os == 'windows-2019'
if: matrix.kind == 'test'
shell: bash
run: |
# run wgpu-info
cargo run --target ${{ matrix.target }} --bin wgpu-info
# run player tests
cargo test --target ${{ matrix.target }} -p wgpu-types -p wgpu-hal -p wgpu-core --no-fail-fast -- --nocapture
# run coretests
cargo run --target ${{ matrix.target }} --bin wgpu-info -- cargo test --target ${{ matrix.target }} -p wgpu --no-fail-fast -- --nocapture
for backend in ${{ matrix.backends }}; do
echo "======= NATIVE TESTS $backend ======";
# run player tests
WGPU_BACKEND=$backend cargo test --target ${{ matrix.target }} -p wgpu-types -p wgpu-hal -p wgpu-core --no-fail-fast -- --nocapture --test-threads=1
# run coretests
WGPU_BACKEND=$backend cargo test --target ${{ matrix.target }} -p wgpu --no-fail-fast -- --nocapture --test-threads=1
done
test:
cts:
strategy:
fail-fast: false
matrix:
include:
# Windows
- name: Windows x86_64
os: windows-latest
os: windows-2019
target: x86_64-pc-windows-msvc
backends: dx12 # dx11
name: Test ${{ matrix.name }}
name: CTS ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
@ -169,6 +181,7 @@ jobs:
uses: actions/checkout@v2
with:
path: wgpu
- name: checkout cts
uses: actions/checkout@v2
with:
@ -183,16 +196,36 @@ jobs:
target: ${{ matrix.target }}
profile: minimal
- name: caching
uses: Swatinem/rust-cache@v1
with:
key: cts-a # suffix for cache busting
working-directory: wgpu/cts_runner
target-dir: wgpu/cts_runner/target
# We enable line numbers for panics, but that's it
- name: disable debug
shell: bash
run: |
mkdir wgpu/.cargo
echo """[profile.dev]
debug = 1" > wgpu/.cargo/config.toml
- name: build CTS runner
run: cd wgpu/cts_runner && cargo build
run: |
cargo build --manifest-path wgpu/cts_runner/Cargo.toml
- name: run CTS
if: ${{ matrix.os }} == 'windows-2019'
shell: bash
run: >-
run: |
cd cts;
grep -v '^//' ../wgpu/cts_runner/test.lst | while IFS=$' \t\r\n' read test; do
echo "=== Running $test ===";
cargo run --manifest-path ../wgpu/cts_runner/Cargo.toml --frozen -- ./tools/run_deno --verbose "$test";
for backend in ${{ matrix.backends }}; do
echo "======= CTS TESTS $backend ======";
grep -v '^//' ../wgpu/cts_runner/test.lst | while IFS=$' \t\r\n' read test; do
echo "=== Running $test ===";
DENO_WEBGPU_BACKEND=$backend cargo run --manifest-path ../wgpu/cts_runner/Cargo.toml --frozen -- ./tools/run_deno --verbose "$test";
done
done
fmt:

View File

@ -242,13 +242,14 @@ pub async fn op_webgpu_request_adapter(
) -> Result<GpuAdapterDeviceOrErr, AnyError> {
let mut state = state.borrow_mut();
check_unstable(&state, "navigator.gpu.requestAdapter");
let backends = std::env::var("DENO_WEBGPU_BACKEND").ok().map_or_else(wgpu_types::Backends::all, |s| wgpu_core::instance::parse_backends_from_comma_list(&s));
let instance = if let Some(instance) = state.try_borrow::<Instance>() {
instance
} else {
state.put(wgpu_core::hub::Global::new(
"webgpu",
wgpu_core::hub::IdentityManagerFactory,
wgpu_types::Backends::PRIMARY,
backends,
));
state.borrow::<Instance>()
};
@ -263,7 +264,7 @@ pub async fn op_webgpu_request_adapter(
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(wgpu_types::Backends::PRIMARY, |_| {
wgpu_core::instance::AdapterInputs::Mask(backends, |_| {
std::marker::PhantomData
}),
);

View File

@ -419,6 +419,7 @@ pub struct BindGroupLayout<A: hal::Api> {
pub(crate) device_id: Stored<DeviceId>,
pub(crate) multi_ref_count: MultiRefCount,
pub(crate) entries: BindEntryMap,
#[allow(unused)]
pub(crate) dynamic_count: usize,
pub(crate) count_validator: BindingTypeMaxCountValidator,
#[cfg(debug_assertions)]

View File

@ -4637,7 +4637,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
resource::BufferMapState::Waiting(resource::BufferPendingMapping {
range,
op,
parent_ref_count: buffer.life_guard.add_ref(),
_parent_ref_count: buffer.life_guard.add_ref(),
})
}
};

View File

@ -17,21 +17,12 @@ use std::cell::Cell;
use std::{fmt::Debug, marker::PhantomData, mem, ops};
/// A simple structure to manage identities of objects.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct IdentityManager {
free: Vec<Index>,
epochs: Vec<Epoch>,
}
impl Default for IdentityManager {
fn default() -> Self {
Self {
free: Default::default(),
epochs: Default::default(),
}
}
}
impl IdentityManager {
pub fn from_index(min_index: u32) -> Self {
Self {

View File

@ -876,3 +876,40 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
(id, Some(error))
}
}
/// Generates a set of backends from a comma separated list of case-insensitive backend names.
///
/// Whitespace is stripped, so both 'gl, dx12' and 'gl,dx12' are valid.
///
/// Always returns WEBGPU on wasm over webgpu.
///
/// Names:
/// - vulkan = "vulkan" or "vk"
/// - dx12 = "dx12" or "d3d12"
/// - dx11 = "dx11" or "d3d11"
/// - metal = "metal" or "mtl"
/// - gles = "opengl" or "gles" or "gl"
/// - webgpu = "webgpu"
pub fn parse_backends_from_comma_list(string: &str) -> Backends {
let mut backends = Backends::empty();
for backend in string.to_lowercase().split(',') {
backends |= match backend.trim() {
"vulkan" | "vk" => Backends::VULKAN,
"dx12" | "d3d12" => Backends::DX12,
"dx11" | "d3d11" => Backends::DX11,
"metal" | "mtl" => Backends::METAL,
"opengl" | "gles" | "gl" => Backends::GL,
"webgpu" => Backends::BROWSER_WEBGPU,
b => {
log::warn!("unknown backend string '{}'", b);
continue;
}
}
}
if backends.is_empty() {
log::warn!("no valid backend strings found!");
}
backends
}

View File

@ -32,6 +32,7 @@ pub const DESIRED_NUM_FRAMES: u32 = 3;
pub(crate) struct Presentation {
pub(crate) device_id: Stored<DeviceId>,
pub(crate) config: wgt::SurfaceConfiguration,
#[allow(unused)]
pub(crate) num_frames: u32,
pub(crate) acquired_texture: Option<Stored<TextureId>>,
}

View File

@ -109,7 +109,7 @@ pub(crate) struct BufferPendingMapping {
pub range: Range<wgt::BufferAddress>,
pub op: BufferMapOperation,
// hold the parent alive while the mapping is active
pub parent_ref_count: RefCount,
pub _parent_ref_count: RefCount,
}
pub type BufferDescriptor<'a> = wgt::BufferDescriptor<Label<'a>>;

View File

@ -21,6 +21,7 @@ enum ResourceType {
#[derive(Debug)]
struct Resource {
#[allow(unused)]
name: Option<String>,
bind: naga::ResourceBinding,
ty: ResourceType,
@ -90,6 +91,7 @@ enum Varying {
BuiltIn(naga::BuiltIn),
}
#[allow(unused)]
#[derive(Debug)]
struct SpecializationConstant {
id: u32,
@ -101,6 +103,7 @@ struct EntryPoint {
inputs: Vec<Varying>,
outputs: Vec<Varying>,
resources: Vec<(naga::Handle<Resource>, GlobalUse)>,
#[allow(unused)]
spec_constants: Vec<SpecializationConstant>,
sampling_pairs: FastHashSet<(naga::Handle<Resource>, naga::Handle<Resource>)>,
}

View File

@ -155,13 +155,17 @@ unsafe impl Sync for Surface {}
#[derive(Debug, Clone, Copy)]
enum MemoryArchitecture {
Unified { cache_coherent: bool },
Unified {
#[allow(unused)]
cache_coherent: bool,
},
NonUnified,
}
#[derive(Debug, Clone, Copy)]
struct PrivateCapabilities {
instance_flags: crate::InstanceFlags,
#[allow(unused)]
heterogeneous_resource_heaps: bool,
memory_architecture: MemoryArchitecture,
heap_create_not_zeroed: bool,

View File

@ -317,6 +317,7 @@ impl AdapterContext {
#[derive(Debug)]
struct Inner {
egl: Arc<egl::DynamicInstance<egl::EGL1_4>>,
#[allow(unused)]
version: (i32, i32),
supports_native_window: bool,
display: egl::Display,
@ -721,6 +722,7 @@ pub struct Swapchain {
extent: wgt::Extent3d,
format: wgt::TextureFormat,
format_desc: super::TextureFormatDesc,
#[allow(unused)]
sample_type: wgt::TextureSampleType,
}
@ -731,6 +733,7 @@ pub struct Surface {
config: egl::Config,
display: egl::Display,
context: egl::Context,
#[allow(unused)]
pbuffer: Option<egl::Surface>,
pub(super) presentable: bool,
raw_window_handle: RawWindowHandle,

View File

@ -229,6 +229,7 @@ pub struct Texture {
mip_level_count: u32,
array_layer_count: u32,
format: wgt::TextureFormat,
#[allow(unused)]
format_desc: TextureFormatDesc,
copy_size: crate::CopyExtent,
}
@ -345,6 +346,7 @@ struct VertexBufferDesc {
stride: u32,
}
#[allow(unused)]
#[derive(Clone)]
struct UniformDesc {
location: glow::UniformLocation,
@ -533,6 +535,7 @@ enum Command {
dst_target: BindTarget,
range: crate::MemoryRange,
},
#[allow(unused)] // yet unimplemented
ClearTexture {
dst: glow::Texture,
dst_target: BindTarget,
@ -554,6 +557,7 @@ enum Command {
},
CopyBufferToTexture {
src: glow::Buffer,
#[allow(unused)]
src_target: BindTarget,
dst: glow::Texture,
dst_target: BindTarget,
@ -565,6 +569,7 @@ enum Command {
src_target: BindTarget,
src_format: wgt::TextureFormat,
dst: glow::Buffer,
#[allow(unused)]
dst_target: BindTarget,
copy: crate::BufferTextureCopy,
},

View File

@ -3,11 +3,6 @@
*/
#![allow(
// The intra doc links to the wgpu crate in this crate actually successfully link to the types in the wgpu crate, when built from the wgpu crate.
// However when building from both the wgpu crate or this crate cargo doc will claim all the links cannot be resolved
// despite the fact that it works fine when it needs to.
// So we just disable those warnings.
broken_intra_doc_links,
// We don't use syntax sugar where it's not necessary.
clippy::match_like_matches_macro,
)]
@ -722,6 +717,8 @@ impl Limits {
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DownlevelLimits {}
#[allow(unknown_lints)] // derivable_impls is nightly only currently
#[allow(clippy::derivable_impls)]
impl Default for DownlevelLimits {
fn default() -> Self {
DownlevelLimits {}
@ -2776,7 +2773,7 @@ impl<L> TextureDescriptor<L> {
/// # use wgpu_types as wgpu;
/// let desc = wgpu::TextureDescriptor {
/// label: (),
/// size: Extent3d { width: 100, height: 60, depth_or_array_layers: 2 },
/// size: wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 },
/// mip_level_count: 7,
/// sample_count: 1,
/// dimension: wgpu::TextureDimension::D3,

View File

@ -2,23 +2,22 @@ use wgt::{Backends, PowerPreference, RequestAdapterOptions};
use crate::{Adapter, Instance, Surface};
#[cfg(any(not(target_arch = "wasm32"), feature = "wgc"))]
pub use wgc::instance::parse_backends_from_comma_list;
/// Always returns WEBGPU on wasm over webgpu.
#[cfg(all(target_arch = "wasm32", not(feature = "wgc")))]
pub fn parse_backends_from_comma_list(_string: &str) -> Backends {
Backends::BROWSER_WEBGPU
}
/// Get a set of backend bits from the environment variable WGPU_BACKEND.
pub fn backend_bits_from_env() -> Option<Backends> {
Some(
match std::env::var("WGPU_BACKEND")
.as_deref()
.map(str::to_lowercase)
.as_deref()
{
Ok("vulkan") => Backends::VULKAN,
Ok("dx12") => Backends::DX12,
Ok("dx11") => Backends::DX11,
Ok("metal") => Backends::METAL,
Ok("gl") => Backends::GL,
Ok("webgpu") => Backends::BROWSER_WEBGPU,
_ => return None,
},
)
std::env::var("WGPU_BACKEND")
.as_deref()
.map(str::to_lowercase)
.ok()
.as_deref()
.map(parse_backends_from_comma_list)
}
/// Get a power preference from the environment variable WGPU_POWER_PREF
@ -79,8 +78,7 @@ pub async fn initialize_adapter_from_env_or_default(
None => {
instance
.request_adapter(&RequestAdapterOptions {
power_preference: power_preference_from_env()
.unwrap_or_else(PowerPreference::default),
power_preference: power_preference_from_env().unwrap_or_default(),
compatible_surface,
})
.await

View File

@ -15,10 +15,7 @@ use std::{
pub use belt::StagingBelt;
pub use device::{BufferInitDescriptor, DeviceExt};
pub use encoder::RenderEncoder;
pub use init::{
backend_bits_from_env, initialize_adapter_from_env, initialize_adapter_from_env_or_default,
power_preference_from_env,
};
pub use init::*;
/// Treat the given byte slice as a SPIR-V module.
///