Commit ecd2e3b1 by Geoff Lang Committed by Commit Bot

GL: Reset the texture base level before uploads on Mac.

Reset the base level of textures before call glTexImage on Mac to prevent driver bugs that cause texture corruption. BUG=angleproject:3671 Change-Id: I90e94b8395a781a2142ef6be3af1d6117f084152 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1692975 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 9917988a
...@@ -691,6 +691,10 @@ angle_source_set("libANGLE") { ...@@ -691,6 +691,10 @@ angle_source_set("libANGLE") {
sources += libangle_null_sources sources += libangle_null_sources
} }
if (is_mac) {
sources += libangle_mac_sources
}
if (is_debug) { if (is_debug) {
defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ] defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
} }
......
...@@ -298,6 +298,14 @@ struct FeaturesGL : FeatureSetBase ...@@ -298,6 +298,14 @@ struct FeaturesGL : FeatureSetBase
Feature clampArrayAccess = {"clamp_array_access", FeatureCategory::OpenGLWorkarounds, Feature clampArrayAccess = {"clamp_array_access", FeatureCategory::OpenGLWorkarounds,
"Clamp uniform array access to avoid reading invalid memory.", "Clamp uniform array access to avoid reading invalid memory.",
&members, "http://anglebug.com/2978"}; &members, "http://anglebug.com/2978"};
// Reset glTexImage2D base level to workaround pixel comparison failure above Mac OS 10.12.4 on
// Intel Mac.
Feature resetTexImage2DBaseLevel = {"reset_teximage2d_base_level",
FeatureCategory::OpenGLWorkarounds,
"Reset texture base level before calling glTexImage2D to "
"work around pixel comparison failure.",
&members, "https://crbug.com/705865"};
}; };
inline FeaturesGL::FeaturesGL() = default; inline FeaturesGL::FeaturesGL() = default;
......
...@@ -157,4 +157,38 @@ int GetAndroidSDKVersion() ...@@ -157,4 +157,38 @@ int GetAndroidSDKVersion()
#endif #endif
} }
OSVersion::OSVersion() {}
OSVersion::OSVersion(int major, int minor, int patch)
: majorVersion(major), minorVersion(minor), patchVersion(patch)
{}
bool operator==(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) ==
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator!=(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) !=
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator<(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) <
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator>=(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) >=
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
#if !defined(ANGLE_PLATFORM_APPLE)
OSVersion GetMacOSVersion()
{
// Return a default version
return OSVersion(0, 0, 0);
}
#endif
} // namespace rx } // namespace rx
...@@ -129,6 +129,22 @@ inline bool IsApple() ...@@ -129,6 +129,22 @@ inline bool IsApple()
#endif #endif
} }
struct OSVersion
{
OSVersion();
OSVersion(int major, int minor, int patch);
int majorVersion = 0;
int minorVersion = 0;
int patchVersion = 0;
};
bool operator==(const OSVersion &a, const OSVersion &b);
bool operator!=(const OSVersion &a, const OSVersion &b);
bool operator<(const OSVersion &a, const OSVersion &b);
bool operator>=(const OSVersion &a, const OSVersion &b);
OSVersion GetMacOSVersion();
inline bool IsAndroid() inline bool IsAndroid()
{ {
#if defined(ANGLE_PLATFORM_ANDROID) #if defined(ANGLE_PLATFORM_ANDROID)
......
//
// Copyright (c) The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// driver_utils_mac.mm : provides mac-specific information about current driver.
#include "libANGLE/renderer/driver_utils.h"
#import <Foundation/Foundation.h>
namespace rx
{
OSVersion GetMacOSVersion()
{
OSVersion result;
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
result.majorVersion = version.majorVersion;
result.minorVersion = version.minorVersion;
result.patchVersion = version.patchVersion;
return result;
}
}
...@@ -224,6 +224,12 @@ void TextureGL::setImageHelper(const gl::Context *context, ...@@ -224,6 +224,12 @@ void TextureGL::setImageHelper(const gl::Context *context,
stateManager->bindTexture(getType(), mTextureID); stateManager->bindTexture(getType(), mTextureID);
if (features.resetTexImage2DBaseLevel.enabled)
{
// setBaseLevel doesn't ever generate errors.
(void)setBaseLevel(context, 0);
}
if (nativegl::UseTexImage2D(getType())) if (nativegl::UseTexImage2D(getType()))
{ {
ASSERT(size.depth == 1); ASSERT(size.depth == 1);
......
...@@ -1514,6 +1514,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -1514,6 +1514,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
// The WebGL conformance/uniforms/out-of-bounds-uniform-array-access test has been seen to fail // The WebGL conformance/uniforms/out-of-bounds-uniform-array-access test has been seen to fail
// on AMD and Android devices. // on AMD and Android devices.
features->clampArrayAccess.enabled = IsAndroid() || IsAMD(vendor); features->clampArrayAccess.enabled = IsAndroid() || IsAMD(vendor);
features->resetTexImage2DBaseLevel.enabled =
IsApple() && IsIntel(vendor) && GetMacOSVersion() >= OSVersion(10, 12, 4);
} }
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features) void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)
......
...@@ -802,6 +802,8 @@ libangle_gl_cgl_sources = [ ...@@ -802,6 +802,8 @@ libangle_gl_cgl_sources = [
"src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h", "src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h",
] ]
libangle_mac_sources = [ "src/libANGLE/renderer/driver_utils_mac.mm" ]
libangle_vulkan_sources = [ libangle_vulkan_sources = [
"src/libANGLE/renderer/vulkan/BufferVk.cpp", "src/libANGLE/renderer/vulkan/BufferVk.cpp",
"src/libANGLE/renderer/vulkan/BufferVk.h", "src/libANGLE/renderer/vulkan/BufferVk.h",
......
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