Skip to content

Commit

Permalink
Run Linux & Windows screenshot tests via lavapipe software rasteriz…
Browse files Browse the repository at this point in the history
…er (#8620)
  • Loading branch information
Wumpf authored Jan 10, 2025
1 parent 0acbea0 commit 45d4df0
Show file tree
Hide file tree
Showing 13 changed files with 422 additions and 82 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/contrib_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ env:
# these incremental artifacts when running on CI.
CARGO_INCREMENTAL: "0"

# Sourced from https://vulkan.lunarg.com/sdk/home#linux
VULKAN_SDK_VERSION: "1.3.296.0"

defaults:
run:
shell: bash
Expand Down Expand Up @@ -97,6 +100,19 @@ jobs:
with:
pixi-version: v0.39.0

# Install the Vulkan SDK, so we can use the software rasterizer.
# TODO(andreas): It would be nice if `setup_software_rasterizer.py` could do that for us as well (note though that this action here is very fast when cached!)
- name: Install Vulkan SDK
uses: jakoch/[email protected]
with:
vulkan_version: ${{ env.VULKAN_SDK_VERSION }}
install_runtime: true
cache: false
stripdown: true

- name: Setup software rasterizer
run: pixi run python ./scripts/ci/setup_software_rasterizer.py

- name: Rust checks & tests
run: pixi run rs-check --skip individual_crates docs_slow

Expand Down
65 changes: 56 additions & 9 deletions .github/workflows/reusable_checks_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ concurrency:
cancel-in-progress: true

env:
PYTHON_VERSION: "3.8"
# web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
Expand All @@ -34,6 +33,12 @@ env:
# these incremental artifacts when running on CI.
CARGO_INCREMENTAL: "0"

# Improve diagnostics for crashes.
RUST_BACKTRACE: full

# Sourced from https://vulkan.lunarg.com/sdk/home#linux
VULKAN_SDK_VERSION: "1.3.296.0"

defaults:
run:
shell: bash
Expand All @@ -52,6 +57,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '' }}
lfs: true

- name: Set up Rust
uses: ./.github/actions/setup-rust
Expand All @@ -65,11 +71,32 @@ jobs:
with:
pixi-version: v0.39.0

- name: Rust checks & tests
# Install the Vulkan SDK, so we can use the software rasterizer.
# TODO(andreas): It would be nice if `setup_software_rasterizer.py` could do that for us as well (note though that this action here is very fast when cached!)
- name: Install Vulkan SDK
uses: jakoch/[email protected]
with:
vulkan_version: ${{ env.VULKAN_SDK_VERSION }}
install_runtime: true
cache: false
stripdown: true

- name: Setup software rasterizer
run: pixi run python ./scripts/ci/setup_software_rasterizer.py

- name: Rust checks (PR subset)
if: ${{ inputs.CHANNEL == 'pr' }}
run: pixi run rs-check --only base_checks sdk_variations cargo_deny wasm docs

- name: Download test assets
run: pixi run python ./tests/assets/download_test_assets.py

- name: Run tests (`cargo test --all-targets --all-features`)
if: ${{ inputs.CHANNEL == 'pr' }}
run: pixi run rs-check --skip individual_crates tests docs_slow
# Need to use pixi due to NASM dependency.
run: pixi run cargo test --all-targets --all-features

- name: Rust checks & tests
- name: Rust most checks & tests
if: ${{ inputs.CHANNEL == 'main' }}
run: pixi run rs-check --skip individual_crates docs_slow

Expand All @@ -83,10 +110,10 @@ jobs:
strategy:
matrix:
include:
# TODO(#8245): we run mac tests on `main` because that's the only platform where UI snapshot tests are covered.
# When the linux runners are able to run these tests (with a software renderer), we can move that back to all nightly.
- os: ${{ inputs.CHANNEL == 'main' && 'macos-latest' || 'windows-latest-8-cores' }}
name: ${{ inputs.CHANNEL == 'main' && 'macos' || 'windows' }}
- os: "macos-latest"
name: "macos"
- os: "windows-latest-8-cores"
name: "windows"

# Note: we can't use `matrix.os` here because its evaluated before the matrix stuff.
if: ${{ inputs.CHANNEL == 'main' || inputs.CHANNEL == 'nightly' }}
Expand All @@ -109,8 +136,28 @@ jobs:
with:
pixi-version: v0.39.0

# Install the Vulkan SDK, so we can use the software rasterizer.
# TODO(andreas): It would be nice if `setup_software_rasterizer.py` could do that for us as well (note though that this action here is very fast when cached!)
- name: Install Vulkan SDK
if: ${{ matrix.name != 'macos' }}
uses: jakoch/[email protected]
with:
vulkan_version: ${{ env.VULKAN_SDK_VERSION }}
install_runtime: true
cache: true
stripdown: true

- name: Setup software rasterizer
run: pixi run python ./scripts/ci/setup_software_rasterizer.py

- name: Download test assets
run: pixi run python ./tests/assets/download_test_assets.py

- name: pixi run cargo test --all-targets --all-features
- name: Run tests (`cargo test --all-targets --all-features`)
if: ${{ inputs.CHANNEL == 'main' }}
# Need to use pixi due to NASM dependency.
run: pixi run cargo test --all-targets --all-features

- name: Rust all checks & tests
if: ${{ inputs.CHANNEL == 'nightly' }}
run: pixi run rs-check
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ wheels
**/tests/snapshots/**/*.diff.png
**/tests/snapshots/**/*.new.png

# Mesa install
mesa
mesa.7z
mesa.tar.xz
icd.json

*.rrd

/meilisearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,7 @@ fn test_single_component_ui_as_list_item(
});

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
if cfg!(target_os = "macos") {
harness.try_snapshot_options(&format!("{test_case}"), _snapshot_options)
} else {
Ok(())
}
harness.try_snapshot_options(&format!("{test_case}"), _snapshot_options)
}

// ---
Expand Down
13 changes: 13 additions & 0 deletions crates/viewer/re_renderer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl RenderContext {
before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&device)),
frame_index: STARTUP_FRAME_IDX,
top_level_error_scope,
num_view_builders_created: AtomicU64::new(0),
};

// Register shader workarounds for the current device.
Expand Down Expand Up @@ -316,6 +317,7 @@ This means, either a call to RenderContext::before_submit was omitted, or the pr
before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&self.device)),
frame_index: self.active_frame.frame_index.wrapping_add(1),
top_level_error_scope: Some(WgpuErrorScope::start(&self.device)),
num_view_builders_created: AtomicU64::new(0),
};
let frame_index = self.active_frame.frame_index;

Expand Down Expand Up @@ -485,6 +487,17 @@ pub struct ActiveFrameContext {
///
/// The only time this is allowed to be `None` is during shutdown and when closing an old and opening a new scope.
top_level_error_scope: Option<WgpuErrorScope>,

/// Number of view builders created in this frame so far.
pub num_view_builders_created: AtomicU64,
}

impl ActiveFrameContext {
/// Returns the number of view builders created in this frame so far.
pub fn num_view_builders_created(&self) -> u64 {
// Uses acquire semenatics to be on the safe side (side effects from the ViewBuilder creation is visible to the caller).
self.num_view_builders_created.load(Ordering::Acquire)
}
}

fn log_adapter_info(info: &wgpu::AdapterInfo) {
Expand Down
4 changes: 4 additions & 0 deletions crates/viewer/re_renderer/src/view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ impl ViewBuilder {
frame_uniform_buffer_content,
};

ctx.active_frame
.num_view_builders_created
.fetch_add(1, std::sync::atomic::Ordering::Release);

Self {
setup,
queued_draws: vec![composition_draw.into()],
Expand Down
3 changes: 0 additions & 3 deletions crates/viewer/re_time_panel/tests/time_panel_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,5 @@ fn run_time_panel_and_save_snapshot(mut test_context: TestContext, _snapshot_nam
});

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
#[cfg(target_os = "macos")]
harness.snapshot(_snapshot_name);
}
3 changes: 0 additions & 3 deletions crates/viewer/re_ui/tests/arrow_ui_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub fn test_arrow_ui() {
harness.fit_contents();

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
#[cfg(target_os = "macos")]
harness.snapshot("arrow_ui");
}

Expand Down
3 changes: 0 additions & 3 deletions crates/viewer/re_ui/tests/list_item_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,5 @@ pub fn test_list_items_should_match_snapshot() {
});

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
#[cfg(target_os = "macos")]
harness.snapshot("list_items");
}
3 changes: 0 additions & 3 deletions crates/viewer/re_ui/tests/modal_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,5 @@ fn run_modal_test(
});

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
#[cfg(target_os = "macos")]
harness.snapshot(_test_name);
}
3 changes: 0 additions & 3 deletions crates/viewer/re_view_graph/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ fn run_graph_view_and_save_snapshot(
});

harness.run();

//TODO(#8245): enable this everywhere when we have a software renderer setup
#[cfg(target_os = "macos")]
harness.snapshot(_name);

Ok(())
Expand Down
Loading

0 comments on commit 45d4df0

Please sign in to comment.