Corentin Wallez | 4a9ef4e | 2018-07-18 11:40:26 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Dawn Authors |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 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 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 15 | #ifndef DAWNNATIVE_SAMPLER_H_ |
| 16 | #define DAWNNATIVE_SAMPLER_H_ |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 17 | |
Austin Eng | 84bcf44 | 2019-10-30 00:20:03 +0000 | [diff] [blame] | 18 | #include "dawn_native/CachedObject.h" |
Corentin Wallez | d37523f | 2018-07-24 13:53:51 +0200 | [diff] [blame] | 19 | #include "dawn_native/Error.h" |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 20 | |
Corentin Wallez | 36afbb6 | 2018-07-25 17:03:23 +0200 | [diff] [blame] | 21 | #include "dawn_native/dawn_platform.h" |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 22 | |
Corentin Wallez | 49a65d0 | 2018-07-24 16:45:45 +0200 | [diff] [blame] | 23 | namespace dawn_native { |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 24 | |
Corentin Wallez | 1ae19e8 | 2018-05-17 17:09:07 -0400 | [diff] [blame] | 25 | class DeviceBase; |
| 26 | |
Corentin Wallez | 36afbb6 | 2018-07-25 17:03:23 +0200 | [diff] [blame] | 27 | MaybeError ValidateSamplerDescriptor(DeviceBase* device, const SamplerDescriptor* descriptor); |
Corentin Wallez | 1ae19e8 | 2018-05-17 17:09:07 -0400 | [diff] [blame] | 28 | |
Austin Eng | 84bcf44 | 2019-10-30 00:20:03 +0000 | [diff] [blame] | 29 | class SamplerBase : public CachedObject { |
Corentin Wallez | c1400f0 | 2017-11-24 13:59:42 -0500 | [diff] [blame] | 30 | public: |
Austin Eng | 84bcf44 | 2019-10-30 00:20:03 +0000 | [diff] [blame] | 31 | SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor); |
Idan Raiter | 2bc3169 | 2019-05-20 18:16:34 +0000 | [diff] [blame] | 32 | ~SamplerBase() override; |
Corentin Wallez | a594f8f | 2019-02-13 13:09:18 +0000 | [diff] [blame] | 33 | |
| 34 | static SamplerBase* MakeError(DeviceBase* device); |
| 35 | |
Austin Eng | 7817a9a | 2020-04-20 23:43:20 +0000 | [diff] [blame] | 36 | bool HasCompareFunction() const; |
| 37 | |
Bryan Bernhart | 24bf7a4 | 2020-12-03 18:42:13 +0000 | [diff] [blame] | 38 | // Functions necessary for the unordered_set<SamplerBase*>-based cache. |
| 39 | size_t ComputeContentHash() override; |
| 40 | |
Idan Raiter | 2bc3169 | 2019-05-20 18:16:34 +0000 | [diff] [blame] | 41 | struct EqualityFunc { |
| 42 | bool operator()(const SamplerBase* a, const SamplerBase* b) const; |
| 43 | }; |
| 44 | |
shrekshao | f8c5e4a | 2020-12-24 03:11:17 +0000 | [diff] [blame] | 45 | uint16_t GetMaxAnisotropy() const { |
| 46 | return mMaxAnisotropy; |
| 47 | } |
| 48 | |
Corentin Wallez | a594f8f | 2019-02-13 13:09:18 +0000 | [diff] [blame] | 49 | private: |
| 50 | SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag); |
Idan Raiter | 2bc3169 | 2019-05-20 18:16:34 +0000 | [diff] [blame] | 51 | |
| 52 | // TODO(cwallez@chromium.org): Store a crypto hash of the items instead? |
Corentin Wallez | 1f6c8c4 | 2019-10-23 11:57:41 +0000 | [diff] [blame] | 53 | wgpu::AddressMode mAddressModeU; |
| 54 | wgpu::AddressMode mAddressModeV; |
| 55 | wgpu::AddressMode mAddressModeW; |
| 56 | wgpu::FilterMode mMagFilter; |
| 57 | wgpu::FilterMode mMinFilter; |
| 58 | wgpu::FilterMode mMipmapFilter; |
Idan Raiter | 2bc3169 | 2019-05-20 18:16:34 +0000 | [diff] [blame] | 59 | float mLodMinClamp; |
| 60 | float mLodMaxClamp; |
Corentin Wallez | 1f6c8c4 | 2019-10-23 11:57:41 +0000 | [diff] [blame] | 61 | wgpu::CompareFunction mCompareFunction; |
shrekshao | f8c5e4a | 2020-12-24 03:11:17 +0000 | [diff] [blame] | 62 | uint16_t mMaxAnisotropy; |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 63 | }; |
| 64 | |
Corentin Wallez | 49a65d0 | 2018-07-24 16:45:45 +0200 | [diff] [blame] | 65 | } // namespace dawn_native |
Corentin Wallez | f07e3bd | 2017-04-20 14:38:20 -0400 | [diff] [blame] | 66 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 67 | #endif // DAWNNATIVE_SAMPLER_H_ |