1 // Copyright 2018 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_ 16 #define DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_ 17 18 #include "dawn_native/CommandEncoder.h" 19 #include "dawn_native/Error.h" 20 #include "dawn_native/ObjectBase.h" 21 22 #include "dawn_native/dawn_platform.h" 23 24 namespace dawn_native { 25 26 class CommandAllocator; 27 class DeviceBase; 28 29 // Base class for shared functionality between ComputePassEncoder and RenderPassEncoder. 30 class ProgrammablePassEncoder : public ObjectBase { 31 public: 32 ProgrammablePassEncoder(DeviceBase* device, 33 CommandEncoderBase* topLevelEncoder, 34 CommandAllocator* allocator); 35 36 void EndPass(); 37 38 void InsertDebugMarker(const char* groupLabel); 39 void PopDebugGroup(); 40 void PushDebugGroup(const char* groupLabel); 41 42 void SetBindGroup(uint32_t groupIndex, 43 BindGroupBase* group, 44 uint32_t dynamicOffsetCount, 45 const uint64_t* dynamicOffsets); 46 47 protected: 48 // Construct an "error" programmable pass encoder. 49 ProgrammablePassEncoder(DeviceBase* device, 50 CommandEncoderBase* topLevelEncoder, 51 ErrorTag errorTag); 52 53 MaybeError ValidateCanRecordCommands() const; 54 55 // The allocator is borrowed from the top level encoder. Keep a reference to the encoder 56 // to make sure the allocator isn't freed. 57 Ref<CommandEncoderBase> mTopLevelEncoder = nullptr; 58 // mAllocator is cleared at the end of the pass so it acts as a tag that EndPass was called 59 CommandAllocator* mAllocator = nullptr; 60 }; 61 62 } // namespace dawn_native 63 64 #endif // DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_ 65