@geastack/gea3d 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,17 +8,21 @@ clipping and rasterization in one scene draw per frame.
8
8
  It supports perspective and orthographic cameras, meshes and instancing,
9
9
  lines, points, sprites, fog, blending, raycasting, and optional depth buffering.
10
10
  Lambert, Phong and Standard materials use Lambert lighting rather than full
11
- Three.js material parity. This package does not implement WebGL; the broader
12
- Three.js port used by Skytail is maintained separately in `gea-threejs`.
11
+ Three.js material parity. This package does not implement WebGL; upstream Three.js
12
+ runs natively through WebGL on ANGLE with
13
+ [`@geastack/native-webgl-angle`](https://github.com/geastack/native-webgl-angle).
13
14
 
14
15
  ## Install
15
16
 
16
17
  Install this package in your Gea app or npm workspace:
17
18
 
18
19
  ```sh
19
- npm install @geastack/gea3d @geastack/core
20
+ npm install @geastack/gea3d @geastack/core @geastack/cli
20
21
  ```
21
22
 
23
+ `@geastack/cli` provides the `gea` command and brings the board targets with
24
+ it.
25
+
22
26
  Import the renderer and scene classes through the public package exports:
23
27
 
24
28
  ```ts
@@ -43,17 +47,18 @@ For native firmware, declare the renderer's C++ source in your app's
43
47
  }
44
48
  ```
45
49
 
46
- Run the app through the Gea CLI from your project root, using your registered
47
- board alias and app id:
50
+ Register your board once with `npx gea setup`, which names its alias, then run
51
+ the app through the Gea CLI from your project root:
48
52
 
49
53
  ```sh
50
- npx --no-install gea run --board mosaico --app your-app-id
54
+ npx gea run --board <alias> --app <your-app-id>
51
55
  ```
52
56
 
53
57
  The Lantern, Aviator, Neon and Orbit apps in
54
58
  [geastack/demos](https://github.com/geastack/demos) demonstrate scene setup,
55
59
  responsive panel sizes, input, animation and composition with retained UI.
56
- They depend on this package; no vendored renderer is required.
60
+ They depend on the published `@geastack/gea3d` and name its native source as
61
+ above; no vendored renderer is required.
57
62
 
58
63
  ## Package contents
59
64
 
@@ -74,7 +79,8 @@ npm ci
74
79
  npm run check
75
80
  ```
76
81
 
77
- Edit this repository's sources; the demos consume the published package.
82
+ The demos use the published package, so a change here reaches them through a
83
+ release.
78
84
 
79
85
  ## License
80
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/gea3d",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Typed Three.js-style scene graph and native software 3D renderer for Gea devices",
6
6
  "exports": {
@@ -1664,6 +1664,84 @@ void prebuildStripLists(const raster::Frame &frame, int slot)
1664
1664
  cache.rows = rows;
1665
1665
  }
1666
1666
 
1667
+ // Second-core share of a staged strip (rasterizePainterInPlace). Lantern on
1668
+ // the CrowPanel 5.0 spent ~18 ms a frame painting strips on one core while
1669
+ // the other built the next frame in ~14 ms; the helper paints the lower 3/8
1670
+ // of each strip there, above the build, and Lantern went from ~27 to ~30 fps.
1671
+ // Measured and dropped: half of each strip (the helper's raster and the build
1672
+ // contend for the shared cache: the build took 32 ms instead of 21), and
1673
+ // chunks claimed by work stealing at or below the build's priority (the
1674
+ // helper got 16-20% of the chunks, mid-chunk preemption left this core
1675
+ // waiting on it, and three rasterizers per strip re-walked the band list).
1676
+ #ifndef GEA3D_SPLIT_STRIPS
1677
+ #if defined(CONFIG_IDF_TARGET_ESP32P4)
1678
+ #define GEA3D_SPLIT_STRIPS 1
1679
+ #else
1680
+ #define GEA3D_SPLIT_STRIPS 0
1681
+ #endif
1682
+ #endif
1683
+ #ifndef GEA3D_SPLIT_EIGHTHS
1684
+ #define GEA3D_SPLIT_EIGHTHS 3
1685
+ #endif
1686
+ constexpr int kSplitMinRows = 8;
1687
+ struct SplitJob {
1688
+ const raster::Frame *frame;
1689
+ raster::BandList list;
1690
+ Pixel *base;
1691
+ int stride, x0, y0, x1, y1;
1692
+ };
1693
+ SplitJob g_splitJob{};
1694
+ raster::Scratch g_splitScratch;
1695
+ SemaphoreHandle_t g_splitWork = nullptr;
1696
+ SemaphoreHandle_t g_splitDone = nullptr;
1697
+ TaskHandle_t g_splitTask = nullptr;
1698
+ bool g_splitFailed = false;
1699
+
1700
+ void splitTaskMain(void *)
1701
+ {
1702
+ for (;;) {
1703
+ xSemaphoreTake(g_splitWork, portMAX_DELAY);
1704
+ const SplitJob job = g_splitJob;
1705
+ raster::Rasterizer lower(*job.frame, g_splitScratch, job.base, job.stride, job.x0, job.y0, job.x1, job.y1, raster::Occlusion::kPainter);
1706
+ lower.runPainter(job.list);
1707
+ xSemaphoreGive(g_splitDone);
1708
+ }
1709
+ }
1710
+
1711
+ bool ensureSplitTask()
1712
+ {
1713
+ if (!GEA3D_SPLIT_STRIPS || portNUM_PROCESSORS < 2) return false;
1714
+ if (g_splitTask) return true;
1715
+ if (g_splitFailed) return false;
1716
+ g_splitFailed = true;
1717
+ g_splitWork = xSemaphoreCreateBinary();
1718
+ g_splitDone = xSemaphoreCreateBinary();
1719
+ if (!g_splitWork || !g_splitDone) return false;
1720
+ const BaseType_t core = xPortGetCoreID() == 0 ? 1 : 0;
1721
+ const UBaseType_t priority = uxTaskPriorityGet(nullptr) + 1;
1722
+ if (xTaskCreatePinnedToCore(splitTaskMain, "gea3d_split", 6144, nullptr, priority, &g_splitTask, core) != pdPASS || !g_splitTask) {
1723
+ g_splitTask = nullptr;
1724
+ return false;
1725
+ }
1726
+ g_splitFailed = false;
1727
+ return true;
1728
+ }
1729
+
1730
+ // Paints rows y0..y1 of a staged strip with the helper; false when the strip
1731
+ // is too short to share or there is no helper.
1732
+ bool paintShared(const raster::Frame &frame, const raster::BandList &list, Pixel *base, int stride, int x0, int y0, int x1, int y1)
1733
+ {
1734
+ const int rows = y1 - y0 + 1;
1735
+ if (rows < kSplitMinRows || !ensureSplitTask()) return false;
1736
+ const int mid = y1 + 1 - (rows * GEA3D_SPLIT_EIGHTHS) / 8;
1737
+ g_splitJob = SplitJob{&frame, list, base, stride, x0, mid, x1, y1};
1738
+ xSemaphoreGive(g_splitWork);
1739
+ raster::Rasterizer upper(frame, g_renderer.scratch, base, stride, x0, y0, x1, mid - 1, raster::Occlusion::kPainter);
1740
+ upper.runPainter(list);
1741
+ xSemaphoreTake(g_splitDone, portMAX_DELAY);
1742
+ return true;
1743
+ }
1744
+
1667
1745
  bool rasterizePainterInPlace(const raster::Frame &frame, Pixel *base, int stride, int x0, int y0, int x1, int y1)
1668
1746
  {
1669
1747
  if (!esp_ptr_internal(base + static_cast<std::ptrdiff_t>(y0) * stride + x0)) return false;
@@ -1712,6 +1790,7 @@ bool rasterizePainterInPlace(const raster::Frame &frame, Pixel *base, int stride
1712
1790
  }
1713
1791
  list = raster::BandList{items.data(), static_cast<int>(items.size()), opaque};
1714
1792
  }
1793
+ if (paintShared(frame, list, base, stride, x0, y0, x1, y1)) return true;
1715
1794
  raster::Rasterizer rasterizer(frame, g_renderer.scratch, base, stride, x0, y0, x1, y1, raster::Occlusion::kPainter);
1716
1795
  rasterizer.runPainter(list);
1717
1796
  return true;