GL: Clean up workaround detection.

Use functions instead of macros for platform detection so compilation can be
checked from any platform.  Also makes the workaround detection more readable.

BUG=angleproject:3026

Change-Id: I4153f0a2a6a6d5860c7b37f7cc67561895165ed1
Reviewed-on: https://chromium-review.googlesource.com/c/1378685
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
This commit is contained in:
Geoff Lang 2018-12-14 14:17:59 -05:00 коммит произвёл Commit Bot
Родитель 70fd9b5d38
Коммит e1f742af18
2 изменённых файлов: 52 добавлений и 46 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_DRIVER_UTILS_H_
#define LIBANGLE_RENDERER_DRIVER_UTILS_H_
#include "common/platform.h"
#include "libANGLE/angletypes.h"
namespace rx
@ -94,5 +95,42 @@ bool IsSkylake(uint32_t DeviceId);
bool IsBroxton(uint32_t DeviceId);
bool IsKabylake(uint32_t DeviceId);
// Platform helpers
inline bool IsWindows()
{
#if defined(ANGLE_PLATFORM_WINDOWS)
return true;
#else
return false;
#endif
}
inline bool IsLinux()
{
#if defined(ANGLE_PLATFORM_LINUX)
return true;
#else
return false;
#endif
}
inline bool IsApple()
{
#if defined(ANGLE_PLATFORM_APPLE)
return true;
#else
return false;
#endif
}
inline bool IsAndroid()
{
#if defined(ANGLE_PLATFORM_ANDROID)
return true;
#else
return false;
#endif
}
} // namespace rx
#endif // LIBANGLE_RENDERER_DRIVER_UTILS_H_

Просмотреть файл

@ -1347,23 +1347,17 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->doesSRGBClearsOnLinearFramebufferAttachments =
functions->standard == STANDARD_GL_DESKTOP && (IsIntel(vendor) || IsAMD(vendor));
#if defined(ANGLE_PLATFORM_LINUX)
workarounds->emulateMaxVertexAttribStride =
functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor);
workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsAMD(vendor);
#endif
IsLinux() && functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor);
workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsLinux() && IsAMD(vendor);
#if defined(ANGLE_PLATFORM_APPLE)
workarounds->doWhileGLSLCausesGPUHang = true;
workarounds->useUnusedBlocksWithStandardOrSharedLayout = true;
workarounds->rewriteFloatUnaryMinusOperator = IsIntel(vendor);
#endif
workarounds->doWhileGLSLCausesGPUHang = IsApple();
workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsApple();
workarounds->rewriteFloatUnaryMinusOperator = IsApple() && IsIntel(vendor);
#if defined(ANGLE_PLATFORM_ANDROID)
// Triggers a bug on Marshmallow Adreno (4xx?) driver.
// http://anglebug.com/2046
workarounds->dontInitializeUninitializedLocals = IsQualcomm(vendor);
#endif
workarounds->dontInitializeUninitializedLocals = IsAndroid() && IsQualcomm(vendor);
workarounds->finishDoesNotCauseQueriesToBeAvailable =
functions->standard == STANDARD_GL_DESKTOP && IsNvidia(vendor);
@ -1376,13 +1370,8 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->initializeCurrentVertexAttributes = IsNvidia(vendor);
#if defined(ANGLE_PLATFORM_APPLE)
workarounds->unpackLastRowSeparatelyForPaddingInclusion = true;
workarounds->packLastRowSeparatelyForPaddingInclusion = true;
#else
workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
workarounds->packLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
#endif
workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsApple() || IsNvidia(vendor);
workarounds->packLastRowSeparatelyForPaddingInclusion = IsApple() || IsNvidia(vendor);
workarounds->removeInvariantAndCentroidForESSL3 =
functions->isAtMostGL(gl::Version(4, 1)) ||
@ -1394,8 +1383,6 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->reapplyUBOBindingsAfterUsingBinaryProgram = IsAMD(vendor);
workarounds->clampPointSize = IsNvidia(vendor);
workarounds->rewriteVectorScalarArithmetic = IsNvidia(vendor);
// TODO(oetuaho): Make this specific to the affected driver versions. Versions at least up to
@ -1406,43 +1393,24 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
// not affected.
workarounds->rewriteRepeatedAssignToSwizzled = IsNvidia(vendor);
#if defined(ANGLE_PLATFORM_ANDROID)
// TODO(jmadill): Narrow workaround range for specific devices.
workarounds->reapplyUBOBindingsAfterUsingBinaryProgram = true;
workarounds->reapplyUBOBindingsAfterUsingBinaryProgram = IsAndroid();
workarounds->clampPointSize = true;
workarounds->clampPointSize = IsAndroid() || IsNvidia(vendor);
workarounds->dontUseLoopsToInitializeVariables = !IsNvidia(vendor);
#endif
workarounds->dontUseLoopsToInitializeVariables = IsAndroid() && !IsNvidia(vendor);
workarounds->disableBlendFuncExtended = IsAMD(vendor) || IsIntel(vendor);
#if defined(ANGLE_PLATFORM_ANDROID)
if (IsQualcomm(vendor))
{
workarounds->unsizedsRGBReadPixelsDoesntTransform = true;
}
#endif // defined(ANGLE_PLATFORM_ANDROID)
workarounds->unsizedsRGBReadPixelsDoesntTransform = IsAndroid() && IsQualcomm(vendor);
}
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds)
{
VendorID vendor = GetVendorID(functions);
ANGLE_UNUSED_VARIABLE(vendor);
#if defined(ANGLE_PLATFORM_ANDROID)
if (IsQualcomm(vendor))
{
workarounds->disableProgramCachingForTransformFeedback = true;
}
#endif // defined(ANGLE_PLATFORM_ANDROID)
#if defined(ANGLE_PLATFORM_WINDOWS)
if (IsIntel(vendor))
{
workarounds->syncFramebufferBindingsOnTexImage = true;
}
#endif // defined(ANGLE_PLATFORM_WINDOWS)
workarounds->disableProgramCachingForTransformFeedback = IsAndroid() && IsQualcomm(vendor);
workarounds->syncFramebufferBindingsOnTexImage = IsWindows() && IsIntel(vendor);
}
} // namespace nativegl_gl