| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright Contributors to the OpenVDB Project | ||
| 2 | // SPDX-License-Identifier: MPL-2.0 | ||
| 3 | |||
| 4 | /// @file codegen/PointComputeGenerator.h | ||
| 5 | /// | ||
| 6 | /// @authors Nick Avramoussis, Matt Warner, Francisco Gochez, Richard Jones | ||
| 7 | /// | ||
| 8 | /// @brief The visitor framework and function definition for point data | ||
| 9 | /// grid code generation | ||
| 10 | /// | ||
| 11 | |||
| 12 | #ifndef OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED | ||
| 13 | #define OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED | ||
| 14 | |||
| 15 | #include "ComputeGenerator.h" | ||
| 16 | #include "FunctionTypes.h" | ||
| 17 | #include "Types.h" | ||
| 18 | #include "Utils.h" | ||
| 19 | |||
| 20 | #include "../compiler/AttributeRegistry.h" | ||
| 21 | |||
| 22 | #include <openvdb/version.h> | ||
| 23 | #include <openvdb/points/AttributeArray.h> | ||
| 24 | |||
| 25 | namespace openvdb { | ||
| 26 | OPENVDB_USE_VERSION_NAMESPACE | ||
| 27 | namespace OPENVDB_VERSION_NAME { | ||
| 28 | |||
| 29 | namespace ax { | ||
| 30 | namespace codegen { | ||
| 31 | |||
| 32 | /////////////////////////////////////////////////////////////////////////////// | ||
| 33 | /////////////////////////////////////////////////////////////////////////////// | ||
| 34 | |||
| 35 | struct PointKernelValue | ||
| 36 | { | ||
| 37 | // The signature of the generated function | ||
| 38 | using Signature = | ||
| 39 | void(const void* const, | ||
| 40 | const int32_t (*)[3], | ||
| 41 | Index32*, // leaf value buffer | ||
| 42 | bool, // active | ||
| 43 | uint64_t, // pindex | ||
| 44 | void**, // transforms | ||
| 45 | void**, // values | ||
| 46 | uint64_t*, // flags | ||
| 47 | const void* const, // attribute set | ||
| 48 | void**, // group handles | ||
| 49 | void*); // leaf data | ||
| 50 | |||
| 51 | using FunctionTraitsT = codegen::FunctionTraits<Signature>; | ||
| 52 | static const size_t N_ARGS = FunctionTraitsT::N_ARGS; | ||
| 53 | |||
| 54 | static const std::array<const char*, N_ARGS>& argumentKeys(); | ||
| 55 | static const char* getDefaultName(); | ||
| 56 | }; | ||
| 57 | |||
| 58 | struct PointKernelAttributeArray | ||
| 59 | { | ||
| 60 | // The signature of the generated function | ||
| 61 | using Signature = | ||
| 62 | void(const void* const, | ||
| 63 | const int32_t (*)[3], | ||
| 64 | Index32*, // leaf value buffer | ||
| 65 | bool, // active | ||
| 66 | uint64_t, // pindex | ||
| 67 | void**, // transforms | ||
| 68 | void**, // arrays | ||
| 69 | uint64_t*, // flags | ||
| 70 | const void* const, // attribute set | ||
| 71 | void**, // group handles | ||
| 72 | void*); // leaf data | ||
| 73 | |||
| 74 | using FunctionTraitsT = codegen::FunctionTraits<Signature>; | ||
| 75 | static const size_t N_ARGS = FunctionTraitsT::N_ARGS; | ||
| 76 | |||
| 77 | static const std::array<const char*, N_ARGS>& argumentKeys(); | ||
| 78 | static const char* getDefaultName(); | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct PointKernelBuffer | ||
| 82 | { | ||
| 83 | // The signature of the generated function | ||
| 84 | using Signature = | ||
| 85 | void(const void* const, | ||
| 86 | const int32_t (*)[3], | ||
| 87 | Index32*, // leaf value buffer | ||
| 88 | bool, // active | ||
| 89 | uint64_t, // pindex | ||
| 90 | void**, // transforms | ||
| 91 | void**, // buffers | ||
| 92 | uint64_t*, // flags | ||
| 93 | const void* const, // attribute set | ||
| 94 | void**, // group handles | ||
| 95 | void*); // leaf data | ||
| 96 | |||
| 97 | using FunctionTraitsT = codegen::FunctionTraits<Signature>; | ||
| 98 | static const size_t N_ARGS = FunctionTraitsT::N_ARGS; | ||
| 99 | |||
| 100 | static const std::array<const char*, N_ARGS>& argumentKeys(); | ||
| 101 | static const char* getDefaultName(); | ||
| 102 | }; | ||
| 103 | |||
| 104 | struct PointKernelBufferRange | ||
| 105 | { | ||
| 106 | // The signature of the generated function | ||
| 107 | using Signature = | ||
| 108 | void(const void* const, | ||
| 109 | const int32_t (*)[3], | ||
| 110 | Index32*, // leaf value buffer | ||
| 111 | uint64_t*, // active buffer | ||
| 112 | int64_t, // leaf buffer size (512) | ||
| 113 | uint64_t, // mode (0 = off, 1 = active, 2 = both) | ||
| 114 | void**, // transforms | ||
| 115 | void**, // buffers | ||
| 116 | uint64_t*, // flags | ||
| 117 | const void* const, // attribute set | ||
| 118 | void**, // group handles | ||
| 119 | void*); // leaf data | ||
| 120 | |||
| 121 | using FunctionTraitsT = codegen::FunctionTraits<Signature>; | ||
| 122 | static const size_t N_ARGS = FunctionTraitsT::N_ARGS; | ||
| 123 | |||
| 124 | static const std::array<const char*, N_ARGS>& argumentKeys(); | ||
| 125 | static const char* getDefaultName(); | ||
| 126 | }; | ||
| 127 | |||
| 128 | |||
| 129 | /////////////////////////////////////////////////////////////////////////// | ||
| 130 | /////////////////////////////////////////////////////////////////////////// | ||
| 131 | |||
| 132 | namespace codegen_internal { | ||
| 133 | |||
| 134 | /// @brief Visitor object which will generate llvm IR for a syntax tree which has been generated from | ||
| 135 | /// AX that targets point grids. The IR will represent 2 functions : one that executes over | ||
| 136 | /// single points and one that executes over a collection of points. This is primarily used by the | ||
| 137 | /// Compiler class. | ||
| 138 | struct PointComputeGenerator : public ComputeGenerator | ||
| 139 | { | ||
| 140 | /// @brief Constructor | ||
| 141 | /// @param module llvm Module for generating IR | ||
| 142 | /// @param options Options for the function registry behaviour | ||
| 143 | /// @param functionRegistry Function registry object which will be used when generating IR | ||
| 144 | /// for function calls | ||
| 145 | /// @param logger Logger for collecting logical errors and warnings | ||
| 146 | PointComputeGenerator(llvm::Module& module, | ||
| 147 | const FunctionOptions& options, | ||
| 148 | FunctionRegistry& functionRegistry, | ||
| 149 | Logger& logger); | ||
| 150 | |||
| 151 | 772 | ~PointComputeGenerator() override = default; | |
| 152 | |||
| 153 | using ComputeGenerator::traverse; | ||
| 154 | using ComputeGenerator::visit; | ||
| 155 | |||
| 156 | AttributeRegistry::Ptr generate(const ast::Tree& node); | ||
| 157 | bool visit(const ast::Attribute*) override; | ||
| 158 | |||
| 159 | private: | ||
| 160 | void computePKBR(const AttributeRegistry&); | ||
| 161 | void computePKB(const AttributeRegistry&); | ||
| 162 | void computePKAA(const AttributeRegistry&); | ||
| 163 | }; | ||
| 164 | |||
| 165 | } // namespace namespace codegen_internal | ||
| 166 | |||
| 167 | } // namespace codegen | ||
| 168 | } // namespace ax | ||
| 169 | } // namespace OPENVDB_VERSION_NAME | ||
| 170 | } // namespace openvdb | ||
| 171 | |||
| 172 | #endif // OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED | ||
| 173 | |||
| 174 |