Commit e1f742af by Geoff Lang Committed by Commit Bot

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: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 70fd9b5d
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_DRIVER_UTILS_H_ #ifndef LIBANGLE_RENDERER_DRIVER_UTILS_H_
#define LIBANGLE_RENDERER_DRIVER_UTILS_H_ #define LIBANGLE_RENDERER_DRIVER_UTILS_H_
#include "common/platform.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
namespace rx namespace rx
...@@ -94,5 +95,42 @@ bool IsSkylake(uint32_t DeviceId); ...@@ -94,5 +95,42 @@ bool IsSkylake(uint32_t DeviceId);
bool IsBroxton(uint32_t DeviceId); bool IsBroxton(uint32_t DeviceId);
bool IsKabylake(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 } // namespace rx
#endif // LIBANGLE_RENDERER_DRIVER_UTILS_H_ #endif // LIBANGLE_RENDERER_DRIVER_UTILS_H_
...@@ -1347,23 +1347,17 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround ...@@ -1347,23 +1347,17 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->doesSRGBClearsOnLinearFramebufferAttachments = workarounds->doesSRGBClearsOnLinearFramebufferAttachments =
functions->standard == STANDARD_GL_DESKTOP && (IsIntel(vendor) || IsAMD(vendor)); functions->standard == STANDARD_GL_DESKTOP && (IsIntel(vendor) || IsAMD(vendor));
#if defined(ANGLE_PLATFORM_LINUX)
workarounds->emulateMaxVertexAttribStride = workarounds->emulateMaxVertexAttribStride =
functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor); IsLinux() && functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor);
workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsAMD(vendor); workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsLinux() && IsAMD(vendor);
#endif
#if defined(ANGLE_PLATFORM_APPLE) workarounds->doWhileGLSLCausesGPUHang = IsApple();
workarounds->doWhileGLSLCausesGPUHang = true; workarounds->useUnusedBlocksWithStandardOrSharedLayout = IsApple();
workarounds->useUnusedBlocksWithStandardOrSharedLayout = true; workarounds->rewriteFloatUnaryMinusOperator = IsApple() && IsIntel(vendor);
workarounds->rewriteFloatUnaryMinusOperator = IsIntel(vendor);
#endif
#if defined(ANGLE_PLATFORM_ANDROID)
// Triggers a bug on Marshmallow Adreno (4xx?) driver. // Triggers a bug on Marshmallow Adreno (4xx?) driver.
// http://anglebug.com/2046 // http://anglebug.com/2046
workarounds->dontInitializeUninitializedLocals = IsQualcomm(vendor); workarounds->dontInitializeUninitializedLocals = IsAndroid() && IsQualcomm(vendor);
#endif
workarounds->finishDoesNotCauseQueriesToBeAvailable = workarounds->finishDoesNotCauseQueriesToBeAvailable =
functions->standard == STANDARD_GL_DESKTOP && IsNvidia(vendor); functions->standard == STANDARD_GL_DESKTOP && IsNvidia(vendor);
...@@ -1376,13 +1370,8 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround ...@@ -1376,13 +1370,8 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->initializeCurrentVertexAttributes = IsNvidia(vendor); workarounds->initializeCurrentVertexAttributes = IsNvidia(vendor);
#if defined(ANGLE_PLATFORM_APPLE) workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsApple() || IsNvidia(vendor);
workarounds->unpackLastRowSeparatelyForPaddingInclusion = true; workarounds->packLastRowSeparatelyForPaddingInclusion = IsApple() || IsNvidia(vendor);
workarounds->packLastRowSeparatelyForPaddingInclusion = true;
#else
workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
workarounds->packLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
#endif
workarounds->removeInvariantAndCentroidForESSL3 = workarounds->removeInvariantAndCentroidForESSL3 =
functions->isAtMostGL(gl::Version(4, 1)) || functions->isAtMostGL(gl::Version(4, 1)) ||
...@@ -1394,8 +1383,6 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround ...@@ -1394,8 +1383,6 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
workarounds->reapplyUBOBindingsAfterUsingBinaryProgram = IsAMD(vendor); workarounds->reapplyUBOBindingsAfterUsingBinaryProgram = IsAMD(vendor);
workarounds->clampPointSize = IsNvidia(vendor);
workarounds->rewriteVectorScalarArithmetic = IsNvidia(vendor); workarounds->rewriteVectorScalarArithmetic = IsNvidia(vendor);
// TODO(oetuaho): Make this specific to the affected driver versions. Versions at least up to // 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 ...@@ -1406,43 +1393,24 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
// not affected. // not affected.
workarounds->rewriteRepeatedAssignToSwizzled = IsNvidia(vendor); workarounds->rewriteRepeatedAssignToSwizzled = IsNvidia(vendor);
#if defined(ANGLE_PLATFORM_ANDROID)
// TODO(jmadill): Narrow workaround range for specific devices. // 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); workarounds->dontUseLoopsToInitializeVariables = IsAndroid() && !IsNvidia(vendor);
#endif
workarounds->disableBlendFuncExtended = IsAMD(vendor) || IsIntel(vendor); workarounds->disableBlendFuncExtended = IsAMD(vendor) || IsIntel(vendor);
#if defined(ANGLE_PLATFORM_ANDROID) workarounds->unsizedsRGBReadPixelsDoesntTransform = IsAndroid() && IsQualcomm(vendor);
if (IsQualcomm(vendor))
{
workarounds->unsizedsRGBReadPixelsDoesntTransform = true;
}
#endif // defined(ANGLE_PLATFORM_ANDROID)
} }
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds) void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds)
{ {
VendorID vendor = GetVendorID(functions); 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) workarounds->disableProgramCachingForTransformFeedback = IsAndroid() && IsQualcomm(vendor);
if (IsIntel(vendor)) workarounds->syncFramebufferBindingsOnTexImage = IsWindows() && IsIntel(vendor);
{
workarounds->syncFramebufferBindingsOnTexImage = true;
}
#endif // defined(ANGLE_PLATFORM_WINDOWS)
} }
} // namespace nativegl_gl } // namespace nativegl_gl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment