Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow other plugins to create renderer resources #9925

Merged
merged 5 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use crate::{
render_asset::prepare_assets,
render_resource::{PipelineCache, Shader, ShaderLoader},
renderer::{render_system, RenderInstance},
settings::RenderSettings,
settings::RenderCreation,
view::{ViewPlugin, WindowRenderPlugin},
};
use bevy_app::{App, AppLabel, Plugin, SubApp};
Expand All @@ -67,7 +67,7 @@ use std::{
/// Contains the default Bevy rendering backend based on wgpu.
#[derive(Default)]
pub struct RenderPlugin {
pub render_settings: RenderSettings,
pub render_settings: RenderCreation,
MalekiRe marked this conversation as resolved.
Show resolved Hide resolved
}

/// The labels of the default App rendering sets.
Expand Down Expand Up @@ -241,7 +241,7 @@ impl Plugin for RenderPlugin {
.init_asset_loader::<ShaderLoader>();

match &self.render_settings {
RenderSettings::Manual(device, queue, adapter_info, adapter, instance) => {
RenderCreation::Manual(device, queue, adapter_info, adapter, instance) => {
let future_renderer_resources_wrapper = Arc::new(Mutex::new(Some((
device.clone(),
queue.clone(),
Expand All @@ -254,7 +254,7 @@ impl Plugin for RenderPlugin {
));
unsafe { initialize_render_app(app) };
}
RenderSettings::Automatic(render_settings) => {
RenderCreation::Automatic(render_settings) => {
if let Some(backends) = render_settings.backends {
let future_renderer_resources_wrapper = Arc::new(Mutex::new(None));
app.insert_resource(FutureRendererResources(
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_render/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Default for WgpuSettings {
}

/// An enum describing how the renderer will initialize resources. This is used when creating the [`RenderPlugin`](crate::RenderPlugin).
pub enum RenderSettings {
pub enum RenderCreation {
/// Allows renderer resource initialization to happen outside of the rendering plugin.
Manual(
RenderDevice,
Expand All @@ -110,8 +110,8 @@ pub enum RenderSettings {
Automatic(WgpuSettings),
}

impl RenderSettings {
/// Function to create a [`RenderSettings::Manual`] variant.
impl RenderCreation {
/// Function to create a [`RenderCreation::Manual`] variant.
pub fn manual(
device: RenderDevice,
queue: RenderQueue,
Expand All @@ -123,13 +123,13 @@ impl RenderSettings {
}
}

impl Default for RenderSettings {
impl Default for RenderCreation {
fn default() -> Self {
Self::Automatic(Default::default())
}
}

impl From<WgpuSettings> for RenderSettings {
impl From<WgpuSettings> for RenderCreation {
fn from(value: WgpuSettings) -> Self {
Self::Automatic(value)
}
Expand Down