diff options
author | Brian Salomon <bsalomon@google.com> | 2017-05-12 11:36:10 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-12 16:32:57 +0000 |
commit | 7c8460e10135c05a42d0744b84838bbc24398ac2 (patch) | |
tree | b4cb392726e4d997a47ccb7fa02552bd96698055 /include | |
parent | 0ff114fe11f9ac6ec869fa128321576764a76167 (diff) |
Make GrRenderTarget[(Proxy)|(Context)]? advertise a "full scene aa type".
Bug: skia:
Change-Id: I24549604e8305028e34e0022bfef992a8e8c33f7
Reviewed-on: https://skia-review.googlesource.com/16230
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrRenderTarget.h | 22 | ||||
-rw-r--r-- | include/gpu/GrTypesPriv.h | 34 | ||||
-rw-r--r-- | include/private/GrInstancedPipelineInfo.h | 6 | ||||
-rw-r--r-- | include/private/GrRenderTargetProxy.h | 26 |
4 files changed, 60 insertions, 28 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h index 05d1239f84..fdf6f9cddc 100644 --- a/include/gpu/GrRenderTarget.h +++ b/include/gpu/GrRenderTarget.h @@ -32,16 +32,14 @@ public: // GrRenderTarget bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; } - /** - * For our purposes, "Mixed Sampled" means the stencil buffer is multisampled but the color - * buffer is not. - */ - bool isMixedSampled() const { return fFlags & Flags::kMixedSampled; } - - /** - * "Unified Sampled" means the stencil and color buffers are both multisampled. - */ - bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->isMixedSampled(); } + GrFSAAType fsaaType() const { + if (!fDesc.fSampleCnt) { + SkASSERT(!(fFlags & Flags::kMixedSampled)); + return GrFSAAType::kNone; + } + return (fFlags & Flags::kMixedSampled) ? GrFSAAType::kMixedSamples + : GrFSAAType::kUnifiedMSAA; + } /** * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA). @@ -51,7 +49,9 @@ public: /** * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled). */ - int numColorSamples() const { return this->isMixedSampled() ? 0 : fDesc.fSampleCnt; } + int numColorSamples() const { + return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fDesc.fSampleCnt; + } /** * Call to indicate the multisample contents were modified such that the diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index 8f828e67d6..42da3d4481 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -51,6 +51,40 @@ static inline bool GrAATypeIsHW(GrAAType type) { return false; } +/** The type of full scene antialiasing supported by a render target. */ +enum class GrFSAAType { + /** No FSAA */ + kNone, + /** Regular MSAA where each attachment has the same sample count. */ + kUnifiedMSAA, + /** One color sample, N stencil samples. */ + kMixedSamples, +}; + +/** + * Not all drawing code paths support using mixed samples when available and instead use + * coverage-based aa. + */ +enum class GrAllowMixedSamples { kNo, kYes }; + +static inline GrAAType GrChooseAAType(GrAA aa, GrFSAAType fsaaType, + GrAllowMixedSamples allowMixedSamples) { + if (GrAA::kNo == aa) { + return GrAAType::kNone; + } + switch (fsaaType) { + case GrFSAAType::kNone: + return GrAAType::kCoverage; + case GrFSAAType::kUnifiedMSAA: + return GrAAType::kMSAA; + case GrFSAAType::kMixedSamples: + return GrAllowMixedSamples::kYes == allowMixedSamples ? GrAAType::kMixedSamples + : GrAAType::kCoverage; + } + SkFAIL("Unexpected fsaa type"); + return GrAAType::kNone; +} + /** * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars, * but should be applicable to other shader languages.) diff --git a/include/private/GrInstancedPipelineInfo.h b/include/private/GrInstancedPipelineInfo.h index 196c35b96f..c07425909a 100644 --- a/include/private/GrInstancedPipelineInfo.h +++ b/include/private/GrInstancedPipelineInfo.h @@ -16,9 +16,9 @@ */ struct GrInstancedPipelineInfo { GrInstancedPipelineInfo(const GrRenderTargetProxy* rtp) - : fIsMultisampled(rtp->isStencilBufferMultisampled()) - , fIsMixedSampled(rtp->isMixedSampled()) - , fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rtp->desc().fConfig)) {} + : fIsMultisampled(GrFSAAType::kNone != rtp->fsaaType()) + , fIsMixedSampled(GrFSAAType::kMixedSamples == rtp->fsaaType()) + , fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rtp->desc().fConfig)) {} bool canUseCoverageAA() const { return !fIsMultisampled || fIsMixedSampled; } diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index adc7553941..dd28b0f86d 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -26,28 +26,26 @@ public: // Actually instantiate the backing rendertarget, if necessary. GrRenderTarget* instantiate(GrResourceProvider* resourceProvider); - bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; } - - /** - * For our purposes, "Mixed Sampled" means the stencil buffer is multisampled but the color - * buffer is not. - */ - bool isMixedSampled() const { return fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled; } - - /** - * "Unified Sampled" means the stencil and color buffers are both multisampled. - */ - bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->isMixedSampled(); } - /** * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA). */ int numStencilSamples() const { return fDesc.fSampleCnt; } + GrFSAAType fsaaType() const { + if (!fDesc.fSampleCnt) { + SkASSERT(!(fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled)); + return GrFSAAType::kNone; + } + return (fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled) + ? GrFSAAType::kMixedSamples + : GrFSAAType::kUnifiedMSAA; + } /** * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled). */ - int numColorSamples() const { return this->isMixedSampled() ? 0 : fDesc.fSampleCnt; } + int numColorSamples() const { + return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fDesc.fSampleCnt; + } int maxWindowRectangles(const GrCaps& caps) const; |