Skip to content

Commit c8676d4

Browse files
xhcaoCommit Bot
authored andcommitted
Unlimit texture size on relatively new linux
If limit texture size to a small number, application may need to reshape texture, lead to more discontinuous memory access and performance loss. Bug: angleproject:4086 Change-Id: I502a90535c2e3d13738e23827f4712a77987585e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1934048 Reviewed-by: Xinghua Cao <xinghua.cao@intel.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Xinghua Cao <xinghua.cao@intel.com>
1 parent 015cb80 commit c8676d4

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

src/libANGLE/renderer/driver_utils.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# include <sys/system_properties.h>
1717
#endif
1818

19+
#if defined(ANGLE_PLATFORM_LINUX)
20+
# include <sys/utsname.h>
21+
#endif
22+
1923
namespace rx
2024
{
2125
// Intel
@@ -202,4 +206,50 @@ OSVersion GetMacOSVersion()
202206
}
203207
#endif
204208

209+
#if defined(ANGLE_PLATFORM_LINUX)
210+
bool ParseLinuxOSVersion(const char *version, int *major, int *minor, int *patch)
211+
{
212+
errno = 0; // reset global error flag.
213+
char *next;
214+
*major = static_cast<int>(strtol(version, &next, 10));
215+
if (next == nullptr || *next != '.' || errno != 0)
216+
{
217+
return false;
218+
}
219+
220+
*minor = static_cast<int>(strtol(next + 1, &next, 10));
221+
if (next == nullptr || *next != '.' || errno != 0)
222+
{
223+
return false;
224+
}
225+
226+
*patch = static_cast<int>(strtol(next + 1, &next, 10));
227+
if (errno != 0)
228+
{
229+
return false;
230+
}
231+
232+
return true;
233+
}
234+
#endif
235+
236+
OSVersion GetLinuxOSVersion()
237+
{
238+
#if defined(ANGLE_PLATFORM_LINUX)
239+
struct utsname uname_info;
240+
if (uname(&uname_info) != 0)
241+
{
242+
return OSVersion(0, 0, 0);
243+
}
244+
245+
int majorVersion = 0, minorVersion = 0, patchVersion = 0;
246+
if (ParseLinuxOSVersion(uname_info.release, &majorVersion, &minorVersion, &patchVersion))
247+
{
248+
return OSVersion(majorVersion, minorVersion, patchVersion);
249+
}
250+
#endif
251+
252+
return OSVersion(0, 0, 0);
253+
}
254+
205255
} // namespace rx

src/libANGLE/renderer/driver_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ bool operator>=(const OSVersion &a, const OSVersion &b);
163163

164164
OSVersion GetMacOSVersion();
165165

166+
OSVersion GetLinuxOSVersion();
167+
166168
inline bool IsAndroid()
167169
{
168170
#if defined(ANGLE_PLATFORM_ANDROID)

src/libANGLE/renderer/gl/renderergl_utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,10 +1590,11 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
15901590
ANGLE_FEATURE_CONDITION(features, disableWorkerContexts,
15911591
(IsWindows() && (isIntel || isAMD)) || (IsLinux() && isNvidia));
15921592

1593+
bool limitMaxTextureSize = isIntel && IsLinux() && GetLinuxOSVersion() < OSVersion(5, 0, 0);
15931594
ANGLE_FEATURE_CONDITION(features, limitMaxTextureSizeTo4096,
1594-
IsAndroid() || (isIntel && IsLinux()));
1595+
IsAndroid() || limitMaxTextureSize);
15951596
ANGLE_FEATURE_CONDITION(features, limitMaxMSAASamplesTo4, IsAndroid());
1596-
ANGLE_FEATURE_CONDITION(features, limitMax3dArrayTextureSizeTo1024, isIntel && IsLinux());
1597+
ANGLE_FEATURE_CONDITION(features, limitMax3dArrayTextureSizeTo1024, limitMaxTextureSize);
15971598

15981599
ANGLE_FEATURE_CONDITION(features, allowClearForRobustResourceInit, IsApple());
15991600

0 commit comments

Comments
 (0)