本文整理汇总了C++中GrGLContextInfo类的典型用法代码示例。如果您正苦于以下问题:C++ GrGLContextInfo类的具体用法?C++ GrGLContextInfo怎么用?C++ GrGLContextInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrGLContextInfo类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initFSAASupport
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
fMSFBOType = kNone_MSFBOType;
if (kGL_GrGLStandard != ctxInfo.standard()) {
// We prefer the EXT/IMG extension over ES3 MSAA because we've observed
// ES3 driver bugs on at least one device with a tiled GPU (N10).
if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
} else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
} else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
} else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
// chrome's extension is equivalent to the EXT msaa
// and fbo_blit extensions.
fMSFBOType = kDesktop_EXT_MSFBOType;
} else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
fMSFBOType = kES_Apple_MSFBOType;
}
} else {
if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
} else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
}
}
}
示例2: initShaderPrecisionTable
void GrGLSLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
const GrGLInterface* intf) {
if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4, 1) ||
ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
for (int s = 0; s < kGrShaderTypeCount; ++s) {
if (kGeometry_GrShaderType != s) {
GrShaderType shaderType = static_cast<GrShaderType>(s);
GrGLenum glShader = shader_type_to_gl_shader(shaderType);
PrecisionInfo* first = NULL;
fShaderPrecisionVaries = false;
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
GrSLPrecision precision = static_cast<GrSLPrecision>(p);
GrGLenum glPrecision = precision_to_gl_float_type(precision);
GrGLint range[2];
GrGLint bits;
GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
if (bits) {
fFloatPrecisions[s][p].fLogRangeLow = range[0];
fFloatPrecisions[s][p].fLogRangeHigh = range[1];
fFloatPrecisions[s][p].fBits = bits;
if (!first) {
first = &fFloatPrecisions[s][p];
}
else if (!fShaderPrecisionVaries) {
fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
}
}
}
}
}
}
else {
// We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
fShaderPrecisionVaries = false;
for (int s = 0; s < kGrShaderTypeCount; ++s) {
if (kGeometry_GrShaderType != s) {
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
fFloatPrecisions[s][p].fLogRangeLow = 127;
fFloatPrecisions[s][p].fLogRangeHigh = 127;
fFloatPrecisions[s][p].fBits = 23;
}
}
}
}
// GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
// the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
// highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
// are recommended against.
if (fGeometryShaderSupport) {
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
}
}
}
示例3: initFSAASupport
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
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.hasExtension("GL_IMG_multisampled_render_to_texture")) {
fMSFBOType = kImaginationES_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(gli,
GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
&count);
fMSAACoverageModes.setCount(count);
GR_GL_GetIntegerv(gli,
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.
qsort(&fMSAACoverageModes[0],
count,
sizeof(MSAACoverageMode),
SkCastForQSort(coverage_mode_compare));
}
}
}
示例4: initStencilFormats
void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
// Build up list of legal stencil formats (though perhaps not supported on
// the particular gpu/driver) from most preferred to least.
// these consts are in order of most preferred to least preferred
// we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
static const StencilFormat
// internal Format stencil bits total bits packed?
gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
// gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
if (kGL_GrGLStandard == ctxInfo.standard()) {
bool supportsPackedDS =
ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
ctxInfo.hasExtension("GL_ARB_framebuffer_object");
// S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
// require FBO support we can expect these are legal formats and don't
// check. These also all support the unsized GL_STENCIL_INDEX.
fStencilFormats.push_back() = gS8;
fStencilFormats.push_back() = gS16;
if (supportsPackedDS) {
fStencilFormats.push_back() = gD24S8;
}
fStencilFormats.push_back() = gS4;
if (supportsPackedDS) {
fStencilFormats.push_back() = gDS;
}
} else {
// ES2 has STENCIL_INDEX8 without extensions but requires extensions
// for other formats.
// ES doesn't support using the unsized format.
fStencilFormats.push_back() = gS8;
//fStencilFormats.push_back() = gS16;
if (ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
fStencilFormats.push_back() = gD24S8;
}
if (ctxInfo.hasExtension("GL_OES_stencil4")) {
fStencilFormats.push_back() = gS4;
}
}
SkASSERT(0 == fStencilVerifiedColorConfigs.count());
fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
}
示例5: initFSAASupport
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;
}
}
}
示例6: init
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);
}
示例7: init
bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
this->reset();
if (!ctxInfo.isInitialized()) {
return false;
}
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
/**************************************************************************
* Caps specific to GrGLCaps
**************************************************************************/
if (kGLES_GrGLStandard == standard) {
GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
&fMaxFragmentUniformVectors);
} else {
SkASSERT(kGL_GrGLStandard == standard);
GrGLint max;
GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
fMaxFragmentUniformVectors = max / 4;
if (version >= GR_GL_VER(3, 2)) {
GrGLint profileMask;
GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
}
if (!fIsCoreProfile) {
GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords);
// Sanity check
SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128);
}
}
GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
if (kGL_GrGLStandard == standard) {
fRGBA8RenderbufferSupport = true;
} else {
fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
ctxInfo.hasExtension("GL_ARM_rgba8");
}
if (kGL_GrGLStandard == standard) {
fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
ctxInfo.hasExtension("GL_ARB_texture_swizzle");
} else {
fTextureSwizzleSupport = version >= GR_GL_VER(3,0);
}
if (kGL_GrGLStandard == standard) {
fUnpackRowLengthSupport = true;
fUnpackFlipYSupport = false;
fPackRowLengthSupport = true;
fPackFlipYSupport = false;
} else {
fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_EXT_unpack_subimage");
fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_NV_pack_subimage");
fPackFlipYSupport =
ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order");
}
fTextureUsageSupport = (kGLES_GrGLStandard == standard) &&
ctxInfo.hasExtension("GL_ANGLE_texture_usage");
if (kGL_GrGLStandard == standard) {
// The EXT version can apply to either GL or GLES.
fTexStorageSupport = version >= GR_GL_VER(4,2) ||
ctxInfo.hasExtension("GL_ARB_texture_storage") ||
ctxInfo.hasExtension("GL_EXT_texture_storage");
} else {
// Qualcomm Adreno drivers appear to have issues with texture storage.
fTexStorageSupport = (version >= GR_GL_VER(3,0) &&
kQualcomm_GrGLVendor != ctxInfo.vendor()) ||
ctxInfo.hasExtension("GL_EXT_texture_storage");
}
// ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support it if
// it doesn't have ARB_texture_rg extension.
if (kGL_GrGLStandard == standard) {
if (ctxInfo.isMesa()) {
fTextureRedSupport = ctxInfo.hasExtension("GL_ARB_texture_rg");
} else {
fTextureRedSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_ARB_texture_rg");
}
} else {
fTextureRedSupport = version >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_EXT_texture_rg");
}
fImagingSupport = kGL_GrGLStandard == standard &&
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
//.........这里部分代码省略.........
示例8: initConfigTexturableTable
void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
// Base texture support
fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
// Check for 8-bit palette..
GrGLint numFormats;
GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
if (numFormats) {
SkAutoSTMalloc<10, GrGLint> formats(numFormats);
GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < numFormats; ++i) {
if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
break;
}
}
}
// Check for BGRA
if (kGL_GrGLStandard == standard) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
} else {
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
} else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
fBGRAIsInternalFormat = true;
}
SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
}
// Compressed texture support
// glCompressedTexImage2D is available on all OpenGL ES devices...
// however, it is only available on standard OpenGL after version 1.3
bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
// Check for ETC1
bool hasETC1 = false;
// First check version for support
if (kGL_GrGLStandard == standard) {
hasETC1 = hasCompressTex2D &&
(version >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
hasETC1 = hasCompressTex2D &&
(version >= GR_GL_VER(3, 0) ||
ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
// ETC2 is a superset of ETC1, so we can just check for that, too.
(ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
}
fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
// Check for LATC under its various forms
LATCAlias alias = kLATC_LATCAlias;
bool hasLATC = hasCompressTex2D &&
(ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
// Check for RGTC
if (!hasLATC) {
// If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
if (kGL_GrGLStandard == standard) {
hasLATC = version >= GR_GL_VER(3, 0);
}
if (!hasLATC) {
hasLATC =
ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
}
if (hasLATC) {
alias = kRGTC_LATCAlias;
}
}
// Check for 3DC
if (!hasLATC) {
hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
if (hasLATC) {
alias = k3DC_LATCAlias;
}
}
fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
fLATCAlias = alias;
}
示例9: initConfigRenderableTable
void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
// OpenGL < 3.0
// no support for render targets unless the GL_ARB_framebuffer_object
// extension is supported (in which case we get ALPHA, RED, RG, RGB,
// RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
// probably don't get R8 in this case.
// OpenGL 3.0
// base color renderable: ALPHA, RED, RG, RGB, and RGBA
// sized derivatives: ALPHA8, R8, RGBA4, RGBA8
// >= OpenGL 3.1
// base color renderable: RED, RG, RGB, and RGBA
// sized derivatives: R8, RGBA4, RGBA8
// if the GL_ARB_compatibility extension is supported then we get back
// support for GL_ALPHA and ALPHA8
// GL_EXT_bgra adds BGRA render targets to any version
// ES 2.0
// color renderable: RGBA4, RGB5_A1, RGB565
// GL_EXT_texture_rg adds support for R8 as a color render target
// GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
// GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
// ES 3.0
// Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
// below already account for this).
GrGLStandard standard = ctxInfo.standard();
enum {
kNo_MSAA = 0,
kYes_MSAA = 1,
};
if (kGL_GrGLStandard == standard) {
// Post 3.0 we will get R8
// Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
if (ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
}
} else {
// On ES we can only hope for R8
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport;
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
}
if (kGL_GrGLStandard != standard) {
// only available in ES
fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
}
// we no longer support 444 as a render target
fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
if (this->fRGBA8RenderbufferSupport) {
fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
}
if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
// The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
// configs that are color-renderable and can be passed to glRenderBufferStorageMultisample.
// Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms.
if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
} else {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
!fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
}
}
// If we don't support MSAA then undo any places above where we set a config as renderable with
// msaa.
if (kNone_MSFBOType == fMSFBOType) {
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
fConfigRenderSupport[i][kYes_MSAA] = false;
}
}
}
示例10: initConfigTexturableTable
void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
// Base texture support
fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
// Check for 8-bit palette..
GrGLint numFormats;
GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
if (numFormats) {
SkAutoSTMalloc<10, GrGLint> formats(numFormats);
GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int i = 0; i < numFormats; ++i) {
if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
break;
}
}
}
// Check for BGRA
if (kGL_GrGLStandard == standard) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
} else {
if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
} else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
fBGRAIsInternalFormat = true;
}
SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
}
// Check for sRGBA
if (kGL_GrGLStandard == standard) {
fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
(version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB"));
} else {
fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
(version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
}
// Compressed texture support
// glCompressedTexImage2D is available on all OpenGL ES devices...
// however, it is only available on standard OpenGL after version 1.3
bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
fCompressedTexSubImageSupport =
hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
// Check for ETC1
bool hasETC1 = false;
// First check version for support
if (kGL_GrGLStandard == standard) {
hasETC1 = hasCompressTex2D &&
(version >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
hasETC1 = hasCompressTex2D &&
(version >= GR_GL_VER(3, 0) ||
ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
// ETC2 is a superset of ETC1, so we can just check for that, too.
(ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
}
fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
// Check for LATC under its various forms
LATCAlias alias = kLATC_LATCAlias;
bool hasLATC = hasCompressTex2D &&
(ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
// Check for RGTC
if (!hasLATC) {
// If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
if (kGL_GrGLStandard == standard) {
hasLATC = version >= GR_GL_VER(3, 0);
}
if (!hasLATC) {
hasLATC =
ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
}
if (hasLATC) {
alias = kRGTC_LATCAlias;
}
}
// Check for 3DC
//.........这里部分代码省略.........
示例11: init
bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo,
const GrGLInterface* gli,
const GrGLCaps& glCaps) {
this->reset();
if (!ctxInfo.isInitialized()) {
return false;
}
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
/**************************************************************************
* Caps specific to GrGLSLCaps
**************************************************************************/
if (kGLES_GrGLStandard == standard) {
if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragData[0]";
fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
}
else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
// Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know
fFBFetchNeedsCustomOutput = false;
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragData[0]";
fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
}
else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
// The arm extension also requires an additional flag which we will set onResetContext
fFBFetchNeedsCustomOutput = false;
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragColorARM";
fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
}
}
// Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();
/**************************************************************************
* GrShaderCaps fields
**************************************************************************/
fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering");
if (fPathRenderingSupport) {
if (kGL_GrGLStandard == standard) {
// We only support v1.3+ of GL_NV_path_rendering which allows us to
// set individual fragment inputs with ProgramPathFragmentInputGen. The API
// additions are detected by checking the existence of the function.
fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") &&
((ctxInfo.version() >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_program_interface_query")) &&
gli->fFunctions.fProgramPathFragmentInputGen);
}
else {
fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3, 1);
}
}
// For now these two are equivalent but we could have dst read in shader via some other method
fDstReadInShaderSupport = fFBFetchSupport;
// Enable supported shader-related caps
if (kGL_GrGLStandard == standard) {
fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3, 3) ||
ctxInfo.hasExtension("GL_ARB_blend_func_extended");
fShaderDerivativeSupport = true;
// we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) &&
ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
}
else {
fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) ||
ctxInfo.hasExtension("GL_OES_standard_derivatives");
}
if (glCaps.advancedBlendEquationSupport()) {
bool coherent = glCaps.advancedCoherentBlendEquationSupport();
if (ctxInfo.hasExtension(coherent ? "GL_NV_blend_equation_advanced_coherent"
: "GL_NV_blend_equation_advanced")) {
fAdvBlendEqInteraction = kAutomatic_AdvBlendEqInteraction;
} else {
fAdvBlendEqInteraction = kGeneralEnable_AdvBlendEqInteraction;
// TODO: Use the following on any platform where "blend_support_all_equations" is slow.
//fAdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction;
}
}
this->initShaderPrecisionTable(ctxInfo, gli);
return true;
}
示例12: init
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);
}
示例13: init
void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
this->reset();
if (!ctxInfo.isInitialized()) {
return;
}
GrGLBinding binding = ctxInfo.binding();
GrGLVersion version = ctxInfo.version();
/**************************************************************************
* Caps specific to GrGLCaps
**************************************************************************/
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");
}
// SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
//.........这里部分代码省略.........