载入中...
搜索中...
未找到
EvpackStaticPrefab.cpp
浏览该文件的文档.
83Result<std::vector<StaticPrefabGpuPart>> EvpackStaticPrefab::prepareGpuDriven(graphics::Graphics& gfx) {
86 DiagnosticCode::InvalidArgument, "prefab resources have been released", {}, {}, "asset.graphics.prefab"));
89 Diagnostic::error(DiagnosticCode::InvalidArgument, "prefab GPU-driven parts are already registered", {}, {},
98 DiagnosticCode::InvalidArgument, "transparent prefab Detail cannot use opaque GPU submission", {}, {},
115 !conventionalBinding(draw.material.surface.textures[std::size_t(graphics::PbrTextureSlot::Normal)]))
117 DiagnosticCode::InvalidArgument, "extended prefab material requires a GPU-driven PBR surface record",
120 material->setTint(draw.material.color.r, draw.material.color.g, draw.material.color.b, draw.material.color.a);
131 DiagnosticCode::InvalidArgument, "prefab material is unavailable to GPU-driven rendering", {}, {},
135 const auto releaseRegistered = [&gfx](const std::vector<std::unique_ptr<graphics::Material>>& owned,
147 std::copy(glm::value_ptr(draw.transform), glm::value_ptr(draw.transform) + 16, part.localTransform.begin());
150 if (part.meshId == graphics::kInvalidGpuDrivenSlot || part.materialId == graphics::kInvalidGpuDrivenSlot) {
154 Diagnostic::error(DiagnosticCode::InvalidArgument, "prefab GPU table registration failed", {}, {},
161 DiagnosticCode::InvalidArgument, "prefab has no enabled renderer", {}, {}, "asset.graphics.prefab"));
166Result<std::unique_ptr<EvpackStaticPrefab>> EvpackStaticPrefab::load(const asset::EvpackResourceReader& reader,
174 std::unique_ptr<EvpackStaticPrefab>(new EvpackStaticPrefab(std::make_unique<Impl>(Impl{meshes, images})));
176 std::function<void(const scene::NodeDesc&, glm::mat4)> walk = [&](const scene::NodeDesc& node, glm::mat4 parent) {
193 if (!parameters) return Result<std::unique_ptr<EvpackStaticPrefab>>::failure(parameters.status());
208 Diagnostic::error(DiagnosticCode::InvalidArgument, "material references missing mesh UV channel",
228 parameters.value().surface.vegetationDetail.textures[role].texture = out->impl_->imageLeases.at(imageKey);
231 if (!validatedSurface) return Result<std::unique_ptr<EvpackStaticPrefab>>::failure(validatedSurface.status());
239Result<void> EvpackStaticPrefab::draw(graphics::Graphics& gfx, const std::array<float, 16>& transform,
243 DiagnosticCode::InvalidArgument, "prefab resources have been released", {}, {}, "asset.graphics.prefab"));
247 DiagnosticCode::InvalidArgument, "nonfinite instance transform", {}, {}, "asset.graphics.prefab"));
250 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "nonfinite camera view", {},
290 DiagnosticCode::InvalidArgument, "prefab resources have been released", {}, {}, "asset.graphics.prefab"));
294 DiagnosticCode::InvalidArgument, "nonfinite instance transform", {}, {}, "asset.graphics.prefab"));
298 DiagnosticCode::InvalidArgument, "nonfinite shadow view projection", {}, {}, "asset.graphics.prefab"));
Transactional graphics consumers for canonical runtime assets.
Transactional EVIMG runtime texture loading.
Runtime decoding of canonical scene templates.
JSON-free versioned runtime metadata codec.
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
Immutable reader retaining an admitted pack by shared ownership.
Definition EvpackResourceReader.h:29
Capability-aware adapter from admitted .evpack assets to graphics resources.
Definition EvpackGraphicsLoader.h:86
Result< LoadedGraphicsMesh > loadMesh(const AssetRef &asset, const asset::EvpackCapabilities &capabilities, const GraphicsAssetLoadLimits &limits={}, std::uint32_t texcoordSet=0, bool preserveAllTexcoords=false) const
Validate and upload one canonical mesh v3 (or compatibility v1/v2) atomically.
Definition EvpackGraphicsLoader.cpp:8
Capability-aware adapter from admitted EVIMG assets to backend textures.
Definition EvpackImageLoader.h:65
Result< LoadedGraphicsImage > load(const AssetRef &image, const asset::EvpackCapabilities &capabilities, const ImageAssetLoadLimits &limits={}) const
Validate and upload image/3 mip assets, retaining image/2 single-level compatibility.
Definition EvpackImageLoader.cpp:17
Owning static-prefab GPU leases and immutable draw transforms; no ECS or Scene mutation....
Definition EvpackStaticPrefab.h:34
static Result< std::unique_ptr< EvpackStaticPrefab > > load(const asset::EvpackResourceReader &reader, graphics::IMeshResourceFactory &meshes, graphics::IImageResourceFactory &images, const AssetRef &asset, const asset::EvpackCapabilities &capabilities)
Validate a template and stage its mesh, material and image dependencies; failures release staged uplo...
Definition EvpackStaticPrefab.cpp:166
std::size_t drawCount() const noexcept
Number of enabled static renderer bindings prepared for drawing.
Definition EvpackStaticPrefab.cpp:49
Result< std::vector< StaticPrefabGpuPart > > prepareGpuDriven(graphics::Graphics &graphics)
Register every opaque or masked prefab draw in GPU-driven tables transactionally.
Definition EvpackStaticPrefab.cpp:83
Result< void > release()
Invalidate draw packets and release all leases; failed releases remain owned for retry.
Definition EvpackStaticPrefab.cpp:50
Result< void > draw(graphics::Graphics &graphics, const std::array< float, 16 > &transform, const std::array< float, 16 > &cameraView) const
Draw in an already-open 3D pass using its camera/light state and a column-major instance transform.
Definition EvpackStaticPrefab.cpp:239
EvpackStaticPrefab(const EvpackStaticPrefab &)=delete
Result< void > drawShadow(graphics::Graphics &graphics, const std::array< float, 16 > &transform, const std::array< float, 16 > &lightViewProjection) const
Submit enabled source shadow casters inside an active cascade shadow pass.
Definition EvpackStaticPrefab.cpp:285
Capability-aware scene-template/3 decoder with explicit scene-template/2 compatibility.
Definition EvpackSceneTemplateLoader.h:38
Result< LoadedSceneTemplate > load(const AssetRef &sceneTemplate, const asset::EvpackCapabilities &capabilities, const SceneTemplateLoadLimits &limits={}) const
Validate identities, hierarchy and finite TRS values before building a tree.
Definition EvpackSceneTemplateLoader.cpp:56
Definition Graphics.h:125
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided=true)=0
Queue an opaque shadow caster.
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
Draw one mesh with model matrix. Requires begin3DFrame() (or an open swapchain pass).
virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr, bool doubleSided=true, float lodWeight=1.f, bool lodFadeReverse=false, bool lodDither=false)=0
Shadow pass draw with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): tra...
virtual Result< void > setMesh3DPbrSurface(const PbrSurface *surface)
Copy a validated extended surface for subsequent draws; null resets to legacy shading.
Definition Graphics.h:1192
virtual uint32_t gpuDrivenMeshRecord(Mesh *mesh)
GPU mesh-table slot for a mesh (kInvalidGpuDrivenSlot when not uploaded).
Definition Graphics.h:274
virtual bool gpuDrivenMaterialUsable(Material *material)
Whether a material can be shaded by the GPU-driven opaque path. Backends/drivers with descriptor-inde...
Definition Graphics.h:304
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
Texture cell bombing for the next default mesh draw (breaks tiling). cellScale: cells per UV unit (ty...
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
Parallax occlusion mapping for the next default mesh draw. scale: UV displacement strength (0=off)....
virtual void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY, float borderFraction)=0
Configure page-table sampling for the next mesh draw.
virtual void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided, float alphaCutoff, const std::string &alphaTechnique="cutoff")=0
Select pipeline state for subsequent mesh draws.
virtual uint32_t gpuDrivenMaterialRecord(Material *material)
GPU material-table slot for a material (lazily created).
Definition Graphics.h:280
virtual void setMesh3DShadowReceive(bool receive)=0
Per-draw: when false, shadow sampling is forced off for the next mesh draw.
virtual Result< void > gpuDrivenReleaseMaterialRecord(Material *material)
Release a lazily-created GPU material-table record.
Definition Graphics.h:292
virtual void setMesh3DNormalTexture(Texture *normal)=0
Optional normal map for the next drawMesh / drawMeshShader (nullptr = flat).
virtual void setMesh3DHeightTexture(Texture *height)=0
Optional height map for parallax (R channel; nullptr = flat / off).
Backend-owned RGBA8 texture upload and release operations.
Definition IImageResourceFactory.h:15
Backend-owned mesh upload and release operations.
Definition IMeshResourceFactory.h:15
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
Result< CookedMaterial > readCookedMaterial(const asset::EvpackResourceReader &reader, const AssetRef &ref, const asset::EvpackCapabilities &caps)
Decode material schemas 5 through 9 without allocating graphics resources. Unknown additive fields ar...
Definition CookedMaterial.cpp:50
Definition CookedMaterial.cpp:5
@ TangentXYZ
@ Inherit
@ Transparent
Result< void > validatePbrSurface(const PbrSurface &s)
Validate finite material factors and sampler enums without changing the input.
Definition PbrSurface.cpp:4
constexpr uint32_t kInvalidGpuDrivenSlot
GPU-driven rendering shared constants + std430 GPU layouts.
Definition GpuDrivenTypes.h:19
@ InvalidArgument
Definition Container.h:602
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
graphics::Texture * image
Definition EvpackStaticPrefab.cpp:34
glm::mat4 transform
Definition EvpackStaticPrefab.cpp:32
bool receiveShadows
Definition EvpackStaticPrefab.cpp:37
graphics::Mesh * mesh
Definition EvpackStaticPrefab.cpp:33
MaterialData material
Definition EvpackStaticPrefab.cpp:35
bool castShadows
Definition EvpackStaticPrefab.cpp:36
std::map< std::string, graphics::Texture * > imageLeases
Definition EvpackStaticPrefab.cpp:30
std::map< std::string, graphics::Mesh * > meshLeases
Definition EvpackStaticPrefab.cpp:28
bool released
Definition EvpackStaticPrefab.cpp:42
std::vector< std::unique_ptr< graphics::Material > > gpuMaterials
Definition EvpackStaticPrefab.cpp:40
graphics::Graphics * gpuGraphics
Definition EvpackStaticPrefab.cpp:41
graphics::IImageResourceFactory & images
Definition EvpackStaticPrefab.cpp:26
graphics::IMeshResourceFactory & meshes
Definition EvpackStaticPrefab.cpp:25
std::map< std::string, std::vector< uint32_t > > meshUvSets
Definition EvpackStaticPrefab.cpp:29
std::vector< Draw > draws
Definition EvpackStaticPrefab.cpp:39
One prefab renderer registered in backend GPU-driven tables.
Definition EvpackStaticPrefab.h:23
std::uint32_t meshId
Definition EvpackStaticPrefab.h:25
std::array< float, 16 > localTransform
Definition EvpackStaticPrefab.h:24
std::uint32_t materialId
Definition EvpackStaticPrefab.h:25
One borrowed texture plus independently owned UV/sampler parameters. Texture is graphics-factory-owne...
Definition PbrSurface.h:39
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19