File size: 2,000 Bytes
096584a
 
 
955ce73
8aa943e
 
 
 
096584a
 
8aa943e
cb7d06b
caa2240
 
8aa943e
 
caa2240
096584a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4b02b2
 
39166f8
c4b02b2
 
 
39166f8
c4b02b2
 
 
 
39166f8
c4b02b2
 
 
 
 
 
 
096584a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

import { RenderedScene, RenderRequest } from "../types.mts"

import { saveRenderedSceneToCache } from "../utils/filesystem/saveRenderedSceneToCache.mts"
import { renderSegmentation } from "./renderSegmentation.mts"
import { renderUpscaling } from "./renderUpscaling.mts"
import { renderContent } from "./renderContent.mts"
import { renderAnalysis } from "./renderAnalysis.mts"

export async function renderPipeline(request: RenderRequest, response: RenderedScene) {
  await renderContent(request, response)

  await Promise.all([
    renderSegmentation(request, response),
    renderAnalysis(request, response),
    renderUpscaling(request, response)
  ])

  /*
  this is the optimized pipeline
  However, right now it doesn't work because for some reason,
  asking to generate the same seed + prompt on different nb of steps
  doesn't generate the same image!

  // first we need to wait for the low quality pre-render
  await renderContent({
    ...request,

    // we are a bit more aggressive with the quality of the video preview
    nbSteps: isVideo ? 8 : 16
  }, response)

  // then we can run both the segmentation and the high-res render at the same time
  await Promise.all([
    renderSegmentation(request, response),
    renderContent(request, response)
  ])
  */

  response.status = "completed"
  response.error = ""

  if (!request.cache || request.cache === "ignore") {
    // console.log("client asked to not use the cache in the rendering pipeline")
    return
  }

  // console.log("client asked this for cache: "+request.cache)

  try {
    // since the request is now completed we cache it
    await saveRenderedSceneToCache(request, response)
    // console.log("successfully saved to cache")

    // we don't really need to remove it from the in-memory cache 
    // (the cache queue in src/production/renderScene.mts)
    // since this cache queue has already an automatic pruning
  } catch (err) {
    console.error(`failed to save to cache, but no big deal: ${err}`)
  }
}