• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_D3D12_UTILSD3D12_H_
16 #define DAWNNATIVE_D3D12_UTILSD3D12_H_
17 
18 #include "dawn_native/Commands.h"
19 #include "dawn_native/d3d12/BufferD3D12.h"
20 #include "dawn_native/d3d12/TextureCopySplitter.h"
21 #include "dawn_native/d3d12/TextureD3D12.h"
22 #include "dawn_native/d3d12/d3d12_platform.h"
23 #include "dawn_native/dawn_platform.h"
24 
25 namespace dawn_native { namespace d3d12 {
26 
27     ResultOrError<std::wstring> ConvertStringToWstring(const char* str);
28 
29     D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func);
30 
31     D3D12_TEXTURE_COPY_LOCATION ComputeTextureCopyLocationForTexture(const Texture* texture,
32                                                                      uint32_t level,
33                                                                      uint32_t layer,
34                                                                      Aspect aspect);
35 
36     D3D12_TEXTURE_COPY_LOCATION ComputeBufferLocationForCopyTextureRegion(
37         const Texture* texture,
38         ID3D12Resource* bufferResource,
39         const Extent3D& bufferSize,
40         const uint64_t offset,
41         const uint32_t rowPitch,
42         Aspect aspect);
43     D3D12_BOX ComputeD3D12BoxFromOffsetAndSize(const Origin3D& offset, const Extent3D& copySize);
44 
45     bool IsTypeless(DXGI_FORMAT format);
46 
47     void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
48                                                        const TextureCopySubresource& baseCopySplit,
49                                                        ID3D12Resource* bufferResource,
50                                                        uint64_t baseOffset,
51                                                        uint64_t bufferBytesPerRow,
52                                                        Texture* texture,
53                                                        uint32_t textureMiplevel,
54                                                        uint32_t textureLayer,
55                                                        Aspect aspect);
56 
57     void RecordCopyBufferToTexture(CommandRecordingContext* commandContext,
58                                    const TextureCopy& textureCopy,
59                                    ID3D12Resource* bufferResource,
60                                    const uint64_t offset,
61                                    const uint32_t bytesPerRow,
62                                    const uint32_t rowsPerImage,
63                                    const Extent3D& copySize,
64                                    Texture* texture,
65                                    Aspect aspect);
66 
67     void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
68                                                        const TextureCopySubresource& baseCopySplit,
69                                                        Buffer* buffer,
70                                                        uint64_t baseOffset,
71                                                        uint64_t bufferBytesPerRow,
72                                                        Texture* texture,
73                                                        uint32_t textureMiplevel,
74                                                        uint32_t textureLayer,
75                                                        Aspect aspect);
76 
77     void RecordCopyTextureToBuffer(ID3D12GraphicsCommandList* commandList,
78                                    const TextureCopy& textureCopy,
79                                    const BufferCopy& bufferCopy,
80                                    Texture* texture,
81                                    Buffer* buffer,
82                                    const Extent3D& copySize);
83 
84     void SetDebugName(Device* device,
85                       ID3D12Object* object,
86                       const char* prefix,
87                       std::string label = "");
88 
89 }}  // namespace dawn_native::d3d12
90 
91 #endif  // DAWNNATIVE_D3D12_UTILSD3D12_H_
92