Line data Source code
1 : /*
2 : * Copyright 2015 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 GrGLUniformHandler_DEFINED
9 : #define GrGLUniformHandler_DEFINED
10 :
11 : #include "glsl/GrGLSLUniformHandler.h"
12 :
13 : #include "gl/GrGLProgramDataManager.h"
14 :
15 : class GrGLCaps;
16 :
17 0 : class GrGLUniformHandler : public GrGLSLUniformHandler {
18 : public:
19 : static const int kUniformsPerBlock = 8;
20 :
21 0 : const GrShaderVar& getUniformVariable(UniformHandle u) const override {
22 0 : return fUniforms[u.toIndex()].fVariable;
23 : }
24 :
25 0 : const char* getUniformCStr(UniformHandle u) const override {
26 0 : return this->getUniformVariable(u).c_str();
27 : }
28 : private:
29 0 : explicit GrGLUniformHandler(GrGLSLProgramBuilder* program)
30 0 : : INHERITED(program)
31 : , fUniforms(kUniformsPerBlock)
32 : , fSamplers(kUniformsPerBlock)
33 0 : , fImageStorages(kUniformsPerBlock) {}
34 :
35 : UniformHandle internalAddUniformArray(uint32_t visibility,
36 : GrSLType type,
37 : GrSLPrecision precision,
38 : const char* name,
39 : bool mangleName,
40 : int arrayCount,
41 : const char** outName) override;
42 :
43 : SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
44 : const char* name) override;
45 :
46 0 : const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
47 0 : return fSamplers[handle.toIndex()].fVariable;
48 : }
49 :
50 : ImageStorageHandle addImageStorage(uint32_t visibility, GrSLType, GrImageStorageFormat,
51 : GrSLMemoryModel, GrSLRestrict, GrIOType,
52 : const char* name) override;
53 :
54 0 : GrSwizzle samplerSwizzle(SamplerHandle handle) const override {
55 0 : return fSamplerSwizzles[handle.toIndex()];
56 : }
57 :
58 0 : const GrShaderVar& imageStorageVariable(ImageStorageHandle handle) const override {
59 0 : return fImageStorages[handle.toIndex()].fVariable;
60 : }
61 :
62 : void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
63 :
64 : // Manually set uniform locations for all our uniforms.
65 : void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps);
66 :
67 : // Updates the loction of the Uniforms if we cannot bind uniform locations manually
68 : void getUniformLocations(GrGLuint programID, const GrGLCaps& caps);
69 :
70 : const GrGLGpu* glGpu() const;
71 :
72 : typedef GrGLProgramDataManager::UniformInfo UniformInfo;
73 : typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
74 :
75 : UniformInfoArray fUniforms;
76 : UniformInfoArray fSamplers;
77 : SkTArray<GrSwizzle> fSamplerSwizzles;
78 : UniformInfoArray fImageStorages;
79 :
80 : friend class GrGLProgramBuilder;
81 :
82 : typedef GrGLSLUniformHandler INHERITED;
83 : };
84 :
85 : #endif
|