forked from nonsensical-dev/zenyx-engine
Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
ca715d1d67 | |||
ebef712ee0 | |||
c455aa5cd6 | |||
5e2cb15e13 | |||
a157812529 | |||
25068a7679 | |||
c86be3ca3d | |||
6884e80646 | |||
7fbec03ecc | |||
131989d9f3 |
8 changed files with 172 additions and 53 deletions
|
@ -15,9 +15,7 @@ jobs:
|
|||
|
||||
- name: 🚀 Setup & Run tests
|
||||
run: |
|
||||
nix-shell --run "
|
||||
git-lfs fetch
|
||||
git-lfs pull
|
||||
nix-shell -p cargo rustc --run "
|
||||
cargo test --release --all
|
||||
"
|
||||
|
||||
|
@ -31,41 +29,47 @@ jobs:
|
|||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- x86_64-pc-windows-msvc
|
||||
- x86_64-apple-darwin
|
||||
#- x86_64-apple-darwin
|
||||
- aarch64-unknown-linux-gnu
|
||||
- aarch64-pc-windows-msvc
|
||||
- aarch64-apple-darwin
|
||||
#- aarch64-apple-darwin
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
binary_name: zenyx-x86_64-linux
|
||||
ext: ""
|
||||
linker: /lib64/ld-linux-x86-64.so.2
|
||||
command: zigbuild
|
||||
args: --target x86_64-unknown-linux-gnu --release
|
||||
- target: aarch64-unknown-linux-gnu
|
||||
binary_name: zenyx-aarch64-linux
|
||||
ext: ""
|
||||
linker: /lib/ld-linux-aarch64.so.1
|
||||
command: zigbuild
|
||||
args: --target aarch64-unknown-linux-gnu --release
|
||||
- target: x86_64-pc-windows-msvc
|
||||
binary_name: zenyx-x86_64-windows
|
||||
ext: ".exe"
|
||||
linker: ""
|
||||
command: xwin build
|
||||
args: --target x86_64-pc-windows-msvc --release
|
||||
- target: aarch64-pc-windows-msvc
|
||||
binary_name: zenyx-aarch64-windows
|
||||
ext: ".exe"
|
||||
linker: ""
|
||||
command: xwin build
|
||||
args: --target aarch64-pc-windows-msvc --release
|
||||
- target: x86_64-apple-darwin
|
||||
binary_name: zenyx-x86_64-macos
|
||||
ext: ""
|
||||
command: zigbuild
|
||||
args: --target x86_64-apple-darwin --release
|
||||
- target: aarch64-apple-darwin
|
||||
binary_name: zenyx-aarch64-macos
|
||||
ext: ""
|
||||
command: zigbuild
|
||||
args: --target aarch64-apple-darwin --release
|
||||
#- target: x86_64-apple-darwin
|
||||
# binary_name: zenyx-x86_64-macos
|
||||
# ext: ""
|
||||
# linker: ""
|
||||
#command: zigbuild
|
||||
#args: --target x86_64-apple-darwin --release
|
||||
#target: aarch64-apple-darwin
|
||||
#binary_name: zenyx-aarch64-macos
|
||||
#ext: ""
|
||||
#linker: ""
|
||||
#command: zigbuild
|
||||
#args: --target aarch64-apple-darwin --release
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout source
|
||||
|
@ -74,8 +78,6 @@ jobs:
|
|||
- name: 🚀 Install Target & Build release binary
|
||||
run: |
|
||||
nix-shell --run "
|
||||
git-lfs fetch --all
|
||||
git-lfs pull
|
||||
cargo ${{ matrix.command }} ${{ matrix.args }}
|
||||
"
|
||||
|
||||
|
@ -84,10 +86,19 @@ jobs:
|
|||
mkdir -p artifacts
|
||||
cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}${{ matrix.ext }}
|
||||
|
||||
- name: 🛠️ Patchelf
|
||||
if: ${{
|
||||
matrix.target == 'x86_64-unknown-linux-gnu' ||
|
||||
matrix.target == 'aarch64-unknown-linux-gnu'
|
||||
}}
|
||||
run: |
|
||||
nix run --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#patchelf -- --set-interpreter ${{ matrix.linker }} \
|
||||
artifacts/${{ matrix.binary_name }}${{ matrix.ext }}
|
||||
|
||||
- name: ⬆️ Upload artifact
|
||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.binary_name }}${{ matrix.ext }}.zip
|
||||
name: ${{ matrix.binary_name }}.zip
|
||||
path: artifacts/${{ matrix.binary_name }}${{ matrix.ext }}
|
||||
compression-level: 9
|
||||
if-no-files-found: error
|
||||
if-no-files-found: error
|
||||
|
|
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -384,6 +384,12 @@ dependencies = [
|
|||
"piper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-print"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a2128d00b7061b82b72844a351e80acd29e05afc60e9261e2ac90dca9ecc2ac"
|
||||
|
||||
[[package]]
|
||||
name = "built"
|
||||
version = "0.7.7"
|
||||
|
@ -1359,6 +1365,7 @@ dependencies = [
|
|||
"num-traits",
|
||||
"once_cell",
|
||||
"petgraph",
|
||||
"pp-rs",
|
||||
"rustc-hash",
|
||||
"spirv",
|
||||
"strum",
|
||||
|
@ -1944,6 +1951,15 @@ version = "1.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
||||
|
||||
[[package]]
|
||||
name = "pp-rs"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb458bb7f6e250e6eb79d5026badc10a3ebb8f9a15d1fff0f13d17c71f4d6dee"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
|
@ -2775,6 +2791,12 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "v_frame"
|
||||
version = "0.3.8"
|
||||
|
@ -3686,9 +3708,11 @@ name = "zenyx"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"build-print",
|
||||
"bytemuck",
|
||||
"cgmath",
|
||||
"image",
|
||||
"naga",
|
||||
"smol",
|
||||
"terminator",
|
||||
"thiserror 2.0.12",
|
||||
|
|
|
@ -58,3 +58,9 @@ allocator-api2 = "0.2.21"
|
|||
|
||||
[target.aarch64-linux-android.dependencies]
|
||||
winit = { version = "0.30.9", features = ["android-native-activity"] }
|
||||
|
||||
[build-dependencies]
|
||||
build-print = "0.1.1"
|
||||
bytemuck = "1.22.0"
|
||||
naga = { version = "25.0.1", features = ["glsl-in", "spv-out"] }
|
||||
thiserror = "2.0.12"
|
||||
|
|
|
@ -94,7 +94,7 @@ Distribute, and use Zenyx for any purpose you wish.
|
|||
| Windows | Primary | ✅ | |
|
||||
| Linux/*BSD | Primary | ✅ | |
|
||||
| macOS | Secondary | ⚠️ | The current main set of maintainers do not own any native MacOS devices to perform tests with. |
|
||||
| Android | Help wanted | ❓ | |
|
||||
| Android | Secondary | ✅ | |
|
||||
| iOS | Not planned | ❓ | |
|
||||
| Web | TBD | ❓ | |
|
||||
| Consoles | Not planned | ⛔ | Consoles require specific dev kits,proprietary licenses, and substantial fees that we (Nonsensical-dev,the Zenyx maintainers,and the open source contributors) currently do not have the capacity for. This may change in the future but most likely will not be soon. |
|
||||
|
|
120
build.rs
120
build.rs
|
@ -1,26 +1,100 @@
|
|||
use std::{env, process::Command};
|
||||
use build_print::{info, warn};
|
||||
use naga::{
|
||||
ShaderStage,
|
||||
back::spv::{self, WriterFlags},
|
||||
front::glsl::{self, Options as GlslOptions, ParseErrors},
|
||||
valid::{ValidationError, ValidationFlags, Validator},
|
||||
};
|
||||
use std::{
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
fn main() {
|
||||
println!("cargo::rerun-if-changed=shaders");
|
||||
let outdir = env::var("OUT_DIR").unwrap();
|
||||
let vert = Command::new("glslc")
|
||||
.args(["shaders/shader.vert", "-o", &format!("{outdir}/vert.spv")])
|
||||
.output()
|
||||
.expect("Failed to execute 'glslc'");
|
||||
let frag = Command::new("glslc")
|
||||
.args(["shaders/shader.frag", "-o", &format!("{outdir}/frag.spv")])
|
||||
.output()
|
||||
.expect("Failed to execute 'glslc'");
|
||||
if !vert.status.success() {
|
||||
panic!(
|
||||
"Failed to compile vertex shader: {}",
|
||||
String::from_utf8(vert.stderr).unwrap()
|
||||
)
|
||||
}
|
||||
if !frag.status.success() {
|
||||
panic!(
|
||||
"Failed to compile fragment shader: {}",
|
||||
String::from_utf8(frag.stderr).unwrap()
|
||||
)
|
||||
#[derive(Debug, Error)]
|
||||
pub enum BuildError {
|
||||
#[error("I/O error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
#[error("environment variable error: {0}")]
|
||||
EnvVar(#[from] env::VarError),
|
||||
#[error("unsupported shader extension: {0}")]
|
||||
UnsupportedExt(String),
|
||||
#[error("GLSL parse errors in `{0}`:\n{1}")]
|
||||
ParseErrors(String, ParseErrors),
|
||||
#[error("validation errors in `{0}`: {1}")]
|
||||
ValidateErrors(String, ValidationError),
|
||||
#[error("SPIR-V write error for `{0}`: {1}")]
|
||||
Spv(String, spv::Error),
|
||||
}
|
||||
|
||||
impl From<(String, ParseErrors)> for BuildError {
|
||||
fn from((s, e): (String, ParseErrors)) -> Self {
|
||||
BuildError::ParseErrors(s, e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(String, ValidationError)> for BuildError {
|
||||
fn from((s, e): (String, ValidationError)) -> Self {
|
||||
BuildError::ValidateErrors(s, e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(String, spv::Error)> for BuildError {
|
||||
fn from((s, e): (String, spv::Error)) -> Self {
|
||||
BuildError::Spv(s, e)
|
||||
}
|
||||
}
|
||||
|
||||
fn compile_shader(path: &Path, out_dir: &Path) -> Result<(), BuildError> {
|
||||
let ext = path
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.map(str::to_string)
|
||||
.ok_or_else(|| BuildError::UnsupportedExt(path.display().to_string()))?;
|
||||
let stage = match ext.as_str() {
|
||||
"vert" => ShaderStage::Vertex,
|
||||
"frag" => ShaderStage::Fragment,
|
||||
"comp" => ShaderStage::Compute,
|
||||
_ => return Err(BuildError::UnsupportedExt(ext)),
|
||||
};
|
||||
let src = fs::read_to_string(path)?;
|
||||
|
||||
let module = glsl::Frontend::default()
|
||||
.parse(&GlslOptions::from(stage), &src)
|
||||
.map_err(|e| (ext.clone(), e))?;
|
||||
let info = Validator::new(ValidationFlags::all(), Default::default())
|
||||
.validate(&module)
|
||||
.map_err(|e| (ext.clone(), e.into_inner()))?;
|
||||
let mut writer = spv::Writer::new(&spv::Options {
|
||||
flags: WriterFlags::empty(),
|
||||
..Default::default()
|
||||
})
|
||||
.map_err(|e| (ext.clone(), e))?;
|
||||
let mut spirv = Vec::new();
|
||||
writer
|
||||
.write(&module, &info, None, &None, &mut spirv)
|
||||
.map_err(|e| (ext.clone(), e))?;
|
||||
let out_path = out_dir.join(format!("{}.spv", ext));
|
||||
fs::write(&out_path, bytemuck::cast_slice(&spirv))?;
|
||||
info!("Compiled {} → {}", path.display(), out_path.display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), BuildError> {
|
||||
println!("cargo:rerun-if-changed=shaders");
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
||||
for entry in fs::read_dir("shaders")? {
|
||||
let path = entry?.path();
|
||||
if !path.is_file() {
|
||||
continue;
|
||||
}
|
||||
if let Err(e) = compile_shader(&path, &out_dir) {
|
||||
if matches!(e, BuildError::UnsupportedExt(_)) {
|
||||
warn!("{}", e);
|
||||
continue;
|
||||
}
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
stdenv,
|
||||
targetPackages ? pkgs,
|
||||
}: let
|
||||
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
|
||||
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
|
||||
src = nix-gitignore.gitignoreSource [] ./.;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
|
@ -61,7 +61,7 @@ rustPlatform.buildRustPackage rec {
|
|||
--set LD_LIBRARY_PATH ${lib.makeLibraryPath buildInputs}
|
||||
'' + lib.optionalString stdenv.targetPlatform.isWindows ''
|
||||
mkdir -p $out/bin
|
||||
cp ${targetPackages.vulkan-loader}/bin/vulkan-1.dll $out/bin/
|
||||
cp ${pkgs.vulkan-loader}/bin/vulkan-1.dll $out/bin/
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
@ -72,4 +72,4 @@ rustPlatform.buildRustPackage rec {
|
|||
platforms = lib.platforms.all;
|
||||
mainProgram = "zenyx";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
15
flake.nix
15
flake.nix
|
@ -31,7 +31,7 @@
|
|||
(import rust-overlay)
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
vulkan-tools
|
||||
vulkan-tools-lunarg
|
||||
|
@ -41,6 +41,7 @@
|
|||
cargo-cross
|
||||
cargo-xwin
|
||||
cargo-wizard
|
||||
cargo-zigbuild
|
||||
wine64
|
||||
pkg-config
|
||||
];
|
||||
|
@ -60,7 +61,7 @@
|
|||
packages = {
|
||||
inherit (pkgs) zenyx;
|
||||
default = pkgs.zenyx;
|
||||
windows = let
|
||||
windows = let
|
||||
pkgsCross = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
crossSystem = nixpkgs.lib.systems.examples.mingwW64;
|
||||
|
@ -73,8 +74,14 @@
|
|||
nativeBuildInputs = with pkgs; [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src" "cargo" "rustfmt" "clippy"];
|
||||
targets = [ "x86_64-pc-windows-msvc" "x86_64-unknown-linux-gnu" ];
|
||||
|
||||
targets = [
|
||||
"x86_64-pc-windows-msvc"
|
||||
"x86_64-unknown-linux-gnu"
|
||||
"x86_64-apple-darwin"
|
||||
"aarch64-pc-windows-msvc"
|
||||
"aarch64-unknown-linux-gnu"
|
||||
"aarch64-apple-darwin"
|
||||
];
|
||||
})
|
||||
pkg-config
|
||||
] ++ nativeBuildInputs;
|
||||
|
|
|
@ -141,9 +141,6 @@ struct WgpuState {
|
|||
instance: wgpu::Instance,
|
||||
}
|
||||
|
||||
static _ICON: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/Badge.png"));
|
||||
static _PUMPKIN: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/Pumpkin.obj"));
|
||||
|
||||
impl WgpuState {
|
||||
fn new() -> Self {
|
||||
let backends = Backends::PRIMARY;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue