yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
ba7001c
v1.3.3b
1//------------------------------------------------------------------------------------------------------------------------------------------------------------- 2// 3// Metal/MTLComputeCommandEncoder.hpp 4// 5// Copyright 2020-2021 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 "MTLBuffer.hpp" 30#include "MTLCommandBuffer.hpp" 31#include "MTLCommandEncoder.hpp" 32#include "MTLHeap.hpp" 33#include "MTLIntersectionFunctionTable.hpp" 34#include "MTLResource.hpp" 35#include "MTLSampler.hpp" 36#include "MTLTexture.hpp" 37#include "MTLTypes.hpp" 38#include "MTLVisibleFunctionTable.hpp" 39 40namespace MTL 41{ 42struct DispatchThreadgroupsIndirectArguments 43{ 44uint32_t threadgroupsPerGrid [ 3 ] ; 45} _MTL_PACKED ; 46 47struct StageInRegionIndirectArguments 48{ 49uint32_t stageInOrigin [ 3 ] ; 50uint32_t stageInSize [ 3 ] ; 51} _MTL_PACKED ; 52 53class ComputeCommandEncoder : public NS :: Referencing < ComputeCommandEncoder , CommandEncoder > 54{ 55public : 56MTL :: DispatchType dispatchType () const ; 57 58void setComputePipelineState ( const class ComputePipelineState * state ) ; 59 60void setBytes ( const void * bytes , NS :: UInteger length , NS :: UInteger index ) ; 61 62void setBuffer ( const class Buffer * buffer , NS :: UInteger offset , NS :: UInteger index ) ; 63 64void setBufferOffset ( NS :: UInteger offset , NS :: UInteger index ) ; 65 66void setBuffers ( MTL :: Buffer * buffers [] , const NS :: UInteger offsets [] , NS :: Range range ) ; 67 68void setVisibleFunctionTable ( const class VisibleFunctionTable * visibleFunctionTable , NS :: UInteger bufferIndex ) ; 69 70void setVisibleFunctionTables ( const class VisibleFunctionTable * visibleFunctionTables [] , NS :: Range range ) ; 71 72void setIntersectionFunctionTable ( const class IntersectionFunctionTable * intersectionFunctionTable , NS :: UInteger bufferIndex ) ; 73 74void setIntersectionFunctionTables ( const class IntersectionFunctionTable * intersectionFunctionTables [] , NS :: Range range ) ; 75 76void setAccelerationStructure ( const class AccelerationStructure * accelerationStructure , NS :: UInteger bufferIndex ) ; 77 78void setTexture ( const class Texture * texture , NS :: UInteger index ) ; 79 80void setTextures ( MTL :: Texture * textures [] , NS :: Range range ) ; 81 82void setSamplerState ( const class SamplerState * sampler , NS :: UInteger index ) ; 83 84void setSamplerStates ( MTL :: SamplerState * samplers [] , NS :: Range range ) ; 85 86void setSamplerState ( const class SamplerState * sampler , float lodMinClamp , float lodMaxClamp , NS :: UInteger index ) ; 87 88void setSamplerStates ( MTL :: SamplerState * samplers [] , const float lodMinClamps [] , const float lodMaxClamps [] , NS :: Range range ) ; 89 90void setThreadgroupMemoryLength ( NS :: UInteger length , NS :: UInteger index ) ; 91 92void setImageblockWidth ( NS :: UInteger width , NS :: UInteger height ) ; 93 94void setStageInRegion ( MTL :: Region region ) ; 95 96void setStageInRegion ( const class Buffer * indirectBuffer , NS :: UInteger indirectBufferOffset ) ; 97 98void dispatchThreadgroups ( MTL :: Size threadgroupsPerGrid , MTL :: Size threadsPerThreadgroup ) ; 99 100void dispatchThreadgroups ( const class Buffer * indirectBuffer , NS :: UInteger indirectBufferOffset , MTL :: Size threadsPerThreadgroup ) ; 101 102void dispatchThreads ( MTL :: Size threadsPerGrid , MTL :: Size threadsPerThreadgroup ) ; 103 104void updateFence ( const class Fence * fence ) ; 105 106void waitForFence ( const class Fence * fence ) ; 107 108void useResource ( const class Resource * resource , MTL :: ResourceUsage usage ) ; 109 110void useResources ( MTL :: Resource * resources [] , NS :: UInteger count , MTL :: ResourceUsage usage ) ; 111 112void useHeap ( const class Heap * heap ) ; 113 114void useHeaps ( MTL :: Heap * heaps [] , NS :: UInteger count ) ; 115 116void executeCommandsInBuffer ( const class IndirectCommandBuffer * indirectCommandBuffer , NS :: Range executionRange ) ; 117 118void executeCommandsInBuffer ( const class IndirectCommandBuffer * indirectCommandbuffer , const class Buffer * indirectRangeBuffer , NS :: UInteger indirectBufferOffset ) ; 119 120void memoryBarrier ( MTL :: BarrierScope scope ) ; 121 122void memoryBarrier ( MTL :: Resource * resources [] , NS :: UInteger count ) ; 123 124void sampleCountersInBuffer ( const class CounterSampleBuffer * sampleBuffer , NS :: UInteger sampleIndex , bool barrier ) ; 125} ; 126 127} 128 129// property: dispatchType 130_MTL_INLINE MTL :: DispatchType MTL :: ComputeCommandEncoder :: dispatchType () const 131{ 132return Object :: sendMessage < MTL :: DispatchType > ( this , _MTL_PRIVATE_SEL ( dispatchType )) ; 133} 134 135// method: setComputePipelineState: 136_MTL_INLINE void MTL :: ComputeCommandEncoder :: setComputePipelineState ( const MTL :: ComputePipelineState * state ) 137{ 138Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setComputePipelineState_ ) , state ) ; 139} 140 141// method: setBytes:length:atIndex: 142_MTL_INLINE void MTL :: ComputeCommandEncoder :: setBytes ( const void * bytes , NS :: UInteger length , NS :: UInteger index ) 143{ 144Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setBytes_length_atIndex_ ) , bytes , length , index ) ; 145} 146 147// method: setBuffer:offset:atIndex: 148_MTL_INLINE void MTL :: ComputeCommandEncoder :: setBuffer ( const MTL :: Buffer * buffer , NS :: UInteger offset , NS :: UInteger index ) 149{ 150Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setBuffer_offset_atIndex_ ) , buffer , offset , index ) ; 151} 152 153// method: setBufferOffset:atIndex: 154_MTL_INLINE void MTL :: ComputeCommandEncoder :: setBufferOffset ( NS :: UInteger offset , NS :: UInteger index ) 155{ 156Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setBufferOffset_atIndex_ ) , offset , index ) ; 157} 158 159// method: setBuffers:offsets:withRange: 160_MTL_INLINE void MTL :: ComputeCommandEncoder :: setBuffers ( MTL :: Buffer * buffers [] , const NS :: UInteger offsets [] , NS :: Range range ) 161{ 162Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setBuffers_offsets_withRange_ ) , buffers , offsets , range ) ; 163} 164 165// method: setVisibleFunctionTable:atBufferIndex: 166_MTL_INLINE void MTL :: ComputeCommandEncoder :: setVisibleFunctionTable ( const MTL :: VisibleFunctionTable * visibleFunctionTable , NS :: UInteger bufferIndex ) 167{ 168Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setVisibleFunctionTable_atBufferIndex_ ) , visibleFunctionTable , bufferIndex ) ; 169} 170 171// method: setVisibleFunctionTables:withBufferRange: 172_MTL_INLINE void MTL :: ComputeCommandEncoder :: setVisibleFunctionTables ( const MTL :: VisibleFunctionTable * visibleFunctionTables [] , NS :: Range range ) 173{ 174Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setVisibleFunctionTables_withBufferRange_ ) , visibleFunctionTables , range ) ; 175} 176 177// method: setIntersectionFunctionTable:atBufferIndex: 178_MTL_INLINE void MTL :: ComputeCommandEncoder :: setIntersectionFunctionTable ( const MTL :: IntersectionFunctionTable * intersectionFunctionTable , NS :: UInteger bufferIndex ) 179{ 180Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setIntersectionFunctionTable_atBufferIndex_ ) , intersectionFunctionTable , bufferIndex ) ; 181} 182 183// method: setIntersectionFunctionTables:withBufferRange: 184_MTL_INLINE void MTL :: ComputeCommandEncoder :: setIntersectionFunctionTables ( const MTL :: IntersectionFunctionTable * intersectionFunctionTables [] , NS :: Range range ) 185{ 186Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setIntersectionFunctionTables_withBufferRange_ ) , intersectionFunctionTables , range ) ; 187} 188 189// method: setAccelerationStructure:atBufferIndex: 190_MTL_INLINE void MTL :: ComputeCommandEncoder :: setAccelerationStructure ( const MTL :: AccelerationStructure * accelerationStructure , NS :: UInteger bufferIndex ) 191{ 192Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setAccelerationStructure_atBufferIndex_ ) , accelerationStructure , bufferIndex ) ; 193} 194 195// method: setTexture:atIndex: 196_MTL_INLINE void MTL :: ComputeCommandEncoder :: setTexture ( const MTL :: Texture * texture , NS :: UInteger index ) 197{ 198Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setTexture_atIndex_ ) , texture , index ) ; 199} 200 201// method: setTextures:withRange: 202_MTL_INLINE void MTL :: ComputeCommandEncoder :: setTextures ( MTL :: Texture * textures [] , NS :: Range range ) 203{ 204Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setTextures_withRange_ ) , textures , range ) ; 205} 206 207// method: setSamplerState:atIndex: 208_MTL_INLINE void MTL :: ComputeCommandEncoder :: setSamplerState ( const MTL :: SamplerState * sampler , NS :: UInteger index ) 209{ 210Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setSamplerState_atIndex_ ) , sampler , index ) ; 211} 212 213// method: setSamplerStates:withRange: 214_MTL_INLINE void MTL :: ComputeCommandEncoder :: setSamplerStates ( MTL :: SamplerState * samplers [] , NS :: Range range ) 215{ 216Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setSamplerStates_withRange_ ) , samplers , range ) ; 217} 218 219// method: setSamplerState:lodMinClamp:lodMaxClamp:atIndex: 220_MTL_INLINE void MTL :: ComputeCommandEncoder :: setSamplerState ( const MTL :: SamplerState * sampler , float lodMinClamp , float lodMaxClamp , NS :: UInteger index ) 221{ 222Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setSamplerState_lodMinClamp_lodMaxClamp_atIndex_ ) , sampler , lodMinClamp , lodMaxClamp , index ) ; 223} 224 225// method: setSamplerStates:lodMinClamps:lodMaxClamps:withRange: 226_MTL_INLINE void MTL :: ComputeCommandEncoder :: setSamplerStates ( MTL :: SamplerState * samplers [] , const float lodMinClamps [] , const float lodMaxClamps [] , NS :: Range range ) 227{ 228Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setSamplerStates_lodMinClamps_lodMaxClamps_withRange_ ) , samplers , lodMinClamps , lodMaxClamps , range ) ; 229} 230 231// method: setThreadgroupMemoryLength:atIndex: 232_MTL_INLINE void MTL :: ComputeCommandEncoder :: setThreadgroupMemoryLength ( NS :: UInteger length , NS :: UInteger index ) 233{ 234Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setThreadgroupMemoryLength_atIndex_ ) , length , index ) ; 235} 236 237// method: setImageblockWidth:height: 238_MTL_INLINE void MTL :: ComputeCommandEncoder :: setImageblockWidth ( NS :: UInteger width , NS :: UInteger height ) 239{ 240Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setImageblockWidth_height_ ) , width , height ) ; 241} 242 243// method: setStageInRegion: 244_MTL_INLINE void MTL :: ComputeCommandEncoder :: setStageInRegion ( MTL :: Region region ) 245{ 246Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setStageInRegion_ ) , region ) ; 247} 248 249// method: setStageInRegionWithIndirectBuffer:indirectBufferOffset: 250_MTL_INLINE void MTL :: ComputeCommandEncoder :: setStageInRegion ( const MTL :: Buffer * indirectBuffer , NS :: UInteger indirectBufferOffset ) 251{ 252Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( setStageInRegionWithIndirectBuffer_indirectBufferOffset_ ) , indirectBuffer , indirectBufferOffset ) ; 253} 254 255// method: dispatchThreadgroups:threadsPerThreadgroup: 256_MTL_INLINE void MTL :: ComputeCommandEncoder :: dispatchThreadgroups ( MTL :: Size threadgroupsPerGrid , MTL :: Size threadsPerThreadgroup ) 257{ 258Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( dispatchThreadgroups_threadsPerThreadgroup_ ) , threadgroupsPerGrid , threadsPerThreadgroup ) ; 259} 260 261// method: dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup: 262_MTL_INLINE void MTL :: ComputeCommandEncoder :: dispatchThreadgroups ( const MTL :: Buffer * indirectBuffer , NS :: UInteger indirectBufferOffset , MTL :: Size threadsPerThreadgroup ) 263{ 264Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup_ ) , indirectBuffer , indirectBufferOffset , threadsPerThreadgroup ) ; 265} 266 267// method: dispatchThreads:threadsPerThreadgroup: 268_MTL_INLINE void MTL :: ComputeCommandEncoder :: dispatchThreads ( MTL :: Size threadsPerGrid , MTL :: Size threadsPerThreadgroup ) 269{ 270Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( dispatchThreads_threadsPerThreadgroup_ ) , threadsPerGrid , threadsPerThreadgroup ) ; 271} 272 273// method: updateFence: 274_MTL_INLINE void MTL :: ComputeCommandEncoder :: updateFence ( const MTL :: Fence * fence ) 275{ 276Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( updateFence_ ) , fence ) ; 277} 278 279// method: waitForFence: 280_MTL_INLINE void MTL :: ComputeCommandEncoder :: waitForFence ( const MTL :: Fence * fence ) 281{ 282Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( waitForFence_ ) , fence ) ; 283} 284 285// method: useResource:usage: 286_MTL_INLINE void MTL :: ComputeCommandEncoder :: useResource ( const MTL :: Resource * resource , MTL :: ResourceUsage usage ) 287{ 288Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( useResource_usage_ ) , resource , usage ) ; 289} 290 291// method: useResources:count:usage: 292_MTL_INLINE void MTL :: ComputeCommandEncoder :: useResources ( MTL :: Resource * resources [] , NS :: UInteger count , MTL :: ResourceUsage usage ) 293{ 294Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( useResources_count_usage_ ) , resources , count , usage ) ; 295} 296 297// method: useHeap: 298_MTL_INLINE void MTL :: ComputeCommandEncoder :: useHeap ( const MTL :: Heap * heap ) 299{ 300Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( useHeap_ ) , heap ) ; 301} 302 303// method: useHeaps:count: 304_MTL_INLINE void MTL :: ComputeCommandEncoder :: useHeaps ( MTL :: Heap * heaps [] , NS :: UInteger count ) 305{ 306Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( useHeaps_count_ ) , heaps , count ) ; 307} 308 309// method: executeCommandsInBuffer:withRange: 310_MTL_INLINE void MTL :: ComputeCommandEncoder :: executeCommandsInBuffer ( const MTL :: IndirectCommandBuffer * indirectCommandBuffer , NS :: Range executionRange ) 311{ 312Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( executeCommandsInBuffer_withRange_ ) , indirectCommandBuffer , executionRange ) ; 313} 314 315// method: executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: 316_MTL_INLINE void MTL :: ComputeCommandEncoder :: executeCommandsInBuffer ( const MTL :: IndirectCommandBuffer * indirectCommandbuffer , const MTL :: Buffer * indirectRangeBuffer , NS :: UInteger indirectBufferOffset ) 317{ 318Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_ ) , indirectCommandbuffer , indirectRangeBuffer , indirectBufferOffset ) ; 319} 320 321// method: memoryBarrierWithScope: 322_MTL_INLINE void MTL :: ComputeCommandEncoder :: memoryBarrier ( MTL :: BarrierScope scope ) 323{ 324Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( memoryBarrierWithScope_ ) , scope ) ; 325} 326 327// method: memoryBarrierWithResources:count: 328_MTL_INLINE void MTL :: ComputeCommandEncoder :: memoryBarrier ( MTL :: Resource * resources [] , NS :: UInteger count ) 329{ 330Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( memoryBarrierWithResources_count_ ) , resources , count ) ; 331} 332 333// method: sampleCountersInBuffer:atSampleIndex:withBarrier: 334_MTL_INLINE void MTL :: ComputeCommandEncoder :: sampleCountersInBuffer ( const MTL :: CounterSampleBuffer * sampleBuffer , NS :: UInteger sampleIndex , bool barrier ) 335{ 336Object :: sendMessage < void > ( this , _MTL_PRIVATE_SEL ( sampleCountersInBuffer_atSampleIndex_withBarrier_ ) , sampleBuffer , sampleIndex , barrier ) ; 337}