|
|
@ -11,7 +11,10 @@ onmessage = (e) => { |
|
|
|
} else if (msg.type === 'import') { |
|
|
|
} else if (msg.type === 'import') { |
|
|
|
const text = msg.text; |
|
|
|
const text = msg.text; |
|
|
|
if (parse(text)) { |
|
|
|
if (parse(text)) { |
|
|
|
traces['0'].geo = generate('0'); |
|
|
|
const geo = generate('0'); |
|
|
|
|
|
|
|
traces['0'].geo = geo; |
|
|
|
|
|
|
|
traces['0'].lod1 = lod(geo, 1); |
|
|
|
|
|
|
|
traces['0'].lod2 = lod(geo, 2); |
|
|
|
delete traces['0'].raw; |
|
|
|
delete traces['0'].raw; |
|
|
|
postMessage({'type': 'trace', 'data': traces['0']}); |
|
|
|
postMessage({'type': 'trace', 'data': traces['0']}); |
|
|
|
} |
|
|
|
} |
|
|
@ -305,7 +308,7 @@ function pack_instruction(instruction, positions, sizes, colors, uvs, starts, y) |
|
|
|
const next_stage = instruction.lanes['0'][i + 1]; |
|
|
|
const next_stage = instruction.lanes['0'][i + 1]; |
|
|
|
stage_cycles = next_stage.c - stage.c; |
|
|
|
stage_cycles = next_stage.c - stage.c; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
stage_cycles = instruction.retcyc - stage.c; |
|
|
|
stage_cycles = isNaN(instruction.retcyc) ? 0 : instruction.retcyc - stage.c; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (stage_cycles > max_stage_cycles) { |
|
|
|
if (stage_cycles > max_stage_cycles) { |
|
|
@ -399,3 +402,56 @@ function generate(trace_id) { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lod(geo) { |
|
|
|
|
|
|
|
let x11, x12, y1, x21, x22, y2; |
|
|
|
|
|
|
|
let merged_rows = 0; |
|
|
|
|
|
|
|
let merged_quads = 0; |
|
|
|
|
|
|
|
let row_y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const merge_count = 100; |
|
|
|
|
|
|
|
const merged_vertices = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < geo.pos.length; i += 2) { |
|
|
|
|
|
|
|
const at_x = geo.pos[i + 0]; |
|
|
|
|
|
|
|
const at_y = geo.pos[i + 1]; |
|
|
|
|
|
|
|
const w = geo.size[i + 0]; |
|
|
|
|
|
|
|
const h = geo.size[i + 1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: error metric, make sure nothing "sticks out" too much
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (merged_quads === 0) { |
|
|
|
|
|
|
|
x11 = x21 = at_x; |
|
|
|
|
|
|
|
y2 = row_y = at_y + h; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (merged_rows === 0) { |
|
|
|
|
|
|
|
y1 = at_y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (merged_quads === 0) { |
|
|
|
|
|
|
|
x12 = x22 = at_x; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x12 = Math.max(x12, at_x + w); |
|
|
|
|
|
|
|
x22 = Math.max(x22, at_x + w); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
++merged_quads; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (at_y != row_y) { |
|
|
|
|
|
|
|
merged_quads = 0; |
|
|
|
|
|
|
|
++merged_rows; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (merged_rows === merge_count) { |
|
|
|
|
|
|
|
merged_vertices.push( |
|
|
|
|
|
|
|
x11, y1, x12, y1, |
|
|
|
|
|
|
|
x21, y2, x22, y2 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(`(${x11}, ${y1}) - (${x12}, ${y1}) - (${x21}, ${y2}) - (${x22}, ${y2})`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
merged_rows = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|