Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: src/gpu/glsl/GrGLSLUniformHandler.h

Issue 1885863004: Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLSLUniformHandler_DEFINED 8 #ifndef GrGLSLUniformHandler_DEFINED
9 #define GrGLSLUniformHandler_DEFINED 9 #define GrGLSLUniformHandler_DEFINED
10 10
11 #include "GrGLSLProgramDataManager.h" 11 #include "GrGLSLProgramDataManager.h"
12 #include "GrGLSLShaderVar.h" 12 #include "GrGLSLShaderVar.h"
13 13
14 class GrGLSLProgramBuilder; 14 class GrGLSLProgramBuilder;
15 class GrGLSLSampler;
15 16
16 class GrGLSLUniformHandler { 17 class GrGLSLUniformHandler {
17 public: 18 public:
18 virtual ~GrGLSLUniformHandler() {} 19 virtual ~GrGLSLUniformHandler() {}
19 20
20 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 21 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
22 typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle;
21 23
22 /** Add a uniform variable to the current program, that has visibility in on e or more shaders. 24 /** Add a uniform variable to the current program, that has visibility in on e or more shaders.
23 visibility is a bitfield of GrShaderFlag values indicating from which sh aders the uniform 25 visibility is a bitfield of GrShaderFlag values indicating from which sh aders the uniform
24 should be accessible. At least one bit must be set. Geometry shader unif orms are not 26 should be accessible. At least one bit must be set. Geometry shader unif orms are not
25 supported at this time. The actual uniform name will be mangled. If outN ame is not nullptr 27 supported at this time. The actual uniform name will be mangled. If outN ame is not nullptr
26 then it will refer to the final uniform name after return. Use the addUn iformArray variant 28 then it will refer to the final uniform name after return. Use the addUn iformArray variant
27 to add an array of uniforms. */ 29 to add an array of uniforms. */
28 UniformHandle addUniform(uint32_t visibility, 30 UniformHandle addUniform(uint32_t visibility,
29 GrSLType type, 31 GrSLType type,
30 GrSLPrecision precision, 32 GrSLPrecision precision,
31 const char* name, 33 const char* name,
32 const char** outName = nullptr) { 34 const char** outName = nullptr) {
35 SkASSERT(!GrSLTypeIsSamplerType(type));
33 return this->addUniformArray(visibility, type, precision, name, 0, outNa me); 36 return this->addUniformArray(visibility, type, precision, name, 0, outNa me);
34 } 37 }
35 38
36 UniformHandle addUniformArray(uint32_t visibility, 39 UniformHandle addUniformArray(uint32_t visibility,
37 GrSLType type, 40 GrSLType type,
38 GrSLPrecision precision, 41 GrSLPrecision precision,
39 const char* name, 42 const char* name,
40 int arrayCount, 43 int arrayCount,
41 const char** outName = nullptr) { 44 const char** outName = nullptr) {
45 SkASSERT(!GrSLTypeIsSamplerType(type));
42 return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount, 46 return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount,
43 outName); 47 outName);
44 } 48 }
45 49
46 virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0 ; 50 virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0 ;
47 51
48 /** 52 /**
49 * Shortcut for getUniformVariable(u).c_str() 53 * Shortcut for getUniformVariable(u).c_str()
50 */ 54 */
51 virtual const char* getUniformCStr(UniformHandle u) const = 0; 55 virtual const char* getUniformCStr(UniformHandle u) const = 0;
56
57 virtual const GrGLSLSampler& getSampler(SamplerHandle handle) const = 0;
bsalomon 2016/04/14 01:40:16 It seems a bit unfortunate to make every processor
egdaniel 2016/04/14 03:11:50 Yeah I think it would be fine for appendTexLookup
58
52 protected: 59 protected:
53 explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuild er(program) {} 60 explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuild er(program) {}
54 61
55 // This is not owned by the class 62 // This is not owned by the class
56 GrGLSLProgramBuilder* fProgramBuilder; 63 GrGLSLProgramBuilder* fProgramBuilder;
57 64
58 private: 65 private:
66 virtual int numSamplers() const = 0;
67
68 SamplerHandle addSampler(uint32_t visibility,
69 GrPixelConfig config,
70 GrSLType type,
71 GrSLPrecision precision,
72 const char* name) {
73 this->internalAddSampler(visibility, config, type, precision, name);
74 }
75
76 virtual SamplerHandle internalAddSampler(uint32_t visibility,
77 GrPixelConfig config,
78 GrSLType type,
79 GrSLPrecision precision,
80 const char* name) = 0;
81
59 virtual UniformHandle internalAddUniformArray(uint32_t visibility, 82 virtual UniformHandle internalAddUniformArray(uint32_t visibility,
60 GrSLType type, 83 GrSLType type,
61 GrSLPrecision precision, 84 GrSLPrecision precision,
62 const char* name, 85 const char* name,
63 bool mangleName, 86 bool mangleName,
64 int arrayCount, 87 int arrayCount,
65 const char** outName) = 0; 88 const char** outName) = 0;
66 89
90
67 virtual void appendUniformDecls(GrShaderFlags visibility, SkString*) const = 0; 91 virtual void appendUniformDecls(GrShaderFlags visibility, SkString*) const = 0;
68 92
69 friend class GrGLSLProgramBuilder; 93 friend class GrGLSLProgramBuilder;
70 }; 94 };
71 95
72 #endif 96 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698