verify-textured-region-budgets.mjs 1.8 KB

12345678910
  1. import assert from 'node:assert/strict'
  2. import {readFileSync,writeFileSync} from 'node:fs'
  3. import {resolve,join} from 'node:path'
  4. import {selectDetailRegions} from '../../src/modules/cockpit/services/regionLoading.js'
  5. const dir=resolve(process.argv[2]),m=JSON.parse(readFileSync(join(dir,'manifest.json'))),sweep=JSON.parse(readFileSync('.scratch/cockpit-shell-panel-layout/verify/artifacts/t35/admission-pose-sweep-v7.json')),samples=[]
  6. for(const r of m.regions){assert.ok(r.contentCount<=180&&r.decodedGeometryBytes<=96*1024*1024);assert.equal(new Set(r.contentUrls).size,r.contentCount);assert.equal(r.previewCount,r.previewContentUrls.length);assert.equal(r.previewRecords.length,r.previewCount)}
  7. for(const pose of sweep.samples){const ids=pose.newRegions,rs=ids.map(id=>m.regions.find(r=>r.id===id));assert.ok(rs.every(Boolean));const contents=rs.reduce((s,r)=>s+r.contentCount,0),memory=rs.reduce((s,r)=>s+r.decodedGeometryBytes,0);assert.ok(ids.length<=2&&contents<=180&&memory<=96*1024*1024);assert.deepEqual(selectDetailRegions(rs,{pipeline:true}),[]);samples.push({heading:pose.heading,pitch:pose.pitch,range:pose.range,regions:ids,totalContents:contents,previewContents:rs.reduce((s,r)=>s+r.previewCount,0),decodedResourcesEstimate:memory,pipelineRegions:0,admissionBoundsUsed:pose.newVisibleContentBounds.reduce((s,r)=>s+r.visibleBounds,0)})}
  8. const result={passed:true,regions:m.regions.length,maxRegionContents:m.maxRegionContents,maxDecodedResourcesEstimate:Math.max(...m.regions.map(r=>r.decodedGeometryBytes)),samples,
  9. coarseTextureMipEstimate:m.coarseRecords.reduce((s,r)=>s+(r.decodedTextureEstimate||0),0),coarseBytes:m.coarseRecords.reduce((s,r)=>s+r.bytes,0),renderingValidated:false,fpsValidated:false}
  10. if(process.argv[3])writeFileSync(process.argv[3],JSON.stringify(result,null,2));console.log(JSON.stringify(result))