0.2.0-dev Download ZIP
134 lines ·4.8 KB Raw
| 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2 | // |
| 3 | // Metal/MTL4CommandEncoder.hpp |
| 4 | // |
| 5 | // Copyright 2020-2025 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 "../Foundation/Foundation.hpp" |
| 24 | #include "MTLCommandEncoder.hpp" |
| 25 | #include "MTLDefines.hpp" |
| 26 | #include "MTLHeaderBridge.hpp" |
| 27 | #include "MTLPrivate.hpp" |
| 28 | |
| 29 | namespace MTL4 |
| 30 | { |
| 31 | class CommandBuffer; |
| 32 | } |
| 33 | |
| 34 | namespace MTL |
| 35 | { |
| 36 | class Fence; |
| 37 | } |
| 38 | |
| 39 | namespace MTL4 |
| 40 | { |
| 41 | _MTL_OPTIONS(NS::UInteger, VisibilityOptions) { |
| 42 | VisibilityOptionNone = 0, |
| 43 | VisibilityOptionDevice = 1, |
| 44 | VisibilityOptionResourceAlias = 1 << 1, |
| 45 | }; |
| 46 | |
| 47 | class CommandEncoder : public NS::Referencing<CommandEncoder> |
| 48 | { |
| 49 | public: |
| 50 | void barrierAfterEncoderStages(MTL::Stages afterEncoderStages, MTL::Stages beforeEncoderStages, MTL4::VisibilityOptions visibilityOptions); |
| 51 | |
| 52 | void barrierAfterQueueStages(MTL::Stages afterQueueStages, MTL::Stages beforeStages, MTL4::VisibilityOptions visibilityOptions); |
| 53 | |
| 54 | void barrierAfterStages(MTL::Stages afterStages, MTL::Stages beforeQueueStages, MTL4::VisibilityOptions visibilityOptions); |
| 55 | |
| 56 | CommandBuffer* commandBuffer() const; |
| 57 | |
| 58 | void endEncoding(); |
| 59 | |
| 60 | void insertDebugSignpost(const NS::String* string); |
| 61 | |
| 62 | NS::String* label() const; |
| 63 | |
| 64 | void popDebugGroup(); |
| 65 | |
| 66 | void pushDebugGroup(const NS::String* string); |
| 67 | |
| 68 | void setLabel(const NS::String* label); |
| 69 | |
| 70 | void updateFence(const MTL::Fence* fence, MTL::Stages afterEncoderStages); |
| 71 | |
| 72 | void waitForFence(const MTL::Fence* fence, MTL::Stages beforeEncoderStages); |
| 73 | }; |
| 74 | |
| 75 | } |
| 76 | _MTL_INLINE void MTL4::CommandEncoder::barrierAfterEncoderStages(MTL::Stages afterEncoderStages, MTL::Stages beforeEncoderStages, MTL4::VisibilityOptions visibilityOptions) |
| 77 | { |
| 78 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(barrierAfterEncoderStages_beforeEncoderStages_visibilityOptions_), afterEncoderStages, beforeEncoderStages, visibilityOptions); |
| 79 | } |
| 80 | |
| 81 | _MTL_INLINE void MTL4::CommandEncoder::barrierAfterQueueStages(MTL::Stages afterQueueStages, MTL::Stages beforeStages, MTL4::VisibilityOptions visibilityOptions) |
| 82 | { |
| 83 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(barrierAfterQueueStages_beforeStages_visibilityOptions_), afterQueueStages, beforeStages, visibilityOptions); |
| 84 | } |
| 85 | |
| 86 | _MTL_INLINE void MTL4::CommandEncoder::barrierAfterStages(MTL::Stages afterStages, MTL::Stages beforeQueueStages, MTL4::VisibilityOptions visibilityOptions) |
| 87 | { |
| 88 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(barrierAfterStages_beforeQueueStages_visibilityOptions_), afterStages, beforeQueueStages, visibilityOptions); |
| 89 | } |
| 90 | |
| 91 | _MTL_INLINE MTL4::CommandBuffer* MTL4::CommandEncoder::commandBuffer() const |
| 92 | { |
| 93 | return Object::sendMessage<MTL4::CommandBuffer*>(this, _MTL_PRIVATE_SEL(commandBuffer)); |
| 94 | } |
| 95 | |
| 96 | _MTL_INLINE void MTL4::CommandEncoder::endEncoding() |
| 97 | { |
| 98 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(endEncoding)); |
| 99 | } |
| 100 | |
| 101 | _MTL_INLINE void MTL4::CommandEncoder::insertDebugSignpost(const NS::String* string) |
| 102 | { |
| 103 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(insertDebugSignpost_), string); |
| 104 | } |
| 105 | |
| 106 | _MTL_INLINE NS::String* MTL4::CommandEncoder::label() const |
| 107 | { |
| 108 | return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label)); |
| 109 | } |
| 110 | |
| 111 | _MTL_INLINE void MTL4::CommandEncoder::popDebugGroup() |
| 112 | { |
| 113 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(popDebugGroup)); |
| 114 | } |
| 115 | |
| 116 | _MTL_INLINE void MTL4::CommandEncoder::pushDebugGroup(const NS::String* string) |
| 117 | { |
| 118 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); |
| 119 | } |
| 120 | |
| 121 | _MTL_INLINE void MTL4::CommandEncoder::setLabel(const NS::String* label) |
| 122 | { |
| 123 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label); |
| 124 | } |
| 125 | |
| 126 | _MTL_INLINE void MTL4::CommandEncoder::updateFence(const MTL::Fence* fence, MTL::Stages afterEncoderStages) |
| 127 | { |
| 128 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateFence_afterEncoderStages_), fence, afterEncoderStages); |
| 129 | } |
| 130 | |
| 131 | _MTL_INLINE void MTL4::CommandEncoder::waitForFence(const MTL::Fence* fence, MTL::Stages beforeEncoderStages) |
| 132 | { |
| 133 | Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(waitForFence_beforeEncoderStages_), fence, beforeEncoderStages); |
| 134 | } |