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_PROGRAMMABLEENCODER_H_ 16 #define DAWNNATIVE_PROGRAMMABLEENCODER_H_ 17 18 #include "dawn_native/CommandEncoder.h" 19 #include "dawn_native/Error.h" 20 #include "dawn_native/Forward.h" 21 #include "dawn_native/IntegerTypes.h" 22 #include "dawn_native/ObjectBase.h" 23 24 #include "dawn_native/dawn_platform.h" 25 26 namespace dawn_native { 27 28 class DeviceBase; 29 30 // Base class for shared functionality between programmable encoders. 31 class ProgrammableEncoder : public ApiObjectBase { 32 public: 33 ProgrammableEncoder(DeviceBase* device, 34 const char* label, 35 EncodingContext* encodingContext); 36 37 void APIInsertDebugMarker(const char* groupLabel); 38 void APIPopDebugGroup(); 39 void APIPushDebugGroup(const char* groupLabel); 40 41 protected: 42 bool IsValidationEnabled() const; 43 MaybeError ValidateProgrammableEncoderEnd() const; 44 45 // Compute and render passes do different things on SetBindGroup. These are helper functions 46 // for the logic they have in common. 47 MaybeError ValidateSetBindGroup(BindGroupIndex index, 48 BindGroupBase* group, 49 uint32_t dynamicOffsetCountIn, 50 const uint32_t* dynamicOffsetsIn) const; 51 void RecordSetBindGroup(CommandAllocator* allocator, 52 BindGroupIndex index, 53 BindGroupBase* group, 54 uint32_t dynamicOffsetCount, 55 const uint32_t* dynamicOffsets) const; 56 57 // Construct an "error" programmable pass encoder. 58 ProgrammableEncoder(DeviceBase* device, 59 EncodingContext* encodingContext, 60 ErrorTag errorTag); 61 62 EncodingContext* mEncodingContext = nullptr; 63 64 uint64_t mDebugGroupStackSize = 0; 65 66 private: 67 const bool mValidationEnabled; 68 }; 69 70 } // namespace dawn_native 71 72 #endif // DAWNNATIVE_PROGRAMMABLEENCODER_H_ 73