void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) { fMSFBOType = kNone_MSFBOType; if (kDesktop_GrGLBinding != ctxInfo.binding()) { if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { // chrome's extension is equivalent to the EXT msaa // and fbo_blit extensions. fMSFBOType = kDesktopEXT_MSFBOType; } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { fMSFBOType = kAppleES_MSFBOType; } } else { if ((ctxInfo.version() >= GR_GL_VER(3,0)) || ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { fMSFBOType = GrGLCaps::kDesktopARB_MSFBOType; } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { fMSFBOType = GrGLCaps::kDesktopEXT_MSFBOType; } // TODO: We could populate fMSAACoverageModes using GetInternalformativ // on GL 4.2+. It's format-specific, though. See also // http://code.google.com/p/skia/issues/detail?id=470 about using actual // rather than requested sample counts in cache key. if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) { fCoverageAAType = kNVDesktop_CoverageAAType; GrGLint count; GR_GL_GetIntegerv(ctxInfo.interface(), GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES, &count); fMSAACoverageModes.setCount(count); GR_GL_GetIntegerv(ctxInfo.interface(), GR_GL_MULTISAMPLE_COVERAGE_MODES, (int*)&fMSAACoverageModes[0]); // The NV driver seems to return the modes already sorted but the // spec doesn't require this. So we sort. SkQSortCompareProc compareProc = reinterpret_cast<SkQSortCompareProc>(&coverage_mode_compare); SkQSort(&fMSAACoverageModes[0], count, sizeof(MSAACoverageMode), compareProc); } } if (kNone_MSFBOType != fMSFBOType) { GR_GL_GetIntegerv(ctxInfo.interface(), GR_GL_MAX_SAMPLES, &fMaxSampleCount); } }
void GrGLCaps::init(const GrGLContextInfo& ctxInfo) { this->reset(); if (!ctxInfo.isInitialized()) { return; } const GrGLInterface* gli = ctxInfo.interface(); GrGLBinding binding = ctxInfo.binding(); GrGLVersion version = ctxInfo.version(); if (kES2_GrGLBinding == binding) { GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, &fMaxFragmentUniformVectors); } else { GrAssert(kDesktop_GrGLBinding == binding); GrGLint max; GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); fMaxFragmentUniformVectors = max / 4; } if (kDesktop_GrGLBinding == binding) { fRGBA8RenderbufferSupport = true; } else { fRGBA8RenderbufferSupport = ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || ctxInfo.hasExtension("GL_ARM_rgba8"); } if (kDesktop_GrGLBinding == binding) { fBGRAFormatSupport = version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); } else { bool hasBGRAExt = false; if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { fBGRAFormatSupport = true; } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { fBGRAFormatSupport = true; fBGRAIsInternalFormat = true; } GrAssert(fBGRAFormatSupport || kSkia8888_PM_GrPixelConfig != kBGRA_8888_PM_GrPixelConfig); } if (kDesktop_GrGLBinding == binding) { fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_swizzle"); } else { fTextureSwizzleSupport = false; } if (kDesktop_GrGLBinding == binding) { fUnpackRowLengthSupport = true; fUnpackFlipYSupport = false; fPackRowLengthSupport = true; fPackFlipYSupport = false; } else { fUnpackRowLengthSupport =ctxInfo.hasExtension("GL_EXT_unpack_subimage"); fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); // no extension for pack row length fPackRowLengthSupport = false; fPackFlipYSupport = ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order"); } fTextureUsageSupport = (kES2_GrGLBinding == binding) && ctxInfo.hasExtension("GL_ANGLE_texture_usage"); // Tex storage is in desktop 4.2 and can be an extension to desktop or ES. fTexStorageSupport = (kDesktop_GrGLBinding == binding && version >= GR_GL_VER(4,2)) || ctxInfo.hasExtension("GL_ARB_texture_storage") || ctxInfo.hasExtension("GL_EXT_texture_storage"); // ARB_texture_rg is part of OpenGL 3.0 if (kDesktop_GrGLBinding == binding) { fTextureRedSupport = version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_ARB_texture_rg"); } else { fTextureRedSupport = ctxInfo.hasExtension("GL_ARB_texture_rg"); } this->initFSAASupport(ctxInfo); this->initStencilFormats(ctxInfo); }
void GrGLCaps::init(const GrGLContextInfo& ctxInfo) { this->reset(); if (!ctxInfo.isInitialized()) { return; } const GrGLInterface* gli = ctxInfo.interface(); GrGLBinding binding = ctxInfo.binding(); GrGLVersion version = ctxInfo.version(); if (kES2_GrGLBinding == binding) { GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, &fMaxFragmentUniformVectors); } else { GrAssert(kDesktop_GrGLBinding == binding); GrGLint max; GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); fMaxFragmentUniformVectors = max / 4; } GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); if (kDesktop_GrGLBinding == binding) { fRGBA8RenderbufferSupport = true; } else { fRGBA8RenderbufferSupport = ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || ctxInfo.hasExtension("GL_ARM_rgba8"); } if (kDesktop_GrGLBinding == binding) { fBGRAFormatSupport = version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); } else { if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { fBGRAFormatSupport = true; } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { fBGRAFormatSupport = true; fBGRAIsInternalFormat = true; } GrAssert(fBGRAFormatSupport || kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); } if (kDesktop_GrGLBinding == binding) { fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_swizzle"); } else { fTextureSwizzleSupport = false; } if (kDesktop_GrGLBinding == binding) { fUnpackRowLengthSupport = true; fUnpackFlipYSupport = false; fPackRowLengthSupport = true; fPackFlipYSupport = false; } else { fUnpackRowLengthSupport =ctxInfo.hasExtension("GL_EXT_unpack_subimage"); fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); // no extension for pack row length fPackRowLengthSupport = false; fPackFlipYSupport = ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order"); } fTextureUsageSupport = (kES2_GrGLBinding == binding) && ctxInfo.hasExtension("GL_ANGLE_texture_usage"); // Tex storage is in desktop 4.2 and can be an extension to desktop or ES. fTexStorageSupport = (kDesktop_GrGLBinding == binding && version >= GR_GL_VER(4,2)) || ctxInfo.hasExtension("GL_ARB_texture_storage") || ctxInfo.hasExtension("GL_EXT_texture_storage"); // ARB_texture_rg is part of OpenGL 3.0 if (kDesktop_GrGLBinding == binding) { fTextureRedSupport = version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_ARB_texture_rg"); } else { fTextureRedSupport = ctxInfo.hasExtension("GL_EXT_texture_rg"); } fImagingSupport = kDesktop_GrGLBinding == binding && ctxInfo.hasExtension("GL_ARB_imaging"); // ES 2 only guarantees RGBA/uchar + one other format/type combo for // ReadPixels. The other format has to checked at run-time since it // can change based on which render target is bound fTwoFormatLimit = kES2_GrGLBinding == binding; // Known issue on at least some Intel platforms: // http://code.google.com/p/skia/issues/detail?id=946 if (kIntel_GrGLVendor != ctxInfo.vendor()) { fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration || ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions"); } this->initFSAASupport(ctxInfo); this->initStencilFormats(ctxInfo); }