Skip to content

Commit ad009a1

Browse files
committed
Add indirect draw rust shaders
1 parent c346df9 commit ad009a1

15 files changed

Lines changed: 233 additions & 8 deletions

File tree

shaders/rust/Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shaders/rust/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ members = [
5555
"pbribl/prefilterenvmap",
5656
"pbribl/skybox",
5757
"pbribl/filtercube",
58+
"indirectdraw/indirectdraw",
59+
"indirectdraw/ground",
60+
"indirectdraw/skysphere",
5861
]
5962

6063
[workspace.dependencies]

shaders/rust/compileshaders.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def compile_shader(shader_dir):
6868
print(f" Created {final_path.name} (entry point: {entry_point})")
6969

7070
# Special case: move to parent directory for nested shader structures
71-
if shader_dir.parent.name in ["base", "descriptorsets", "dynamicuniformbuffer", "multisampling", "pipelines", "specializationconstants", "computeshader", "texturearray", "screenshot", "negativeviewportheight", "stencilbuffer", "parallaxmapping", "computecloth", "ssao", "shadowmapping", "deferred", "computenbody", "bloom", "hdr", "radialblur", "pbribl"]:
71+
if shader_dir.parent.name in ["base", "descriptorsets", "dynamicuniformbuffer", "multisampling", "pipelines", "specializationconstants", "computeshader", "texturearray", "screenshot", "negativeviewportheight", "stencilbuffer", "parallaxmapping", "computecloth", "ssao", "shadowmapping", "deferred", "computenbody", "bloom", "hdr", "radialblur", "pbribl", "indirectdraw"]:
7272
parent_dir = shader_dir.parent
7373
parent_final_path = parent_dir / f"{shader_name}.{shader_type}.spv"
7474
shutil.move(str(final_path), str(parent_final_path))
@@ -125,12 +125,6 @@ def main():
125125

126126
print(f"Found {len(shader_dirs)} shader crates to build")
127127

128-
# Clean old .spv files
129-
print("\nCleaning old files...")
130-
for spv_file in rust_gpu_dir.rglob("*.spv"):
131-
if "target" not in str(spv_file):
132-
spv_file.unlink()
133-
134128
# Compile each shader crate
135129
total_success = 0
136130
total_failed = 0
@@ -150,4 +144,4 @@ def main():
150144
sys.exit(1)
151145

152146
if __name__ == "__main__":
153-
main()
147+
main()
464 Bytes
Binary file not shown.
4.39 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "ground"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[lib]
8+
crate-type = ["dylib"]
9+
10+
[dependencies]
11+
spirv-std = { workspace = true }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![cfg_attr(target_arch = "spirv", no_std)]
2+
3+
use spirv_std::spirv;
4+
use spirv_std::glam::{Vec2, Vec3, Vec4, Mat4};
5+
6+
#[repr(C)]
7+
pub struct UBO {
8+
projection: Mat4,
9+
modelview: Mat4,
10+
}
11+
12+
#[spirv(vertex)]
13+
pub fn main_vs(
14+
in_pos: Vec4,
15+
_in_normal: Vec3,
16+
in_uv: Vec2,
17+
_in_color: Vec3,
18+
#[spirv(uniform, descriptor_set = 0, binding = 0)] ubo: &UBO,
19+
#[spirv(position)] out_position: &mut Vec4,
20+
out_uv: &mut Vec2,
21+
) {
22+
*out_uv = in_uv * 32.0;
23+
*out_position = ubo.projection * ubo.modelview * Vec4::new(in_pos.x, in_pos.y, in_pos.z, 1.0);
24+
}
25+
26+
#[spirv(fragment)]
27+
pub fn main_fs(
28+
in_uv: Vec2,
29+
#[spirv(descriptor_set = 0, binding = 2)] sampler_color: &spirv_std::image::SampledImage<spirv_std::image::Image2d>,
30+
out_color: &mut Vec4,
31+
) {
32+
*out_color = sampler_color.sample(in_uv);
33+
}
1.75 KB
Binary file not shown.
6.58 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "indirectdraw"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
crate-type = ["dylib"]
8+
9+
[dependencies]
10+
spirv-std = { workspace = true }

0 commit comments

Comments
 (0)