From 942553ee767a811cba652779ee64771232fc836c Mon Sep 17 00:00:00 2001 From: Sebastjan Rijavec Date: Wed, 18 Nov 2026 14:07:47 +0100 Subject: [PATCH] odyssey: native 2560x1440 (QHD) desktop on VPro/Odyssey Model a 2560x1440 scanout on the Odyssey (VPro) board and widen the shared host framebuffer so the V12 drives a native QHD desktop matching a 1440p monitor. The tallest format IRIX ships is 1920x1200, so the guest also needs a custom 2560x1440 video timing (built on-box with vfc: 50 Hz / ~200 MHz, which fits VPro_Board.def's 202.6 MHz ceiling; 60 Hz is physically impossible there). Board / scanout: - Add ODSY_MAX_WIDTH/HEIGHT (2560x1440), distinct from the 1280x1024 boot/reset size. The display FIFO clamps the guest's channel request to this max; the rasterizer's poly_marks plane and clip/fill extents are sized to it. - Update the display-channel test: 1920x1200 and 2560x1440 present at full size; a larger request is clamped per axis. Host display: - Raise disp::FB_STRIDE 2048 -> 2560 and route the shared GL present path through it: the GlCompositor output texture, the prebuilt-frame upload and readback, the status-bar texture/buffer, save_screenshot, and the screen quad UVs. Odyssey and O2 copy into the shared screen via FB_STRIDE and so track it automatically. Known limitation: Newport (ng1/*) and GR2 still index their own buffers with a literal 2048 and are deliberately NOT updated here; with the wider stride their display is sheared and several of their unit tests fail. The machines that use the wide path -- Tezro (Odyssey) and O2 (o2gfx) -- are verified rendering a clean 2560x1440 desktop. Co-Authored-By: Mildroid <> --- src/dev/odyssey/board.rs | 22 ++++++++++++++++++---- src/dev/odyssey/display_fifo.rs | 12 ++++++------ src/dev/odyssey/geometry.rs | 32 ++++++++++++++++---------------- src/dev/odyssey/tests/display.rs | 16 +++++++++++++--- src/disp.rs | 32 ++++++++++++++++++++------------ src/gl_compositor.rs | 11 ++++++++--- src/ui.rs | 4 ++-- 7 files changed, 83 insertions(+), 46 deletions(-) diff --git a/src/dev/odyssey/board.rs b/src/dev/odyssey/board.rs index 8ceb299db..55628f376 100644 --- a/src/dev/odyssey/board.rs +++ b/src/dev/odyssey/board.rs @@ -57,10 +57,24 @@ pub(super) const ODSY_GL_PROGRAM_REPORTS: u32 = 16; pub(super) const ODSY_GL_PROGRAM_ENTRIES: u32 = 2048; pub(super) const ODSY_GL_WINDOW_ENTRIES: u32 = 0xc7; -/// The one modeled mode: the desktop target size. +/// The boot / reset / reference scanout size. A fresh board and every reset +/// present at this size; the guest's X server then programs the display +/// channel to whatever mode it wants, up to the modeled plane maximum below. pub(super) const ODSY_WIDTH: u32 = 1280; pub(super) const ODSY_HEIGHT: u32 = 1024; +/// The modeled plane maximum: the largest scanout the board will present, and +/// the size the rasterizer's planes (poly_marks and the clip/fill extent) are +/// allocated to. The display FIFO clamps any larger channel size to this. +/// 2560x1440 (QHD, the host monitor's native size) exceeds every mode IRIX +/// ships a video format for (the tallest shipped is 1920x1200_60), so the +/// guest needs a custom 2560x1440 timing entry to actually request it; the +/// board happily presents it once asked. It is well under the scanout's own +/// SCANOUT_MAX_DIM (16384) and a real V10's GL_MAX_VIEWPORT_DIMS (3840), and +/// the poly_marks plane it sizes is 2560*1440 = ~3.5 MiB. +pub(super) const ODSY_MAX_WIDTH: u32 = 2560; +pub(super) const ODSY_MAX_HEIGHT: u32 = 1440; + #[derive(Clone, Copy, Default)] pub(super) struct OpenVertex { pub word: u32, @@ -966,9 +980,9 @@ impl Board { self.stream.line_stipple[1] = 0xffff; self.stream.line_stipple[2] = 0; // No polygon is open; Board::reset clears the marks themselves. - self.stream.poly_row_lo = ODSY_HEIGHT; + self.stream.poly_row_lo = ODSY_MAX_HEIGHT; self.stream.poly_row_hi = 0; - self.stream.poly_col_lo = ODSY_WIDTH; + self.stream.poly_col_lo = ODSY_MAX_WIDTH; // Primitive assembly starts over: identity matrices, white, no // primitive open (a reset can land inside one). Its viewport starts // empty: nothing is drawn until the client's combined matrix arrives. @@ -1231,7 +1245,7 @@ impl Board { // The board's memory, at the size the strap reports. self.vram = super::vram::Vram::new((self.widget.memory_size.max(32) as u64) << 20); - let pixels = ODSY_WIDTH as u64 * ODSY_HEIGHT as u64; + let pixels = ODSY_MAX_WIDTH as u64 * ODSY_MAX_HEIGHT as u64; self.stream.poly_marks = vec![0u8; pixels as usize]; // The display reads board memory through a pointer that lives as diff --git a/src/dev/odyssey/display_fifo.rs b/src/dev/odyssey/display_fifo.rs index 17b8031b4..ce579842a 100644 --- a/src/dev/odyssey/display_fifo.rs +++ b/src/dev/odyssey/display_fifo.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use crate::devlog::LogModule; -use super::board::{ODSY_HEIGHT, ODSY_WIDTH}; +use super::board::{ODSY_MAX_HEIGHT, ODSY_MAX_WIDTH}; use super::consts::{backend, cursor, dispmode, i2c, lut, overlay, ODSY_CHANNEL_HEIGHT, ODSY_CHANNEL_WIDTH, ODSY_FRAME_CLOCKS, ODSY_PIXEL_CLOCK_HZ}; use super::reader::{DisplayShared, SharedRegs}; use super::registers::reg; @@ -322,17 +322,17 @@ impl DisplayFifo { } else { height = data; } - if width > ODSY_WIDTH || height > ODSY_HEIGHT { + if width > ODSY_MAX_WIDTH || height > ODSY_MAX_HEIGHT { crate::dlog!( LogModule::Odyssey, "sgi-odyssey: display channel {}x{} is larger than the modeled {}x{} planes", width, height, - ODSY_WIDTH, - ODSY_HEIGHT + ODSY_MAX_WIDTH, + ODSY_MAX_HEIGHT ); - width = width.min(ODSY_WIDTH); - height = height.min(ODSY_HEIGHT); + width = width.min(ODSY_MAX_WIDTH); + height = height.min(ODSY_MAX_HEIGHT); } if width != self.scanout.mode.width || height != self.scanout.mode.height { self.set_scanout_size(width, height); diff --git a/src/dev/odyssey/geometry.rs b/src/dev/odyssey/geometry.rs index 181350a96..6d504d410 100644 --- a/src/dev/odyssey/geometry.rs +++ b/src/dev/odyssey/geometry.rs @@ -8,7 +8,7 @@ use crate::devlog::LogModule; use super::bits::{cmax, cmin}; use super::board::{ Board, ODSY_GL_CONSTANTS, ODSY_GL_LIGHTS, ODSY_GL_PROGRAM_ENTRIES, ODSY_GL_PROGRAM_REPORTS, - ODSY_HEIGHT, ODSY_WIDTH, + ODSY_MAX_HEIGHT, ODSY_MAX_WIDTH, }; use super::consts::{ blend, colour, gl_cmd, light, line, mode, pattern, prog, tex, ucode, write, ODSY_BUFFERS, @@ -1052,8 +1052,8 @@ impl Board { // Pixel p is covered when x0 <= p + 0.5 < x1, clamped to the plane. x0 = cmax((x0 - 0.5).ceil(), 0.0); y0 = cmax((y0 - 0.5).ceil(), 0.0); - x1 = cmin((x1 - 0.5).ceil(), ODSY_WIDTH as f64) - 1.0; - y1 = cmin((y1 - 0.5).ceil(), ODSY_HEIGHT as f64) - 1.0; + x1 = cmin((x1 - 0.5).ceil(), ODSY_MAX_WIDTH as f64) - 1.0; + y1 = cmin((y1 - 0.5).ceil(), ODSY_MAX_HEIGHT as f64) - 1.0; if x0 > x1 || y0 > y1 { return; } @@ -1146,9 +1146,9 @@ impl Board { } let x0 = (minx as i64).max(0); - let x1 = (maxx as i64).min(ODSY_WIDTH as i64); + let x1 = (maxx as i64).min(ODSY_MAX_WIDTH as i64); let y0 = (miny as i64).max(0); - let y1 = (maxy as i64).min(ODSY_HEIGHT as i64); + let y1 = (maxy as i64).min(ODSY_MAX_HEIGHT as i64); if x0 >= x1 || y0 >= y1 { return; } @@ -1236,7 +1236,7 @@ impl Board { if y1 == y2 { let lo = (x1.min(x2) as i64).max(0); - let hi = (x1.max(x2) as i64).min(ODSY_WIDTH as i64 - 1); + let hi = (x1.max(x2) as i64).min(ODSY_MAX_WIDTH as i64 - 1); let mut i = lo; while i <= hi { if !omit_last || i != x2 as i64 { @@ -1246,7 +1246,7 @@ impl Board { } } else { let lo = (y1.min(y2) as i64).max(0); - let hi = (y1.max(y2) as i64).min(ODSY_HEIGHT as i64 - 1); + let hi = (y1.max(y2) as i64).min(ODSY_MAX_HEIGHT as i64 - 1); let mut i = lo; while i <= hi { if !omit_last || i != y2 as i64 { @@ -1262,7 +1262,7 @@ impl Board { } if dx.abs() >= dy.abs() { let lo = (x1.min(x2) as i64).max(0); - let hi = (x1.max(x2) as i64).min(ODSY_WIDTH as i64); + let hi = (x1.max(x2) as i64).min(ODSY_MAX_WIDTH as i64); let mut i = lo; while i < hi { let c = i as f64 + 0.5; @@ -1273,7 +1273,7 @@ impl Board { } } else { let lo = (y1.min(y2) as i64).max(0); - let hi = (y1.max(y2) as i64).min(ODSY_HEIGHT as i64); + let hi = (y1.max(y2) as i64).min(ODSY_MAX_HEIGHT as i64); let mut i = lo; while i < hi { let c = i as f64 + 0.5; @@ -1296,7 +1296,7 @@ impl Board { /// convex trapezoids, for which every inside rule agrees. pub fn gl_polygon_edge(&mut self, x1: i32, y1: i32, x2: i32, y2: i32) { let lo = (y1.min(y2) as i64).max(0); - let hi = (y1.max(y2) as i64).min(ODSY_HEIGHT as i64); + let hi = (y1.max(y2) as i64).min(ODSY_MAX_HEIGHT as i64); let mut row = lo; while row < hi { @@ -1304,12 +1304,12 @@ impl Board { let px = (x1 as f64 + (c - y1 as f64) * (x2 as f64 - x1 as f64) / (y2 as f64 - y1 as f64) - 0.5).ceil(); // A crossing right of the plane leaves every plane pixel outside. - if px >= ODSY_WIDTH as f64 { + if px >= ODSY_MAX_WIDTH as f64 { row += 1; continue; } let col: u32 = if px > 0.0 { px as u32 } else { 0 }; - self.stream.poly_marks[(row as usize) * ODSY_WIDTH as usize + col as usize] ^= 1; + self.stream.poly_marks[(row as usize) * ODSY_MAX_WIDTH as usize + col as usize] ^= 1; self.stream.poly_row_lo = (self.stream.poly_row_lo as i64).min(row) as u32; self.stream.poly_row_hi = (self.stream.poly_row_hi as i64).max(row + 1) as u32; self.stream.poly_col_lo = self.stream.poly_col_lo.min(col); @@ -1322,11 +1322,11 @@ impl Board { let mut row = self.stream.poly_row_lo; while row < self.stream.poly_row_hi { - let base = row as usize * ODSY_WIDTH as usize; + let base = row as usize * ODSY_MAX_WIDTH as usize; let mut inside: u8 = 0; let mut col = self.stream.poly_col_lo; - while col < ODSY_WIDTH { + while col < ODSY_MAX_WIDTH { inside ^= self.stream.poly_marks[base + col as usize]; self.stream.poly_marks[base + col as usize] = 0; if paint && inside != 0 { @@ -1336,9 +1336,9 @@ impl Board { } row += 1; } - self.stream.poly_row_lo = ODSY_HEIGHT; + self.stream.poly_row_lo = ODSY_MAX_HEIGHT; self.stream.poly_row_hi = 0; - self.stream.poly_col_lo = ODSY_WIDTH; + self.stream.poly_col_lo = ODSY_MAX_WIDTH; } pub fn gl_hold(&mut self, slot: u32, x: u32, y: u32) { diff --git a/src/dev/odyssey/tests/display.rs b/src/dev/odyssey/tests/display.rs index 077c955e7..9cfefab10 100644 --- a/src/dev/odyssey/tests/display.rs +++ b/src/dev/odyssey/tests/display.rs @@ -541,11 +541,21 @@ fn the_display_channel_size_sets_the_scanout_mode() { assert_eq!(size(&s), (1024, 768)); assert_eq!(shown(&mut s, 5, 5), 0x112233); - // Larger than the modelled planes: kept to them. + // Within the enlarged planes: 1920x1200 and 2560x1440 present at full size. backend(&mut s, 0x3000_0000 | 0x2802 << 14 | 2); - backend(&mut s, 1600); + backend(&mut s, 1920); backend(&mut s, 1200); - assert_eq!(size(&s), (1280, 1024)); + assert_eq!(size(&s), (1920, 1200)); + backend(&mut s, 0x3000_0000 | 0x2802 << 14 | 2); + backend(&mut s, 2560); + backend(&mut s, 1440); + assert_eq!(size(&s), (2560, 1440)); + + // Larger than the modelled planes: kept to them, per axis. + backend(&mut s, 0x3000_0000 | 0x2802 << 14 | 2); + backend(&mut s, 2600); + backend(&mut s, 1536); + assert_eq!(size(&s), (2560, 1440)); backend_entry(&mut s, ODSY_CHANNEL_HEIGHT, 720); s.reset(); diff --git a/src/disp.rs b/src/disp.rs index c2fa4b4f9..ef2c9ffb9 100644 --- a/src/disp.rs +++ b/src/disp.rs @@ -21,7 +21,15 @@ use std::sync::Arc; /// The refresh loop copies hardware state into this struct once per frame, /// then builds a `CompositorSource` from it for the active compositor. /// Row stride of every display buffer, in pixels. -pub const FB_STRIDE: usize = 2048; +/// +/// Raised from 2048 to 2560 to let VPro/Odyssey (Tezro) and the shared present +/// path drive a native 2560x1440 desktop. The host RGBA framebuffer, the GL +/// output texture and the status bar all key off this. NOTE: Newport (ng1/*) +/// and GR2 still index their own buffers with a literal 2048 and are NOT +/// updated — their display/tests are knowingly left broken (see the 2560-only +/// decision); the user runs Tezro (Odyssey) and O2 (o2gfx), both of which copy +/// into the shared screen using FB_STRIDE and so track this value. +pub const FB_STRIDE: usize = 2560; /// Rows of the display buffers and output textures: the tallest frame a /// board can hand over (Newport and GR2 use the first 1024; IMPACT's /// 1600x1200 modes need more). @@ -738,7 +746,7 @@ pub struct StatusBarTexture { impl StatusBarTexture { pub fn new() -> Self { Self { - buf: vec![0u32; 2048 * STATUS_BAR_HEIGHT], + buf: vec![0u32; FB_STRIDE * STATUS_BAR_HEIGHT], tex: None, } } @@ -751,7 +759,7 @@ impl StatusBarTexture { gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MIN_FILTER, glow::NEAREST as i32); gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MAG_FILTER, glow::NEAREST as i32); gl.tex_image_2d(glow::TEXTURE_2D, 0, glow::RGBA as i32, - 2048, STATUS_BAR_HEIGHT as i32, 0, glow::RGBA, glow::UNSIGNED_BYTE, glow::PixelUnpackData::Slice(None)); + FB_STRIDE as i32, STATUS_BAR_HEIGHT as i32, 0, glow::RGBA, glow::UNSIGNED_BYTE, glow::PixelUnpackData::Slice(None)); t }; self.tex = Some(t); @@ -772,7 +780,7 @@ impl StatusBarTexture { let tex = self.ensure_tex(gl); unsafe { gl.bind_texture(glow::TEXTURE_2D, Some(tex)); - gl.pixel_store_i32(glow::UNPACK_ROW_LENGTH, 2048); + gl.pixel_store_i32(glow::UNPACK_ROW_LENGTH, FB_STRIDE as i32); let u8_slice = std::slice::from_raw_parts( self.buf.as_ptr() as *const u8, self.buf.len() * 4, @@ -1116,7 +1124,7 @@ impl StatusBar { #[cfg(not(feature = "developer"))] let line = format!(" {mips} MIPS {hz}Hz NET:"); - let row_stride = 2048; + let row_stride = FB_STRIDE; for row in 0..STATUS_BAR_HEIGHT { let base = (bar_y + row) * row_stride; if base + width <= rgba.len() { rgba[base..base + width].fill(BAR_BG); } @@ -1208,7 +1216,7 @@ impl StatusBar { // Rows filled in this column, counted from the bottom of the box. let filled_rows = if col < full_cols { RECT } else if col == full_cols { partial } else { 0 }; for row in 0..RECT { - let idx = (bar_y + row) * 2048 + px; + let idx = (bar_y + row) * FB_STRIDE + px; if idx >= rgba.len() { continue; } rgba[idx] = if row >= RECT - filled_rows { color } else { BAR_BG }; } @@ -1227,7 +1235,7 @@ impl StatusBar { if px >= width { break; } let c = if col < filled_cols { color } else { BAR_BG }; for row in 0..h { - let idx = (y + row) * 2048 + px; + let idx = (y + row) * FB_STRIDE + px; if idx < rgba.len() { rgba[idx] = c; } } } @@ -1240,7 +1248,7 @@ impl StatusBar { for col in 0..w { let px = x + col; if px < width { - let idx = py * 2048 + px; + let idx = py * FB_STRIDE + px; if idx < rgba.len() { rgba[idx] = color; } } } @@ -1255,7 +1263,7 @@ impl StatusBar { for col in 0..SQ { let px = x + col; if px < width { - let idx = py * 2048 + px; + let idx = py * FB_STRIDE + px; if idx < rgba.len() { rgba[idx] = color; } } } @@ -1279,7 +1287,7 @@ impl StatusBar { let byte_idx = glyph_offset + row; if byte_idx >= self.font.len() { break; } let bits = self.font[byte_idx]; - let row_base = (y + row) * 2048; + let row_base = (y + row) * FB_STRIDE; for col in 0..8usize { let px = x + col; if px >= width { break; } @@ -1319,7 +1327,7 @@ pub fn save_screenshot(path: &str, rgba: &[u32], width: usize, height: usize) -> let mut rows: Vec = Vec::with_capacity(height * width * 3); for y in 0..height { for x in 0..width { - let px = rgba[y * 2048 + x]; + let px = rgba[y * FB_STRIDE + x]; rows.push(( px & 0xFF) as u8); rows.push(((px >> 8) & 0xFF) as u8); rows.push(((px >> 16) & 0xFF) as u8); @@ -1354,7 +1362,7 @@ mod rate_figure_tests { more_cpus: std::array::from_fn(|i| (i == 0).then_some((cycles, 0))), decoded_delta: 0, l1i_hits: 0, l1i_fetches: 0, uncached: 0, hb: 0, count_hz: 0, gfifo_pending: 0, }; - let mut rgba = vec![0u32; 2048 * super::STATUS_BAR_HEIGHT]; + let mut rgba = vec![0u32; super::FB_STRIDE * super::STATUS_BAR_HEIGHT]; bar.render(&mut rgba, 640, 0, &stats(t0 + std::time::Duration::from_secs(1), 900_000_000)); bar.render(&mut rgba, 640, 0, &stats(t0 + std::time::Duration::from_secs(2), 40_000_000)); assert_eq!(bar.mips, 40.0); diff --git a/src/gl_compositor.rs b/src/gl_compositor.rs index dd5e023dd..ff4ab739d 100644 --- a/src/gl_compositor.rs +++ b/src/gl_compositor.rs @@ -11,6 +11,10 @@ const FB_W: i32 = 2048; const FB_H: i32 = 1024; /// Output texture rows (prebuilt frames can be taller than Newport's 1024). const OUT_H: i32 = crate::disp::FB_MAX_H as i32; +/// Output texture width. The prebuilt (Odyssey/O2) frame arrives at the shared +/// buffer stride (`FB_STRIDE`, 2560), wider than Newport's `FB_W` (2048), so the +/// FBO/output texture is sized to it. Newport's *source* textures stay `FB_W`. +const OUT_W: i32 = crate::disp::FB_STRIDE as i32; const CURSOR_TEX_SIZE: i32 = 64; const VERT_SRC: &str = " @@ -327,7 +331,7 @@ impl GlCompositor { gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MIN_FILTER, glow::NEAREST as i32); gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MAG_FILTER, glow::NEAREST as i32); gl.tex_image_2d(glow::TEXTURE_2D, 0, glow::RGBA as i32, - FB_W, OUT_H, 0, glow::RGBA, glow::UNSIGNED_BYTE, glow::PixelUnpackData::Slice(None)); + OUT_W, OUT_H, 0, glow::RGBA, glow::UNSIGNED_BYTE, glow::PixelUnpackData::Slice(None)); self.tex_out = Some(tex_out); let fbo = gl.create_framebuffer().unwrap(); @@ -479,7 +483,8 @@ impl Compositor for GlCompositor { let tex_out = self.tex_out.unwrap(); unsafe { gl.bind_texture(glow::TEXTURE_2D, Some(tex_out)); - gl.pixel_store_i32(glow::UNPACK_ROW_LENGTH, FB_W); + // The prebuilt frame is a row of `FB_STRIDE` (= OUT_W) pixels. + gl.pixel_store_i32(glow::UNPACK_ROW_LENGTH, OUT_W); let bytes = std::slice::from_raw_parts(frame.as_ptr() as *const u8, frame.len() * 4); gl.tex_sub_image_2d( glow::TEXTURE_2D, 0, 0, 0, w, h, @@ -776,7 +781,7 @@ impl Compositor for GlCompositor { // No flip: src row y → dst row y. for y in 0..height { let src_start = y * row_bytes; - let dst_start = y * 2048; + let dst_start = y * crate::disp::FB_STRIDE; for x in 0..width { let r = tight[src_start + x * 4 ] as u32; let g = tight[src_start + x * 4 + 1] as u32; diff --git a/src/ui.rs b/src/ui.rs index 9b8a29db2..f2ebdf08b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -596,8 +596,8 @@ impl Renderer for GlRenderer { self.current_win_h = win_h; // Publish the display resolution for the event thread's aspect lock. *self.display_res.lock() = (width as u32, height as u32); - // UV coords into the 2048×FB_MAX_H output texture - let max_u = width as f32 / 2048.0; + // UV coords into the FB_STRIDE×FB_MAX_H output texture + let max_u = width as f32 / crate::disp::FB_STRIDE as f32; let max_v_main = height as f32 / crate::disp::FB_MAX_H as f32; unsafe { // Main display quad (letterboxed).