9 std::expected<LabSession, std::string>
LabSession::Create(ID3D12Device5* device, D3D12_COMMAND_LIST_TYPE queueType,
13 return std::unexpected(queue.error());
17 return std::unexpected(ring.error());
21 return std::unexpected(box.error());
23 return LabSession(table, std::move(*queue), std::move(*ring), std::move(*box));
30 m_box(std::move(box)),
47 uint32_t temperatureMilliKelvin) {
59 std::vector<Command> commands;
61 command.targetTick = tick;
62 commands.push_back(command);
79 const uint64_t tick =
m_tick;
80 const std::vector<Command> commands =
TakeCommands(tick);
83 ID3D12GraphicsCommandList10* list =
m_queue.Begin();
85 return std::unexpected(
"コマンドリストを始められない");
89 return std::unexpected(
"初めの箱を写せない");
91 if (!
m_box.RecordTick(list,
m_ring.GpuAddress(), tick, commands))
92 return std::unexpected(
"刻みを記録できない");
94 m_box.RecordReadback(list);
95 m_ring.RecordReadbackAndReset(list);
97 return std::unexpected(
"GPU での実行に失敗");
101 return std::unexpected(std::format(
"GPU の FX_ASSERT が {} 件(刻み {})", debug.assertCount, tick));
104 return std::unexpected(
"箱を読み戻せない");
121 for (uint32_t i = 0; i < tickCount && !
m_mismatch; ++i) {
122 if (
auto stepped =
StepOne(); !stepped)
150 if (
auto reset =
Reset(); !reset)
static std::expected< DebugRing, std::string > Create(ID3D12Device *device, uint32_t slotCount=1)
static std::expected< GpuLabBox, std::string > Create(ID3D12Device5 *device, const BakedReactionTable &table)
std::optional< LabMismatch > m_mismatch
std::vector< uint64_t > m_hashes
bool Queue(const Command &command)
std::expected< void, std::string > Step(uint32_t tickCount)
std::vector< Command > m_history
bool SetTemperature(LabCellPosition cell, uint32_t temperatureMilliKelvin)
BakedReactionTable m_table
std::optional< uint64_t > m_replayDivergence
std::expected< void, std::string > Replay(const LabRecording &recording)
std::expected< void, std::string > StepOne()
LabRecording Recording() const
std::expected< void, std::string > Reset()
std::vector< Command > m_scheduled
std::vector< uint64_t > m_replayHashes
static std::expected< LabSession, std::string > Create(ID3D12Device5 *device, D3D12_COMMAND_LIST_TYPE queueType, const BakedReactionTable &table)
std::vector< Command > m_pending
bool Place(LabCellPosition cell, std::span< const SpeciesAmount > contents, uint32_t temperatureMilliKelvin)
gpu::ImmediateQueue m_queue
std::vector< Command > TakeCommands(uint64_t tick)
LabSession(BakedReactionTable table, gpu::ImmediateQueue queue, gpu::DebugRing ring, GpuLabBox box)
constexpr bool CommandPrecedes(const Command &a, const Command &b)
constexpr uint32_t LAB_MAX_COMMANDS_PER_TICK
Command MakeLabFillCommand(uint64_t targetTick, uint32_t sequence, LabCellPosition cell, std::span< const SpeciesAmount > contents, uint32_t temperatureMilliKelvin)
uint64_t HashWholeNest(const MultiresNest &nest)
void StepLabBox(MultiresNest &nest, const BakedReactionTable &table, uint64_t tick, std::span< const Command > commands)
Command MakeLabTemperatureCommand(uint64_t targetTick, uint32_t sequence, LabCellPosition cell, uint32_t temperatureMilliKelvin)
MultiresNest MakeLabBoxNest(const BakedReactionTable &table)
std::optional< LabMismatch > FindLabMismatch(const MultiresNest &cpu, const MultiresNest &gpu, uint64_t tick)
std::vector< uint64_t > hashes
std::vector< Command > commands