Corentin Wallez | 4a9ef4e | 2018-07-18 11:40:26 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Dawn Authors |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 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 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 15 | #ifndef DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_ |
| 16 | #define DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_ |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 17 | |
Corentin Wallez | d37523f | 2018-07-24 13:53:51 +0200 | [diff] [blame] | 18 | #include "dawn_native/ComputePipeline.h" |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 19 | |
Corentin Wallez | 0055d95 | 2020-11-16 23:07:56 +0000 | [diff] [blame] | 20 | #include "common/NSRef.h" |
| 21 | |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 22 | #import <Metal/Metal.h> |
| 23 | |
Corentin Wallez | 49a65d0 | 2018-07-24 16:45:45 +0200 | [diff] [blame] | 24 | namespace dawn_native { namespace metal { |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 25 | |
Corentin Wallez | 8e335a5 | 2018-08-27 23:12:56 +0200 | [diff] [blame] | 26 | class Device; |
| 27 | |
Rafael Cintron | c64242d | 2020-04-06 18:20:02 +0000 | [diff] [blame] | 28 | class ComputePipeline final : public ComputePipelineBase { |
Corentin Wallez | f58d84d | 2017-11-24 14:12:44 -0500 | [diff] [blame] | 29 | public: |
Jiawei Shao | 8fd1eb5 | 2021-10-13 00:43:05 +0000 | [diff] [blame] | 30 | static Ref<ComputePipeline> CreateUninitialized( |
Corentin Wallez | 50f9958 | 2021-03-31 18:36:32 +0000 | [diff] [blame] | 31 | Device* device, |
| 32 | const ComputePipelineDescriptor* descriptor); |
Jiawei Shao | 8fd1eb5 | 2021-10-13 00:43:05 +0000 | [diff] [blame] | 33 | static void InitializeAsync(Ref<ComputePipelineBase> computePipeline, |
| 34 | WGPUCreateComputePipelineAsyncCallback callback, |
| 35 | void* userdata); |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 36 | |
Corentin Wallez | f58d84d | 2017-11-24 14:12:44 -0500 | [diff] [blame] | 37 | void Encode(id<MTLComputeCommandEncoder> encoder); |
| 38 | MTLSize GetLocalWorkGroupSize() const; |
Corentin Wallez | bfc9cee | 2019-08-02 18:15:08 +0000 | [diff] [blame] | 39 | bool RequiresStorageBufferLength() const; |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 40 | |
Corentin Wallez | f58d84d | 2017-11-24 14:12:44 -0500 | [diff] [blame] | 41 | private: |
Ryan Harrison | 5c413af | 2019-12-12 17:51:39 +0000 | [diff] [blame] | 42 | using ComputePipelineBase::ComputePipelineBase; |
Jiawei Shao | 42448da | 2021-09-11 09:04:34 +0000 | [diff] [blame] | 43 | MaybeError Initialize() override; |
Ryan Harrison | 5c413af | 2019-12-12 17:51:39 +0000 | [diff] [blame] | 44 | |
Corentin Wallez | 0055d95 | 2020-11-16 23:07:56 +0000 | [diff] [blame] | 45 | NSPRef<id<MTLComputePipelineState>> mMtlComputePipelineState; |
Corentin Wallez | f58d84d | 2017-11-24 14:12:44 -0500 | [diff] [blame] | 46 | MTLSize mLocalWorkgroupSize; |
Corentin Wallez | bfc9cee | 2019-08-02 18:15:08 +0000 | [diff] [blame] | 47 | bool mRequiresStorageBufferLength; |
Austin Eng | 5528d0e | 2021-09-15 18:16:50 +0000 | [diff] [blame] | 48 | std::vector<uint32_t> mWorkgroupAllocations; |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 49 | }; |
| 50 | |
Corentin Wallez | 49a65d0 | 2018-07-24 16:45:45 +0200 | [diff] [blame] | 51 | }} // namespace dawn_native::metal |
Corentin Wallez | 0ba5550 | 2017-06-14 15:46:59 -0400 | [diff] [blame] | 52 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 53 | #endif // DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_ |