Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Render: a size the CPU profile can't render names the profile that can (#8941) (#8943)

HiroKenEzdb0c25522efe
diff --git a/assets/locales/pending/render-size-cpu-profile.json b/assets/locales/pending/render-size-cpu-profile.json
new file mode 100644
index 0000000000..61a6cca753
--- /dev/null
+++ b/assets/locales/pending/render-size-cpu-profile.json
@@ -0,0 +1,42 @@
+{
+ "en": {
+ "render.output_size_profile": "To render {width} × {height}, choose the {profile} CPU resource profile, or a smaller size.",
+ "render.size_needs_profile": "{size} · needs {profile}",
+ "render.output_size_method_profile": "To render {width} × {height}, choose {method} with the {profile} CPU resource profile, or a smaller size."
+ },
+ "ar": {
+ "render.output_size_profile": "لعرض {width} × {height}، اختر ملف موارد CPU «{profile}» أو حجمًا أصغر.",
+ "render.size_needs_profile": "{size} · يتطلب «{profile}»",
+ "render.output_size_method_profile": "لعرض {width} × {height}، اختر {method} مع ملف موارد CPU «{profile}» أو حجمًا أصغر."
+ },
+ "de": {
+ "render.output_size_profile": "Für {width} × {height} das CPU-Ressourcenprofil {profile} wählen oder eine kleinere Größe.",
+ "render.size_needs_profile": "{size} · erfordert {profile}",
+ "render.output_size_method_profile": "Für {width} × {height} {method} mit dem CPU-Ressourcenprofil {profile} wählen oder eine kleinere Größe."
+ },
+ "he": {
+ "render.output_size_profile": "כדי לרנדר {width} × {height}, יש לבחור בפרופיל משאבי CPU {profile} או בגודל קטן יותר.",
+ "render.size_needs_profile": "{size} · נדרש {profile}",
+ "render.output_size_method_profile": "כדי לרנדר {width} × {height}, יש לבחור ב-{method} עם פרופיל משאבי CPU {profile} או בגודל קטן יותר."
+ },
+ "ja": {
+ "render.output_size_profile": "{width} × {height} をレンダリングするには、CPUリソースプロファイル「{profile}」を選ぶか、より小さいサイズを選んでください。",
+ "render.size_needs_profile": "{size}・「{profile}」が必要",
+ "render.output_size_method_profile": "{width} × {height} をレンダリングするには、{method} と CPUリソースプロファイル「{profile}」を選ぶか、より小さいサイズを選んでください。"
+ },
+ "ko": {
+ "render.output_size_profile": "{width} × {height}을(를) 렌더링하려면 {profile} CPU 리소스 프로필이나 더 작은 크기를 선택하세요.",
+ "render.size_needs_profile": "{size} · {profile} 필요",
+ "render.output_size_method_profile": "{width} × {height}을(를) 렌더링하려면 {method}와(과) {profile} CPU 리소스 프로필을 선택하거나 더 작은 크기를 선택하세요."
+ },
+ "vi": {
+ "render.output_size_profile": "Để kết xuất {width} × {height}, hãy chọn cấu hình tài nguyên CPU {profile} hoặc một kích thước nhỏ hơn.",
+ "render.size_needs_profile": "{size} · cần {profile}",
+ "render.output_size_method_profile": "Để kết xuất {width} × {height}, hãy chọn {method} với cấu hình tài nguyên CPU {profile} hoặc một kích thước nhỏ hơn."
+ },
+ "zh": {
+ "render.output_size_profile": "要渲染 {width} × {height},请选择“{profile}”CPU 资源配置,或选择更小的尺寸。",
+ "render.size_needs_profile": "{size} · 需要“{profile}”",
+ "render.output_size_method_profile": "要渲染 {width} × {height},请选择 {method} 和“{profile}”CPU 资源配置,或选择更小的尺寸。"
+ }
+}
diff --git a/crates/doc/src/render_settings.rs b/crates/doc/src/render_settings.rs
index 4bec6f7c23..1d575648be 100644
--- a/crates/doc/src/render_settings.rs
+++ b/crates/doc/src/render_settings.rs
@@ -39,6 +39,12 @@ pub struct RenderSetup {
pub stage: solidcraft_render::stage::Stage,
}
+/// The CPU request a size check belongs to, so a refusal can name the profile that admits it.
+#[derive(Clone, Copy)]
+struct CpuSize {
+ progressive: Option<solidcraft_render::job::CpuProgressiveOptions>,
+}
+
// Reuse Camera's representation and defaults, but reject misspelled saved fields. A remote
// derive constructs Camera itself, so adding a Camera field requires updating this adapter.
// Navigation/named-view deserialization keeps its existing compatibility policy.
@@ -80,27 +86,29 @@ impl Default for RenderSetup {
impl RenderSetup {
pub fn validate(&self) -> Result<()> {
- let limits = match &self.job {
- Some(RenderJob::CpuRaytrace { options }) => options.budget.image_limits(options.progressive.is_some()),
- Some(RenderJob::GpuPath { .. }) => solidcraft_render::job::GPU_PATH_LIMITS,
- _ => RenderLimits::default(),
+ let (limits, cpu) = match &self.job {
+ Some(RenderJob::CpuRaytrace { options }) => {
+ (options.budget.image_limits(options.progressive.is_some()), Some(CpuSize { progressive: options.progressive }))
+ }
+ Some(RenderJob::GpuPath { .. }) => (solidcraft_render::job::GPU_PATH_LIMITS, None),
+ _ => (RenderLimits::default(), None),
};
- self.validate_with_limits(limits)
+ self.validate_with_limits(limits, cpu)
}
/// Runtime CPU lowering has already moved typed options out of this setup.
/// Saving still uses validate(), so a legacy setup cannot smuggle a large profile.
pub fn validate_for_cpu(&self, budget: solidcraft_render::job::CpuBudget) -> Result<()> {
budget.validate_image(self.width, self.height, None).map_err(|e| DocError::Invalid(e.to_string()))?;
- self.validate_with_limits(budget.image_limits(false))
+ self.validate_with_limits(budget.image_limits(false), Some(CpuSize { progressive: None }))
}
/// Typed GPU options have already been lowered; retain their dimension envelope.
pub fn validate_for_gpu(&self) -> Result<()> {
- self.validate_with_limits(solidcraft_render::job::GPU_PATH_LIMITS)
+ self.validate_with_limits(solidcraft_render::job::GPU_PATH_LIMITS, None)
}
- fn validate_with_limits(&self, limits: RenderLimits) -> Result<()> {
+ fn validate_with_limits(&self, limits: RenderLimits, cpu: Option<CpuSize>) -> Result<()> {
self.surfaces.validate()?;
self.optics.validate()?;
if !self.optics.is_empty() && !matches!(self.job, Some(RenderJob::GpuPath { .. })) {
@@ -123,9 +131,14 @@ impl RenderSetup {
if let Some((w, h)) = limits.fit(width, height, None)
&& (w, h) != (width, height)
{
+ // A CPU refusal names the profile that can render the size (#8941). It is never
+ // selected for the person: resolution and profile change only when they choose.
+ let advice = cpu.map_or_else(String::new, |cpu| {
+ format!("; {}", solidcraft_render::job::CpuBudget::size_advice(self.width, self.height, cpu.progressive))
+ });
return Err(DocError::Invalid(format!(
"render output {width} × {height} exceeds the image limits ({} pixels per side, {} pixels in all); \
- the largest image at this aspect is {w} × {h}",
+ the largest image at this aspect is {w} × {h}{advice}",
limits.max_dimension, limits.max_pixels
)));
}
@@ -538,9 +551,58 @@ mod tests {
let setup = RenderSetup { width: 7680, height: 4320, ..Default::default() };
let message = setup.validate().unwrap_err().to_string();
assert!(message.contains("the largest image at this aspect is 27"), "{message}");
+ assert!(!message.contains("CPU resource profile"), "a raster refusal names no CPU profile: {message}");
assert!(RenderSetup { width: 2048, height: 2048, ..Default::default() }.validate().is_ok());
}
+ /// #8941: 4K UHD under the default Compact profile names Studio, the profile that renders it;
+ /// a 16K-wide image under Studio names Workstation; past Workstation no profile is named.
+ /// The saved profile is never changed by the check, and GPU path tracing keeps its own limits.
+ #[test]
+ fn a_cpu_size_refusal_names_the_profile_that_can_render_it() {
+ use solidcraft_render::job::CpuBudget;
+ let cpu = |budget, width, height| RenderSetup {
+ width,
+ height,
+ job: Some(RenderJob::CpuRaytrace { options: CpuJob { budget, ..Default::default() } }),
+ ..Default::default()
+ };
+ let compact = cpu(CpuBudget::Compact, 3840, 2160);
+ let message = compact.validate().unwrap_err().to_string();
+ assert!(message.contains("3840 × 2160 exceeds the image limits (4096 pixels per side, 4194304 pixels in all)"), "{message}");
+ assert!(message.contains("the largest image at this aspect is 2730 × 1536"), "{message}");
+ assert!(message.contains("choose the Studio CPU resource profile, or a smaller size"), "{message}");
+ assert!(matches!(&compact.job, Some(RenderJob::CpuRaytrace { options }) if options.budget == CpuBudget::Compact));
+ let message = compact.validate_for_cpu(CpuBudget::Compact).unwrap_err().to_string();
+ assert!(message.contains("choose the Studio CPU resource profile"), "{message}");
+
+ cpu(CpuBudget::Studio, 3840, 2160).validate().unwrap();
+ RenderSetup { width: 3840, height: 2160, ..Default::default() }.validate_for_cpu(CpuBudget::Studio).unwrap();
+
+ let message = cpu(CpuBudget::Studio, 15360, 4320).validate().unwrap_err().to_string();
+ assert!(message.contains("choose the Workstation CPU resource profile"), "{message}");
+ cpu(CpuBudget::Workstation, 15360, 4320).validate().unwrap();
+
+ let message = cpu(CpuBudget::Workstation, 16384, 16384).validate().unwrap_err().to_string();
+ assert!(message.contains("no CPU resource profile accepts this size; choose a smaller size"), "{message}");
+ for profile in ["Compact", "Studio", "Workstation"] {
+ assert!(!message.contains(&format!("the {profile} CPU")), "{message}");
+ }
+
+ // GPU path tracing: 4K renders, an over-limit size names no CPU profile.
+ let gpu = |width, height| RenderSetup {
+ width,
+ height,
+ job: Some(RenderJob::GpuPath { transparent_background: false, options: Default::default() }),
+ ..Default::default()
+ };
+ gpu(3840, 2160).validate().unwrap();
+ gpu(3840, 2160).validate_for_gpu().unwrap();
+ let message = gpu(8193, 8193).validate().unwrap_err().to_string();
+ assert!(message.contains("(8192 pixels per side, 16777216 pixels in all)"), "{message}");
+ assert!(!message.contains("CPU resource profile"), "{message}");
+ }
+
#[test]
fn portable_jobs_preserve_complete_numerical_intent_and_legacy_omission() {
use serde_json::json;
diff --git a/crates/render/src/job/cpu_budget.rs b/crates/render/src/job/cpu_budget.rs
index fa3cd6469d..0494419f8d 100644
--- a/crates/render/src/job/cpu_budget.rs
+++ b/crates/render/src/job/cpu_budget.rs
@@ -104,17 +104,54 @@ impl CpuBudget {
Ok(())
}
+ /// The smallest profile that admits this image, to name in a refusal. It is never
+ /// selected automatically: the person chooses it. `None` when no profile admits it.
+ pub fn smallest_admitting(width: u32, height: u32, progressive: Option<CpuProgressiveOptions>) -> Option<Self> {
+ Self::ALL.into_iter().find(|budget| budget.admits_image(width, height, progressive))
+ }
+
+ /// What `validate_image` accepts, without building its message (which names a profile).
+ fn admits_image(self, width: u32, height: u32, progressive: Option<CpuProgressiveOptions>) -> bool {
+ let (w, h) = (u64::from(width), u64::from(height));
+ let limits = self.image_limits(progressive.is_some());
+ let Some(pixels) = w.checked_mul(h) else { return false };
+ w > 0
+ && h > 0
+ && w <= limits.max_dimension
+ && h <= limits.max_dimension
+ && pixels <= limits.max_pixels
+ && progressive.is_none_or(|options| {
+ let samples = options.samples_per_pixel;
+ (1..=self.limits().max_samples_per_pixel).contains(&samples)
+ && pixels.checked_mul(u64::from(samples)).is_some_and(|n| n <= self.limits().max_camera_samples)
+ })
+ }
+
+ /// The way out of a size refusal, for English messages: the profile that can render
+ /// the image, or only a smaller size when none can.
+ pub fn size_advice(width: u32, height: u32, progressive: Option<CpuProgressiveOptions>) -> String {
+ match Self::smallest_admitting(width, height, progressive) {
+ Some(budget) => format!("choose the {budget:?} CPU resource profile, or a smaller size"),
+ None => "no CPU resource profile accepts this size; choose a smaller size".into(),
+ }
+ }
+
/// No geometry reads or allocations. This also validates offline saved intent.
pub fn validate_image(self, width: u32, height: u32, progressive: Option<CpuProgressiveOptions>) -> Result<()> {
let (w, h) = (u64::from(width), u64::from(height));
let limits = self.image_limits(progressive.is_some());
let pixels = w.checked_mul(h).ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "CPU pixel count overflow"))?;
- if w == 0 || h == 0 || w > limits.max_dimension || h > limits.max_dimension || pixels > limits.max_pixels {
+ if w == 0 || h == 0 {
+ return Err(JobError::new(ErrorCode::LimitExceeded, format!("CPU {self:?} accepts dimensions 1..{}", limits.max_dimension)));
+ }
+ if w > limits.max_dimension || h > limits.max_dimension || pixels > limits.max_pixels {
return Err(JobError::new(
ErrorCode::LimitExceeded,
format!(
- "CPU {self:?} accepts dimensions 1..{} and at most {} pixels; select a larger resource profile explicitly",
- limits.max_dimension, limits.max_pixels
+ "CPU {self:?} accepts dimensions 1..{} and at most {} pixels; {}",
+ limits.max_dimension,
+ limits.max_pixels,
+ Self::size_advice(width, height, progressive)
),
));
}
@@ -173,4 +210,39 @@ mod tests {
assert!(CpuBudget::Workstation.validate_image(8192, 8192, p).is_err());
assert!(CpuBudget::Workstation.validate_image(3840, 2160, p).is_ok());
}
+
+ /// #8941: a size refusal names the smallest profile that admits the image, and none when
+ /// even Workstation refuses it. The profile is only named, never selected.
+ #[test]
+ fn a_size_refusal_names_the_smallest_profile_that_admits_it() {
+ assert_eq!(CpuBudget::smallest_admitting(1920, 1080, None), Some(CpuBudget::Compact));
+ assert_eq!(CpuBudget::smallest_admitting(3840, 2160, None), Some(CpuBudget::Studio));
+ assert_eq!(CpuBudget::smallest_admitting(15360, 4320, None), Some(CpuBudget::Workstation));
+ assert_eq!(CpuBudget::smallest_admitting(16385, 1, None), None);
+ assert_eq!(CpuBudget::smallest_admitting(0, 1, None), None);
+ let message = CpuBudget::Compact.validate_image(3840, 2160, None).unwrap_err().to_string();
+ assert!(message.contains("choose the Studio CPU resource profile, or a smaller size"), "{message}");
+ let message = CpuBudget::Studio.validate_image(15360, 4320, None).unwrap_err().to_string();
+ assert!(message.contains("choose the Workstation CPU resource profile"), "{message}");
+ let message = CpuBudget::Workstation.validate_image(16384, 16384, None).unwrap_err().to_string();
+ assert!(message.contains("no CPU resource profile accepts this size"), "{message}");
+ assert!(!message.contains("Studio") && !message.contains("choose the"), "{message}");
+ // The message-free check agrees with validate_image everywhere, progressive included.
+ let sizes = [(0, 1), (1, 1), (2048, 2048), (3840, 2160), (4096, 4096), (7680, 4320), (8192, 8192), (16384, 4096), (u32::MAX, 2)];
+ for budget in CpuBudget::ALL {
+ for progressive in [
+ None,
+ Some(CpuProgressiveOptions { samples_per_pixel: 64, seed: 0 }),
+ Some(CpuProgressiveOptions { samples_per_pixel: 4096, seed: 0 }),
+ ] {
+ for (w, h) in sizes {
+ assert_eq!(
+ budget.admits_image(w, h, progressive),
+ budget.validate_image(w, h, progressive).is_ok(),
+ "{budget:?} {w}x{h} {progressive:?}"
+ );
+ }
+ }
+ }
+ }
}
diff --git a/crates/ui-egui/src/render_workspace_cpu.rs b/crates/ui-egui/src/render_workspace_cpu.rs
index 694467ea16..9251f1c1c1 100644
--- a/crates/ui-egui/src/render_workspace_cpu.rs
+++ b/crates/ui-egui/src/render_workspace_cpu.rs
@@ -6,9 +6,19 @@ use super::hdr;
use crate::{SolveApp, ui_kit};
pub(super) fn validate_progressive_image(app: &SolveApp) -> Result<(), String> {
- if app.render_workspace.view.method == super::ImageMethod::CpuRaytrace {
- let view = &app.render_workspace.view;
- view.raytrace.budget.validate_image(view.draft.width, view.draft.height, view.raytrace.progressive).map_err(|error| error.to_string())?;
+ let view = &app.render_workspace.view;
+ if view.method == super::ImageMethod::GpuRaytrace {
+ return Ok(());
+ }
+ // A size refusal is shown translated, naming the profile that can render it (#8941). Both CPU
+ // methods stop here, before the English refusals of the render and document crates.
+ let (width, height) = (view.draft.width, view.draft.height);
+ let size = (u64::from(width), u64::from(height));
+ if width > 0 && height > 0 && image_limits(app).fit(size.0, size.1, None) != Some(size) {
+ return Err(super::inspector::size_limit_reason(app, width, height));
+ }
+ if view.method == super::ImageMethod::CpuRaytrace {
+ view.raytrace.budget.validate_image(width, height, view.raytrace.progressive).map_err(|error| error.to_string())?;
}
Ok(())
}
@@ -28,6 +38,22 @@ pub(super) fn image_limits(app: &SolveApp) -> solidcraft_engine::render::RenderL
limits
}
+/// For a size a CPU method refuses, the smallest CPU ray tracing profile that can render it, to
+/// name in a hint. `None` for GPU path tracing, for sizes that fit, and past every profile. CPU
+/// raster has no profiles of its own, so its hint also names CPU ray tracing. Neither the method
+/// nor the profile is switched here: they and the resolution change only when chosen.
+pub(super) fn profile_for_size(app: &SolveApp, width: u64, height: u64) -> Option<CpuBudget> {
+ if app.render_workspace.view.method == super::ImageMethod::GpuRaytrace || image_limits(app).fit(width, height, None) == Some((width, height)) {
+ return None;
+ }
+ CpuBudget::smallest_admitting(u32::try_from(width).ok()?, u32::try_from(height).ok()?, app.render_workspace.view.raytrace.progressive)
+}
+
+/// The translated name of a profile, as the profile selector shows it.
+pub(super) fn budget_name(app: &SolveApp, budget: CpuBudget) -> &str {
+ app.tr(budget_key(budget))
+}
+
fn budget_key(budget: CpuBudget) -> &'static str {
match budget {
CpuBudget::Compact => "render.children.compact",
diff --git a/crates/ui-egui/src/render_workspace_inspector.rs b/crates/ui-egui/src/render_workspace_inspector.rs
index a3ba0c7214..81750b42d9 100644
--- a/crates/ui-egui/src/render_workspace_inspector.rs
+++ b/crates/ui-egui/src/render_workspace_inspector.rs
@@ -854,13 +854,23 @@ fn output_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.horizontal_wrapped(|ui| {
for (key, label, size) in choices {
let allowed = size.filter(|&(w, h)| cpu::image_limits(app).fit(w, h, None) == Some((w, h)));
+ let mark = size_mark(app, label, *size);
let response = ui
.add_enabled_ui(allowed.is_some(), |ui| {
- ui_kit::choice_chip(ui, key, label, *size == Some((u64::from(before[0]), u64::from(before[1]))))
+ ui_kit::choice_chip(
+ ui,
+ key,
+ mark.as_deref().unwrap_or(label),
+ *size == Some((u64::from(before[0]), u64::from(before[1]))),
+ )
})
.inner;
crate::scenario::publish_target(&format!("render:size:{key}"), response.rect);
- if response.on_disabled_hover_text(app.tr("render.output_over_budget")).clicked()
+ let reason = match (mark.is_some(), *size) {
+ (true, Some((w, h))) => size_limit_reason(app, u32::try_from(w).unwrap_or(u32::MAX), u32::try_from(h).unwrap_or(u32::MAX)),
+ _ => app.tr("render.output_over_budget").to_string(),
+ };
+ if response.on_disabled_hover_text(reason).clicked()
&& let Some((w, h)) = allowed
&& let (Ok(w), Ok(h)) = (u32::try_from(w), u32::try_from(h))
&& let Err(error) = apply_size(app, w, h, false)
@@ -1248,10 +1258,10 @@ fn apply_size(app: &mut SolveApp, width: u32, height: u32, custom: bool) -> Resu
app.render_workspace.view.dirty = true;
Ok(())
}
-fn size_limit_reason(app: &SolveApp, width: u32, height: u32) -> String {
+pub(super) fn size_limit_reason(app: &SolveApp, width: u32, height: u32) -> String {
let limits = cpu::image_limits(app);
let (w, h) = limits.fit(u64::from(width), u64::from(height), None).unwrap_or((0, 0));
- crate::i18n::format(
+ let reason = crate::i18n::format(
"render.output_size_limit",
&[
("method", app.tr(app.render_workspace.view.method.label())),
@@ -1260,7 +1270,24 @@ fn size_limit_reason(app: &SolveApp, width: u32, height: u32) -> String {
("width", &w.to_string()),
("height", &h.to_string()),
],
- )
+ );
+ let Some(profile) = cpu::profile_for_size(app, u64::from(width), u64::from(height)) else {
+ return reason;
+ };
+ let (profile, method) = (cpu::budget_name(app, profile), app.tr(ImageMethod::CpuRaytrace.label()));
+ let (width, height) = (width.to_string(), height.to_string());
+ let args = [("profile", profile), ("method", method), ("width", width.as_str()), ("height", height.as_str())];
+ // CPU raster has no profile selector: the way out includes changing the method.
+ let key =
+ if app.render_workspace.view.method == ImageMethod::Raster { "render.output_size_method_profile" } else { "render.output_size_profile" };
+ format!("{reason} {}", crate::i18n::format(key, &args))
+}
+/// A preset a CPU method refuses carries the profile that renders it (#8941). Kept short for the
+/// narrow size lists; the reason in its tooltip says what to choose, method included.
+pub(super) fn size_mark(app: &SolveApp, text: &str, size: Option<(u64, u64)>) -> Option<String> {
+ let (width, height) = size?;
+ let profile = cpu::budget_name(app, cpu::profile_for_size(app, width, height)?);
+ Some(crate::i18n::format("render.size_needs_profile", &[("size", text), ("profile", profile)]))
}
pub(super) fn size_presets(app: &mut SolveApp, ui: &mut egui::Ui) {
ui_kit::scope(ui, |ui| {
@@ -1268,6 +1295,7 @@ pub(super) fn size_presets(app: &mut SolveApp, ui: &mut egui::Ui) {
let custom = app.render_workspace.view.inspector.resolution.custom || !SIZE_PRESETS.iter().any(|(_, _, size)| *size == Some(current));
for (key, label, size) in SIZE_PRESETS {
let summary = size.map_or_else(String::new, |(w, h)| format!("{w} × {h}"));
+ let summary = size_mark(app, &summary, size.map(|(w, h)| (u64::from(w), u64::from(h)))).unwrap_or(summary);
let enabled =
size.is_none_or(|(w, h)| cpu::image_limits(app).fit(u64::from(w), u64::from(h), None) == Some((u64::from(w), u64::from(h))));
let response = ui
@@ -1298,7 +1326,8 @@ pub(super) fn stage_tools(app: &mut SolveApp, ui: &mut egui::Ui) {
for (key, label, size) in SIZE_PRESETS {
let enabled =
size.is_none_or(|(w, h)| cpu::image_limits(app).fit(u64::from(w), u64::from(h), None) == Some((u64::from(w), u64::from(h))));
- let response = ui.add_enabled_ui(enabled, |ui| ui_kit::list_picker(ui, key, app.tr(label), false)).inner;
+ let mark = size_mark(app, app.tr(label), size.map(|(w, h)| (u64::from(w), u64::from(h))));
+ let response = ui.add_enabled_ui(enabled, |ui| ui_kit::list_picker(ui, key, mark.as_deref().unwrap_or(app.tr(label)), false)).inner;
crate::scenario::publish_target(&format!("render:stage:size:{key}"), response.rect);
let reason = size.map_or_else(String::new, |(w, h)| size_limit_reason(app, w, h));
if response.on_disabled_hover_text(reason).clicked() {
diff --git a/crates/ui-egui/src/render_workspace_inspector_tests.rs b/crates/ui-egui/src/render_workspace_inspector_tests.rs
index 46f93ec8b5..b848b9f638 100644
--- a/crates/ui-egui/src/render_workspace_inspector_tests.rs
+++ b/crates/ui-egui/src/render_workspace_inspector_tests.rs
@@ -1624,6 +1624,110 @@ fn output_sections_sizes_refuse_hostile_input_and_4k_follows_the_selected_budget
assert!(h.app.render_workspace.view.job.is_none());
}
+/// #8941: the Shots strip offers 4K UHD whatever the method. Under the default CPU raster, which
+/// has no profiles, the list and the refusal name CPU ray tracing with Studio; neither is selected.
+#[test]
+fn cpu_raster_refusing_a_size_names_the_method_and_profile_that_render_it() {
+ use solidcraft_engine::render::job::CpuBudget;
+ let mut h = fixture();
+ assert_eq!(h.app.render_workspace.view.method, ImageMethod::Raster, "the default method is unchanged");
+ let doc = h.app.session.doc.clone();
+ let undo = h.app.session.undo.len();
+ h.step(&json!({"click":{"handle":"render:shots:size"}})).unwrap();
+ h.step(&json!({"widget":"Full HD · 1920 × 1080"})).unwrap();
+ assert_eq!((h.app.render_workspace.view.draft.width, h.app.render_workspace.view.draft.height), (1920, 1080));
+ assert!(super::super::image_request(&h.app).is_ok());
+ h.step(&json!({"click":{"handle":"render:shots:size"}})).unwrap();
+ h.step(&json!({"widget":"4K UHD · 3840 × 2160 · needs Studio"})).unwrap();
+ assert_eq!((h.app.render_workspace.view.draft.width, h.app.render_workspace.view.draft.height), (3840, 2160));
+ let refusal = super::super::image_request(&h.app).unwrap_err();
+ assert!(refusal.contains("Largest fitting size: 2730 × 1536."), "{refusal}");
+ assert!(refusal.contains("To render 3840 × 2160, choose CPU ray tracing with the Studio CPU resource profile, or a smaller size."), "{refusal}");
+ assert_eq!(refusal, size_limit_reason(&h.app, 3840, 2160));
+ assert_eq!(h.app.render_workspace.view.method, ImageMethod::Raster);
+ assert_eq!(h.app.render_workspace.view.raytrace.budget, CpuBudget::Compact);
+ assert!(Arc::ptr_eq(&doc, &h.app.session.doc));
+ assert_eq!(h.app.session.undo.len(), undo);
+ assert!(!size_limit_reason(&h.app, 16384, 16384).contains("CPU resource profile"), "past Workstation no profile is named");
+ assert_eq!(size_mark(&h.app, "fits", Some((2048, 2048))), None);
+ h.app.preferences.language = "de".into();
+ let _language = crate::i18n::scope("de");
+ assert!(super::super::image_request(&h.app).unwrap_err().contains("CPU-Ressourcenprofil Studio"));
+}
+
+/// #8941: under the default Compact CPU profile 4K UHD is refused with a translated reason that
+/// names Studio, and the size lists mark only the presets the selected profile can't render.
+/// Nothing switches the profile or the size; GPU path tracing shows no CPU profile.
+#[test]
+fn a_size_the_cpu_profile_refuses_names_the_profile_that_renders_it() {
+ use solidcraft_engine::render::job::CpuBudget;
+ let mut h = fixture();
+ super::super::select_image_method(&mut h.app, ImageMethod::CpuRaytrace);
+ h.frames(3);
+ h.step(&json!({"click":{"handle":"render:shots:size"}})).unwrap();
+ h.step(&json!({"widget":"4K UHD · 3840 × 2160 · needs Studio"})).unwrap();
+ assert_eq!(h.app.render_workspace.view.raytrace.budget, CpuBudget::Compact, "the default profile is unchanged");
+ let reason = size_limit_reason(&h.app, 3840, 2160);
+ assert!(reason.contains("Largest fitting size: 2730 × 1536."), "{reason}");
+ assert!(reason.contains("To render 3840 × 2160, choose the Studio CPU resource profile, or a smaller size."), "{reason}");
+ assert_eq!(size_mark(&h.app, "4K UHD", Some((3840, 2160))).as_deref(), Some("4K UHD · needs Studio"));
+ for fits in [(1280, 720), (1920, 1080), (2048, 2048)] {
+ assert_eq!(size_mark(&h.app, "fits", Some(fits)), None, "{fits:?}");
+ }
+ assert_eq!(size_mark(&h.app, "custom", None), None);
+ assert_eq!(size_mark(&h.app, "past every profile", Some((16385, 16385))), None);
+ let reason = size_limit_reason(&h.app, 16384, 16384);
+ assert!(!reason.contains("CPU resource profile"), "past Workstation no profile is named: {reason}");
+
+ // Render and Check are refused with the same translated reason, and nothing is changed.
+ h.app.render_workspace.view.draft.width = 3840;
+ h.app.render_workspace.view.draft.height = 2160;
+ let doc = h.app.session.doc.clone();
+ h.frames(3);
+ assert_eq!(cpu::validate_progressive_image(&h.app).unwrap_err(), size_limit_reason(&h.app, 3840, 2160));
+ assert!(super::super::image_request(&h.app).unwrap_err().contains("choose the Studio CPU resource profile"));
+ assert_eq!(h.app.render_workspace.view.raytrace.budget, CpuBudget::Compact);
+ assert_eq!((h.app.render_workspace.view.draft.width, h.app.render_workspace.view.draft.height), (3840, 2160));
+ assert!(Arc::ptr_eq(&doc, &h.app.session.doc));
+
+ // Studio renders 4K and marks nothing up to it; a 16K-wide image names Workstation.
+ h.app.render_workspace.view.raytrace.budget = CpuBudget::Studio;
+ cpu::validate_progressive_image(&h.app).unwrap();
+ assert_eq!(size_mark(&h.app, "4K UHD", Some((3840, 2160))), None);
+ assert_eq!(size_mark(&h.app, "16K", Some((15360, 4320))).as_deref(), Some("16K · needs Workstation"));
+ assert!(size_limit_reason(&h.app, 15360, 4320).contains("choose the Workstation CPU resource profile"));
+ h.app.render_workspace.view.raytrace.budget = CpuBudget::Workstation;
+ assert_eq!(size_mark(&h.app, "16K", Some((15360, 4320))), None);
+
+ // Progressive sampling's camera-sample budget counts: 4K at 64 spp needs Studio too.
+ h.app.render_workspace.view.raytrace.budget = CpuBudget::Compact;
+ h.app.render_workspace.view.raytrace.progressive = Some(solidcraft_engine::render::job::CpuProgressiveOptions { samples_per_pixel: 64, seed: 0 });
+ assert_eq!(cpu::profile_for_size(&h.app, 3840, 2160), Some(CpuBudget::Studio));
+ h.app.render_workspace.view.raytrace.progressive = None;
+
+ // Translated: the profile is named as the profile selector names it.
+ h.app.preferences.language = "ja".into();
+ {
+ let _language = crate::i18n::scope("ja");
+ let reason = size_limit_reason(&h.app, 3840, 2160);
+ assert!(reason.contains("CPUリソースプロファイル「スタジオ」"), "{reason}");
+ assert_eq!(size_mark(&h.app, "4K UHD", Some((3840, 2160))).as_deref(), Some("4K UHD・「スタジオ」が必要"));
+ }
+ h.app.preferences.language = "en".into();
+ h.frames(3);
+
+ // GPU path tracing renders 4K and never names a CPU profile.
+ super::super::select_image_method(&mut h.app, ImageMethod::GpuRaytrace);
+ h.frames(3);
+ h.step(&json!({"click":{"handle":"render:shots:size"}})).unwrap();
+ h.step(&json!({"widget":"4K UHD · 3840 × 2160"})).unwrap();
+ assert_eq!(size_mark(&h.app, "4K UHD", Some((3840, 2160))), None);
+ // 15360 × 4320 is past the GPU limits, yet Workstation would admit it: still no CPU profile.
+ assert_eq!(size_mark(&h.app, "16K", Some((15360, 4320))), None);
+ assert!(!size_limit_reason(&h.app, 15360, 4320).contains("CPU resource profile"));
+ cpu::validate_progressive_image(&h.app).unwrap();
+}
+
#[test]
fn shots_strip_render_submits_the_current_job_request() {
let mut h = fixture();
diff --git a/crates/ui-egui/src/render_workspace_shots.rs b/crates/ui-egui/src/render_workspace_shots.rs
index 495f619ba9..ef4879d8a1 100644
--- a/crates/ui-egui/src/render_workspace_shots.rs
+++ b/crates/ui-egui/src/render_workspace_shots.rs
@@ -59,9 +59,14 @@ pub(crate) fn contents(app: &mut SolveApp, ui: &mut egui::Ui) {
start = response.clicked();
let response = ui_kit::compact_dropdown_menu(ui, "render_shots_size", &size_label, |ui| {
for (label, width, height) in SIZE_PRESETS {
- if ui_kit::list_picker(ui, label, &format!("{label} · {width} × {height}"), draft.width == width && draft.height == height)
- .clicked()
- {
+ let text = format!("{label} · {width} × {height}");
+ let mark = super::inspector::size_mark(app, &text, Some((u64::from(width), u64::from(height))));
+ let mut response =
+ ui_kit::list_picker(ui, label, mark.as_deref().unwrap_or(&text), draft.width == width && draft.height == height);
+ if mark.is_some() {
+ response = response.on_hover_text(super::inspector::size_limit_reason(app, width, height));
+ }
+ if response.clicked() {
size = Some((width, height));
ui.close();
}