Skip to content

Commit 0f3e6c1

Browse files
authored
Merge branch 'main' into frustum_halfspace_13945
2 parents f2d0610 + 6b175cf commit 0f3e6c1

File tree

6 files changed

+44
-38
lines changed

6 files changed

+44
-38
lines changed

crates/bevy_anti_alias/src/dlss/node.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ impl ViewNode for DlssNode<DlssSuperResolutionFeature> {
7272

7373
let diagnostics = render_context.diagnostic_recorder();
7474
let command_encoder = render_context.command_encoder();
75-
let mut dlss_context = dlss_context.context.lock().unwrap();
76-
77-
command_encoder.push_debug_group("dlss_super_resolution");
7875
let time_span = diagnostics.time_span(command_encoder, "dlss_super_resolution");
7976

77+
let mut dlss_context = dlss_context.context.lock().unwrap();
8078
let dlss_command_buffer = dlss_context
8179
.render(render_parameters, command_encoder, &adapter)
8280
.expect("Failed to render DLSS Super Resolution");
8381

84-
time_span.end(command_encoder);
85-
command_encoder.pop_debug_group();
8682
render_context.add_command_buffer(dlss_command_buffer);
83+
time_span.end(render_context.command_encoder());
8784

8885
Ok(())
8986
}
@@ -149,19 +146,15 @@ impl ViewNode for DlssNode<DlssRayReconstructionFeature> {
149146

150147
let diagnostics = render_context.diagnostic_recorder();
151148
let command_encoder = render_context.command_encoder();
152-
let mut dlss_context = dlss_context.context.lock().unwrap();
153-
154-
command_encoder.push_debug_group("dlss_ray_reconstruction");
155149
let time_span = diagnostics.time_span(command_encoder, "dlss_ray_reconstruction");
156150

151+
let mut dlss_context = dlss_context.context.lock().unwrap();
157152
let dlss_command_buffer = dlss_context
158153
.render(render_parameters, command_encoder, &adapter)
159154
.expect("Failed to render DLSS Ray Reconstruction");
160155

161-
time_span.end(command_encoder);
162-
command_encoder.pop_debug_group();
163-
164156
render_context.add_command_buffer(dlss_command_buffer);
157+
time_span.end(render_context.command_encoder());
165158

166159
Ok(())
167160
}

crates/bevy_render/src/diagnostic/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::renderer::{RenderDevice, RenderQueue};
4646
/// ```ignore
4747
/// let time_span = diagnostics.time_span(render_context.command_encoder(), "shadows");
4848
/// ```
49-
/// 3. End the span, providing the same encoder.
49+
/// 3. End the span, providing the encoder (or the same render/compute pass).
5050
/// ```ignore
5151
/// time_span.end(render_context.command_encoder());
5252
/// ```
@@ -151,7 +151,7 @@ pub struct TimeSpanGuard<'a, R: ?Sized, E> {
151151
}
152152

153153
impl<R: RecordDiagnostics + ?Sized, E: WriteTimestamp> TimeSpanGuard<'_, R, E> {
154-
/// End the span. You have to provide the same encoder which was used to begin the span.
154+
/// End the span.
155155
pub fn end(self, encoder: &mut E) {
156156
self.recorder.end_time_span(encoder);
157157
core::mem::forget(self);

crates/bevy_solari/src/realtime/restir_gi.wgsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enable wgpu_ray_query;
1212
#import bevy_solari::scene_bindings::{trace_ray, resolve_ray_hit_full, RAY_T_MIN, RAY_T_MAX}
1313
#import bevy_solari::world_cache::{query_world_cache, WORLD_CACHE_CELL_LIFETIME}
1414
#import bevy_solari::realtime_bindings::{view_output, gi_reservoirs_a, gi_reservoirs_b, gbuffer, depth_buffer, motion_vectors, previous_gbuffer, previous_depth_buffer, view, previous_view, constants, Reservoir}
15+
#import bevy_solari::specular_gi::DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD
1516

1617
const SPATIAL_REUSE_RADIUS_PIXELS = 30.0;
1718
const CONFIDENCE_WEIGHT_CAP = 8.0;
@@ -29,6 +30,10 @@ fn initial_and_temporal(@builtin(global_invocation_id) global_id: vec3<u32>) {
2930
return;
3031
}
3132
let surface = gpixel_resolve(textureLoad(gbuffer, global_id.xy, 0), depth, global_id.xy, view.main_pass_viewport.zw, view.world_from_clip);
33+
if surface.material.metallic > 0.9999 && surface.material.roughness <= DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD {
34+
gi_reservoirs_b[pixel_index] = empty_reservoir();
35+
return;
36+
}
3237

3338
let initial_reservoir = generate_initial_reservoir(surface.world_position, surface.world_normal, &rng);
3439
let temporal = load_temporal_reservoir(global_id.xy, depth, surface.world_position, surface.world_normal);
@@ -51,6 +56,10 @@ fn spatial_and_shade(@builtin(global_invocation_id) global_id: vec3<u32>) {
5156
return;
5257
}
5358
let surface = gpixel_resolve(textureLoad(gbuffer, global_id.xy, 0), depth, global_id.xy, view.main_pass_viewport.zw, view.world_from_clip);
59+
if surface.material.metallic > 0.9999 && surface.material.roughness <= DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD {
60+
gi_reservoirs_a[pixel_index] = empty_reservoir();
61+
return;
62+
}
5463

5564
let input_reservoir = gi_reservoirs_b[pixel_index];
5665
let spatial = load_spatial_reservoir(global_id.xy, depth, surface.world_position, surface.world_normal, &rng);

crates/bevy_text/src/pipeline.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_ecs::{
66
system::ResMut,
77
};
88
use bevy_image::prelude::*;
9-
use bevy_log::{once, warn};
9+
use bevy_log::warn_once;
1010
use bevy_math::{Rect, UVec2, Vec2};
1111
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
1212

@@ -166,9 +166,7 @@ impl TextPipeline {
166166
computed.needs_rerender = false;
167167

168168
if scale_factor <= 0.0 {
169-
once!(warn!(
170-
"Text scale factor is <= 0.0. No text will be displayed.",
171-
));
169+
warn_once!("Text scale factor is <= 0.0. No text will be displayed.",);
172170

173171
return Err(TextError::DegenerateScaleFactor);
174172
}
@@ -212,13 +210,24 @@ impl TextPipeline {
212210

213211
// Save spans that aren't zero-sized.
214212
if text_font.font_size <= 0.0 {
215-
once!(warn!(
213+
warn_once!(
216214
"Text span {entity} has a font size <= 0.0. Nothing will be displayed.",
217-
));
215+
);
218216

219217
continue;
220218
}
221219

220+
const WARN_FONT_SIZE: f32 = 1000.0;
221+
if text_font.font_size * scale_factor as f32 > WARN_FONT_SIZE {
222+
warn_once!(
223+
"Text span {entity} has an excessively large font size ({} with scale factor {}). \
224+
Extremely large font sizes will cause performance issues with font atlas \
225+
generation and high memory usage.",
226+
text_font.font_size,
227+
scale_factor,
228+
);
229+
}
230+
222231
let attrs = get_attrs(span_index, text_font, line_height, family, scale_factor);
223232

224233
sections.push((span, attrs));
@@ -583,19 +592,22 @@ fn get_attrs<'a>(
583592
family: Family<'a>,
584593
scale_factor: f64,
585594
) -> Attrs<'a> {
595+
let font_size = (text_font.font_size * scale_factor as f32).round();
596+
let line_height = match line_height {
597+
LineHeight::Px(px) => px * scale_factor as f32,
598+
LineHeight::RelativeToFont(s) => s * font_size,
599+
};
600+
586601
Attrs::new()
587602
.metadata(span_index)
588603
.family(family)
589604
.stretch(text_font.width.into())
590605
.style(text_font.style.into())
591606
.weight(text_font.weight.into())
592-
.metrics(
593-
Metrics {
594-
font_size: text_font.font_size,
595-
line_height: line_height.eval(text_font.font_size),
596-
}
597-
.scale(scale_factor as f32),
598-
)
607+
.metrics(Metrics {
608+
font_size,
609+
line_height,
610+
})
599611
.font_features((&text_font.font_features).into())
600612
}
601613

crates/bevy_text/src/text.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,9 @@ pub struct TextFont {
368368
pub font: FontSource,
369369
/// The vertical height of rasterized glyphs in the font atlas in pixels.
370370
///
371-
/// This is multiplied by the window scale factor and `UiScale`, but not the text entity
372-
/// transform or camera projection.
371+
/// This is multiplied by the window scale factor and `UiScale`, but not the text entity's
372+
/// transform or camera projection. Then, the scaled font size is rounded to the nearest pixel
373+
/// to produce the final font size used during glyph layout.
373374
///
374375
/// A new font atlas is generated for every combination of font handle and scaled font size
375376
/// which can have a strong performance impact.
@@ -794,15 +795,6 @@ pub enum LineHeight {
794795
RelativeToFont(f32),
795796
}
796797

797-
impl LineHeight {
798-
pub(crate) fn eval(self, font_size: f32) -> f32 {
799-
match self {
800-
LineHeight::Px(px) => px,
801-
LineHeight::RelativeToFont(scale) => scale * font_size,
802-
}
803-
}
804-
}
805-
806798
impl Default for LineHeight {
807799
fn default() -> Self {
808800
LineHeight::RelativeToFont(1.2)

examples/3d/solari.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ fn update_performance_text(
601601
"Specular indirect",
602602
"render/solari_lighting/specular_indirect_lighting/elapsed_gpu",
603603
);
604-
text.push_str(&format!("{:17} TODO\n", "DLSS-RR"));
604+
(add_diagnostic)("DLSS-RR", "render/dlss_ray_reconstruction/elapsed_gpu");
605605
text.push_str(&format!("{:17} {total:.2} ms\n", "Total"));
606606

607607
if let Some(world_cache_active_cells_count) = diagnostics

0 commit comments

Comments
 (0)