Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1666563003: Add support for GL_EXT_raster_multisample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove rasterMultisampleSupport Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLPathRendering.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3b7ccd32417718a14367399125d5247981f84978..8dc8e44d87f85c190bf2c71d1fd6e5af4dee703b 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -443,11 +443,14 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
if (resetBits & kMSAAEnable_GrGLBackendState) {
fMSAAEnabled = kUnknown_TriState;
- // In mixed samples mode coverage modulation allows the coverage to be converted to
- // "opacity", which can then be blended into the color buffer to accomplish antialiasing.
- // Enable coverage modulation suitable for premultiplied alpha colors.
- // This state has no effect when not rendering to a mixed sampled target.
if (this->caps()->usesMixedSamples()) {
+ if (0 != this->caps()->maxRasterSamples()) {
+ fHWRasterMultisampleEnabled = kUnknown_TriState;
+ fHWNumRasterSamples = 0;
+ }
+
+ // The skia blend modes all use premultiplied alpha and therefore expect RGBA coverage
+ // modulation. This state has no effect when not rendering to a mixed sampled target.
GL_CALL(CoverageModulation(GR_GL_RGBA));
}
}
@@ -1711,7 +1714,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
this->flushStencil(pipeline.getStencil());
this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin());
- this->flushHWAAState(glRT, pipeline.isHWAntialiasState());
+ this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled());
// This must come after textures are flushed because a texture may need
// to be msaa-resolved (which will modify bound FBO state).
@@ -2384,7 +2387,7 @@ void GrGLGpu::performFlushWorkaround() {
*/
this->disableScissor();
// using PLS in the presence of MSAA results in GL_INVALID_OPERATION
- this->flushHWAAState(nullptr, false);
+ this->flushHWAAState(nullptr, false, false);
SkASSERT(!fHWPLSEnabled);
SkASSERT(fMSAAEnabled != kYes_TriState);
GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
@@ -2716,7 +2719,7 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
}
}
-void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
+void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled) {
SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
if (this->glCaps().multisampleDisableSupport()) {
@@ -2732,6 +2735,29 @@ void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
}
}
}
+
+ if (0 != this->caps()->maxRasterSamples()) {
+ if (useHWAA && rt->hasMixedSamples() && !stencilEnabled) {
+ // Since stencil is disabled and we want more samples than are in the color buffer, we
+ // need to tell the rasterizer explicitly how many to run.
+ if (kYes_TriState != fHWRasterMultisampleEnabled) {
+ GL_CALL(Enable(GR_GL_RASTER_MULTISAMPLE));
+ fHWRasterMultisampleEnabled = kYes_TriState;
+ }
+ if (rt->numStencilSamples() != fHWNumRasterSamples) {
+ SkASSERT(rt->numStencilSamples() <= this->caps()->maxRasterSamples());
+ GL_CALL(RasterSamples(rt->numStencilSamples(), GR_GL_TRUE));
+ fHWNumRasterSamples = rt->numStencilSamples();
+ }
+ } else {
+ if (kNo_TriState != fHWRasterMultisampleEnabled) {
+ GL_CALL(Disable(GR_GL_RASTER_MULTISAMPLE));
+ fHWRasterMultisampleEnabled = kNo_TriState;
+ }
+ }
+ } else {
+ SkASSERT(!useHWAA || !rt->hasMixedSamples() || stencilEnabled);
+ }
}
void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle& swizzle) {
@@ -3474,7 +3500,7 @@ void GrGLGpu::drawDebugWireRect(GrRenderTarget* rt, const SkIRect& rect, GrColor
this->flushBlend(blendInfo, GrSwizzle::RGBA());
this->flushColorWrite(true);
this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
- this->flushHWAAState(glRT, false);
+ this->flushHWAAState(glRT, false, false);
this->disableScissor();
GrStencilSettings stencil;
stencil.setDisabled();
@@ -3552,7 +3578,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
this->flushBlend(blendInfo, GrSwizzle::RGBA());
this->flushColorWrite(true);
this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
- this->flushHWAAState(dstRT, false);
+ this->flushHWAAState(dstRT, false, false);
this->disableScissor();
GrStencilSettings stencil;
stencil.setDisabled();
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLPathRendering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698