Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e79440c

Browse files
committedOct 15, 2024·
clippys, slab buffers are created with size 1 to avoid wgpu validation bug
1 parent b7b9800 commit e79440c

File tree

10 files changed

+48
-44
lines changed

10 files changed

+48
-44
lines changed
 

‎Cargo.lock

+31-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resolver = "2"
1717
assert_approx_eq = "1.1.0"
1818
async-channel = "1.8"
1919
bytemuck = { version = "1.13.0", features = ["derive"] }
20-
crabslab = { version = "0.6.0", path = "../crabslab/crates/crabslab", default-features = false }
20+
crabslab = { version = "0.6.1", default-features = false }
2121
ctor = "0.2.2"
2222
dagga = "0.2.1"
2323
env_logger = "0.10.0"
@@ -50,7 +50,7 @@ opt-level = 3
5050
opt-level = 3
5151

5252
[patch.crates-io]
53-
naga = { git = "https://github.com/schell/wgpu.git", branch = "fix/spv-in-sampling-result-for-depth-texture-is-scalar" }
54-
wgpu = { git = "https://github.com/schell/wgpu.git", branch = "fix/spv-in-sampling-result-for-depth-texture-is-scalar" }
55-
spirv-std = {path = "../rust-gpu/crates/spirv-std" } #{ git = "https://github.com/Rust-GPU/rust-gpu" }
53+
naga = { git = "https://github.com/gfx-rs/wgpu.git" }
54+
wgpu = { git = "https://github.com/gfx-rs/wgpu.git" }
55+
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu" }
5656

‎crates/renderling/src/atlas/cpu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl Atlas {
278278
let mut texture_array = self.texture_array.write().unwrap();
279279
let extent = texture_array.texture.size();
280280

281-
let newly_packed_layers = pack_images(&layers, &images, extent)
281+
let newly_packed_layers = pack_images(&layers, images, extent)
282282
.context(CannotPackTexturesSnafu { size: extent })?;
283283

284284
let mut staged = StagedResources::try_staging(
@@ -422,14 +422,14 @@ fn pack_images<'a>(
422422
images
423423
.iter()
424424
.enumerate()
425-
.map(|(i, img)| AnotherPacking::Img {
425+
.map(|(i, image)| AnotherPacking::Img {
426426
original_index: i,
427-
image: &img,
427+
image,
428428
}),
429429
)
430430
.collect()
431431
};
432-
new_packing.sort_by(|a, b| (a.size().length_squared()).cmp(&(b.size().length_squared())));
432+
new_packing.sort_by_key(|a| (a.size().length_squared()));
433433
let total_images = new_packing.len();
434434
let new_packing_layers: Vec<Vec<AnotherPacking>> =
435435
fan_split_n(extent.depth_or_array_layers as usize, new_packing);

‎crates/renderling/src/convolution.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use spirv_std::num_traits::Float;
1414

1515
use crate::{camera::Camera, math::IsVector};
1616

17+
// Allow manual bit rotation because this code is `no_std`.
18+
#[allow(clippy::manual_rotate)]
1719
fn radical_inverse_vdc(mut bits: u32) -> f32 {
1820
bits = (bits << 16u32) | (bits >> 16u32);
1921
bits = ((bits & 0x55555555u32) << 1u32) | ((bits & 0xAAAAAAAAu32) >> 1u32);

‎crates/renderling/src/cull/cpu.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ impl From<SlabAllocatorError> for CullingError {
3636
}
3737
}
3838

39-
4039
/// Computes frustum and occlusion culling on the GPU.
4140
pub struct ComputeCulling {
4241
pipeline: wgpu::ComputePipeline,
@@ -308,12 +307,11 @@ impl DepthPyramid {
308307
let depth_data: Vec<f32> = slab_data
309308
.read_vec(mip.array())
310309
.into_iter()
311-
.map(|depth| {
310+
.inspect(|&depth| {
312311
if i == 0 {
313312
min = min.min(depth);
314313
max = max.max(depth);
315314
}
316-
depth
317315
})
318316
.collect();
319317
log::info!("min: {min}");
@@ -329,7 +327,6 @@ impl DepthPyramid {
329327
}
330328
}
331329

332-
333330
/// Copies the depth texture to the top of the depth pyramid.
334331
struct ComputeCopyDepth {
335332
pipeline: wgpu::ComputePipeline,
@@ -516,7 +513,6 @@ impl ComputeCopyDepth {
516513
}
517514
}
518515

519-
520516
/// Downsamples the depth texture from one mip to the next.
521517
struct ComputeDownsampleDepth {
522518
pipeline: wgpu::ComputePipeline,

‎crates/renderling/src/linkage.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub mod compute_copy_depth_to_pyramid;
1111
pub mod compute_copy_depth_to_pyramid_multisampled;
1212
pub mod compute_culling;
1313
pub mod compute_downsample_depth_pyramid;
14-
pub mod compute_occlusion_culling;
1514
pub mod generate_mipmap_fragment;
1615
pub mod generate_mipmap_vertex;
1716
pub mod prefilter_environment_cubemap_fragment;

‎crates/renderling/src/slab/cpu.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ impl<Buffer> Default for SlabAllocator<Buffer> {
247247
update_queue: Default::default(),
248248
recycles: Default::default(),
249249
len: Default::default(),
250-
capacity: Default::default(),
250+
// Start with size 1, because some of `wgpu`'s validation depends on it.
251+
// See <https://github.com/gfx-rs/wgpu/issues/6414> for more info.
252+
capacity: Arc::new(AtomicUsize::new(1)),
251253
needs_expansion: Arc::new(true.into()),
252254
buffer: Default::default(),
253255
}

‎crates/renderling/src/texture.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,7 @@ impl Texture {
619619
) -> Vec<Self> {
620620
let generator = MipMapGenerator::new(device, self.texture.format());
621621
// UNWRAP: safe because we know the formats match.
622-
generator
623-
.generate(device, queue, &self, mip_levels)
624-
.unwrap()
622+
generator.generate(device, queue, self, mip_levels).unwrap()
625623
}
626624

627625
pub const HDR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba16Float;

‎crates/renderling/src/texture/mips.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn create_pipeline(
2525
let fragment_linkage = crate::linkage::generate_mipmap_fragment::linkage(device);
2626
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
2727
label: LABEL,
28-
layout: Some(&pp_layout),
28+
layout: Some(pp_layout),
2929
vertex: wgpu::VertexState {
3030
module: &vertex_linkage.module,
3131
entry_point: Some(vertex_linkage.entry_point),

‎shaders/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env_logger = "^0.10"
1212
log = "^0.4"
1313
naga = { version = "0.19", features = ["spv-in", "wgsl-out", "wgsl-in", "msl-out"] }
1414
quote = "1.0"
15-
spirv-builder = { path = "../../rust-gpu/crates/spirv-builder" } #git = "https://github.com/Rust-GPU/rust-gpu" }
15+
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu" }
1616

1717
# Enable incremental by default in release mode.
1818
[profile.release]

0 commit comments

Comments
 (0)
Please sign in to comment.