diff options
author | egdaniel <egdaniel@google.com> | 2016-04-20 07:09:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-20 07:09:46 -0700 |
commit | 09aa1fce69b214714171db12c341aebd78dd29ea (patch) | |
tree | 2c57de3ceaa5ba5303278a3b04623df187ea97a6 /src/gpu/glsl/GrGLSLShaderBuilder.h | |
parent | b0ec9836dbf7f2304a3a29289b818719ca0a39bd (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
Committed: https://skia.googlesource.com/skia/+/45b61a1c4c0be896e7b12fd1405abfece799114f
Review URL: https://codereview.chromium.org/1885863004
Diffstat (limited to 'src/gpu/glsl/GrGLSLShaderBuilder.h')
-rw-r--r-- | src/gpu/glsl/GrGLSLShaderBuilder.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h index ef7963f83a..ea36a56a7a 100644 --- a/src/gpu/glsl/GrGLSLShaderBuilder.h +++ b/src/gpu/glsl/GrGLSLShaderBuilder.h @@ -9,14 +9,12 @@ #define GrGLSLShaderBuilder_DEFINED #include "GrAllocator.h" +#include "glsl/GrGLSLUniformHandler.h" #include "glsl/GrGLSLShaderVar.h" #include "SkTDArray.h" #include <stdarg.h> -class GrGLSLProgramBuilder; -class GrGLSLSampler; - /** base class for all shaders builders */ @@ -25,17 +23,19 @@ public: GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); virtual ~GrGLSLShaderBuilder() {} + typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle; + /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle order of the result depends on the GrTextureAccess associated with the GrGLSLSampler. */ void appendTextureLookup(SkString* out, - const GrGLSLSampler&, + SamplerHandle, const char* coordName, GrSLType coordType = kVec2f_GrSLType) const; /** Version of above that appends the result to the shader code instead.*/ - void appendTextureLookup(const GrGLSLSampler&, + void appendTextureLookup(SamplerHandle, const char* coordName, GrSLType coordType = kVec2f_GrSLType); @@ -45,17 +45,17 @@ public: vec4 or float. If modulation is "" or nullptr it this function acts as though appendTextureLookup were called. */ void appendTextureLookupAndModulate(const char* modulation, - const GrGLSLSampler&, + SamplerHandle, const char* coordName, GrSLType coordType = kVec2f_GrSLType); /** Fetches an unfiltered texel from a sampler at integer coordinates. coordExpr must match the dimensionality of the sampler and must be within the sampler's range. coordExpr is emitted exactly once, so expressions like "idx++" are acceptable. */ - void appendTexelFetch(SkString* out, const GrGLSLSampler&, const char* coordExpr) const; + void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) const; /** Version of above that appends the result to the shader code instead.*/ - void appendTexelFetch(const GrGLSLSampler&, const char* coordExpr); + void appendTexelFetch(SamplerHandle, const char* coordExpr); /** * Adds a #define directive to the top of the shader. |