1f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com/* 2f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Copyright 2012 Google Inc. 3f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * 4f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Use of this source code is governed by a BSD-style license that can be 5f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * found in the LICENSE file. 6f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 7f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 8f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 9f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#ifndef GrGLCaps_DEFINED 10f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#define GrGLCaps_DEFINED 11f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 121aa202935ff698f1f35c5435455073fd9f1d08debsalomon#include <functional> 131aa202935ff698f1f35c5435455073fd9f1d08debsalomon 143183a4136364cfe18b3584302e71ea528a018401mtklein#include "glsl/GrGLSL.h" 15cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon#include "GrCaps.h" 168dc7c3a839b38b73af34cc2674a06f49eb1ce527egdaniel#include "GrGLStencilAttachment.h" 17cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon#include "GrSwizzle.h" 18e4b231428e8c14cbc82d20cfb12eb08fc45f8df6piotaixr#include "SkChecksum.h" 192aa1f7e6799501974532d35c1f6c3a0447121b95mtklein#include "SkTHash.h" 20a2d71482db8b6d752a51c96da74768d7dfc27932robertphillips@google.com#include "SkTArray.h" 21f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 22f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.comclass GrGLContextInfo; 23e9c0fc616d2a1632c285885b9b656b68ca8d4f24jvanverthclass GrGLSLCaps; 241aa202935ff698f1f35c5435455073fd9f1d08debsalomonclass GrGLRenderTarget; 25f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 26f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com/** 27f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Stores some capabilities of a GL context. Most are determined by the GL 28f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * version and the extensions string. It also tracks formats that have passed 29f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * the FBO completeness test. 30f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 314b91f768b348aa1cebeb54f3ff9331938734c242bsalomonclass GrGLCaps : public GrCaps { 32f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.compublic: 338dc7c3a839b38b73af34cc2674a06f49eb1ce527egdaniel typedef GrGLStencilAttachment::Format StencilFormat; 34f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 35f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 36f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * The type of MSAA for FBOs supported. Different extensions have different 37f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * semantics of how / when a resolve is performed. 38f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 39f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com enum MSFBOType { 40f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 41f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * no support for MSAA FBOs 42f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 43fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com kNone_MSFBOType = 0, 44f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 456fc1b4998917791a73bf54428513940fe77dc058skia.committer@gmail.com * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object). 46f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 47347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kDesktop_ARB_MSFBOType, 48f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 49f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * earlier GL_EXT_framebuffer* extensions 50f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 51347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kDesktop_EXT_MSFBOType, 52f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 53a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer. 54a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org */ 55a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org kES_3_0_MSFBOType, 56a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org /** 57f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * GL_APPLE_framebuffer_multisample ES extension 58f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 59347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kES_Apple_MSFBOType, 60f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com /** 61347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers. 62347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * Instead the texture is multisampled when bound to the FBO and then resolved automatically 63347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call 64347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * GR_GL_MAX_SAMPLES_IMG). 65f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com */ 66347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kES_IMG_MsToTexture_MSFBOType, 67347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com /** 68347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard 69347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * GL_MAX_SAMPLES value. 70347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com */ 71347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kES_EXT_MsToTexture_MSFBOType, 72dded69693dd3779f081326cde24c3954505b129dvbuzinov /** 73dded69693dd3779f081326cde24c3954505b129dvbuzinov * GL_NV_framebuffer_mixed_samples. 74dded69693dd3779f081326cde24c3954505b129dvbuzinov */ 75dded69693dd3779f081326cde24c3954505b129dvbuzinov kMixedSamples_MSFBOType, 766b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com 77dded69693dd3779f081326cde24c3954505b129dvbuzinov kLast_MSFBOType = kMixedSamples_MSFBOType 786b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com }; 796b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com 80083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon enum BlitFramebufferSupport { 81083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon kNone_BlitFramebufferSupport, 82083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon /** 83083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon * ANGLE exposes a limited blit framebuffer extension that does not allow for stretching 84083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon * or mirroring. 85083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon */ 86083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon kNoScalingNoMirroring_BlitFramebufferSupport, 87083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon kFull_BlitFramebufferSupport 88083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon }; 89083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon 9052ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org enum InvalidateFBType { 9152ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org kNone_InvalidateFBType, 9252ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org kDiscard_InvalidateFBType, //<! glDiscardFramebuffer() 93083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer() 9452ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org 9552ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org kLast_InvalidateFBType = kInvalidate_InvalidateFBType 96f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com }; 97f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 98160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org enum MapBufferType { 99160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org kNone_MapBufferType, 100160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org kMapBuffer_MapBufferType, // glMapBuffer() 101160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org kMapBufferRange_MapBufferType, // glMapBufferRange() 102160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org kChromium_MapBufferType, // GL_CHROMIUM_map_sub 103160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org 104160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org kLast_MapBufferType = kChromium_MapBufferType, 105160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org }; 106160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org 107d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth enum TransferBufferType { 108d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth kNone_TransferBufferType, 109d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth kPBO_TransferBufferType, // ARB_pixel_buffer_object 110d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object 111d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth 112d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth kLast_TransferBufferType = kChromium_TransferBufferType, 113d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth }; 114d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth 115f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 116f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Initializes the GrGLCaps to the set of features supported in the current 117f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * OpenGL context accessible via ctxInfo. 118f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 119682c269a1511200322916af83053e26004c0ec40bsalomon GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, 120682c269a1511200322916af83053e26004c0ec40bsalomon const GrGLInterface* glInterface); 121f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 12241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon bool isConfigTexturable(GrPixelConfig config) const override { 12341e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon SkASSERT(kGrPixelConfigCnt > config); 12441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag); 12541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon } 12641e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon 12741e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { 12841e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon SkASSERT(kGrPixelConfigCnt > config); 12941e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon if (withMSAA) { 13041e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag); 13141e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon } else { 13241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag); 13341e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon } 13441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon } 13541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon 136cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon /** Returns the mapping between GrPixelConfig components and GL internal format components. */ 137cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon const GrSwizzle& configSwizzle(GrPixelConfig config) const { 138cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon return fConfigTable[config].fSwizzle; 139cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon } 140cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon 14176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, 14276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum* internalFormat, GrGLenum* externalFormat, 14376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum* externalType) const; 14476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 14576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const; 14676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 14776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, 14876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum* externalFormat, GrGLenum* externalType) const; 14976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 15076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const; 15176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 152304473749db1ee877addb3ddf090d2e36ede2c2absalomon /** 153304473749db1ee877addb3ddf090d2e36ede2c2absalomon * Gets an array of legal stencil formats. These formats are not guaranteed 154304473749db1ee877addb3ddf090d2e36ede2c2absalomon * to be supported by the driver but are legal GLenum names given the GL 155304473749db1ee877addb3ddf090d2e36ede2c2absalomon * version and extensions supported. 156304473749db1ee877addb3ddf090d2e36ede2c2absalomon */ 157304473749db1ee877addb3ddf090d2e36ede2c2absalomon const SkTArray<StencilFormat, true>& stencilFormats() const { 158304473749db1ee877addb3ddf090d2e36ede2c2absalomon return fStencilFormats; 159304473749db1ee877addb3ddf090d2e36ede2c2absalomon } 160304473749db1ee877addb3ddf090d2e36ede2c2absalomon 161304473749db1ee877addb3ddf090d2e36ede2c2absalomon /** 162304473749db1ee877addb3ddf090d2e36ede2c2absalomon * Has a stencil format index been found for the config (or we've found that no format works). 163304473749db1ee877addb3ddf090d2e36ede2c2absalomon */ 164304473749db1ee877addb3ddf090d2e36ede2c2absalomon bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const { 165304473749db1ee877addb3ddf090d2e36ede2c2absalomon return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex; 166304473749db1ee877addb3ddf090d2e36ede2c2absalomon } 167304473749db1ee877addb3ddf090d2e36ede2c2absalomon 168304473749db1ee877addb3ddf090d2e36ede2c2absalomon /** 169304473749db1ee877addb3ddf090d2e36ede2c2absalomon * Gets the stencil format index for the config. This assumes 170304473749db1ee877addb3ddf090d2e36ede2c2absalomon * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if 171304473749db1ee877addb3ddf090d2e36ede2c2absalomon * no stencil format is supported with the config. Otherwise, returned index refers to the array 172304473749db1ee877addb3ddf090d2e36ede2c2absalomon * returned by stencilFormats(). 173304473749db1ee877addb3ddf090d2e36ede2c2absalomon */ 174304473749db1ee877addb3ddf090d2e36ede2c2absalomon int getStencilFormatIndexForConfig(GrPixelConfig config) const { 175304473749db1ee877addb3ddf090d2e36ede2c2absalomon SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config)); 176304473749db1ee877addb3ddf090d2e36ede2c2absalomon return fConfigTable[config].fStencilFormatIndex; 177304473749db1ee877addb3ddf090d2e36ede2c2absalomon } 178304473749db1ee877addb3ddf090d2e36ede2c2absalomon 179304473749db1ee877addb3ddf090d2e36ede2c2absalomon /** 180304473749db1ee877addb3ddf090d2e36ede2c2absalomon * If index is >= 0 this records an index into stencilFormats() as the best stencil format for 181304473749db1ee877addb3ddf090d2e36ede2c2absalomon * the config. If < 0 it records that the config has no supported stencil format index. 182304473749db1ee877addb3ddf090d2e36ede2c2absalomon */ 183304473749db1ee877addb3ddf090d2e36ede2c2absalomon void setStencilFormatIndexForConfig(GrPixelConfig config, int index) { 184304473749db1ee877addb3ddf090d2e36ede2c2absalomon SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config)); 185304473749db1ee877addb3ddf090d2e36ede2c2absalomon if (index < 0) { 186304473749db1ee877addb3ddf090d2e36ede2c2absalomon fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex; 187304473749db1ee877addb3ddf090d2e36ede2c2absalomon } else { 188304473749db1ee877addb3ddf090d2e36ede2c2absalomon fConfigTable[config].fStencilFormatIndex = index; 189304473749db1ee877addb3ddf090d2e36ede2c2absalomon } 190304473749db1ee877addb3ddf090d2e36ede2c2absalomon } 191304473749db1ee877addb3ddf090d2e36ede2c2absalomon 192f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 193f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Call to note that a color config has been verified as a valid color 194f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * attachment. This may save future calls to glCheckFramebufferStatus 195f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * using isConfigVerifiedColorAttachment(). 196f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 197f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com void markConfigAsValidColorAttachment(GrPixelConfig config) { 198480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag; 199f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com } 200f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 201f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 202f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Call to check whether a config has been verified as a valid color 203f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * attachment. 204f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 205f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { 206480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag); 207f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com } 208f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 209f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 210f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Reports the type of MSAA FBO support. 211f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 212f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com MSFBOType msFBOType() const { return fMSFBOType; } 213f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 214f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 215083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon * Does the preferred MSAA FBO extension have MSAA renderbuffers? 216347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com */ 217347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com bool usesMSAARenderBuffers() const { 218347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com return kNone_MSFBOType != fMSFBOType && 219347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kES_IMG_MsToTexture_MSFBOType != fMSFBOType && 220dded69693dd3779f081326cde24c3954505b129dvbuzinov kES_EXT_MsToTexture_MSFBOType != fMSFBOType && 221dded69693dd3779f081326cde24c3954505b129dvbuzinov kMixedSamples_MSFBOType != fMSFBOType; 222347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com } 223347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com 224347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com /** 225083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon * What functionality is supported by glBlitFramebuffer. 226083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon */ 227083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon BlitFramebufferSupport blitFramebufferSupport() const { return fBlitFramebufferSupport; } 228083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon 229083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon /** 230347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and 231347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com * then implicitly resolved when read. 232347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com */ 233347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com bool usesImplicitMSAAResolve() const { 234347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || 235347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com kES_EXT_MsToTexture_MSFBOType == fMSFBOType; 236347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com } 237347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com 23852ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } 23952ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org 240160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org /// What type of buffer mapping is supported? 241160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org MapBufferType mapBufferType() const { return fMapBufferType; } 242f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 243d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth /// What type of transfer buffer is supported? 244d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth TransferBufferType transferBufferType() const { return fTransferBufferType; } 245d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth 246f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// The maximum number of fragment uniform vectors (GLES has min. 16). 247f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } 248f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 249a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org /// maximum number of attribute values per vertex 25060da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com int maxVertexAttributes() const { return fMaxVertexAttributes; } 25160da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com 252a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org /// maximum number of texture units accessible in the fragment shader. 253a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } 254a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org 255f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /** 256f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Depending on the ES extensions present the BGRA external format may 25741e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is 258f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * RGBA. 259f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */ 26041e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon bool bgraIsInternalFormat() const; 261f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 262f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for GL_UNPACK_ROW_LENGTH 263f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; } 264f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 265f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for GL_UNPACK_FLIP_Y 266f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool unpackFlipYSupport() const { return fUnpackFlipYSupport; } 267f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 268f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for GL_PACK_ROW_LENGTH 269f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool packRowLengthSupport() const { return fPackRowLengthSupport; } 270f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 271f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for GL_PACK_REVERSE_ROW_ORDER 272f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool packFlipYSupport() const { return fPackFlipYSupport; } 273f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 274f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for texture parameter GL_TEXTURE_USAGE 275f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool textureUsageSupport() const { return fTextureUsageSupport; } 276f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 277f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com /// Is there support for glTexStorage 278f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool texStorageSupport() const { return fTexStorageSupport; } 279f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 280443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com /// Is there support for GL_RED and GL_R8 281443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com bool textureRedSupport() const { return fTextureRedSupport; } 282443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com 283e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com /// Is GL_ARB_IMAGING supported 284e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com bool imagingSupport() const { return fImagingSupport; } 285e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com 28607631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com /// Is there support for Vertex Array Objects? 28707631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } 28807631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com 289626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton /// Is there support for GL_EXT_direct_state_access? 290626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton bool directStateAccessSupport() const { return fDirectStateAccessSupport; } 291626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton 292626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton /// Is there support for GL_KHR_debug? 293626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton bool debugSupport() const { return fDebugSupport; } 294626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton 2953f801cbb67895fa9fa29498aa017a7666960a627jvanverth /// Is there support for ES2 compatability? 2963f801cbb67895fa9fa29498aa017a7666960a627jvanverth bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } 2973f801cbb67895fa9fa29498aa017a7666960a627jvanverth 298d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton /// Can we call glDisable(GL_MULTISAMPLE)? 29976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool multisampleDisableSupport() const { return fMultisampleDisableSupport; } 300d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton 30106604b95622359640a1c2028b885646deda28d52cdalton /// Is there support for glDraw*Indirect? Note that the baseInstance fields of indirect draw 30206604b95622359640a1c2028b885646deda28d52cdalton /// commands cannot be used unless we have base instance support. 30306604b95622359640a1c2028b885646deda28d52cdalton bool drawIndirectSupport() const { return fDrawIndirectSupport; } 30406604b95622359640a1c2028b885646deda28d52cdalton 30506604b95622359640a1c2028b885646deda28d52cdalton /// Is there support for glMultiDraw*Indirect? Note that the baseInstance fields of indirect 30606604b95622359640a1c2028b885646deda28d52cdalton /// draw commands cannot be used unless we have base instance support. 30706604b95622359640a1c2028b885646deda28d52cdalton bool multiDrawIndirectSupport() const { return fMultiDrawIndirectSupport; } 30806604b95622359640a1c2028b885646deda28d52cdalton 30906604b95622359640a1c2028b885646deda28d52cdalton /// Are the baseInstance fields supported in indirect draw commands? 31006604b95622359640a1c2028b885646deda28d52cdalton bool baseInstanceSupport() const { return fBaseInstanceSupport; } 31106604b95622359640a1c2028b885646deda28d52cdalton 31207631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. 31376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; } 31496966a5a1ffc2f03eef1b5523308299aa4195f50bsalomon@google.com 3151aa202935ff698f1f35c5435455073fd9f1d08debsalomon /// Does ReadPixels support reading readConfig pixels from a FBO that is renderTargetConfig? 3161aa202935ff698f1f35c5435455073fd9f1d08debsalomon bool readPixelsSupported(GrPixelConfig renderTargetConfig, 3177928ef613f11a3c97fd939090197b8ae2be44b7absalomon GrPixelConfig readConfig, 3181aa202935ff698f1f35c5435455073fd9f1d08debsalomon std::function<void (GrGLenum, GrGLint*)> getIntegerv, 3191aa202935ff698f1f35c5435455073fd9f1d08debsalomon std::function<bool ()> bindRenderTarget) const; 320631cdcb4a6b926b6447f328b81911a4499fb3698skia.committer@gmail.com 3212b1b8c083b969a2a798b03d1754a3fc99ea054dfbsalomon@google.com bool isCoreProfile() const { return fIsCoreProfile; } 3221d89c93b2a61a9679f444b19b6fce4325ae7df65robertphillips@google.com 323c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; } 324c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt 3257bdd70ab9162980f3173c98c48234f9f345665a3joshualitt bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; } 3267bdd70ab9162980f3173c98c48234f9f345665a3joshualitt 3277ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported. 3287ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon bool externalTextureSupport() const { return fExternalTextureSupport; } 3297ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon 330e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon /// Are textures with GL_TEXTURE_RECTANGLE type supported. 331e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon bool rectangleTextureSupport() const { return fRectangleTextureSupport; } 332e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon 333cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon /// GL_ARB_texture_swizzle 334cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon bool textureSwizzleSupport() const { return fTextureSwizzleSupport; } 335cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon 336160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org /** 33716921ec30a81976129d507b1148c93a322e61a4fbsalomon * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments? 33816921ec30a81976129d507b1148c93a322e61a4fbsalomon * If false this does not mean sRGB is not supported but rather that if it is supported 33916921ec30a81976129d507b1148c93a322e61a4fbsalomon * it cannot be turned off for configs that support it. 34016921ec30a81976129d507b1148c93a322e61a4fbsalomon */ 34116921ec30a81976129d507b1148c93a322e61a4fbsalomon bool srgbWriteControl() const { return fSRGBWriteControl; } 34216921ec30a81976129d507b1148c93a322e61a4fbsalomon 34316921ec30a81976129d507b1148c93a322e61a4fbsalomon /** 344160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org * Returns a string containing the caps info. 345160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org */ 34636352bf5e38f45a70ee4f4fc132a38048d38206dmtklein SkString dump() const override; 347beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org 34888c7b988ba7792e51e741567426069cd9cc852ddbsalomon bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } 34988c7b988ba7792e51e741567426069cd9cc852ddbsalomon bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } 35088c7b988ba7792e51e741567426069cd9cc852ddbsalomon 351f529439fea003851d986a0573a7e0465754b2a48egdaniel const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); } 352e9c0fc616d2a1632c285885b9b656b68ca8d4f24jvanverth 353f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.comprivate: 35476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon enum ExternalFormatUsage { 35576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon kTexImage_ExternalFormatUsage, 35676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon kOther_ExternalFormatUsage, 35776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 35876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon kLast_ExternalFormatUsage = kOther_ExternalFormatUsage 35976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon }; 36076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1; 36176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig, 36276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon ExternalFormatUsage usage, GrGLenum* externalFormat, 36376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum* externalType) const; 36476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 3654cd6713af1c699b79e04b590109768300faee531cdalton void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); 36605ded891272772d43acc16345b2f90a4560df090egdaniel void initGLSL(const GrGLContextInfo&); 367cfe62e30848eadead4358b0385e57723779b762bkkinnunen bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); 368424cc26add7ed491c6941d0c0c3a0e6d83190307bsalomon 369b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel void onApplyOptionsOverrides(const GrContextOptions& options) override; 370b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel 3717388051d745590d7759e7ed49c233caec6bea0f7commit-bot@chromium.org void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); 3721dd0542ca37cf1b4a2ab0ea41f8009ded097fd47cdalton void initBlendEqationSupport(const GrGLContextInfo&); 3737388051d745590d7759e7ed49c233caec6bea0f7commit-bot@chromium.org void initStencilFormats(const GrGLContextInfo&); 3746b7938f9cb250086a7c6325cf31576f894ca4a1bcommit-bot@chromium.org // This must be called after initFSAASupport(). 375cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps); 37642dc8136914ee0777bb9110a5e04a75016687c0dcommit-bot@chromium.org 377cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, 378cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth const GrGLInterface* intf, 379cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth GrGLSLCaps* glslCaps); 380cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth 3811aa202935ff698f1f35c5435455073fd9f1d08debsalomon GrGLStandard fStandard; 3821aa202935ff698f1f35c5435455073fd9f1d08debsalomon 383f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com SkTArray<StencilFormat, true> fStencilFormats; 384f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 385f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com int fMaxFragmentUniformVectors; 38660da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com int fMaxVertexAttributes; 387a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org int fMaxFragmentTextureUnits; 38860da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com 38952ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org MSFBOType fMSFBOType; 39052ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org InvalidateFBType fInvalidateFBType; 391160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org MapBufferType fMapBufferType; 392d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth TransferBufferType fTransferBufferType; 3936b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com 394f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fUnpackRowLengthSupport : 1; 395f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fUnpackFlipYSupport : 1; 396f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fPackRowLengthSupport : 1; 397f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fPackFlipYSupport : 1; 398f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fTextureUsageSupport : 1; 399f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com bool fTexStorageSupport : 1; 400443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com bool fTextureRedSupport : 1; 401e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com bool fImagingSupport : 1; 40207631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com bool fVertexArrayObjectSupport : 1; 403626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton bool fDirectStateAccessSupport : 1; 404626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton bool fDebugSupport : 1; 4053f801cbb67895fa9fa29498aa017a7666960a627jvanverth bool fES2CompatibilitySupport : 1; 406d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton bool fMultisampleDisableSupport : 1; 40706604b95622359640a1c2028b885646deda28d52cdalton bool fDrawIndirectSupport : 1; 40806604b95622359640a1c2028b885646deda28d52cdalton bool fMultiDrawIndirectSupport : 1; 40906604b95622359640a1c2028b885646deda28d52cdalton bool fBaseInstanceSupport : 1; 41096966a5a1ffc2f03eef1b5523308299aa4195f50bsalomon@google.com bool fUseNonVBOVertexAndIndexDynamicData : 1; 4112b1b8c083b969a2a798b03d1754a3fc99ea054dfbsalomon@google.com bool fIsCoreProfile : 1; 412c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt bool fBindFragDataLocationSupport : 1; 41316921ec30a81976129d507b1148c93a322e61a4fbsalomon bool fSRGBWriteControl : 1; 41488c7b988ba7792e51e741567426069cd9cc852ddbsalomon bool fRGBA8888PixelsOpsAreSlow : 1; 41588c7b988ba7792e51e741567426069cd9cc852ddbsalomon bool fPartialFBOReadIsSlow : 1; 4167bdd70ab9162980f3173c98c48234f9f345665a3joshualitt bool fBindUniformLocationSupport : 1; 4177ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon bool fExternalTextureSupport : 1; 418e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon bool fRectangleTextureSupport : 1; 419cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon bool fTextureSwizzleSupport : 1; 4205816233d237e5c214f14f1c92eda4a87c898ea11joshualitt 421083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon BlitFramebufferSupport fBlitFramebufferSupport; 422083617b9a7247dd4c52f8dfd195fa34a083e6f1dbsalomon 4237928ef613f11a3c97fd939090197b8ae2be44b7absalomon /** Number type of the components (with out considering number of bits.) */ 4247928ef613f11a3c97fd939090197b8ae2be44b7absalomon enum FormatType { 4257928ef613f11a3c97fd939090197b8ae2be44b7absalomon kNormalizedFixedPoint_FormatType, 4267928ef613f11a3c97fd939090197b8ae2be44b7absalomon kFloat_FormatType, 4277928ef613f11a3c97fd939090197b8ae2be44b7absalomon }; 4287928ef613f11a3c97fd939090197b8ae2be44b7absalomon 4297928ef613f11a3c97fd939090197b8ae2be44b7absalomon struct ReadPixelsFormat { 4307928ef613f11a3c97fd939090197b8ae2be44b7absalomon ReadPixelsFormat() : fFormat(0), fType(0) {} 4317928ef613f11a3c97fd939090197b8ae2be44b7absalomon GrGLenum fFormat; 4327928ef613f11a3c97fd939090197b8ae2be44b7absalomon GrGLenum fType; 4337928ef613f11a3c97fd939090197b8ae2be44b7absalomon }; 4347928ef613f11a3c97fd939090197b8ae2be44b7absalomon 43576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon struct ConfigFormats { 43676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon ConfigFormats() { 43776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon // Inits to known bad GL enum values. 43876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon memset(this, 0xAB, sizeof(ConfigFormats)); 43976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon } 44076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fBaseInternalFormat; 44176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fSizedInternalFormat; 44276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 44376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon /** The external format and type are to be used when uploading/downloading data using this 44476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon config where both the CPU data and GrSurface are the same config. To get the external 44576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon format and type when converting between configs while copying to/from memory use 44676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon getExternalFormat(). 44776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon The kTexImage external format is usually the same as kOther except for kSRGBA on some 44876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GL contexts. */ 44976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fExternalFormat[kExternalFormatUsageCnt]; 45076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fExternalType; 45176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 45276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 45376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon // Either the base or sized internal format depending on the GL and config. 45476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fInternalFormatTexImage; 45576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon GrGLenum fInternalFormatRenderbuffer; 45676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon }; 45776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon 458304473749db1ee877addb3ddf090d2e36ede2c2absalomon struct ConfigInfo { 4597928ef613f11a3c97fd939090197b8ae2be44b7absalomon ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} 460304473749db1ee877addb3ddf090d2e36ede2c2absalomon 461304473749db1ee877addb3ddf090d2e36ede2c2absalomon ConfigFormats fFormats; 462304473749db1ee877addb3ddf090d2e36ede2c2absalomon 4637928ef613f11a3c97fd939090197b8ae2be44b7absalomon FormatType fFormatType; 4647928ef613f11a3c97fd939090197b8ae2be44b7absalomon 4657928ef613f11a3c97fd939090197b8ae2be44b7absalomon // On ES contexts there are restrictions on type type/format that may be used for 4667928ef613f11a3c97fd939090197b8ae2be44b7absalomon // ReadPixels. One is implicitly specified by the current FBO's format. The other is 4677928ef613f11a3c97fd939090197b8ae2be44b7absalomon // queryable. This stores the queried option (lazily). 4687928ef613f11a3c97fd939090197b8ae2be44b7absalomon ReadPixelsFormat fSecondReadPixelsFormat; 4697928ef613f11a3c97fd939090197b8ae2be44b7absalomon 470304473749db1ee877addb3ddf090d2e36ede2c2absalomon enum { 471304473749db1ee877addb3ddf090d2e36ede2c2absalomon // This indicates that a stencil format has not yet been determined for the config. 472304473749db1ee877addb3ddf090d2e36ede2c2absalomon kUnknown_StencilIndex = -1, 473304473749db1ee877addb3ddf090d2e36ede2c2absalomon // This indicates that there is no supported stencil format for the config. 474304473749db1ee877addb3ddf090d2e36ede2c2absalomon kUnsupported_StencilFormatIndex = -2 475304473749db1ee877addb3ddf090d2e36ede2c2absalomon }; 476480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon 477480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon // Index fStencilFormats. 478480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon int fStencilFormatIndex; 479480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon 480480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon enum { 48141e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon kVerifiedColorAttachment_Flag = 0x1, 48241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon kTextureable_Flag = 0x2, 48341e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon kRenderable_Flag = 0x4, 48441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon kRenderableWithMSAA_Flag = 0x8, 485480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon }; 486480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon uint32_t fFlags; 487cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon 488cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon GrSwizzle fSwizzle; 489304473749db1ee877addb3ddf090d2e36ede2c2absalomon }; 490304473749db1ee877addb3ddf090d2e36ede2c2absalomon 491304473749db1ee877addb3ddf090d2e36ede2c2absalomon ConfigInfo fConfigTable[kGrPixelConfigCnt]; 492304473749db1ee877addb3ddf090d2e36ede2c2absalomon 4934b91f768b348aa1cebeb54f3ff9331938734c242bsalomon typedef GrCaps INHERITED; 494f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com}; 495f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com 496f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#endif 497