(view: IRenderView, state: IProgramState)
| 221 | } |
| 222 | |
| 223 | export function runProgram(view: IRenderView, state: IProgramState) { |
| 224 | let timer0 = performance.now(); |
| 225 | |
| 226 | if (!state.render) { |
| 227 | return; |
| 228 | } |
| 229 | |
| 230 | resetRenderBuffers(state.render); |
| 231 | state.render.sharedRender.activePhase = RenderPhase.Opaque; |
| 232 | state.display.lines = []; |
| 233 | state.display.hoverTarget = null; |
| 234 | state.display.tokenColors = null; |
| 235 | state.display.tokenIdxColors = null; |
| 236 | |
| 237 | if (state.wasmGptModel && state.jsGptModel) { |
| 238 | syncWasmDataWithJsAndGpu(state.wasmGptModel, state.jsGptModel); |
| 239 | } |
| 240 | |
| 241 | if (state.stepModel && state.wasmGptModel && state.jsGptModel) { |
| 242 | state.stepModel = false; |
| 243 | stepWasmModel(state.wasmGptModel, state.jsGptModel); |
| 244 | } |
| 245 | |
| 246 | // generate the base model, incorporating the gpu-side model if available |
| 247 | state.layout = genGptModelLayout(state.shape, state.jsGptModel); |
| 248 | |
| 249 | // @TODO: handle different models in the same scene. |
| 250 | // Maybe need to copy a lot of different things like the entire render state per model? |
| 251 | for (let example of state.examples) { |
| 252 | if (example.enabled && !example.layout) { |
| 253 | let layout = genGptModelLayout(example.shape, null, example.offset); |
| 254 | example.layout = layout; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | genModelViewMatrices(state, state.layout!); |
| 259 | |
| 260 | let queryRes = beginQueryAndGetPrevMs(state.render.queryManager, 'render'); |
| 261 | if (isNotNil(queryRes)) { |
| 262 | state.render.lastGpuMs = queryRes; |
| 263 | } |
| 264 | |
| 265 | state.render.renderTiming = false; // state.pageLayout.isDesktop; |
| 266 | |
| 267 | // will modify layout; view; render a few things. |
| 268 | if (state.inWalkthrough) { |
| 269 | runWalkthrough(state, view); |
| 270 | } |
| 271 | |
| 272 | updateCamera(state, view); |
| 273 | |
| 274 | drawBlockInfo(state); |
| 275 | // these will get modified by the walkthrough (stored where?) |
| 276 | drawAllArrows(state.render, state.layout); |
| 277 | |
| 278 | drawModelCard(state, state.layout, 'nano-gpt', new Vec3()); |
| 279 | // drawTokens(state.render, state.layout, state.display); |
| 280 |
no test coverage detected