@@ -21,8 +21,11 @@ export function WebGLShader() {
2121 targetFps : "Uncapped (Native)" ,
2222 dprMultiplier : 1.5 ,
2323 actualDpr : 1 ,
24+ logicalWidth : 0 ,
25+ logicalHeight : 0 ,
2426 canvasWidth : 0 ,
2527 canvasHeight : 0 ,
28+ frameTimeMs : 0 ,
2629 concurrency : 4 ,
2730 memory : 4 ,
2831 renderer : "Unknown" ,
@@ -201,11 +204,13 @@ export function WebGLShader() {
201204 let time = 0 ;
202205
203206 // Stats update helper
204- const updateStats = ( w : number , h : number , isDegraded = false ) => {
207+ const updateStats = ( w : number , h : number , lw : number , lh : number , isDegraded = false ) => {
205208 setStats ( s => ( {
206209 ...s ,
207210 canvasWidth : w ,
208211 canvasHeight : h ,
212+ logicalWidth : lw ,
213+ logicalHeight : lh ,
209214 concurrency,
210215 memory,
211216 renderer,
@@ -227,7 +232,7 @@ export function WebGLShader() {
227232 gl . viewport ( 0 , 0 , canvas . width , canvas . height ) ;
228233 gl . uniform2f ( resolutionLocation , canvas . width , canvas . height ) ;
229234
230- updateStats ( canvas . width , canvas . height ) ;
235+ updateStats ( canvas . width , canvas . height , width , height ) ;
231236 } ;
232237
233238 resize ( ) ;
@@ -262,7 +267,7 @@ export function WebGLShader() {
262267 framesRenderedRef . current ++ ;
263268 if ( currentTime - lastFpsCalculateTimeRef . current >= 1000 ) {
264269 const actualFps = framesRenderedRef . current ;
265- setStats ( s => ( { ...s , fps : actualFps } ) ) ;
270+ setStats ( s => ( { ...s , fps : actualFps , frameTimeMs : Number ( ( 1000 / Math . max ( actualFps , 1 ) ) . toFixed ( 2 ) ) } ) ) ;
266271 framesRenderedRef . current = 0 ;
267272 lastFpsCalculateTimeRef . current = currentTime ;
268273
@@ -273,7 +278,7 @@ export function WebGLShader() {
273278 if ( frameDropsRef . current > 3 && currentPixelRatio > 0.5 ) {
274279 currentPixelRatio = Math . max ( 0.5 , currentPixelRatio - 0.5 ) ;
275280 resize ( ) ;
276- updateStats ( canvas . width , canvas . height , true ) ;
281+ updateStats ( canvas . width , canvas . height , window . innerWidth , window . innerHeight , true ) ;
277282 frameDropsRef . current = 0 ;
278283 console . warn ( "WebGL Shader: Performance degraded, dropping pixel multiplier to" , currentPixelRatio ) ;
279284 }
@@ -333,38 +338,43 @@ export function WebGLShader() {
333338 />
334339
335340 { /* Stats for nerds toggle & panel */ }
336- < div className = "fixed bottom-4 left-4 z-50 flex flex-col items-start gap-2" >
341+ < div className = "fixed bottom-4 left-4 z-50 flex flex-col items-start gap-2 max-w-[calc(100vw-2rem)] pointer-events-none " >
337342 { showStats && (
338- < div className = "bg-black/80 backdrop-blur-md rounded-xl p-4 text-xs font-mono text-green-400 border border-green-500/30 w-72 shadow-2xl animate-fade-in shadow-black/50" >
343+ < div className = "bg-black/80 backdrop-blur-md rounded-xl p-3 sm:p- 4 text-[10px] sm:text- xs font-mono text-green-400 border border-green-500/30 w-[85vw] sm:w-80 shadow-2xl animate-fade-in shadow-black/50 overflow-hidden pointer-events-auto " >
339344 < div className = "flex justify-between items-center mb-2 pb-2 border-b border-green-500/20" >
340345 < span className = "font-bold text-green-300 tracking-wider" > STATS FOR NERDS</ span >
341- < button onClick = { ( ) => setShowStats ( false ) } className = "text-green-500 hover:text-green-300 transition-colors" >
346+ < button onClick = { ( ) => setShowStats ( false ) } className = "text-green-500 hover:text-green-300 transition-colors p-1 -mr-1 " >
342347 < X className = "w-4 h-4" />
343348 </ button >
344349 </ div >
345350 < div className = "space-y-1" >
346- < div className = "flex justify-between" > < span > Current FPS:</ span > < span className = "text-white" > { stats . fps } </ span > </ div >
351+ < div className = "flex justify-between" > < span > Current FPS:</ span > < span className = "text-white" > { stats . fps } < span className = "text-green-500/50" > ( { stats . frameTimeMs } ms) </ span > </ span > </ div >
347352 < div className = "flex justify-between" > < span > Target FPS:</ span > < span className = "text-white" > { stats . targetFps } </ span > </ div >
348- < div className = "flex justify-between" > < span > Degraded Mode:</ span > < span className = { stats . degraded ? "text-red-400 font-bold" : "text-white" } > { stats . degraded ? "YES" : "NO" } </ span > </ div >
353+ < div className = "flex justify-between" > < span > Degraded Mode:</ span > < span className = { stats . degraded ? "text-red-400 font-bold" : "text-white" } > { stats . degraded ? "CRITICAL" : "OK" } </ span > </ div >
354+
349355 < div className = "flex justify-between mt-2 pt-2 border-t border-green-500/20" > < span > DPR Multiplier:</ span > < span className = "text-white" > { stats . dprMultiplier } x</ span > </ div >
350356 < div className = "flex justify-between" > < span > Actual DPR:</ span > < span className = "text-white" > { stats . actualDpr . toFixed ( 2 ) } x</ span > </ div >
351- < div className = "flex justify-between mt-2 pt-2 border-t border-green-500/20" > < span > Resolution:</ span > < span className = "text-white" > { stats . canvasWidth } x { stats . canvasHeight } </ span > </ div >
352- < div className = "flex justify-between mt-2 pt-2 border-t border-green-500/20" > < span > Concurrency:</ span > < span className = "text-white" > { stats . concurrency } Cores</ span > </ div >
357+
358+ < div className = "flex justify-between mt-2 pt-2 border-t border-green-500/20" > < span > Logical Res:</ span > < span className = "text-white" > { stats . logicalWidth } x{ stats . logicalHeight } </ span > </ div >
359+ < div className = "flex justify-between" > < span > Render Res:</ span > < span className = "text-white" > { Math . round ( stats . canvasWidth ) } x{ Math . round ( stats . canvasHeight ) } </ span > </ div >
360+ < div className = "flex justify-between text-[9px] text-green-500/60 " > < span className = "mr-4 sm:mr-8 whitespace-nowrap" > Pixels Processed:</ span > < span className = "text-right" > ~{ ( stats . canvasWidth * stats . canvasHeight ) . toLocaleString ( ) } px</ span > </ div >
361+
362+ < div className = "flex justify-between mt-2 pt-2 border-t border-green-500/20" > < span > CPU Threads:</ span > < span className = "text-white" > { stats . concurrency } </ span > </ div >
353363 < div className = "flex justify-between" > < span > Device RAM:</ span > < span className = "text-white" > ~{ stats . memory } GB</ span > </ div >
354364 < div className = "flex flex-col mt-2 pt-2 border-t border-green-500/20" >
355- < span > GPU Renderer :</ span >
356- < span className = "text-white truncate opacity-80 mt-0.5 " title = { stats . renderer } > { stats . renderer } </ span >
365+ < span className = "mb-0.5" > GPU Subsystem :</ span >
366+ < span className = "text-white opacity-80 leading-tight break-words text-[9px] sm:text-[10px] " title = { stats . renderer } > { stats . renderer } </ span >
357367 </ div >
358368 </ div >
359369 </ div >
360370 ) }
361371
362372 < button
363373 onClick = { ( ) => setShowStats ( ! showStats ) }
364- className = "group p-2.5 rounded-full bg-black/40 backdrop-blur-md border border-white/10 hover:bg-black/60 transition-all text-white/50 hover:text-white "
365- title = "Stats for nerds "
374+ className = "group p-2.5 rounded-full bg-black/40 backdrop-blur-md border border-white/10 hover:bg-black/60 hover:border-green-500/30 transition-all text-white/30 hover:text-green-400 z-50 pointer-events-auto "
375+ title = "Toggle performance stats "
366376 >
367- < Terminal className = "w-4 h-4" />
377+ < Terminal className = "w-5 h-5 sm:w-4 sm: h-4" />
368378 </ button >
369379 </ div >
370380 </ >
0 commit comments