Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
immediate_queue.h
Go to the documentation of this file.
1// immediate_queue.h — コマンドリストを 1 本記録して投げ、GPU が終えるまで待つキュー(T-0013)。
2// テストと起動時の準備(アップロード・初期化)のための簡単な道具。フレームのループ(T-0004・T-0012)は待たない別の仕組みを使う。
3//
4// auto queue = ImmediateQueue::Create(device, D3D12_COMMAND_LIST_TYPE_COMPUTE);
5// ID3D12GraphicsCommandList10* list = queue->Begin(); // ここに記録する
6// if (!queue->ExecuteAndWait()) ... // 投げて待つ。デバイスが失われたら false
7#pragma once
8
9#include <cstdint>
10#include <expected>
11#include <string>
12
13#include "gpu/com_ptr.h"
14
15namespace bicameral::gpu {
16
18 public:
19 [[nodiscard]] static std::expected<ImmediateQueue, std::string> Create(ID3D12Device5* device,
20 D3D12_COMMAND_LIST_TYPE type);
21
22 // 記録を始める(前の記録は捨てる)。失敗なら nullptr
23 [[nodiscard]] ID3D12GraphicsCommandList10* Begin();
24
25 // 記録を閉じて投げ、GPU が終えるまで待つ。記録の誤りやデバイスの喪失なら false(理由はログ)
26 [[nodiscard]] bool ExecuteAndWait();
27
28 // タイムスタンプの周波数を得るなど、キューそのものが要るとき
29 [[nodiscard]] ID3D12CommandQueue* Native() const { return m_queue.Get(); }
30
31 private:
32 ImmediateQueue() = default;
33
34 ComPtr<ID3D12CommandQueue> m_queue;
35 ComPtr<ID3D12CommandAllocator> m_allocator;
36 ComPtr<ID3D12GraphicsCommandList10> m_list;
37 ComPtr<ID3D12Fence> m_fence;
38 uint64_t m_fenceValue = 0;
39 };
40
41} // namespace bicameral::gpu
ComPtr< ID3D12Fence > m_fence
static std::expected< ImmediateQueue, std::string > Create(ID3D12Device5 *device, D3D12_COMMAND_LIST_TYPE type)
ComPtr< ID3D12GraphicsCommandList10 > m_list
ComPtr< ID3D12CommandQueue > m_queue
ID3D12CommandQueue * Native() const
ID3D12GraphicsCommandList10 * Begin()
ComPtr< ID3D12CommandAllocator > m_allocator