From 26430f1d6055b01fbe303ad2955e10d07faa2548 Mon Sep 17 00:00:00 2001 From: Jammy Zhou Date: Wed, 22 Aug 2012 14:05:45 +0800 Subject: [PATCH] Whitelist AMD Catalyst for kwin direct rendering BUG: 301103 FIXED-IN: 4.10 REVIEW: 106050 --- opengltest/opengltest.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/opengltest/opengltest.cpp b/opengltest/opengltest.cpp index eda7b51ec1..17641e2faf 100644 --- a/opengltest/opengltest.cpp +++ b/opengltest/opengltest.cpp @@ -22,7 +22,28 @@ along with this program. If not, see . #include #include #include +#include +// Command to get Catalyst release version string +// The output is similar as "String: 9.00-120629n-045581E-ATI" +#define SHELL_COMMAND "aticonfig --get-pcs-key=LDC,ReleaseVersion" + +static bool getCatalystVersion(int *first, int *second) +{ + FILE *fp = NULL; + + fp = popen(SHELL_COMMAND, "r"); + + if (!fp) + return false; + + fscanf(fp, "String: %d.%d", first, second); + + if (pclose(fp) != 0) + return false; + + return true; +} // Return 0 if we can use a direct context, 1 otherwise int main(int argc, char *argv[]) @@ -91,6 +112,19 @@ int main(int argc, char *argv[]) if (strstr((const char *)vendor, "NVIDIA")) return 0; + // Enable direct rendering for AMD Catalyst driver 8.973/8.98 and later. There are + // three kinds of Catalyst releases, major, minor and point releses. For example, + // 8.98 is one major release, 8.981 is one minor release based on 8.98, and 8.981.1 + // is one point release based on 8.981, 8.98.1 is one point release based on 8.98 + if (strstr((const char *)vendor, "ATI") || strstr((const char *)vendor, "AMD")) { + int first = 0, second = 0; + if (getCatalystVersion(&first, &second)) + if ((first > 8) || // 9.xx and future releases + ((first == 8) && (second >= 98) && (second < 100)) || // 8.xx and 8.xx.z + ((first == 8) && (second >= 973))) //8.xxy and 8.xxy.z + return 0; + } + return 1; }