diff options
author | mtklein <mtklein@google.com> | 2016-01-08 12:11:39 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 12:11:39 -0800 |
commit | 3183a4136364cfe18b3584302e71ea528a018401 (patch) | |
tree | 00dc9f7509516757e84de9c311a413743af1275f /include/gpu | |
parent | defa0daa6a0f4e97a3527a522ae602c6771a7c80 (diff) |
Revert of Add a class representing texture swizzle. (patchset #6 id:100001 of https://codereview.chromium.org/1567733005/ )
Reason for revert:
Shader compilation failures when implicitly converting vec4 to float.
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win8-MSVC-ShuttleA-GPU-GTX960-x86_64-Debug/builds/3266/steps/dm/logs/stdio
https://uberchromegw.corp.google.com/i/client.skia.android/builders/Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug/builds/3154/steps/dm/logs/stdio
Original issue's description:
> Add a class representing texture swizzle.
>
> Store config swizzle GrGLCaps and shader swizzles in GrGLSLCaps.
>
> Remove GrTextureAccess's swizzle and update users of it to swizzle in their shader code.
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1567733005
>
> Committed: https://skia.googlesource.com/skia/+/1a1efeacf7cc94a8c2977114dfe230fed3efc105
TBR=egdaniel@google.com,bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1569393002
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrTextureAccess.h | 55 | ||||
-rw-r--r-- | include/gpu/GrTypesPriv.h | 8 |
2 files changed, 51 insertions, 12 deletions
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h index 124a75aabc..e3ded34ff8 100644 --- a/include/gpu/GrTextureAccess.h +++ b/include/gpu/GrTextureAccess.h @@ -14,33 +14,60 @@ #include "SkRefCnt.h" #include "SkShader.h" -/** - * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with - * an associated GrTextureParams +/** A class representing the swizzle access pattern for a texture. Note that if the texture is + * an alpha-only texture then the alpha channel is substituted for other components. Any mangling + * to handle the r,g,b->a conversions for alpha textures is automatically included in the stage + * key. However, if a GrProcessor uses different swizzles based on its input then it must + * consider that variation in its key-generation. */ class GrTextureAccess : public SkNoncopyable { public: /** - * Must be initialized before adding to a GrProcessor's texture access list. + * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's + * constructor if it will be accessible via GrProcessor::textureAccess(). */ GrTextureAccess(); + /** + * Uses the default swizzle, "rgba". + */ GrTextureAccess(GrTexture*, const GrTextureParams&); - explicit GrTextureAccess(GrTexture*, GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); + /** + * swizzle must be a string between one and four (inclusive) characters containing only 'r', + * 'g', 'b', and/or 'a'. + */ + GrTextureAccess(GrTexture*, const char* swizzle, const GrTextureParams&); + GrTextureAccess(GrTexture*, + const char* swizzle, + GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, + SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); + void reset(GrTexture*, const GrTextureParams&); void reset(GrTexture*, GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); + void reset(GrTexture*, const char* swizzle, const GrTextureParams&); + void reset(GrTexture*, + const char* swizzle, + GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, + SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); - bool operator==(const GrTextureAccess& that) const { - return this->getTexture() == that.getTexture() && fParams == that.fParams; + bool operator== (const GrTextureAccess& other) const { +#ifdef SK_DEBUG + // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long. + SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) == + strcmp(fSwizzle, other.fSwizzle)); +#endif + return fParams == other.fParams && + (this->getTexture() == other.getTexture()) && + (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); } - bool operator!=(const GrTextureAccess& other) const { return !(*this == other); } + bool operator!= (const GrTextureAccess& other) const { return !(*this == other); } GrTexture* getTexture() const { return fTexture.get(); } @@ -49,14 +76,26 @@ public: */ const GrGpuResourceRef* getProgramTexture() const { return &fTexture; } + /** + * Returns a string representing the swizzle. The string is is null-terminated. + */ + const char* getSwizzle() const { return fSwizzle; } + + /** Returns a mask indicating which components are referenced in the swizzle. The return + is a bitfield of GrColorComponentFlags. */ + uint32_t swizzleMask() const { return fSwizzleMask; } + const GrTextureParams& getParams() const { return fParams; } private: + void setSwizzle(const char*); typedef GrTGpuResourceRef<GrTexture> ProgramTexture; ProgramTexture fTexture; GrTextureParams fParams; + uint32_t fSwizzleMask; + char fSwizzle[5]; typedef SkNoncopyable INHERITED; }; diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index 491b23b37b..16e2b0bc56 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -12,10 +12,10 @@ #include "SkTArray.h" #include "SkRect.h" - /** - * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars, - * but should be applicable to other shader languages.) - */ +/** + * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars, + * but should be applicable to other shader languages.) + */ enum GrSLType { kVoid_GrSLType, kFloat_GrSLType, |