Chromium Code Reviews| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 fCopyProgram.fProgram = 0; | 274 fCopyProgram.fProgram = 0; |
| 275 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 275 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 276 this->glPathRendering()->abandonGpuResources(); | 276 this->glPathRendering()->abandonGpuResources(); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 /////////////////////////////////////////////////////////////////////////////// | 280 /////////////////////////////////////////////////////////////////////////////// |
| 281 | 281 |
| 282 void GrGLGpu::onResetContext(uint32_t resetBits) { | 282 void GrGLGpu::onResetContext(uint32_t resetBits) { |
| 283 // we don't use the zb at all | 283 // we don't use the zb at all |
| 284 if (resetBits & kMisc_GrGLBackendState) { | 284 if (resetBits & kMisc_GrGLBackendState) { |
|
Kimmo Kinnunen
2015/09/29 12:45:24
The sample locations are probably part of GL state
Kimmo Kinnunen
2015/09/29 12:53:37
Ah, never mind. The sample locations state is per
| |
| 285 GL_CALL(Disable(GR_GL_DEPTH_TEST)); | 285 GL_CALL(Disable(GR_GL_DEPTH_TEST)); |
| 286 GL_CALL(DepthMask(GR_GL_FALSE)); | 286 GL_CALL(DepthMask(GR_GL_FALSE)); |
| 287 | 287 |
| 288 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 288 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
| 289 | 289 |
| 290 if (kGL_GrGLStandard == this->glStandard()) { | 290 if (kGL_GrGLStandard == this->glStandard()) { |
| 291 // Desktop-only state that we never change | 291 // Desktop-only state that we never change |
| 292 if (!this->glCaps().isCoreProfile()) { | 292 if (!this->glCaps().isCoreProfile()) { |
| 293 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); | 293 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); |
| 294 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); | 294 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1469 | 1469 |
| 1470 int numTextureAccesses = textureAccesses.count(); | 1470 int numTextureAccesses = textureAccesses.count(); |
| 1471 for (int i = 0; i < numTextureAccesses; i++) { | 1471 for (int i = 0; i < numTextureAccesses; i++) { |
| 1472 this->bindTexture(i, textureAccesses[i]->getParams(), | 1472 this->bindTexture(i, textureAccesses[i]->getParams(), |
| 1473 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re())); | 1473 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re())); |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); | 1476 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); |
| 1477 this->flushStencil(pipeline.getStencil()); | 1477 this->flushStencil(pipeline.getStencil()); |
| 1478 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); | 1478 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); |
| 1479 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); | 1479 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled()); |
| 1480 | 1480 |
| 1481 // This must come after textures are flushed because a texture may need | 1481 // This must come after textures are flushed because a texture may need |
| 1482 // to be msaa-resolved (which will modify bound FBO state). | 1482 // to be msaa-resolved (which will modify bound FBO state). |
| 1483 this->flushRenderTarget(glRT, nullptr); | 1483 this->flushRenderTarget(glRT, nullptr); |
| 1484 | 1484 |
| 1485 return true; | 1485 return true; |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1488 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| 1489 const GrNonInstancedVertices& vertices, | 1489 const GrNonInstancedVertices& vertices, |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1892 if (!flipY) { | 1892 if (!flipY) { |
| 1893 dst += rowBytes; | 1893 dst += rowBytes; |
| 1894 } else { | 1894 } else { |
| 1895 dst -= rowBytes; | 1895 dst -= rowBytes; |
| 1896 } | 1896 } |
| 1897 } | 1897 } |
| 1898 } | 1898 } |
| 1899 return true; | 1899 return true; |
| 1900 } | 1900 } |
| 1901 | 1901 |
| 1902 void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedS ampleLocations) { | |
| 1903 GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget ()); | |
| 1904 SkASSERT(0 != target->renderFBOID()); | |
| 1905 | |
| 1906 if (!rt->isStencilBufferMultisampled() || | |
| 1907 useColocatedSampleLocations == rt->renderTargetPriv().usesColocatedSampl eLocations()) { | |
| 1908 return; | |
| 1909 } | |
| 1910 | |
| 1911 GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), | |
| 1912 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOC ATIONS, useColocatedSampleLocations)); | |
|
bsalomon
2015/09/29 17:41:57
nit: wrap
vbuzinov
2015/09/30 06:08:29
Done.
| |
| 1913 | |
| 1914 rt->renderTargetPriv().flagAsUsingColocatedSampleLocations(useColocatedSampl eLocations); | |
| 1915 } | |
| 1916 | |
| 1902 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { | 1917 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { |
| 1903 | 1918 |
| 1904 SkASSERT(target); | 1919 SkASSERT(target); |
| 1905 | 1920 |
| 1906 uint32_t rtID = target->getUniqueID(); | 1921 uint32_t rtID = target->getUniqueID(); |
| 1907 if (fHWBoundRenderTargetUniqueID != rtID) { | 1922 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 1908 fStats.incRenderTargetBinds(); | 1923 fStats.incRenderTargetBinds(); |
| 1909 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1924 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 1910 #ifdef SK_DEBUG | 1925 #ifdef SK_DEBUG |
| 1911 // don't do this check in Chromium -- this is causing | 1926 // don't do this check in Chromium -- this is causing |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2139 set_gl_stencil(this->glInterface(), | 2154 set_gl_stencil(this->glInterface(), |
| 2140 stencilSettings, | 2155 stencilSettings, |
| 2141 GR_GL_FRONT_AND_BACK, | 2156 GR_GL_FRONT_AND_BACK, |
| 2142 GrStencilSettings::kFront_Face); | 2157 GrStencilSettings::kFront_Face); |
| 2143 } | 2158 } |
| 2144 } | 2159 } |
| 2145 fHWStencilSettings = stencilSettings; | 2160 fHWStencilSettings = stencilSettings; |
| 2146 } | 2161 } |
| 2147 } | 2162 } |
| 2148 | 2163 |
| 2149 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2164 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) { |
| 2150 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2165 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
| 2151 | 2166 |
| 2167 if (rt->hasMixedSamples() && stencilEnabled && | |
| 2168 this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { | |
| 2169 if (useHWAA) { | |
| 2170 setColocatedSampleLocations(rt, false); | |
|
bsalomon
2015/09/29 17:41:57
this->
vbuzinov
2015/09/30 06:08:29
Done.
| |
| 2171 } else { | |
| 2172 setColocatedSampleLocations(rt, true); | |
|
bsalomon
2015/09/29 17:41:57
this->
vbuzinov
2015/09/30 06:08:29
Done.
| |
| 2173 } | |
| 2174 useHWAA = true; | |
| 2175 } | |
| 2176 | |
| 2152 if (this->glCaps().multisampleDisableSupport()) { | 2177 if (this->glCaps().multisampleDisableSupport()) { |
| 2153 if (useHWAA) { | 2178 if (useHWAA) { |
| 2154 if (kYes_TriState != fMSAAEnabled) { | 2179 if (kYes_TriState != fMSAAEnabled) { |
| 2155 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2180 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2156 fMSAAEnabled = kYes_TriState; | 2181 fMSAAEnabled = kYes_TriState; |
| 2157 } | 2182 } |
| 2158 } else { | 2183 } else { |
| 2159 if (kNo_TriState != fMSAAEnabled) { | 2184 if (kNo_TriState != fMSAAEnabled) { |
| 2160 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2185 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2161 fMSAAEnabled = kNo_TriState; | 2186 fMSAAEnabled = kNo_TriState; |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2909 | 2934 |
| 2910 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0, dy0)); | 2935 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0, dy0)); |
| 2911 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0, sx0, sy0)); | 2936 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0, sx0, sy0)); |
| 2912 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 2937 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
| 2913 | 2938 |
| 2914 GrXferProcessor::BlendInfo blendInfo; | 2939 GrXferProcessor::BlendInfo blendInfo; |
| 2915 blendInfo.reset(); | 2940 blendInfo.reset(); |
| 2916 this->flushBlend(blendInfo); | 2941 this->flushBlend(blendInfo); |
| 2917 this->flushColorWrite(true); | 2942 this->flushColorWrite(true); |
| 2918 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 2943 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 2919 this->flushHWAAState(dstRT, false); | 2944 this->flushHWAAState(dstRT, false, false); |
| 2920 this->disableScissor(); | 2945 this->disableScissor(); |
| 2921 GrStencilSettings stencil; | 2946 GrStencilSettings stencil; |
| 2922 stencil.setDisabled(); | 2947 stencil.setDisabled(); |
| 2923 this->flushStencil(stencil); | 2948 this->flushStencil(stencil); |
| 2924 | 2949 |
| 2925 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 2950 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
| 2926 } | 2951 } |
| 2927 | 2952 |
| 2928 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 2953 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
| 2929 GrSurface* src, | 2954 GrSurface* src, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3144 this->setVertexArrayID(gpu, 0); | 3169 this->setVertexArrayID(gpu, 0); |
| 3145 } | 3170 } |
| 3146 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3171 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3147 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3172 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3148 fDefaultVertexArrayAttribState.resize(attrCount); | 3173 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3149 } | 3174 } |
| 3150 attribState = &fDefaultVertexArrayAttribState; | 3175 attribState = &fDefaultVertexArrayAttribState; |
| 3151 } | 3176 } |
| 3152 return attribState; | 3177 return attribState; |
| 3153 } | 3178 } |
| OLD | NEW |