Begin tracking driver info in GrGLContextInfo
BUG=skia: Review URL: https://codereview.chromium.org/1165463005
This commit is contained in:
parent
5aa5ea3831
commit
1acea86914
@ -135,7 +135,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
||||
|
||||
// ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
|
||||
// and GL_RG on FBO textures.
|
||||
if (!ctxInfo.isMesa()) {
|
||||
if (kMesa_GrGLDriver != ctxInfo.driver()) {
|
||||
if (kGL_GrGLStandard == standard) {
|
||||
fTextureRedSupport = version >= GR_GL_VER(3,0) ||
|
||||
ctxInfo.hasExtension("GL_ARB_texture_rg");
|
||||
@ -274,7 +274,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
||||
// On many GPUs, map memory is very expensive, so we effectively disable it here by setting the
|
||||
// threshold to the maximum unless the client gives us a hint that map memory is cheap.
|
||||
if (fGeometryBufferMapThreshold < 0) {
|
||||
fGeometryBufferMapThreshold = ctxInfo.isChromium() ? 0 : SK_MaxS32;
|
||||
fGeometryBufferMapThreshold = kChromium_GrGLDriver == ctxInfo.driver() ? 0 : SK_MaxS32;
|
||||
}
|
||||
|
||||
if (kGL_GrGLStandard == standard) {
|
||||
|
@ -52,9 +52,8 @@ GrGLContext* GrGLContext::Create(const GrGLInterface* interface, const GrContext
|
||||
|
||||
args.fRenderer = GrGLGetRendererFromString(renderer);
|
||||
|
||||
args.fIsMesa = GrGLIsMesaFromVersionString(ver);
|
||||
|
||||
args.fIsChromium = GrGLIsChromiumFromRendererString(renderer);
|
||||
GrGLGetDriverInfo(interface->fStandard, args.fVendor, renderer, ver,
|
||||
&args.fDriver, &args.fDriverVersion);
|
||||
|
||||
args.fContextOptions = &options;
|
||||
|
||||
@ -67,8 +66,8 @@ GrGLContextInfo::GrGLContextInfo(const ConstructorArgs& args) {
|
||||
fGLSLGeneration = args.fGLSLGeneration;
|
||||
fVendor = args.fVendor;
|
||||
fRenderer = args.fRenderer;
|
||||
fIsMesa = args.fIsMesa;
|
||||
fIsChromium = args.fIsChromium;
|
||||
fDriver = args.fDriver;
|
||||
fDriverVersion = args.fDriverVersion;
|
||||
|
||||
fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*args.fContextOptions, *this, fInterface)));
|
||||
}
|
||||
|
@ -28,12 +28,10 @@ public:
|
||||
GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
|
||||
GrGLVendor vendor() const { return fVendor; }
|
||||
GrGLRenderer renderer() const { return fRenderer; }
|
||||
/** Is this a mesa-based driver. Does not mean it is the osmesa software rasterizer. */
|
||||
bool isMesa() const { return fIsMesa; }
|
||||
/** Are we running inside Chromium (using the command buffer)? We make some different tradeoffs
|
||||
about what errors to check for because queries are synchronous. We should probably expose
|
||||
this as an option for clients other than Chromium. */
|
||||
bool isChromium() const { return fIsChromium; }
|
||||
/** What driver is running our GL implementation? This is not necessarily related to the vendor.
|
||||
(e.g. Intel GPU being driven by Mesa) */
|
||||
GrGLDriver driver() const { return fDriver; }
|
||||
GrGLDriverVersion driverVersion() const { return fDriverVersion; }
|
||||
const GrGLCaps* caps() const { return fGLCaps.get(); }
|
||||
GrGLCaps* caps() { return fGLCaps; }
|
||||
bool hasExtension(const char* ext) const {
|
||||
@ -49,8 +47,8 @@ protected:
|
||||
GrGLSLGeneration fGLSLGeneration;
|
||||
GrGLVendor fVendor;
|
||||
GrGLRenderer fRenderer;
|
||||
bool fIsMesa;
|
||||
bool fIsChromium;
|
||||
GrGLDriver fDriver;
|
||||
GrGLDriverVersion fDriverVersion;
|
||||
const GrContextOptions* fContextOptions;
|
||||
};
|
||||
|
||||
@ -61,8 +59,8 @@ protected:
|
||||
GrGLSLGeneration fGLSLGeneration;
|
||||
GrGLVendor fVendor;
|
||||
GrGLRenderer fRenderer;
|
||||
bool fIsMesa;
|
||||
bool fIsChromium;
|
||||
GrGLDriver fDriver;
|
||||
GrGLDriverVersion fDriverVersion;
|
||||
SkAutoTUnref<GrGLCaps> fGLCaps;
|
||||
};
|
||||
|
||||
|
@ -270,7 +270,7 @@ GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig,
|
||||
GrPixelConfig surfaceConfig) const {
|
||||
if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig) {
|
||||
return kBGRA_8888_GrPixelConfig;
|
||||
} else if (this->glContext().isMesa() &&
|
||||
} else if (kMesa_GrGLDriver == this->glContext().driver() &&
|
||||
GrBytesPerPixel(readConfig) == 4 &&
|
||||
GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) {
|
||||
// Mesa 3D takes a slow path on when reading back BGRA from an RGBA surface and vice-versa.
|
||||
@ -1865,7 +1865,7 @@ void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
|
||||
// lots of repeated command buffer flushes when the compositor is
|
||||
// rendering with Ganesh, which is really slow; even too slow for
|
||||
// Debug mode.
|
||||
if (!this->glContext().isChromium()) {
|
||||
if (kChromium_GrGLDriver != this->glContext().driver()) {
|
||||
GrGLenum status;
|
||||
GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
|
||||
if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
|
||||
|
@ -92,24 +92,62 @@ GrGLStandard GrGLGetStandardInUseFromString(const char* versionString) {
|
||||
return kNone_GrGLStandard;
|
||||
}
|
||||
|
||||
bool GrGLIsMesaFromVersionString(const char* versionString) {
|
||||
int major, minor, mesaMajor, mesaMinor;
|
||||
void GrGLGetDriverInfo(GrGLStandard standard,
|
||||
GrGLVendor vendor,
|
||||
const char* rendererString,
|
||||
const char* versionString,
|
||||
GrGLDriver* outDriver,
|
||||
GrGLDriverVersion* outVersion) {
|
||||
int major, minor, rev, driverMajor, driverMinor;
|
||||
|
||||
GrGLStandard standard = GrGLGetStandardInUseFromString(versionString);
|
||||
*outDriver = kUnknown_GrGLDriver;
|
||||
*outVersion = GR_GL_DRIVER_UNKNOWN_VER;
|
||||
|
||||
if (0 == strcmp(rendererString, "Chromium")) {
|
||||
*outDriver = kChromium_GrGLDriver;
|
||||
return;
|
||||
}
|
||||
|
||||
if (standard == kGL_GrGLStandard) {
|
||||
int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor, &mesaMinor);
|
||||
return 4 == n;
|
||||
if (kNVIDIA_GrGLVendor == vendor) {
|
||||
*outDriver = kNVIDIA_GrGLDriver;
|
||||
int n = sscanf(versionString, "%d.%d.%d NVIDIA %d.%d",
|
||||
&major, &minor, &rev, &driverMajor, &driverMinor);
|
||||
// Some older NVIDIA drivers don't report the driver version.
|
||||
if (5 == n) {
|
||||
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int n = sscanf(versionString, "%d.%d Mesa %d.%d",
|
||||
&major, &minor, &driverMajor, &driverMinor);
|
||||
if (4 == n) {
|
||||
*outDriver = kMesa_GrGLDriver;
|
||||
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int n = sscanf(versionString, "OpenGL ES %d.%d Mesa %d.%d", &major, &minor, &mesaMajor, &mesaMinor);
|
||||
return 4 == n;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (kNVIDIA_GrGLVendor == vendor) {
|
||||
*outDriver = kNVIDIA_GrGLDriver;
|
||||
int n = sscanf(versionString, "OpenGL ES %d.%d NVIDIA %d.%d",
|
||||
&major, &minor, &driverMajor, &driverMinor);
|
||||
// Some older NVIDIA drivers don't report the driver version.
|
||||
if (4 == n) {
|
||||
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool GrGLIsChromiumFromRendererString(const char* rendererString) {
|
||||
return 0 == strcmp(rendererString, "Chromium");
|
||||
int n = sscanf(versionString, "OpenGL ES %d.%d Mesa %d.%d",
|
||||
&major, &minor, &driverMajor, &driverMinor);
|
||||
if (4 == n) {
|
||||
*outDriver = kMesa_GrGLDriver;
|
||||
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
||||
|
@ -18,14 +18,18 @@ class SkMatrix;
|
||||
|
||||
typedef uint32_t GrGLVersion;
|
||||
typedef uint32_t GrGLSLVersion;
|
||||
typedef uint32_t GrGLDriverVersion;
|
||||
|
||||
#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
||||
static_cast<int>(minor))
|
||||
#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
||||
static_cast<int>(minor))
|
||||
#define GR_GL_DRIVER_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
||||
static_cast<int>(minor))
|
||||
|
||||
#define GR_GL_INVALID_VER GR_GL_VER(0, 0)
|
||||
#define GR_GLSL_INVALID_VER GR_GL_VER(0, 0)
|
||||
#define GR_GLSL_INVALID_VER GR_GLSL_VER(0, 0)
|
||||
#define GR_GL_DRIVER_UNKNOWN_VER GR_GL_DRIVER_VER(0, 0)
|
||||
|
||||
/**
|
||||
* The Vendor and Renderer enum values are lazily updated as required.
|
||||
@ -50,6 +54,13 @@ enum GrGLRenderer {
|
||||
kOther_GrGLRenderer
|
||||
};
|
||||
|
||||
enum GrGLDriver {
|
||||
kMesa_GrGLDriver,
|
||||
kChromium_GrGLDriver,
|
||||
kNVIDIA_GrGLDriver,
|
||||
kUnknown_GrGLDriver
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@ -98,10 +109,15 @@ enum GrGLRenderer {
|
||||
GrGLVersion GrGLGetVersionFromString(const char* versionString);
|
||||
GrGLStandard GrGLGetStandardInUseFromString(const char* versionString);
|
||||
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
|
||||
bool GrGLIsMesaFromVersionString(const char* versionString);
|
||||
GrGLVendor GrGLGetVendorFromString(const char* vendorString);
|
||||
GrGLRenderer GrGLGetRendererFromString(const char* rendererString);
|
||||
bool GrGLIsChromiumFromRendererString(const char* rendererString);
|
||||
|
||||
void GrGLGetDriverInfo(GrGLStandard standard,
|
||||
GrGLVendor vendor,
|
||||
const char* rendererString,
|
||||
const char* versionString,
|
||||
GrGLDriver* outDriver,
|
||||
GrGLDriverVersion* outVersion);
|
||||
|
||||
// these variants call glGetString()
|
||||
GrGLVersion GrGLGetVersion(const GrGLInterface*);
|
||||
|
@ -429,7 +429,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
|
||||
GL_CALL(LinkProgram(programID));
|
||||
|
||||
// Calling GetProgramiv is expensive in Chromium. Assume success in release builds.
|
||||
bool checkLinked = !fGpu->ctxInfo().isChromium();
|
||||
bool checkLinked = kChromium_GrGLDriver != fGpu->ctxInfo().driver();
|
||||
#ifdef SK_DEBUG
|
||||
checkLinked = true;
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
|
||||
GR_GL_CALL(gli, CompileShader(shaderId));
|
||||
|
||||
// Calling GetShaderiv in Chromium is quite expensive. Assume success in release builds.
|
||||
bool checkCompiled = !glCtx.isChromium();
|
||||
bool checkCompiled = kChromium_GrGLDriver != glCtx.driver();
|
||||
#ifdef SK_DEBUG
|
||||
checkCompiled = true;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user