aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGpu.h
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-06-02 05:49:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-02 05:49:21 -0700
commit33f6b3f6ee4de24282f5e7f2dc31a5f538bcf40c (patch)
treea42a432cb1d2460a2de870f4506271c720d5b0e7 /src/gpu/gl/GrGLGpu.h
parent0851d2d04716ad4a7c7a646a5846a81db3d5b925 (diff)
Manually generated sRGB mipmaps, with successively smaller draws.
Dirty GL-generated mipmaps whenever an sRGB texture is used with a new value for TEXTURE_SRGB_DECODE. Add a new test rectangle to the gamma GM that tests that textures are correctly converted to linear before filtering when generating mipmaps. Added a new unit test that alternates how a texture is interpreted (sRGB or not), to verify that we rebuild mipmaps when needed, and that we get the correct results out in both modes. This test originally failed on four of our bots producing incorrect mips in three different ways. I'm not real surprised, but it looks like we can't rely on glGenerateMipmap to do the right thing, in conjunction with TEXTURE_SRGB_DECODE. Instead, actually create mip-chains using a series of draw calls. (My first attempt used glBlitFramebuffer, and that still had bugs on several bots). This approach appears to work correctly on any device that fully supports sRGB. Because the mipmap draws are fairly destructive to state, I had to hoist them out of bindTexture. That means adding a second pass over the texture accesses in the processor, at the very beginning of flush. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1840473002 Review-Url: https://codereview.chromium.org/2007973002
Diffstat (limited to 'src/gpu/gl/GrGLGpu.h')
-rw-r--r--src/gpu/gl/GrGLGpu.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 0b2198a834..06d4bd357b 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -62,6 +62,8 @@ public:
void bindTexelBuffer(int unitIdx, intptr_t offsetInBytes, GrPixelConfig, GrGLBuffer*);
+ void generateMipmaps(const GrTextureParams& params, bool allowSRGBInputs, GrGLTexture* texture);
+
bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes,
GrPixelConfig readConfig, DrawPreference*,
ReadPixelTempDrawInfo*) override;
@@ -237,6 +239,7 @@ private:
GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint);
+ bool generateMipmap(GrGLTexture* texture, bool gammaCorrect);
void stampPLSSetupRect(const SkRect& bounds);
@@ -319,6 +322,8 @@ private:
void flushMinSampleShading(float minSampleShading);
+ void flushFramebufferSRGB(bool enable);
+
// helper for onCreateTexture and writeTexturePixels
enum UploadType {
kNewTexture_UploadType, // we are creating a new texture
@@ -365,6 +370,7 @@ private:
SkAutoTUnref<GrGLContext> fGLContext;
bool createCopyProgram(int progIdx);
+ bool createMipmapProgram(int progIdx);
bool createWireRectProgram();
bool createPLSSetupProgram();
@@ -532,6 +538,14 @@ private:
} fCopyPrograms[3];
SkAutoTUnref<GrGLBuffer> fCopyProgramArrayBuffer;
+ /** IDs for texture mipmap program. (4 filter configurations) */
+ struct {
+ GrGLuint fProgram;
+ GrGLint fTextureUniform;
+ GrGLint fTexCoordXformUniform;
+ } fMipmapPrograms[4];
+ SkAutoTUnref<GrGLBuffer> fMipmapProgramArrayBuffer;
+
struct {
GrGLuint fProgram;
GrGLint fColorUniform;
@@ -553,6 +567,12 @@ private:
}
}
+ static int TextureSizeToMipmapProgramIdx(int width, int height) {
+ const bool wide = (width > 1) && SkToBool(width & 0x1);
+ const bool tall = (height > 1) && SkToBool(height & 0x1);
+ return (wide ? 0x2 : 0x0) | (tall ? 0x1 : 0x0);
+ }
+
struct {
GrGLuint fProgram;
GrGLint fPosXformUniform;