From 1dfc4be6abeded19b50373e909282208edb18b6d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 11 Jul 2017 11:05:21 +0200 Subject: Opensubdiv: Fix compilation error with older Opensubdiv versions --- intern/opensubdiv/opensubdiv_capi.cc | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'intern') diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc index 91803551f12..0a55a432cc6 100644 --- a/intern/opensubdiv/opensubdiv_capi.cc +++ b/intern/opensubdiv/opensubdiv_capi.cc @@ -75,6 +75,16 @@ #include "MEM_guardedalloc.h" +#include +#include + +using std::string; +using std::vector; + +#define STRINGIFY_ARG(x) "" #x +#define STRINGIFY_APPEND(a, b) "" a #b +#define STRINGIFY(x) STRINGIFY_APPEND("", x) + /* **************** Types declaration **************** */ using OpenSubdiv::Osd::GLMeshInterface; @@ -147,6 +157,38 @@ typedef Mesh* tokens, + const string& str, + const string& separators, + bool skip_empty) { + size_t token_start = 0, token_length = 0; + for (size_t i = 0; i < str.length(); ++i) { + const char ch = str[i]; + if (separators.find(ch) == string::npos) { + /* Append non-separator char to a token. */ + ++token_length; + } else { + /* Append current token to the list (if any). */ + if (token_length > 0 || !skip_empty) { + string token = str.substr(token_start, token_length); + tokens->push_back(token); + } + /* Re-set token pointers, */ + token_start = i + 1; + token_length = 0; + } + } + /* Append token which might be at the end of the string. */ + if ((token_length != 0) || + (!skip_empty && token_start > 0 && + separators.find(str[token_start-1]) != string::npos)) { + string token = str.substr(token_start, token_length); + tokens->push_back(token); + } +} +#endif + struct FVarVertex { float u, v; void Clear() { @@ -385,5 +427,27 @@ int openSubdiv_supportGPUDisplay(void) int openSubdiv_getVersionHex(void) { +#if defined(OPENSUBDIV_VERSION_NUMBER) return OPENSUBDIV_VERSION_NUMBER; +#elif defined(OPENSUBDIV_VERSION_MAJOR) + return OPENSUBDIV_VERSION_MAJOR * 10000 + + OPENSUBDIV_VERSION_MINOR * 100 + + OPENSUBDIV_VERSION_PATCH; +#elif defined(OPENSUBDIV_VERSION) + const char* version = STRINGIFY(OPENSUBDIV_VERSION); + if (version[0] == 'v') { + version += 1; + } + int major = 0, minor = 0, patch = 0; + vector tokens; + stringSplit(&tokens, version, "_", true); + if (tokens.size() == 3) { + major = atoi(tokens[0].c_str()); + minor = atoi(tokens[1].c_str()); + patch = atoi(tokens[2].c_str()); + } + return major * 10000 + minor * 100 + patch; +#else + return 0; +#endif } -- cgit v1.2.3 From e26f61a2b5071ba4e587dbee62e55ad46519a5d9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 11 Jul 2017 12:16:58 +0200 Subject: Cycles: Disable OpenCL clFlush workarounds This is something which was reported to work fine by Mai, Benjamin and confirmed by myself. Disabling this workaround gains us some speedup: Before Now bmw27 04:28.42 04:07.79 classroom 09:26.48 08:54.53 fishy_cat 08:44.01 08:18.70 koro 09:17.98 08:57.18 pavillon_barcelone 12:26.64 11:52.81 Test environment is: - Ubuntu 16.04, with all updates installed - AMD RX 480 GPU - amdgpu pro driver version 17.10-450821 --- intern/cycles/device/opencl/opencl.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'intern') diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 7da690904aa..78ca377d933 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -27,6 +27,9 @@ CCL_NAMESPACE_BEGIN +/* Disable workarounds, seems to be working fine on latest drivers. */ +#define CYCLES_DISABLE_DRIVER_WORKAROUNDS + /* Define CYCLES_DISABLE_DRIVER_WORKAROUNDS to disable workaounds for testing */ #ifndef CYCLES_DISABLE_DRIVER_WORKAROUNDS /* Work around AMD driver hangs by ensuring each command is finished before doing anything else. */ -- cgit v1.2.3