• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_METAL_COMMANDBUFFERMTL_H_
16 #define DAWNNATIVE_METAL_COMMANDBUFFERMTL_H_
17 
18 #include "dawn_native/CommandBuffer.h"
19 #include "dawn_native/Error.h"
20 
21 #import <Metal/Metal.h>
22 
23 namespace dawn_native {
24     class CommandEncoder;
25 }
26 
27 namespace dawn_native { namespace metal {
28 
29     class CommandRecordingContext;
30     class Device;
31     class Texture;
32 
33     void RecordCopyBufferToTexture(CommandRecordingContext* commandContext,
34                                    id<MTLBuffer> mtlBuffer,
35                                    uint64_t bufferSize,
36                                    uint64_t offset,
37                                    uint32_t bytesPerRow,
38                                    uint32_t rowsPerImage,
39                                    Texture* texture,
40                                    uint32_t mipLevel,
41                                    const Origin3D& origin,
42                                    Aspect aspect,
43                                    const Extent3D& copySize);
44 
45     class CommandBuffer final : public CommandBufferBase {
46       public:
47         static Ref<CommandBuffer> Create(CommandEncoder* encoder,
48                                          const CommandBufferDescriptor* descriptor);
49 
50         MaybeError FillCommands(CommandRecordingContext* commandContext);
51 
52       private:
53         using CommandBufferBase::CommandBufferBase;
54 
55         MaybeError EncodeComputePass(CommandRecordingContext* commandContext);
56         MaybeError EncodeRenderPass(CommandRecordingContext* commandContext,
57                                     MTLRenderPassDescriptor* mtlRenderPass,
58                                     uint32_t width,
59                                     uint32_t height);
60 
61         MaybeError EncodeRenderPassInternal(CommandRecordingContext* commandContext,
62                                             MTLRenderPassDescriptor* mtlRenderPass,
63                                             uint32_t width,
64                                             uint32_t height);
65     };
66 
67 }}  // namespace dawn_native::metal
68 
69 #endif  // DAWNNATIVE_METAL_COMMANDBUFFERMTL_H_
70