mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
more profile work
This commit is contained in:
parent
7c2c1a62d5
commit
0c141a9cff
|
@ -11,6 +11,8 @@
|
|||
#include "../graphics/graphics.h"
|
||||
#include "../util/memory.h"
|
||||
|
||||
extern u16 __attribute__((aligned(64))) zbuffer[SCREEN_HT * SCREEN_WD];
|
||||
|
||||
#define VIDEO_MSG 666
|
||||
#define RSP_DONE_MSG 667
|
||||
#define RDP_DONE_MSG 668
|
||||
|
@ -172,6 +174,9 @@ void profileTask(OSSched* scheduler, OSThread* currentThread, OSTask* task, u16*
|
|||
// sprintf(message, "step_%d", curr - (Gfx*)task->t.data_ptr);
|
||||
// gdbSendImage(message, SCREEN_WD, SCREEN_HT, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer);
|
||||
|
||||
// sprintf(message, "step_zb_%d", curr - (Gfx*)task->t.data_ptr);
|
||||
// gdbSendImage(message, SCREEN_WD, SCREEN_HT, G_IM_FMT_RGBA, G_IM_SIZ_16b, zbuffer);
|
||||
|
||||
++curr;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ for (let i = 0; i < SCREEN_WD * SCREEN_HT; ++i) {
|
|||
}
|
||||
|
||||
function calculateAverage(batch) {
|
||||
const combinedCommands = [];
|
||||
let combinedCommands = [];
|
||||
|
||||
for (const parsedLine of batch.lines) {
|
||||
const existing = combinedCommands[parsedLine.index];
|
||||
|
@ -199,7 +199,7 @@ function calculateAverage(batch) {
|
|||
current.startTime /= current.total;
|
||||
}
|
||||
|
||||
if (fs.existsSync(`log_images/step_${i}.bmp`)) {
|
||||
if (current && fs.existsSync(`log_images/step_${i}.bmp`)) {
|
||||
const data = fs.readFileSync(`log_images/step_${i}.bmp`);
|
||||
current.imageData = data.subarray(14 + 12);
|
||||
console.log(`log_images/step_${i}.bmp`);
|
||||
|
@ -209,6 +209,10 @@ function calculateAverage(batch) {
|
|||
for (let i = 0; i + 1 < combinedCommands.length; ++i) {
|
||||
const current = combinedCommands[i];
|
||||
const next = combinedCommands[i + 1];
|
||||
|
||||
if (!current || !next) {
|
||||
continue;
|
||||
}
|
||||
|
||||
current.elapsedTime = next.startTime - current.startTime;
|
||||
|
||||
|
@ -248,6 +252,8 @@ function calculateAverage(batch) {
|
|||
|
||||
combinedCommands.sort((a, b) => b.elapsedTime - a.elapsedTime);
|
||||
|
||||
combinedCommands = combinedCommands.filter(Boolean);
|
||||
|
||||
batch.combinedCommands = combinedCommands;
|
||||
}
|
||||
|
||||
|
|
75
tools/zimage_formatter.js
Normal file
75
tools/zimage_formatter.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
const fs = require('fs');
|
||||
|
||||
function pad(idx, len) {
|
||||
let result = String(idx);
|
||||
|
||||
while (result.length < len) {
|
||||
result = '0' + result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function fixForImage(imageIdx) {
|
||||
const filename = process.argv[2] + String(imageIdx) + '.bmp';
|
||||
|
||||
if (!fs.existsSync(filename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = fs.readFileSync(filename);
|
||||
const imageInput = data.subarray(14 + 12);
|
||||
|
||||
let idx = 0;
|
||||
|
||||
const grayscale = [];
|
||||
|
||||
const SCREEN_WD = 320;
|
||||
const SCREEN_HT = 240;
|
||||
|
||||
for (let x = 0; x < SCREEN_WD; ++x) {
|
||||
for (let y = 0; y < SCREEN_HT; ++y) {
|
||||
grayscale.push(((imageInput[idx + 2] & 0xF8) << 7) | ((imageInput[idx + 1] & 0xF8) << 2) | ((imageInput[idx + 0] & 0xF8) >> 3));
|
||||
|
||||
idx += 3;
|
||||
}
|
||||
}
|
||||
|
||||
const headerSize = 14;
|
||||
const dataSize = SCREEN_WD * SCREEN_HT * 3;
|
||||
|
||||
const dibHeaderSize = 12;
|
||||
|
||||
const buffer = Buffer.alloc(headerSize + dibHeaderSize + dataSize);
|
||||
|
||||
buffer[0] = 0x42;
|
||||
buffer[1] = 0x4D;
|
||||
|
||||
buffer.writeUInt32LE(buffer.length, 2);
|
||||
buffer.writeUInt16LE(0, 6);
|
||||
buffer.writeUInt16LE(0, 8);
|
||||
buffer.writeUInt32LE(headerSize + dibHeaderSize, 10);
|
||||
|
||||
buffer.writeUInt32LE(12, 14);
|
||||
buffer.writeUInt16LE(SCREEN_WD, 18);
|
||||
buffer.writeUInt16LE(SCREEN_HT, 20);
|
||||
buffer.writeUInt16LE(1, 22);
|
||||
buffer.writeUInt16LE(24, 24);
|
||||
|
||||
for (let idx = 0; idx < SCREEN_WD * SCREEN_HT; ++idx) {
|
||||
const outIdx = headerSize + dibHeaderSize + idx * 3;
|
||||
|
||||
const value = Math.floor(grayscale[idx] >> 7);
|
||||
|
||||
buffer[outIdx + 2] = value;
|
||||
buffer[outIdx + 1] = value;
|
||||
buffer[outIdx + 0] = value;
|
||||
}
|
||||
|
||||
fs.writeFileSync(process.argv[3] + pad(String(imageIdx), 3) + '.bmp', buffer);
|
||||
}
|
||||
|
||||
|
||||
for (let i = 0; i <= 300; ++i) {
|
||||
fixForImage(i);
|
||||
}
|
Loading…
Reference in a new issue