载入中...
搜索中...
未找到
FrameCapture.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4#include "common/Result.h"
5
6#include <array>
7#include <chrono>
8#include <cstddef>
9#include <cstdint>
10#include <functional>
11#include <memory>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace eve {
17
19enum class FrameAttachment : uint8_t {
20 Final,
21 Depth,
22 HwDepth,
23 Normal,
24 Albedo,
28 Shadow0,
29 Shadow1,
31};
33enum class FrameCapturePhase : uint8_t {
34 Queued,
37 Ready,
38 Failed,
40 Expired,
42};
46[[nodiscard]] constexpr size_t framePixelBytes(FramePixelFormat format) {
47 switch (format) {
50 case FramePixelFormat::Depth32Float: return 4;
51 case FramePixelFormat::Rgba16Float: return 8;
52 }
53 return 0;
54}
56[[nodiscard]] EVENGINE_API_FOUNDATION std::string_view frameAttachmentName(FrameAttachment attachment);
58[[nodiscard]] EVENGINE_API_FOUNDATION Result<FrameAttachment> parseFrameAttachment(std::string_view name);
61
64 std::vector<FrameAttachment> attachments;
65 std::chrono::milliseconds timeout{5000};
66 bool reportUnavailable = false;
67 std::string requestKey;
68};
69
74 uint32_t width = 0, height = 0;
75 uint64_t producerFrameId = 0;
76 std::string unavailableReason;
77 std::string encoding;
78 std::string colorSpace;
79 std::array<float, 16> producerMatrix{};
80 std::shared_ptr<const std::vector<uint8_t>> bytes;
81};
82
85 std::string token;
87 uint64_t frameId = 0, generation = 0;
88 uint64_t targetGeneration = 0;
89 std::string backend;
90 std::string reason;
91 std::vector<FrameCaptureBuffer> buffers;
92 std::array<float, 16> inverseProjection{};
93 std::array<float, 16> viewMatrix{};
94 std::array<float, 16> projectionMatrix{};
95 std::string depthConvention;
96};
97
100 std::string backend;
101 std::vector<FrameAttachment> attachments;
102 uint64_t generation = 0;
103 size_t maxBytes = 256u * 1024u * 1024u;
104};
105
112public:
113 static constexpr const char* capabilityName = "IRenderFrameCapture";
115 virtual ~IRenderFrameCapture() = default;
117 [[nodiscard]] virtual FrameCaptureCapabilities capabilities() const = 0;
121 [[nodiscard]] virtual Result<FrameCaptureSnapshot> snapshot(std::string_view token) = 0;
123 [[nodiscard]] virtual Result<FrameCapturePhase> release(std::string_view token) = 0;
125 virtual void invalidate() = 0;
126};
127
134public:
135 using Clock = std::function<std::chrono::steady_clock::time_point()>;
139 explicit FrameCaptureStore(Clock clock);
145 void configure(FrameCaptureCapabilities capabilities);
147 [[nodiscard]] FrameCaptureCapabilities capabilities() const override;
151 [[nodiscard]] Result<FrameCaptureSnapshot> snapshot(std::string_view token) override;
153 [[nodiscard]] Result<FrameCapturePhase> release(std::string_view token) override;
155 void invalidate() override;
157 void collect();
159 [[nodiscard]] std::optional<std::pair<std::string, FrameCaptureRequest>> queued();
161 [[nodiscard]] Result<void> begin(std::string_view token, uint64_t frameId, size_t bytes);
163 [[nodiscard]] Result<void> submitted(std::string_view token);
165 [[nodiscard]] Result<void> complete(std::string_view token, FrameCaptureSnapshot snapshot);
167 [[nodiscard]] Result<void> fail(std::string_view token, std::string reason);
169 void retire(std::string_view token);
170
171private:
172 struct Impl;
173 std::unique_ptr<Impl> impl_;
174};
175} // namespace eve
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
const GltfImportRequest & request
Snapshot snapshot
std::uint64_t bytes
OceanGpuFrameToken token
size_t queued
Definition OnnxGpgpu.cpp:60
Move-only, checked operation results for the common layer.
size_t begin
float phase
Graphics-owned state machine and immutable CPU snapshot authority. @thread Main-thread only; supplied...
FrameCaptureStore(const FrameCaptureStore &)=delete
std::function< std::chrono::steady_clock::time_point()> Clock
~FrameCaptureStore() override
Destroy CPU snapshots; backend must retire its GPU staging first.
FrameCaptureStore & operator=(const FrameCaptureStore &)=delete
Single-provider frame observation boundary, independent of graphics headers. @thread Engine main thre...
virtual Result< FrameCaptureSnapshot > snapshot(std::string_view token)=0
Inspect an immutable CPU snapshot; never waits on a GPU fence.
virtual Result< std::string > request(FrameCaptureRequest request)=0
Queue next normal frame. @cost Readback scales with selected pixel count, once per request.
virtual FrameCaptureCapabilities capabilities() const =0
Inspect backend support, without GPU work.
virtual Result< FrameCapturePhase > release(std::string_view token)=0
Cancel or release a token; in-flight resources remain backend-owned until safe.
virtual void invalidate()=0
Invalidate all tokens on provider or game generation changes.
virtual ~IRenderFrameCapture()=default
Destroy the service after withdrawing its registration.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
FrameCapturePhase
Capture progress; Ready is published only after all selected copies complete.
constexpr size_t framePixelBytes(FramePixelFormat format)
Packed CPU bytes per pixel; pure value query, callable on any thread.
std::string_view frameAttachmentName(FrameAttachment a)
Stable protocol spelling of an attachment.
Result< FrameAttachment > parseFrameAttachment(std::string_view name)
Validate a protocol attachment name without inventing a resource.
FramePixelFormat
CPU storage encoding; no GPU object escapes the provider.
FrameAttachment
Stable logical render attachments; Depth and Velocity share storage.
std::string_view frameCapturePhaseName(FrameCapturePhase p)
Stable protocol spelling of a progress state.
Immutable CPU attachment with producer-provided decoding metadata.
std::shared_ptr< const std::vector< uint8_t > > bytes
std::string unavailableReason
std::array< float, 16 > producerMatrix
FramePixelFormat format
FrameAttachment attachment
Backend support is explicit; candidates need not be produced in every frame.
std::vector< FrameAttachment > attachments
Owning request; timeout uses monotonic wall time, never gameplay time.
std::chrono::milliseconds timeout
std::vector< FrameAttachment > attachments
Owning snapshot metadata; byte storage is immutable and lease-owned.
std::array< float, 16 > projectionMatrix
std::array< float, 16 > inverseProjection
std::vector< FrameCaptureBuffer > buffers
std::array< float, 16 > viewMatrix
FrameCapturePhase phase