Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 1 | // Copyright 2021 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_EXTERNALTEXTURE_H_ |
| 16 | #define DAWNNATIVE_EXTERNALTEXTURE_H_ |
| 17 | |
| 18 | #include "dawn_native/Error.h" |
Loko Kung | 8d195d5 | 2021-09-28 15:40:01 +0000 | [diff] [blame] | 19 | #include "dawn_native/Forward.h" |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 20 | #include "dawn_native/ObjectBase.h" |
| 21 | #include "dawn_native/Subresource.h" |
| 22 | |
| 23 | #include <array> |
| 24 | |
| 25 | namespace dawn_native { |
| 26 | |
| 27 | struct ExternalTextureDescriptor; |
| 28 | class TextureViewBase; |
| 29 | |
| 30 | MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device, |
| 31 | const ExternalTextureDescriptor* descriptor); |
| 32 | |
Loko Kung | 8d195d5 | 2021-09-28 15:40:01 +0000 | [diff] [blame] | 33 | class ExternalTextureBase : public ApiObjectBase { |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 34 | public: |
| 35 | static ResultOrError<Ref<ExternalTextureBase>> Create( |
| 36 | DeviceBase* device, |
| 37 | const ExternalTextureDescriptor* descriptor); |
| 38 | |
Brandon Jones | 39633e2 | 2021-06-01 19:45:53 +0000 | [diff] [blame] | 39 | const std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat>& GetTextureViews() const; |
| 40 | |
| 41 | MaybeError ValidateCanUseInSubmitNow() const; |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 42 | |
| 43 | static ExternalTextureBase* MakeError(DeviceBase* device); |
| 44 | |
Loko Kung | 8d195d5 | 2021-09-28 15:40:01 +0000 | [diff] [blame] | 45 | ObjectType GetType() const override; |
| 46 | |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 47 | void APIDestroy(); |
| 48 | |
| 49 | private: |
Brandon Jones | b94c41a | 2021-06-08 20:29:37 +0000 | [diff] [blame] | 50 | enum class ExternalTextureState { Alive, Destroyed }; |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 51 | ExternalTextureBase(DeviceBase* device, const ExternalTextureDescriptor* descriptor); |
| 52 | ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag); |
| 53 | std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat> textureViews; |
Brandon Jones | 39633e2 | 2021-06-01 19:45:53 +0000 | [diff] [blame] | 54 | ExternalTextureState mState; |
Brandon Jones | 0e92e9b | 2021-04-01 20:46:42 +0000 | [diff] [blame] | 55 | }; |
| 56 | } // namespace dawn_native |
| 57 | |
Loko Kung | 8d195d5 | 2021-09-28 15:40:01 +0000 | [diff] [blame] | 58 | #endif // DAWNNATIVE_EXTERNALTEXTURE_H_ |