blob: fe63329da409aab310f0af73326f767f326eee61 [file] [log] [blame]
Timothy Liang44636e92018-08-08 10:50:21 -04001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/core/SkAutoMalloc.h"
Jim Van Verthabf4d502021-02-10 14:39:25 -050012#include "src/gpu/GrUniformDataManager.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/mtl/GrMtlUniformHandler.h"
Timothy Liang44636e92018-08-08 10:50:21 -040014
Jim Van Verthdd15d692019-04-22 15:29:53 -040015#import <Metal/Metal.h>
16
Timothy Liang44636e92018-08-08 10:50:21 -040017class GrMtlBuffer;
18class GrMtlGpu;
19
Jim Van Verthabf4d502021-02-10 14:39:25 -050020class GrMtlPipelineStateDataManager : public GrUniformDataManager {
Timothy Liang44636e92018-08-08 10:50:21 -040021public:
22 typedef GrMtlUniformHandler::UniformInfoArray UniformInfoArray;
23
24 GrMtlPipelineStateDataManager(const UniformInfoArray&,
Ethan Nicholase5dc1eb2019-08-13 17:02:25 -040025 uint32_t uniformSize);
Timothy Liang44636e92018-08-08 10:50:21 -040026
Timothy Liang44636e92018-08-08 10:50:21 -040027 void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
Timothy Liang44636e92018-08-08 10:50:21 -040028 void set1fv(UniformHandle, int arrayCount, const float v[]) const override;
Michael Ludwig779ed022018-08-28 17:20:07 -040029 void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
Timothy Liang44636e92018-08-08 10:50:21 -040030 void set2fv(UniformHandle, int arrayCount, const float v[]) const override;
Jim Van Verthabf4d502021-02-10 14:39:25 -050031 // matrices are column-major, the first one uploads a single matrix, the latter uploads
Timothy Liang44636e92018-08-08 10:50:21 -040032 // arrayCount matrices into a uniform array.
33 void setMatrix2f(UniformHandle, const float matrix[]) const override;
Timothy Liang44636e92018-08-08 10:50:21 -040034 void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override;
Timothy Liang44636e92018-08-08 10:50:21 -040035
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 Verthdd15d692019-04-22 15:29:53 -040042 void uploadAndBindUniformBuffers(GrMtlGpu* gpu,
43 id<MTLRenderCommandEncoder> renderCmdEncoder) const;
44 void resetDirtyBits();
Timothy Liang44636e92018-08-08 10:50:21 -040045
46private:
Jim Van Verthabf4d502021-02-10 14:39:25 -050047 typedef GrUniformDataManager INHERITED;
Timothy Liang44636e92018-08-08 10:50:21 -040048};
49
50#endif