--User changes

-Add variations changes to the list of functionality that can be applied to all xforms using the Select tab.
 -Allow for graphical affine adjustments to apply to multiple selected xforms.
 -Slight optimization of the pie variation.
 -Undo state is only saved when the render completes and the mouse buttons are released. This helps avoid intermediate steps for quickly completing renders while dragging.
 -Add some keyboard shortcuts for toolbar and menu items.
 -Make info tab tree always expanded.

--Bug fixes
 -Make precalcs for all hypertile variations safer by using Zeps() for denominators.
 -Changing the current xform with more than one selected would set all xform's color index value that of the current one.
 -Use hard found palette path information for randoms as well.
 -OpenCL build and assignment errors for Z value in epispiral variation.
 -Unitialized local variables in hexaplay3D, crob, pRose3D.

--Code changes
 -Change static member variables from m_ to s_.
 -Get rid of excessive endl and replace with "\n".
 -Remove old IMAGEGL2D define from before Nvidia supported OpenCL 1.2.
 -Remove old CriticalSection code and use std::recursive_mutex.
 -Make Affine2D Rotate() and RotateTrans() take radians instead of angles.
 -More C++11 work.
 -General cleanup.
This commit is contained in:
mfeemster
2016-02-11 21:38:21 -08:00
parent a345e2d5e1
commit a800b08b67
69 changed files with 981 additions and 1094 deletions

View File

@ -3,39 +3,39 @@
namespace EmberCLns
{
std::unordered_map<string, string> FunctionMapper::m_GlobalMap;
std::unordered_map<string, string> FunctionMapper::s_GlobalMap;
FunctionMapper::FunctionMapper()
{
if (m_GlobalMap.empty())
if (s_GlobalMap.empty())
{
m_GlobalMap["LRint"] =
s_GlobalMap["LRint"] =
"inline real_t LRint(real_t x)\n"
"{\n"
" intPrec temp = (x >= 0.0 ? (intPrec)(x + 0.5) : (intPrec)(x - 0.5));\n"
" return (real_t)temp;\n"
"}\n";
m_GlobalMap["Round"] =
s_GlobalMap["Round"] =
"inline real_t Round(real_t r)\n"
"{\n"
" return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);\n"
"}\n";
m_GlobalMap["Sign"] =
s_GlobalMap["Sign"] =
"inline real_t Sign(real_t v)\n"
"{\n"
" return (v < 0.0) ? -1 : (v > 0.0) ? 1 : 0.0;\n"
"}\n";
m_GlobalMap["SignNz"] =
s_GlobalMap["SignNz"] =
"inline real_t SignNz(real_t v)\n"
"{\n"
" return (v < 0.0) ? -1.0 : 1.0;\n"
"}\n";
m_GlobalMap["Sqr"] =
s_GlobalMap["Sqr"] =
"inline real_t Sqr(real_t v)\n"
"{\n"
" return v * v;\n"
"}\n";
m_GlobalMap["SafeSqrt"] =
s_GlobalMap["SafeSqrt"] =
"inline real_t SafeSqrt(real_t x)\n"
"{\n"
" if (x <= 0.0)\n"
@ -43,7 +43,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return sqrt(x);\n"
"}\n";
m_GlobalMap["SafeDivInv"] =
s_GlobalMap["SafeDivInv"] =
"inline real_t SafeDivInv(real_t q, real_t r)\n"
"{\n"
" if (r < EPS)\n"
@ -51,81 +51,81 @@ FunctionMapper::FunctionMapper()
"\n"
" return q / r;\n"
"}\n";
m_GlobalMap["Cube"] =
s_GlobalMap["Cube"] =
"inline real_t Cube(real_t v)\n"
"{\n"
" return v * v * v;\n"
"}\n";
m_GlobalMap["Hypot"] =
s_GlobalMap["Hypot"] =
"inline real_t Hypot(real_t x, real_t y)\n"
"{\n"
" return sqrt(SQR(x) + SQR(y));\n"
"}\n";
m_GlobalMap["Spread"] =
s_GlobalMap["Spread"] =
"inline real_t Spread(real_t x, real_t y)\n"
"{\n"
" return Hypot(x, y) * ((x) > 0.0 ? 1.0 : -1.0);\n"
"}\n";
m_GlobalMap["Powq4"] =
s_GlobalMap["Powq4"] =
"inline real_t Powq4(real_t x, real_t y)\n"
"{\n"
" return pow(fabs(x), y) * SignNz(x);\n"
"}\n";
m_GlobalMap["Powq4c"] =
s_GlobalMap["Powq4c"] =
"inline real_t Powq4c(real_t x, real_t y)\n"
"{\n"
" return y == 1.0 ? x : Powq4(x, y);\n"
"}\n";
m_GlobalMap["Zeps"] =
s_GlobalMap["Zeps"] =
"inline real_t Zeps(real_t x)\n"
"{\n"
" return x == 0.0 ? EPS : x;\n"
"}\n";
m_GlobalMap["Lerp"] =
s_GlobalMap["Lerp"] =
"inline real_t Lerp(real_t a, real_t b, real_t p)\n"
"{\n"
" return a + (b - a) * p;\n"
"}\n";
m_GlobalMap["Fabsmod"] =
s_GlobalMap["Fabsmod"] =
"inline real_t Fabsmod(real_t v)\n"
"{\n"
" real_t dummy;\n"
"\n"
" return modf(v, &dummy);\n"
"}\n";
m_GlobalMap["Fosc"] =
s_GlobalMap["Fosc"] =
"inline real_t Fosc(real_t p, real_t amp, real_t ph)\n"
"{\n"
" return 0.5 - cos(p * amp + ph) * 0.5;\n"
"}\n";
m_GlobalMap["Foscn"] =
s_GlobalMap["Foscn"] =
"inline real_t Foscn(real_t p, real_t ph)\n"
"{\n"
" return 0.5 - cos(p + ph) * 0.5;\n"
"}\n";
m_GlobalMap["LogScale"] =
s_GlobalMap["LogScale"] =
"inline real_t LogScale(real_t x)\n"
"{\n"
" return x == 0.0 ? 0.0 : log((fabs(x) + 1) * M_E) * SignNz(x) / M_E;\n"
"}\n";
m_GlobalMap["LogMap"] =
s_GlobalMap["LogMap"] =
"inline real_t LogMap(real_t x)\n"
"{\n"
" return x == 0.0 ? 0.0 : (M_E + log(x * M_E)) * 0.25 * SignNz(x);\n"
"}\n";
m_GlobalMap["ClampGte"] =
s_GlobalMap["ClampGte"] =
"inline real_t ClampGte(real_t val, real_t gte)\n"
"{\n"
" return (val < gte) ? gte : val;\n"
"}\n";
m_GlobalMap["Swap"] =
s_GlobalMap["Swap"] =
"inline void Swap(real_t* val1, real_t* val2)\n"
"{\n"
" real_t tmp = *val1;\n"
" *val1 = *val2;\n"
" *val2 = tmp;\n"
"}\n";
m_GlobalMap["Vratio"] =
s_GlobalMap["Vratio"] =
"inline real_t Vratio(real2* p, real2* q, real2* u)\n"
"{\n"
" real2 pmq = *p - *q;\n"
@ -135,7 +135,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / Zeps(SQR(pmq.x) + SQR(pmq.y));\n"
"}\n";
m_GlobalMap["Closest"] =
s_GlobalMap["Closest"] =
"inline int Closest(real2* p, int n, real2* u)\n"
"{\n"
" real_t d2;\n"
@ -155,7 +155,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return j;\n"
"}\n";
m_GlobalMap["Voronoi"] =
s_GlobalMap["Voronoi"] =
"inline real_t Voronoi(real2* p, int n, int q, real2* u)\n"
"{\n"
" real_t ratio;\n"
@ -175,7 +175,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return ratiomax;\n"
"}\n";
m_GlobalMap["SimplexNoise3D"] =
s_GlobalMap["SimplexNoise3D"] =
"inline real_t SimplexNoise3D(real3* v, __global real_t* p, __global real3* grad)\n"
"{\n"
" real3 c[4];\n"
@ -263,7 +263,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return 32 * n;\n"
"}\n";
m_GlobalMap["PerlinNoise3D"] =
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"
"{\n"
" int i;\n"
@ -281,11 +281,11 @@ FunctionMapper::FunctionMapper()
"\n"
" return n;\n"
"}\n";
m_GlobalMap["JacobiElliptic"] =
s_GlobalMap["JacobiElliptic"] =
"inline void JacobiElliptic(real_t uu, real_t emmc, real_t* sn, real_t* cn, real_t* dn)\n"
"{\n"
" real_t CA = 0.0003;\n"
" real_t a, b, c, d, em[13], en[13];\n"
" real_t a, b, c, d = 1, em[13], en[13];\n"
" int bo;\n"
" int l;\n"
" int ii;\n"
@ -371,11 +371,16 @@ FunctionMapper::FunctionMapper()
}
}
/// <summary>
/// Get a pointer to the text of the global function whose name is the passed in string.
/// </summary>
/// <param name="func">The function name to retrieve</param>
/// <returns>A pointer to the function body string if found, else nullptr.</returns>
const string* FunctionMapper::GetGlobalFunc(const string& func)
{
const auto& text = m_GlobalMap.find(func);
const auto& text = s_GlobalMap.find(func);
if (text != m_GlobalMap.end())
if (text != s_GlobalMap.end())
return &text->second;
else
return nullptr;

View File

@ -16,6 +16,6 @@ public:
static const string* GetGlobalFunc(const string& func);
private:
static std::unordered_map<string, string> m_GlobalMap;
static std::unordered_map<string, string> s_GlobalMap;
};
}

View File

@ -575,7 +575,7 @@ string IterOpenCLKernelCreator<T>::GlobalFunctionsString(const Ember<T>& ember)
for (auto& funcName : funcNames)
if (auto text = m_FunctionMapper.GetGlobalFunc(funcName))
os << *text << endl;
os << *text << "\n";
return os.str();
}
@ -643,7 +643,7 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(const Ember<T>& ember, pair<
if (!parVar->Params()[k].IsState())
{
if (doString)
os << "#define " << ToUpper(parVar->Params()[k].Name()) << "_" << i << " " << size << endl;//Uniquely identify this param in this variation in this xform.
os << "#define " << ToUpper(parVar->Params()[k].Name()) << "_" << i << " " << size << "\n";//Uniquely identify this param in this variation in this xform.
auto elements = parVar->Params()[k].Size() / sizeof(T);
@ -710,7 +710,7 @@ void IterOpenCLKernelCreator<T>::SharedDataIndexDefines(const Ember<T>& ember, p
if (auto dataInfo = varFuncs->GetSharedData(s))///Will contain a name, pointer to data, and size of the data in units of sizeof(T).
{
if (doString)
os << "#define " << ToUpper(name) << " " << offset << endl;
os << "#define " << ToUpper(name) << " " << offset << "\n";
if (doVals)
params.second.insert(params.second.end(), dataInfo->first, dataInfo->first + dataInfo->second);

View File

@ -57,12 +57,12 @@ typedef void (*KernelFuncPointer) (size_t gridWidth, size_t gridHeight, size_t b
static void OpenCLSim(size_t gridWidth, size_t gridHeight, size_t blockWidth, size_t blockHeight, KernelFuncPointer func)
{
cout << "OpenCLSim(): " << endl;
cout << " Params: " << endl;
cout << " gridW: " << gridWidth << endl;
cout << " gridH: " << gridHeight << endl;
cout << " blockW: " << blockWidth << endl;
cout << " blockH: " << blockHeight << endl;
cout << "OpenCLSim(): ";
cout << "\n Params: ";
cout << "\n gridW: " << gridWidth;
cout << "\n gridH: " << gridHeight;
cout << "\n blockW: " << blockWidth;
cout << "\n blockH: " << blockHeight;
for (size_t i = 0; i < gridHeight; i += blockHeight)
{

View File

@ -264,35 +264,35 @@ string OpenCLInfo::DumpInfo() const
for (size_t platform = 0; platform < m_Platforms.size(); platform++)
{
os << "Platform " << platform << ": " << PlatformName(platform) << endl;
os << "Platform " << platform << ": " << PlatformName(platform) << "\n";
for (size_t device = 0; device < m_Devices[platform].size(); device++)
{
os << "Device " << device << ": " << DeviceName(platform, device) << endl;
os << "CL_DEVICE_OPENCL_C_VERSION: " << GetInfo<string>(platform, device, CL_DEVICE_OPENCL_C_VERSION) << endl;
os << "CL_DEVICE_LOCAL_MEM_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_LOCAL_MEM_SIZE) << endl;
os << "CL_DEVICE_LOCAL_MEM_TYPE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_LOCAL_MEM_TYPE) << endl;
os << "CL_DEVICE_MAX_COMPUTE_UNITS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_COMPUTE_UNITS) << endl;
os << "CL_DEVICE_MAX_READ_IMAGE_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_READ_IMAGE_ARGS) << endl;
os << "CL_DEVICE_MAX_WRITE_IMAGE_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS) << endl;
os << "CL_DEVICE_MAX_MEM_ALLOC_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_MEM_ALLOC_SIZE) << endl;
os << "CL_DEVICE_ADDRESS_BITS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_ADDRESS_BITS) << endl;
os << "CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE) << endl;
os << "CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE) << endl;
os << "CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE) << endl;
os << "CL_DEVICE_GLOBAL_MEM_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_SIZE) << endl;
os << "CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE) << endl;
os << "CL_DEVICE_MAX_CONSTANT_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_CONSTANT_ARGS) << endl;
os << "CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS) << endl;
os << "CL_DEVICE_MAX_WORK_GROUP_SIZE: " << GetInfo<size_t>(platform, device, CL_DEVICE_MAX_WORK_GROUP_SIZE) << endl;
os << "Device " << device << ": " << DeviceName(platform, device);
os << "\nCL_DEVICE_OPENCL_C_VERSION: " << GetInfo<string>(platform, device, CL_DEVICE_OPENCL_C_VERSION);
os << "\nCL_DEVICE_LOCAL_MEM_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_LOCAL_MEM_SIZE);
os << "\nCL_DEVICE_LOCAL_MEM_TYPE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_LOCAL_MEM_TYPE);
os << "\nCL_DEVICE_MAX_COMPUTE_UNITS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_COMPUTE_UNITS);
os << "\nCL_DEVICE_MAX_READ_IMAGE_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_READ_IMAGE_ARGS);
os << "\nCL_DEVICE_MAX_WRITE_IMAGE_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS);
os << "\nCL_DEVICE_MAX_MEM_ALLOC_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_MEM_ALLOC_SIZE);
os << "\nCL_DEVICE_ADDRESS_BITS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_ADDRESS_BITS);
os << "\nCL_DEVICE_GLOBAL_MEM_CACHE_TYPE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE);
os << "\nCL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE);
os << "\nCL_DEVICE_GLOBAL_MEM_CACHE_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE);
os << "\nCL_DEVICE_GLOBAL_MEM_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_SIZE);
os << "\nCL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE);
os << "\nCL_DEVICE_MAX_CONSTANT_ARGS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_CONSTANT_ARGS);
os << "\nCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: " << GetInfo<cl_uint>(platform, device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS);
os << "\nCL_DEVICE_MAX_WORK_GROUP_SIZE: " << GetInfo<size_t>(platform, device, CL_DEVICE_MAX_WORK_GROUP_SIZE);
sizes = GetInfo<vector<size_t>>(platform, device, CL_DEVICE_MAX_WORK_ITEM_SIZES);
os << "CL_DEVICE_MAX_WORK_ITEM_SIZES: " << sizes[0] << ", " << sizes[1] << ", " << sizes[2] << endl << endl;
os << "\nCL_DEVICE_MAX_WORK_ITEM_SIZES: " << sizes[0] << ", " << sizes[1] << ", " << sizes[2] << "\n" << "\n";
if (device != m_Devices[platform].size() - 1 && platform != m_Platforms.size() - 1)
os << endl;
os << "\n";
}
os << endl;
os << "\n";
}
return os.str();
@ -309,7 +309,7 @@ bool OpenCLInfo::CheckCL(cl_int err, const char* name)
if (err != CL_SUCCESS)
{
ostringstream ss;
ss << "ERROR: " << ErrorToStringCL(err) << " in " << name << "." << endl;
ss << "ERROR: " << ErrorToStringCL(err) << " in " << name << ".\n";
AddToReport(ss.str());
}

View File

@ -332,7 +332,7 @@ bool OpenCLWrapper::AddAndWriteImage(const string& name, cl_mem_flags flags, con
if (shared)
{
//::wglMakeCurrent(wglGetCurrentDC(), wglGetCurrentContext());
IMAGEGL2D imageGL(m_Context, flags, GL_TEXTURE_2D, 0, texName, &err);
cl::ImageGL imageGL(m_Context, flags, GL_TEXTURE_2D, 0, texName, &err);
NamedImage2DGL namedImageGL(imageGL, name);
if (m_Info->CheckCL(err, "cl::ImageGL()"))
@ -360,11 +360,11 @@ bool OpenCLWrapper::AddAndWriteImage(const string& name, cl_mem_flags flags, con
{
if (shared)
{
IMAGEGL2D imageGL = m_GLImages[imageIndex].m_Image;
cl::ImageGL imageGL = m_GLImages[imageIndex].m_Image;
if (!CompareImageParams(imageGL, flags, format, width, height, row_pitch))
{
NamedImage2DGL namedImageGL(IMAGEGL2D(m_Context, flags, GL_TEXTURE_2D, 0, texName, &err), name);//Sizes are different, so create new.
NamedImage2DGL namedImageGL(cl::ImageGL(m_Context, flags, GL_TEXTURE_2D, 0, texName, &err), name);//Sizes are different, so create new.
if (m_Info->CheckCL(err, "cl::ImageGL()"))
{
@ -430,7 +430,7 @@ bool OpenCLWrapper::WriteImage2D(size_t index, bool shared, ::size_t width, ::si
if (shared && index < m_GLImages.size())
{
IMAGEGL2D imageGL = m_GLImages[index].m_Image;
cl::ImageGL imageGL = m_GLImages[index].m_Image;
if (EnqueueAcquireGLObjects(imageGL))
{
@ -502,7 +502,7 @@ bool OpenCLWrapper::ReadImage(size_t imageIndex, ::size_t width, ::size_t height
if (shared && imageIndex < m_GLImages.size())
{
IMAGEGL2D imageGL = m_GLImages[imageIndex].m_Image;
cl::ImageGL imageGL = m_GLImages[imageIndex].m_Image;
if (EnqueueAcquireGLObjects(imageGL))
{
@ -573,7 +573,7 @@ size_t OpenCLWrapper::GetImageSize(size_t imageIndex, bool shared)
{
vector<cl::Memory> images;
images.push_back(m_GLImages[imageIndex].m_Image);
IMAGEGL2D image = m_GLImages[imageIndex].m_Image;
cl::ImageGL image = m_GLImages[imageIndex].m_Image;
if (EnqueueAcquireGLObjects(&images))
size = image.getImageInfo<CL_IMAGE_WIDTH>(nullptr) * image.getImageInfo<CL_IMAGE_HEIGHT>(nullptr) * image.getImageInfo<CL_IMAGE_ELEMENT_SIZE>(nullptr);//Should pitch be checked here?
@ -662,17 +662,17 @@ bool OpenCLWrapper::CreateImage2D(cl::Image2D& image2D, cl_mem_flags flags, cl::
/// <param name="miplevel">The mip map level</param>
/// <param name="texobj">The texture ID of the shared OpenGL texture</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::CreateImage2DGL(IMAGEGL2D& image2DGL, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj)
bool OpenCLWrapper::CreateImage2DGL(cl::ImageGL& image2DGL, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj)
{
if (m_Init)
{
cl_int err;
image2DGL = IMAGEGL2D(m_Context,
flags,
target,
miplevel,
texobj,
&err);
image2DGL = cl::ImageGL(m_Context,
flags,
target,
miplevel,
texobj,
&err);
return m_Info->CheckCL(err, "cl::ImageGL()");
}
@ -699,7 +699,7 @@ bool OpenCLWrapper::EnqueueAcquireGLObjects(const string& name)
/// </summary>
/// <param name="image">The image to acquire</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::EnqueueAcquireGLObjects(IMAGEGL2D& image)
bool OpenCLWrapper::EnqueueAcquireGLObjects(cl::ImageGL& image)
{
if (m_Init && m_Shared)
{
@ -733,7 +733,7 @@ bool OpenCLWrapper::EnqueueReleaseGLObjects(const string& name)
/// </summary>
/// <param name="image">The image to release</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::EnqueueReleaseGLObjects(IMAGEGL2D& image)
bool OpenCLWrapper::EnqueueReleaseGLObjects(cl::ImageGL& image)
{
if (m_Init && m_Shared)
{

View File

@ -9,8 +9,6 @@
namespace EmberCLns
{
#define IMAGEGL2D cl::ImageGL
/// <summary>
/// Class to contain all of the things needed to store an OpenCL program.
/// The name of it, the source, the compiled program object and the kernel.
@ -75,13 +73,13 @@ public:
{
}
NamedImage2DGL(const IMAGEGL2D& image, const string& name)
NamedImage2DGL(const cl::ImageGL& image, const string& name)
{
m_Image = image;
m_Name = name;
}
IMAGEGL2D m_Image;
cl::ImageGL m_Image;
string m_Name;
};
@ -129,11 +127,11 @@ public:
bool CompareImageParams(cl::Image& image, cl_mem_flags flags, const cl::ImageFormat& format, ::size_t width, ::size_t height, ::size_t row_pitch);
void ClearImages(bool shared);
bool CreateImage2D(cl::Image2D& image2D, cl_mem_flags flags, cl::ImageFormat format, ::size_t width, ::size_t height, ::size_t row_pitch = 0, void* data = NULL);
bool CreateImage2DGL(IMAGEGL2D& image2DGL, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj);
bool CreateImage2DGL(cl::ImageGL& image2DGL, cl_mem_flags flags, GLenum target, GLint miplevel, GLuint texobj);
bool EnqueueAcquireGLObjects(const string& name);
bool EnqueueAcquireGLObjects(IMAGEGL2D& image);
bool EnqueueAcquireGLObjects(cl::ImageGL& image);
bool EnqueueReleaseGLObjects(const string& name);
bool EnqueueReleaseGLObjects(IMAGEGL2D& image);
bool EnqueueReleaseGLObjects(cl::ImageGL& image);
bool EnqueueAcquireGLObjects(const VECTOR_CLASS<cl::Memory>* memObjects = NULL);
bool EnqueueReleaseGLObjects(const VECTOR_CLASS<cl::Memory>* memObjects = NULL);
bool CreateSampler(cl::Sampler& sampler, cl_bool normalizedCoords, cl_addressing_mode addressingMode, cl_filter_mode filterMode);

View File

@ -895,25 +895,23 @@ bool RendererCL<T, bucketT>::BuildIterProgramForEmber(bool doAccum)
if (b)
{
m_IterKernel = m_IterOpenCLKernelCreator.CreateIterKernelString(m_Ember, m_Params.first, m_GlobalShared.first, m_LockAccum, doAccum);
//cout << "Building: " << endl << iterProgram << endl;
//cout << "Building: " << "\n" << iterProgram << "\n";
vector<std::thread> threads;
std::function<void(RendererClDevice*)> func = [&](RendererClDevice * dev)
{
if (!dev->m_Wrapper.AddProgram(m_IterOpenCLKernelCreator.IterEntryPoint(), m_IterKernel, m_IterOpenCLKernelCreator.IterEntryPoint(), m_DoublePrecision))
{
m_ResizeCs.Enter();//Just use the resize CS for lack of a better one.
rlg l(m_ResizeCs);//Just use the resize CS for lack of a better one.
b = false;
AddToReport(string(loc) + "()\n" + dev->m_Wrapper.DeviceName() + ":\nBuilding the following program failed: \n" + m_IterKernel + "\n");
m_ResizeCs.Leave();
}
else if (!m_GlobalShared.second.empty())
{
if (!dev->m_Wrapper.AddAndWriteBuffer(m_GlobalSharedBufferName, m_GlobalShared.second.data(), m_GlobalShared.second.size() * sizeof(m_GlobalShared.second[0])))
{
m_ResizeCs.Enter();//Just use the resize CS for lack of a better one.
rlg l(m_ResizeCs);//Just use the resize CS for lack of a better one.
b = false;
AddToReport(string(loc) + "()\n" + dev->m_Wrapper.DeviceName() + ":\nAdding global shared buffer failed.\n");
m_ResizeCs.Leave();
}
}
};
@ -934,7 +932,7 @@ bool RendererCL<T, bucketT>::BuildIterProgramForEmber(bool doAccum)
if (b)
{
//t.Toc(__FUNCTION__ " program build");
//cout << string(loc) << "():\nBuilding the following program succeeded: \n" << iterProgram << endl;
//cout << string(loc) << "():\nBuilding the following program succeeded: \n" << iterProgram << "\n";
m_LastBuiltEmber = m_Ember;
}
}
@ -988,7 +986,7 @@ bool RendererCL<T, bucketT>::RunIter(size_t iterCount, size_t temporalSample, si
{
bool b = true;
auto& wrapper = m_Devices[dev]->m_Wrapper;
intmax_t itersRemaining;
intmax_t itersRemaining = 0;
while (atomLaunchesRan.fetch_add(1), (b && (atomLaunchesRan.load() <= launches) && ((itersRemaining = atomItersRemaining.load()) > 0) && !m_Abort))
{
@ -1002,7 +1000,7 @@ bool RendererCL<T, bucketT>::RunIter(size_t iterCount, size_t temporalSample, si
//The number of iters per thread must be adjusted if they've requested less iters than is normally ran in a grid (256 * 256 * 64 * 2 = 32,768).
uint iterCountPerKernel = std::min<uint>(uint(adjustedIterCountPerKernel), uint(ceil(double(itersRemaining) / IterGridKernelCount())));
size_t iterCountThisLaunch = iterCountPerKernel * IterGridKernelWidth() * IterGridKernelHeight();
//cout << "itersRemaining " << itersRemaining << ", iterCountPerKernel " << iterCountPerKernel << ", iterCountThisLaunch " << iterCountThisLaunch << endl;
//cout << "itersRemaining " << itersRemaining << ", iterCountPerKernel " << iterCountPerKernel << ", iterCountThisLaunch " << iterCountThisLaunch << "\n";
if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, iterCountPerKernel))) { AddToReport(loc); }//Number of iters for each thread to run.

View File

@ -222,7 +222,7 @@ private:
cl::ImageFormat m_PaletteFormat;
cl::ImageFormat m_FinalFormat;
cl::Image2D m_Palette;
IMAGEGL2D m_AccumImage;
cl::ImageGL m_AccumImage;
GLuint m_OutputTexID;
EmberCL<T> m_EmberCL;
vector<XformCL<T>> m_XformsCL;