Hacked to work with bevy 0.8, Nix flake
This commit is contained in:
parent
b94b95f7c3
commit
6ced0d32cd
|
@ -472,6 +472,16 @@ dependencies = [
|
||||||
"ndk-glue 0.5.2",
|
"ndk-glue 0.5.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_julia"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bevy",
|
||||||
|
"bevy_better_exit",
|
||||||
|
"csv",
|
||||||
|
"palette",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_log"
|
name = "bevy_log"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
@ -1848,16 +1858,6 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "julia"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"bevy",
|
|
||||||
"bevy_better_exit",
|
|
||||||
"csv",
|
|
||||||
"palette",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "khronos-egl"
|
name = "khronos-egl"
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "julia"
|
name = "bevy_julia"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
[[group(0), binding(0)]]
|
@group(0) @binding(0)
|
||||||
var input: texture_storage_2d<r32float, read>;
|
var input: texture_storage_2d<r32float, read>;
|
||||||
|
|
||||||
[[group(0), binding(1)]]
|
@group(0) @binding(1)
|
||||||
var output: texture_storage_2d<rgba8unorm, write>;
|
var output: texture_storage_2d<rgba8unorm, write>;
|
||||||
|
|
||||||
[[group(0), binding(2)]]
|
@group(0) @binding(2)
|
||||||
var mapping: texture_storage_1d<rgba8unorm, read>;
|
var mapping: texture_storage_1d<rgba8unorm, read>;
|
||||||
|
|
||||||
[[stage(compute), workgroup_size(8, 8, 1)]]
|
@compute @workgroup_size(8, 8, 1)
|
||||||
fn colormap([[builtin(global_invocation_id)]] invocation_id: vec3<u32>, [[builtin(num_workgroups)]] num_workgroups: vec3<u32>) {
|
fn colormap(@builtin(global_invocation_id) invocation_id: vec3<u32>, @builtin(num_workgroups) num_workgroups: vec3<u32>) {
|
||||||
let mapping_size = f32(textureDimensions(mapping));
|
let mapping_size = f32(textureDimensions(mapping));
|
||||||
let pos = vec2<i32>(i32(invocation_id.x), i32(invocation_id.y));
|
let pos = vec2<i32>(i32(invocation_id.x), i32(invocation_id.y));
|
||||||
let val = textureLoad(input, pos).r;
|
let val = textureLoad(input, pos).r;
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1656928814,
|
||||||
|
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1662220400,
|
||||||
|
"narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663264531,
|
||||||
|
"narHash": "sha256-2ncO5chPXlTxaebDlhx7MhL0gOEIWxzSyfsl0r0hxQk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "454887a35de6317a30be284e8adc2d2f6d8a07c4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663364893,
|
||||||
|
"narHash": "sha256-Ttz4WrohHKbWFK7ayjEdbo3CTQphpttcHIW9EpghT8k=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "5498855d03a71a4805f9d56265989a43e8a63e07",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659102345,
|
||||||
|
"narHash": "sha256-Vbzlz254EMZvn28BhpN8JOi5EuKqnHZ3ujFYgFcSGvk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "11b60e4f80d87794a2a4a8a256391b37c59a1ea7",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"naersk": "naersk",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs_3"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663297375,
|
||||||
|
"narHash": "sha256-7pjd2x9fSXXynIzp9XiXjbYys7sR6MKCot/jfGL7dgE=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "0678b6187a153eb0baa9688335b002fe14ba6712",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
99
flake.nix
99
flake.nix
|
@ -7,50 +7,61 @@
|
||||||
|
|
||||||
outputs = { self, naersk, nixpkgs, rust-overlay }:
|
outputs = { self, naersk, nixpkgs, rust-overlay }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
systems = [
|
||||||
|
"aarch64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit overlays system;
|
|
||||||
};
|
|
||||||
rust-bin = pkgs.rust-bin.rust-nightly;
|
|
||||||
naersk-lib = naersk.lib.${system};#.override {
|
|
||||||
#cargo = rust-bin;
|
|
||||||
#rust = rust-bin;
|
|
||||||
# };
|
|
||||||
build-deps = with pkgs; [
|
|
||||||
lld
|
|
||||||
clang
|
|
||||||
pkg-config
|
|
||||||
makeWrapper
|
|
||||||
];
|
|
||||||
runtime-deps = with pkgs; [
|
|
||||||
alsa-lib
|
|
||||||
udev
|
|
||||||
xorg.libX11
|
|
||||||
xorg.libXcursor
|
|
||||||
xorg.libXrandr
|
|
||||||
xorg.libXi
|
|
||||||
xorg.libxcb
|
|
||||||
libGL
|
|
||||||
vulkan-loader
|
|
||||||
vulkan-headers
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
{
|
builtins.foldl'
|
||||||
packages.${system}.bevy_julia = naersk-lib.buildPackage {
|
(outputs: system:
|
||||||
pname = "bevy_julia";
|
let
|
||||||
root = ./.;
|
pkgs = import nixpkgs {
|
||||||
buildInputs = runtime-deps;
|
inherit overlays system;
|
||||||
nativeBuildInputs = build-deps;
|
};
|
||||||
overrideMain = attrs: {
|
rust-bin = pkgs.rust-bin.rust-nightly;
|
||||||
fixupPhase = ''
|
naersk-lib = naersk.lib.${system};#.override {
|
||||||
wrapProgram $out/bin/bevy_julia \
|
#cargo = rust-bin;
|
||||||
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtime-deps} \
|
#rust = rust-bin;
|
||||||
--set CARGO_MANIFEST_DIR $out/share/bevy_julia
|
# };
|
||||||
mkdir -p $out/share/bevy_julia
|
build-deps = with pkgs; [
|
||||||
cp -a assets $out/share/bevy_julia'';
|
lld
|
||||||
};
|
clang
|
||||||
};
|
pkg-config
|
||||||
defaultPackage.${system} = self.packages.${system}.bevy_julia;
|
makeWrapper
|
||||||
};
|
];
|
||||||
|
runtime-deps = with pkgs; [
|
||||||
|
alsa-lib
|
||||||
|
udev
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXi
|
||||||
|
xorg.libxcb
|
||||||
|
libGL
|
||||||
|
vulkan-loader
|
||||||
|
vulkan-headers
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.${system}.bevy_julia = naersk-lib.buildPackage {
|
||||||
|
pname = "bevy_julia";
|
||||||
|
root = ./.;
|
||||||
|
buildInputs = runtime-deps;
|
||||||
|
nativeBuildInputs = build-deps;
|
||||||
|
overrideMain = attrs: {
|
||||||
|
fixupPhase = ''
|
||||||
|
wrapProgram $out/bin/bevy_julia \
|
||||||
|
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtime-deps} \
|
||||||
|
--set CARGO_MANIFEST_DIR $out/share/bevy_julia
|
||||||
|
mkdir -p $out/share/bevy_julia
|
||||||
|
cp -a assets $out/share/bevy_julia'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultPackage.${system} = self.packages.${system}.bevy_julia;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
systems;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy::{
|
||||||
render_graph::{self, RenderGraph},
|
render_graph::{self, RenderGraph},
|
||||||
render_resource::*,
|
render_resource::*,
|
||||||
renderer::{RenderContext, RenderDevice},
|
renderer::{RenderContext, RenderDevice},
|
||||||
RenderApp, RenderStage,
|
Extract, RenderApp, RenderStage,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ impl Plugin for ColormapPlugin {
|
||||||
|
|
||||||
let mut render_graph = render_app.world.get_resource_mut::<RenderGraph>().unwrap();
|
let mut render_graph = render_app.world.get_resource_mut::<RenderGraph>().unwrap();
|
||||||
render_graph.add_node("colormap", ColormapDispatch);
|
render_graph.add_node("colormap", ColormapDispatch);
|
||||||
render_graph.add_node_edge("colormap", MAIN_PASS).unwrap();
|
render_graph
|
||||||
|
.add_node_edge("colormap", bevy::render::main_graph::node::CAMERA_DRIVER)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
render_graph
|
render_graph
|
||||||
.add_node_edge(self.prev_node, "colormap")
|
.add_node_edge(self.prev_node, "colormap")
|
||||||
|
@ -157,9 +159,9 @@ impl render_graph::Node for ColormapDispatch {
|
||||||
|
|
||||||
fn extract_colormap(
|
fn extract_colormap(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
input: Res<ColormapInputImage>,
|
input: Extract<Res<ColormapInputImage>>,
|
||||||
output: Res<ColormapOutputImage>,
|
output: Extract<Res<ColormapOutputImage>>,
|
||||||
mapping: Res<ColormapMappingImage>,
|
mapping: Extract<Res<ColormapMappingImage>>,
|
||||||
) {
|
) {
|
||||||
commands.insert_resource(ColormapInputImage(input.0.clone()));
|
commands.insert_resource(ColormapInputImage(input.0.clone()));
|
||||||
commands.insert_resource(ColormapOutputImage(output.0.clone()));
|
commands.insert_resource(ColormapOutputImage(output.0.clone()));
|
||||||
|
|
12
src/julia.rs
12
src/julia.rs
|
@ -11,7 +11,7 @@ use bevy::{
|
||||||
render_resource::*,
|
render_resource::*,
|
||||||
renderer::{RenderContext, RenderDevice},
|
renderer::{RenderContext, RenderDevice},
|
||||||
texture::GpuImage,
|
texture::GpuImage,
|
||||||
RenderApp, RenderStage,
|
Extract, RenderApp, RenderStage,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,9 @@ impl Plugin for JuliaPlugin {
|
||||||
|
|
||||||
let mut render_graph = render_app.world.get_resource_mut::<RenderGraph>().unwrap();
|
let mut render_graph = render_app.world.get_resource_mut::<RenderGraph>().unwrap();
|
||||||
render_graph.add_node("julia", JuliaDispatch);
|
render_graph.add_node("julia", JuliaDispatch);
|
||||||
render_graph.add_node_edge("julia", MAIN_PASS).unwrap();
|
render_graph
|
||||||
|
.add_node_edge("julia", bevy::render::main_graph::node::CAMERA_DRIVER)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +119,9 @@ struct JuliaBindGroup(BindGroup);
|
||||||
|
|
||||||
fn extract_julia(
|
fn extract_julia(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
data: Res<Handle<JuliaData>>,
|
data: Extract<Res<Handle<JuliaData>>>,
|
||||||
params: Res<Assets<JuliaData>>,
|
params: Extract<Res<Assets<JuliaData>>>,
|
||||||
images: Res<Assets<Image>>,
|
images: Extract<Res<Assets<Image>>>,
|
||||||
) {
|
) {
|
||||||
commands.insert_resource(data.clone());
|
commands.insert_resource(data.clone());
|
||||||
let data = params.get(&data).unwrap();
|
let data = params.get(&data).unwrap();
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -2,13 +2,17 @@ mod colormap;
|
||||||
mod colorramp;
|
mod colorramp;
|
||||||
mod julia;
|
mod julia;
|
||||||
|
|
||||||
use std::{ops::Add, path::Path};
|
use std::{
|
||||||
|
ops::Add,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
use colormap::{ColormapInputImage, ColormapMappingImage, ColormapOutputImage, ColormapPlugin};
|
use colormap::{ColormapInputImage, ColormapMappingImage, ColormapOutputImage, ColormapPlugin};
|
||||||
use colorramp::ColorRamp;
|
use colorramp::ColorRamp;
|
||||||
use julia::{JuliaData, JuliaPlugin};
|
use julia::{JuliaData, JuliaPlugin};
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
|
asset::FileAssetIo,
|
||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::render_resource::*,
|
render::render_resource::*,
|
||||||
|
@ -137,10 +141,14 @@ fn setup(
|
||||||
commands.insert_resource(data);
|
commands.insert_resource(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_path(mut commands: Commands) {
|
fn load_path(mut commands: Commands, server: Res<AssetServer>) {
|
||||||
|
let mut path = PathBuf::new();
|
||||||
|
path.push(FileAssetIo::get_base_path());
|
||||||
|
path.push("assets");
|
||||||
|
path.push("path.csv");
|
||||||
let mut reader = csv::ReaderBuilder::new()
|
let mut reader = csv::ReaderBuilder::new()
|
||||||
.has_headers(false)
|
.has_headers(false)
|
||||||
.from_reader(File::open("assets/path.csv").unwrap());
|
.from_reader(File::open(path).unwrap());
|
||||||
|
|
||||||
let mut points: Vec<Vec2> = Vec::new();
|
let mut points: Vec<Vec2> = Vec::new();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue