Skip to content
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

Release graphics-0.3, render-0.2 #58

Merged
merged 2 commits into from
Nov 18, 2023
Merged
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ readme = "docs/README.md"
[features]

[dependencies]
blade-asset = { version = "0.1.0", path = "blade-asset" }
blade-macros = { version = "0.2.0", path = "blade-macros" }
blade-graphics = { version = "0.2.0", path = "blade-graphics" }
blade-render = { version = "0.1.0", path = "blade-render" }
blade-asset = { version = "0.2.0", path = "blade-asset" }
blade-egui = { version = "0.2.0", path = "blade-egui" }
blade-macros = { version = "0.2.1", path = "blade-macros" }
blade-graphics = { version = "0.3.0", path = "blade-graphics" }
blade-render = { version = "0.2.0", path = "blade-render" }

[dev-dependencies]
blade-egui = { version = "0.1.0", path = "blade-egui" }
bytemuck = { workspace = true }
choir = { workspace = true }
egui = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion blade-asset/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blade-asset"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "Asset manager for Blade"
keywords = ["asset"]
Expand Down
4 changes: 2 additions & 2 deletions blade-egui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blade-egui"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "egui integration for Blade"
keywords = ["graphics"]
Expand All @@ -10,7 +10,7 @@ repository = "https://github.com/kvark/blade"
[lib]

[dependencies]
blade-graphics = { version = "0.2", path = "../blade-graphics"}
blade-graphics = { version = "0.3", path = "../blade-graphics"}
blade-macros = { version = "0.2", path = "../blade-macros"}
bytemuck = { workspace = true }
egui = { workspace = true, features = ["bytemuck"] }
Expand Down
2 changes: 1 addition & 1 deletion blade-graphics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blade-graphics"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
description = "Graphics abstraction for Blade"
keywords = ["graphics"]
Expand Down
6 changes: 3 additions & 3 deletions blade-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blade-macros"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "Macros helpers for Blade users"
keywords = ["proc-macro"]
Expand All @@ -16,6 +16,6 @@ proc-macro2 = "1"
quote = "1.0"

[dev-dependencies]
blade-graphics = { version = "0.2", path = "../blade-graphics" }
blade-asset = { version = "0.1", path = "../blade-asset" }
blade-graphics = { version = "0.3", path = "../blade-graphics" }
blade-asset = { version = "0.2", path = "../blade-asset" }
bytemuck = { workspace = true }
22 changes: 10 additions & 12 deletions blade-render/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blade-render"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "Renderer built on Blade"
keywords = ["graphics", "engine"]
Expand All @@ -11,14 +11,14 @@ repository = "https://github.com/kvark/blade"

[features]
default = ["asset"]
asset = ["gltf" , "base64", "exr", "mikktspace", "slab", "texpresso", "zune-core", "zune-jpeg", "zune-png", "zune-imageprocs"]
asset = ["gltf" , "base64", "exr", "mikktspace", "slab", "texpresso", "zune-core", "zune-jpeg", "zune-png", "zune-hdr", "zune-imageprocs"]

[dependencies]
base64 = { workspace = true, optional = true }
bitflags = { workspace = true }
blade-graphics = { version = "0.2", path = "../blade-graphics" }
blade-asset = { version = "0.1", path = "../blade-asset" }
blade-macros = { version = "0.2", path = "../blade-macros" }
blade-graphics = { version = "0.3", path = "../blade-graphics" }
blade-asset = { version = "0.2", path = "../blade-asset" }
blade-macros = { version = "0.2.1", path = "../blade-macros" }
bytemuck = { workspace = true }
choir = { workspace = true }
exr = { version = "1.6", optional = true }
Expand All @@ -31,10 +31,8 @@ profiling = { workspace = true }
slab = { workspace = true, optional = true }
strum = { workspace = true }
texpresso = { version = "2.0", optional = true }
#zune-core = { version = "0.2", optional = true }
#zune-jpeg = { version = "0.3", optional = true }
#zune-png = { version = "0.2", optional = true }
zune-core = { git = "https://github.com/etemesi254/zune-image", optional = true }
zune-jpeg = { git = "https://github.com/etemesi254/zune-image", optional = true }
zune-png = { git = "https://github.com/etemesi254/zune-image", optional = true }
zune-imageprocs = { git = "https://github.com/etemesi254/zune-image", optional = true }
zune-core = { version = "0.4", optional = true }
zune-jpeg = { version = "0.4", optional = true }
zune-png = { version = "0.4", optional = true }
zune-hdr = { version = "0.4", optional = true }
zune-imageprocs = { version = "0.4", optional = true }
69 changes: 52 additions & 17 deletions blade-render/src/texture/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
fmt, io, mem, ptr, slice, str,

Check warning on line 2 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused imports: `io`, `mem`, `slice`

Check warning on line 2 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused imports: `io`, `mem`, `slice`

Check warning on line 2 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused imports: `io`, `mem`, `slice`
sync::{Arc, Mutex},
};

Expand Down Expand Up @@ -107,16 +107,19 @@
type Output = Texture;
fn cook(
&self,
source: &[u8],

Check warning on line 110 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `source`

Check warning on line 110 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `source`

Check warning on line 110 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `source`
extension: &str,
meta: Meta,

Check warning on line 112 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `meta`

Check warning on line 112 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `meta`

Check warning on line 112 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `meta`
cooker: Arc<blade_asset::Cooker<Self>>,
exe_context: &choir::ExecutionContext,
) {
use blade_graphics::TextureFormat as Tf;

Check warning on line 116 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused import: `blade_graphics::TextureFormat as Tf`

Check warning on line 116 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused import: `blade_graphics::TextureFormat as Tf`

Check warning on line 116 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused import: `blade_graphics::TextureFormat as Tf`

type LdrTexel = [u8; 4];
type HdrTexel = [f32; 3];
enum PlainData {
Ldr(Vec<[u8; 4]>),
Hdr(Vec<[f32; 4]>),
Ldr(Vec<LdrTexel>),
Hdr(Vec<HdrTexel>),
}
struct PlainImage {
width: usize,
Expand All @@ -124,7 +127,7 @@
data: PlainData,
}

let src: PlainImage = match extension {

Check warning on line 130 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `src`

Check warning on line 130 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `src`

Check warning on line 130 in blade-render/src/texture/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `src`
#[cfg(feature = "asset")]
"png" => {
profiling::scope!("decode png");
Expand All @@ -134,9 +137,11 @@
decoder.decode_headers().unwrap();
let info = decoder.get_info().unwrap().clone();
let mut data = vec![[0u8; 4]; info.width * info.height];
let count = data.len() * data[0].len();
assert_eq!(count, decoder.output_buffer_size().unwrap());
decoder
.decode_into(unsafe {
slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, data.len() * 4)
slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, count)
})
.unwrap();
PlainImage {
Expand All @@ -154,9 +159,11 @@
decoder.decode_headers().unwrap();
let info = decoder.info().unwrap();
let mut data = vec![[0u8; 4]; info.width as usize * info.height as usize];
let count = data.len() * data[0].len();
assert_eq!(count, decoder.output_buffer_size().unwrap());
decoder
.decode_into(unsafe {
slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, data.len() * 4)
slice::from_raw_parts_mut(data.as_mut_ptr() as *mut u8, count)
})
.unwrap();
PlainImage {
Expand All @@ -166,23 +173,46 @@
}
}
#[cfg(feature = "asset")]
"hdr" => {
profiling::scope!("decode hdr");
let options = zune_core::options::DecoderOptions::default();
let mut decoder = zune_hdr::HdrDecoder::new_with_options(source, options);
decoder.decode_headers().unwrap();
let (width, height) = decoder.get_dimensions().unwrap();
let colorspace = decoder.get_colorspace().unwrap();
assert_eq!(colorspace, zune_core::colorspace::ColorSpace::RGB);
let mut data = vec![[0f32; 3]; width * height];
let count = data.len() * data[0].len();
assert_eq!(count, decoder.output_buffer_size().unwrap());
decoder
.decode_into(unsafe {
slice::from_raw_parts_mut(data.as_mut_ptr() as *mut f32, count)
})
.unwrap();
PlainImage {
width,
height,
data: PlainData::Hdr(data),
}
}
#[cfg(feature = "asset")]
"exr" => {
use exr::prelude::{ReadChannels as _, ReadLayers as _};
profiling::scope!("decode exr");
struct RawImage {
width: usize,
data: Vec<[f32; 4]>,
data: Vec<HdrTexel>,
}
let image = exr::image::read::read()
.no_deep_data()
.largest_resolution_level()
.rgba_channels(
|size, _| RawImage {
width: size.width(),
data: vec![[0f32; 4]; size.width() * size.height()],
data: vec![[0f32; 3]; size.width() * size.height()],
},
|image, position, (r, g, b, a): (f32, f32, f32, f32)| {
image.data[position.y() * image.width + position.x()] = [r, g, b, a];
|image, position, (r, g, b, _): (f32, f32, f32, f32)| {
image.data[position.y() * image.width + position.x()] = [r, g, b];
},
)
.first_valid_layer()
Expand Down Expand Up @@ -262,7 +292,7 @@
}

struct CompressTask {
src: Vec<[u8; 4]>,
src: Vec<LdrTexel>,
dst_ptr: *mut u8,
}
unsafe impl Send for CompressTask {}
Expand Down Expand Up @@ -321,15 +351,20 @@
}
PlainData::Hdr(data) => {
//TODO: compress as BC6E
//Note: we convert RGB32 to RGBA32 here, for now
assert_eq!(meta.format, blade_graphics::TextureFormat::Rgba32Float);
let data_raw = unsafe {
slice::from_raw_parts(
data.as_ptr() as *const u8,
data.len() * data[0].len() * mem::size_of::<f32>(),
)
};
let mut buf = vec![0u8; data_raw.len()];
buf.copy_from_slice(data_raw);
let in_texel_elements = data[0].len();
let out_texel_size = 4 * mem::size_of::<f32>();
let mut buf = vec![0u8; data.len() * out_texel_size];
for (slice, texel) in buf.chunks_mut(out_texel_size).zip(data) {
unsafe {
ptr::copy_nonoverlapping(
texel.as_ptr(),
slice.as_mut_ptr() as *mut f32,
in_texel_elements,
)
}
}
cooker.finish(CookedImage {
name: &[],
extent: [src.width as u32, src.height as u32, 1],
Expand Down
16 changes: 11 additions & 5 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
Changelog for Blade

## Unreleased
## blade-graphics-0.3, blade-render-0.2 (17 Nov 2023)
- tangent space generation
- spatio-temporal resampling
- SVGF de-noising
- environment map importance sampling
- shaders as assets
- with includes, enums, and bitflags
- with hot reloading
- load textures: `exr`, `hdr`
- utility: `FramePacer`
- examples: scene editing in "scene"
- using egui-gizmo for manipulation

## 0.2 (31 May 2023)
## blade-graphics-0.2, blade-render-0.1 (31 May 2023)
- ray tracing support
- examples: ray-query, scene
- examples: "ray-query", "scene"
- crate: `blade-egui` for egui integration
- crate: `blade-asset` for asset pipeline
- crate: `blade-render` for ray-traced renderer
- load models: `gltf`
- load textures: `png`, `jpg`

## 0.1 (25 Jan 2023)
## blade-graphics-0.1 (25 Jan 2023)
- backends: Vulkan, Metal, OpenGL ES + WebGL2
- examples: mini, bunnymark, particle
- examples: "mini", "bunnymark", "particle"
- crate `blade-graphics` for GPU abstracting GPU operations
- crate `blade-macros` for `ShaderData` derivation
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[![Matrix](https://img.shields.io/static/v1?label=dev&message=%23blade&color=blueviolet&logo=matrix)](https://matrix.to/#/#blade-dev:matrix.org)
[![Build Status](https://github.com/kvark/blade/workflows/check/badge.svg)](https://github.com/kvark/blade/actions)
[![Docs](https://docs.rs/blade/badge.svg)](https://docs.rs/blade)
[![Crates.io](https://img.shields.io/crates/v/blade.svg?maxAge=2592000)](https://crates.io/crates/blade)
[![Crates.io](https://img.shields.io/crates/v/blade-graphics.svg?maxAge=2592000)](https://crates.io/crates/blade-graphics)
[![Crates.io](https://img.shields.io/crates/v/blade-render.svg?maxAge=2592000)](https://crates.io/crates/blade-render)

![](logo.png)

Expand Down
17 changes: 10 additions & 7 deletions examples/bunnymark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Sprite {

struct Example {
pipeline: gpu::RenderPipeline,
command_encoder: gpu::CommandEncoder,
command_encoder: Option<gpu::CommandEncoder>,
prev_sync_point: Option<gpu::SyncPoint>,
texture: gpu::Texture,
view: gpu::TextureView,
Expand Down Expand Up @@ -169,7 +169,7 @@ impl Example {

Self {
pipeline,
command_encoder,
command_encoder: Some(command_encoder),
prev_sync_point: None,
texture,
view,
Expand Down Expand Up @@ -223,10 +223,11 @@ impl Example {
fn render(&mut self) {
let frame = self.context.acquire_frame();

self.command_encoder.start();
self.command_encoder.init_texture(frame.texture());
let encoder = self.command_encoder.as_mut().unwrap();
encoder.start();
encoder.init_texture(frame.texture());

if let mut pass = self.command_encoder.render(gpu::RenderTargetSet {
if let mut pass = encoder.render(gpu::RenderTargetSet {
colors: &[gpu::RenderTarget {
view: frame.texture_view(),
init_op: gpu::InitOp::Clear(gpu::TextureColor::TransparentBlack),
Expand Down Expand Up @@ -258,8 +259,8 @@ impl Example {
rc.draw(0, 4, 0, 1);
}
}
self.command_encoder.present(frame);
let sync_point = self.context.submit(&mut self.command_encoder);
encoder.present(frame);
let sync_point = self.context.submit(encoder);
if let Some(sp) = self.prev_sync_point.take() {
self.context.wait_for(&sp, !0);
}
Expand All @@ -271,6 +272,8 @@ impl Example {
self.context.wait_for(&sp, !0);
}
self.context.destroy_texture(self.texture);
self.context
.destroy_command_encoder(self.command_encoder.take().unwrap());
}
}

Expand Down
Loading