Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrMtlPipelineStateDataManager_DEFINED |
| 9 | #define GrMtlPipelineStateDataManager_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/core/SkAutoMalloc.h" |
Jim Van Verth | abf4d50 | 2021-02-10 14:39:25 -0500 | [diff] [blame^] | 12 | #include "src/gpu/GrUniformDataManager.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/mtl/GrMtlUniformHandler.h" |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 14 | |
Jim Van Verth | dd15d69 | 2019-04-22 15:29:53 -0400 | [diff] [blame] | 15 | #import <Metal/Metal.h> |
| 16 | |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 17 | class GrMtlBuffer; |
| 18 | class GrMtlGpu; |
| 19 | |
Jim Van Verth | abf4d50 | 2021-02-10 14:39:25 -0500 | [diff] [blame^] | 20 | class GrMtlPipelineStateDataManager : public GrUniformDataManager { |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 21 | public: |
| 22 | typedef GrMtlUniformHandler::UniformInfoArray UniformInfoArray; |
| 23 | |
| 24 | GrMtlPipelineStateDataManager(const UniformInfoArray&, |
Ethan Nicholas | e5dc1eb | 2019-08-13 17:02:25 -0400 | [diff] [blame] | 25 | uint32_t uniformSize); |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 26 | |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 27 | void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override; |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 28 | void set1fv(UniformHandle, int arrayCount, const float v[]) const override; |
Michael Ludwig | 779ed02 | 2018-08-28 17:20:07 -0400 | [diff] [blame] | 29 | void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override; |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 30 | void set2fv(UniformHandle, int arrayCount, const float v[]) const override; |
Jim Van Verth | abf4d50 | 2021-02-10 14:39:25 -0500 | [diff] [blame^] | 31 | // matrices are column-major, the first one uploads a single matrix, the latter uploads |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 32 | // arrayCount matrices into a uniform array. |
| 33 | void setMatrix2f(UniformHandle, const float matrix[]) const override; |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 34 | void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override; |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 35 | |
| 36 | // for nvpr only |
| 37 | void setPathFragmentInputTransform(VaryingHandle u, int components, |
| 38 | const SkMatrix& matrix) const override { |
| 39 | SK_ABORT("Only supported in NVPR, which is not in Metal"); |
| 40 | } |
| 41 | |
Jim Van Verth | dd15d69 | 2019-04-22 15:29:53 -0400 | [diff] [blame] | 42 | void uploadAndBindUniformBuffers(GrMtlGpu* gpu, |
| 43 | id<MTLRenderCommandEncoder> renderCmdEncoder) const; |
| 44 | void resetDirtyBits(); |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 45 | |
| 46 | private: |
Jim Van Verth | abf4d50 | 2021-02-10 14:39:25 -0500 | [diff] [blame^] | 47 | typedef GrUniformDataManager INHERITED; |
Timothy Liang | 44636e9 | 2018-08-08 10:50:21 -0400 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #endif |