• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #include "src/gpu/GrAllocator.h"
12 #include "src/gpu/glsl/GrGLSLUniformHandler.h"
13 
14 class GrDawnGpu;
15 
16 class GrDawnUniformHandler : public GrGLSLUniformHandler {
17 public:
18     static const int kUniformsPerBlock = 8;
19 
20     const GrShaderVar& getUniformVariable(UniformHandle u) const override;
21     const char* getUniformCStr(UniformHandle u) const override;
22 
23     struct UniformInfo {
24         GrShaderVar    fVar;
25         int            fUBOOffset;
26         int            fVisibility;
27     };
28     typedef GrTAllocator<UniformInfo> UniformInfoArray;
29     enum {
30         kGeometryBinding = 0,
31         kFragBinding = 1,
32         kSamplerBindingBase = 2,
33     };
34 
35 private:
36     explicit GrDawnUniformHandler(GrGLSLProgramBuilder* program);
37 
38     SamplerHandle addSampler(const GrTexture*, const GrSamplerState&, const GrSwizzle&,
39                              const char* name, const GrShaderCaps*) override;
40     const char* samplerVariable(SamplerHandle handle) const override;
41     GrSwizzle samplerSwizzle(SamplerHandle handle) const override;
42     void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
43     UniformHandle internalAddUniformArray(uint32_t visibility,
44                                           GrSLType type,
45                                           const char* name,
46                                           bool mangleName,
47                                           int arrayCount,
48                                           const char** outName) override;
49 
50     UniformInfoArray     fUniforms;
51     UniformInfoArray     fSamplers;
52     UniformInfoArray     fTextures;
53     SkTArray<GrSwizzle>  fSamplerSwizzles;
54     SkTArray<SkString>   fSamplerReferences;
55 
56     uint32_t fCurrentGeometryUBOOffset = 0;
57     uint32_t fCurrentFragmentUBOOffset = 0;
58 
59     friend class GrDawnProgramBuilder;
60     typedef GrGLSLUniformHandler INHERITED;
61 };
62 
63 #endif
64