Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
screenshot.h
Go to the documentation of this file.
1// screenshot.h — バックバッファを画像ファイル(BMP)に書く(T-0015。10「テスト」の画像比較の入口)。
2//
3// データの流れ: フレームのループが最後のフレームの描画の後・Present の前に Record() で「バックバッファ → 読み戻しのバッファ」を
4// direct キューに積む → GPU が終わってから(フレームのループの終わりの Flush の後)WriteBmp() がファイルに書く。
5// 外部のライブラリを使わないため BMP(32bit、上から下)。比較・変換は tools 側で行う。
6#pragma once
7
8#include <cstdint>
9#include <expected>
10#include <filesystem>
11#include <string>
12
13#include "core/aliases.h"
14#include "gpu/com_ptr.h"
15
16namespace bicameral::render {
17
19 public:
20 // backBuffer と同じ大きさの読み戻しのバッファと、写すためのコマンドリストを作る
21 [[nodiscard]] static std::expected<ScreenshotCapture, std::string> Create(ID3D12Device* device,
22 ID3D12Resource* backBuffer);
23
24 // PRESENT のバックバッファを写すリストを記録して返す(Present の前に direct キューへ投げる)
25 [[nodiscard]] ID3D12CommandList* Record(ID3D12Resource* backBuffer);
26
27 // 写したリストを GPU が終えた後に呼ぶ(RGBA8 → BMP の BGRA)
28 [[nodiscard]] std::expected<void, std::string> WriteBmp(const fs::path& path) const;
29
30 private:
31 ScreenshotCapture() = default;
32
33 // --- 写すリスト ---
34 ComPtr<ID3D12CommandAllocator> m_allocator;
35 ComPtr<ID3D12GraphicsCommandList> m_list;
36
37 // --- 写し先と、その並び ---
38 ComPtr<ID3D12Resource> m_readback;
39 D3D12_PLACED_SUBRESOURCE_FOOTPRINT m_footprint{};
40 uint32_t m_width = 0;
41 uint32_t m_height = 0;
42 };
43
44} // namespace bicameral::render
std::expected< void, std::string > WriteBmp(const fs::path &path) const
static std::expected< ScreenshotCapture, std::string > Create(ID3D12Device *device, ID3D12Resource *backBuffer)
ComPtr< ID3D12GraphicsCommandList > m_list
Definition screenshot.h:35
D3D12_PLACED_SUBRESOURCE_FOOTPRINT m_footprint
Definition screenshot.h:39
ComPtr< ID3D12CommandAllocator > m_allocator
Definition screenshot.h:34
ComPtr< ID3D12Resource > m_readback
Definition screenshot.h:38
ID3D12CommandList * Record(ID3D12Resource *backBuffer)