Skip to content

Commit

Permalink
Merge branch 'trunk' into ray-tracing-new
Browse files Browse the repository at this point in the history
  • Loading branch information
Vecvec authored Oct 21, 2024
2 parents 17b2d89 + e06f10e commit 6c2b6f3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ jobs:
run: taplo format --check --diff

- name: Check for typos
uses: crate-ci/typos@v1.24.6
uses: crate-ci/typos@v1.26.0

check-cts-runner:
# runtime is normally 2 minutes
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).

- Fix GL debug message callbacks not being properly cleaned up (causing UB). By @Imberflur in [#6114](https://github.com/gfx-rs/wgpu/pull/6114)
- Fix calling `slice::from_raw_parts` with unaligned pointers in push constant handling. By @Imberflur in [#6341](https://github.com/gfx-rs/wgpu/pull/6341)
- Optimise fence checking when `Queue::submit` is called many times per frame. By @dinnerbone in [#6427](https://github.com/gfx-rs/wgpu/pull/6427)

#### WebGPU

Expand Down Expand Up @@ -952,7 +953,7 @@ By @cwfitzgerald in [#5053](https://github.com/gfx-rs/wgpu/pull/5053)

#### Naga

- Naga's WGSL front end now allows operators to produce values with abstract types, rather than concretizing thir operands. By @jimblandy in [#4850](https://github.com/gfx-rs/wgpu/pull/4850) and [#4870](https://github.com/gfx-rs/wgpu/pull/4870).
- Naga's WGSL front end now allows operators to produce values with abstract types, rather than concretizing their operands. By @jimblandy in [#4850](https://github.com/gfx-rs/wgpu/pull/4850) and [#4870](https://github.com/gfx-rs/wgpu/pull/4870).
- Naga's WGSL front and back ends now have experimental support for 64-bit floating-point literals: `1.0lf` denotes an `f64` value. There has been experimental support for an `f64` type for a while, but until now there was no syntax for writing literals with that type. As before, Naga module validation rejects `f64` values unless `naga::valid::Capabilities::FLOAT64` is requested. By @jimblandy in [#4747](https://github.com/gfx-rs/wgpu/pull/4747).
- Naga constant evaluation can now process binary operators whose operands are both vectors. By @jimblandy in [#4861](https://github.com/gfx-rs/wgpu/pull/4861).
- Add `--bulk-validate` option to Naga CLI. By @jimblandy in [#4871](https://github.com/gfx-rs/wgpu/pull/4871).
Expand Down
2 changes: 1 addition & 1 deletion naga/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ MSL-OUT

API

- Make `WithSpan` clonable ([#1620](https://github.com/gfx-rs/naga/pull/1620)) **@jakobhellermann**
- Make `WithSpan` cloneable ([#1620](https://github.com/gfx-rs/naga/pull/1620)) **@jakobhellermann**

MSL-OUT

Expand Down
21 changes: 14 additions & 7 deletions wgpu-hal/src/gles/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
sync::{Arc, Mutex},
};

use crate::AtomicFenceValue;
use arrayvec::ArrayVec;
use std::sync::atomic::Ordering;

Expand Down Expand Up @@ -1534,7 +1535,7 @@ impl crate::Device for super::Device {
unsafe fn create_fence(&self) -> Result<super::Fence, crate::DeviceError> {
self.counters.fences.add(1);
Ok(super::Fence {
last_completed: 0,
last_completed: AtomicFenceValue::new(0),
pending: Vec::new(),
})
}
Expand All @@ -1560,7 +1561,7 @@ impl crate::Device for super::Device {
wait_value: crate::FenceValue,
timeout_ms: u32,
) -> Result<bool, crate::DeviceError> {
if fence.last_completed < wait_value {
if fence.last_completed.load(Ordering::Relaxed) < wait_value {
let gl = &self.shared.context.lock();
let timeout_ns = if cfg!(any(webgl, Emscripten)) {
0
Expand All @@ -1572,19 +1573,25 @@ impl crate::Device for super::Device {
.iter()
.find(|&&(value, _)| value >= wait_value)
{
return match unsafe {
let signalled = match unsafe {
gl.client_wait_sync(sync, glow::SYNC_FLUSH_COMMANDS_BIT, timeout_ns as i32)
} {
// for some reason firefox returns WAIT_FAILED, to investigate
#[cfg(any(webgl, Emscripten))]
glow::WAIT_FAILED => {
log::warn!("wait failed!");
Ok(false)
false
}
glow::TIMEOUT_EXPIRED => Ok(false),
glow::CONDITION_SATISFIED | glow::ALREADY_SIGNALED => Ok(true),
_ => Err(crate::DeviceError::Lost),
glow::TIMEOUT_EXPIRED => false,
glow::CONDITION_SATISFIED | glow::ALREADY_SIGNALED => true,
_ => return Err(crate::DeviceError::Lost),
};
if signalled {
fence
.last_completed
.fetch_max(wait_value, Ordering::Relaxed);
}
return Ok(signalled);
}
}
Ok(true)
Expand Down
18 changes: 14 additions & 4 deletions wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ use glow::HasContext;

use naga::FastHashMap;
use parking_lot::Mutex;
use std::sync::atomic::{AtomicU32, AtomicU8};
use std::sync::atomic::{AtomicU32, AtomicU8, Ordering};
use std::{fmt, ops::Range, sync::Arc};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -718,7 +718,7 @@ impl crate::DynQuerySet for QuerySet {}

#[derive(Debug)]
pub struct Fence {
last_completed: crate::FenceValue,
last_completed: crate::AtomicFenceValue,
pending: Vec<(crate::FenceValue, glow::Fence)>,
}

Expand All @@ -743,13 +743,24 @@ unsafe impl Sync for Fence {}

impl Fence {
fn get_latest(&self, gl: &glow::Context) -> crate::FenceValue {
let mut max_value = self.last_completed;
let mut max_value = self.last_completed.load(Ordering::Relaxed);
for &(value, sync) in self.pending.iter() {
if value <= max_value {
// We already know this was good, no need to check again
continue;
}
let status = unsafe { gl.get_sync_status(sync) };
if status == glow::SIGNALED {
max_value = value;
} else {
// Anything after the first unsignalled is guaranteed to also be unsignalled
break;
}
}

// Track the latest value, to save ourselves some querying later
self.last_completed.fetch_max(max_value, Ordering::Relaxed);

max_value
}

Expand All @@ -763,7 +774,6 @@ impl Fence {
}
}
self.pending.retain(|&(value, _)| value > latest);
self.last_completed = latest;
}
}

Expand Down

0 comments on commit 6c2b6f3

Please sign in to comment.