forked from bartvdbraak/blender
Cycles / OSL:
* Remove custom template from r52885, not needed anymore as OSL 1.3 is a requirement and we do not use a custom branch anymore.
This commit is contained in:
parent
d0ffbeec73
commit
ce40e7fe27
@ -347,43 +347,9 @@ const char *OSLShaderManager::shader_load_filepath(string filepath)
|
|||||||
return shader_load_bytecode(bytecode_hash, bytecode);
|
return shader_load_bytecode(bytecode_hash, bytecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't try this at home .. this is a template trick to use either
|
|
||||||
* LoadMemoryShader or LoadMemoryCompiledShader which are the function
|
|
||||||
* names in our custom branch and the official repository. */
|
|
||||||
|
|
||||||
template<bool C, typename T = void> struct enable_if { typedef T type; };
|
|
||||||
template<typename T> struct enable_if<false, T> { };
|
|
||||||
|
|
||||||
template<typename T, typename Sign>
|
|
||||||
struct has_LoadMemoryCompiledShader {
|
|
||||||
typedef int yes;
|
|
||||||
typedef char no;
|
|
||||||
|
|
||||||
template<typename U, U> struct type_check;
|
|
||||||
template<typename _1> static yes &chk(type_check<Sign, &_1::LoadMemoryCompiledShader>*);
|
|
||||||
template<typename > static no &chk(...);
|
|
||||||
static bool const value = sizeof(chk<T>(0)) == sizeof(yes);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
typename enable_if<has_LoadMemoryCompiledShader<T,
|
|
||||||
bool(T::*)(const char*, const char*)>::value, bool>::type
|
|
||||||
load_memory_shader(T *ss, const char *name, const char *buffer)
|
|
||||||
{
|
|
||||||
return ss->LoadMemoryCompiledShader(name, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
typename enable_if<!has_LoadMemoryCompiledShader<T,
|
|
||||||
bool(T::*)(const char*, const char*)>::value, bool>::type
|
|
||||||
load_memory_shader(T *ss, const char *name, const char *buffer)
|
|
||||||
{
|
|
||||||
return ss->LoadMemoryShader(name, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OSLShaderManager::shader_load_bytecode(const string& hash, const string& bytecode)
|
const char *OSLShaderManager::shader_load_bytecode(const string& hash, const string& bytecode)
|
||||||
{
|
{
|
||||||
load_memory_shader(ss, hash.c_str(), bytecode.c_str());
|
ss->LoadMemoryCompiledShader(hash.c_str(), bytecode.c_str());
|
||||||
|
|
||||||
/* this is a bit weak, but works */
|
/* this is a bit weak, but works */
|
||||||
OSLShaderInfo info;
|
OSLShaderInfo info;
|
||||||
|
Loading…
Reference in New Issue
Block a user