Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Jan 15, 2024
1 parent 90e9d07 commit db6d354
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions examples/shader/custom_render_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ use bevy::{
},
utils::{nonmax::NonMaxU32, FloatOrd},
};
use bevy_internal::render::render_resource::{
BindGroupLayoutEntry, BindingType, BufferBindingType,
};

fn main() {
App::new()
Expand Down Expand Up @@ -233,6 +236,8 @@ impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetMaterialBindGroup<I>
bind_group: SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
println!("!!! set bind group !!!");

pass.set_bind_group(I, bind_group.into_inner(), &[mesh_index.index()]);
RenderCommandResult::Success
}
Expand Down Expand Up @@ -322,10 +327,16 @@ impl FromWorld for CustomPipeline {

let bind_group_layout = render_device.create_bind_group_layout(
"custom_bind_group_layout",
&BindGroupLayoutEntries::single(
ShaderStages::FRAGMENT,
uniform_buffer::<CustomMaterial>(true),
),
&[BindGroupLayoutEntry {
binding: 0,
ty: BindingType::Buffer {
ty: BufferBindingType::Uniform,
has_dynamic_offset: true,
min_binding_size: Some(CustomMaterial::min_size()),
},
visibility: ShaderStages::FRAGMENT,
count: None,
}],
);

let shader = world
Expand All @@ -352,7 +363,7 @@ impl SpecializedMeshPipeline for CustomPipeline {
println!("specialize custom");
let mut desc = self.mesh_pipeline.specialize(key, layout)?;

desc.label = Some("mesh_custom_pipeline".into());
desc.label = Some("custom_mesh_pipeline".into());

// The layout of the pipeline
// It's important that it matches the order specified in the `DrawCustom`
Expand Down Expand Up @@ -400,7 +411,7 @@ fn prepare_custom_bind_group(
&custom_pipeline.bind_group_layout,
&BindGroupEntries::single(uniform),
);
println!("bind group preprared");
println!("bind group prepared");
commands.insert_resource(CustomMaterialBindGroup(bind_group));
}

Expand Down

0 comments on commit db6d354

Please sign in to comment.