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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1431593006: Fix mixed samples stencil clip (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLPathRendering.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 1485
1486 int numTextureAccesses = textureAccesses.count(); 1486 int numTextureAccesses = textureAccesses.count();
1487 for (int i = 0; i < numTextureAccesses; i++) { 1487 for (int i = 0; i < numTextureAccesses; i++) {
1488 this->bindTexture(i, textureAccesses[i]->getParams(), 1488 this->bindTexture(i, textureAccesses[i]->getParams(),
1489 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re())); 1489 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re()));
1490 } 1490 }
1491 1491
1492 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); 1492 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
1493 this->flushStencil(pipeline.getStencil()); 1493 this->flushStencil(pipeline.getStencil());
1494 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); 1494 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
1495 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled()); 1495 this->flushHWAAState(glRT, pipeline.isHWAntialiasState());
1496 1496
1497 // This must come after textures are flushed because a texture may need 1497 // This must come after textures are flushed because a texture may need
1498 // to be msaa-resolved (which will modify bound FBO state). 1498 // to be msaa-resolved (which will modify bound FBO state).
1499 this->flushRenderTarget(glRT, nullptr); 1499 this->flushRenderTarget(glRT, nullptr, pipeline.hasCoCenteredSamples());
1500 1500
1501 return true; 1501 return true;
1502 } 1502 }
1503 1503
1504 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 1504 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
1505 const GrNonInstancedVertices& vertices, 1505 const GrNonInstancedVertices& vertices,
1506 size_t* indexOffsetInBytes) { 1506 size_t* indexOffsetInBytes) {
1507 GrGLVertexBuffer* vbuf; 1507 GrGLVertexBuffer* vbuf;
1508 vbuf = (GrGLVertexBuffer*) vertices.vertexBuffer(); 1508 vbuf = (GrGLVertexBuffer*) vertices.vertexBuffer();
1509 1509
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 if (!flipY) { 2019 if (!flipY) {
2020 dst += rowBytes; 2020 dst += rowBytes;
2021 } else { 2021 } else {
2022 dst -= rowBytes; 2022 dst -= rowBytes;
2023 } 2023 }
2024 } 2024 }
2025 } 2025 }
2026 return true; 2026 return true;
2027 } 2027 }
2028 2028
2029 void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedS ampleLocations) { 2029 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound,
2030 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget ()); 2030 bool coCenterSamples) {
2031 SkASSERT(0 != target->renderFBOID());
2032
2033 if (!rt->isStencilBufferMultisampled() ||
2034 useColocatedSampleLocations == target->usesColocatedSampleLocations()) {
2035 return;
2036 }
2037
2038 if (kGL_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_VER (4,5)) {
2039 GL_CALL(NamedFramebufferParameteri(target->renderFBOID(),
2040 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE _LOCATIONS,
2041 useColocatedSampleLocations));
2042 } else {
2043 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
2044 GL_CALL(FramebufferParameteri(GR_GL_FRAMEBUFFER,
2045 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCA TIONS,
2046 useColocatedSampleLocations));
2047 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
2048 }
2049
2050 target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations);
2051 }
2052
2053 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) {
2054
2055 SkASSERT(target); 2031 SkASSERT(target);
2032 SkASSERT(!coCenterSamples || this->caps()->programmableSampleLocationsSuppor t());
2056 2033
2057 uint32_t rtID = target->getUniqueID(); 2034 uint32_t rtID = target->getUniqueID();
2058 if (fHWBoundRenderTargetUniqueID != rtID) { 2035 if (fHWBoundRenderTargetUniqueID != rtID) {
2059 fStats.incRenderTargetBinds(); 2036 fStats.incRenderTargetBinds();
2060 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); 2037 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
2061 #ifdef SK_DEBUG 2038 #ifdef SK_DEBUG
2062 // don't do this check in Chromium -- this is causing 2039 // don't do this check in Chromium -- this is causing
2063 // lots of repeated command buffer flushes when the compositor is 2040 // lots of repeated command buffer flushes when the compositor is
2064 // rendering with Ganesh, which is really slow; even too slow for 2041 // rendering with Ganesh, which is really slow; even too slow for
2065 // Debug mode. 2042 // Debug mode.
(...skipping 23 matching lines...) Expand all
2089 } 2066 }
2090 } 2067 }
2091 if (nullptr == bound || !bound->isEmpty()) { 2068 if (nullptr == bound || !bound->isEmpty()) {
2092 target->flagAsNeedingResolve(bound); 2069 target->flagAsNeedingResolve(bound);
2093 } 2070 }
2094 2071
2095 GrTexture *texture = target->asTexture(); 2072 GrTexture *texture = target->asTexture();
2096 if (texture) { 2073 if (texture) {
2097 texture->texturePriv().dirtyMipMaps(true); 2074 texture->texturePriv().dirtyMipMaps(true);
2098 } 2075 }
2076
2077 if (this->caps()->programmableSampleLocationsSupport()) {
2078 ResetTimestamp timestamp;
2079 bool hasCoCenteredSamples = target->getCachedCoCenteredSamplesState(&tim estamp);
2080 if (timestamp < this->getResetTimestamp() || hasCoCenteredSamples != coC enterSamples) {
2081 // The default state for programmable sample locations is already at pixel center, so we
2082 // don't assign them. This assumes the client does not modify them o utside of Skia.
2083 GL_CALL(FramebufferParameteri(GR_GL_FRAMEBUFFER,
2084 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_ LOCATIONS,
2085 coCenterSamples));
2086 target->setCachedCoCenteredSamplesState(coCenterSamples, this->getRe setTimestamp());
2087 }
2088 }
2099 } 2089 }
2100 2090
2101 GrGLenum gPrimitiveType2GLMode[] = { 2091 GrGLenum gPrimitiveType2GLMode[] = {
2102 GR_GL_TRIANGLES, 2092 GR_GL_TRIANGLES,
2103 GR_GL_TRIANGLE_STRIP, 2093 GR_GL_TRIANGLE_STRIP,
2104 GR_GL_TRIANGLE_FAN, 2094 GR_GL_TRIANGLE_FAN,
2105 GR_GL_POINTS, 2095 GR_GL_POINTS,
2106 GR_GL_LINES, 2096 GR_GL_LINES,
2107 GR_GL_LINE_STRIP 2097 GR_GL_LINE_STRIP
2108 }; 2098 };
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 set_gl_stencil(this->glInterface(), 2280 set_gl_stencil(this->glInterface(),
2291 stencilSettings, 2281 stencilSettings,
2292 GR_GL_FRONT_AND_BACK, 2282 GR_GL_FRONT_AND_BACK,
2293 GrStencilSettings::kFront_Face); 2283 GrStencilSettings::kFront_Face);
2294 } 2284 }
2295 } 2285 }
2296 fHWStencilSettings = stencilSettings; 2286 fHWStencilSettings = stencilSettings;
2297 } 2287 }
2298 } 2288 }
2299 2289
2300 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) { 2290 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
2301 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); 2291 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
2302 2292
2303 if (rt->hasMixedSamples() && stencilEnabled && 2293 if (this->caps()->multisampleDisableSupport()) {
2304 this->glCaps().glslCaps()->programmableSampleLocationsSupport()) {
2305 if (useHWAA) {
2306 this->setColocatedSampleLocations(rt, false);
2307 } else {
2308 this->setColocatedSampleLocations(rt, true);
2309 }
2310 useHWAA = true;
2311 }
2312
2313 if (this->glCaps().multisampleDisableSupport()) {
2314 if (useHWAA) { 2294 if (useHWAA) {
2315 if (kYes_TriState != fMSAAEnabled) { 2295 if (kYes_TriState != fMSAAEnabled) {
2316 GL_CALL(Enable(GR_GL_MULTISAMPLE)); 2296 GL_CALL(Enable(GR_GL_MULTISAMPLE));
2317 fMSAAEnabled = kYes_TriState; 2297 fMSAAEnabled = kYes_TriState;
2318 } 2298 }
2319 } else { 2299 } else {
2320 if (kNo_TriState != fMSAAEnabled) { 2300 if (kNo_TriState != fMSAAEnabled) {
2321 GL_CALL(Disable(GR_GL_MULTISAMPLE)); 2301 GL_CALL(Disable(GR_GL_MULTISAMPLE));
2322 fMSAAEnabled = kNo_TriState; 2302 fMSAAEnabled = kNo_TriState;
2323 } 2303 }
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 3084
3105 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0, dy0)); 3085 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0, dy0));
3106 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0, sx0, sy0)); 3086 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0, sx0, sy0));
3107 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); 3087 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0));
3108 3088
3109 GrXferProcessor::BlendInfo blendInfo; 3089 GrXferProcessor::BlendInfo blendInfo;
3110 blendInfo.reset(); 3090 blendInfo.reset();
3111 this->flushBlend(blendInfo); 3091 this->flushBlend(blendInfo);
3112 this->flushColorWrite(true); 3092 this->flushColorWrite(true);
3113 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); 3093 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
3114 this->flushHWAAState(dstRT, false, false); 3094 this->flushHWAAState(dstRT, false);
3115 this->disableScissor(); 3095 this->disableScissor();
3116 GrStencilSettings stencil; 3096 GrStencilSettings stencil;
3117 stencil.setDisabled(); 3097 stencil.setDisabled();
3118 this->flushStencil(stencil); 3098 this->flushStencil(stencil);
3119 3099
3120 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); 3100 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4));
3121 } 3101 }
3122 3102
3123 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, 3103 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst,
3124 GrSurface* src, 3104 GrSurface* src,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3328 this->setVertexArrayID(gpu, 0); 3308 this->setVertexArrayID(gpu, 0);
3329 } 3309 }
3330 int attrCount = gpu->glCaps().maxVertexAttributes(); 3310 int attrCount = gpu->glCaps().maxVertexAttributes();
3331 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3311 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3332 fDefaultVertexArrayAttribState.resize(attrCount); 3312 fDefaultVertexArrayAttribState.resize(attrCount);
3333 } 3313 }
3334 attribState = &fDefaultVertexArrayAttribState; 3314 attribState = &fDefaultVertexArrayAttribState;
3335 } 3315 }
3336 return attribState; 3316 return attribState;
3337 } 3317 }
OLDNEW
« 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