it starts at least
This commit is contained in:
@@ -5,7 +5,7 @@ pub mod allocator;
|
||||
|
||||
use allocator::TapeAllocatorPlugin;
|
||||
use bevy_app::{App, Plugin};
|
||||
use bevy_asset::{AssetId, AssetServer, Assets, Handle};
|
||||
use bevy_asset::{AssetId, AssetServer, Assets, Handle, load_embedded_asset};
|
||||
use bevy_ecs::{
|
||||
prelude::*,
|
||||
system::{SystemParamItem, lifetimeless::SRes},
|
||||
@@ -25,19 +25,31 @@ use bevy_render::{
|
||||
use bevy_shader::{Shader, load_shader_library};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use rspirv::dr::Module;
|
||||
use wgpu::{ShaderModuleDescriptor, ShaderSource, include_spirv};
|
||||
|
||||
use crate::{
|
||||
render::allocator::{ElementClass, TapeAllocationKey, TapeAllocator, TapeSlabId},
|
||||
tape::Tape,
|
||||
};
|
||||
|
||||
fn get_module(shader: ShaderModuleDescriptor) -> Module {
|
||||
let ShaderSource::SpirV(source) = shader.source else {
|
||||
unreachable!()
|
||||
};
|
||||
let mut loader = rspirv::dr::Loader::new();
|
||||
rspirv::binary::parse_words(source, &mut loader).unwrap();
|
||||
loader.module()
|
||||
}
|
||||
|
||||
/// Makes sure that [`Tape`]es are extracted and prepared for the GPU.
|
||||
/// Does *not* add the [`Tape`] as an asset. Use [`TapePlugin`] for that.
|
||||
pub struct TapeRenderAssetPlugin;
|
||||
|
||||
impl Plugin for TapeRenderAssetPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
load_shader_library!(app, "aabb.wesl");
|
||||
load_shader_library!(app, "metadata_types.wesl");
|
||||
load_shader_library!(app, "implicit.wesl");
|
||||
|
||||
app.add_plugins(RenderAssetPlugin::<RenderTape>::default())
|
||||
.add_plugins(TapeAllocatorPlugin);
|
||||
@@ -46,6 +58,19 @@ impl Plugin for TapeRenderAssetPlugin {
|
||||
return;
|
||||
};
|
||||
|
||||
let enable_gen = include_spirv!("../../shaders_out/replacement/enable_gen.comp.glsl.spv");
|
||||
|
||||
render_app.insert_resource(ReplacementModules {
|
||||
enable_gen: get_module(enable_gen.clone()),
|
||||
fuzz: get_module(enable_gen.clone()),
|
||||
normals: get_module(enable_gen.clone()),
|
||||
spatial_texture: get_module(enable_gen.clone()),
|
||||
trace: get_module(enable_gen.clone()),
|
||||
enable_gen_layout: BindGroupLayoutDescriptor::new("Enable Gen Layout", &[]),
|
||||
fuzz_layout: BindGroupLayoutDescriptor::new("Tape Fuzz Layout", &[]),
|
||||
spatial_texture_layout: BindGroupLayoutDescriptor::new("Spatial Texture Layout", &[]),
|
||||
});
|
||||
|
||||
render_app.add_systems(
|
||||
Render,
|
||||
prepare_tape_metadata_fallback_buffer
|
||||
@@ -128,6 +153,7 @@ pub struct TapeMetadata {
|
||||
// AABB for decompressing positions.
|
||||
pub aabb_half_extents: Vec3,
|
||||
pub pad2: u32,
|
||||
pub subdivision_log2: u32,
|
||||
}
|
||||
|
||||
/// The render world representation of a [`Tape`].
|
||||
@@ -207,7 +233,7 @@ impl RenderAsset for RenderTape {
|
||||
label: Some(format!("bevy_tape_drive::gen_shader::enable_gen::{key}").into()),
|
||||
layout: vec![replacement_modules.enable_gen_layout.clone()],
|
||||
shader: enable_gen.clone(),
|
||||
entry_point: Some("enable_gen_entry".into()),
|
||||
entry_point: Some("main".into()),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@@ -215,7 +241,7 @@ impl RenderAsset for RenderTape {
|
||||
label: Some(format!("bevy_tape_drive::gen_shader::fuzz::{key}").into()),
|
||||
layout: vec![replacement_modules.fuzz_layout.clone()],
|
||||
shader: fuzz.clone(),
|
||||
entry_point: Some("fuzz_entry".into()),
|
||||
entry_point: Some("main".into()),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@@ -224,7 +250,7 @@ impl RenderAsset for RenderTape {
|
||||
label: Some(format!("bevy_tape_drive::gen_shader::spatial_texture::{key}").into()),
|
||||
layout: vec![replacement_modules.spatial_texture_layout.clone()],
|
||||
shader: spatial_texture.clone(),
|
||||
entry_point: Some("spatial_texture_entry".into()),
|
||||
entry_point: Some("main".into()),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user