wgpu: fix format mismatch for copies
This commit is contained in:
parent
7593f9f9b5
commit
9c895caa51
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -3255,9 +3255,9 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
|||
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
version = "0.19.1"
|
||||
version = "0.19.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bfe9a310dcf2e6b85f00c46059aaeaf4184caa8e29a1ecd4b7a704c3482332d"
|
||||
checksum = "a4b1213b52478a7631d6e387543ed8f642bc02c578ef4e3b49aca2a29a7df0cb"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"cfg-if",
|
||||
|
@ -3350,9 +3350,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.19.0"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "895fcbeb772bfb049eb80b2d6e47f6c9af235284e9703c96fc0218a42ffd5af2"
|
||||
checksum = "b671ff9fb03f78b46ff176494ee1ebe7d603393f42664be55b64dc8d53969805"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"js-sys",
|
||||
|
|
|
@ -24,7 +24,7 @@ metal = ["icrate"]
|
|||
[dependencies]
|
||||
gl = { version = "0.14.0", optional = true }
|
||||
ash = { version = "0.37", optional = true }
|
||||
wgpu-types = { version = "0.19.0", optional = true }
|
||||
wgpu-types = { version = "0.19.2", optional = true }
|
||||
num-traits = "0.2.15"
|
||||
rustc-hash = "1.1.0"
|
||||
halfbrown = "0.2.4"
|
||||
|
|
|
@ -94,58 +94,6 @@ impl From<wgpu_types::Extent3d> for Size<u32> {
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// impl From<Size<u32>> for vk::Extent2D {
|
||||
// fn from(value: Size<u32>) -> Self {
|
||||
// vk::Extent2D {
|
||||
// width: value.width,
|
||||
// height: value.height,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
//
|
||||
// impl From<vk::Extent2D> for Size<u32> {
|
||||
// fn from(value: vk::Extent2D) -> Self {
|
||||
// Size {
|
||||
// width: value.width,
|
||||
// height: value.height,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<vk::Viewport> for Size<u32> {
|
||||
// fn from(value: vk::Viewport) -> Self {
|
||||
// Size {
|
||||
// width: value.width as u32,
|
||||
// height: value.height as u32,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<&vk::Viewport> for Size<u32> {
|
||||
// fn from(value: &vk::Viewport) -> Self {
|
||||
// Size {
|
||||
// width: value.width as u32,
|
||||
// height: value.height as u32,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<Size<u32>> for vk::Viewport {
|
||||
// fn from(value: Size<u32>) -> Self {
|
||||
// vk::Viewport {
|
||||
// x: 0.0,
|
||||
// y: 0.0,
|
||||
// width: value.width as f32,
|
||||
// height: value.height as f32,
|
||||
// min_depth: 0.0,
|
||||
// max_depth: 1.0,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
impl From<FilterMode> for wgpu_types::FilterMode {
|
||||
fn from(value: FilterMode) -> Self {
|
||||
match value {
|
||||
|
|
|
@ -20,7 +20,7 @@ librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.6"
|
|||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.6", features = ["wgsl"], default-features = false }
|
||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.6" }
|
||||
|
||||
wgpu = { version = "0.19.0", default-features = false, features = ["wgsl"] }
|
||||
wgpu = { version = "0.19.3", default-features = false, features = ["wgsl"] }
|
||||
image = "0.24.7"
|
||||
thiserror = "1.0.50"
|
||||
bytemuck = { version = "1.14.0", features = ["derive"] }
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::sync::Arc;
|
|||
|
||||
use crate::buffer::WgpuStagedBuffer;
|
||||
use crate::draw_quad::DrawQuad;
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, Viewport, WrapMode};
|
||||
use librashader_common::{FilterMode, Size, Viewport, WrapMode};
|
||||
use librashader_reflect::reflect::naga::{Naga, NagaLoweringOptions};
|
||||
use librashader_runtime::framebuffer::FramebufferInit;
|
||||
use librashader_runtime::render_target::RenderTarget;
|
||||
|
@ -157,7 +157,7 @@ impl FilterChainWgpu {
|
|||
Arc::clone(&device),
|
||||
Size::new(1, 1),
|
||||
1,
|
||||
ImageFormat::R8G8B8A8Unorm,
|
||||
TextureFormat::Bgra8Unorm,
|
||||
))
|
||||
};
|
||||
let input_gen = || None;
|
||||
|
|
|
@ -4,6 +4,7 @@ use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
|||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
|
||||
use std::sync::Arc;
|
||||
use wgpu::TextureFormat;
|
||||
|
||||
pub struct OwnedImage {
|
||||
device: Arc<wgpu::Device>,
|
||||
|
@ -35,11 +36,8 @@ impl OwnedImage {
|
|||
device: Arc<wgpu::Device>,
|
||||
size: Size<u32>,
|
||||
max_miplevels: u32,
|
||||
format: ImageFormat,
|
||||
format: TextureFormat,
|
||||
) -> Self {
|
||||
let format: Option<wgpu::TextureFormat> = format.into();
|
||||
let format = format.unwrap_or(wgpu::TextureFormat::Rgba8Unorm);
|
||||
|
||||
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: None,
|
||||
size: size.into(),
|
||||
|
@ -78,16 +76,13 @@ impl OwnedImage {
|
|||
pub fn scale(
|
||||
&mut self,
|
||||
scaling: Scale2D,
|
||||
format: ImageFormat,
|
||||
format: TextureFormat,
|
||||
viewport_size: &Size<u32>,
|
||||
source_size: &Size<u32>,
|
||||
original_size: &Size<u32>,
|
||||
mipmap: bool,
|
||||
) -> Size<u32> {
|
||||
let size = source_size.scale_viewport(scaling, *viewport_size, *original_size);
|
||||
let format: Option<wgpu::TextureFormat> = format.into();
|
||||
let format = format.unwrap_or(wgpu::TextureFormat::Rgba8Unorm);
|
||||
|
||||
if self.size != size
|
||||
|| (mipmap && self.max_miplevels == 1)
|
||||
|| (!mipmap && self.max_miplevels != 1)
|
||||
|
@ -114,7 +109,18 @@ impl OwnedImage {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn copy_from(&self, cmd: &mut wgpu::CommandEncoder, source: &wgpu::Texture) {
|
||||
pub fn copy_from(&mut self, cmd: &mut wgpu::CommandEncoder, source: &wgpu::Texture) {
|
||||
let source_size = source.size().into();
|
||||
if source.format() != self.image.format() || self.size != source_size {
|
||||
let mut new = OwnedImage::new(
|
||||
Arc::clone(&self.device),
|
||||
source_size,
|
||||
self.max_miplevels,
|
||||
source.format(),
|
||||
);
|
||||
std::mem::swap(self, &mut new);
|
||||
}
|
||||
|
||||
cmd.copy_texture_to_texture(
|
||||
source.as_image_copy(),
|
||||
self.image.as_image_copy(),
|
||||
|
@ -149,6 +155,8 @@ impl ScaleFramebuffer for OwnedImage {
|
|||
should_mipmap: bool,
|
||||
_context: &Self::Context,
|
||||
) -> Result<Size<u32>, Self::Error> {
|
||||
let format: Option<wgpu::TextureFormat> = format.into();
|
||||
let format = format.unwrap_or(TextureFormat::Bgra8Unorm);
|
||||
Ok(self.scale(
|
||||
scaling,
|
||||
format,
|
||||
|
|
|
@ -123,8 +123,7 @@ impl<'a> State<'a> {
|
|||
// )
|
||||
// .unwrap();
|
||||
//
|
||||
let preset =
|
||||
ShaderPreset::try_parse("../test/shaders_slang/crt/crt-royale.slangp").unwrap();
|
||||
let preset = ShaderPreset::try_parse("../test/shaders_slang/test/history.slangp").unwrap();
|
||||
|
||||
// let preset = ShaderPreset::try_parse(
|
||||
// "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
|
||||
|
|
Loading…
Reference in a new issue