载入中...
搜索中...
未找到
VegetationFieldGpu.cpp
浏览该文件的文档.
49bool finite(glm::vec3 value) { return std::isfinite(value.x) && std::isfinite(value.y) && std::isfinite(value.z); }
56 if (!finite(center) || !finite(extent) || extent.x < 1e-4f || extent.y < 1e-4f || extent.z < 1e-4f || !width ||
58 return Result<VegetationGpuAtlas>::failure(invalid("invalid atlas geometry or upload budget exceeded"));
99 return Result<VegetationGpuAtlas>::failure(invalid("field changed while baking vegetation atlas"));
106 DiagnosticCode::Failed, "vegetation atlas allocation failed", {}, {}, "graphics.vegetation.atlas"));
110Result<VegetationExtrasGpuAtlas> uploadVegetationExtrasAtlas(IResourceFactory& factory, const VegetationField& field,
113 return uploadAtlas(factory, field, VegetationChannel::Extras, center, extent, width, height, snapToTexel);
116Result<VegetationColorsGpuAtlas> uploadVegetationColorsAtlas(IResourceFactory& factory, const VegetationField& field,
119 return uploadAtlas(factory, field, VegetationChannel::Color, center, extent, width, height, snapToTexel);
122Result<VegetationMotionGpuAtlas> uploadVegetationMotionAtlas(IResourceFactory& factory, const VegetationField& field,
125 return uploadAtlas(factory, field, VegetationChannel::Motion, center, extent, width, height, snapToTexel);
128Result<VegetationVertexGpuAtlas> uploadVegetationVertexAtlas(IResourceFactory& factory, const VegetationField& field,
131 return uploadAtlas(factory, field, VegetationChannel::Vertex, center, extent, width, height, snapToTexel);
134Result<void> releaseVegetationGpuFieldSet(IResourceFactory& factory, VegetationGpuFieldSet& set) {
150Result<VegetationGpuFieldSet> uploadVegetationGpuFieldSet(IResourceFactory& factory, const VegetationField& field,
158 Diagnostic::error(DiagnosticCode::Failed, "vegetation GPU field upload rollback failed", {}, {},
162 auto extras = uploadVegetationExtrasAtlas(factory, field, center, extent, width, height, snapToTexel);
165 auto colors = uploadVegetationColorsAtlas(factory, field, candidate.extras.center, extent, width, height, false);
168 auto motion = uploadVegetationMotionAtlas(factory, field, candidate.extras.center, extent, width, height, false);
171 auto vertex = uploadVegetationVertexAtlas(factory, field, candidate.extras.center, extent, width, height, false);
178 Diagnostic::error(DiagnosticCode::Failed, "vegetation GPU field upload rollback failed", {}, {},
200 return Result<VegetationGpuAtlas>::failure(invalid("pre-baked vegetation value exceeds RGBA16F range"));
208 auto uploaded = factory.newTextureArrayRgba16f(geometry.width, geometry.height, layerCount, pixels);
210 return Result<VegetationGpuAtlas>::success({uploaded.value(), sourceRevision, geometry.width, geometry.height,
214 Diagnostic::error(DiagnosticCode::Failed, "pre-baked vegetation atlas allocation failed", {}, {},
223 !finite(first.center) || !finite(first.extent) || first.extent.x < 1e-4f || first.extent.y < 1e-4f ||
227 if (layer.width != first.width || layer.height != first.height || layer.center != first.center ||
236 IResourceFactory& factory, std::span<const VegetationAtlas, 9> layers, std::uint64_t sourceRevision) {
239 if (sourceRevision == 0 || first.width == 0 || first.height == 0 || first.width > 2048 || first.height > 2048 ||
240 !finite(first.center) || !finite(first.extent) || first.extent.x < 1e-4f || first.extent.y < 1e-4f ||
242 return Result<VegetationGpuFieldSet>::failure(invalid("pre-baked vegetation atlas geometry is invalid"));
244 if (layer.width != first.width || layer.height != first.height || layer.center != first.center ||
247 return Result<VegetationGpuFieldSet>::failure(invalid("pre-baked vegetation atlas layers are incoherent"));
267 Diagnostic::error(DiagnosticCode::Failed, "pre-baked vegetation channel projection allocation failed",
274 std::span<const VegetationChannelAtlas, 9> extras, std::span<const VegetationChannelAtlas, 9> motion,
277 return Result<VegetationGpuFieldSet>::failure(invalid("pre-baked vegetation revision must be nonzero"));
287 return Result<VegetationGpuFieldSet>::failure(invalid("pre-baked vegetation upload size overflow"));
291 return Result<VegetationGpuFieldSet>::failure(invalid("pre-baked vegetation upload budget exceeded"));
298 Diagnostic::error(DiagnosticCode::Failed, "pre-baked vegetation GPU upload rollback failed", {}, {},
318Result<void> bindVegetationGpuFieldsAtRevision(PbrSurface& surface, std::uint64_t expectedRevision,
323 return atlas.texture && atlas.fieldRevision == extras.fieldRevision && atlas.width && atlas.height &&
324 atlas.width <= 2048 && atlas.height <= 2048 && atlas.layers == layerCount && finite(atlas.center) &&
325 finite(atlas.extent) && atlas.extent.x >= 1e-4f && atlas.extent.y >= 1e-4f && atlas.extent.z >= 1e-4f;
332 !std::isfinite(runtime.time) || std::abs(runtime.time) > 1e12 || !std::isfinite(runtime.globalBending) ||
336 !std::isfinite(runtime.fadeNoiseTiling) || runtime.globalBending < 0 || runtime.globalBending > 1000000 ||
339 runtime.motionFadeDistance < 0 || runtime.motionFadeDistance > 1000000 || runtime.cameraFadeMin < 0 ||
340 runtime.cameraFadeMin > 1000000 || runtime.cameraFadeMax < 0 || runtime.cameraFadeMax > 1000000 ||
342 return Result<void>::failure(invalid("incoherent, stale or invalid vegetation GPU field binding"));
389 return bindVegetationGpuFieldsAtRevision(surface, field.revision(), extras, colors, motion, vertex, runtime);
394 return bindVegetationGpuFields(surface, field, set.extras, set.colors, set.motion, set.vertex, runtime);
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Texture / mesh / shader / canvas creation and release.
Definition IResourceFactory.h:38
virtual Result< Texture * > newTextureArrayRgba16f(uint32_t width, uint32_t height, uint32_t layers, std::span< const uint16_t > rgbaHalf)
Upload a sampled 2D array of tightly packed linear RGBA16F texels.
Definition IResourceFactory.h:77
virtual bool releaseTexture(Texture *texture)=0
Release texture.
Backend-independent, owning vegetation influence field. Single writer; concurrent const evaluation is...
Definition VegetationField.h:86
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
VegetationGpuAtlas VegetationColorsGpuAtlas
Definition VegetationFieldGpu.h:30
Result< void > releaseVegetationGpuFieldSet(IResourceFactory &factory, VegetationGpuFieldSet &set)
Release every texture still present in a detached field set. Successful entries are nulled....
Definition VegetationFieldGpu.cpp:134
VegetationGpuAtlas VegetationVertexGpuAtlas
Definition VegetationFieldGpu.h:32
VegetationGpuAtlas VegetationMotionGpuAtlas
Definition VegetationFieldGpu.h:31
VegetationChannel
Independent vegetation field channels; values use linear color and world units.
Definition VegetationField.h:16
Result< VegetationGpuFieldSet > uploadVegetationGpuFieldSet(IResourceFactory &factory, const VegetationField &field, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Bake and upload all four nine-layer projections as one publication. Earlier uploads are released if a...
Definition VegetationFieldGpu.cpp:150
Result< VegetationGpuAtlas > uploadAtlas(IResourceFactory &factory, const VegetationField &field, VegetationChannel channel, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Definition VegetationFieldGpu.cpp:52
Result< void > validatePbrSurface(const PbrSurface &s)
Validate finite material factors and sampler enums without changing the input.
Definition PbrSurface.cpp:4
Result< void > bindVegetationGpuFields(PbrSurface &surface, const VegetationField &field, const VegetationExtrasGpuAtlas &extras, const VegetationColorsGpuAtlas &colors, const VegetationMotionGpuAtlas &motion, const VegetationVertexGpuAtlas &vertex, const VegetationGpuRuntime &runtime)
Atomically bind four coherent GPU projections to an owning PBR parameter snapshot.
Definition VegetationFieldGpu.cpp:385
Result< VegetationExtrasGpuAtlas > uploadVegetationExtrasAtlas(IResourceFactory &factory, const VegetationField &field, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Bake and atomically upload all nine Extras layers as a linear RGBA16F 2D array.
Definition VegetationFieldGpu.cpp:110
Result< VegetationVertexGpuAtlas > uploadVegetationVertexAtlas(IResourceFactory &factory, const VegetationField &field, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Bake and atomically upload all nine Vertex layers as a linear RGBA16F 2D array.
Definition VegetationFieldGpu.cpp:128
VegetationGpuAtlas VegetationExtrasGpuAtlas
Definition VegetationFieldGpu.h:29
Result< VegetationMotionGpuAtlas > uploadVegetationMotionAtlas(IResourceFactory &factory, const VegetationField &field, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Bake and atomically upload all nine Motion layers as a linear RGBA16F 2D array.
Definition VegetationFieldGpu.cpp:122
Result< VegetationColorsGpuAtlas > uploadVegetationColorsAtlas(IResourceFactory &factory, const VegetationField &field, glm::vec3 center, glm::vec3 extent, uint32_t width, uint32_t height, bool snapToTexel)
Bake and atomically upload all nine Colors layers as a linear RGBA16F 2D array. Ownership,...
Definition VegetationFieldGpu.cpp:116
@ InvalidArgument
@ Failed
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:218
One owning vegetation channel in row-major X/Z order at texel centers. Channel atlases may use indepe...
Definition VegetationField.h:75
std::vector< glm::vec4 > pixels
Definition VegetationField.h:78
Immutable GPU projection of nine layers from one vegetation field channel. The source field remains a...
Definition VegetationFieldGpu.h:23
uint64_t fieldRevision
Definition VegetationFieldGpu.h:25
Coherent detached projections for all four vegetation channels. Textures are factory-owned....
Definition VegetationFieldGpu.h:38
VegetationVertexGpuAtlas vertex
Definition VegetationFieldGpu.h:42
VegetationExtrasGpuAtlas extras
Definition VegetationFieldGpu.h:39
VegetationColorsGpuAtlas colors
Definition VegetationFieldGpu.h:40
VegetationMotionGpuAtlas motion
Definition VegetationFieldGpu.h:41
Runtime-owned global inputs shared by one coherent vegetation field binding. Time is explicit for det...
Definition VegetationFieldGpu.h:48