mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
cargo fmt
This commit is contained in:
parent
8a704a3e28
commit
e855995145
55 changed files with 185 additions and 161 deletions
|
@ -11,9 +11,9 @@ mod system;
|
|||
|
||||
pub use app::*;
|
||||
pub use app_builder::*;
|
||||
pub use bevy_derive::{DynamicAppPlugin, EntityArchetype, FromResources};
|
||||
pub use entity_archetype::*;
|
||||
pub use event::*;
|
||||
pub use plugin::*;
|
||||
pub use resources::*;
|
||||
pub use system::*;
|
||||
pub use bevy_derive::{DynamicAppPlugin, EntityArchetype, FromResources};
|
||||
|
|
|
@ -11,4 +11,4 @@ where
|
|||
fn from_resources(_resources: &Resources) -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,4 +104,4 @@ impl SchedulePlan {
|
|||
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{App, AppBuilder, AppPlugin};
|
||||
use crate::{AppExit, Events, EventReader};
|
||||
use crate::{AppExit, EventReader, Events};
|
||||
use std::{thread, time::Duration};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{AssetServer, Assets, Handle, AssetVersion, LoadState};
|
||||
use crate::{AssetServer, AssetVersion, Assets, Handle, LoadState};
|
||||
use anyhow::Result;
|
||||
use crossbeam_channel::{Receiver, Sender, TryRecvError};
|
||||
use fs::File;
|
||||
|
@ -56,18 +56,18 @@ pub fn update_asset_storage_system<T>(
|
|||
) {
|
||||
loop {
|
||||
match asset_channel.receiver.try_recv() {
|
||||
Ok(result) => {
|
||||
match result.result {
|
||||
Ok(asset) => {
|
||||
assets.set(result.handle, asset);
|
||||
asset_server.set_load_state(result.handle.id, LoadState::Loaded(result.version));
|
||||
},
|
||||
Err(err) => {
|
||||
asset_server.set_load_state(result.handle.id, LoadState::Failed(result.version));
|
||||
log::error!("Failed to load asset: {:?}", err);
|
||||
}
|
||||
Ok(result) => match result.result {
|
||||
Ok(asset) => {
|
||||
assets.set(result.handle, asset);
|
||||
asset_server
|
||||
.set_load_state(result.handle.id, LoadState::Loaded(result.version));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
asset_server
|
||||
.set_load_state(result.handle.id, LoadState::Failed(result.version));
|
||||
log::error!("Failed to load asset: {:?}", err);
|
||||
}
|
||||
},
|
||||
Err(TryRecvError::Empty) => {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
pub mod bytes;
|
||||
pub mod float_ord;
|
||||
pub mod time;
|
||||
pub mod transform;
|
||||
pub mod float_ord;
|
||||
|
||||
use bevy_app::{stage, AppBuilder, AppPlugin};
|
||||
use bevy_transform::{
|
||||
components::{
|
||||
Children, LocalTransform, Transform, NonUniformScale, Rotation, Scale, Translation,
|
||||
Children, LocalTransform, NonUniformScale, Rotation, Scale, Transform, Translation,
|
||||
},
|
||||
transform_system_bundle,
|
||||
};
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
mod app_plugin;
|
||||
mod as_vertex_buffer_descriptor;
|
||||
mod attributes;
|
||||
mod bytes;
|
||||
mod entity_archetype;
|
||||
mod modules;
|
||||
mod render_resources;
|
||||
mod render_resource;
|
||||
mod render_resources;
|
||||
mod resource;
|
||||
mod shader_defs;
|
||||
mod as_vertex_buffer_descriptor;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
|
@ -48,8 +48,7 @@ pub fn derive_entity_archetype(input: TokenStream) -> TokenStream {
|
|||
entity_archetype::derive_entity_archetype(input)
|
||||
}
|
||||
|
||||
|
||||
#[proc_macro_derive(DynamicAppPlugin)]
|
||||
pub fn derive_app_plugin(input: TokenStream) -> TokenStream {
|
||||
app_plugin::derive_dynamic_app_plugin(input)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,9 @@ pub fn derive_render_resources(input: TokenStream) -> TokenStream {
|
|||
render_resource_fields.push(field_ident);
|
||||
render_resource_names.push(format!("{}_{}", struct_name, field_name));
|
||||
if attrs.buffer {
|
||||
render_resource_hints.push(quote! {Some(#bevy_render_path::render_resource::RenderResourceHints::BUFFER)})
|
||||
render_resource_hints.push(
|
||||
quote! {Some(#bevy_render_path::render_resource::RenderResourceHints::BUFFER)},
|
||||
)
|
||||
} else {
|
||||
render_resource_hints.push(quote! {None})
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::modules::{get_modules, get_path};
|
||||
use inflector::Inflector;
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::Ident;
|
||||
use inflector::Inflector;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Fields, Path};
|
||||
|
||||
|
@ -44,7 +44,6 @@ pub fn derive_shader_defs(input: TokenStream) -> TokenStream {
|
|||
let generics = ast.generics;
|
||||
let (impl_generics, ty_generics, _where_clause) = generics.split_for_impl();
|
||||
|
||||
|
||||
TokenStream::from(quote! {
|
||||
impl #impl_generics #bevy_render_path::shader::ShaderDefs for #struct_name#ty_generics {
|
||||
fn shader_defs_len(&self) -> usize {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use bevy_app::{Events, EventReader};
|
||||
use legion::prelude::{Res, ResMut};
|
||||
use crate::Input;
|
||||
use bevy_app::{EventReader, Events};
|
||||
use legion::prelude::{Res, ResMut};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct KeyboardInput {
|
||||
|
|
|
@ -9,8 +9,7 @@ use bevy_app::{AppBuilder, AppPlugin};
|
|||
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput, KeyboardInputState};
|
||||
use legion::prelude::IntoSystem;
|
||||
use mouse::{
|
||||
mouse_button_input_system, MouseButton, MouseButtonInput, MouseButtonInputState,
|
||||
MouseMotion,
|
||||
mouse_button_input_system, MouseButton, MouseButtonInput, MouseButtonInputState, MouseMotion,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::keyboard::{ElementState, KeyboardInput, KeyCode};
|
||||
use crate::keyboard::{ElementState, KeyCode, KeyboardInput};
|
||||
use bevy_app::{AppExit, EventReader, Events};
|
||||
use legion::prelude::*;
|
||||
|
||||
|
@ -8,9 +8,7 @@ pub fn exit_on_esc_system(_resources: &mut Resources) -> Box<dyn Schedulable> {
|
|||
mut app_exit_events: ResMut<Events<AppExit>>| {
|
||||
for event in keyboard_input_event_reader.iter(&keyboard_input_events) {
|
||||
if let Some(key_code) = event.key_code {
|
||||
if event.state == ElementState::Pressed
|
||||
&& key_code == KeyCode::Escape
|
||||
{
|
||||
if event.state == ElementState::Pressed && key_code == KeyCode::Escape {
|
||||
app_exit_events.send(AppExit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use bevy_render::{
|
||||
render_graph::{CommandQueue, Node, ResourceSlots, SystemNode},
|
||||
render_resource::{
|
||||
BufferInfo, BufferUsage, RenderResourceBinding, RenderResourceBindings,
|
||||
},
|
||||
render_resource::{BufferInfo, BufferUsage, RenderResourceBinding, RenderResourceBindings},
|
||||
renderer::{RenderContext, RenderResourceContext},
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ use crate::{
|
|||
RenderPassDepthStencilAttachmentDescriptor, StoreOp, TextureAttachment,
|
||||
},
|
||||
render_graph::{
|
||||
nodes::{CameraNode, MainPassNode, TextureCopyNode, WindowSwapChainNode, WindowTextureNode},
|
||||
nodes::{
|
||||
CameraNode, MainPassNode, TextureCopyNode, WindowSwapChainNode, WindowTextureNode,
|
||||
},
|
||||
RenderGraph,
|
||||
},
|
||||
texture::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsage},
|
||||
|
@ -51,17 +53,11 @@ impl Default for BaseRenderGraphConfig {
|
|||
/// By itself this graph doesn't do much, but it allows Render plugins to interop with each other by having a common
|
||||
/// set of nodes. It can be customized using `BaseRenderGraphConfig`.
|
||||
pub trait BaseRenderGraphBuilder {
|
||||
fn add_base_graph(
|
||||
&mut self,
|
||||
config: &BaseRenderGraphConfig,
|
||||
) -> &mut Self;
|
||||
fn add_base_graph(&mut self, config: &BaseRenderGraphConfig) -> &mut Self;
|
||||
}
|
||||
|
||||
impl BaseRenderGraphBuilder for RenderGraph {
|
||||
fn add_base_graph(
|
||||
&mut self,
|
||||
config: &BaseRenderGraphConfig,
|
||||
) -> &mut Self {
|
||||
fn add_base_graph(&mut self, config: &BaseRenderGraphConfig) -> &mut Self {
|
||||
self.add_node(node::TEXTURE_COPY, TextureCopyNode::default());
|
||||
if config.add_3d_camera {
|
||||
self.add_system_node(node::CAMERA, CameraNode::new(uniform::CAMERA));
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
use super::texture::Texture;
|
||||
use crate::{render_resource::{RenderResourceType, RenderResource}, impl_render_resource_bytes};
|
||||
use crate::{
|
||||
impl_render_resource_bytes,
|
||||
render_resource::{RenderResource, RenderResourceType},
|
||||
};
|
||||
use bevy_asset::Handle;
|
||||
use bevy_core::bytes::{Byteable, Bytes};
|
||||
use bevy_property::Property;
|
||||
|
@ -130,4 +133,4 @@ impl From<Handle<Texture>> for ColorSource {
|
|||
}
|
||||
}
|
||||
|
||||
impl_render_resource_bytes!(Color);
|
||||
impl_render_resource_bytes!(Color);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::{
|
||||
base_render_graph, mesh::Mesh, Camera, OrthographicProjection, PerspectiveProjection,
|
||||
WindowOrigin, draw::Draw, pipeline::RenderPipelines,
|
||||
base_render_graph, draw::Draw, mesh::Mesh, pipeline::RenderPipelines, Camera,
|
||||
OrthographicProjection, PerspectiveProjection, WindowOrigin,
|
||||
};
|
||||
use bevy_asset::Handle;
|
||||
use bevy_derive::EntityArchetype;
|
||||
use bevy_transform::components::{Transform, Rotation, Scale, Translation};
|
||||
use bevy_transform::components::{Rotation, Scale, Transform, Translation};
|
||||
|
||||
#[derive(EntityArchetype, Default)]
|
||||
pub struct MeshMaterialEntity<T: Default + Send + Sync + 'static> {
|
||||
|
|
|
@ -409,9 +409,7 @@ pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box<dyn Sched
|
|||
for (handle, mut render_pipelines) in query.iter_mut(world) {
|
||||
if let Some(mesh) = meshes.get(&handle) {
|
||||
for render_pipeline in render_pipelines.pipelines.iter_mut() {
|
||||
render_pipeline
|
||||
.specialization
|
||||
.primitive_topology = mesh.primitive_topology;
|
||||
render_pipeline.specialization.primitive_topology = mesh.primitive_topology;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
pipeline::{PipelineDescriptor, BindGroupDescriptorId},
|
||||
pipeline::{BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{BindGroupId, BufferId},
|
||||
renderer::RenderContext,
|
||||
};
|
||||
|
|
|
@ -3,9 +3,9 @@ mod binding;
|
|||
mod pipeline;
|
||||
mod pipeline_compiler;
|
||||
mod pipeline_layout;
|
||||
mod render_pipelines;
|
||||
pub mod state_descriptors;
|
||||
mod vertex_buffer_descriptor;
|
||||
mod render_pipelines;
|
||||
mod vertex_format;
|
||||
|
||||
pub use bind_group::*;
|
||||
|
@ -15,4 +15,4 @@ pub use pipeline_compiler::*;
|
|||
pub use pipeline_layout::*;
|
||||
pub use render_pipelines::*;
|
||||
pub use vertex_buffer_descriptor::*;
|
||||
pub use vertex_format::*;
|
||||
pub use vertex_format::*;
|
||||
|
|
|
@ -3,8 +3,9 @@ use super::{
|
|||
VertexBufferDescriptors,
|
||||
};
|
||||
use crate::{
|
||||
render_resource::RenderResourceBindings,
|
||||
renderer::RenderResourceContext,
|
||||
shader::{Shader, ShaderSource}, render_resource::RenderResourceBindings,
|
||||
shader::{Shader, ShaderSource},
|
||||
};
|
||||
use bevy_asset::{Assets, Handle};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
|
|
@ -65,4 +65,4 @@ impl VertexBufferDescriptors {
|
|||
|
||||
pub trait AsVertexBufferDescriptor {
|
||||
fn as_vertex_buffer_descriptor() -> &'static VertexBufferDescriptor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
use crate::{render_resource::{BufferId, TextureId}, renderer::RenderContext, texture::Extent3d};
|
||||
use crate::{
|
||||
render_resource::{BufferId, TextureId},
|
||||
renderer::RenderContext,
|
||||
texture::Extent3d,
|
||||
};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -309,7 +309,8 @@ mod tests {
|
|||
use super::RenderGraph;
|
||||
use crate::{
|
||||
render_graph::{Edge, Node, NodeId, RenderGraphError, ResourceSlotInfo, ResourceSlots},
|
||||
renderer::RenderContext, render_resource::RenderResourceType,
|
||||
render_resource::RenderResourceType,
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use legion::prelude::{Resources, World};
|
||||
use std::{collections::HashSet, iter::FromIterator};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
mod camera_node;
|
||||
mod pass_node;
|
||||
mod texture_copy_node;
|
||||
mod render_resources_node;
|
||||
mod texture_copy_node;
|
||||
mod window_swapchain_node;
|
||||
mod window_texture_node;
|
||||
|
||||
pub use camera_node::*;
|
||||
pub use pass_node::*;
|
||||
pub use texture_copy_node::*;
|
||||
pub use render_resources_node::*;
|
||||
pub use texture_copy_node::*;
|
||||
pub use window_swapchain_node::*;
|
||||
pub use window_texture_node::*;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
render_graph::{CommandQueue, Node, ResourceSlots, SystemNode},
|
||||
render_resource::{BufferInfo, BufferUsage, RenderResourceBinding, RenderResourceBindings},
|
||||
renderer::{RenderResourceContext, RenderContext},
|
||||
renderer::{RenderContext, RenderResourceContext},
|
||||
Camera,
|
||||
};
|
||||
use bevy_core::bytes::AsBytes;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
pass::{PassDescriptor, TextureAttachment},
|
||||
pipeline::PipelineDescriptor,
|
||||
render_graph::{Node, ResourceSlotInfo, ResourceSlots},
|
||||
render_resource::{BufferId, RenderResourceBindings, BindGroupId, RenderResourceType},
|
||||
render_resource::{BindGroupId, BufferId, RenderResourceBindings, RenderResourceType},
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use bevy_asset::{Assets, Handle};
|
||||
|
|
|
@ -35,14 +35,20 @@ impl Node for TextureCopyNode {
|
|||
AssetEvent::Created { handle } | AssetEvent::Modified { handle } => {
|
||||
if let Some(texture) = textures.get(&handle) {
|
||||
let texture_descriptor: TextureDescriptor = texture.into();
|
||||
let width = texture.size.x() as usize;
|
||||
let width = texture.size.x() as usize;
|
||||
let aligned_width = get_aligned(texture.size.x());
|
||||
let format_size = 4; // TODO: this will be incorrect for some formats
|
||||
let mut aligned_data = vec![0; format_size * aligned_width * texture.size.y() as usize];
|
||||
texture.data.chunks_exact(format_size * width).enumerate().for_each(|(index, row)| {
|
||||
let offset = index * aligned_width * format_size;
|
||||
aligned_data[offset..(offset + width * format_size)].copy_from_slice(row);
|
||||
});
|
||||
let mut aligned_data =
|
||||
vec![0; format_size * aligned_width * texture.size.y() as usize];
|
||||
texture
|
||||
.data
|
||||
.chunks_exact(format_size * width)
|
||||
.enumerate()
|
||||
.for_each(|(index, row)| {
|
||||
let offset = index * aligned_width * format_size;
|
||||
aligned_data[offset..(offset + width * format_size)]
|
||||
.copy_from_slice(row);
|
||||
});
|
||||
let texture_buffer = render_context.resources().create_buffer_with_data(
|
||||
BufferInfo {
|
||||
buffer_usage: BufferUsage::COPY_SRC,
|
||||
|
|
|
@ -70,6 +70,9 @@ impl Node for WindowSwapChainNode {
|
|||
}
|
||||
|
||||
let swap_chain_texture = render_resource_context.next_swap_chain_texture(window.id);
|
||||
output.set(WINDOW_TEXTURE, RenderResourceId::Texture(swap_chain_texture));
|
||||
output.set(
|
||||
WINDOW_TEXTURE,
|
||||
RenderResourceId::Texture(swap_chain_texture),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,8 @@ mod tests {
|
|||
use super::{DependentNodeStager, OrderedJob, RenderGraphStager, Stage};
|
||||
use crate::{
|
||||
render_graph::{Node, NodeId, RenderGraph, ResourceSlotInfo, ResourceSlots},
|
||||
renderer::RenderContext, render_resource::RenderResourceType,
|
||||
render_resource::RenderResourceType,
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use legion::prelude::{Resources, World};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use legion::prelude::{Resources, World};
|
||||
use super::RenderGraph;
|
||||
use legion::prelude::{Resources, World};
|
||||
|
||||
pub fn render_graph_schedule_executor_system(world: &mut World, resources: &mut Resources) {
|
||||
// run render graph systems
|
||||
|
@ -15,4 +15,4 @@ pub fn render_graph_schedule_executor_system(world: &mut World, resources: &mut
|
|||
if let Some(executor) = system_executor.take() {
|
||||
render_graph.set_executor(executor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,4 @@ bitflags::bitflags! {
|
|||
const STORAGE = 128;
|
||||
const INDIRECT = 256;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
mod buffer;
|
||||
mod texture;
|
||||
mod shared_buffer;
|
||||
mod render_resource;
|
||||
mod bind_group;
|
||||
mod buffer;
|
||||
mod render_resource;
|
||||
mod render_resource_bindings;
|
||||
mod shared_buffer;
|
||||
mod systems;
|
||||
mod texture;
|
||||
|
||||
pub use buffer::*;
|
||||
pub use texture::*;
|
||||
pub use shared_buffer::*;
|
||||
pub use render_resource::*;
|
||||
pub use bind_group::*;
|
||||
pub use buffer::*;
|
||||
pub use render_resource::*;
|
||||
pub use render_resource_bindings::*;
|
||||
pub use systems::*;
|
||||
pub use shared_buffer::*;
|
||||
pub use systems::*;
|
||||
pub use texture::*;
|
||||
|
|
|
@ -6,7 +6,6 @@ use bevy_core::bytes::{Byteable, Bytes};
|
|||
pub use bevy_derive::{RenderResource, RenderResources};
|
||||
use glam::{Mat4, Vec2, Vec3, Vec4};
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub enum RenderResourceType {
|
||||
Buffer,
|
||||
|
@ -41,24 +40,24 @@ impl From<SamplerId> for RenderResourceId {
|
|||
|
||||
impl RenderResourceId {
|
||||
pub fn get_texture(&self) -> Option<TextureId> {
|
||||
if let RenderResourceId::Texture(id) = self{
|
||||
Some(*id)
|
||||
if let RenderResourceId::Texture(id) = self {
|
||||
Some(*id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_buffer(&self) -> Option<BufferId> {
|
||||
if let RenderResourceId::Buffer(id) = self{
|
||||
Some(*id)
|
||||
if let RenderResourceId::Buffer(id) = self {
|
||||
Some(*id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_sampler(&self) -> Option<SamplerId> {
|
||||
if let RenderResourceId::Sampler(id) = self{
|
||||
Some(*id)
|
||||
if let RenderResourceId::Sampler(id) = self {
|
||||
Some(*id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use super::{BindGroup, BindGroupId, BufferId, RenderResourceId, SamplerId, TextureId};
|
||||
use crate::pipeline::{BindGroupDescriptor, BindGroupDescriptorId};
|
||||
use bevy_asset::{Handle, HandleUntyped};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
hash::Hash,
|
||||
ops::Range,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
use bevy_asset::{HandleUntyped, Handle};
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||
pub enum RenderResourceBinding {
|
||||
|
@ -198,7 +198,9 @@ impl AssetRenderResourceBindings {
|
|||
}
|
||||
|
||||
pub fn get_or_insert_mut<T>(&mut self, handle: Handle<T>) -> &mut RenderResourceBindings {
|
||||
self.bindings.entry(HandleUntyped::from(handle)).or_insert_with(|| RenderResourceBindings::default())
|
||||
self.bindings
|
||||
.entry(HandleUntyped::from(handle))
|
||||
.or_insert_with(|| RenderResourceBindings::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ pub fn bind_groups_system(
|
|||
for mut render_pipelines in query.iter_mut(world) {
|
||||
let render_pipelines = render_pipelines.as_mut();
|
||||
for render_pipeline in render_pipelines.pipelines.iter_mut() {
|
||||
let pipeline = pipelines.get(&render_pipeline.specialized_pipeline.unwrap()).unwrap();
|
||||
let pipeline = pipelines
|
||||
.get(&render_pipeline.specialized_pipeline.unwrap())
|
||||
.unwrap();
|
||||
update_bind_groups(
|
||||
pipeline,
|
||||
&mut render_pipelines.bindings,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::RenderResourceContext;
|
||||
use crate::{
|
||||
pipeline::{BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{BufferId, BufferInfo, RenderResourceId, BindGroup, SamplerId, TextureId},
|
||||
render_resource::{BindGroup, BufferId, BufferInfo, RenderResourceId, SamplerId, TextureId},
|
||||
shader::Shader,
|
||||
texture::{SamplerDescriptor, TextureDescriptor},
|
||||
};
|
||||
|
@ -85,7 +85,11 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
|
|||
.unwrap()
|
||||
.insert((handle, index), render_resource);
|
||||
}
|
||||
fn get_asset_resource_untyped(&self, handle: HandleUntyped, index: usize) -> Option<RenderResourceId> {
|
||||
fn get_asset_resource_untyped(
|
||||
&self,
|
||||
handle: HandleUntyped,
|
||||
index: usize,
|
||||
) -> Option<RenderResourceId> {
|
||||
self.asset_resources
|
||||
.write()
|
||||
.unwrap()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
pipeline::{BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{BufferId, BufferInfo, RenderResourceId, BindGroup, SamplerId, TextureId},
|
||||
render_resource::{BindGroup, BufferId, BufferInfo, RenderResourceId, SamplerId, TextureId},
|
||||
shader::Shader,
|
||||
texture::{SamplerDescriptor, TextureDescriptor},
|
||||
};
|
||||
|
@ -30,8 +30,17 @@ pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
|
|||
fn remove_sampler(&self, sampler: SamplerId);
|
||||
fn get_buffer_info(&self, buffer: BufferId) -> Option<BufferInfo>;
|
||||
|
||||
fn set_asset_resource_untyped(&self, handle: HandleUntyped, resource: RenderResourceId, index: usize);
|
||||
fn get_asset_resource_untyped(&self, handle: HandleUntyped, index: usize) -> Option<RenderResourceId>;
|
||||
fn set_asset_resource_untyped(
|
||||
&self,
|
||||
handle: HandleUntyped,
|
||||
resource: RenderResourceId,
|
||||
index: usize,
|
||||
);
|
||||
fn get_asset_resource_untyped(
|
||||
&self,
|
||||
handle: HandleUntyped,
|
||||
index: usize,
|
||||
) -> Option<RenderResourceId>;
|
||||
fn remove_asset_resource_untyped(&self, handle: HandleUntyped, index: usize);
|
||||
fn create_render_pipeline(
|
||||
&self,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bevy_core::bytes::Byteable;
|
||||
use crate::pipeline::AsVertexBufferDescriptor;
|
||||
use bevy_core::bytes::Byteable;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, AsVertexBufferDescriptor)]
|
||||
|
@ -11,4 +11,4 @@ pub struct Vertex {
|
|||
}
|
||||
|
||||
// SAFE: Vertex is repr(C) containing primitives
|
||||
unsafe impl Byteable for Vertex {}
|
||||
unsafe impl Byteable for Vertex {}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
mod color_material;
|
||||
mod dynamic_texture_atlas_builder;
|
||||
pub mod entity;
|
||||
mod quad;
|
||||
mod rect;
|
||||
|
@ -6,16 +7,15 @@ mod render;
|
|||
mod sprite;
|
||||
mod texture_atlas;
|
||||
mod texture_atlas_builder;
|
||||
mod dynamic_texture_atlas_builder;
|
||||
|
||||
pub use color_material::*;
|
||||
pub use dynamic_texture_atlas_builder::*;
|
||||
pub use quad::*;
|
||||
pub use rect::*;
|
||||
pub use render::*;
|
||||
pub use sprite::*;
|
||||
pub use texture_atlas::*;
|
||||
pub use texture_atlas_builder::*;
|
||||
pub use dynamic_texture_atlas_builder::*;
|
||||
|
||||
use bevy_app::{stage, AppBuilder, AppPlugin};
|
||||
use bevy_asset::{AddAsset, Assets, Handle};
|
||||
|
|
|
@ -105,7 +105,7 @@ impl TextureAtlasBuilder {
|
|||
current_width *= 2;
|
||||
current_height *= 2;
|
||||
None
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,9 +113,7 @@ impl TextureAtlasBuilder {
|
|||
|
||||
let mut texture_rects = Vec::with_capacity(rect_placements.packed_locations().len());
|
||||
let mut texture_handles = HashMap::new();
|
||||
for (texture_handle, (_, packed_location)) in
|
||||
rect_placements.packed_locations().iter()
|
||||
{
|
||||
for (texture_handle, (_, packed_location)) in rect_placements.packed_locations().iter() {
|
||||
let texture = textures.get(texture_handle).unwrap();
|
||||
let min = Vec2::new(packed_location.x() as f32, packed_location.y() as f32);
|
||||
let max = min
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
mod draw;
|
||||
mod font;
|
||||
mod font_loader;
|
||||
mod font_atlas;
|
||||
mod font_atlas_set;
|
||||
mod draw;
|
||||
mod font_loader;
|
||||
|
||||
pub use draw::*;
|
||||
pub use font::*;
|
||||
pub use font_loader::*;
|
||||
pub use font_atlas::*;
|
||||
pub use font_atlas_set::*;
|
||||
pub use draw::*;
|
||||
|
||||
pub use font_loader::*;
|
||||
|
||||
use bevy_app::{AppBuilder, AppPlugin};
|
||||
use bevy_asset::AddAsset;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
mod children;
|
||||
mod local_transform;
|
||||
mod transform;
|
||||
mod non_uniform_scale;
|
||||
mod parent;
|
||||
mod rotation;
|
||||
mod scale;
|
||||
mod transform;
|
||||
mod translation;
|
||||
|
||||
pub use children::Children;
|
||||
pub use local_transform::*;
|
||||
pub use transform::*;
|
||||
pub use non_uniform_scale::*;
|
||||
pub use parent::{Parent, PreviousParent};
|
||||
pub use rotation::*;
|
||||
pub use scale::*;
|
||||
pub use transform::*;
|
||||
pub use translation::*;
|
||||
|
|
|
@ -8,12 +8,14 @@ use crate::{
|
|||
pub fn build(_: &mut World) -> Box<dyn Schedulable> {
|
||||
SystemBuilder::<()>::new("LocalToParentUpdateSystem")
|
||||
// Translation
|
||||
.with_query(<(Write<LocalTransform>, Read<Translation>)>::query().filter(
|
||||
!component::<Rotation>()
|
||||
& !component::<Scale>()
|
||||
& !component::<NonUniformScale>()
|
||||
& (changed::<Translation>()),
|
||||
))
|
||||
.with_query(
|
||||
<(Write<LocalTransform>, Read<Translation>)>::query().filter(
|
||||
!component::<Rotation>()
|
||||
& !component::<Scale>()
|
||||
& !component::<NonUniformScale>()
|
||||
& (changed::<Translation>()),
|
||||
),
|
||||
)
|
||||
// Rotation
|
||||
.with_query(<(Write<LocalTransform>, Read<Rotation>)>::query().filter(
|
||||
!component::<Translation>()
|
||||
|
|
|
@ -32,15 +32,13 @@ pub fn build(_: &mut World) -> Box<dyn Schedulable> {
|
|||
& (changed::<Scale>()),
|
||||
))
|
||||
// NonUniformScale
|
||||
.with_query(
|
||||
<(Write<Transform>, Read<NonUniformScale>)>::query().filter(
|
||||
!component::<Parent>()
|
||||
& !component::<Translation>()
|
||||
& !component::<Rotation>()
|
||||
& !component::<Scale>()
|
||||
& (changed::<NonUniformScale>()),
|
||||
),
|
||||
)
|
||||
.with_query(<(Write<Transform>, Read<NonUniformScale>)>::query().filter(
|
||||
!component::<Parent>()
|
||||
& !component::<Translation>()
|
||||
& !component::<Rotation>()
|
||||
& !component::<Scale>()
|
||||
& (changed::<NonUniformScale>()),
|
||||
))
|
||||
// Translation + Rotation
|
||||
.with_query(
|
||||
<(Write<Transform>, Read<Translation>, Read<Rotation>)>::query().filter(
|
||||
|
@ -61,12 +59,7 @@ pub fn build(_: &mut World) -> Box<dyn Schedulable> {
|
|||
)
|
||||
// Translation + NonUniformScale
|
||||
.with_query(
|
||||
<(
|
||||
Write<Transform>,
|
||||
Read<Translation>,
|
||||
Read<NonUniformScale>,
|
||||
)>::query()
|
||||
.filter(
|
||||
<(Write<Transform>, Read<Translation>, Read<NonUniformScale>)>::query().filter(
|
||||
!component::<Parent>()
|
||||
& !component::<Rotation>()
|
||||
& !component::<Scale>()
|
||||
|
@ -153,9 +146,8 @@ pub fn build(_: &mut World) -> Box<dyn Schedulable> {
|
|||
if !ltw.sync {
|
||||
return;
|
||||
}
|
||||
*ltw = Transform::new(Mat4::from_scale(Vec3::new(
|
||||
scale.0, scale.0, scale.0,
|
||||
)));
|
||||
*ltw =
|
||||
Transform::new(Mat4::from_scale(Vec3::new(scale.0, scale.0, scale.0)));
|
||||
});
|
||||
});
|
||||
s.spawn(|_| unsafe {
|
||||
|
|
|
@ -10,7 +10,10 @@ pub use wgpu_renderer::*;
|
|||
pub use wgpu_resources::*;
|
||||
|
||||
use bevy_app::{AppBuilder, AppPlugin};
|
||||
use bevy_render::{renderer::RenderResourceContext, render_resource::{free_shared_buffers_system, SharedBuffers}};
|
||||
use bevy_render::{
|
||||
render_resource::{free_shared_buffers_system, SharedBuffers},
|
||||
renderer::RenderResourceContext,
|
||||
};
|
||||
use legion::prelude::*;
|
||||
use renderer::WgpuRenderResourceContext;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use bevy_asset::{Assets, Handle, HandleUntyped};
|
|||
use bevy_render::{
|
||||
pipeline::{BindGroupDescriptor, BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{
|
||||
BufferId, BufferInfo, RenderResourceId, RenderResourceBinding, BindGroup, SamplerId,
|
||||
BindGroup, BufferId, BufferInfo, RenderResourceBinding, RenderResourceId, SamplerId,
|
||||
TextureId,
|
||||
},
|
||||
renderer::RenderResourceContext,
|
||||
|
@ -313,7 +313,11 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||
asset_resources.insert((handle, index), render_resource);
|
||||
}
|
||||
|
||||
fn get_asset_resource_untyped(&self, handle: HandleUntyped, index: usize) -> Option<RenderResourceId> {
|
||||
fn get_asset_resource_untyped(
|
||||
&self,
|
||||
handle: HandleUntyped,
|
||||
index: usize,
|
||||
) -> Option<RenderResourceId> {
|
||||
let asset_resources = self.resources.asset_resources.read().unwrap();
|
||||
asset_resources.get(&(handle, index)).cloned()
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use bevy_asset::Handle;
|
|||
use bevy_render::{
|
||||
pass::RenderPass,
|
||||
pipeline::{BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{BufferId, BindGroupId},
|
||||
render_resource::{BindGroupId, BufferId},
|
||||
renderer::RenderContext,
|
||||
};
|
||||
use std::ops::Range;
|
||||
|
@ -56,11 +56,7 @@ impl<'a> RenderPass for WgpuRenderPass<'a> {
|
|||
bind_group: BindGroupId,
|
||||
dynamic_uniform_indices: Option<&[u32]>,
|
||||
) {
|
||||
if let Some(bind_group_info) = self
|
||||
.wgpu_resources
|
||||
.bind_groups
|
||||
.get(&bind_group_descriptor)
|
||||
{
|
||||
if let Some(bind_group_info) = self.wgpu_resources.bind_groups.get(&bind_group_descriptor) {
|
||||
if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) {
|
||||
const EMPTY: &'static [u32] = &[];
|
||||
let dynamic_uniform_indices =
|
||||
|
@ -83,7 +79,11 @@ impl<'a> RenderPass for WgpuRenderPass<'a> {
|
|||
}
|
||||
|
||||
fn set_pipeline(&mut self, pipeline_handle: Handle<PipelineDescriptor>) {
|
||||
let pipeline = self.wgpu_resources.render_pipelines.get(&pipeline_handle).expect(
|
||||
let pipeline = self
|
||||
.wgpu_resources
|
||||
.render_pipelines
|
||||
.get(&pipeline_handle)
|
||||
.expect(
|
||||
"Attempted to use a pipeline that does not exist in this RenderPass's RenderContext",
|
||||
);
|
||||
self.render_pass.set_pipeline(pipeline);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use bevy_asset::{Handle, HandleUntyped};
|
||||
use bevy_render::{
|
||||
pipeline::{BindGroupDescriptorId, PipelineDescriptor},
|
||||
render_resource::{BufferId, BufferInfo, RenderResourceId, BindGroupId, SamplerId, TextureId},
|
||||
render_resource::{BindGroupId, BufferId, BufferInfo, RenderResourceId, SamplerId, TextureId},
|
||||
shader::Shader,
|
||||
texture::TextureDescriptor,
|
||||
};
|
||||
|
@ -108,10 +108,7 @@ impl WgpuResources {
|
|||
.unwrap()
|
||||
.get(&bind_group_descriptor_id)
|
||||
{
|
||||
bind_group_info
|
||||
.bind_groups
|
||||
.get(&bind_group_id)
|
||||
.is_some()
|
||||
bind_group_info.bind_groups.get(&bind_group_id).is_some()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ pub struct WindowCloseRequested {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CursorMoved {
|
||||
pub id: WindowId,
|
||||
pub id: WindowId,
|
||||
pub position: Vec2,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bevy_input::{
|
||||
keyboard::{ElementState, KeyboardInput, KeyCode},
|
||||
keyboard::{ElementState, KeyCode, KeyboardInput},
|
||||
mouse::MouseButton,
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,10 @@ fn setup(
|
|||
) {
|
||||
env_logger::init();
|
||||
let texture_handle = asset_server
|
||||
.load_sync(&mut textures, "assets/textures/rpg/chars/gabe/gabe-idle-run.png")
|
||||
.load_sync(
|
||||
&mut textures,
|
||||
"assets/textures/rpg/chars/gabe/gabe-idle-run.png",
|
||||
)
|
||||
.unwrap();
|
||||
let texture = textures.get(&texture_handle).unwrap();
|
||||
let texture_atlas = TextureAtlas::from_grid(texture_handle, texture.size, 7, 1);
|
||||
|
|
|
@ -7,7 +7,6 @@ fn main() {
|
|||
.run();
|
||||
}
|
||||
|
||||
|
||||
/// set up a simple scene
|
||||
fn setup(
|
||||
command_buffer: &mut CommandBuffer,
|
||||
|
|
|
@ -12,7 +12,7 @@ fn mouse_click_system(mouse_button_input: Res<Input<MouseButton>>) {
|
|||
if mouse_button_input.pressed(MouseButton::Left) {
|
||||
println!("left mouse currently pressed");
|
||||
}
|
||||
|
||||
|
||||
if mouse_button_input.just_pressed(MouseButton::Left) {
|
||||
println!("left mouse just pressed");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,10 @@ fn setup(
|
|||
vertex: shaders.add(Shader::from_glsl(ShaderStage::Vertex, VERTEX_SHADER)),
|
||||
fragment: Some(shaders.add(Shader::from_glsl(ShaderStage::Fragment, FRAGMENT_SHADER))),
|
||||
}));
|
||||
render_graph.add_system_node("my_material", AssetRenderResourcesNode::<MyMaterial>::new(true));
|
||||
render_graph.add_system_node(
|
||||
"my_material",
|
||||
AssetRenderResourcesNode::<MyMaterial>::new(true),
|
||||
);
|
||||
pipeline_handle
|
||||
};
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ pub use bevy_text as text;
|
|||
pub use bevy_transform as transform;
|
||||
pub use bevy_type_registry as type_registry;
|
||||
pub use bevy_ui as ui;
|
||||
pub use bevy_window as window;
|
||||
#[cfg(feature = "bevy_wgpu")]
|
||||
pub use bevy_wgpu as wgpu;
|
||||
pub use bevy_window as window;
|
||||
#[cfg(feature = "bevy_winit")]
|
||||
pub use bevy_winit as winit;
|
||||
|
|
Loading…
Reference in a new issue