OLD | NEW |
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 Loading... |
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()); | 1495 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc
il().isDisabled()); |
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, pipeline.hasCoCenteredSamples()); | 1499 this->flushRenderTarget(glRT, nullptr); |
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 Loading... |
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::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound, | 2029 void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedS
ampleLocations) { |
2030 bool coCenterSamples) { | 2030 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget
()); |
| 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 |
2031 SkASSERT(target); | 2055 SkASSERT(target); |
2032 SkASSERT(!coCenterSamples || this->caps()->programmableSampleLocationsSuppor
t()); | |
2033 | 2056 |
2034 uint32_t rtID = target->getUniqueID(); | 2057 uint32_t rtID = target->getUniqueID(); |
2035 if (fHWBoundRenderTargetUniqueID != rtID) { | 2058 if (fHWBoundRenderTargetUniqueID != rtID) { |
2036 fStats.incRenderTargetBinds(); | 2059 fStats.incRenderTargetBinds(); |
2037 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2060 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
2038 #ifdef SK_DEBUG | 2061 #ifdef SK_DEBUG |
2039 // don't do this check in Chromium -- this is causing | 2062 // don't do this check in Chromium -- this is causing |
2040 // lots of repeated command buffer flushes when the compositor is | 2063 // lots of repeated command buffer flushes when the compositor is |
2041 // rendering with Ganesh, which is really slow; even too slow for | 2064 // rendering with Ganesh, which is really slow; even too slow for |
2042 // Debug mode. | 2065 // Debug mode. |
(...skipping 23 matching lines...) Expand all Loading... |
2066 } | 2089 } |
2067 } | 2090 } |
2068 if (nullptr == bound || !bound->isEmpty()) { | 2091 if (nullptr == bound || !bound->isEmpty()) { |
2069 target->flagAsNeedingResolve(bound); | 2092 target->flagAsNeedingResolve(bound); |
2070 } | 2093 } |
2071 | 2094 |
2072 GrTexture *texture = target->asTexture(); | 2095 GrTexture *texture = target->asTexture(); |
2073 if (texture) { | 2096 if (texture) { |
2074 texture->texturePriv().dirtyMipMaps(true); | 2097 texture->texturePriv().dirtyMipMaps(true); |
2075 } | 2098 } |
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 } | |
2089 } | 2099 } |
2090 | 2100 |
2091 GrGLenum gPrimitiveType2GLMode[] = { | 2101 GrGLenum gPrimitiveType2GLMode[] = { |
2092 GR_GL_TRIANGLES, | 2102 GR_GL_TRIANGLES, |
2093 GR_GL_TRIANGLE_STRIP, | 2103 GR_GL_TRIANGLE_STRIP, |
2094 GR_GL_TRIANGLE_FAN, | 2104 GR_GL_TRIANGLE_FAN, |
2095 GR_GL_POINTS, | 2105 GR_GL_POINTS, |
2096 GR_GL_LINES, | 2106 GR_GL_LINES, |
2097 GR_GL_LINE_STRIP | 2107 GR_GL_LINE_STRIP |
2098 }; | 2108 }; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 set_gl_stencil(this->glInterface(), | 2290 set_gl_stencil(this->glInterface(), |
2281 stencilSettings, | 2291 stencilSettings, |
2282 GR_GL_FRONT_AND_BACK, | 2292 GR_GL_FRONT_AND_BACK, |
2283 GrStencilSettings::kFront_Face); | 2293 GrStencilSettings::kFront_Face); |
2284 } | 2294 } |
2285 } | 2295 } |
2286 fHWStencilSettings = stencilSettings; | 2296 fHWStencilSettings = stencilSettings; |
2287 } | 2297 } |
2288 } | 2298 } |
2289 | 2299 |
2290 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2300 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { |
2291 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2301 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
2292 | 2302 |
2293 if (this->caps()->multisampleDisableSupport()) { | 2303 if (rt->hasMixedSamples() && stencilEnabled && |
| 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()) { |
2294 if (useHWAA) { | 2314 if (useHWAA) { |
2295 if (kYes_TriState != fMSAAEnabled) { | 2315 if (kYes_TriState != fMSAAEnabled) { |
2296 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2316 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2297 fMSAAEnabled = kYes_TriState; | 2317 fMSAAEnabled = kYes_TriState; |
2298 } | 2318 } |
2299 } else { | 2319 } else { |
2300 if (kNo_TriState != fMSAAEnabled) { | 2320 if (kNo_TriState != fMSAAEnabled) { |
2301 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2321 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2302 fMSAAEnabled = kNo_TriState; | 2322 fMSAAEnabled = kNo_TriState; |
2303 } | 2323 } |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 | 3104 |
3085 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); | 3105 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
3086 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); | 3106 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
3087 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 3107 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
3088 | 3108 |
3089 GrXferProcessor::BlendInfo blendInfo; | 3109 GrXferProcessor::BlendInfo blendInfo; |
3090 blendInfo.reset(); | 3110 blendInfo.reset(); |
3091 this->flushBlend(blendInfo); | 3111 this->flushBlend(blendInfo); |
3092 this->flushColorWrite(true); | 3112 this->flushColorWrite(true); |
3093 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 3113 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
3094 this->flushHWAAState(dstRT, false); | 3114 this->flushHWAAState(dstRT, false, false); |
3095 this->disableScissor(); | 3115 this->disableScissor(); |
3096 GrStencilSettings stencil; | 3116 GrStencilSettings stencil; |
3097 stencil.setDisabled(); | 3117 stencil.setDisabled(); |
3098 this->flushStencil(stencil); | 3118 this->flushStencil(stencil); |
3099 | 3119 |
3100 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 3120 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
3101 } | 3121 } |
3102 | 3122 |
3103 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 3123 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
3104 GrSurface* src, | 3124 GrSurface* src, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3308 this->setVertexArrayID(gpu, 0); | 3328 this->setVertexArrayID(gpu, 0); |
3309 } | 3329 } |
3310 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3330 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3311 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3331 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3312 fDefaultVertexArrayAttribState.resize(attrCount); | 3332 fDefaultVertexArrayAttribState.resize(attrCount); |
3313 } | 3333 } |
3314 attribState = &fDefaultVertexArrayAttribState; | 3334 attribState = &fDefaultVertexArrayAttribState; |
3315 } | 3335 } |
3316 return attribState; | 3336 return attribState; |
3317 } | 3337 } |
OLD | NEW |