device/slang/reflection.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstddef> | ||
| 5 | #include <string> | ||
| 6 | #include <string_view> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "chrono_batch_render/device/adapter.h" | ||
| 10 | #include "chrono_batch_render/device/slang/compiler.h" | ||
| 11 | |||
| 12 | namespace chrono::batch_render::device { | ||
| 13 | |||
| 14 | enum class FieldType { Bool, Int, Float, Float2, Float3, Float4, Spectral }; | ||
| 15 | |||
| 16 | struct ReflectedField { | ||
| 17 | std::string name; | ||
| 18 | FieldType type = FieldType::Float; | ||
| 19 | std::vector<std::byte> fallback; | ||
| 20 | bool color = false; | ||
| 21 | float minimum = 0; | ||
| 22 | float maximum = 0; | ||
| 23 | std::string displayName; | ||
| 24 | }; | ||
| 25 | |||
| 26 | enum class NodeRole { Material, Surface, Pattern, Primitive }; | ||
| 27 | |||
| 28 | enum class ParameterSource { Input, Context, Point }; | ||
| 29 | |||
| 30 | struct ReflectedParameter { | ||
| 31 | ParameterSource source = ParameterSource::Input; | ||
| 32 | uint32_t input = 0; | ||
| 33 | }; | ||
| 34 | |||
| 35 | struct ReflectedNode { | ||
| 36 | std::string name; | ||
| 37 | NodeRole role = NodeRole::Material; | ||
| 38 | std::vector<ReflectedField> fields; | ||
| 39 | FieldType result = FieldType::Float; | ||
| 40 | std::vector<ReflectedParameter> parameters; | ||
| 41 | }; | ||
| 42 | |||
| 43 | enum class SensorPipelineNodeKind { Point, Stencil }; | ||
| 44 | |||
| 45 | 26 | struct ReflectedPort { | |
| 46 | std::string name; | ||
| 47 | std::string type; | ||
| 48 | }; | ||
| 49 | |||
| 50 | inline constexpr uint32_t kNoContext = ~0u; | ||
| 51 | |||
| 52 | struct ReflectedSensorPipelineNode { | ||
| 53 | std::string name; | ||
| 54 | std::string displayName; | ||
| 55 | SensorPipelineNodeKind kind = SensorPipelineNodeKind::Point; | ||
| 56 | uint32_t radius = 0; | ||
| 57 | std::vector<ReflectedField> fields; | ||
| 58 | std::vector<ReflectedPort> inputs; | ||
| 59 | uint32_t context = kNoContext; | ||
| 60 | std::string result; | ||
| 61 | }; | ||
| 62 | |||
| 63 | 71 | struct ReflectedNodes { | |
| 64 | std::vector<ReflectedNode> material; | ||
| 65 | std::vector<ReflectedSensorPipelineNode> pipeline; | ||
| 66 | }; | ||
| 67 | |||
| 68 | CHRONO_BATCH_RENDER_API ReflectedNodes ReflectNodes(Backend backend, const KernelLibrary* library, | ||
| 69 | const SourceFiles& sources, | ||
| 70 | std::string_view module, std::string_view label, | ||
| 71 | const DiskCache* modules = nullptr); | ||
| 72 | |||
| 73 | CHRONO_BATCH_RENDER_API std::vector<ReflectedSensorPipelineNode> | ||
| 74 | ReflectSensorPipelineNodes(Backend backend, const KernelLibrary* library, | ||
| 75 | const SourceFiles& sources, std::string_view module, | ||
| 76 | std::string_view label, const DiskCache* modules = nullptr); | ||
| 77 | |||
| 78 | CHRONO_BATCH_RENDER_API std::vector<ReflectedNode> | ||
| 79 | ReflectMaterialNodes(Backend backend, const KernelLibrary* library, const SourceFiles& sources, | ||
| 80 | std::string_view module, std::string_view label, | ||
| 81 | const DiskCache* modules = nullptr); | ||
| 82 | |||
| 83 | } | ||
| 84 |