aaaaaaaaaa

This commit is contained in:
Schrottkatze 2024-11-24 09:07:19 +01:00
parent 69ab5b3b0a
commit 2dceef6f79
8 changed files with 665 additions and 763 deletions

1242
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,9 @@ edition = "2021"
[dependencies] [dependencies]
bytemuck = "1.16.0" bytemuck = "1.16.0"
eframe = {version = "0.27", features = ["wgpu"]} eframe = {version = "0.28", features = ["wgpu"]}
egui-file-dialog = "0.5.0" egui-file-dialog = "0.6.0"
egui_extras = { version = "0.27.2", features = ["image"] } egui_extras = { version = "0.28", features = ["image"] }
env_logger = "0.11.3" env_logger = "0.11.3"
image = "0.25.1" image = "0.25.1"
nalgebra = "0.32.5" nalgebra = "0.32.5"

View file

@ -1,17 +1,12 @@
{ {
"nodes": { "nodes": {
"crane": { "crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1715274763, "lastModified": 1725409566,
"narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -28,11 +23,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1715927173, "lastModified": 1726468443,
"narHash": "sha256-2S8hVck6nlyiBifzymDvePl5HWgqvVgxkBZCRax1qD8=", "narHash": "sha256-O1VcbVBrqIf58U05yFXl9+J7XM2qh0I+7vqMbNwZPq0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "a2d19ef9305841f26c8ab908b1c09a84ca307e18", "rev": "effac20e9560aab202e82b6d833f685163a9c138",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -59,31 +54,13 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1715867414, "lastModified": 1726436956,
"narHash": "sha256-cu4UEffKkBByyGR6CFs9XP6iSNsKTkq1r66DA5BkYnE=", "narHash": "sha256-a3rP7uafX/qBFX0y4CGS8vvTPvxsLl9eZQ85DkIn3DI=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "bf446f08bff6814b569265bef8374cfdd3d8f0e0", "rev": "039b72d0c738c934e2e36d7fc5520d1b425287a6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -98,18 +75,17 @@
"crane": "crane", "crane": "crane",
"fenix": "fenix", "fenix": "fenix",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"wgsl_analyzer": "wgsl_analyzer"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1715839492, "lastModified": 1726443025,
"narHash": "sha256-EyjtjocGLtB7tqyqwBfadP4y5BBtT5EkoG3kq/zym5U=", "narHash": "sha256-nCmG4NJpwI0IoIlYlwtDwVA49yuspA2E6OhfCOmiArQ=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "83ba42043166948db91fcfcfe30e0b7eac10b3d5", "rev": "94b526fc86eaa0e90fb4d54a5ba6313aa1e9b269",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -133,45 +109,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"wgsl_analyzer": {
"inputs": {
"crane": [
"crane"
],
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1702151450,
"narHash": "sha256-bhosTihbW89vkqp1ua0C1HGLJJdCNfRde98z4+IjkOc=",
"owner": "wgsl-analyzer",
"repo": "wgsl-analyzer",
"rev": "8851962fc191aa5ea85a25b0ebd10cb9f70627b3",
"type": "github"
},
"original": {
"owner": "wgsl-analyzer",
"repo": "wgsl-analyzer",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -14,12 +14,6 @@
}; };
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
wgsl_analyzer = {
url = "github:wgsl-analyzer/wgsl-analyzer";
inputs.nixpkgs.follows = "nixpkgs";
inputs.crane.follows = "crane";
};
}; };
outputs = { outputs = {
@ -28,40 +22,44 @@
crane, crane,
fenix, fenix,
flake-utils, flake-utils,
wgsl_analyzer,
... ...
}: }:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.lib.${system}; craneLib = (crane.mkLib pkgs).overrideToolchain rs-toolchain;
rs-toolchain = with fenix.packages.${system}; rs-toolchain = with fenix.packages.${system};
combine [ combine [
complete.toolchain complete.toolchain
targets.wasm32-unknown-unknown.latest.rust-std # targets.x86_64-pc-windows-gnu.latest.rust-std
# rust-analyzer # rust-analyzer
]; ];
my-crate = craneLib.buildPackage { img-proc = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.); src = craneLib.cleanCargoSource (craneLib.path ./.);
strictDeps = true; strictDeps = true;
doCheck = false;
buildInputs = CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
[
# Add additional build inputs here # fixes issues related to libring
] TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here #fixes issues related to openssl
pkgs.libiconv OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
depsBuildBuild = with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
]; ];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
}; };
in { in {
packages.default = my-crate; packages.default = img-proc;
apps.default = flake-utils.lib.mkApp { apps.default = flake-utils.lib.mkApp {
drv = my-crate; drv = img-proc;
}; };
devShells.default = pkgs.mkShell rec { devShells.default = pkgs.mkShell rec {
@ -70,7 +68,6 @@
rs-toolchain rs-toolchain
udev udev
alsa-lib alsa-lib
vulkan-loader
libxkbcommon libxkbcommon
wayland wayland
xorg.libX11 xorg.libX11
@ -81,7 +78,14 @@
clang clang
trunk trunk
binaryen binaryen
wgsl_analyzer.outputs.packages."x86_64-linux".default
libGL
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-tools-lunarg
vulkan-extension-layer
vulkan-validation-layers
]; ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;

View file

@ -1,5 +1,5 @@
use eframe::egui; use eframe::egui;
use nalgebra::{Matrix, SMatrix}; use nalgebra::SMatrix;
pub fn mat_editor<const R: usize, const C: usize>( pub fn mat_editor<const R: usize, const C: usize>(
ui: &mut egui::Ui, ui: &mut egui::Ui,

View file

@ -4,8 +4,8 @@ use std::{
}; };
use eframe::egui::{self, TextureOptions}; use eframe::egui::{self, TextureOptions};
use image::{DynamicImage, Pixel, Rgb, Rgb32FImage}; use image::{DynamicImage, Rgb, Rgb32FImage};
use nalgebra::{ComplexField, Const, Matrix, OMatrix, SMatrix, Vector3, Vector4}; use nalgebra::{Const, OMatrix, SMatrix, Vector3, Vector4};
use rayon::prelude::*; use rayon::prelude::*;
use image::EncodableLayout; use image::EncodableLayout;

View file

@ -1,14 +1,10 @@
use std::{num::NonZeroU64, path::PathBuf, sync::Arc, thread}; use std::{path::PathBuf, sync::Arc};
use eframe::{ use eframe::egui::{self, Vec2};
egui::{self, ImageSource},
egui_wgpu,
wgpu::{self, util::DeviceExt},
};
use egui_file_dialog::FileDialog; use egui_file_dialog::FileDialog;
use image::Rgb32FImage; use image::Rgb32FImage;
use img_processor::Processor; use img_processor::Processor;
use nalgebra::{Matrix3, SMatrix}; use nalgebra::SMatrix;
use oneshot::TryRecvError; use oneshot::TryRecvError;
mod components; mod components;
@ -20,30 +16,34 @@ pub struct App {
file_dialog: FileDialog, file_dialog: FileDialog,
new_file: Option<PathBuf>, new_file: Option<PathBuf>,
cur_img: Option<Arc<Rgb32FImage>>, cur_img: Option<Arc<Rgb32FImage>>,
preview_img: Option<Arc<Rgb32FImage>>,
space_available: (u32, u32),
proc: Processor, proc: Processor,
cur_rx: Option<oneshot::Receiver<(egui::TextureHandle, (f32, f32))>>, cur_rx: Option<oneshot::Receiver<(egui::TextureHandle, (f32, f32))>>,
cur_res: Option<egui::TextureHandle>, cur_res: Option<egui::TextureHandle>,
cur_size: Option<(f32, f32)>, cur_size: Option<(f32, f32)>,
} }
impl App { impl App {
pub fn new<'a>(cc: &'a eframe::CreationContext<'a>) -> Option<Self> { pub fn new<'a>(_cc: &'a eframe::CreationContext<'a>) -> Option<Self> {
Some(Self { Some(Self {
color_matrix: SMatrix::identity(), color_matrix: SMatrix::identity(),
pos_matrix: SMatrix::identity(), pos_matrix: SMatrix::identity(),
file_dialog: FileDialog::new(), file_dialog: FileDialog::new(),
new_file: None, new_file: None,
cur_img: None, cur_img: None,
preview_img: None,
proc: Processor::init(), proc: Processor::init(),
cur_rx: None, cur_rx: None,
cur_res: None, cur_res: None,
cur_size: None, cur_size: None,
space_available: (1, 1),
}) })
} }
} }
impl eframe::App for App { impl eframe::App for App {
fn update(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let mut mats_changed = false; // let mut mats_changed = false;
egui::SidePanel::right("sidebar").show(ctx, |ui| { egui::SidePanel::right("sidebar").show(ctx, |ui| {
if ui.button("Select Image").clicked() { if ui.button("Select Image").clicked() {
self.file_dialog.select_file() self.file_dialog.select_file()
@ -79,10 +79,10 @@ impl eframe::App for App {
let pos_mat_edited = let pos_mat_edited =
components::mat_editor(ui, &mut self.pos_matrix, "pos_matrix", true).changed(); components::mat_editor(ui, &mut self.pos_matrix, "pos_matrix", true).changed();
if dbg!(self.cur_img.is_some()) if self.cur_img.is_some()
&& dbg!((color_mat_edited || pos_mat_edited)) && (color_mat_edited || pos_mat_edited)
&& dbg!(self.cur_res.is_some()) && self.cur_res.is_some()
&& dbg!(self.cur_rx.is_none()) && self.cur_rx.is_none()
{ {
self.cur_rx = Some(self.proc.exec( self.cur_rx = Some(self.proc.exec(
self.cur_img.clone().unwrap(), self.cur_img.clone().unwrap(),
@ -95,7 +95,8 @@ impl eframe::App for App {
} }
}); });
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application"); let Vec2 { x, y } = ui.available_size();
self.space_available = (x as u32, y as u32);
if let Some(r) = &self.cur_rx { if let Some(r) = &self.cur_rx {
match r.try_recv() { match r.try_recv() {

View file

@ -8,6 +8,6 @@ fn main() -> Result<(), eframe::Error> {
renderer: eframe::Renderer::Wgpu, renderer: eframe::Renderer::Wgpu,
..Default::default() ..Default::default()
}, },
Box::new(|cc| Box::new(App::new(cc).unwrap())), Box::new(|cc| Ok(Box::new(App::new(cc).unwrap()))),
) )
} }