Skip to content

Commit

Permalink
Don't reëxport bevy_image from bevy_render (#16163)
Browse files Browse the repository at this point in the history
Fixes #15940

Remove the `pub use` and fix the compile errors.
Make `bevy_image` available as `bevy::image`.

Feature Frenzy would be good here! Maybe I'll learn how to use it if I
have some time this weekend, or maybe a reviewer can use it.

Use `bevy_image` instead of `bevy_render::texture` items.

---------

Co-authored-by: chompaa <[email protected]>
Co-authored-by: Carter Anderson <[email protected]>
  • Loading branch information
3 people authored and mockersf committed Nov 11, 2024
1 parent 1da3fcc commit 31ec575
Show file tree
Hide file tree
Showing 92 changed files with 189 additions and 170 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/auto_exposure/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use super::compensation_curve::{
};
use bevy_asset::prelude::*;
use bevy_ecs::prelude::*;
use bevy_image::Image;
use bevy_render::{
globals::GlobalsUniform,
render_resource::{binding_types::*, *},
renderer::RenderDevice,
texture::Image,
view::ViewUniform,
};
use core::num::NonZero;
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_core_pipeline/src/auto_exposure/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use core::ops::RangeInclusive;
use super::compensation_curve::AutoExposureCompensationCurve;
use bevy_asset::Handle;
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_image::Image;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{extract_component::ExtractComponent, texture::Image};
use bevy_render::extract_component::ExtractComponent;
use bevy_utils::default;

/// Component that enables auto exposure for an HDR-enabled 2d or 3d camera.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Handle};
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_image::BevyDefault as _;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin},
Expand All @@ -16,7 +17,6 @@ use bevy_render::{
*,
},
renderer::RenderDevice,
texture::BevyDefault,
view::{ExtractedView, ViewTarget},
Render, RenderApp, RenderSet,
};
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ pub const DEPTH_TEXTURE_SAMPLING_SUPPORTED: bool = true;

use core::ops::Range;

use bevy_asset::{AssetId, UntypedAssetId};
use bevy_color::LinearRgba;
pub use camera_3d::*;
pub use main_opaque_pass_3d_node::*;
pub use main_transparent_pass_3d_node::*;

use bevy_app::{App, Plugin, PostUpdate};
use bevy_asset::{AssetId, UntypedAssetId};
use bevy_color::LinearRgba;
use bevy_ecs::{entity::EntityHashSet, prelude::*};
use bevy_image::{BevyDefault, Image};
use bevy_math::FloatOrd;
use bevy_render::sync_world::MainEntity;
use bevy_render::{
Expand All @@ -91,7 +92,7 @@ use bevy_render::{
},
renderer::RenderDevice,
sync_world::RenderEntity,
texture::{BevyDefault, ColorAttachment, Image, TextureCache},
texture::{ColorAttachment, TextureCache},
view::{ExtractedView, ViewDepthTexture, ViewTarget},
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_core_pipeline/src/dof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use bevy_ecs::{
system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::BevyDefault as _;
use bevy_math::ops;
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_render::{
Expand All @@ -48,7 +49,7 @@ use bevy_render::{
renderer::{RenderContext, RenderDevice},
sync_component::SyncComponentPlugin,
sync_world::RenderEntity,
texture::{BevyDefault, CachedTexture, TextureCache},
texture::{CachedTexture, TextureCache},
view::{
prepare_view_targets, ExtractedView, Msaa, ViewDepthTexture, ViewTarget, ViewUniform,
ViewUniformOffset, ViewUniforms,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/fxaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Handle};
use bevy_ecs::prelude::*;
use bevy_image::BevyDefault as _;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
Expand All @@ -16,7 +17,6 @@ use bevy_render::{
*,
},
renderer::RenderDevice,
texture::BevyDefault,
view::{ExtractedView, ViewTarget},
Render, RenderApp, RenderSet,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/motion_blur/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use bevy_ecs::{
system::{Commands, Query, Res, ResMut, Resource},
world::FromWorld,
};
use bevy_image::BevyDefault as _;
use bevy_render::{
globals::GlobalsUniform,
render_resource::{
Expand All @@ -19,7 +20,6 @@ use bevy_render::{
TextureFormat, TextureSampleType,
},
renderer::RenderDevice,
texture::BevyDefault,
view::{ExtractedView, Msaa, ViewTarget},
};

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/oit/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use bevy_ecs::{
entity::{EntityHashMap, EntityHashSet},
prelude::*,
};
use bevy_image::BevyDefault as _;
use bevy_render::{
render_resource::{
binding_types::{storage_buffer_sized, texture_depth_2d, uniform_buffer},
Expand All @@ -18,7 +19,6 @@ use bevy_render::{
Shader, ShaderDefVal, ShaderStages, TextureFormat,
},
renderer::{RenderAdapter, RenderDevice},
texture::BevyDefault,
view::{ExtractedView, ViewTarget, ViewUniform, ViewUniforms},
Render, RenderApp, RenderSet,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_core_pipeline/src/post_process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use bevy_ecs::{
system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::{BevyDefault, Image};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
camera::Camera,
Expand All @@ -32,7 +33,7 @@ use bevy_render::{
TextureDimension, TextureFormat, TextureSampleType,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
texture::{BevyDefault, GpuImage, Image},
texture::GpuImage,
view::{ExtractedView, ViewTarget},
Render, RenderApp, RenderSet,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use bevy_ecs::{
schedule::IntoSystemConfigs,
system::{Commands, Query, Res, ResMut, Resource},
};
use bevy_image::{BevyDefault, Image};
use bevy_math::{Mat4, Quat};
use bevy_render::{
camera::Exposure,
Expand All @@ -19,7 +20,7 @@ use bevy_render::{
*,
},
renderer::RenderDevice,
texture::{BevyDefault, GpuImage, Image},
texture::GpuImage,
view::{ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniforms},
Render, RenderApp, RenderSet,
};
Expand Down
35 changes: 14 additions & 21 deletions crates/bevy_core_pipeline/src/smaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
//!
//! [SMAA]: https://www.iryoku.com/smaa/

use crate::{
core_2d::graph::{Core2d, Node2d},
core_3d::graph::{Core3d, Node3d},
};
use bevy_app::{App, Plugin};
#[cfg(feature = "smaa_luts")]
use bevy_asset::load_internal_binary_asset;
Expand All @@ -44,6 +48,7 @@ use bevy_ecs::{
system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::{BevyDefault, Image};
use bevy_math::{vec4, Vec4};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
Expand All @@ -67,24 +72,12 @@ use bevy_render::{
VertexState,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
texture::{BevyDefault, CachedTexture, GpuImage, Image, TextureCache},
texture::{CachedTexture, GpuImage, TextureCache},
view::{ExtractedView, ViewTarget},
Render, RenderApp, RenderSet,
};
#[cfg(feature = "smaa_luts")]
use bevy_render::{
render_asset::RenderAssetUsages,
texture::{CompressedImageFormats, ImageFormat, ImageSampler, ImageType},
};
use bevy_utils::prelude::default;

#[cfg(not(feature = "smaa_luts"))]
use crate::tonemapping::lut_placeholder;
use crate::{
core_2d::graph::{Core2d, Node2d},
core_3d::graph::{Core3d, Node3d},
};

/// The handle of the `smaa.wgsl` shader.
const SMAA_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(12247928498010601081);
/// The handle of the area LUT, a KTX2 format texture that SMAA uses internally.
Expand Down Expand Up @@ -306,11 +299,11 @@ impl Plugin for SmaaPlugin {
#[cfg(all(debug_assertions, feature = "dds"))]
"SMAAAreaLUT".to_owned(),
bytes,
ImageType::Format(ImageFormat::Ktx2),
CompressedImageFormats::NONE,
bevy_image::ImageType::Format(bevy_image::ImageFormat::Ktx2),
bevy_image::CompressedImageFormats::NONE,
false,
ImageSampler::Default,
RenderAssetUsages::RENDER_WORLD,
bevy_image::ImageSampler::Default,
bevy_asset::RenderAssetUsages::RENDER_WORLD,
)
.expect("Failed to load SMAA area LUT")
);
Expand All @@ -324,11 +317,11 @@ impl Plugin for SmaaPlugin {
#[cfg(all(debug_assertions, feature = "dds"))]
"SMAASearchLUT".to_owned(),
bytes,
ImageType::Format(ImageFormat::Ktx2),
CompressedImageFormats::NONE,
bevy_image::ImageType::Format(bevy_image::ImageFormat::Ktx2),
bevy_image::CompressedImageFormats::NONE,
false,
ImageSampler::Default,
RenderAssetUsages::RENDER_WORLD,
bevy_image::ImageSampler::Default,
bevy_asset::RenderAssetUsages::RENDER_WORLD,
)
.expect("Failed to load SMAA search LUT")
);
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use bevy_ecs::{
system::{Commands, Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::BevyDefault as _;
use bevy_math::vec2;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
Expand All @@ -34,7 +35,7 @@ use bevy_render::{
renderer::{RenderContext, RenderDevice},
sync_component::SyncComponentPlugin,
sync_world::RenderEntity,
texture::{BevyDefault, CachedTexture, TextureCache},
texture::{CachedTexture, TextureCache},
view::{ExtractedView, Msaa, ViewTarget},
ExtractSchedule, MainWorld, Render, RenderApp, RenderSet,
};
Expand Down
17 changes: 9 additions & 8 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_image::{CompressedImageFormats, Image, ImageSampler, ImageType};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
camera::Camera,
Expand All @@ -13,7 +14,7 @@ use bevy_render::{
*,
},
renderer::RenderDevice,
texture::{CompressedImageFormats, FallbackImage, GpuImage, Image, ImageSampler, ImageType},
texture::{FallbackImage, GpuImage},
view::{ExtractedView, ViewTarget, ViewUniform},
Render, RenderApp, RenderSet,
};
Expand Down Expand Up @@ -433,14 +434,14 @@ pub fn get_lut_bind_group_layout_entries() -> [BindGroupLayoutEntryBuilder; 2] {
// allow(dead_code) so it doesn't complain when the tonemapping_luts feature is disabled
#[allow(dead_code)]
fn setup_tonemapping_lut_image(bytes: &[u8], image_type: ImageType) -> Image {
let image_sampler = ImageSampler::Descriptor(bevy_render::texture::ImageSamplerDescriptor {
let image_sampler = ImageSampler::Descriptor(bevy_image::ImageSamplerDescriptor {
label: Some("Tonemapping LUT sampler".to_string()),
address_mode_u: bevy_render::texture::ImageAddressMode::ClampToEdge,
address_mode_v: bevy_render::texture::ImageAddressMode::ClampToEdge,
address_mode_w: bevy_render::texture::ImageAddressMode::ClampToEdge,
mag_filter: bevy_render::texture::ImageFilterMode::Linear,
min_filter: bevy_render::texture::ImageFilterMode::Linear,
mipmap_filter: bevy_render::texture::ImageFilterMode::Linear,
address_mode_u: bevy_image::ImageAddressMode::ClampToEdge,
address_mode_v: bevy_image::ImageAddressMode::ClampToEdge,
address_mode_w: bevy_image::ImageAddressMode::ClampToEdge,
mag_filter: bevy_image::ImageFilterMode::Linear,
min_filter: bevy_image::ImageFilterMode::Linear,
mipmap_filter: bevy_image::ImageFilterMode::Linear,
..default()
});
Image::from_buffer(
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_gizmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bevy_sprite = { path = "../bevy_sprite", version = "0.15.0-rc.3", optional = tru
bevy_app = { path = "../bevy_app", version = "0.15.0-rc.3" }
bevy_color = { path = "../bevy_color", version = "0.15.0-rc.3" }
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-rc.3" }
bevy_image = { path = "../bevy_image", version = "0.15.0-rc.3" }
bevy_math = { path = "../bevy_math", version = "0.15.0-rc.3" }
bevy_asset = { path = "../bevy_asset", version = "0.15.0-rc.3" }
bevy_render = { path = "../bevy_render", version = "0.15.0-rc.3", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/pipeline_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use bevy_ecs::{
system::{Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::BevyDefault as _;
use bevy_math::FloatOrd;
use bevy_render::sync_world::MainEntity;
use bevy_render::{
Expand All @@ -22,7 +23,6 @@ use bevy_render::{
ViewSortedRenderPhases,
},
render_resource::*,
texture::BevyDefault,
view::{ExtractedView, Msaa, RenderLayers, ViewTarget},
Render, RenderApp, RenderSet,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/pipeline_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use bevy_ecs::{
system::{Query, Res, ResMut, Resource},
world::{FromWorld, World},
};
use bevy_image::BevyDefault as _;
use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup};
use bevy_render::sync_world::MainEntity;
use bevy_render::{
Expand All @@ -26,7 +27,6 @@ use bevy_render::{
ViewSortedRenderPhases,
},
render_resource::*,
texture::BevyDefault,
view::{ExtractedView, Msaa, RenderLayers, ViewTarget},
Render, RenderApp, RenderSet,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ pub use loader::*;
use bevy_app::prelude::*;
use bevy_asset::{Asset, AssetApp, AssetPath, Handle};
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_image::CompressedImageFormats;
use bevy_pbr::StandardMaterial;
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
use bevy_render::{
mesh::{skinning::SkinnedMeshInverseBindposes, Mesh, MeshVertexAttribute},
renderer::RenderDevice,
texture::CompressedImageFormats,
};
use bevy_scene::Scene;

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use bevy_ecs::{
world::World,
};
use bevy_hierarchy::{BuildChildren, ChildBuild, WorldChildBuilder};
use bevy_image::{
CompressedImageFormats, Image, ImageAddressMode, ImageFilterMode, ImageLoaderSettings,
ImageSampler, ImageSamplerDescriptor, ImageType, TextureError,
};
use bevy_math::{Affine2, Mat4, Vec3};
use bevy_pbr::{
DirectionalLight, MeshMaterial3d, PointLight, SpotLight, StandardMaterial, UvChannel,
Expand All @@ -31,10 +35,6 @@ use bevy_render::{
primitives::Aabb,
render_asset::RenderAssetUsages,
render_resource::{Face, PrimitiveTopology},
texture::{
CompressedImageFormats, Image, ImageAddressMode, ImageFilterMode, ImageLoaderSettings,
ImageSampler, ImageSamplerDescriptor, ImageType, TextureError,
},
view::Visibility,
};
use bevy_scene::Scene;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_image/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use core::hash::Hash;
use derive_more::derive::{Display, Error, From};
use serde::{Deserialize, Serialize};
use wgpu::{Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor};

pub trait BevyDefault {
fn bevy_default() -> Self;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_image/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#![allow(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![allow(unsafe_code)]

pub mod prelude {
pub use crate::{BevyDefault as _, Image, ImageFormat, TextureError};
}

mod image;
pub use self::image::*;
#[cfg(feature = "basis-universal")]
Expand Down
Loading

0 comments on commit 31ec575

Please sign in to comment.