зеркало из https://github.com/mozilla/gecko-dev.git
Bug 958369 - 2/5 - Make GLVendor and GLRenderer typed enums - r=jgilbert
This commit is contained in:
Родитель
b05e26dc69
Коммит
f02a9b87ea
|
@ -2151,7 +2151,7 @@ WebGLContext::LinkProgram(WebGLProgram *program)
|
|||
// Bug 750527
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
updateInfoSucceeded &&
|
||||
gl->Vendor() == gl::GLContext::VendorNVIDIA)
|
||||
gl->Vendor() == gl::GLVendor::NVIDIA)
|
||||
{
|
||||
if (program == mCurrentProgram)
|
||||
gl->fUseProgram(progname);
|
||||
|
@ -3118,7 +3118,7 @@ WebGLContext::CompileShader(WebGLShader *shader)
|
|||
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->Vendor() == gl::GLContext::VendorNVIDIA) {
|
||||
if (gl->Vendor() == gl::GLVendor::NVIDIA) {
|
||||
// Work around bug 890432
|
||||
resources.MaxExpressionComplexity = 1000;
|
||||
}
|
||||
|
@ -3222,12 +3222,12 @@ WebGLContext::CompileShader(WebGLShader *shader)
|
|||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
// Work around bug 665578 and bug 769810
|
||||
if (gl->Vendor() == gl::GLContext::VendorATI) {
|
||||
if (gl->Vendor() == gl::GLVendor::ATI) {
|
||||
compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
|
||||
}
|
||||
|
||||
// Work around bug 735560
|
||||
if (gl->Vendor() == gl::GLContext::VendorIntel) {
|
||||
if (gl->Vendor() == gl::GLVendor::Intel) {
|
||||
compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -980,7 +980,7 @@ WebGLContext::InitAndValidateGL()
|
|||
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Vendor() == gl::GLContext::VendorATI) {
|
||||
gl->Vendor() == gl::GLVendor::ATI) {
|
||||
// The Mac ATI driver, in all known OSX version up to and including 10.8,
|
||||
// renders points sprites upside-down. Apple bug 11778921
|
||||
gl->fPointParameterf(LOCAL_GL_POINT_SPRITE_COORD_ORIGIN, LOCAL_GL_LOWER_LEFT);
|
||||
|
|
|
@ -724,7 +724,7 @@ void WebGLContext::Draw_cleanup()
|
|||
}
|
||||
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
if (gl->Renderer() == gl::GLContext::RendererTegra) {
|
||||
if (gl->Renderer() == gl::GLRenderer::Tegra) {
|
||||
mDrawCallsSinceLastFlush++;
|
||||
|
||||
if (mDrawCallsSinceLastFlush >= MAX_DRAW_CALLS_SINCE_FLUSH) {
|
||||
|
|
|
@ -195,7 +195,7 @@ WebGLRenderbuffer::GetRenderbufferParameter(GLenum target, GLenum pname) const {
|
|||
case LOCAL_GL_RENDERBUFFER_STENCIL_SIZE: {
|
||||
if (NeedsDepthStencilEmu(mContext->gl, InternalFormatForGL())) {
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Renderer() == GLContext::RendererTegra)
|
||||
gl->Renderer() == GLRenderer::Tegra)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
|
|
@ -257,8 +257,8 @@ GLContext::GLContext(const SurfaceCaps& caps,
|
|||
mContextLost(false),
|
||||
mVersion(0),
|
||||
mProfile(ContextProfile::Unknown),
|
||||
mVendor(-1),
|
||||
mRenderer(-1),
|
||||
mVendor(GLVendor::Other),
|
||||
mRenderer(GLRenderer::Other),
|
||||
mHasRobustness(false),
|
||||
#ifdef DEBUG
|
||||
mGLError(LOCAL_GL_NO_ERROR),
|
||||
|
@ -514,7 +514,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
if (!glVendorString)
|
||||
mInitialized = false;
|
||||
|
||||
const char *vendorMatchStrings[VendorOther] = {
|
||||
const char *vendorMatchStrings[size_t(GLVendor::Other)] = {
|
||||
"Intel",
|
||||
"NVIDIA",
|
||||
"ATI",
|
||||
|
@ -523,10 +523,10 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
"nouveau"
|
||||
};
|
||||
|
||||
mVendor = VendorOther;
|
||||
for (int i = 0; i < VendorOther; ++i) {
|
||||
mVendor = GLVendor::Other;
|
||||
for (size_t i = 0; i < size_t(GLVendor::Other); ++i) {
|
||||
if (DoesStringMatch(glVendorString, vendorMatchStrings[i])) {
|
||||
mVendor = i;
|
||||
mVendor = GLVendor(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
if (!glRendererString)
|
||||
mInitialized = false;
|
||||
|
||||
const char *rendererMatchStrings[RendererOther] = {
|
||||
const char *rendererMatchStrings[size_t(GLRenderer::Other)] = {
|
||||
"Adreno 200",
|
||||
"Adreno 205",
|
||||
"Adreno (TM) 205",
|
||||
|
@ -548,10 +548,10 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
"Android Emulator"
|
||||
};
|
||||
|
||||
mRenderer = RendererOther;
|
||||
for (int i = 0; i < RendererOther; ++i) {
|
||||
mRenderer = GLRenderer::Other;
|
||||
for (size_t i = 0; i < size_t(GLRenderer::Other); ++i) {
|
||||
if (DoesStringMatch(glRendererString, rendererMatchStrings[i])) {
|
||||
mRenderer = i;
|
||||
mRenderer = GLRenderer(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
#ifdef DEBUG
|
||||
static bool firstRun = true;
|
||||
if (firstRun && DebugMode()) {
|
||||
const char *vendors[VendorOther] = {
|
||||
const char *vendors[size_t(GLVendor::Other)] = {
|
||||
"Intel",
|
||||
"NVIDIA",
|
||||
"ATI",
|
||||
|
@ -584,9 +584,9 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
};
|
||||
|
||||
MOZ_ASSERT(glVendorString);
|
||||
if (mVendor < VendorOther) {
|
||||
if (mVendor < GLVendor::Other) {
|
||||
printf_stderr("OpenGL vendor ('%s') recognized as: %s\n",
|
||||
glVendorString, vendors[mVendor]);
|
||||
glVendorString, vendors[size_t(mVendor)]);
|
||||
} else {
|
||||
printf_stderr("OpenGL vendor ('%s') unrecognized\n", glVendorString);
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
|
||||
// Disable extensions with partial or incorrect support.
|
||||
if (WorkAroundDriverBugs()) {
|
||||
if (Renderer() == RendererAdrenoTM320) {
|
||||
if (Renderer() == GLRenderer::AdrenoTM320) {
|
||||
MarkUnsupported(GLFeature::standard_derivatives);
|
||||
}
|
||||
|
||||
|
@ -607,7 +607,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
// The Mac Nvidia driver, for versions up to and including 10.8, don't seem
|
||||
// to properly support this. See 814839
|
||||
// this has been fixed in Mac OS X 10.9. See 907946
|
||||
if (Vendor() == gl::GLContext::VendorNVIDIA &&
|
||||
if (Vendor() == gl::GLVendor::NVIDIA &&
|
||||
!nsCocoaFeatures::OnMavericksOrLater())
|
||||
{
|
||||
MarkUnsupported(GLFeature::depth_texture);
|
||||
|
@ -1031,14 +1031,14 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
|
||||
#ifdef XP_MACOSX
|
||||
if (mWorkAroundDriverBugs) {
|
||||
if (mVendor == VendorIntel) {
|
||||
if (mVendor == GLVendor::Intel) {
|
||||
// see bug 737182 for 2D textures, bug 684882 for cube map textures.
|
||||
mMaxTextureSize = std::min(mMaxTextureSize, 4096);
|
||||
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 512);
|
||||
// for good measure, we align renderbuffers on what we do for 2D textures
|
||||
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
|
||||
mNeedsTextureSizeChecks = true;
|
||||
} else if (mVendor == VendorNVIDIA) {
|
||||
} else if (mVendor == GLVendor::NVIDIA) {
|
||||
if (nsCocoaFeatures::OnMountainLionOrLater()) {
|
||||
// See bug 879656. 8192 fails, 8191 works.
|
||||
mMaxTextureSize = std::min(mMaxTextureSize, 8191);
|
||||
|
@ -1057,7 +1057,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
#endif
|
||||
#ifdef MOZ_X11
|
||||
if (mWorkAroundDriverBugs &&
|
||||
mVendor == VendorNouveau) {
|
||||
mVendor == GLVendor::Nouveau) {
|
||||
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
|
||||
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048);
|
||||
mNeedsTextureSizeChecks = true;
|
||||
|
@ -1116,14 +1116,14 @@ GLContext::InitExtensions()
|
|||
InitializeExtensionsBitSet(mAvailableExtensions, extensions, sExtensionNames, firstRun && DebugMode());
|
||||
|
||||
if (WorkAroundDriverBugs() &&
|
||||
Vendor() == VendorQualcomm) {
|
||||
Vendor() == GLVendor::Qualcomm) {
|
||||
|
||||
// Some Adreno drivers do not report GL_OES_EGL_sync, but they really do support it.
|
||||
MarkExtensionSupported(OES_EGL_sync);
|
||||
}
|
||||
|
||||
if (WorkAroundDriverBugs() &&
|
||||
Renderer() == RendererAndroidEmulator) {
|
||||
Renderer() == GLRenderer::AndroidEmulator) {
|
||||
// the Android emulator, which we use to run B2G reftests on,
|
||||
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
|
||||
// support it (tautologically, as it only runs on desktop GL).
|
||||
|
|
|
@ -120,6 +120,28 @@ MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
|
|||
OpenGLES
|
||||
MOZ_END_ENUM_CLASS(ContextProfile)
|
||||
|
||||
MOZ_BEGIN_ENUM_CLASS(GLVendor)
|
||||
Intel,
|
||||
NVIDIA,
|
||||
ATI,
|
||||
Qualcomm,
|
||||
Imagination,
|
||||
Nouveau,
|
||||
Other
|
||||
MOZ_END_ENUM_CLASS(GLVendor)
|
||||
|
||||
MOZ_BEGIN_ENUM_CLASS(GLRenderer)
|
||||
Adreno200,
|
||||
Adreno205,
|
||||
AdrenoTM205,
|
||||
AdrenoTM320,
|
||||
SGX530,
|
||||
SGX540,
|
||||
Tegra,
|
||||
AndroidEmulator,
|
||||
Other
|
||||
MOZ_END_ENUM_CLASS(GLRenderer)
|
||||
|
||||
class GLContext
|
||||
: public GLLibraryLoader
|
||||
, public GenericAtomicRefCounted
|
||||
|
@ -128,29 +150,6 @@ class GLContext
|
|||
// basic enums
|
||||
public:
|
||||
|
||||
enum {
|
||||
VendorIntel,
|
||||
VendorNVIDIA,
|
||||
VendorATI,
|
||||
VendorQualcomm,
|
||||
VendorImagination,
|
||||
VendorNouveau,
|
||||
VendorOther
|
||||
};
|
||||
|
||||
enum {
|
||||
RendererAdreno200,
|
||||
RendererAdreno205,
|
||||
RendererAdrenoTM205,
|
||||
RendererAdrenoTM320,
|
||||
RendererSGX530,
|
||||
RendererSGX540,
|
||||
RendererTegra,
|
||||
RendererAndroidEmulator,
|
||||
RendererOther
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// basic getters
|
||||
public:
|
||||
|
@ -255,11 +254,11 @@ public:
|
|||
return mVersionString.get();
|
||||
}
|
||||
|
||||
int Vendor() const {
|
||||
GLVendor Vendor() const {
|
||||
return mVendor;
|
||||
}
|
||||
|
||||
int Renderer() const {
|
||||
GLRenderer Renderer() const {
|
||||
return mRenderer;
|
||||
}
|
||||
|
||||
|
@ -305,8 +304,8 @@ protected:
|
|||
nsCString mVersionString;
|
||||
ContextProfile mProfile;
|
||||
|
||||
int32_t mVendor;
|
||||
int32_t mRenderer;
|
||||
GLVendor mVendor;
|
||||
GLRenderer mRenderer;
|
||||
|
||||
inline void SetProfileVersion(ContextProfile profile, unsigned int version) {
|
||||
MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before initialization!");
|
||||
|
@ -814,7 +813,7 @@ public:
|
|||
// bug 744888
|
||||
if (WorkAroundDriverBugs() &&
|
||||
!data &&
|
||||
Vendor() == VendorNVIDIA)
|
||||
Vendor() == GLVendor::NVIDIA)
|
||||
{
|
||||
char c = 0;
|
||||
fBufferSubData(target, size-1, 1, &c);
|
||||
|
|
|
@ -378,7 +378,7 @@ ReadPixelsIntoImageSurface(GLContext* gl, gfxImageSurface* dest) {
|
|||
// RGBA reads to RGBA images from no-alpha buffers.
|
||||
#ifdef XP_MACOSX
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Vendor() == gl::GLContext::VendorNVIDIA &&
|
||||
gl->Vendor() == gl::GLVendor::NVIDIA &&
|
||||
dest->Format() == gfxImageFormatARGB32 &&
|
||||
width && height)
|
||||
{
|
||||
|
|
|
@ -321,7 +321,7 @@ WantsSmallTiles(GLContext* gl)
|
|||
|
||||
// We can't use small tiles on the SGX 540, because of races in texture upload.
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Renderer() == GLContext::RendererSGX540)
|
||||
gl->Renderer() == GLRenderer::SGX540)
|
||||
return false;
|
||||
|
||||
// Don't use small tiles otherwise. (If we implement incremental texture upload,
|
||||
|
|
|
@ -106,16 +106,16 @@ CanUploadSubTextures(GLContext* gl)
|
|||
|
||||
// There are certain GPUs that we don't want to use glTexSubImage2D on
|
||||
// because that function can be very slow and/or buggy
|
||||
if (gl->Renderer() == GLContext::RendererAdreno200 ||
|
||||
gl->Renderer() == GLContext::RendererAdreno205)
|
||||
if (gl->Renderer() == GLRenderer::Adreno200 ||
|
||||
gl->Renderer() == GLRenderer::Adreno205)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// On PowerVR glTexSubImage does a readback, so it will be slower
|
||||
// than just doing a glTexImage2D() directly. i.e. 26ms vs 10ms
|
||||
if (gl->Renderer() == GLContext::RendererSGX540 ||
|
||||
gl->Renderer() == GLContext::RendererSGX530)
|
||||
if (gl->Renderer() == GLRenderer::SGX540 ||
|
||||
gl->Renderer() == GLRenderer::SGX530)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -594,8 +594,8 @@ CanUploadNonPowerOfTwo(GLContext* gl)
|
|||
return true;
|
||||
|
||||
// Some GPUs driver crash when uploading non power of two 565 textures.
|
||||
return gl->Renderer() != GLContext::RendererAdreno200 &&
|
||||
gl->Renderer() != GLContext::RendererAdreno205;
|
||||
return gl->Renderer() != GLRenderer::Adreno200 &&
|
||||
gl->Renderer() != GLRenderer::Adreno205;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче