载入中...
搜索中...
未找到
ShaderResourceScriptBindings.cpp
浏览该文件的文档.
29 if (!found || found->type() != type) throw std::runtime_error("Missing or invalid image field: " + name);
34 if (value < 0 || uint64_t(value) > UINT32_MAX) throw std::runtime_error("Image integer out of range: " + name);
44Result<void> replace(Graphics& graphics, Shader& shader, const std::string& vertex, const std::string& fragment,
112 if (filter > 2 || wrapU > 1 || wrapV > 1) throw std::runtime_error("Unknown resource sampler mode");
129 if (totalBytes > 2ull * 1024 * 1024 * 1024) throw std::runtime_error("Resource set exceeds 2 GiB");
139 inputs.constants = {static_cast<const std::byte*>(uniform->getData()), size_t(uniform->getSize())};
143 inputs.instanceMatrices = {static_cast<const std::byte*>(matrices->getData()), size_t(matrices->getSize())};
147 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, error.what(), "resources"));
154 case Graphics::Mesh3DSceneColorCaptureStatus::ExplicitOverride: return std::string("explicitOverride");
163 cls.addFunc("setBloomFilter", [vm](Graphics* graphics, const std::string& mode, float scatter, int iterations,
165 if (!graphics || (mode != "karisTent" && mode != "gaussianScatter" && mode != "gaussianPyramid"))
180 graphics->pipelineBloom()->filterSettings().filter == BloomFilter::GaussianScatter ? "gaussianScatter"
181 : graphics->pipelineBloom()->filterSettings().filter == BloomFilter::GaussianPyramid ? "gaussianPyramid"
208 vm, Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Graphics must be present",
235 cls.addFunc("setDisplayHdrCalibration", [vm](Graphics* graphics, float paperWhiteNits, float peakNits) {
238 vm, Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "Graphics must be present",
265 cls.addFunc("drawMeshShaderInstances", [vm](Graphics* graphics, Mesh* mesh, Shader* shader, ssq::Array model,
270 throw std::runtime_error("Expected mesh, shader, 16 matrix floats and nonnegative uint32 range");
273 return script::projectResult(vm, graphics->drawMeshShaderInstances(*mesh, *shader, transform, Color(1.f),
289 return script::projectResult(vm, replace(*graphics, *shader, vertex, fragment, value.value(), constants));
308Result<void> Graphics::replaceMeshShaderResources(Shader&, const std::vector<uint32_t>&, const std::vector<uint32_t>&,
311 DiagnosticCode::Unsupported, "Resource mesh programs are unavailable on this backend", "backend"));
319 if (!image.width || !image.height || image.width > 32768 || image.height > 32768 || !image.layers ||
321 image.mipLevels > static_cast<uint32_t>(std::bit_width(std::max({image.width, image.height, image.depth}))) ||
336 if (image.layers != 6 || image.width != image.height) return invalid("A cube image needs six square faces");
370 !std::isfinite(image.sampler.maxLod) || image.sampler.minLod < 0 || image.sampler.maxLod < image.sampler.minLod)
402 if (m[3] != 0 || m[7] != 0 || m[11] != 0 || m[15] != 1) return bad("Instance transform must be affine");
416 if (!std::isfinite(radius) || !std::isfinite(extent) || radius <= 0 || extent <= 0 || radius < extent / 1000 ||
473 Diagnostic::error(DiagnosticCode::InvalidArgument, "Grass scatter exceeds 49,999 points", "scatter"));
496 {{0.18f, 0.65f, -0.17f, 0.075f}, {0.48f, 0.96f, 0.08f, 0.10f}, {0.79f, 0.76f, 0.15f, 0.085f}, {}},
533ResultRef<Shader> buildGrassShader(Graphics& graphics, ssq::Array records, const std::string& pass) {
542 if (records.size() == 0 || records.size() % 16 != 0 || records.size() > 64u * 1024u * 1024u / sizeof(float))
544 DiagnosticCode::InvalidArgument, "Expected nonempty affine matrix records within 64 MiB", "instances"));
551 Diagnostic::error(DiagnosticCode::InvalidArgument, "Matrix elements must be numbers", "instances"));
552 matrices.push_back(type == ssq::Type::INTEGER ? float(records.get<SQInteger>(i)) : records.get<float>(i));
576 auto* shader = graphics.newMeshShaderFromSpv({std::begin(bootstrap_vert_spv), std::end(bootstrap_vert_spv)},
585 return ResultRef<Shader>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "stylized-grass"));
599 Diagnostic::error(DiagnosticCode::InvalidArgument, "SPIR-V words must be unsigned 32-bit integers"));
629ResultRef<Shader> loadMeshShader(Graphics& graphics, const std::string& vertex, const std::string& fragment) {
635 Diagnostic::error(DiagnosticCode::InvalidArgument, "fragment path must not be empty", "fragment"));
651 return ResultRef<Shader>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "shader"));
663 cls.addFunc("buildStylizedGrassShader", [vm](Graphics* self, ssq::Array instances, const std::string& pass) {
676 "replaceShaderFromSpv", [vm](Graphics* graphics, Shader* shader, ssq::Array vertex, ssq::Array fragment) {
685 return eve::script::projectResult(vm, graphics->replaceShaderFromSpv(*shader, vert.value(), frag.value()));
708 [vm](Graphics* self, Shader* shader, const std::string& name, bool depthWrite, bool doubleSided) {
729 cls.addFunc("configureMeshShaderRaster", [vm](Graphics* self, Shader* shader, const std::string& compare,
Vocabulary aliases for nullable and checked borrowed references.
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
@ String
@ Int64
Definition Graphics.h:134
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 Result< void > replaceShaderFromGlsl(Shader &shader, const std::string &vertGlsl, const std::string &fragGlsl)=0
Compile GLSL and transactionally replace an existing shader.
virtual float getDisplayPaperWhiteNits() const
Paper-white luminance in nits for HDR present encoding.
Definition DisplayOutput.cpp:40
virtual float getDisplayPeakNits() const
Peak luminance in nits for HDR present encoding.
Definition DisplayOutput.cpp:41
virtual bool isDisplayHdrActive() const
True when the live swapchain is scRGB or HDR10.
Definition DisplayOutput.cpp:45
virtual Result< void > replaceMeshShaderResources(Shader &shader, const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv, const ShaderResourceInputs &resources)
Replace a mesh program and its immutable set-1 resources atomically.
Definition ShaderResourceScriptBindings.cpp:308
virtual eve::Result< void > configureMeshShaderRaster(Shader &shader, const MeshShaderRasterState &state)
Transactionally configure an owned ordinary mesh shader's raster state.
Definition Graphics.h:1915
virtual eve::Result< void > configureMeshShaderSurface(Shader &, BlendMode, bool, bool)
Prepare a custom mesh shader's blend, depth and culling state.
Definition Graphics.h:1898
virtual Result< void > replaceShaderFromSpv(Shader &shader, const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Transactionally replace an existing shader with SPIR-V stages.
virtual Result< void > replaceShaderFromWgsl(Shader &shader, const std::string &vertWgsl, const std::string &fragWgsl)=0
Transactionally replace an existing shader with WGSL stages.
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
Result< std::shared_ptr< const FileData > > readPreparedFile(const std::string &path, size_t limit)
Join a queued read or synchronously read an immutable file snapshot.
Definition PreparedFile.cpp:59
void keys(const Value &value, std::initializer_list< const char * > names)
Definition OceanCodecInternal.h:8
Definition PbrGpuUniform.cpp:7
void exposeShaderResourceBindings(ssq::Table &table, ssq::Class &cls)
Expose shader resource bindings.
Definition ShaderResourceScriptBindings.cpp:151
Result< std::vector< std::uint32_t > > readShaderStageFile(const std::string &path)
Reads shader stage file.
Definition ShaderResourceScriptBindings.cpp:607
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
@ RGBA8Srgb
@ BGRA8Srgb
@ RGBA16Float
@ RGBA16Unorm
@ RGBA32Float
@ Nearest
@ KarisTent
@ GaussianPyramid
@ GaussianScatter
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
@ Nearest
@ Disabled
EVENGINE_API_BACKENDS Result< std::vector< ShaderImageRegion > > shaderImageRegions(const ShaderImageInput &image)
Validate layout, dimensions, sampler compatibility and exact payload size.
Definition ShaderResourceScriptBindings.cpp:314
EVENGINE_API_BACKENDS Result< void > validateBloomFilterSettings(const BloomFilterSettings &settings)
Validate enum, finite scatter [0,1], iterations [1,16], and finite clamp (0,65504].
Definition BloomGaussian.cpp:17
void exposeShaderScriptBindings(ssq::Table &table, ssq::Class &cls)
Register shader loading and binary replacement on the VM owner thread. Borrows both tables for this c...
Definition ShaderResourceScriptBindings.cpp:656
EVENGINE_API_BACKENDS Result< std::uint32_t > shaderInstanceMatrixCount(std::span< const std::byte > bytes)
Validate packed instance records without GPU access; returns the record count.
Definition ShaderResourceScriptBindings.cpp:390
@ LessEqual
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
void markResultHasValue(ssq::Table &result)
Declare that a projected table received a payload the caller attached itself.
Definition SquirrelBinding.cpp:538
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Definition SquirrelBinding.cpp:524
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
Definition SquirrelBinding.cpp:412
WidgetDesc grid(int columns, std::vector< WidgetDesc > children, std::string id)
Fixed-column grid; children are placed in source order.
Definition Widget.cpp:878
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
@ InvalidArgument
@ Unsupported
@ Failed
@ ParseError
@ Premultiplied
@ Additive
@ Alpha
@ Multiply
@ Opaque
Definition Container.h:602
Value-owned Gaussian bloom settings, independent of camera intensity and threshold.
Definition Bloom.h:21
Surface present formats the current device/window can offer.
Definition Graphics.h:1392
Value snapshot of custom mesh rasterization state, independent of blending/culling.
Definition MeshShaderRasterState.h:15
Synchronous borrowed input for one immutable shader image. @ownership The caller owns bytes; upload c...
Definition ShaderResources.h:42
Inputs for descriptor set 1 of a resource mesh program.
Definition ShaderResources.h:67