Skip to content

Commit

Permalink
support embedded shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
kvey committed Oct 9, 2024
1 parent dac76f8 commit 4109f8c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions toolchain/Cargo.lock

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

2 changes: 1 addition & 1 deletion toolchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.2.2"
version = "0.2.4"
authors = ["Colton Pierson <colton@thousandbirds.ai>"]
edition = "2021"
license = "MIT"
Expand Down
4 changes: 4 additions & 0 deletions toolchain/chidori-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ webbrowser = { version = "0.8.2", optional = true }
serde_yaml = "0.8.26"
regex = "1.10.4"
bevy_framepace = "0.17.1"
#bevy_assets_bundler = "0.6.0"
lazy_static = "1.5.0"

[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
arboard = { version = "3.2.0", optional = true }
Expand All @@ -64,6 +66,8 @@ thread_local = { version = "1.1.0", optional = true }
target-lexicon = "0.12"
dirs = "3.0"
pyo3-build-config = "0.19.1"
#bevy_assets_bundler = "0.6.0"
lazy_static = "1.5.0"


# https://github.com/mvlabat/bevy_egui/blob/main/Cargo.toml
Expand Down
2 changes: 2 additions & 0 deletions toolchain/chidori-debugger/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

use dirs::home_dir;
use std::env;
use std::io::{self, Write};
use std::str::FromStr;
use target_lexicon::{OperatingSystem, Triple};


fn add_extension_module_link_args(triple: &Triple) -> io::Result<()> {
let mut writer = io::stdout();
match triple.operating_system {
Expand Down
4 changes: 3 additions & 1 deletion toolchain/chidori-debugger/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::hash::{DefaultHasher, Hash, Hasher};
use std::path::Path;
use std::ptr::NonNull;
use std::time::{Duration, Instant};
use bevy::asset::embedded_asset;
use bevy::render::camera::{ScalingMode, Viewport};
use bevy::render::render_asset::RenderAssetUsages;
use dashmap::DashMap;
Expand Down Expand Up @@ -1399,7 +1400,7 @@ struct RoundedRectMaterial {
/// You only need to implement functions for features that need non-default behavior. See the Material api docs for details!
impl Material for RoundedRectMaterial {
fn fragment_shader() -> ShaderRef {
"shaders/rounded_rect.wgsl".into()
"embedded://chidori_debugger/../assets/shaders/rounded_rect.wgsl".into()
}

fn alpha_mode(&self) -> AlphaMode {
Expand Down Expand Up @@ -1600,6 +1601,7 @@ fn graph_setup(
struct OnGraphScreen;

pub fn graph_plugin(app: &mut App) {
embedded_asset!(app, "../assets/shaders/rounded_rect.wgsl");
app.init_resource::<NodeIdToEntity>()
.init_resource::<EdgePairIdToEntity>()
.init_resource::<SelectedEntity>()
Expand Down
6 changes: 6 additions & 0 deletions toolchain/chidori-debugger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ mod bevy_egui;
mod egui_json_tree;
mod tree_grouping;
mod json_editor;
// mod r#mod;
// use bevy_assets_bundler::BundledAssetIoPlugin;
// use r#mod::BUNDLE_OPTIONS;


use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
use bevy::prelude::*;
Expand All @@ -34,6 +38,8 @@ use egui::style::{HandleShape, NumericColorSpace};
use once_cell::sync::{Lazy, OnceCell};




static DEVICE_SCALE: OnceCell<f32> = OnceCell::new();

pub const RENDER_LAYER_ROOT_CAMERA: Layer = 1;
Expand Down
6 changes: 4 additions & 2 deletions toolchain/chidori-debugger/src/shader_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy::render::mesh::{GpuBufferInfo, MeshVertexBufferLayout};
use bevy::core_pipeline::core_3d::Transparent3d;
use bevy::render::render_resource::{Buffer, BufferInitDescriptor, BufferUsages, PipelineCache, RenderPipelineDescriptor, SpecializedMeshPipeline, SpecializedMeshPipelineError, SpecializedMeshPipelines, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode};
use bevy::render::view::{ExtractedView, RenderLayers};
use bevy::asset::{AssetServer, Handle};
use bevy::asset::{embedded_asset, AssetServer, Handle};
use bevy::render::renderer::RenderDevice;
use bytemuck::offset_of;
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
Expand Down Expand Up @@ -102,7 +102,8 @@ pub struct CustomPipeline {
impl FromWorld for CustomPipeline {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource::<AssetServer>();
let shader = asset_server.load("shaders/instancing.wgsl");
let shader = asset_server.load("embedded://chidori_debugger/../assets/shaders/instancing.wgsl");


let mesh_pipeline = world.resource::<MeshPipeline>();

Expand Down Expand Up @@ -233,6 +234,7 @@ pub struct CustomMaterialPlugin;

impl Plugin for CustomMaterialPlugin {
fn build(&self, app: &mut App) {
embedded_asset!(app, "../assets/shaders/instancing.wgsl");
app.add_plugins(ExtractComponentPlugin::<InstanceMaterialData>::default());
app.sub_app_mut(RenderApp)
.add_render_command::<Transparent3d, DrawCustom>()
Expand Down

0 comments on commit 4109f8c

Please sign in to comment.