载入中...
搜索中...
未找到
ArtifactProvider.h
浏览该文件的文档.
1#pragma once
2
10
11#include <cstddef>
12#include <cstdint>
13#include <optional>
14#include <string>
15#include <vector>
16
17namespace eve::graphics {
18
19class Graphics;
20class Mesh;
21
26
30 std::string buildKey;
31 std::string role;
32 std::size_t vertexCount = 0;
33 std::size_t indexCount = 0;
34 std::uint64_t checksum = 0;
36 std::uint32_t backendVertexStride = 0;
38 std::uint32_t backendIndexElementSize = 0;
39
42};
43
47 std::string buildKey;
49 std::string role;
50 std::vector<float> positions;
51 std::vector<float> normals;
52 std::vector<float> uvs;
53 std::vector<std::uint32_t> indices;
55 std::string backendName = "cpu";
57 std::string uploadState = "not-attempted";
59 bool gpuResident = false;
61 std::uint32_t backendVertexStride = 0;
63 std::uint32_t backendIndexElementSize = 0;
64};
65
73public:
75 [[nodiscard]] static std::optional<GraphicsArtifactDescriptor> describe(
76 const eve::artifact::PublicationView& publication);
77};
78
88public:
91 const eve::artifact::PublicationView& publication) override;
93 [[nodiscard]] eve::Result<eve::Value> snapshotState() const override;
95 [[nodiscard]] eve::Result<void> restoreState(const eve::Value& state) override;
97 [[nodiscard]] bool emptyState() const noexcept override { return resources_.empty(); }
99 void clearState() noexcept override { clear(); }
100
110 [[nodiscard]] const GraphicsArtifactResource* find(eve::PersistentId id) const noexcept;
112 [[nodiscard]] std::size_t size() const noexcept { return resources_.size(); }
114 [[nodiscard]] std::uint64_t checksum(eve::PersistentId id) const noexcept;
116 [[nodiscard]] std::optional<GraphicsArtifactDescriptor> descriptor(eve::PersistentId id) const;
118 [[nodiscard]] bool isGpuResident(eve::PersistentId id) const noexcept;
120 void clear() noexcept;
122 void setPrepareFailure(bool enabled) noexcept { failPrepare_ = enabled; }
123
125 void bindGraphics(Graphics* graphics) noexcept;
127 void detachGraphics(Graphics* graphics) noexcept;
128
129private:
131 struct RuntimeResource {
133 Mesh* uploadedMesh = nullptr;
134 };
135 static void uploadIfAvailable(Graphics* graphics, RuntimeResource& resource) noexcept;
136 void commit(RuntimeResource resource) noexcept;
137 void release(RuntimeResource& resource) noexcept;
138 std::vector<RuntimeResource> resources_;
139 Graphics* graphics_ = nullptr;
140 std::uint32_t nextIndex_ = 0;
141 bool failPrepare_ = false;
142};
143
145[[nodiscard]] EVENGINE_API_BACKENDS GraphicsArtifactProvider& graphicsArtifactProvider() noexcept;
147EVENGINE_API_BACKENDS void registerGraphicsArtifactProvider(Graphics* graphics = nullptr);
149void detachGraphicsArtifactProvider(Graphics* graphics) noexcept;
150
151} // namespace eve::graphics
Low-level capability contracts for publishing backend-neutral artifacts.
std::string descriptor
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
Strong generation-qualified handles for non-ECS runtime registries.
std::string resource
Move-only operation result carrying either a value or Status.
Definition Result.h:155
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Graphics resource publication capability, implemented by graphics.
Id128 public API.
Definition Identity.h:112
Real graphics-module provider for generated mesh publication.
std::size_t size() const noexcept
Return the number of committed graphics resources.
bool emptyState() const noexcept override
Return whether the graphics registry has no committed resources.
void clearState() noexcept override
Clear provider state through the common restore-cleanup hook.
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25
Computes the same descriptor a WebGPU backend would expose without a device.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
void detachGraphicsArtifactProvider(Graphics *graphics) noexcept
Detach a Graphics instance before its derived backend is destroyed.
void registerGraphicsArtifactProvider(Graphics *graphics)
Register the graphics provider in the common capability registry.
GraphicsArtifactProvider & graphicsArtifactProvider() noexcept
Return the process-owned graphics artifact provider singleton.
bool enabled
Borrowed immutable view of one complete generated publication.
Backend-neutral mesh descriptor shared by Vulkan and WebGPU adapters.
friend bool operator==(const GraphicsArtifactDescriptor &, const GraphicsArtifactDescriptor &)=default
Operator ==.
std::uint32_t backendVertexStride
Actual backend vertex stride when a live upload exists.
std::uint32_t backendIndexElementSize
Actual backend index element size when a live upload exists.
Owner tag for graphics artifact runtime handles.
Queryable backend-neutral mesh resource owned by the graphics module.
std::uint32_t backendVertexStride
Actual backend vertex stride, zero when no upload exists.
std::string backendName
Backend name observed when upload was attempted, or cpu.
std::vector< std::uint32_t > indices
std::uint32_t backendIndexElementSize
Actual backend index element size, zero when no upload exists.
bool gpuResident
Whether the provider currently owns a backend resource for this descriptor.
std::string uploadState
Explicit upload outcome: not-attempted, uploaded, or capability-degraded.