From d08ea5fdae990ee7829e3755abddfab9740eab99 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Fri, 20 Feb 2015 06:58:13 -0800 Subject: Round stencil buffers dims up to next pow2 when allowed Review URL: https://codereview.chromium.org/937303002 --- src/gpu/GrGpu.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/gpu/GrGpu.cpp') diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 27fed3c582..d22399f81c 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -87,8 +87,15 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { SkASSERT(NULL == rt->getStencilBuffer()); GrUniqueKey sbKey; - GrStencilBuffer::ComputeSharedStencilBufferKey(rt->width(), rt->height(), rt->numSamples(), - &sbKey); + + int width = rt->width(); + int height = rt->height(); + if (this->caps()->oversizedStencilSupport()) { + width = SkNextPow2(width); + height = SkNextPow2(height); + } + + GrStencilBuffer::ComputeSharedStencilBufferKey(width, height, rt->numSamples(), &sbKey); SkAutoTUnref sb(static_cast( this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))); if (sb) { @@ -99,7 +106,7 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { } return attached; } - if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height())) { + if (this->createStencilBufferForRenderTarget(rt, width, height)) { // Right now we're clearing the stencil buffer here after it is // attached to an RT for the first time. When we start matching // stencil buffers with smaller color targets this will no longer -- cgit v1.2.3