/ include / Metal / MTLResourceStateCommandEncoder.hpp
MTLResourceStateCommandEncoder.hpp
  1  //-------------------------------------------------------------------------------------------------------------------------------------------------------------
  2  //
  3  // Metal/MTLResourceStateCommandEncoder.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 "MTLCommandEncoder.hpp"
 30  #include "MTLTypes.hpp"
 31  
 32  namespace MTL
 33  {
 34  _MTL_ENUM(NS::UInteger, SparseTextureMappingMode) {
 35      SparseTextureMappingModeMap = 0,
 36      SparseTextureMappingModeUnmap = 1,
 37  };
 38  
 39  struct MapIndirectArguments
 40  {
 41      uint32_t regionOriginX;
 42      uint32_t regionOriginY;
 43      uint32_t regionOriginZ;
 44      uint32_t regionSizeWidth;
 45      uint32_t regionSizeHeight;
 46      uint32_t regionSizeDepth;
 47      uint32_t mipMapLevel;
 48      uint32_t sliceId;
 49  } _MTL_PACKED;
 50  
 51  class ResourceStateCommandEncoder : public NS::Referencing<ResourceStateCommandEncoder, CommandEncoder>
 52  {
 53  public:
 54      void updateTextureMappings(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions);
 55  
 56      void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice);
 57  
 58      void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
 59  
 60      void updateFence(const class Fence* fence);
 61  
 62      void waitForFence(const class Fence* fence);
 63  
 64      void moveTextureMappingsFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin);
 65  };
 66  
 67  }
 68  
 69  // method: updateTextureMappings:mode:regions:mipLevels:slices:numRegions:
 70  _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMappings(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions)
 71  {
 72      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_), texture, mode, regions, mipLevels, slices, numRegions);
 73  }
 74  
 75  // method: updateTextureMapping:mode:region:mipLevel:slice:
 76  _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice)
 77  {
 78      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_region_mipLevel_slice_), texture, mode, region, mipLevel, slice);
 79  }
 80  
 81  // method: updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:
 82  _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
 83  {
 84      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_), texture, mode, indirectBuffer, indirectBufferOffset);
 85  }
 86  
 87  // method: updateFence:
 88  _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateFence(const MTL::Fence* fence)
 89  {
 90      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateFence_), fence);
 91  }
 92  
 93  // method: waitForFence:
 94  _MTL_INLINE void MTL::ResourceStateCommandEncoder::waitForFence(const MTL::Fence* fence)
 95  {
 96      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(waitForFence_), fence);
 97  }
 98  
 99  // method: moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:
100  _MTL_INLINE void MTL::ResourceStateCommandEncoder::moveTextureMappingsFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin)
101  {
102      Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin);
103  }