blob: 93c3b7e90d9c722c863974399feec0b59a2fffa9 [file] [log] [blame]
Stephen White4da34bf2019-07-30 10:37:47 -04001/*
2 * Copyright 2019 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 GrDawnUniformHandler_DEFINED
9#define GrDawnUniformHandler_DEFINED
10
Michael Ludwig45191342020-03-24 12:29:39 -040011#include "src/gpu/GrTAllocator.h"
Stephen White4da34bf2019-07-30 10:37:47 -040012#include "src/gpu/glsl/GrGLSLUniformHandler.h"
13
14class GrDawnGpu;
15
16class GrDawnUniformHandler : public GrGLSLUniformHandler {
17public:
18 static const int kUniformsPerBlock = 8;
19
20 const GrShaderVar& getUniformVariable(UniformHandle u) const override;
21 const char* getUniformCStr(UniformHandle u) const override;
22
Ethan Nicholas16464c32020-04-06 13:53:05 -040023 struct DawnUniformInfo : public UniformInfo {
24 int fUBOOffset;
Stephen White4da34bf2019-07-30 10:37:47 -040025 };
Ethan Nicholas16464c32020-04-06 13:53:05 -040026 typedef GrTAllocator<DawnUniformInfo> UniformInfoArray;
Stephen White4da34bf2019-07-30 10:37:47 -040027 enum {
Stephen Whitedd78efd2019-10-23 15:00:20 -040028 kUniformBinding = 0,
Stephen White4da34bf2019-07-30 10:37:47 -040029 };
Stephen White40c47e12019-11-01 13:13:03 -040030 uint32_t getRTHeightOffset() const;
Stephen White4da34bf2019-07-30 10:37:47 -040031
32private:
33 explicit GrDawnUniformHandler(GrGLSLProgramBuilder* program);
34
Chris Dalton1b1b0d52020-03-03 12:00:59 -070035 SamplerHandle addSampler(const GrBackendFormat&, GrSamplerState, const GrSwizzle&,
Stephen White4da34bf2019-07-30 10:37:47 -040036 const char* name, const GrShaderCaps*) override;
37 const char* samplerVariable(SamplerHandle handle) const override;
38 GrSwizzle samplerSwizzle(SamplerHandle handle) const override;
39 void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
Ethan Nicholas16464c32020-04-06 13:53:05 -040040 UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
41 uint32_t visibility,
Stephen White4da34bf2019-07-30 10:37:47 -040042 GrSLType type,
43 const char* name,
44 bool mangleName,
45 int arrayCount,
46 const char** outName) override;
47
Ethan Nicholas16464c32020-04-06 13:53:05 -040048
49 UniformInfoArray fUniforms;
50 UniformInfoArray fSamplers;
51 UniformInfoArray fTextures;
52 SkTArray<GrSwizzle> fSamplerSwizzles;
53 SkTArray<SkString> fSamplerReferences;
Stephen White170d9902019-08-15 16:48:24 -040054
Stephen Whitedd78efd2019-10-23 15:00:20 -040055 uint32_t fCurrentUBOOffset = 0;
Stephen White40c47e12019-11-01 13:13:03 -040056 uint32_t fRTHeightOffset = 0;
Stephen White4da34bf2019-07-30 10:37:47 -040057
58 friend class GrDawnProgramBuilder;
59 typedef GrGLSLUniformHandler INHERITED;
60};
61
62#endif