Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
lab_panel.h
Go to the documentation of this file.
1// lab_panel.h — エディタの「実験室」のパネル(14 §2・T-0142・ADR-0037)。小さな箱(sim/lab_box。8³ セル・4 m 角・300 K の空気)に
2// 物質と温度を置いて反応を試し、GPU と CPU リファレンスを刻みごとに並べて比べる。食い違ったら最初の刻みとセルを出す。
3//
4// データの流れ:
5// パネルの操作(置く・温度・刻む・戻す)→ sim::LabSession(置く操作はコマンド。箱のセルを CPU から書かない。D-107)
6// → 読み戻した GPU の箱と CPU リファレンスの箱 → パネルに断面の温度・選んだセルの成分を並べて出す。
7// 記録の保存・読み込み(コマンドの列 + ハッシュの列。sim::SerializeLabRecording)→ 再生で同じ実験を流し直す。
8// 箱は仮の世界(ProbeSim)とは別の世界で、自分の compute キューで 1 刻みずつ待って進める(エディタの道具。ADR-0001)。
9// GPU の箱は「箱を作る」を押した時に作る(debug では多重解像度のパイプラインの作成に時間がかかるので、使わない時は作らない)。
10#pragma once
11
12#include <array>
13#include <cstdint>
14#include <expected>
15#include <memory>
16#include <optional>
17#include <string>
18#include <vector>
19
20#include "gpu/com_ptr.h"
21#include "sim/lab_session.h"
22
23namespace bicameral::editor {
24
25 class LabPanel {
26 public:
27 explicit LabPanel(ID3D12Device* device);
28
29 // ImGui のフレームの中で呼ぶ
30 void Build();
31
32 // --- 人がいない確認(--auto-lab): 最初の Build で、木を置いて火を付ける実験 → 記録 → 再生を流して確かめる ---
33 void StartAuto() { m_autoPending = true; }
34 [[nodiscard]] bool AutoFailed() const { return m_autoFailed; }
35
36 private:
37 bool CreateSession();
38 void RunAuto();
39
40 void BuildControls();
41 void BuildStatus();
42 void BuildSlice();
43 void BuildCell() const;
44 void BuildRecording();
45 void Report(const std::expected<void, std::string>& result);
46
47 ComPtr<ID3D12Device5> m_device;
48 std::optional<sim::LabSession> m_session;
49 std::vector<sim::LabMaterial> m_materials;
50 std::string m_error; // 最後の失敗(GPU・ファイル)
51 std::string m_message; // 最後の操作の結果
52
53 // --- 操作の状態(View。世界に入らない)---
54 std::array<int, 3> m_cell = {3, 3, 3};
55 int m_material = 1;
57 bool m_running = false; // 毎フレーム 1 刻み
58 std::string m_recordingPath = "lab_recording.blab";
59
60 bool m_autoPending = false;
61 bool m_autoFailed = false;
62 };
63
64} // namespace bicameral::editor
ComPtr< ID3D12Device5 > m_device
Definition lab_panel.h:47
std::array< int, 3 > m_cell
Definition lab_panel.h:54
std::optional< sim::LabSession > m_session
Definition lab_panel.h:48
void Report(const std::expected< void, std::string > &result)
Definition lab_panel.cpp:77
std::vector< sim::LabMaterial > m_materials
Definition lab_panel.h:49
LabPanel(ID3D12Device *device)
Definition lab_panel.cpp:46