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_SAMPLER_H_ 16 #define DAWNNATIVE_SAMPLER_H_ 17 18 #include "dawn_native/Error.h" 19 #include "dawn_native/ObjectBase.h" 20 21 #include "dawn_native/dawn_platform.h" 22 23 namespace dawn_native { 24 25 class DeviceBase; 26 27 MaybeError ValidateSamplerDescriptor(DeviceBase* device, const SamplerDescriptor* descriptor); 28 29 class SamplerBase : public ObjectBase { 30 public: 31 SamplerBase(DeviceBase* device, 32 const SamplerDescriptor* descriptor, 33 bool blueprint = false); 34 ~SamplerBase() override; 35 36 static SamplerBase* MakeError(DeviceBase* device); 37 38 // Functors necessary for the unordered_set<SamplerBase*>-based cache. 39 struct HashFunc { 40 size_t operator()(const SamplerBase* module) const; 41 }; 42 struct EqualityFunc { 43 bool operator()(const SamplerBase* a, const SamplerBase* b) const; 44 }; 45 46 private: 47 SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag); 48 49 // TODO(cwallez@chromium.org): Store a crypto hash of the items instead? 50 dawn::AddressMode mAddressModeU; 51 dawn::AddressMode mAddressModeV; 52 dawn::AddressMode mAddressModeW; 53 dawn::FilterMode mMagFilter; 54 dawn::FilterMode mMinFilter; 55 dawn::FilterMode mMipmapFilter; 56 float mLodMinClamp; 57 float mLodMaxClamp; 58 dawn::CompareFunction mCompareFunction; 59 bool mIsBlueprint = false; 60 }; 61 62 } // namespace dawn_native 63 64 #endif // DAWNNATIVE_SAMPLER_H_ 65