Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions examples/headless/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
);

// Create a color texture to render into
let mut texture = Texture2D::new_empty::<[u8; 4]>(
let texture = Texture2D::new_empty::<[u8; 4]>(
&context,
viewport.width,
viewport.height,
Expand All @@ -51,7 +51,7 @@ fn main() {
);

// Also create a depth texture to support depth testing
let mut depth_texture = DepthTexture2D::new::<f32>(
let depth_texture = DepthTexture2D::new::<f32>(
&context,
viewport.width,
viewport.height,
Expand Down
2 changes: 1 addition & 1 deletion examples/image/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub async fn run() {
..Default::default()
};

let mut target = Texture2D::new_empty::<[f16; 4]>(
let target = Texture2D::new_empty::<[f16; 4]>(
&context,
viewport.width,
viewport.height,
Expand Down
4 changes: 2 additions & 2 deletions examples/multisample/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn main() {

RenderMethod::ToTexture => {
// Render the shapes to a non-multisample texture, and copy the color texture to the screen.
let mut color_texture = Texture2D::new_empty::<[u8; 4]>(
let color_texture = Texture2D::new_empty::<[u8; 4]>(
&context,
frame_input.viewport.width,
frame_input.viewport.height,
Expand All @@ -144,7 +144,7 @@ pub fn main() {
Wrapping::ClampToEdge,
Wrapping::ClampToEdge,
);
let mut depth_texture = DepthTexture2D::new::<f32>(
let depth_texture = DepthTexture2D::new::<f32>(
&context,
frame_input.viewport.width,
frame_input.viewport.height,
Expand Down
2 changes: 1 addition & 1 deletion src/core/render_target/color_target_multisample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<C: TextureDataType> ColorTargetMultisample<C> {
/// Use [ColorTargetMultisample::resolve_to] to resolve to a custom non-multisample texture.
///
pub fn resolve(&self) -> Texture2D {
let mut color_texture = Texture2D::new_empty::<C>(
let color_texture = Texture2D::new_empty::<C>(
&self.context,
self.width(),
self.height(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/render_target/depth_target_multisample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<D: DepthTextureDataType> DepthTargetMultisample<D> {
/// Use [DepthTargetMultisample::resolve_to] to resolve to a custom non-multisample texture.
///
pub fn resolve(&self) -> DepthTexture2D {
let mut depth_texture = DepthTexture2D::new::<D>(
let depth_texture = DepthTexture2D::new::<D>(
&self.context,
self.width(),
self.height(),
Expand Down
8 changes: 4 additions & 4 deletions src/core/render_target/multisample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<C: TextureDataType, D: DepthTextureDataType> RenderTargetMultisample<C, D>
/// Use [RenderTargetMultisample::resolve_color_to] to resolve to a custom non-multisample texture.
///
pub fn resolve_color(&self) -> Texture2D {
let mut color_texture = Texture2D::new_empty::<C>(
let color_texture = Texture2D::new_empty::<C>(
&self.context,
self.color.width(),
self.color.height(),
Expand All @@ -148,7 +148,7 @@ impl<C: TextureDataType, D: DepthTextureDataType> RenderTargetMultisample<C, D>
/// Use [RenderTargetMultisample::resolve_depth_to] to resolve to a custom non-multisample texture.
///
pub fn resolve_depth(&self) -> DepthTexture2D {
let mut depth_texture = DepthTexture2D::new::<D>(
let depth_texture = DepthTexture2D::new::<D>(
&self.context,
self.width(),
self.height(),
Expand All @@ -164,7 +164,7 @@ impl<C: TextureDataType, D: DepthTextureDataType> RenderTargetMultisample<C, D>
/// Use [RenderTargetMultisample::resolve_to] to resolve to custom non-multisample textures.
///
pub fn resolve(&self) -> (Texture2D, DepthTexture2D) {
let mut color_texture = Texture2D::new_empty::<C>(
let color_texture = Texture2D::new_empty::<C>(
&self.context,
self.color.width(),
self.color.height(),
Expand All @@ -174,7 +174,7 @@ impl<C: TextureDataType, D: DepthTextureDataType> RenderTargetMultisample<C, D>
Wrapping::ClampToEdge,
Wrapping::ClampToEdge,
);
let mut depth_texture = DepthTexture2D::new::<D>(
let depth_texture = DepthTexture2D::new::<D>(
&self.context,
self.width(),
self.height(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/texture/depth_texture2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl DepthTexture2D {
/// Returns a [DepthTarget] which can be used to clear, write to and read from this texture.
/// Combine this together with a [ColorTarget] with [RenderTarget::new] to be able to write to both a depth and color target at the same time.
///
pub fn as_depth_target(&mut self) -> DepthTarget<'_> {
pub fn as_depth_target(&self) -> DepthTarget<'_> {
DepthTarget::new_texture2d(&self.context, self)
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/texture/depth_texture2d_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl DepthTexture2DArray {
/// Returns a [DepthTarget] which can be used to clear, write to and read from the given layer of this texture.
/// Combine this together with a [ColorTarget] with [RenderTarget::new] to be able to write to both a depth and color target at the same time.
///
pub fn as_depth_target(&mut self, layer: u32) -> DepthTarget<'_> {
pub fn as_depth_target(&self, layer: u32) -> DepthTarget<'_> {
DepthTarget::new_texture_2d_array(&self.context, self, layer)
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/texture/depth_texture_cube_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl DepthTextureCubeMap {
/// Returns a [DepthTarget] which can be used to clear, write to and read from the given side of this texture.
/// Combine this together with a [ColorTarget] with [RenderTarget::new] to be able to write to both a depth and color target at the same time.
///
pub fn as_depth_target(&mut self, side: CubeMapSide) -> DepthTarget<'_> {
pub fn as_depth_target(&self, side: CubeMapSide) -> DepthTarget<'_> {
DepthTarget::new_texture_cube_map(&self.context, self, side)
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/texture/texture2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Texture2D {
///
/// **Note:** [DepthTest] is disabled if not also writing to a depth texture.
///
pub fn as_color_target(&mut self, mip_level: Option<u32>) -> ColorTarget<'_> {
pub fn as_color_target(&self, mip_level: Option<u32>) -> ColorTarget<'_> {
ColorTarget::new_texture2d(&self.context, self, mip_level)
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/texture/texture2d_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Texture2DArray {
cpu_texture: &CpuTexture,
data: &[&[T]],
) -> Self {
let mut texture = Self::new_empty::<T>(
let texture = Self::new_empty::<T>(
context,
cpu_texture.width,
cpu_texture.height,
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Texture2DArray {
/// Will panic if the data does not correspond to the width, height, depth and format specified at construction.
/// It is therefore necessary to create a new texture if the texture size or format has changed.
///
pub fn fill<T: TextureDataType>(&mut self, data: &[&[T]]) {
pub fn fill<T: TextureDataType>(&self, data: &[&[T]]) {
for (i, data) in data.iter().enumerate() {
self.fill_layer(i as u32, data);
}
Expand All @@ -205,7 +205,7 @@ impl Texture2DArray {
/// Will panic if the layer number is bigger than the number of layers or if the data does not correspond to the width, height and format specified at construction.
/// It is therefore necessary to create a new texture if the texture size or format has changed.
///
pub fn fill_layer<T: TextureDataType>(&mut self, layer: u32, data: &[T]) {
pub fn fill_layer<T: TextureDataType>(&self, layer: u32, data: &[T]) {
if layer >= self.depth {
panic!(
"cannot fill the layer {} with data, since there are only {} layers in the texture array",
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Texture2DArray {
/// **Note:** [DepthTest] is disabled if not also writing to a depth texture.
///
pub fn as_color_target<'a>(
&'a mut self,
&'a self,
layers: &'a [u32],
mip_level: Option<u32>,
) -> ColorTarget<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/core/texture/texture3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Texture3D {
cpu_texture: &CpuTexture3D,
data: &[T],
) -> Self {
let mut texture = Self::new_empty::<T>(
let texture = Self::new_empty::<T>(
context,
cpu_texture.width,
cpu_texture.height,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Texture3D {
/// Will panic if the length of the data does not correspond to the width, height, depth and format specified at construction.
/// It is therefore necessary to create a new texture if the texture size or format has changed.
///
pub fn fill<T: TextureDataType>(&mut self, data: &[T]) {
pub fn fill<T: TextureDataType>(&self, data: &[T]) {
check_data_length::<T>(
self.width,
self.height,
Expand Down
8 changes: 4 additions & 4 deletions src/core/texture/texture_cube_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl TextureCubeMap {
front_data: &[T],
back_data: &[T],
) -> Self {
let mut texture = Self::new_empty::<T>(
let texture = Self::new_empty::<T>(
context,
cpu_texture.width,
cpu_texture.height,
Expand Down Expand Up @@ -346,7 +346,7 @@ impl TextureCubeMap {
/// It is therefore necessary to create a new texture if the texture size or format has changed.
///
pub fn fill<T: TextureDataType>(
&mut self,
&self,
right_data: &[T],
left_data: &[T],
top_data: &[T],
Expand Down Expand Up @@ -432,7 +432,7 @@ impl TextureCubeMap {
cpu_texture: &CpuTexture,
) -> Self {
let texture_size = cpu_texture.width / 4;
let mut texture = Self::new_empty::<[T; 4]>(
let texture = Self::new_empty::<[T; 4]>(
context,
texture_size,
texture_size,
Expand Down Expand Up @@ -497,7 +497,7 @@ impl TextureCubeMap {
/// **Note:** [DepthTest] is disabled if not also writing to a depth texture.
///
pub fn as_color_target<'a>(
&'a mut self,
&'a self,
sides: &'a [CubeMapSide],
mip_level: Option<u32>,
) -> ColorTarget<'a> {
Expand Down
8 changes: 4 additions & 4 deletions src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ macro_rules! impl_render_target_extensions_body {
let geometry_pass_camera = GeometryPassCamera(&viewer);
let viewport = geometry_pass_camera.viewport();
deferred_objects.sort_by(|a, b| cmp_render_order(&geometry_pass_camera, a, b));
let mut geometry_pass_texture = Texture2DArray::new_empty::<[u8; 4]>(
let geometry_pass_texture = Texture2DArray::new_empty::<[u8; 4]>(
&self.context,
viewport.width,
viewport.height,
Expand All @@ -116,7 +116,7 @@ macro_rules! impl_render_target_extensions_body {
Wrapping::ClampToEdge,
Wrapping::ClampToEdge,
);
let mut geometry_pass_depth_texture = DepthTexture2D::new::<f32>(
let geometry_pass_depth_texture = DepthTexture2D::new::<f32>(
&self.context,
viewport.width,
viewport.height,
Expand Down Expand Up @@ -641,7 +641,7 @@ pub fn ray_intersect(
0.0,
max_depth,
);
let mut texture = Texture2D::new_empty::<[f32; 4]>(
let texture = Texture2D::new_empty::<[f32; 4]>(
context,
viewport.width,
viewport.height,
Expand All @@ -651,7 +651,7 @@ pub fn ray_intersect(
Wrapping::ClampToEdge,
Wrapping::ClampToEdge,
);
let mut depth_texture = DepthTexture2D::new::<f32>(
let depth_texture = DepthTexture2D::new::<f32>(
context,
viewport.width,
viewport.height,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/light/directional_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl DirectionalLight {
z_near,
z_far,
);
let mut shadow_texture = DepthTexture2D::new::<f32>(
let shadow_texture = DepthTexture2D::new::<f32>(
&self.context,
texture_size,
texture_size,
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/light/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Environment {
) -> Self {
// Diffuse
let irradiance_size = 32;
let mut irradiance_map = TextureCubeMap::new_empty::<[f16; 4]>(
let irradiance_map = TextureCubeMap::new_empty::<[f16; 4]>(
context,
irradiance_size,
irradiance_size,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl Environment {

// Prefilter
let prefilter_size = 128;
let mut prefilter_map = TextureCubeMap::new_empty::<[f16; 4]>(
let prefilter_map = TextureCubeMap::new_empty::<[f16; 4]>(
context,
prefilter_size,
prefilter_size,
Expand Down Expand Up @@ -108,7 +108,7 @@ impl Environment {
}

// BRDF
let mut brdf_map = Texture2D::new_empty::<[f32; 2]>(
let brdf_map = Texture2D::new_empty::<[f32; 2]>(
context,
512,
512,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/light/spot_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl SpotLight {
);
self.shadow_matrix = shadow_matrix(&shadow_camera);

let mut shadow_texture = DepthTexture2D::new::<f32>(
let shadow_texture = DepthTexture2D::new::<f32>(
&self.context,
texture_size,
texture_size,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/object/imposters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl ImpostersMaterial {
Wrapping::ClampToEdge,
Wrapping::ClampToEdge,
);
let mut depth_texture = DepthTexture2D::new::<f32>(
let depth_texture = DepthTexture2D::new::<f32>(
&self.context,
texture_width,
texture_height,
Expand Down
Loading