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 1458 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 == target->usesColocatedSampleLocations()) { |
| 1908 return; |
| 1909 } |
| 1910 |
| 1911 GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), |
| 1912 GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOC
ATIONS, |
| 1913 useColocatedSampleLocations)); |
| 1914 |
| 1915 target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations); |
| 1916 } |
| 1917 |
1902 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 1918 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ |
1903 | 1919 |
1904 SkASSERT(target); | 1920 SkASSERT(target); |
1905 | 1921 |
1906 uint32_t rtID = target->getUniqueID(); | 1922 uint32_t rtID = target->getUniqueID(); |
1907 if (fHWBoundRenderTargetUniqueID != rtID) { | 1923 if (fHWBoundRenderTargetUniqueID != rtID) { |
1908 fStats.incRenderTargetBinds(); | 1924 fStats.incRenderTargetBinds(); |
1909 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1925 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
1910 #ifdef SK_DEBUG | 1926 #ifdef SK_DEBUG |
1911 // don't do this check in Chromium -- this is causing | 1927 // 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(), | 2155 set_gl_stencil(this->glInterface(), |
2140 stencilSettings, | 2156 stencilSettings, |
2141 GR_GL_FRONT_AND_BACK, | 2157 GR_GL_FRONT_AND_BACK, |
2142 GrStencilSettings::kFront_Face); | 2158 GrStencilSettings::kFront_Face); |
2143 } | 2159 } |
2144 } | 2160 } |
2145 fHWStencilSettings = stencilSettings; | 2161 fHWStencilSettings = stencilSettings; |
2146 } | 2162 } |
2147 } | 2163 } |
2148 | 2164 |
2149 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2165 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { |
2150 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2166 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
2151 | 2167 |
| 2168 if (rt->hasMixedSamples() && stencilEnabled && |
| 2169 this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { |
| 2170 if (useHWAA) { |
| 2171 this->setColocatedSampleLocations(rt, false); |
| 2172 } else { |
| 2173 this->setColocatedSampleLocations(rt, true); |
| 2174 } |
| 2175 useHWAA = true; |
| 2176 } |
| 2177 |
2152 if (this->glCaps().multisampleDisableSupport()) { | 2178 if (this->glCaps().multisampleDisableSupport()) { |
2153 if (useHWAA) { | 2179 if (useHWAA) { |
2154 if (kYes_TriState != fMSAAEnabled) { | 2180 if (kYes_TriState != fMSAAEnabled) { |
2155 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2181 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2156 fMSAAEnabled = kYes_TriState; | 2182 fMSAAEnabled = kYes_TriState; |
2157 } | 2183 } |
2158 } else { | 2184 } else { |
2159 if (kNo_TriState != fMSAAEnabled) { | 2185 if (kNo_TriState != fMSAAEnabled) { |
2160 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2186 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2161 fMSAAEnabled = kNo_TriState; | 2187 fMSAAEnabled = kNo_TriState; |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 | 2947 |
2922 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); | 2948 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
2923 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); | 2949 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
2924 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); | 2950 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
2925 | 2951 |
2926 GrXferProcessor::BlendInfo blendInfo; | 2952 GrXferProcessor::BlendInfo blendInfo; |
2927 blendInfo.reset(); | 2953 blendInfo.reset(); |
2928 this->flushBlend(blendInfo); | 2954 this->flushBlend(blendInfo); |
2929 this->flushColorWrite(true); | 2955 this->flushColorWrite(true); |
2930 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 2956 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
2931 this->flushHWAAState(dstRT, false); | 2957 this->flushHWAAState(dstRT, false, false); |
2932 this->disableScissor(); | 2958 this->disableScissor(); |
2933 GrStencilSettings stencil; | 2959 GrStencilSettings stencil; |
2934 stencil.setDisabled(); | 2960 stencil.setDisabled(); |
2935 this->flushStencil(stencil); | 2961 this->flushStencil(stencil); |
2936 | 2962 |
2937 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); | 2963 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); |
2938 } | 2964 } |
2939 | 2965 |
2940 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, | 2966 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, |
2941 GrSurface* src, | 2967 GrSurface* src, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 this->setVertexArrayID(gpu, 0); | 3182 this->setVertexArrayID(gpu, 0); |
3157 } | 3183 } |
3158 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3184 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3159 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3185 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3160 fDefaultVertexArrayAttribState.resize(attrCount); | 3186 fDefaultVertexArrayAttribState.resize(attrCount); |
3161 } | 3187 } |
3162 attribState = &fDefaultVertexArrayAttribState; | 3188 attribState = &fDefaultVertexArrayAttribState; |
3163 } | 3189 } |
3164 return attribState; | 3190 return attribState; |
3165 } | 3191 } |
OLD | NEW |