--User changes

-Edits will not save back to the file in memory on render completion when preview renderer is running.

--Bug fixes
 -dc_perlin was crashing on Nvidia when using SP.
 -Duplicate images were randomly getting added to the file in memory.
 -Crash when opening an Xml with less than 2 flames in it.

--Code changes
 -Use raw array of floats in OpenCL for perlin noise, rather than float3/double3.
 -Add some default cases to dc_perlin.
 -Redo singleton pattern yet again. Deriving from a templated Singleton<T> class was creating a separate instance per module. Now only one instance of each type will ever be created and it will be wrapped in a shared_ptr which guarantees its deletion as main() exits.
This commit is contained in:
mfeemster
2016-04-13 20:59:57 -07:00
parent 7715910362
commit 0fbea60026
29 changed files with 264 additions and 220 deletions

View File

@ -176,7 +176,7 @@ FunctionMapper::FunctionMapper()
" return ratiomax;\n"
"}\n";
s_GlobalMap["SimplexNoise3D"] =
"inline real_t SimplexNoise3D(real3* v, __global real_t* p, __global real3* grad)\n"
"inline real_t SimplexNoise3D(real3* v, __global real_t* p, __global real_t* grad)\n"
"{\n"
" real3 c[4];\n"
" real_t n = 0;\n"
@ -195,6 +195,7 @@ FunctionMapper::FunctionMapper()
" c[0].z = (*v).z - z0;\n"
" int i1, j1, k1;\n"
" int i2, j2, k2;\n"
" real3 u;\n"
"\n"
" if (c[0].x >= c[0].y)\n"
" {\n"
@ -249,25 +250,28 @@ FunctionMapper::FunctionMapper()
" gi[1] = (int)p[ii + i1 + (int)p[jj + j1 + (int)p[kk + k1]]];\n"
" gi[2] = (int)p[ii + i2 + (int)p[jj + j2 + (int)p[kk + k2]]];\n"
" gi[3] = (int)p[ii + 1 + (int)p[jj + 1 + (int)p[kk + 1]]];\n"
"\n"
" for (uint corner = 0; corner < 4; corner++)\n"
" {\n"
" t = 0.6 - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z);\n"
"\n"
" if (t > 0)\n"
" {\n"
" real3 u = grad[gi[corner]];\n"
" u.x = grad[(gi[corner] * 3)];\n"
" u.y = grad[(gi[corner] * 3) + 1];\n"
" u.z = grad[(gi[corner] * 3) + 2];\n"
" t *= t;\n"
" n += t * t * (u.x * c[corner].x + u.y * c[corner].y + u.z * c[corner].z);\n"
" }\n"
" }\n"
"\n"
" return 32 * n;\n"
" return 32.0 * n;\n"
"}\n";
s_GlobalMap["PerlinNoise3D"] =
"inline real_t PerlinNoise3D(real3* v, __global real_t* p, __global real3* grad, real_t aScale, real_t fScale, int octaves)\n"
"inline real_t PerlinNoise3D(real3* v, __global real_t* p, __global real_t* grad, real_t aScale, real_t fScale, int octaves)\n"
"{\n"
" int i;\n"
" real_t n = 0, a = 1;\n"
" real_t n = 0.0, a = 1.0;\n"
" real3 u = *v;\n"
"\n"
" for (i = 0; i < octaves; i++)\n"

View File

@ -68,6 +68,8 @@ OpenCLInfo::OpenCLInfo()
}
}
SINGLETON_INSTANCE_IMPL(OpenCLInfo)
/// <summary>
/// Get a const reference to the vector of available platforms.
/// </summary>

View File

@ -17,7 +17,7 @@ namespace EmberCLns
/// This class derives from EmberReport, so the caller is able
/// to retrieve a text dump of error information if any errors occur.
/// </summary>
class EMBERCL_API OpenCLInfo : public EmberReport, public Singleton<OpenCLInfo>
class EMBERCL_API OpenCLInfo : public EmberReport
{
public:
const vector<cl::Platform>& Platforms() const;
@ -54,7 +54,7 @@ public:
return val;
}
SINGLETON_DERIVED_IMPL(OpenCLInfo);
SINGLETON_INSTANCE_DECL(OpenCLInfo);
private:
OpenCLInfo();