8#ifndef GrGLUtil_DEFINED
9#define GrGLUtil_DEFINED
26#define GR_GL_VER(major, minor) ((static_cast<uint32_t>(major) << 16) | \
27 static_cast<uint32_t>(minor))
28#define GR_GLSL_VER(major, minor) ((static_cast<uint32_t>(major) << 16) | \
29 static_cast<uint32_t>(minor))
30#define GR_GL_DRIVER_VER(major, minor, point) ((static_cast<uint64_t>(major) << 32) | \
31 (static_cast<uint64_t>(minor) << 16) | \
32 static_cast<uint64_t>(point))
34#define GR_GL_MAJOR_VER(version) (static_cast<uint32_t>(version) >> 16)
35#define GR_GL_MINOR_VER(version) (static_cast<uint32_t>(version) & 0xFFFF)
37#define GR_GL_INVALID_VER GR_GL_VER(0, 0)
38#define GR_GLSL_INVALID_VER GR_GLSL_VER(0, 0)
39#define GR_GL_DRIVER_UNKNOWN_VER GR_GL_DRIVER_VER(0, 0, 0)
244#define GR_GL_INIT_ZERO 0
245#define GR_GL_GetIntegerv(gl, e, p) \
247 *(p) = GR_GL_INIT_ZERO; \
248 GR_GL_CALL(gl, GetIntegerv(e, p)); \
251#define GR_GL_GetFloatv(gl, e, p) \
253 *(p) = GR_GL_INIT_ZERO; \
254 GR_GL_CALL(gl, GetFloatv(e, p)); \
257#define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p) \
259 *(p) = GR_GL_INIT_ZERO; \
260 GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \
263#define GR_GL_GetInternalformativ(gl, t, f, n, s, p) \
265 *(p) = GR_GL_INIT_ZERO; \
266 GR_GL_CALL(gl, GetInternalformativ(t, f, n, s, p)); \
269#define GR_GL_GetNamedFramebufferAttachmentParameteriv(gl, fb, a, pname, p) \
271 *(p) = GR_GL_INIT_ZERO; \
272 GR_GL_CALL(gl, GetNamedFramebufferAttachmentParameteriv(fb, a, pname, p)); \
275#define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p) \
277 *(p) = GR_GL_INIT_ZERO; \
278 GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \
281#define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p) \
283 *(p) = GR_GL_INIT_ZERO; \
284 GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \
287#define GR_GL_GetShaderPrecisionFormat(gl, st, pt, range, precision) \
289 (range)[0] = GR_GL_INIT_ZERO; \
290 (range)[1] = GR_GL_INIT_ZERO; \
291 (*precision) = GR_GL_INIT_ZERO; \
292 GR_GL_CALL(gl, GetShaderPrecisionFormat(st, pt, range, precision)); \
333 const char* location,
342#define GR_STRING(X) GR_STRING_IMPL(X)
343#define GR_STRING_IMPL(X) #X
348#define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
356 extern bool gCheckErrorGL;
357#define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
359 if (gCheckErrorGL) { \
360 IFACE->checkError(GR_FILE_AND_LINE_STR, #X); \
364#define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
372 extern bool gLogCallsGL;
373 #define GR_GL_LOG_CALLS_IMPL(X) \
375 SkDebugf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
377 #define GR_GL_LOG_CALLS_IMPL(X)
381#define GR_GL_CALL(IFACE, X) \
383 GR_GL_CALL_NOERRCHECK(IFACE, X); \
384 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
389#define GR_GL_CALL_NOERRCHECK(IFACE, X) \
391 (IFACE)->fFunctions.f##X; \
392 GR_GL_LOG_CALLS_IMPL(X); \
396#define GR_GL_CALL_RET(IFACE, RET, X) \
398 GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \
399 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
403#define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \
405 (RET) = (IFACE)->fFunctions.f##X; \
406 GR_GL_LOG_CALLS_IMPL(X); \
624#if defined(SK_DEBUG) || defined(GR_TEST_UTILS)
625static constexpr const char* GrGLFormatToStr(
GrGLenum glFormat) {
655 default:
return "Unknown";
#define GR_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
#define GR_GL_SRGB8_ALPHA8
#define GR_GL_STENCIL_INDEX16
#define GR_GL_COMPRESSED_ETC1_RGB8
#define GR_GL_COMPRESSED_RGB8_ETC2
#define GR_GL_LUMINANCE8_ALPHA8
#define GR_GL_LUMINANCE16F
#define GR_GL_DEPTH24_STENCIL8
#define GR_GL_STENCIL_INDEX8
#define GR_GL_COMPRESSED_RGB_S3TC_DXT1_EXT
#define GR_GL_DRIVER_UNKNOWN_VER
#define GR_GL_INVALID_VER
static constexpr size_t GrGLFormatBytesPerBlock(GrGLFormat format)
#define GR_GLSL_INVALID_VER
static constexpr bool GrGLFormatIsSRGB(GrGLFormat format)
uint64_t GrGLDriverVersion
GrGLSLVersion GrGLGetVersionFromString(const char *)
GrGLDriverInfo GrGLGetDriverInfo(const GrGLInterface *)
static constexpr int GrGLFormatStencilBits(GrGLFormat format)
GrGLenum GrToGLStencilFunc(GrStencilTest test)
static constexpr GrGLFormat GrGLFormatFromGLEnum(GrGLenum glFormat)
GrGLSLVersion GrGLGetVersion(const GrGLInterface *)
GrGLStandard GrGLGetStandardInUseFromString(const char *versionString)
static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format)
static constexpr GrColorFormatDesc GrGLFormatDesc(GrGLFormat format)
void GrGLCheckErr(const GrGLInterface *gl, const char *location, const char *call)
static constexpr uint32_t GrGLFormatChannels(GrGLFormat format)
bool GrGLFormatIsCompressed(GrGLFormat)
static constexpr bool GrGLFormatIsPackedDepthStencil(GrGLFormat format)
@ kRGB_SkColorChannelFlags
@ kRGBA_SkColorChannelFlags
@ kRed_SkColorChannelFlag
@ kGrayAlpha_SkColorChannelFlags
@ kRG_SkColorChannelFlags
@ kAlpha_SkColorChannelFlag
@ kGray_SkColorChannelFlag
uint32_t uint32_t * format
GrGLANGLEBackend fANGLEBackend
bool fIsOverCommandBuffer
GrGLSLVersion fGLSLVersion
GrGLDriverVersion fDriverVersion
GrGLRenderer fANGLERenderer
GrGLRenderer fWebGLRenderer
GrGLDriverVersion fANGLEDriverVersion