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_D3D12_TEXTURECOPYSPLITTER_H_
16 #define DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
17 
18 #include "dawn_native/dawn_platform.h"
19 
20 #include <array>
21 
22 namespace dawn_native {
23 
24     struct TexelBlockInfo;
25 
26 }  // namespace dawn_native
27 
28 namespace dawn_native { namespace d3d12 {
29 
30     struct Texture2DCopySplit {
31         static constexpr unsigned int kMaxTextureCopyRegions = 2;
32 
33         struct CopyInfo {
34             Origin3D textureOffset;
35             Origin3D bufferOffset;
36             Extent3D bufferSize;
37 
38             Extent3D copySize;
39         };
40 
41         uint64_t offset = 0;
42         uint32_t count = 0;
43         std::array<CopyInfo, kMaxTextureCopyRegions> copies;
44     };
45 
46     struct TextureCopySplits {
47         static constexpr uint32_t kMaxTextureCopySplits = 2;
48 
49         std::array<Texture2DCopySplit, kMaxTextureCopySplits> copies2D;
50     };
51 
52     Texture2DCopySplit ComputeTextureCopySplit(Origin3D origin,
53                                                Extent3D copySize,
54                                                const TexelBlockInfo& blockInfo,
55                                                uint64_t offset,
56                                                uint32_t bytesPerRow,
57                                                uint32_t rowsPerImage);
58 
59     TextureCopySplits ComputeTextureCopySplits(Origin3D origin,
60                                                Extent3D copySize,
61                                                const TexelBlockInfo& blockInfo,
62                                                uint64_t offset,
63                                                uint32_t bytesPerRow,
64                                                uint32_t rowsPerImage);
65 }}  // namespace dawn_native::d3d12
66 
67 #endif  // DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
68