update to latest bevy (local checkout)
This commit is contained in:
parent
00c67d5bdf
commit
f6af46e7f4
36
Cargo.toml
36
Cargo.toml
|
|
@ -3,9 +3,6 @@ name = "vidya"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
bevy = {path = "../bevy"}
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
@ -36,7 +33,7 @@ derive_more = { version = "1.0.0", features = ["deref", "debug", "deref_mut"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = {version ="0.3", features = ["env-filter"]}
|
tracing-subscriber = {version ="0.3", features = ["env-filter"]}
|
||||||
|
|
||||||
glam = {version = "0.29.0", features = ["bytemuck"]}
|
glam = {version = "0.33", features = ["bytemuck"]}
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
bitflags = "2.6"
|
bitflags = "2.6"
|
||||||
thread_local = "1.1.8"
|
thread_local = "1.1.8"
|
||||||
|
|
@ -71,22 +68,21 @@ raw-window-handle = "0.6"
|
||||||
egui = "0.32"
|
egui = "0.32"
|
||||||
egui_winit_platform = "0.27"
|
egui_winit_platform = "0.27"
|
||||||
|
|
||||||
bevy = { version = "0.20.0-dev" }
|
bevy = { path = "/var/code/bevy-engine/bevy" }
|
||||||
bevy_app = { version = "0.20.0-dev" }
|
bevy_app = { path = "/var/code/bevy-engine/bevy/crates/bevy_app" }
|
||||||
bevy_asset = { version = "0.20.0-dev" }
|
bevy_asset = { path = "/var/code/bevy-engine/bevy/crates/bevy_asset" }
|
||||||
bevy_derive = { version = "0.20.0-dev" }
|
bevy_derive = { path = "/var/code/bevy-engine/bevy/crates/bevy_derive" }
|
||||||
bevy_ecs = { version = "0.20.0-dev" }
|
bevy_ecs = { path = "/var/code/bevy-engine/bevy/crates/bevy_ecs" }
|
||||||
bevy_hierarchy = { version = "0.20.0-dev" }
|
bevy_log = { path = "/var/code/bevy-engine/bevy/crates/bevy_log" }
|
||||||
bevy_log = { version = "0.20.0-dev" }
|
bevy_math = { path = "/var/code/bevy-engine/bevy/crates/bevy_math" }
|
||||||
bevy_math = { version = "0.20.0-dev" }
|
bevy_platform = { path = "/var/code/bevy-engine/bevy/crates/bevy_platform" }
|
||||||
bevy_platform = { version = "0.20.0-dev" }
|
bevy_reflect = { path = "/var/code/bevy-engine/bevy/crates/bevy_reflect" }
|
||||||
bevy_reflect = { version = "0.20.0-dev" }
|
bevy_tasks = { path = "/var/code/bevy-engine/bevy/crates/bevy_tasks" }
|
||||||
bevy_tasks = { version = "0.20.0-dev" }
|
bevy_time = { path = "/var/code/bevy-engine/bevy/crates/bevy_time" }
|
||||||
bevy_time = { version = "0.20.0-dev" }
|
bevy_transform = { path = "/var/code/bevy-engine/bevy/crates/bevy_transform" }
|
||||||
bevy_transform = { version = "0.20.0-dev" }
|
bevy_utils = { path = "/var/code/bevy-engine/bevy/crates/bevy_utils" }
|
||||||
bevy_utils = { version = "0.20.0-dev" }
|
bevy_window = { path = "/var/code/bevy-engine/bevy/crates/bevy_window" }
|
||||||
bevy_window = { version = "0.20.0-dev" }
|
bevy_winit = { path = "/var/code/bevy-engine/bevy/crates/bevy_winit" }
|
||||||
bevy_winit = { version = "0.20.0-dev" }
|
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "bevy_integration"
|
name = "bevy_integration"
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@ use crate::extract_plugin::MainWorld;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
change_detection::Tick,
|
change_detection::Tick,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
query::FilteredAccessSet,
|
|
||||||
system::{
|
system::{
|
||||||
ReadOnlySystemParam, SystemMeta, SystemParam, SystemParamItem, SystemParamValidationError,
|
ReadOnlySystemParam, SystemAccess, SystemMeta, SystemParam, SystemParamItem,
|
||||||
SystemState,
|
SystemParamValidationError, SystemState,
|
||||||
},
|
},
|
||||||
world::unsafe_world_cell::UnsafeWorldCell,
|
world::unsafe_world_cell::UnsafeWorldCell,
|
||||||
};
|
};
|
||||||
|
|
@ -83,15 +82,9 @@ where
|
||||||
fn init_access(
|
fn init_access(
|
||||||
state: &Self::State,
|
state: &Self::State,
|
||||||
system_meta: &mut SystemMeta,
|
system_meta: &mut SystemMeta,
|
||||||
component_access_set: &mut FilteredAccessSet,
|
system_access: &mut SystemAccess,
|
||||||
world: &mut World,
|
) -> Result<(), bevy_ecs::system::SystemParamAccessConflict> {
|
||||||
) {
|
Res::<MainWorld>::init_access(&state.main_world_state, system_meta, system_access)
|
||||||
Res::<MainWorld>::init_access(
|
|
||||||
&state.main_world_state,
|
|
||||||
system_meta,
|
|
||||||
component_access_set,
|
|
||||||
world,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ fn mock_render_system() {
|
||||||
impl Plugin for RenderPlugin {
|
impl Plugin for RenderPlugin {
|
||||||
fn build(&self, app: &mut bevy_app::App) {
|
fn build(&self, app: &mut bevy_app::App) {
|
||||||
app.add_plugins(ExtractPlugin::default());
|
app.add_plugins(ExtractPlugin::default());
|
||||||
|
app.insert_non_send(window::Surfaces::default());
|
||||||
|
|
||||||
let asset_server = app.world().resource::<AssetServer>().clone();
|
let asset_server = app.world().resource::<AssetServer>().clone();
|
||||||
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
|
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
|
||||||
|
|
@ -100,18 +101,6 @@ impl Plugin for RenderPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_vulkan(app: &mut App) -> Option<()> {
|
|
||||||
let device = renderer::device::Device::new_from_default_desc(None, &[]).ok()?;
|
|
||||||
|
|
||||||
let device = RenderDevice { device };
|
|
||||||
app.insert_resource(device.clone());
|
|
||||||
|
|
||||||
let render_app = app.sub_app_mut(RenderApp);
|
|
||||||
render_app.insert_resource(device.clone());
|
|
||||||
|
|
||||||
Some(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A "scratch" world used to avoid allocating new worlds every frame when
|
/// A "scratch" world used to avoid allocating new worlds every frame when
|
||||||
/// swapping out the [`MainWorld`] for [`ExtractSchedule`].
|
/// swapping out the [`MainWorld`] for [`ExtractSchedule`].
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
|
|
|
||||||
|
|
@ -93,12 +93,12 @@ impl Plugin for SyncWorldPlugin {
|
||||||
fn build(&self, app: &mut bevy_app::App) {
|
fn build(&self, app: &mut bevy_app::App) {
|
||||||
app.init_resource::<PendingSyncEntity>();
|
app.init_resource::<PendingSyncEntity>();
|
||||||
app.add_observer(
|
app.add_observer(
|
||||||
|add: On<Add, SyncToRenderWorld>, mut pending: ResMut<PendingSyncEntity>| {
|
|add: On<Add<SyncToRenderWorld>>, mut pending: ResMut<PendingSyncEntity>| {
|
||||||
pending.push(EntityRecord::Added(add.entity));
|
pending.push(EntityRecord::Added(add.entity));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
app.add_observer(
|
app.add_observer(
|
||||||
|remove: On<Remove, SyncToRenderWorld>,
|
|remove: On<Remove<SyncToRenderWorld>>,
|
||||||
mut pending: ResMut<PendingSyncEntity>,
|
mut pending: ResMut<PendingSyncEntity>,
|
||||||
query: Query<&RenderEntity>| {
|
query: Query<&RenderEntity>| {
|
||||||
if let Ok(e) = query.get(remove.entity) {
|
if let Ok(e) = query.get(remove.entity) {
|
||||||
|
|
@ -344,6 +344,13 @@ mod render_entities_world_query_impls {
|
||||||
<&RenderEntity as WorldQuery>::update_component_access(&component_id, access);
|
<&RenderEntity as WorldQuery>::update_component_access(&component_id, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn init_nested_access(
|
||||||
|
state: &Self::State,
|
||||||
|
component_access_set: &mut bevy_ecs::query::FilteredAccessSet,
|
||||||
|
) -> Result<(), bevy_ecs::query::FilteredAccessSet> {
|
||||||
|
<&RenderEntity as WorldQuery>::init_nested_access(state, component_access_set)
|
||||||
|
}
|
||||||
|
|
||||||
fn init_state(world: &mut World) -> ComponentId {
|
fn init_state(world: &mut World) -> ComponentId {
|
||||||
<&RenderEntity as WorldQuery>::init_state(world)
|
<&RenderEntity as WorldQuery>::init_state(world)
|
||||||
}
|
}
|
||||||
|
|
@ -358,6 +365,10 @@ mod render_entities_world_query_impls {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
<&RenderEntity as WorldQuery>::matches_component_set(&state, set_contains_id)
|
<&RenderEntity as WorldQuery>::matches_component_set(&state, set_contains_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_archetypes(state: &mut Self::State, world: UnsafeWorldCell) {
|
||||||
|
<&RenderEntity as WorldQuery>::update_archetypes(state, world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: Component access of Self::ReadOnly is a subset of Self.
|
// SAFETY: Component access of Self::ReadOnly is a subset of Self.
|
||||||
|
|
@ -464,6 +475,13 @@ mod render_entities_world_query_impls {
|
||||||
<&MainEntity as WorldQuery>::update_component_access(&component_id, access);
|
<&MainEntity as WorldQuery>::update_component_access(&component_id, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn init_nested_access(
|
||||||
|
state: &Self::State,
|
||||||
|
component_access_set: &mut bevy_ecs::query::FilteredAccessSet,
|
||||||
|
) -> Result<(), bevy_ecs::query::FilteredAccessSet> {
|
||||||
|
<&MainEntity as WorldQuery>::init_nested_access(state, component_access_set)
|
||||||
|
}
|
||||||
|
|
||||||
fn init_state(world: &mut World) -> ComponentId {
|
fn init_state(world: &mut World) -> ComponentId {
|
||||||
<&MainEntity as WorldQuery>::init_state(world)
|
<&MainEntity as WorldQuery>::init_state(world)
|
||||||
}
|
}
|
||||||
|
|
@ -478,6 +496,10 @@ mod render_entities_world_query_impls {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
<&MainEntity as WorldQuery>::matches_component_set(&state, set_contains_id)
|
<&MainEntity as WorldQuery>::matches_component_set(&state, set_contains_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_archetypes(state: &mut Self::State, world: UnsafeWorldCell) {
|
||||||
|
<&MainEntity as WorldQuery>::update_archetypes(state, world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: Component access of Self::ReadOnly is a subset of Self.
|
// SAFETY: Component access of Self::ReadOnly is a subset of Self.
|
||||||
|
|
@ -558,12 +580,12 @@ mod tests {
|
||||||
main_world.init_resource::<PendingSyncEntity>();
|
main_world.init_resource::<PendingSyncEntity>();
|
||||||
|
|
||||||
main_world.add_observer(
|
main_world.add_observer(
|
||||||
|add: On<Add, SyncToRenderWorld>, mut pending: ResMut<PendingSyncEntity>| {
|
|add: On<Add<SyncToRenderWorld>>, mut pending: ResMut<PendingSyncEntity>| {
|
||||||
pending.push(EntityRecord::Added(add.entity));
|
pending.push(EntityRecord::Added(add.entity));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
main_world.add_observer(
|
main_world.add_observer(
|
||||||
|remove: On<Remove, SyncToRenderWorld>,
|
|remove: On<Remove<SyncToRenderWorld>>,
|
||||||
mut pending: ResMut<PendingSyncEntity>,
|
mut pending: ResMut<PendingSyncEntity>,
|
||||||
query: Query<&RenderEntity>| {
|
query: Query<&RenderEntity>| {
|
||||||
if let Ok(e) = query.get(remove.entity) {
|
if let Ok(e) = query.get(remove.entity) {
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use std::{
|
||||||
|
|
||||||
use bevy_ecs::{entity::EntityHashMap, prelude::*};
|
use bevy_ecs::{entity::EntityHashMap, prelude::*};
|
||||||
use bevy_window::{PrimaryWindow, RawHandleWrapper, Window, WindowClosing};
|
use bevy_window::{PrimaryWindow, RawHandleWrapper, Window, WindowClosing};
|
||||||
use renderer::{ash::vk, swapchain::WindowSurface};
|
use renderer::{ash::vk, swapchain::Surface};
|
||||||
|
|
||||||
use crate::{RenderDevice, extract_param::Extract};
|
use crate::extract_param::Extract;
|
||||||
|
|
||||||
pub struct ExtractedWindow {
|
pub struct ExtractedWindow {
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
|
|
@ -39,7 +39,7 @@ impl DerefMut for ExtractedWindows {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Resource)]
|
#[derive(Default)]
|
||||||
pub struct Surfaces {
|
pub struct Surfaces {
|
||||||
surfaces: EntityHashMap<SurfaceData>,
|
surfaces: EntityHashMap<SurfaceData>,
|
||||||
configured: HashSet<Entity>,
|
configured: HashSet<Entity>,
|
||||||
|
|
@ -57,11 +57,12 @@ impl Surfaces {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SurfaceData {
|
pub struct SurfaceData {
|
||||||
pub surface: WindowSurface,
|
renderer: renderer::Renderer2,
|
||||||
|
pub surface: Surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for SurfaceData {
|
impl Deref for SurfaceData {
|
||||||
type Target = WindowSurface;
|
type Target = Surface;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.surface
|
&self.surface
|
||||||
|
|
@ -74,7 +75,7 @@ pub(crate) fn extract_windows(
|
||||||
mut closing: Extract<MessageReader<WindowClosing>>,
|
mut closing: Extract<MessageReader<WindowClosing>>,
|
||||||
windows: Extract<Query<(Entity, &RawHandleWrapper, &Window, Option<&PrimaryWindow>)>>,
|
windows: Extract<Query<(Entity, &RawHandleWrapper, &Window, Option<&PrimaryWindow>)>>,
|
||||||
mut removed: Extract<RemovedComponents<RawHandleWrapper>>,
|
mut removed: Extract<RemovedComponents<RawHandleWrapper>>,
|
||||||
mut surfaces: ResMut<Surfaces>,
|
mut surfaces: NonSendMut<Surfaces>,
|
||||||
) {
|
) {
|
||||||
for (entity, handle, window, primary) in windows.iter() {
|
for (entity, handle, window, primary) in windows.iter() {
|
||||||
if primary.is_some() {
|
if primary.is_some() {
|
||||||
|
|
@ -116,7 +117,7 @@ pub(crate) fn extract_windows(
|
||||||
|
|
||||||
pub(crate) fn need_surface_configuration(
|
pub(crate) fn need_surface_configuration(
|
||||||
windows: Res<ExtractedWindows>,
|
windows: Res<ExtractedWindows>,
|
||||||
surfaces: Res<Surfaces>,
|
surfaces: NonSend<Surfaces>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
windows
|
windows
|
||||||
.windows
|
.windows
|
||||||
|
|
@ -126,37 +127,43 @@ pub(crate) fn need_surface_configuration(
|
||||||
|
|
||||||
pub(crate) fn configure_surfaces(
|
pub(crate) fn configure_surfaces(
|
||||||
windows: Res<ExtractedWindows>,
|
windows: Res<ExtractedWindows>,
|
||||||
mut surfaces: ResMut<Surfaces>,
|
mut surfaces: NonSendMut<Surfaces>,
|
||||||
device: Res<RenderDevice>,
|
|
||||||
) {
|
) {
|
||||||
for window in windows.windows.values() {
|
for window in windows.windows.values() {
|
||||||
let surface = surfaces.surfaces.entry(window.entity).or_insert_with(|| {
|
let surface_data = surfaces.surfaces.entry(window.entity).or_insert_with(|| {
|
||||||
let (display_handle, window_handle) = (
|
let (display_handle, window_handle) = (
|
||||||
window.handle.get_display_handle(),
|
window.handle.get_display_handle(),
|
||||||
window.handle.get_window_handle(),
|
window.handle.get_window_handle(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let surface = WindowSurface::new(
|
let renderer =
|
||||||
(**device).clone(),
|
renderer::Renderer2::new(display_handle).expect("Failed to create Vulkan renderer");
|
||||||
vk::Extent2D {
|
let surface = renderer
|
||||||
width: window.physical_width,
|
.create_surface(
|
||||||
height: window.physical_height,
|
window_handle,
|
||||||
},
|
vk::Extent2D {
|
||||||
window_handle,
|
width: window.physical_width,
|
||||||
display_handle,
|
height: window.physical_height,
|
||||||
)
|
},
|
||||||
.expect("Failed to create window surface");
|
)
|
||||||
|
.expect("Failed to create window surface");
|
||||||
|
|
||||||
SurfaceData { surface }
|
SurfaceData { renderer, surface }
|
||||||
});
|
});
|
||||||
|
|
||||||
if window.size_changed {
|
if window.size_changed {
|
||||||
surface
|
surface_data
|
||||||
.surface
|
.surface
|
||||||
.recreate_with(Some(vk::Extent2D {
|
.configure(
|
||||||
width: window.physical_width,
|
surface_data.renderer.device(),
|
||||||
height: window.physical_height,
|
renderer::swapchain::SwapchainConfiguration {
|
||||||
}))
|
extent: vk::Extent2D {
|
||||||
|
width: window.physical_width,
|
||||||
|
height: window.physical_height,
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
.expect("Failed to recreate surface");
|
.expect("Failed to recreate surface");
|
||||||
}
|
}
|
||||||
surfaces.configured.insert(window.entity);
|
surfaces.configured.insert(window.entity);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
negative_impls,
|
negative_impls,
|
||||||
map_try_insert,
|
map_try_insert,
|
||||||
debug_closure_helpers,
|
debug_closure_helpers,
|
||||||
|
core_io,
|
||||||
core_io_borrowed_buf,
|
core_io_borrowed_buf,
|
||||||
slice_partition_dedup
|
slice_partition_dedup
|
||||||
)]
|
)]
|
||||||
|
|
|
||||||
|
|
@ -471,52 +471,6 @@ pub struct RenderAttachment {
|
||||||
pub store_op: vk::AttachmentStoreOp,
|
pub store_op: vk::AttachmentStoreOp,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderAttachment {
|
|
||||||
pub fn side_effect(&self, mut map: SideEffectMap, load: bool) {
|
|
||||||
for attachment in &self.color_attachments {
|
|
||||||
// The dependencies declared here need to be barrier'd before and
|
|
||||||
// after the render pass: the spec says pipelineBarrier inside of a
|
|
||||||
// render pass instance referencing framebuffer-local stages must
|
|
||||||
// contain only framebuffer-local stages.
|
|
||||||
|
|
||||||
map.with(
|
|
||||||
vk::PipelineStageFlags2::COLOR_ATTACHMENT_OUTPUT,
|
|
||||||
if attachment.load_op == vk::AttachmentLoadOp::LOAD {
|
|
||||||
vk::AccessFlags2::COLOR_ATTACHMENT_READ
|
|
||||||
} else {
|
|
||||||
vk::AccessFlags2::empty()
|
|
||||||
},
|
|
||||||
Some(attachment.layout),
|
|
||||||
)
|
|
||||||
.insert_range(attachment.texture.id(), attachment.region);
|
|
||||||
}
|
|
||||||
if let Some(depth) = &self.depth_attachment {
|
|
||||||
map.with(
|
|
||||||
vk::PipelineStageFlags2::EARLY_FRAGMENT_TESTS,
|
|
||||||
if depth.load_op == vk::AttachmentLoadOp::LOAD {
|
|
||||||
vk::AccessFlags2::DEPTH_STENCIL_ATTACHMENT_READ
|
|
||||||
} else {
|
|
||||||
vk::AccessFlags2::empty()
|
|
||||||
},
|
|
||||||
Some(depth.layout),
|
|
||||||
)
|
|
||||||
.insert_range(depth.texture.id(), depth.region);
|
|
||||||
}
|
|
||||||
if let Some(stencil) = &self.stencil_attachment {
|
|
||||||
map.with(
|
|
||||||
vk::PipelineStageFlags2::EARLY_FRAGMENT_TESTS,
|
|
||||||
if stencil.load_op == vk::AttachmentLoadOp::LOAD {
|
|
||||||
vk::AccessFlags2::DEPTH_STENCIL_ATTACHMENT_READ
|
|
||||||
} else {
|
|
||||||
vk::AccessFlags2::empty()
|
|
||||||
},
|
|
||||||
Some(stencil.layout),
|
|
||||||
)
|
|
||||||
.insert_range(stencil.texture.id(), stencil.region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BeginRendering {
|
pub struct BeginRendering {
|
||||||
pub color_attachments: Vec<RenderAttachment>,
|
pub color_attachments: Vec<RenderAttachment>,
|
||||||
pub depth_attachment: Option<RenderAttachment>,
|
pub depth_attachment: Option<RenderAttachment>,
|
||||||
|
|
@ -525,21 +479,7 @@ pub struct BeginRendering {
|
||||||
pub layers: u32,
|
pub layers: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EndRendering {
|
pub struct EndRendering;
|
||||||
pub color_attachments: Vec<RenderAttachment>,
|
|
||||||
pub depth_attachment: Option<RenderAttachment>,
|
|
||||||
pub stencil_attachment: Option<RenderAttachment>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BeginRendering {
|
|
||||||
fn end_rendering(&self) -> EndRendering {
|
|
||||||
EndRendering {
|
|
||||||
color_attachments: self.color_attachments.clone(),
|
|
||||||
depth_attachment: self.depth_attachment.clone(),
|
|
||||||
stencil_attachment: self.stencil_attachment.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Command for BeginRendering {
|
impl Command for BeginRendering {
|
||||||
fn side_effects(&self, mut map: SideEffectMap) {
|
fn side_effects(&self, mut map: SideEffectMap) {
|
||||||
|
|
|
||||||
|
|
@ -154,13 +154,17 @@ mod api_demo {
|
||||||
let staging_size = vertex_size + index_size + draw_calls_size + textures_indices_size;
|
let staging_size = vertex_size + index_size + draw_calls_size + textures_indices_size;
|
||||||
let mut staging = builder.make_staging_buffer(staging_size as u64);
|
let mut staging = builder.make_staging_buffer(staging_size as u64);
|
||||||
|
|
||||||
use core::io::BorrowedBuf;
|
let staging_map = staging.map_mut().unwrap();
|
||||||
let mut buf = BorrowedBuf::from(staging.map_mut().unwrap());
|
let mut offset = 0;
|
||||||
let mut cursor = buf.unfilled();
|
for data in [
|
||||||
cursor.append(bytemuck::cast_slice(&vertices));
|
bytemuck::cast_slice(&vertices),
|
||||||
cursor.append(bytemuck::cast_slice(&indices));
|
bytemuck::cast_slice(&indices),
|
||||||
cursor.append(bytemuck::cast_slice(&draw_calls));
|
bytemuck::cast_slice(&draw_calls),
|
||||||
cursor.append(bytemuck::cast_slice(&textures_indices));
|
bytemuck::cast_slice(&textures_indices),
|
||||||
|
] {
|
||||||
|
staging_map[offset..offset + data.len()].copy_from_slice(data);
|
||||||
|
offset += data.len();
|
||||||
|
}
|
||||||
|
|
||||||
let vertex_buffer = builder.make_buffer(
|
let vertex_buffer = builder.make_buffer(
|
||||||
vertex_size as u64,
|
vertex_size as u64,
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ pub struct RenderPass<'cmd, 'a> {
|
||||||
|
|
||||||
impl<'cmd, 'a> RenderPass<'cmd, 'a> {
|
impl<'cmd, 'a> RenderPass<'cmd, 'a> {
|
||||||
pub fn finalise(self) {
|
pub fn finalise(self) {
|
||||||
self.cmd_list.push_inner(super::commands::EndRendering);
|
self.cmd_list.push_inner(super::commands::EndRendering {});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push<C: Command + InsideRenderPass + 'cmd>(&mut self, command: C) {
|
pub fn push<C: Command + InsideRenderPass + 'cmd>(&mut self, command: C) {
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,8 @@ mod components {
|
||||||
pub struct Text(pub String);
|
pub struct Text(pub String);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ROBOTO_BYTES: &[u8] =
|
const ROBOTO_BYTES: &[u8] = include_bytes!("../../../assets/fonts/Roboto.ttf");
|
||||||
include_bytes!("../../../assets/fonts/Roboto/Roboto-VariableFont_wdth,wght.ttf");
|
const NOTO_SANS_HAN_BYTES: &[u8] = include_bytes!("../../../assets/fonts/NotoSansSC.ttf");
|
||||||
const NOTO_SANS_HAN_BYTES: &[u8] =
|
|
||||||
include_bytes!("../../../assets/fonts/Noto_Sans_SC/NotoSansSC-VariableFont_wght.ttf");
|
|
||||||
|
|
||||||
def_monotonic_id!(pub FontId);
|
def_monotonic_id!(pub FontId);
|
||||||
|
|
||||||
|
|
@ -42,7 +40,7 @@ impl std::fmt::Debug for FontData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, TypePath)]
|
||||||
struct FontLoader;
|
struct FontLoader;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue