PhotoCraft: An open-source, photo editor written by scratch in pure Rust
GPU composite: lower-stack cache chunks have no texture view (#5423)
Matthew Santiagod213273c744c
diff --git a/crates/gpu/src/prefix.rs b/crates/gpu/src/prefix.rsindex 34c70916e..cf53a6285 100644--- a/crates/gpu/src/prefix.rs+++ b/crates/gpu/src/prefix.rs@@ -18,15 +18,16 @@ use std::collections::HashMap;use photocraft_doc::{Document, Layer};use photocraft_geom::Rect;-use crate::Tex;use crate::plan::{Checkpoint, Plan};pub(crate) const MAX_BYTES: u64 = 512 << 20;/// One whole grid chunk, with the document rectangles that hold valid pixels: a whole-chunk/// capture covers the cell in one entry, partial captures accumulate alongside each other.+/// The texture is only copied to and from, so it has no view: Vulkan rejects a view on an image+/// without a sampled/storage/attachment usage (VUID-VkImageViewCreateInfo-image-04441).pub(crate) struct Chunk {- tex: Tex,+ tex: wgpu::Texture,covered: Vec<Rect>,/// The checkpoint the covered pixels hold.checkpoint: Checkpoint,@@ -172,7 +173,7 @@ impl Prefix {let Some((chunk, (ox, oy))) = self.covered_by(rect) else { return false };encoder.copy_texture_to_texture(wgpu::TexelCopyTextureInfo {- texture: &chunk.tex.texture,+ texture: &chunk.tex,mip_level: 0,origin: wgpu::Origin3d { x: ox.unsigned_abs(), y: oy.unsigned_abs(), z: 0 },aspect: wgpu::TextureAspect::All,@@ -198,8 +199,16 @@ impl Prefix {if cell_bytes == 0 || cell_bytes > self.budget.saturating_sub(self.bytes) {return;}- let tex =- Tex::new(device, "pc_compose_prefix", cell.width(), cell.height(), src.format(), wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::COPY_DST);+ let tex = device.create_texture(&wgpu::TextureDescriptor {+ label: Some("pc_compose_prefix"),+ size: wgpu::Extent3d { width: cell.width().max(1), height: cell.height().max(1), depth_or_array_layers: 1 },+ mip_level_count: 1,+ sample_count: 1,+ dimension: wgpu::TextureDimension::D2,+ format: src.format(),+ usage: wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::COPY_DST,+ view_formats: &[],+ });self.bytes = self.bytes.saturating_add(cell_bytes);self.chunks.insert(cell, Chunk { tex, covered: Vec::new(), checkpoint, bytes: cell_bytes });}@@ -221,7 +230,7 @@ impl Prefix {encoder.copy_texture_to_texture(wgpu::TexelCopyTextureInfo { texture: src, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All },wgpu::TexelCopyTextureInfo {- texture: &chunk.tex.texture,+ texture: &chunk.tex,mip_level: 0,origin: wgpu::Origin3d { x: ox.unsigned_abs(), y: oy.unsigned_abs(), z: 0 },aspect: wgpu::TextureAspect::All,