From 04ac5f2851aa6c19e2ce4560247acbacced6cb43 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Sun, 22 Oct 2023 00:34:00 -0400 Subject: [PATCH] Update WARP and Install Mesa on Windows CI (#4270) --- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++---- README.md | 36 ++++++++++--------- examples/hello-compute/src/tests.rs | 4 --- tests/src/params.rs | 4 +-- tests/tests/vertex_indices/mod.rs | 40 +++++++++++++++------ xtask/src/test.rs | 1 + 6 files changed, 100 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a20cd0f84..7236e0e94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,7 +118,7 @@ jobs: with: key: clippy-${{ matrix.target }}-${{ matrix.kind }}-${{ env.CACHE_SUFFIX }} - - name: install aarch64-linux-gnu g++ + - name: (linux aarch64) install aarch64-linux-gnu g++ if: matrix.target == 'aarch64-unknown-linux-gnu' run: | set -e @@ -127,7 +127,7 @@ jobs: sudo apt-get install g++-aarch64-linux-gnu - - name: add android apk to path + - name: (android) add android apk to path if: matrix.target == 'aarch64-linux-android' run: | # clang++ will be detected correctly by CC from path @@ -286,17 +286,46 @@ jobs: - name: checkout repo uses: actions/checkout@v4 + - name: Install Repo MSRV toolchain + run: | + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal -c llvm-tools + cargo -V + - name: Install cargo-nextest and cargo-llvm-cov uses: taiki-e/install-action@v2 with: tool: cargo-nextest,cargo-llvm-cov - - name: Install Repo MSRV toolchain + - name: (windows) install warp + if: matrix.os == 'windows-2022' + shell: bash run: | - rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal - cargo -V + set -e - - name: install llvmpipe, vulkan sdk + curl.exe -L https://www.nuget.org/api/v2/package/Microsoft.Direct3D.WARP/1.0.7.1 -o warp.zip + 7z.exe e warp.zip -owarp build/native/amd64/d3d10warp.dll + + mkdir -p target/llvm-cov-target/debug/deps + + cp -v warp/d3d10warp.dll target/llvm-cov-target/debug/ + cp -v warp/d3d10warp.dll target/llvm-cov-target/debug/deps + + - name: (windows) install mesa + if: matrix.os == 'windows-2022' + shell: bash + run: | + set -e + + curl.exe -L https://github.com/pal1000/mesa-dist-win/releases/download/23.2.1/mesa3d-23.2.1-release-msvc.7z -o mesa.7z + 7z.exe e mesa.7z -omesa x64/{opengl32.dll,libgallium_wgl.dll,libglapi.dll,vulkan_lvp.dll,lvp_icd.x86_64.json} + + cp -v mesa/* target/llvm-cov-target/debug/ + cp -v mesa/* target/llvm-cov-target/debug/deps + + echo "VK_DRIVER_FILES=$PWD/mesa/lvp_icd.x86_64.json" >> "$GITHUB_ENV" + echo "GALLIUM_DRIVER=llvmpipe" >> "$GITHUB_ENV" + + - name: (linux) install llvmpipe, lavapipe, vulkan sdk if: matrix.os == 'ubuntu-22.04' shell: bash run: | @@ -326,6 +355,19 @@ jobs: if: matrix.os[0] != 'self-hosted' with: key: test-${{ matrix.os }}-${{ env.CACHE_SUFFIX }} + workspaces: | + . -> target + xtask -> xtask/target + + - name: run wgpu-info + shell: bash + run: | + echo "$PATH" + + export RUST_LOG=trace + + # This needs to match the command in xtask/tests.rs + cargo llvm-cov --no-cfg-coverage --no-report run --bin wgpu-info - name: run tests shell: bash diff --git a/README.md b/README.md index a3a1a6cf6..d7e72fe2e 100644 --- a/README.md +++ b/README.md @@ -70,16 +70,20 @@ We have a [wiki](https://github.com/gfx-rs/wgpu/wiki) that serves as a knowledge ## Supported Platforms -| API | Windows | Linux & Android | macOS & iOS | Web (wasm) | +| API | Windows | Linux/Android | macOS/iOS | Web (wasm) | | ----------- | ------------------------------ | ------------------ | ------------------------- | ------------------------- | -| Vulkan | :white_check_mark: | :white_check_mark: | :ok: (vulkan-portability) | | +| Vulkan | :white_check_mark: | :white_check_mark: | :volcano: | | | Metal | | | :white_check_mark: | | -| DX12 | :white_check_mark: (W10+ only) | | | | +| DX12 | :white_check_mark: | | | | | DX11 | :hammer_and_wrench: | | | | -| OpenGL | :ok: (Desktop GL 3.3+) | :ok: (GL ES 3.0+) | :ok: (angle; GL ES 3.0+) | :ok: (WebGL2) | +| OpenGL | :ok: (GL 3.3+) | :ok: (GL ES 3.0+) | :triangular_ruler: | :ok: (WebGL2) | | WebGPU | | | | :white_check_mark: | -:white_check_mark: = First Class Support — :ok: = Best Effort Support — :hammer_and_wrench: = Unsupported, but support in progress +:white_check_mark: = First Class Support +:ok: = Downlevel/Best Effort Support +:triangular_ruler: = Requires the [ANGLE](#angle) translation layer +:volcano: = Requires the [MoltenVK](https://vulkan.lunarg.com/sdk/home#mac) translation layer +:hammer_and_wrench: = Unsupported, though open to contributions ### Shader Support @@ -103,7 +107,7 @@ To enable GLSL shaders, enable the `glsl` feature of wgpu. ### Angle [Angle](http://angleproject.org) is a translation layer from GLES to other backends, developed by Google. -We support running our GLES3 backend over it in order to reach platforms with GLES2 or DX11 support, which aren't accessible otherwise. +We support running our GLES3 backend over it in order to reach platforms DX11 support, which aren't accessible otherwise. In order to run with Angle, "angle" feature has to be enabled, and Angle libraries placed in a location visible to the application. These binaries can be downloaded from [gfbuild-angle](https://github.com/DileSoft/gfbuild-angle) artifacts, [manual compilation](https://github.com/google/angle/blob/main/doc/DevSetup.md) may be required on Macs with Apple silicon. @@ -140,17 +144,17 @@ When running the CTS, use the variables `DENO_WEBGPU_ADAPTER_NAME`, `DENO_WEBGPU ## Testing -We have multiple methods of testing, each of which tests different qualities about wgpu. We automatically run our tests on CI if possible. The current state of CI testing: +We have multiple methods of testing, each of which tests different qualities about wgpu. We automatically run our tests on CI. The current state of CI testing: -| Backend/Platform | Tests | CTS | Notes | -| ---------------- | ------------------ | ------------------ | ------------------------------------- | -| DX12/Windows 10 | :heavy_check_mark: | - | using WARP | -| DX11/Windows 10 | :construction: | — | using WARP | -| Metal/MacOS | :heavy_check_mark: | — | using hardware runner | -| Vulkan/Linux | :heavy_check_mark: | - | using swiftshader | -| GL/Windows | | — | | -| GLES/Linux | :heavy_check_mark: | — | using llvmpipe | -| WebGL/Chrome | :heavy_check_mark: | — | using swiftshader | +| Platform/Backend | Tests | Notes | +| ---------------- | ------------------ | ------------------------------------- | +| Windows/DX12 | :heavy_check_mark: | using WARP | +| Windows/OpenGL | :heavy_check_mark: | using llvmpipe | +| MacOS/Metal | :heavy_check_mark: | using hardware runner | +| Linux/Vulkan | :heavy_check_mark: | using lavapipe | +| Linux/OpenGL ES | :heavy_check_mark: | using llvmpipe | +| Chrome/WebGL | :heavy_check_mark: | using swiftshader | +| Chrome/WebGPU | :x: | not set up | ### Core Test Infrastructure diff --git a/examples/hello-compute/src/tests.rs b/examples/hello-compute/src/tests.rs index d435b011f..84405640a 100644 --- a/examples/hello-compute/src/tests.rs +++ b/examples/hello-compute/src/tests.rs @@ -7,7 +7,6 @@ static COMPUTE_1: GpuTestConfiguration = GpuTestConfiguration::new() TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults()) - .features(wgpu::Features::TIMESTAMP_QUERY) .skip(FailureCase::adapter("V3D")), ) .run_async(|ctx| { @@ -22,7 +21,6 @@ static COMPUTE_2: GpuTestConfiguration = GpuTestConfiguration::new() TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults()) - .features(wgpu::Features::TIMESTAMP_QUERY) .skip(FailureCase::adapter("V3D")), ) .run_async(|ctx| { @@ -37,7 +35,6 @@ static COMPUTE_OVERFLOW: GpuTestConfiguration = GpuTestConfiguration::new() TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults()) - .features(wgpu::Features::TIMESTAMP_QUERY) .skip(FailureCase::adapter("V3D")), ) .run_async(|ctx| { @@ -60,7 +57,6 @@ static MULTITHREADED_COMPUTE: GpuTestConfiguration = GpuTestConfiguration::new() TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults()) - .features(wgpu::Features::TIMESTAMP_QUERY) .skip(FailureCase::adapter("V3D")), ) .run_sync(|ctx| { diff --git a/tests/src/params.rs b/tests/src/params.rs index 4da998987..e83a33d64 100644 --- a/tests/src/params.rs +++ b/tests/src/params.rs @@ -240,9 +240,9 @@ bitflags::bitflags! { // Builder pattern to make it easier impl TestParameters { - /// Set of common features that most internal tests require for readback. + /// Set of common features that most internal tests require for compute and readback. pub fn test_features_limits(self) -> Self { - self.features(Features::MAPPABLE_PRIMARY_BUFFERS | Features::VERTEX_WRITABLE_STORAGE) + self.downlevel_flags(DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults()) } diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index fbfb18179..4fe8395ea 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -29,12 +29,18 @@ fn pulling_common( }], }); - let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { + let buffer_size = 4 * expected.len() as u64; + let cpu_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { label: None, - size: 4 * expected.len() as u64, - usage: wgpu::BufferUsages::COPY_SRC - | wgpu::BufferUsages::STORAGE - | wgpu::BufferUsages::MAP_READ, + size: buffer_size, + usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, + mapped_at_creation: false, + }); + + let gpu_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { + label: None, + size: buffer_size, + usage: wgpu::BufferUsages::COPY_SRC | wgpu::BufferUsages::STORAGE, mapped_at_creation: false, }); @@ -43,7 +49,7 @@ fn pulling_common( layout: &bgl, entries: &[wgpu::BindGroupEntry { binding: 0, - resource: buffer.as_entire_binding(), + resource: gpu_buffer.as_entire_binding(), }], }); @@ -124,8 +130,10 @@ fn pulling_common( drop(rpass); + encoder.copy_buffer_to_buffer(&gpu_buffer, 0, &cpu_buffer, 0, buffer_size); + ctx.queue.submit(Some(encoder.finish())); - let slice = buffer.slice(..); + let slice = cpu_buffer.slice(..); slice.map_async(wgpu::MapMode::Read, |_| ()); ctx.device.poll(wgpu::Maintain::Wait); let data: Vec = bytemuck::cast_slice(&slice.get_mapped_range()).to_vec(); @@ -135,7 +143,11 @@ fn pulling_common( #[gpu_test] static DRAW: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().test_features_limits()) + .parameters( + TestParameters::default() + .test_features_limits() + .features(wgpu::Features::VERTEX_WRITABLE_STORAGE), + ) .run_sync(|ctx| { pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| { cmb.draw(0..6, 0..1); @@ -144,7 +156,11 @@ static DRAW: GpuTestConfiguration = GpuTestConfiguration::new() #[gpu_test] static DRAW_VERTEX: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().test_features_limits()) + .parameters( + TestParameters::default() + .test_features_limits() + .features(wgpu::Features::VERTEX_WRITABLE_STORAGE), + ) .run_sync(|ctx| { pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| { cmb.draw(0..3, 0..1); @@ -157,7 +173,7 @@ static DRAW_INSTANCED: GpuTestConfiguration = GpuTestConfiguration::new() .parameters( TestParameters::default() .test_features_limits() - .expect_fail(FailureCase::backend(wgpu::Backends::DX11)), + .features(wgpu::Features::VERTEX_WRITABLE_STORAGE), ) .run_sync(|ctx| { pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| { @@ -170,7 +186,9 @@ static DRAW_INSTANCED_OFFSET: GpuTestConfiguration = GpuTestConfiguration::new() .parameters( TestParameters::default() .test_features_limits() - .expect_fail(FailureCase::backend(wgpu::Backends::DX11)), + .features(wgpu::Features::VERTEX_WRITABLE_STORAGE) + // https://github.com/gfx-rs/wgpu/issues/4276 + .expect_fail(FailureCase::backend(wgpu::Backends::GL)), ) .run_sync(|ctx| { pulling_common(ctx, &[0, 1, 2, 3, 4, 5], |cmb| { diff --git a/xtask/src/test.rs b/xtask/src/test.rs index 6d003c7a9..23035146c 100644 --- a/xtask/src/test.rs +++ b/xtask/src/test.rs @@ -3,6 +3,7 @@ use pico_args::Arguments; pub fn run_tests(mut args: Arguments) -> anyhow::Result<()> { let llvm_cov = args.contains("--llvm-cov"); + // These needs to match the command in "run wgpu-info" in `.github/workflows/ci.yml` let llvm_cov_flags: &[_] = if llvm_cov { &["llvm-cov", "--no-cfg-coverage", "--no-report"] } else {