aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLUniformHandler.h
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-04-19 14:45:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-19 14:45:57 -0700
commit45b61a1c4c0be896e7b12fd1405abfece799114f (patch)
treed39781d14238a55da739d0174854cbfedb8b76f1 /src/gpu/glsl/GrGLSLUniformHandler.h
parent4c13db2a6bb4c795bec6b050b6ebd2ff5177bb5e (diff)
Refactor how we store and use samplers in Ganesh
The main goal of this refactorization is to allow Vulkan to use separate sampler and texture objects in the shader and descriptor sets and combine them into a sampler2d in the shader where needed. A large part of this is separating how we store samplers and uniforms in the UniformHandler. We no longer need to store handles to samplers besides when we are initially emitting code. After we emit code all we ever do is loop over all samplers and do some processor independent work on them, so we have no need for direct access to individual samplers. In the GLProgram all we ever do is set the sampler uniforms in the ctor and never touch them again, so no need to save sampler info there. The texture access on program reuse just assume that they come in the same order as we set the texture units for the samplers For Vulkan, it is a similar story. We create the descriptor set layouts with the samplers, then when we get new textures, we just assume they come in in the same order as we set the samplers on the descriptor sets. Thus no need to save direct vulkan info. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1885863004 Review URL: https://codereview.chromium.org/1885863004
Diffstat (limited to 'src/gpu/glsl/GrGLSLUniformHandler.h')
-rw-r--r--src/gpu/glsl/GrGLSLUniformHandler.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h
index a2f70532ad..56cac4a49f 100644
--- a/src/gpu/glsl/GrGLSLUniformHandler.h
+++ b/src/gpu/glsl/GrGLSLUniformHandler.h
@@ -12,12 +12,14 @@
#include "GrGLSLShaderVar.h"
class GrGLSLProgramBuilder;
+class GrGLSLSampler;
class GrGLSLUniformHandler {
public:
virtual ~GrGLSLUniformHandler() {}
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
+ typedef GrGLSLProgramDataManager::UniformHandle SamplerHandle;
/** Add a uniform variable to the current program, that has visibility in one or more shaders.
visibility is a bitfield of GrShaderFlag values indicating from which shaders the uniform
@@ -30,6 +32,7 @@ public:
GrSLPrecision precision,
const char* name,
const char** outName = nullptr) {
+ SkASSERT(!GrSLTypeIsSamplerType(type));
return this->addUniformArray(visibility, type, precision, name, 0, outName);
}
@@ -39,6 +42,7 @@ public:
const char* name,
int arrayCount,
const char** outName = nullptr) {
+ SkASSERT(!GrSLTypeIsSamplerType(type));
return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount,
outName);
}
@@ -49,6 +53,7 @@ public:
* Shortcut for getUniformVariable(u).c_str()
*/
virtual const char* getUniformCStr(UniformHandle u) const = 0;
+
protected:
explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuilder(program) {}
@@ -56,6 +61,23 @@ protected:
GrGLSLProgramBuilder* fProgramBuilder;
private:
+ virtual int numSamplers() const = 0;
+ virtual const GrGLSLSampler& getSampler(SamplerHandle handle) const = 0;
+
+ SamplerHandle addSampler(uint32_t visibility,
+ GrPixelConfig config,
+ GrSLType type,
+ GrSLPrecision precision,
+ const char* name) {
+ return this->internalAddSampler(visibility, config, type, precision, name);
+ }
+
+ virtual SamplerHandle internalAddSampler(uint32_t visibility,
+ GrPixelConfig config,
+ GrSLType type,
+ GrSLPrecision precision,
+ const char* name) = 0;
+
virtual UniformHandle internalAddUniformArray(uint32_t visibility,
GrSLType type,
GrSLPrecision precision,