MTLIntersectionFunctionTable.hpp
1 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 // 3 // Metal/MTLIntersectionFunctionTable.hpp 4 // 5 // Copyright 2020-2024 Apple Inc. 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 // See the License for the specific language governing permissions and 17 // limitations under the License. 18 // 19 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 21 #pragma once 22 23 #include "MTLDefines.hpp" 24 #include "MTLHeaderBridge.hpp" 25 #include "MTLPrivate.hpp" 26 27 #include <Foundation/Foundation.hpp> 28 29 #include "MTLIntersectionFunctionTable.hpp" 30 #include "MTLResource.hpp" 31 #include "MTLTypes.hpp" 32 33 namespace MTL 34 { 35 _MTL_OPTIONS(NS::UInteger, IntersectionFunctionSignature) { 36 IntersectionFunctionSignatureNone = 0, 37 IntersectionFunctionSignatureInstancing = 1, 38 IntersectionFunctionSignatureTriangleData = 2, 39 IntersectionFunctionSignatureWorldSpaceData = 4, 40 IntersectionFunctionSignatureInstanceMotion = 8, 41 IntersectionFunctionSignaturePrimitiveMotion = 16, 42 IntersectionFunctionSignatureExtendedLimits = 32, 43 IntersectionFunctionSignatureMaxLevels = 64, 44 IntersectionFunctionSignatureCurveData = 128, 45 }; 46 47 class IntersectionFunctionTableDescriptor : public NS::Copying<IntersectionFunctionTableDescriptor> 48 { 49 public: 50 static class IntersectionFunctionTableDescriptor* alloc(); 51 52 class IntersectionFunctionTableDescriptor* init(); 53 54 static class IntersectionFunctionTableDescriptor* intersectionFunctionTableDescriptor(); 55 56 NS::UInteger functionCount() const; 57 void setFunctionCount(NS::UInteger functionCount); 58 }; 59 60 class IntersectionFunctionTable : public NS::Referencing<IntersectionFunctionTable, Resource> 61 { 62 public: 63 void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); 64 65 void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); 66 67 MTL::ResourceID gpuResourceID() const; 68 69 void setFunction(const class FunctionHandle* function, NS::UInteger index); 70 71 void setFunctions(const class FunctionHandle* const functions[], NS::Range range); 72 73 void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); 74 75 void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range); 76 77 void setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); 78 79 void setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range); 80 81 void setVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); 82 83 void setVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range bufferRange); 84 }; 85 86 } 87 88 // static method: alloc 89 _MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::alloc() 90 { 91 return NS::Object::alloc<MTL::IntersectionFunctionTableDescriptor>(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor)); 92 } 93 94 // method: init 95 _MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::init() 96 { 97 return NS::Object::init<MTL::IntersectionFunctionTableDescriptor>(); 98 } 99 100 // static method: intersectionFunctionTableDescriptor 101 _MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::intersectionFunctionTableDescriptor() 102 { 103 return Object::sendMessage<MTL::IntersectionFunctionTableDescriptor*>(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor), _MTL_PRIVATE_SEL(intersectionFunctionTableDescriptor)); 104 } 105 106 // property: functionCount 107 _MTL_INLINE NS::UInteger MTL::IntersectionFunctionTableDescriptor::functionCount() const 108 { 109 return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(functionCount)); 110 } 111 112 _MTL_INLINE void MTL::IntersectionFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount) 113 { 114 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount); 115 } 116 117 // method: setBuffer:offset:atIndex: 118 _MTL_INLINE void MTL::IntersectionFunctionTable::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) 119 { 120 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); 121 } 122 123 // method: setBuffers:offsets:withRange: 124 _MTL_INLINE void MTL::IntersectionFunctionTable::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) 125 { 126 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); 127 } 128 129 // property: gpuResourceID 130 _MTL_INLINE MTL::ResourceID MTL::IntersectionFunctionTable::gpuResourceID() const 131 { 132 return Object::sendMessage<MTL::ResourceID>(this, _MTL_PRIVATE_SEL(gpuResourceID)); 133 } 134 135 // method: setFunction:atIndex: 136 _MTL_INLINE void MTL::IntersectionFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index) 137 { 138 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index); 139 } 140 141 // method: setFunctions:withRange: 142 _MTL_INLINE void MTL::IntersectionFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range) 143 { 144 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range); 145 } 146 147 // method: setOpaqueTriangleIntersectionFunctionWithSignature:atIndex: 148 _MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) 149 { 150 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_atIndex_), signature, index); 151 } 152 153 // method: setOpaqueTriangleIntersectionFunctionWithSignature:withRange: 154 _MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) 155 { 156 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_withRange_), signature, range); 157 } 158 159 // method: setOpaqueCurveIntersectionFunctionWithSignature:atIndex: 160 _MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) 161 { 162 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_atIndex_), signature, index); 163 } 164 165 // method: setOpaqueCurveIntersectionFunctionWithSignature:withRange: 166 _MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) 167 { 168 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_withRange_), signature, range); 169 } 170 171 // method: setVisibleFunctionTable:atBufferIndex: 172 _MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) 173 { 174 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); 175 } 176 177 // method: setVisibleFunctionTables:withBufferRange: 178 _MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range bufferRange) 179 { 180 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withBufferRange_), functionTables, bufferRange); 181 }