Austin Eng | 3318caa | 2019-08-13 00:22:28 +0000 | [diff] [blame] | 1 | // Copyright 2019 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_COMMANDVALIDATION_H_ |
| 16 | #define DAWNNATIVE_COMMANDVALIDATION_H_ |
| 17 | |
| 18 | #include "dawn_native/CommandAllocator.h" |
| 19 | #include "dawn_native/Error.h" |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 20 | #include "dawn_native/Texture.h" |
Austin Eng | 3318caa | 2019-08-13 00:22:28 +0000 | [diff] [blame] | 21 | |
| 22 | #include <vector> |
| 23 | |
| 24 | namespace dawn_native { |
| 25 | |
Hao Li | 5191adc | 2020-07-01 10:48:16 +0000 | [diff] [blame] | 26 | class QuerySetBase; |
Corentin Wallez | 2dd2d67 | 2021-05-05 15:41:13 +0000 | [diff] [blame] | 27 | struct SyncScopeResourceUsage; |
Austin Eng | 0d9fce1 | 2020-07-30 15:29:57 +0000 | [diff] [blame] | 28 | struct TexelBlockInfo; |
Austin Eng | 3318caa | 2019-08-13 00:22:28 +0000 | [diff] [blame] | 29 | |
Corentin Wallez | 2dd2d67 | 2021-05-05 15:41:13 +0000 | [diff] [blame] | 30 | MaybeError ValidateSyncScopeResourceUsage(const SyncScopeResourceUsage& usage); |
Austin Eng | 3318caa | 2019-08-13 00:22:28 +0000 | [diff] [blame] | 31 | |
Hao Li | 575729e | 2020-11-16 02:24:06 +0000 | [diff] [blame] | 32 | MaybeError ValidateTimestampQuery(QuerySetBase* querySet, uint32_t queryIndex); |
Hao Li | 5191adc | 2020-07-01 10:48:16 +0000 | [diff] [blame] | 33 | |
Tomek Ponitka | 11c0f57 | 2020-08-11 12:04:52 +0000 | [diff] [blame] | 34 | ResultOrError<uint64_t> ComputeRequiredBytesInCopy(const TexelBlockInfo& blockInfo, |
| 35 | const Extent3D& copySize, |
| 36 | uint32_t bytesPerRow, |
| 37 | uint32_t rowsPerImage); |
Tomek Ponitka | 9d66c53 | 2020-07-15 18:06:07 +0000 | [diff] [blame] | 38 | |
Kai Ninomiya | 16036cf | 2020-11-06 13:41:50 +0000 | [diff] [blame] | 39 | TextureDataLayout FixUpDeprecatedTextureDataLayoutOptions( |
| 40 | DeviceBase* device, |
| 41 | const TextureDataLayout& originalLayout, |
| 42 | const TexelBlockInfo& blockInfo, |
| 43 | const Extent3D& copyExtent); |
| 44 | void ApplyDefaultTextureDataLayoutOptions(TextureDataLayout* layout, |
| 45 | const TexelBlockInfo& blockInfo, |
| 46 | const Extent3D& copyExtent); |
| 47 | MaybeError ValidateLinearTextureData(const TextureDataLayout& layout, |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 48 | uint64_t byteSize, |
Austin Eng | 0d9fce1 | 2020-07-30 15:29:57 +0000 | [diff] [blame] | 49 | const TexelBlockInfo& blockInfo, |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 50 | const Extent3D& copyExtent); |
Yunchao He | 3e8f3f9 | 2021-04-01 22:40:43 +0000 | [diff] [blame] | 51 | MaybeError ValidateTextureCopyRange(DeviceBase const* device, |
| 52 | const ImageCopyTexture& imageCopyTexture, |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 53 | const Extent3D& copySize); |
Corentin Wallez | 8091584 | 2021-03-04 18:13:45 +0000 | [diff] [blame] | 54 | ResultOrError<Aspect> SingleAspectUsedByImageCopyTexture(const ImageCopyTexture& view); |
| 55 | MaybeError ValidateLinearToDepthStencilCopyRestrictions(const ImageCopyTexture& dst); |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 56 | |
Corentin Wallez | 8091584 | 2021-03-04 18:13:45 +0000 | [diff] [blame] | 57 | MaybeError ValidateImageCopyBuffer(DeviceBase const* device, |
| 58 | const ImageCopyBuffer& imageCopyBuffer); |
| 59 | MaybeError ValidateImageCopyTexture(DeviceBase const* device, |
| 60 | const ImageCopyTexture& imageCopyTexture, |
| 61 | const Extent3D& copySize); |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 62 | |
Tomek Ponitka | 0f5d496 | 2020-07-07 10:18:51 +0000 | [diff] [blame] | 63 | MaybeError ValidateCopySizeFitsInBuffer(const Ref<BufferBase>& buffer, |
| 64 | uint64_t offset, |
| 65 | uint64_t size); |
| 66 | |
Jiawei Shao | e472c45 | 2020-06-08 11:30:01 +0000 | [diff] [blame] | 67 | bool IsRangeOverlapped(uint32_t startA, uint32_t startB, uint32_t length); |
| 68 | |
Corentin Wallez | 8091584 | 2021-03-04 18:13:45 +0000 | [diff] [blame] | 69 | MaybeError ValidateTextureToTextureCopyRestrictions(const ImageCopyTexture& src, |
| 70 | const ImageCopyTexture& dst, |
Yan, Shaobo | db8766b | 2020-11-04 02:30:16 +0000 | [diff] [blame] | 71 | const Extent3D& copySize); |
| 72 | |
Yan, Shaobo | d42f4b3 | 2021-03-23 02:09:37 +0000 | [diff] [blame] | 73 | MaybeError ValidateCopyTextureForBrowserRestrictions(const ImageCopyTexture& src, |
| 74 | const ImageCopyTexture& dst, |
| 75 | const Extent3D& copySize); |
| 76 | |
Yan, Shaobo | db8766b | 2020-11-04 02:30:16 +0000 | [diff] [blame] | 77 | MaybeError ValidateCanUseAs(const TextureBase* texture, wgpu::TextureUsage usage); |
| 78 | |
| 79 | MaybeError ValidateCanUseAs(const BufferBase* buffer, wgpu::BufferUsage usage); |
| 80 | |
Austin Eng | 3318caa | 2019-08-13 00:22:28 +0000 | [diff] [blame] | 81 | } // namespace dawn_native |
| 82 | |
| 83 | #endif // DAWNNATIVE_COMMANDVALIDATION_H_ |