Flutter Engine
The Flutter Engine
Functions
GrGLCaps.cpp File Reference
#include "src/gpu/ganesh/gl/GrGLCaps.h"
#include "include/core/SkColor.h"
#include "include/core/SkRect.h"
#include "include/core/SkSize.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDriverBugWorkarounds.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/gl/GrGLBackendSurface.h"
#include "include/gpu/gl/GrGLFunctions.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/gpu/Blend.h"
#include "src/gpu/ganesh/GrBackendUtils.h"
#include "src/gpu/ganesh/GrProgramDesc.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrShaderCaps.h"
#include "src/gpu/ganesh/GrSurface.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/TestFormatColorTypeCombination.h"
#include "src/gpu/ganesh/gl/GrGLContext.h"
#include "src/gpu/ganesh/gl/GrGLDefines.h"
#include "src/gpu/ganesh/gl/GrGLRenderTarget.h"
#include "src/gpu/ganesh/gl/GrGLTexture.h"
#include "src/gpu/ganesh/gl/GrGLUtil.h"
#include "src/sksl/SkSLGLSL.h"
#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <memory>

Go to the source code of this file.

Functions

static bool angle_backend_is_d3d (GrGLANGLEBackend backend)
 
static bool angle_backend_is_metal (GrGLANGLEBackend backend)
 
const char * get_glsl_version_decl_string (GrGLStandard standard, SkSL::GLSLGeneration generation, bool isCoreProfile)
 
bool is_float_fp32 (const GrGLContextInfo &ctxInfo, const GrGLInterface *gli, GrGLenum precision)
 
static bool has_msaa_render_buffer (const GrSurfaceProxy *surf, const GrGLCaps &glCaps)
 
size_t offset_alignment_for_transfer_buffer (GrGLenum externalType)
 

Function Documentation

◆ angle_backend_is_d3d()

static bool angle_backend_is_d3d ( GrGLANGLEBackend  backend)
static

Definition at line 110 of file GrGLCaps.cpp.

◆ angle_backend_is_metal()

static bool angle_backend_is_metal ( GrGLANGLEBackend  backend)
static

Definition at line 114 of file GrGLCaps.cpp.

114 {
116}

◆ get_glsl_version_decl_string()

const char * get_glsl_version_decl_string ( GrGLStandard  standard,
SkSL::GLSLGeneration  generation,
bool  isCoreProfile 
)

Definition at line 864 of file GrGLCaps.cpp.

865 {
866 if (GR_IS_GR_GL(standard)) {
867 switch (generation) {
869 return "#version 110\n";
871 return "#version 130\n";
873 return "#version 140\n";
875 if (isCoreProfile) {
876 return "#version 150\n";
877 } else {
878 return "#version 150 compatibility\n";
879 }
881 if (isCoreProfile) {
882 return "#version 330\n";
883 } else {
884 return "#version 330 compatibility\n";
885 }
887 if (isCoreProfile) {
888 return "#version 400\n";
889 } else {
890 return "#version 400 compatibility\n";
891 }
893 if (isCoreProfile) {
894 return "#version 420\n";
895 } else {
896 return "#version 420 compatibility\n";
897 }
898 default:
899 break;
900 }
901 } else if (GR_IS_GR_GL_ES(standard) || GR_IS_GR_WEBGL(standard)) {
902 switch (generation) {
904 return "#version 100\n";
906 return "#version 300 es\n";
908 return "#version 310 es\n";
910 return "#version 320 es\n";
911 default:
912 break;
913 }
914 }
915 return "<no version>";
916}
#define GR_IS_GR_WEBGL(standard)
Definition: GrGLTypes.h:50
#define GR_IS_GR_GL(standard)
Definition: GrGLTypes.h:48
#define GR_IS_GR_GL_ES(standard)
Definition: GrGLTypes.h:49

◆ has_msaa_render_buffer()

static bool has_msaa_render_buffer ( const GrSurfaceProxy surf,
const GrGLCaps glCaps 
)
static

Definition at line 3686 of file GrGLCaps.cpp.

3686 {
3687 const GrRenderTargetProxy* rt = surf->asRenderTargetProxy();
3688 if (!rt) {
3689 return false;
3690 }
3691 // A RT has a separate MSAA renderbuffer if:
3692 // 1) It's multisampled
3693 // 2) We're using an extension with separate MSAA renderbuffers
3694 // 3) It's not FBO 0, which is special and always auto-resolves
3695 return rt->numSamples() > 1 &&
3696 glCaps.usesMSAARenderBuffers() &&
3697 !rt->glRTFBOIDIs0();
3698}
bool usesMSAARenderBuffers() const
Definition: GrGLCaps.h:290
virtual GrRenderTargetProxy * asRenderTargetProxy()

◆ is_float_fp32()

bool is_float_fp32 ( const GrGLContextInfo ctxInfo,
const GrGLInterface gli,
GrGLenum  precision 
)

Definition at line 918 of file GrGLCaps.cpp.

918 {
919 if (GR_IS_GR_GL(ctxInfo.standard()) &&
920 ctxInfo.version() < GR_GL_VER(4,1) &&
921 !ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
922 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
923 return true;
924 }
925 // glGetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Hopefully the
926 // geometry shaders don't have lower precision than vertex and fragment.
928 GrGLint range[2];
930 GR_GL_GetShaderPrecisionFormat(gli, shader, precision, range, &bits);
931 if (range[0] < 127 || range[1] < 127 || bits < 23) {
932 return false;
933 }
934 }
935 return true;
936}
#define GR_GL_FRAGMENT_SHADER
Definition: GrGLDefines.h:551
#define GR_GL_VERTEX_SHADER
Definition: GrGLDefines.h:552
int GrGLint
Definition: GrGLTypes.h:108
unsigned int GrGLenum
Definition: GrGLTypes.h:102
#define GR_GL_VER(major, minor)
Definition: GrGLUtil.h:26
#define GR_GL_GetShaderPrecisionFormat(gl, st, pt, range, precision)
Definition: GrGLUtil.h:287
GrGLVersion version() const
Definition: GrGLContext.h:31
bool hasExtension(const char *ext) const
Definition: GrGLContext.h:72
GrGLStandard standard() const
Definition: GrGLContext.h:30

◆ offset_alignment_for_transfer_buffer()

size_t offset_alignment_for_transfer_buffer ( GrGLenum  externalType)

Definition at line 4762 of file GrGLCaps.cpp.

4762 {
4763 // This switch is derived from a table titled "Pixel data type parameter values and the
4764 // corresponding GL data types" in the OpenGL spec (Table 8.2 in OpenGL 4.5).
4765 switch (externalType) {
4766 case GR_GL_UNSIGNED_BYTE: return sizeof(GrGLubyte);
4767 case GR_GL_BYTE: return sizeof(GrGLbyte);
4768 case GR_GL_UNSIGNED_SHORT: return sizeof(GrGLushort);
4769 case GR_GL_SHORT: return sizeof(GrGLshort);
4770 case GR_GL_UNSIGNED_INT: return sizeof(GrGLuint);
4771 case GR_GL_INT: return sizeof(GrGLint);
4772 case GR_GL_HALF_FLOAT: return sizeof(GrGLhalf);
4773 case GR_GL_HALF_FLOAT_OES: return sizeof(GrGLhalf);
4774 case GR_GL_FLOAT: return sizeof(GrGLfloat);
4775 case GR_GL_UNSIGNED_SHORT_5_6_5: return sizeof(GrGLushort);
4776 case GR_GL_UNSIGNED_SHORT_4_4_4_4: return sizeof(GrGLushort);
4777 case GR_GL_UNSIGNED_SHORT_5_5_5_1: return sizeof(GrGLushort);
4778 case GR_GL_UNSIGNED_INT_2_10_10_10_REV: return sizeof(GrGLuint);
4779#if 0 // GL types we currently don't use. Here for future reference.
4780 case GR_GL_UNSIGNED_BYTE_3_3_2: return sizeof(GrGLubyte);
4781 case GR_GL_UNSIGNED_BYTE_2_3_3_REV: return sizeof(GrGLubyte);
4782 case GR_GL_UNSIGNED_SHORT_5_6_5_REV: return sizeof(GrGLushort);
4783 case GR_GL_UNSIGNED_SHORT_4_4_4_4_REV: return sizeof(GrGLushort);
4784 case GR_GL_UNSIGNED_SHORT_1_5_5_5_REV: return sizeof(GrGLushort);
4785 case GR_GL_UNSIGNED_INT_8_8_8_8: return sizeof(GrGLuint);
4786 case GR_GL_UNSIGNED_INT_8_8_8_8_REV: return sizeof(GrGLuint);
4787 case GR_GL_UNSIGNED_INT_10_10_10_2: return sizeof(GrGLuint);
4788 case GR_GL_UNSIGNED_INT_24_8: return sizeof(GrGLuint);
4789 case GR_GL_UNSIGNED_INT_10F_11F_11F_REV: return sizeof(GrGLuint);
4790 case GR_GL_UNSIGNED_INT_5_9_9_9_REV: return sizeof(GrGLuint);
4791 // This one is not corresponding to a GL data type and the spec just says it is 4.
4792 case GR_GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return 4;
4793#endif
4794 default: return 0;
4795 }
4796}
#define GR_GL_HALF_FLOAT
Definition: GrGLDefines.h:356
#define GR_GL_BYTE
Definition: GrGLDefines.h:349
#define GR_GL_UNSIGNED_SHORT
Definition: GrGLDefines.h:352
#define GR_GL_UNSIGNED_SHORT_5_6_5
Definition: GrGLDefines.h:547
#define GR_GL_UNSIGNED_SHORT_4_4_4_4
Definition: GrGLDefines.h:545
#define GR_GL_INT
Definition: GrGLDefines.h:353
#define GR_GL_HALF_FLOAT_OES
Definition: GrGLDefines.h:358
#define GR_GL_UNSIGNED_INT
Definition: GrGLDefines.h:354
#define GR_GL_SHORT
Definition: GrGLDefines.h:351
#define GR_GL_UNSIGNED_SHORT_5_5_5_1
Definition: GrGLDefines.h:546
#define GR_GL_UNSIGNED_BYTE
Definition: GrGLDefines.h:350
#define GR_GL_FLOAT
Definition: GrGLDefines.h:355
#define GR_GL_UNSIGNED_INT_2_10_10_10_REV
Definition: GrGLDefines.h:548
unsigned int GrGLuint
Definition: GrGLTypes.h:113
unsigned short int GrGLhalf
Definition: GrGLTypes.h:115
short GrGLshort
Definition: GrGLTypes.h:107
float GrGLfloat
Definition: GrGLTypes.h:116
unsigned short GrGLushort
Definition: GrGLTypes.h:112
unsigned char GrGLubyte
Definition: GrGLTypes.h:111
signed char GrGLbyte
Definition: GrGLTypes.h:105