Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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/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 109 of file GrGLCaps.cpp.

◆ angle_backend_is_metal()

static bool angle_backend_is_metal ( GrGLANGLEBackend  backend)
static

Definition at line 113 of file GrGLCaps.cpp.

113 {
115}

◆ get_glsl_version_decl_string()

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

Definition at line 863 of file GrGLCaps.cpp.

864 {
865 if (GR_IS_GR_GL(standard)) {
866 switch (generation) {
868 return "#version 110\n";
870 return "#version 130\n";
872 return "#version 140\n";
874 if (isCoreProfile) {
875 return "#version 150\n";
876 } else {
877 return "#version 150 compatibility\n";
878 }
880 if (isCoreProfile) {
881 return "#version 330\n";
882 } else {
883 return "#version 330 compatibility\n";
884 }
886 if (isCoreProfile) {
887 return "#version 400\n";
888 } else {
889 return "#version 400 compatibility\n";
890 }
892 if (isCoreProfile) {
893 return "#version 420\n";
894 } else {
895 return "#version 420 compatibility\n";
896 }
897 default:
898 break;
899 }
900 } else if (GR_IS_GR_GL_ES(standard) || GR_IS_GR_WEBGL(standard)) {
901 switch (generation) {
903 return "#version 100\n";
905 return "#version 300 es\n";
907 return "#version 310 es\n";
909 return "#version 320 es\n";
910 default:
911 break;
912 }
913 }
914 return "<no version>";
915}
#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 3685 of file GrGLCaps.cpp.

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

917 {
918 if (GR_IS_GR_GL(ctxInfo.standard()) &&
919 ctxInfo.version() < GR_GL_VER(4,1) &&
920 !ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
921 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
922 return true;
923 }
924 // glGetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Hopefully the
925 // geometry shaders don't have lower precision than vertex and fragment.
927 GrGLint range[2];
929 GR_GL_GetShaderPrecisionFormat(gli, shader, precision, range, &bits);
930 if (range[0] < 127 || range[1] < 127 || bits < 23) {
931 return false;
932 }
933 }
934 return true;
935}
#define GR_GL_FRAGMENT_SHADER
#define GR_GL_VERTEX_SHADER
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 4770 of file GrGLCaps.cpp.

4770 {
4771 // This switch is derived from a table titled "Pixel data type parameter values and the
4772 // corresponding GL data types" in the OpenGL spec (Table 8.2 in OpenGL 4.5).
4773 switch (externalType) {
4774 case GR_GL_UNSIGNED_BYTE: return sizeof(GrGLubyte);
4775 case GR_GL_BYTE: return sizeof(GrGLbyte);
4776 case GR_GL_UNSIGNED_SHORT: return sizeof(GrGLushort);
4777 case GR_GL_SHORT: return sizeof(GrGLshort);
4778 case GR_GL_UNSIGNED_INT: return sizeof(GrGLuint);
4779 case GR_GL_INT: return sizeof(GrGLint);
4780 case GR_GL_HALF_FLOAT: return sizeof(GrGLhalf);
4781 case GR_GL_HALF_FLOAT_OES: return sizeof(GrGLhalf);
4782 case GR_GL_FLOAT: return sizeof(GrGLfloat);
4783 case GR_GL_UNSIGNED_SHORT_5_6_5: return sizeof(GrGLushort);
4784 case GR_GL_UNSIGNED_SHORT_4_4_4_4: return sizeof(GrGLushort);
4785 case GR_GL_UNSIGNED_SHORT_5_5_5_1: return sizeof(GrGLushort);
4786 case GR_GL_UNSIGNED_INT_2_10_10_10_REV: return sizeof(GrGLuint);
4787#if 0 // GL types we currently don't use. Here for future reference.
4788 case GR_GL_UNSIGNED_BYTE_3_3_2: return sizeof(GrGLubyte);
4789 case GR_GL_UNSIGNED_BYTE_2_3_3_REV: return sizeof(GrGLubyte);
4790 case GR_GL_UNSIGNED_SHORT_5_6_5_REV: return sizeof(GrGLushort);
4791 case GR_GL_UNSIGNED_SHORT_4_4_4_4_REV: return sizeof(GrGLushort);
4792 case GR_GL_UNSIGNED_SHORT_1_5_5_5_REV: return sizeof(GrGLushort);
4793 case GR_GL_UNSIGNED_INT_8_8_8_8: return sizeof(GrGLuint);
4794 case GR_GL_UNSIGNED_INT_8_8_8_8_REV: return sizeof(GrGLuint);
4795 case GR_GL_UNSIGNED_INT_10_10_10_2: return sizeof(GrGLuint);
4796 case GR_GL_UNSIGNED_INT_24_8: return sizeof(GrGLuint);
4797 case GR_GL_UNSIGNED_INT_10F_11F_11F_REV: return sizeof(GrGLuint);
4798 case GR_GL_UNSIGNED_INT_5_9_9_9_REV: return sizeof(GrGLuint);
4799 // This one is not corresponding to a GL data type and the spec just says it is 4.
4800 case GR_GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return 4;
4801#endif
4802 default: return 0;
4803 }
4804}
#define GR_GL_HALF_FLOAT
#define GR_GL_BYTE
#define GR_GL_UNSIGNED_SHORT
#define GR_GL_UNSIGNED_SHORT_5_6_5
#define GR_GL_UNSIGNED_SHORT_4_4_4_4
#define GR_GL_INT
#define GR_GL_HALF_FLOAT_OES
#define GR_GL_UNSIGNED_INT
#define GR_GL_SHORT
#define GR_GL_UNSIGNED_SHORT_5_5_5_1
#define GR_GL_UNSIGNED_BYTE
#define GR_GL_FLOAT
#define GR_GL_UNSIGNED_INT_2_10_10_10_REV
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