1 // Copyright 2017 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_BINDGROUP_H_ 16 #define DAWNNATIVE_BINDGROUP_H_ 17 18 #include "common/Constants.h" 19 #include "dawn_native/BindGroupLayout.h" 20 #include "dawn_native/Error.h" 21 #include "dawn_native/Forward.h" 22 #include "dawn_native/ObjectBase.h" 23 24 #include "dawn_native/dawn_platform.h" 25 26 #include <array> 27 28 namespace dawn_native { 29 30 class DeviceBase; 31 32 MaybeError ValidateBindGroupDescriptor(DeviceBase* device, 33 const BindGroupDescriptor* descriptor); 34 35 struct BufferBinding { 36 BufferBase* buffer; 37 uint64_t offset; 38 uint64_t size; 39 }; 40 41 class BindGroupBase : public ObjectBase { 42 public: 43 BindGroupBase(DeviceBase* device, const BindGroupDescriptor* descriptor); 44 45 static BindGroupBase* MakeError(DeviceBase* device); 46 47 const BindGroupLayoutBase* GetLayout() const; 48 BufferBinding GetBindingAsBufferBinding(size_t binding); 49 SamplerBase* GetBindingAsSampler(size_t binding); 50 TextureViewBase* GetBindingAsTextureView(size_t binding); 51 52 private: 53 BindGroupBase(DeviceBase* device, ObjectBase::ErrorTag tag); 54 55 Ref<BindGroupLayoutBase> mLayout; 56 std::array<Ref<ObjectBase>, kMaxBindingsPerGroup> mBindings; 57 std::array<uint32_t, kMaxBindingsPerGroup> mOffsets; 58 std::array<uint32_t, kMaxBindingsPerGroup> mSizes; 59 }; 60 61 } // namespace dawn_native 62 63 #endif // DAWNNATIVE_BINDGROUP_H_ 64