Skip to content

New shadertoys features #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# From: https://docs.github.com/en/github/getting-started-with-github/configuring-git-to-handle-line-endings
# Set the default behavior for line endings.
* text=auto eol=lf

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.ttf binary
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
rustc-ice-*.txt
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"rust-analyzer.cargo.targetDir": true,
//"rust-analyzer.check.command": "clippy",
}
16 changes: 4 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 73 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@ use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]

[dependencies]
shared = { path = "shared" }
shadertoys-shaders = { path = "shaders" }
futures = { version = "0.3", default-features = false, features = [
"std",
"executor"
] }
wgpu = { version = "25.0.0", features = [
"spirv",
"vulkan-portability"
"executor",
] }
wgpu = { version = "25.0.0", features = ["spirv", "vulkan-portability"] }
winit = { git = "https://github.com/rust-windowing/winit.git", rev = "cdbdd974fbf79b82b3fb1a4bc84ed717312a3bd2" }
bytemuck = "1.20.0"
bytemuck = "1.23.0"
env_logger = "0.11.6"
ouroboros = "0.18.5"

[build-dependencies]
spirv-builder.workspace = true

[workspace]
members = ["shaders", "shared"]
members = ["shaders"]

[workspace.dependencies]
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "0b37696e9f5edde8fa0c1363a88e6c8cb8e6ff68", default-features = false }
Expand All @@ -53,7 +50,74 @@ opt-level = 3
[profile.release.package."shadertoys-shaders"]
opt-level = 0

[workspace.lints.clippy]
# disabled because shader code does this often
cast_precision_loss = "allow"
cast_possible_truncation = "allow"
excessive_precision = "allow"
missing_const_for_fn = "allow"
many_single_char_names = "allow"
similar_names = "allow"
too_many_arguments = "allow"
suboptimal_flops = "allow"
too_many_lines = "allow"
cognitive_complexity = "allow"
# disabled because of rust gpu limitatoins
manual_range_contains = "allow" # Rust gpu does not like the core range checks
needless_range_loop = "allow" # Rust gpu does not like iterators very much
manual_swap = "allow" # Rust gpu does not like the core swap function
# temporarily disabled rules
inline_always = "allow" # need some hard numbers for this
unreadable_literal = "allow" # Maybe fix this?
useless_let_if_seq = "allow" # Maybe fix this?
used_underscore_items = "allow" # Maybe fix this?
no_effect_underscore_binding = "allow" # Maybe fix this?

# standard rules for idiomatic Rust code
let_and_return = "allow"
needless_lifetimes = "allow"
option_if_let_else = "allow"
# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"
missing_panics_doc = "allow"
doc-markdown = "allow"

nursery = { priority = -1, level = "warn" }
pedantic = { priority = -1, level = "warn" }
doc_markdown = "warn"
manual_let_else = "warn"
match_same_arms = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
semicolon_if_nothing_returned = "warn"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"

std_instead_of_core = "warn"
std_instead_of_alloc = "warn"
alloc_instead_of_core = "warn"

[workspace.lints.rust]
nonstandard-style = "warn"
future-incompatible = "warn"
missing_docs = "allow" # TODO: warn
unused = { priority = -1, level = "warn" }
rust_2018_idioms = { priority = -1, level = "warn" }
rust-2024-compatibility = "warn"
array-into-iter = "warn"
bare-trait-objects = "warn"
ellipsis-inclusive-range-patterns = "warn"
non-fmt-panics = "warn"
explicit-outlives-requirements = "warn"
unused-extern-crates = "warn"
unsafe_code = "allow" # TODO: forbid
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"
unexpected_cfgs = { level = "allow", check-cfg = [
'cfg(target_arch, values("spirv"))'
'cfg(target_arch, values("spirv"))',
] }
12 changes: 6 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use spirv_builder::{MetadataPrintout, SpirvBuilder};
use std::error::Error;

fn build_shader(path_to_crate: &str) -> Result<(), Box<dyn Error>> {
let builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.2")
.print_metadata(MetadataPrintout::Full);
let builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.2")
.print_metadata(MetadataPrintout::Full);

let _result = builder.build()?;
Ok(())
let _result = builder.build()?;
Ok(())
}

fn main() -> Result<(), Box<dyn Error>> {
build_shader("shaders")?;
Ok(())
build_shader("shaders")?;
Ok(())
}
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
check-private-items = true
13 changes: 13 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
match_block_trailing_comma = true
tab_spaces = 2
condense_wildcard_suffixes = false
newline_style = "Unix"

# The options below are unstable
unstable_features = true
imports_granularity = "Crate"
normalize_comments = false # Often doesn't do what you want

# these options seem poorly implemented and cause churn, so, try to avoid them
# wrap_comments = true
# comment_width = 100
2 changes: 1 addition & 1 deletion shaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["dylib"]

[dependencies]
spirv-std.workspace = true
shared = { path = "../shared" }
bytemuck = { version = "1.23.0", features = ["derive"] }

[lints]
workspace = true
Loading