Viewport: hidden edges no longer show through faces, and thin or coplanar faces stop z-fighting (#1434, #1739) (#1768)
Thanks @CamWight.
This commit is contained in:
1 parent
c7bb64dd74
commit
c5f3515073
10 files changed
+599
-62
No files matched your search
@@ -29,6 +29,26 @@ pub mod view;
|
||||
/// The tessellation compute shader (WGSL).
|
||||
pub const SHADER: &str = include_str!("tess.wgsl");
|
||||
|
||||
/// The device feature for a 32-bit float depth buffer with a stencil, which the viewport draws
|
||||
/// with reversed depth ([`view::reversed_depth`]) where the device has it. A device is opened
|
||||
/// with it whenever its adapter offers it ([`depth_features`]).
|
||||
pub const FLOAT_DEPTH_STENCIL: wgpu::Features = wgpu::Features::DEPTH32FLOAT_STENCIL8;
|
||||
|
||||
/// The depth features to open a device on `adapter` with: [`FLOAT_DEPTH_STENCIL`] if it has it.
|
||||
pub fn depth_features(adapter: &wgpu::Adapter) -> wgpu::Features {
|
||||
adapter.features() & FLOAT_DEPTH_STENCIL
|
||||
}
|
||||
|
||||
/// The depth format to draw with on `device`: 32-bit float (reversed depth) where it can, with a
|
||||
/// stencil when `stencil` (the section cap needs one), else 24 bits with a stencil.
|
||||
pub fn depth_format(device: &wgpu::Device, stencil: bool) -> wgpu::TextureFormat {
|
||||
match (stencil, device.features().contains(FLOAT_DEPTH_STENCIL)) {
|
||||
(false, _) => wgpu::TextureFormat::Depth32Float,
|
||||
(true, true) => wgpu::TextureFormat::Depth32FloatStencil8,
|
||||
(true, false) => wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
}
|
||||
}
|
||||
|
||||
/// The error a popped error scope caught. Native devices answer at once; a browser's answer
|
||||
/// comes later, and is not waited for (no error is assumed).
|
||||
fn popped(f: impl std::future::Future<Output = Option<wgpu::Error>>) -> Option<wgpu::Error> {
|
||||
@@ -48,6 +68,7 @@ fn open_headless() -> Result<(wgpu::Adapter, wgpu::Device, wgpu::Queue)> {
|
||||
let (adapter, _) = select::pick(policy).ok_or(GpuError::NoAdapter(policy.name()))?;
|
||||
let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
|
||||
label: Some("solidcraft headless"),
|
||||
required_features: depth_features(&adapter),
|
||||
required_limits: wgpu::Limits::downlevel_defaults().using_resolution(adapter.limits()),
|
||||
..Default::default()
|
||||
}))
|
||||
|
||||
Reference in new issue
Block a user