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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Our render targets are always created with textures as the color | 271 // Our render targets are always created with textures as the color |
272 // attachment, hence this min: | 272 // attachment, hence this min: |
273 caps->fMaxRenderTargetSize = GrMin(caps->fMaxTextureSize, caps->fMaxRenderTa
rgetSize); | 273 caps->fMaxRenderTargetSize = GrMin(caps->fMaxTextureSize, caps->fMaxRenderTa
rgetSize); |
274 | 274 |
275 caps->fFSAASupport = GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()
; | 275 caps->fFSAASupport = GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()
; |
276 caps->fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && | 276 caps->fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && |
277 this->hasExtension("GL_NV_path_rendering"); | 277 this->hasExtension("GL_NV_path_rendering"); |
278 | 278 |
279 // Enable supported shader-related caps | 279 // Enable supported shader-related caps |
280 if (kDesktop_GrGLBinding == this->glBinding()) { | 280 if (kDesktop_GrGLBinding == this->glBinding()) { |
281 caps->fDualSourceBlendingSupport = | 281 caps->fDualSourceBlendingSupport = this->glVersion() >= GR_GL_VER(3,3) |
| |
282 this->glVersion() >= GR_GL_VER(3,3) || | 282 this->hasExtension("GL_ARB_blend_func
_extended"); |
283 this->hasExtension("GL_ARB_blend_func_extended"); | |
284 caps->fShaderDerivativeSupport = true; | 283 caps->fShaderDerivativeSupport = true; |
285 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS | 284 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS |
286 caps->fGeometryShaderSupport = | 285 caps->fGeometryShaderSupport = this->glVersion() >= GR_GL_VER(3,2) && |
287 this->glVersion() >= GR_GL_VER(3,2) && | 286 this->glslGeneration() >= k150_GrGLSLGene
ration; |
288 this->glslGeneration() >= k150_GrGLSLGeneration; | |
289 } else { | 287 } else { |
290 caps->fShaderDerivativeSupport = | 288 caps->fShaderDerivativeSupport = |
291 this->hasExtension("GL_OES_standard_derivatives"); | 289 this->hasExtension("GL_OES_standard_derivatives"); |
292 } | 290 } |
| 291 |
| 292 if (GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()) { |
| 293 GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES, &caps->fMaxSam
pleCount); |
| 294 } |
293 } | 295 } |
294 | 296 |
295 void GrGpuGL::fillInConfigRenderableTable() { | 297 void GrGpuGL::fillInConfigRenderableTable() { |
296 | 298 |
297 // OpenGL < 3.0 | 299 // OpenGL < 3.0 |
298 // no support for render targets unless the GL_ARB_framebuffer_object | 300 // no support for render targets unless the GL_ARB_framebuffer_object |
299 // extension is supported (in which case we get ALPHA, RED, RG, RGB, | 301 // extension is supported (in which case we get ALPHA, RED, RG, RGB, |
300 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we | 302 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we |
301 // probably don't get R8 in this case. | 303 // probably don't get R8 in this case. |
302 | 304 |
303 // OpenGL 3.0 | 305 // OpenGL 3.0 |
304 // base color renderable: ALPHA, RED, RG, RGB, and RGBA | 306 // base color renderable: ALPHA, RED, RG, RGB, and RGBA |
305 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 | 307 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 |
306 | 308 |
307 // >= OpenGL 3.1 | 309 // >= OpenGL 3.1 |
308 // base color renderable: RED, RG, RGB, and RGBA | 310 // base color renderable: RED, RG, RGB, and RGBA |
309 // sized derivatives: R8, RGBA4, RGBA8 | 311 // sized derivatives: R8, RGBA4, RGBA8 |
310 // if the GL_ARB_compatibility extension is supported then we get back | 312 // if the GL_ARB_compatibility extension is supported then we get back |
311 // support for GL_ALPHA and ALPHA8 | 313 // support for GL_ALPHA and ALPHA8 |
312 | 314 |
313 // GL_EXT_bgra adds BGRA render targets to any version | 315 // GL_EXT_bgra adds BGRA render targets to any version |
314 | 316 |
315 // ES 2.0 | 317 // ES 2.0 |
316 // color renderable: RGBA4, RGB5_A1, RGB565 | 318 // color renderable: RGBA4, RGB5_A1, RGB565 |
317 // GL_EXT_texture_rg adds support for R8 as a color render target | 319 // GL_EXT_texture_rg adds support for R8 as a color render target |
318 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 | 320 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 |
319 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 | 321 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 a
dded BGRA support |
320 // added BGRA support | |
321 | 322 |
322 if (kDesktop_GrGLBinding == this->glBinding()) { | 323 if (kDesktop_GrGLBinding == this->glBinding()) { |
323 // Post 3.0 we will get R8 | 324 // Post 3.0 we will get R8 |
324 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) | 325 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) |
325 if (this->glVersion() >= GR_GL_VER(3,0) || | 326 if (this->glVersion() >= GR_GL_VER(3,0) || |
326 this->hasExtension("GL_ARB_framebuffer_object")) { | 327 this->hasExtension("GL_ARB_framebuffer_object")) { |
327 fConfigRenderSupport[kAlpha_8_GrPixelConfig] = true; | 328 fConfigRenderSupport[kAlpha_8_GrPixelConfig] = true; |
328 } | 329 } |
329 } else { | 330 } else { |
330 // On ES we can only hope for R8 | 331 // On ES we can only hope for R8 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 ctx.info().caps().getMSAACoverageMode(sampleCount); | 843 ctx.info().caps().getMSAACoverageMode(sampleCount); |
843 GL_ALLOC_CALL(ctx.interface(), | 844 GL_ALLOC_CALL(ctx.interface(), |
844 RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER, | 845 RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER, |
845 mode.fCoverageSampleCnt, | 846 mode.fCoverageSampleCnt, |
846 mode.fColorSampleCnt, | 847 mode.fColorSampleCnt, |
847 format, | 848 format, |
848 width, height)); | 849 width, height)); |
849 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); | 850 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); |
850 } | 851 } |
851 if (!created) { | 852 if (!created) { |
852 // glRBMS will fail if requested samples is > max samples. | |
853 sampleCount = GrMin(sampleCount, ctx.info().caps().maxSampleCount()); | |
854 GL_ALLOC_CALL(ctx.interface(), | 853 GL_ALLOC_CALL(ctx.interface(), |
855 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 854 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
856 sampleCount, | 855 sampleCount, |
857 format, | 856 format, |
858 width, height)); | 857 width, height)); |
859 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); | 858 created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); |
860 } | 859 } |
861 return created; | 860 return created; |
862 } | 861 } |
863 } | 862 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 | 968 |
970 GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, | 969 GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, |
971 const void* srcData, | 970 const void* srcData, |
972 size_t rowBytes) { | 971 size_t rowBytes) { |
973 | 972 |
974 GrGLTexture::Desc glTexDesc; | 973 GrGLTexture::Desc glTexDesc; |
975 GrGLRenderTarget::Desc glRTDesc; | 974 GrGLRenderTarget::Desc glRTDesc; |
976 | 975 |
977 // Attempt to catch un- or wrongly initialized sample counts; | 976 // Attempt to catch un- or wrongly initialized sample counts; |
978 GrAssert(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 977 GrAssert(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
| 978 // We fail if the MSAA was requested and is not available. |
| 979 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC
nt) { |
| 980 //GrPrintf("MSAA RT requested but not supported on this platform."); |
| 981 return return_null_texture(); |
| 982 } |
| 983 // If the sample count exceeds the max then we clamp it. |
| 984 glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->getCaps().maxSampleCount
()); |
979 | 985 |
980 glTexDesc.fFlags = desc.fFlags; | 986 glTexDesc.fFlags = desc.fFlags; |
981 glTexDesc.fWidth = desc.fWidth; | 987 glTexDesc.fWidth = desc.fWidth; |
982 glTexDesc.fHeight = desc.fHeight; | 988 glTexDesc.fHeight = desc.fHeight; |
983 glTexDesc.fConfig = desc.fConfig; | 989 glTexDesc.fConfig = desc.fConfig; |
984 glTexDesc.fSampleCnt = desc.fSampleCnt; | |
985 glTexDesc.fIsWrapped = false; | 990 glTexDesc.fIsWrapped = false; |
986 | 991 |
987 glRTDesc.fMSColorRenderbufferID = 0; | 992 glRTDesc.fMSColorRenderbufferID = 0; |
988 glRTDesc.fRTFBOID = 0; | 993 glRTDesc.fRTFBOID = 0; |
989 glRTDesc.fTexFBOID = 0; | 994 glRTDesc.fTexFBOID = 0; |
990 glRTDesc.fIsWrapped = false; | 995 glRTDesc.fIsWrapped = false; |
991 glRTDesc.fConfig = glTexDesc.fConfig; | 996 glRTDesc.fConfig = glTexDesc.fConfig; |
992 | 997 |
993 bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit); | 998 bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit); |
994 | 999 |
995 const Caps& caps = this->getCaps(); | 1000 const Caps& caps = this->getCaps(); |
996 | 1001 |
997 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 1002 glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
998 glRTDesc.fOrigin = glTexDesc.fOrigin; | 1003 glRTDesc.fOrigin = glTexDesc.fOrigin; |
999 | 1004 |
1000 glRTDesc.fSampleCnt = desc.fSampleCnt; | 1005 glRTDesc.fSampleCnt = glTexDesc.fSampleCnt; |
1001 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && | 1006 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && |
1002 desc.fSampleCnt) { | 1007 desc.fSampleCnt) { |
1003 //GrPrintf("MSAA RT requested but not supported on this platform."); | 1008 //GrPrintf("MSAA RT requested but not supported on this platform."); |
1004 return return_null_texture(); | 1009 return return_null_texture(); |
1005 } | 1010 } |
1006 | 1011 |
1007 if (renderTarget) { | 1012 if (renderTarget) { |
1008 if (glTexDesc.fWidth > caps.maxRenderTargetSize() || | 1013 if (glTexDesc.fWidth > caps.maxRenderTargetSize() || |
1009 glTexDesc.fHeight > caps.maxRenderTargetSize()) { | 1014 glTexDesc.fHeight > caps.maxRenderTargetSize()) { |
1010 return return_null_texture(); | 1015 return return_null_texture(); |
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 this->setVertexArrayID(gpu, 0); | 2333 this->setVertexArrayID(gpu, 0); |
2329 } | 2334 } |
2330 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2335 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2331 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2336 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2332 fDefaultVertexArrayAttribState.resize(attrCount); | 2337 fDefaultVertexArrayAttribState.resize(attrCount); |
2333 } | 2338 } |
2334 attribState = &fDefaultVertexArrayAttribState; | 2339 attribState = &fDefaultVertexArrayAttribState; |
2335 } | 2340 } |
2336 return attribState; | 2341 return attribState; |
2337 } | 2342 } |
OLD | NEW |