载入中...
搜索中...
未找到
EvpackShader.cpp
浏览该文件的文档.
16 return std::all_of(values.begin(), values.end(), [](float value) { return std::isfinite(value); });
30Result<std::unique_ptr<EvpackShader>> EvpackShader::load(const asset::EvpackResourceReader& reader,
36 Diagnostic::error(DiagnosticCode::Unsupported, "Shader backend mismatch", {}, {}, "asset.shader.runtime"));
50 DiagnosticCode::Failed, "Shader upload returned no allocation", {}, {}, "asset.shader.runtime"));
76Result<void> EvpackShader::setParameter(std::string_view name, std::span<const float> values) try {
79 Diagnostic::error(DiagnosticCode::StaleHandle, "Shader lease is released", {}, {}, "asset.shader.runtime"));
97 Diagnostic::error(DiagnosticCode::StaleHandle, "Shader lease is released", {}, {}, "asset.shader.runtime"));
98 if (impl_->definition.interface != asset::ShaderAssetInterface::Mesh3D || !finite(transform) || !finite(tint))
100 DiagnosticCode::InvalidArgument, "Invalid mesh draw or shader kind", {}, {}, "asset.shader.runtime"));
101 impl_->graphics.drawMeshShader(&mesh, glm::make_mat4(transform.data()), texture ? &texture->get() : nullptr,
108Result<void> EvpackShader::drawSprite(OptionalRef<graphics::Texture> texture, const std::array<float, 4>& rect,
112 Diagnostic::error(DiagnosticCode::StaleHandle, "Shader lease is released", {}, {}, "asset.shader.runtime"));
113 if (impl_->definition.interface != asset::ShaderAssetInterface::Sprite2D || !finite(rect) || !finite(tint))
115 DiagnosticCode::InvalidArgument, "Invalid sprite draw or shader kind", {}, {}, "asset.shader.runtime"));
126 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, "Graphics rejected shader release", {},
Typed capability-aware runtime access to admitted packs.
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
Unique lease on a validated package shader and its independent parameter instance....
Definition EvpackShader.h:27
Result< void > drawMesh(graphics::Mesh &mesh, const std::array< float, 16 > &transform, OptionalRef< graphics::Texture > texture, const std::array< float, 4 > &tint)
Draw through the owning Graphics in an open 3D frame; all arguments are immediate borrowed inputs.
Definition EvpackShader.cpp:93
Result< void > setParameter(std::string_view name, std::span< const float > values)
Set one declared scalar/vector with exact finite component count; failure leaves it unchanged.
Definition EvpackShader.cpp:76
EvpackShader(const EvpackShader &)=delete
Result< void > release()
Release explicitly; failure retains the lease for retry. Destruction retries and reports errors.
Definition EvpackShader.cpp:123
const asset::ShaderAsset & definition() const noexcept
Immutable CPU metadata borrowed until this lease is destroyed.
Definition EvpackShader.cpp:29
Result< void > drawSprite(OptionalRef< graphics::Texture > texture, const std::array< float, 4 > &rect, const std::array< float, 4 > &tint)
Draw a sprite in the active canvas; rect is x/y/width/height in pixels.
Definition EvpackShader.cpp:108
static Result< std::unique_ptr< EvpackShader > > load(const asset::EvpackResourceReader &reader, const AssetRef &asset, const asset::EvpackCapabilities &capabilities, graphics::Graphics &graphics)
Validate then upload; failures preserve all existing instances. Reader is not retained.
Definition EvpackShader.cpp:30
Definition Graphics.h:125
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a custom 2D shader from SPIR-V words (vert + frag). Owned by Graphics. Vertex stage may be emp...
Definition CookedMaterial.cpp:5
Result< void > validateShaderAssetGpu(const asset::ShaderAsset &shader)
Validate complete SPIR-V semantics and the supported engine pipeline interface before upload.
Definition ShaderAssetValidation.cpp:96
EVENGINE_API_FOUNDATION Result< ShaderAsset > loadShaderAsset(const EvpackResourceReader &reader, const AssetRef &asset, const EvpackCapabilities &capabilities)
Read and decode one capability-selected eve.shader/1 from an admitted runtime package.
Definition ShaderAssetLoader.cpp:6
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
@ InvalidArgument
@ Unsupported
@ Failed
@ StaleHandle
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
Definition Container.h:602
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
Owning CPU program snapshot; decoding does not prove GPU/descriptor compatibility.
Definition ShaderAsset.h:26
graphics::Graphics & graphics
Definition EvpackShader.cpp:20
asset::ShaderAsset definition
Definition EvpackShader.cpp:21
graphics::Shader * shader
Definition EvpackShader.cpp:22