diff --git a/Source/Ember/PaletteList.h b/Source/Ember/PaletteList.h index 95ea736..a100caa 100644 --- a/Source/Ember/PaletteList.h +++ b/Source/Ember/PaletteList.h @@ -37,10 +37,10 @@ public: /// Whether anything was read bool Add(const string& filename, bool force = false) { - bool added = false; - auto& palettes = m_Palettes[filename]; + bool added = true; + auto palettes = m_Palettes.insert(make_pair(filename, vector>())); - if (palettes.empty() || force) + if (force || palettes.second) { string buf; const char* loc = __FUNCTION__; @@ -54,20 +54,23 @@ public: auto rootNode = xmlDocGetRootElement(doc); auto pfilename = shared_ptr(new string(filename)); - palettes.clear(); - palettes.reserve(buf.size() / 2048);//Roughly what it takes per palette. - ParsePalettes(rootNode, pfilename, palettes); + palettes.first->second.clear(); + palettes.first->second.reserve(buf.size() / 2048);//Roughly what it takes per palette. + ParsePalettes(rootNode, pfilename, palettes.first->second); xmlFreeDoc(doc); - added = true; } else { - m_ErrorReport.push_back(string(loc) + " : Couldn't load xml doc"); + added = false; + m_Palettes.erase(filename); + AddToReport(string(loc) + " : Couldn't load xml doc"); } } else { - m_ErrorReport.push_back(string(loc) + " : Couldn't read palette file " + filename); + added = false; + m_Palettes.erase(filename); + AddToReport(string(loc) + " : Couldn't read palette file " + filename); } } @@ -258,7 +261,7 @@ private: if (ret != 3) { - m_ErrorReport.push_back(string(loc) + " : Problem reading hexadecimal color data " + string(&val[colorIndex])); + AddToReport(string(loc) + " : Problem reading hexadecimal color data " + string(&val[colorIndex])); hexError = true; break; } diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp index 228139b..5d47539 100644 --- a/Source/Ember/Renderer.cpp +++ b/Source/Ember/Renderer.cpp @@ -414,14 +414,14 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, s if (m_SpatialFilter.get() == nullptr || m_TemporalFilter.get() == nullptr) { - m_ErrorReport.push_back("Spatial and temporal filter allocations failed, aborting.\n"); + AddToReport("Spatial and temporal filter allocations failed, aborting.\n"); success = RENDER_ERROR; goto Finish; } if (!resume && !Alloc()) { - m_ErrorReport.push_back("Histogram, accumulator and samples buffer allocations failed, aborting.\n"); + AddToReport("Histogram, accumulator and samples buffer allocations failed, aborting.\n"); success = RENDER_ERROR; goto Finish; } @@ -444,7 +444,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, s if (!CreateDEFilter(newFilterAlloc)) { - m_ErrorReport.push_back("Density filter creation failed, aborting.\n"); + AddToReport("Density filter creation failed, aborting.\n"); success = RENDER_ERROR; goto Finish; } @@ -465,7 +465,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, s if (!resume && !AssignIterator()) { - m_ErrorReport.push_back("Iterator assignment failed, aborting.\n"); + AddToReport("Iterator assignment failed, aborting.\n"); success = RENDER_ERROR; goto Finish; } @@ -495,7 +495,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, s //If no iters were executed, something went catastrophically wrong. if (stats.m_Iters == 0) { - m_ErrorReport.push_back("Zero iterations ran, rendering failed, aborting.\n"); + AddToReport("Zero iterations ran, rendering failed, aborting.\n"); success = RENDER_ERROR; Abort(); goto Finish; diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h index cca9184..da8f49d 100644 --- a/Source/Ember/Utils.h +++ b/Source/Ember/Utils.h @@ -146,13 +146,13 @@ public: /// Add string to report. /// /// The string to add - virtual void AddToReport(const string& s) { m_ErrorReport.push_back(s); } + virtual void AddToReport(const string& s) { if (!Contains(m_ErrorReport, s)) m_ErrorReport.push_back(s); } /// /// Add a vector of strings to report. /// /// The vector of strings to add - virtual void AddToReport(const vector& vec) { m_ErrorReport.insert(m_ErrorReport.end(), vec.begin(), vec.end()); } + virtual void AddToReport(const vector& vec) { for (auto& v : vec) AddToReport(v); } /// /// Static function to dump a vector of strings passed in. @@ -174,7 +174,7 @@ public: return ss.str(); } -protected: +private: vector m_ErrorReport; }; diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index 0d4986c..4ed563c 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -285,7 +285,7 @@ public: xmlNodePtr rootnode; Locale locale;//Sets and restores on exit. //Timing t; - m_ErrorReport.clear(); + ClearErrorReport(); //Parse XML string into internal document. xmlPtr = CX(&buf[0]); @@ -296,7 +296,7 @@ public: if (doc == nullptr) { - m_ErrorReport.push_back(string(loc) + " : Error parsing xml file " + string(filename)); + AddToReport(string(loc) + " : Error parsing xml file " + string(filename)); return false; } @@ -367,7 +367,7 @@ public: //Ensure palette list is setup first. if (!m_PaletteList.Size()) { - m_ErrorReport.push_back(string(loc) + " : Palette list must be initialized before parsing embers."); + AddToReport(string(loc) + " : Palette list must be initialized before parsing embers."); return false; } @@ -398,7 +398,7 @@ public: if (istr.bad() || istr.fail()) { - m_ErrorReport.push_back(string(loc) + " : Error converting " + string(str)); + AddToReport(string(loc) + " : Error converting " + string(str)); b = false; } @@ -479,7 +479,7 @@ private: if (!parseEmberSuccess) { //Original leaked memory here, ours doesn't. - m_ErrorReport.push_back(string(loc) + " : Error parsing ember element"); + AddToReport(string(loc) + " : Error parsing ember element"); return; } @@ -488,11 +488,11 @@ private: if (auto pal = m_PaletteList.GetPalette(PaletteList::m_DefaultFilename, currentEmber.PaletteIndex())) currentEmber.m_Palette = *pal; else - m_ErrorReport.push_back(string(loc) + " : Error assigning palette with index " + Itos(currentEmber.PaletteIndex())); + AddToReport(string(loc) + " : Error assigning palette with index " + Itos(currentEmber.PaletteIndex())); } //if (!Interpolater::InterpMissingColors(currentEmber.m_Palette.m_Entries)) - // m_ErrorReport.push_back(string(loc) + " : Error interpolating missing palette colors"); + // AddToReport(string(loc) + " : Error interpolating missing palette colors"); currentEmber.CacheXforms(); currentEmber.m_Index = embers.size(); @@ -531,7 +531,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : element has no attributes"); + AddToReport(string(loc) + " : element has no attributes"); return false; } @@ -581,7 +581,7 @@ private: else if (!_stricmp("smooth", attStr)) currentEmber.m_Interp = EMBER_INTERP_SMOOTH; else - m_ErrorReport.push_back(string(loc) + " : Unrecognized interpolation type " + string(attStr)); + AddToReport(string(loc) + " : Unrecognized interpolation type " + string(attStr)); } else if (!Compare(curAtt->name, "palette_interpolation")) { @@ -590,7 +590,7 @@ private: else if (!_stricmp("sweep", attStr)) currentEmber.m_PaletteInterp = INTERP_SWEEP; else - m_ErrorReport.push_back(string(loc) + " : Unrecognized palette interpolation type " + string(attStr)); + AddToReport(string(loc) + " : Unrecognized palette interpolation type " + string(attStr)); } else if (!Compare(curAtt->name, "interpolation_space") || !Compare(curAtt->name, "interpolation_type")) { @@ -603,7 +603,7 @@ private: else if (!_stricmp("older", attStr)) currentEmber.m_AffineInterp = AFFINE_INTERP_OLDER; else - m_ErrorReport.push_back(string(loc) + " : Unrecognized interpolation type " + string(attStr)); + AddToReport(string(loc) + " : Unrecognized interpolation type " + string(attStr)); } else if (!Compare(curAtt->name, "name")) { @@ -619,7 +619,7 @@ private: { if (sscanf_s(attStr, "%lu %lu", ¤tEmber.m_FinalRasW, ¤tEmber.m_FinalRasH) != 2) { - m_ErrorReport.push_back(string(loc) + " : Invalid size attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid size attribute " + string(attStr)); xmlFree(attStr); //These return statements are bad. One because they are inconsistent with others that just assign defaults. @@ -634,7 +634,7 @@ private: { if (sscanf_s(attStr, "%lf %lf", &vals[0], &vals[1]) != 2) { - m_ErrorReport.push_back(string(loc) + " : Invalid center attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid center attribute " + string(attStr)); xmlFree(attStr); return false; } @@ -659,14 +659,14 @@ private: else { currentEmber.m_PaletteMode = PALETTE_STEP; - m_ErrorReport.push_back(string(loc) + " : Unrecognized palette mode " + string(attStr) + ", using step"); + AddToReport(string(loc) + " : Unrecognized palette mode " + string(attStr) + ", using step"); } } else if (!Compare(curAtt->name, "background")) { if (sscanf_s(attStr, "%lf %lf %lf", &vals[0], &vals[1], &vals[2]) != 3) { - m_ErrorReport.push_back(string(loc) + " : Invalid background attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid background attribute " + string(attStr)); xmlFree(attStr); return false; } @@ -706,7 +706,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : No attributes for color element"); + AddToReport(string(loc) + " : No attributes for color element"); continue; } @@ -727,21 +727,21 @@ private: else if(!Compare(curAtt->name, "rgb")) { if (sscanf_s(attStr, "%lf %lf %lf", &r, &g, &b) != 3) - m_ErrorReport.push_back(string(loc) + " : Invalid rgb attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid rgb attribute " + string(attStr)); } else if(!Compare(curAtt->name, "rgba")) { if (sscanf_s(attStr, "%lf %lf %lf %lf", &r, &g, &b, &a) != 4) - m_ErrorReport.push_back(string(loc) + " : Invalid rgba attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid rgba attribute " + string(attStr)); } else if(!Compare(curAtt->name, "a")) { if (sscanf_s(attStr, "%lf", &a) != 1) - m_ErrorReport.push_back(string(loc) + " : Invalid a attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid a attribute " + string(attStr)); } else { - m_ErrorReport.push_back(string(loc) + " : Unknown color attribute " + string(CCX(curAtt->name))); + AddToReport(string(loc) + " : Unknown color attribute " + string(CCX(curAtt->name))); } xmlFree(attStr); @@ -762,7 +762,7 @@ private: { stringstream ss; ss << "ParseEmberElement() : Color element with bad/missing index attribute " << index; - m_ErrorReport.push_back(ss.str()); + AddToReport(ss.str()); } } else if (!Compare(childNode->name, "colors")) @@ -772,7 +772,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : No attributes for colors element"); + AddToReport(string(loc) + " : No attributes for colors element"); continue; } @@ -788,12 +788,12 @@ private: { if (!ParseHexColors(attStr, currentEmber, count, -4)) { - m_ErrorReport.push_back(string(loc) + " : Error parsing hexformatted colors, some may be set to zero"); + AddToReport(string(loc) + " : Error parsing hexformatted colors, some may be set to zero"); } } else { - m_ErrorReport.push_back(string(loc) + " : Unknown color attribute " + string(CCX(curAtt->name))); + AddToReport(string(loc) + " : Unknown color attribute " + string(CCX(curAtt->name))); } xmlFree(attStr); @@ -811,7 +811,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : No attributes for palette element"); + AddToReport(string(loc) + " : No attributes for palette element"); continue; } @@ -831,13 +831,13 @@ private: numBytes = 4; else { - m_ErrorReport.push_back(string(loc) + " : Unrecognized palette format string " + string(attStr) + ", defaulting to RGB"); + AddToReport(string(loc) + " : Unrecognized palette format string " + string(attStr) + ", defaulting to RGB"); numBytes = 3; } } else { - m_ErrorReport.push_back(string(loc) + " : Unknown palette attribute " + string(CCX(curAtt->name))); + AddToReport(string(loc) + " : Unknown palette attribute " + string(CCX(curAtt->name))); } xmlFree(attStr); @@ -849,7 +849,7 @@ private: if (!ParseHexColors(palStr, currentEmber, numColors, numBytes)) { - m_ErrorReport.push_back(string(loc) + " : Problem reading hexadecimal color data in palette"); + AddToReport(string(loc) + " : Problem reading hexadecimal color data in palette"); } xmlFree(palStr); @@ -863,7 +863,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : No attributes for palette element"); + AddToReport(string(loc) + " : No attributes for palette element"); continue; } @@ -877,7 +877,7 @@ private: } else { - m_ErrorReport.push_back(string(loc) + " : Unknown symmetry attribute " + string(attStr)); + AddToReport(string(loc) + " : Unknown symmetry attribute " + string(attStr)); continue; } @@ -899,14 +899,14 @@ private: if (!ParseXform(childNode, finalXform, false, fromEmber)) { - m_ErrorReport.push_back(string(loc) + " : Error parsing final xform"); + AddToReport(string(loc) + " : Error parsing final xform"); } else { if (finalXform.m_Weight != 0) { finalXform.m_Weight = 0; - m_ErrorReport.push_back(string(loc) + " : Final xforms should not have weight specified, setting to zero"); + AddToReport(string(loc) + " : Final xforms should not have weight specified, setting to zero"); } currentEmber.SetFinalXform(finalXform); @@ -919,7 +919,7 @@ private: if (!ParseXform(childNode, xform, false, fromEmber)) { - m_ErrorReport.push_back(string(loc) + " : Error parsing xform"); + AddToReport(string(loc) + " : Error parsing xform"); } else { @@ -933,7 +933,7 @@ private: //Check for non-zero motion params. if (fabs(theXform->m_MotionFreq) > 0.0)//Original checked for motion func being non-zero, but it was set to MOTION_SIN (1) in Xform::Init(), so don't check for 0 here. { - m_ErrorReport.push_back(string(loc) + " : Motion parameters should not be specified in regular, non-motion xforms"); + AddToReport(string(loc) + " : Motion parameters should not be specified in regular, non-motion xforms"); } //Motion Language: Check the xform element for children - should be named 'motion'. @@ -944,7 +944,7 @@ private: Xform xform(false);//Will only have valid values in fields parsed for motion, all others will be EMPTYFIELD. if (!ParseXform(motionNode, xform, true, fromEmber)) - m_ErrorReport.push_back(string(loc) + " : Error parsing motion xform"); + AddToReport(string(loc) + " : Error parsing motion xform"); else theXform->m_Motion.push_back(xform); } @@ -966,7 +966,7 @@ private: if (att == nullptr) { - m_ErrorReport.push_back(string(loc) + " : element has no attributes"); + AddToReport(string(loc) + " : element has no attributes"); return false; } @@ -990,7 +990,7 @@ private: motion.m_MotionFunc = MOTION_SAW; else { - m_ErrorReport.push_back(string(loc) + " : invalid flame motion function " + func); + AddToReport(string(loc) + " : invalid flame motion function " + func); return false; } } @@ -1024,7 +1024,7 @@ private: if (sscanf_s(attStr, "%lf %lf %lf", &r, &g, &b) != 3) { - m_ErrorReport.push_back(string(loc) + " : Invalid flame motion background attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid flame motion background attribute " + string(attStr)); xmlFree(attStr); return false; } @@ -1044,7 +1044,7 @@ private: if (sscanf_s(attStr, "%lf %lf", &cx, &cy) != 2) { - m_ErrorReport.push_back(string(loc) + " : Invalid flame motion center attribute " + string(attStr)); + AddToReport(string(loc) + " : Invalid flame motion center attribute " + string(attStr)); xmlFree(attStr); return false; } @@ -1057,7 +1057,7 @@ private: } else { - m_ErrorReport.push_back(string(loc) + " : Unknown flame motion attribute " + string(CCX(curAtt->name))); + AddToReport(string(loc) + " : Unknown flame motion attribute " + string(CCX(curAtt->name))); xmlFree(attStr); return false; } @@ -1076,7 +1076,7 @@ private: if (soloXform >= 0 && i != soloXform) currentEmber.GetXform(i)->m_Opacity = 0;//Will calc the cached adjusted viz value later. - return m_ErrorReport.empty(); + return ErrorReport().empty(); } /// @@ -1100,7 +1100,7 @@ private: } else { - m_ErrorReport.push_back(string(loc) + " : Failed to parse float value for flame motion attribute \"" + string(CCX(att->name)) + "\" : " + string(attStr)); + AddToReport(string(loc) + " : Failed to parse float value for flame motion attribute \"" + string(CCX(att->name)) + "\" : " + string(attStr)); } return r; @@ -1129,7 +1129,7 @@ private: if (attPtr == nullptr) { - m_ErrorReport.push_back(string(loc) + " : Error: No attributes for element"); + AddToReport(string(loc) + " : Error: No attributes for element"); return false; } @@ -1173,7 +1173,7 @@ private: else { xform.m_MotionFunc = MOTION_SIN; - m_ErrorReport.push_back(string(loc) + " : Unknown motion function " + string(attStr) + ", using sin"); + AddToReport(string(loc) + " : Unknown motion function " + string(attStr) + ", using sin"); } } else if (!Compare(curAtt->name, "color")) @@ -1193,7 +1193,7 @@ private: else { xform.m_ColorX = xform.m_ColorY = T(0.5); - m_ErrorReport.push_back(string(loc) + " : Malformed xform color attribute " + string(attStr) + ", using 0.5, 0.5"); + AddToReport(string(loc) + " : Malformed xform color attribute " + string(attStr) + ", using 0.5, 0.5"); } } else if (!Compare(curAtt->name, "chaos")) @@ -1211,7 +1211,7 @@ private: { if (motion == 1) { - m_ErrorReport.push_back(string(loc) + " : Motion element cannot have a plotmode attribute"); + AddToReport(string(loc) + " : Motion element cannot have a plotmode attribute"); } else if (!_stricmp("off", attStr)) xform.m_Opacity = 0; @@ -1221,7 +1221,7 @@ private: if (sscanf_s(attStr, "%lf %lf %lf %lf %lf %lf", &a, &d, &b, &e, &c, &f) != 6)//Original did a complicated parsing scheme. This is easier.//ORIG { a = d = b = e = c = f = 0; - m_ErrorReport.push_back(string(loc) + " : Bad coeffs attribute " + string(attStr)); + AddToReport(string(loc) + " : Bad coeffs attribute " + string(attStr)); } xform.m_Affine.A(T(a)); @@ -1236,7 +1236,7 @@ private: if (sscanf_s(attStr, "%lf %lf %lf %lf %lf %lf", &a, &d, &b, &e, &c, &f) != 6)//Original did a complicated parsing scheme. This is easier.//ORIG { a = d = b = e = c = f = 0; - m_ErrorReport.push_back(string(loc) + " : Bad post coeffs attribute " + string(attStr)); + AddToReport(string(loc) + " : Bad post coeffs attribute " + string(attStr)); } xform.m_Post.A(T(a)); @@ -1260,7 +1260,7 @@ private: } //else //{ - // m_ErrorReport.push_back("Unsupported variation: " + string((const char*)curAtt->name)); + // AddToReport("Unsupported variation: " + string((const char*)curAtt->name)); //} } @@ -1291,7 +1291,7 @@ private: } if (!var1) - m_ErrorReport.push_back(string(loc) + " : Bad value for var1 " + string(attStr)); + AddToReport(string(loc) + " : Bad value for var1 " + string(attStr)); xmlFree(attStr); break; @@ -1316,7 +1316,7 @@ private: } if (!var) - m_ErrorReport.push_back(string(loc) + " : Bad value for var " + string(attStr)); + AddToReport(string(loc) + " : Bad value for var " + string(attStr)); xmlFree(attStr); break; @@ -1345,7 +1345,7 @@ private: } else { - m_ErrorReport.push_back(string(loc) + " : Failed to parse parametric variation parameter " + s + " - " + string(attStr)); + AddToReport(string(loc) + " : Failed to parse parametric variation parameter " + s + " - " + string(attStr)); } xmlFree(attStr); @@ -1466,7 +1466,7 @@ private: { ok = false; r = g = b = 0; - m_ErrorReport.push_back(string(loc) + " : Problem reading hexadecimal color data, assigning to 0"); + AddToReport(string(loc) + " : Problem reading hexadecimal color data, assigning to 0"); break; } @@ -1490,7 +1490,7 @@ private: if (sscanf_s(&(colstr[colorIndex]),"%1s", tmps) > 0) #endif { - m_ErrorReport.push_back(string(loc) + " : Extra data at end of hex color data " + string(&(colstr[colorIndex]))); + AddToReport(string(loc) + " : Extra data at end of hex color data " + string(&(colstr[colorIndex]))); ok = false; } diff --git a/Source/EmberCL/OpenCLInfo.cpp b/Source/EmberCL/OpenCLInfo.cpp index 2e70d44..a8871de 100644 --- a/Source/EmberCL/OpenCLInfo.cpp +++ b/Source/EmberCL/OpenCLInfo.cpp @@ -330,7 +330,7 @@ bool OpenCLInfo::CheckCL(cl_int err, const char* name) { ostringstream ss; ss << "ERROR: " << ErrorToStringCL(err) << " in " << name << "." << endl; - m_ErrorReport.push_back(ss.str()); + AddToReport(ss.str()); } return err == CL_SUCCESS; diff --git a/Source/EmberCL/OpenCLWrapper.cpp b/Source/EmberCL/OpenCLWrapper.cpp index d816b82..69847ea 100644 --- a/Source/EmberCL/OpenCLWrapper.cpp +++ b/Source/EmberCL/OpenCLWrapper.cpp @@ -39,8 +39,8 @@ bool OpenCLWrapper::Init(size_t platformIndex, size_t deviceIndex, bool shared) auto& devices = m_Info.Devices(); m_Init = false; - m_ErrorReport.clear(); - + ClearErrorReport(); + if (m_Info.Ok()) { if (platformIndex < platforms.size() && platformIndex < devices.size()) @@ -1022,7 +1022,7 @@ bool OpenCLWrapper::CreateSPK(const string& name, const string& program, const s else { for (auto& i : m_DeviceVec) - m_ErrorReport.push_back(spk.m_Program.getBuildInfo(i, nullptr)); + AddToReport(spk.m_Program.getBuildInfo(i, nullptr)); } } diff --git a/Source/EmberCL/RendererCL.cpp b/Source/EmberCL/RendererCL.cpp index 6048744..fd47508 100644 --- a/Source/EmberCL/RendererCL.cpp +++ b/Source/EmberCL/RendererCL.cpp @@ -125,8 +125,8 @@ bool RendererCL::Init(const vector>& devices, b if ((b = cld->Init()))//Build a simple program to ensure OpenCL is working right. { - if (b && !(b = cld->m_Wrapper.AddProgram(m_IterOpenCLKernelCreator.ZeroizeEntryPoint(), zeroizeProgram, m_IterOpenCLKernelCreator.ZeroizeEntryPoint(), m_DoublePrecision))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = cld->m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, 256, 1, 0, nullptr))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = cld->m_Wrapper.AddProgram(m_IterOpenCLKernelCreator.ZeroizeEntryPoint(), zeroizeProgram, m_IterOpenCLKernelCreator.ZeroizeEntryPoint(), m_DoublePrecision))) { AddToReport(loc); } + if (b && !(b = cld->m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, 256, 1, 0, nullptr))) { AddToReport(loc); } if (b) { @@ -135,7 +135,7 @@ bool RendererCL::Init(const vector>& devices, b else { os << loc << ": failed to init platform " << devices[i].first << ", device " << devices[i].second; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); break; } } @@ -143,12 +143,12 @@ bool RendererCL::Init(const vector>& devices, b catch (const std::exception& e) { os << loc << ": failed to init platform " << devices[i].first << ", device " << devices[i].second << ": " << e.what(); - this->m_ErrorReport.push_back(os.str()); + AddToReport(os.str()); } catch (...) { os << loc << ": failed to init platform " << devices[i].first << ", device " << devices[i].second; - this->m_ErrorReport.push_back(os.str()); + AddToReport(os.str()); } } @@ -158,8 +158,8 @@ bool RendererCL::Init(const vector>& devices, b m_DEOpenCLKernelCreator = DEOpenCLKernelCreator(m_DoublePrecision, m_Devices[0]->Nvidia()); //Build a simple program to ensure OpenCL is working right. - if (b && !(b = firstWrapper.AddProgram(m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint(), m_DEOpenCLKernelCreator.LogScaleAssignDEKernel(), m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint(), m_DoublePrecision))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = firstWrapper.AddProgram(m_IterOpenCLKernelCreator.SumHistEntryPoint(), sumHistProgram, m_IterOpenCLKernelCreator.SumHistEntryPoint(), m_DoublePrecision))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = firstWrapper.AddProgram(m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint(), m_DEOpenCLKernelCreator.LogScaleAssignDEKernel(), m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint(), m_DoublePrecision))) { AddToReport(loc); } + if (b && !(b = firstWrapper.AddProgram(m_IterOpenCLKernelCreator.SumHistEntryPoint(), sumHistProgram, m_IterOpenCLKernelCreator.SumHistEntryPoint(), m_DoublePrecision))) { AddToReport(loc); } if (b) { @@ -174,7 +174,7 @@ bool RendererCL::Init(const vector>& devices, b FillSeeds(); for (size_t device = 0; device < m_Devices.size(); device++) - if (b && !(b = m_Devices[device]->m_Wrapper.AddAndWriteBuffer(m_SeedsBufferName, reinterpret_cast(m_Seeds[device].data()), SizeOf(m_Seeds[device])))) { this->m_ErrorReport.push_back(loc); break; } + if (b && !(b = m_Devices[device]->m_Wrapper.AddAndWriteBuffer(m_SeedsBufferName, reinterpret_cast(m_Seeds[device].data()), SizeOf(m_Seeds[device])))) { AddToReport(loc); break; } } m_Init = b; @@ -183,7 +183,7 @@ bool RendererCL::Init(const vector>& devices, b { m_Devices.clear(); os << loc << ": failed to init all devices and platforms."; - this->m_ErrorReport.push_back(os.str()); + AddToReport(os.str()); } return m_Init; @@ -208,7 +208,7 @@ bool RendererCL::SetOutputTexture(GLuint outputTexID) if (!firstWrapper.AddAndWriteImage(m_FinalImageName, CL_MEM_WRITE_ONLY, m_FinalFormat, FinalRasW(), FinalRasH(), 0, nullptr, firstWrapper.Shared(), m_OutputTexID)) { - this->m_ErrorReport.push_back(loc); + AddToReport(loc); success = false; } @@ -302,7 +302,7 @@ bool RendererCL::ClearHist() const char* loc = __FUNCTION__; for (size_t i = 0; i < m_Devices.size(); i++) - if (b && !(b = ClearBuffer(i, m_HistBufferName, uint(SuperRasW()), uint(SuperRasH()), sizeof(v4bT)))) { this->m_ErrorReport.push_back(loc); break; } + if (b && !(b = ClearBuffer(i, m_HistBufferName, uint(SuperRasW()), uint(SuperRasH()), sizeof(v4bT)))) { AddToReport(loc); break; } return b; } @@ -318,7 +318,7 @@ bool RendererCL::ClearHist(size_t device) bool b = device < m_Devices.size(); const char* loc = __FUNCTION__; - if (b && !(b = ClearBuffer(device, m_HistBufferName, uint(SuperRasW()), uint(SuperRasH()), sizeof(v4bT)))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = ClearBuffer(device, m_HistBufferName, uint(SuperRasW()), uint(SuperRasH()), sizeof(v4bT)))) { AddToReport(loc); } return b; } @@ -347,7 +347,7 @@ bool RendererCL::WritePoints(size_t device, vector>& vec) const char* loc = __FUNCTION__; if (device < m_Devices.size()) - if (!(b = m_Devices[device]->m_Wrapper.WriteBuffer(m_PointsBufferName, reinterpret_cast(vec.data()), SizeOf(vec)))) { this->m_ErrorReport.push_back(loc); } + if (!(b = m_Devices[device]->m_Wrapper.WriteBuffer(m_PointsBufferName, reinterpret_cast(vec.data()), SizeOf(vec)))) { AddToReport(loc); } return b; } @@ -432,7 +432,7 @@ bool RendererCL::ClearFinal() bool b = wrapper.WriteImage2D(index, wrapper.Shared(), FinalRasW(), FinalRasH(), 0, v.data()); if (!b) - this->m_ErrorReport.push_back(__FUNCTION__); + AddToReport(__FUNCTION__); return b; } @@ -532,9 +532,9 @@ bool RendererCL::CreateDEFilter(bool& newAlloc) const char* loc = __FUNCTION__; auto& wrapper = m_Devices[0]->m_Wrapper; - if (b && !(b = wrapper.AddAndWriteBuffer(m_DECoefsBufferName, reinterpret_cast(const_cast(m_DensityFilter->Coefs())), m_DensityFilter->CoefsSizeBytes()))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddAndWriteBuffer(m_DEWidthsBufferName, reinterpret_cast(const_cast(m_DensityFilter->Widths())), m_DensityFilter->WidthsSizeBytes()))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddAndWriteBuffer(m_DECoefIndicesBufferName, reinterpret_cast(const_cast(m_DensityFilter->CoefIndices())), m_DensityFilter->CoefsIndicesSizeBytes()))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DECoefsBufferName, reinterpret_cast(const_cast(m_DensityFilter->Coefs())), m_DensityFilter->CoefsSizeBytes()))) { AddToReport(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DEWidthsBufferName, reinterpret_cast(const_cast(m_DensityFilter->Widths())), m_DensityFilter->WidthsSizeBytes()))) { AddToReport(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DECoefIndicesBufferName, reinterpret_cast(const_cast(m_DensityFilter->CoefIndices())), m_DensityFilter->CoefsIndicesSizeBytes()))) { AddToReport(loc); } } } else @@ -557,7 +557,7 @@ bool RendererCL::CreateSpatialFilter(bool& newAlloc) if (!m_Devices.empty() && Renderer::CreateSpatialFilter(newAlloc)) { if (newAlloc) - if (!(b = m_Devices[0]->m_Wrapper.AddAndWriteBuffer(m_SpatialFilterCoefsBufferName, reinterpret_cast(m_SpatialFilter->Filter()), m_SpatialFilter->BufferSizeBytes()))) { this->m_ErrorReport.push_back(__FUNCTION__); } + if (!(b = m_Devices[0]->m_Wrapper.AddAndWriteBuffer(m_SpatialFilterCoefsBufferName, reinterpret_cast(m_SpatialFilter->Filter()), m_SpatialFilter->BufferSizeBytes()))) { AddToReport(__FUNCTION__); } } else b = false; @@ -629,7 +629,7 @@ bool RendererCL::RandVec(vector>& ran FillSeeds(); for (size_t device = 0; device < m_Devices.size(); device++) - if (b && !(b = m_Devices[device]->m_Wrapper.AddAndWriteBuffer(m_SeedsBufferName, reinterpret_cast(m_Seeds[device].data()), SizeOf(m_Seeds[device])))) { this->m_ErrorReport.push_back(loc); break; } + if (b && !(b = m_Devices[device]->m_Wrapper.AddAndWriteBuffer(m_SeedsBufferName, reinterpret_cast(m_Seeds[device].data()), SizeOf(m_Seeds[device])))) { AddToReport(loc); break; } } else b = false; @@ -663,25 +663,25 @@ bool RendererCL::Alloc(bool histOnly) auto& wrapper = m_Devices[0]->m_Wrapper; - if (b && !(b = wrapper.AddBuffer(m_DEFilterParamsBufferName, sizeof(m_DensityFilterCL)))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddBuffer(m_SpatialFilterParamsBufferName, sizeof(m_SpatialFilterCL)))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddBuffer(m_CurvesCsaName, SizeOf(m_Csa.m_Entries)))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddBuffer(m_AccumBufferName, accumLength))) { this->m_ErrorReport.push_back(loc); }//Accum buffer. + if (b && !(b = wrapper.AddBuffer(m_DEFilterParamsBufferName, sizeof(m_DensityFilterCL)))) { AddToReport(loc); } + if (b && !(b = wrapper.AddBuffer(m_SpatialFilterParamsBufferName, sizeof(m_SpatialFilterCL)))) { AddToReport(loc); } + if (b && !(b = wrapper.AddBuffer(m_CurvesCsaName, SizeOf(m_Csa.m_Entries)))) { AddToReport(loc); } + if (b && !(b = wrapper.AddBuffer(m_AccumBufferName, accumLength))) { AddToReport(loc); }//Accum buffer. for (auto& device : m_Devices) { - if (b && !(b = device->m_Wrapper.AddBuffer(m_EmberBufferName, sizeof(m_EmberCL)))) { this->m_ErrorReport.push_back(loc); break; } - if (b && !(b = device->m_Wrapper.AddBuffer(m_XformsBufferName, SizeOf(m_XformsCL)))) { this->m_ErrorReport.push_back(loc); break; } - if (b && !(b = device->m_Wrapper.AddBuffer(m_ParVarsBufferName, 128 * sizeof(T)))) { this->m_ErrorReport.push_back(loc); break; } - if (b && !(b = device->m_Wrapper.AddBuffer(m_DistBufferName, CHOOSE_XFORM_GRAIN))) { this->m_ErrorReport.push_back(loc); break; }//Will be resized for xaos. - if (b && !(b = device->m_Wrapper.AddBuffer(m_CarToRasBufferName, sizeof(m_CarToRasCL)))) { this->m_ErrorReport.push_back(loc); break; } - if (b && !(b = device->m_Wrapper.AddBuffer(m_HistBufferName, histLength))) { this->m_ErrorReport.push_back(loc); break; }//Histogram. Will memset to zero later. - if (b && !(b = device->m_Wrapper.AddBuffer(m_PointsBufferName, IterGridKernelCount() * sizeof(PointCL)))) { this->m_ErrorReport.push_back(loc); break; }//Points between iter calls. + if (b && !(b = device->m_Wrapper.AddBuffer(m_EmberBufferName, sizeof(m_EmberCL)))) { AddToReport(loc); break; } + if (b && !(b = device->m_Wrapper.AddBuffer(m_XformsBufferName, SizeOf(m_XformsCL)))) { AddToReport(loc); break; } + if (b && !(b = device->m_Wrapper.AddBuffer(m_ParVarsBufferName, 128 * sizeof(T)))) { AddToReport(loc); break; } + if (b && !(b = device->m_Wrapper.AddBuffer(m_DistBufferName, CHOOSE_XFORM_GRAIN))) { AddToReport(loc); break; }//Will be resized for xaos. + if (b && !(b = device->m_Wrapper.AddBuffer(m_CarToRasBufferName, sizeof(m_CarToRasCL)))) { AddToReport(loc); break; } + if (b && !(b = device->m_Wrapper.AddBuffer(m_HistBufferName, histLength))) { AddToReport(loc); break; }//Histogram. Will memset to zero later. + if (b && !(b = device->m_Wrapper.AddBuffer(m_PointsBufferName, IterGridKernelCount() * sizeof(PointCL)))) { AddToReport(loc); break; }//Points between iter calls. } LeaveResize(); - if (b && !(b = SetOutputTexture(m_OutputTexID))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = SetOutputTexture(m_OutputTexID))) { AddToReport(loc); } return b; } @@ -734,7 +734,7 @@ eRenderStatus RendererCL::GaussianDensityFilter() // Renderer::ResetBuckets(false, true); // Renderer::GaussianDensityFilter(); // - // if (!m_Wrapper.WriteBuffer(m_AccumBufferName, AccumulatorBuckets(), accumLength)) { this->m_ErrorReport.push_back(loc); return RENDER_ERROR; } + // if (!m_Wrapper.WriteBuffer(m_AccumBufferName, AccumulatorBuckets(), accumLength)) { AddToReport(loc); return RENDER_ERROR; } // return RENDER_OK; //} //else @@ -807,12 +807,12 @@ EmberStats RendererCL::Iterate(size_t iterCount, size_t temporalSamp { auto& wrapper = device->m_Wrapper; - if (b && !(b = wrapper.WriteBuffer (m_EmberBufferName, reinterpret_cast(&m_EmberCL), sizeof(m_EmberCL)))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.WriteBuffer (m_XformsBufferName, reinterpret_cast(m_XformsCL.data()), sizeof(m_XformsCL[0]) * m_XformsCL.size()))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddAndWriteBuffer(m_DistBufferName, reinterpret_cast(const_cast(XformDistributions())), XformDistributionsSize()))) { this->m_ErrorReport.push_back(loc); }//Will be resized for xaos. - if (b && !(b = wrapper.WriteBuffer (m_CarToRasBufferName, reinterpret_cast(&m_CarToRasCL), sizeof(m_CarToRasCL)))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.WriteBuffer (m_EmberBufferName, reinterpret_cast(&m_EmberCL), sizeof(m_EmberCL)))) { AddToReport(loc); } + if (b && !(b = wrapper.WriteBuffer (m_XformsBufferName, reinterpret_cast(m_XformsCL.data()), sizeof(m_XformsCL[0]) * m_XformsCL.size()))) { AddToReport(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DistBufferName, reinterpret_cast(const_cast(XformDistributions())), XformDistributionsSize()))) { AddToReport(loc); }//Will be resized for xaos. + if (b && !(b = wrapper.WriteBuffer (m_CarToRasBufferName, reinterpret_cast(&m_CarToRasCL), sizeof(m_CarToRasCL)))) { AddToReport(loc); } - if (b && !(b = wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, m_Dmap.m_Entries.size(), 1, 0, m_Dmap.m_Entries.data()))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, m_Dmap.m_Entries.size(), 1, 0, m_Dmap.m_Entries.data()))) { AddToReport(loc); } if (b) { @@ -825,7 +825,7 @@ EmberStats RendererCL::Iterate(size_t iterCount, size_t temporalSamp if (!wrapper.AddAndWriteBuffer(m_ParVarsBufferName, m_Params.second.data(), m_Params.second.size() * sizeof(m_Params.second[0]))) { m_Abort = true; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); return stats; } } @@ -853,7 +853,7 @@ EmberStats RendererCL::Iterate(size_t iterCount, size_t temporalSamp else { m_Abort = true; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } return stats; @@ -885,7 +885,7 @@ bool RendererCL::BuildIterProgramForEmber(bool doAccum) { m_ResizeCs.Enter();//Just use the resize CS for lack of a better one. b = false; - this->m_ErrorReport.push_back(string(loc) + "()\n" + dev->m_Wrapper.DeviceName() + ":\nBuilding the following program failed: \n" + m_IterKernel + "\n"); + AddToReport(string(loc) + "()\n" + dev->m_Wrapper.DeviceName() + ":\nBuilding the following program failed: \n" + m_IterKernel + "\n"); m_ResizeCs.Leave(); } }; @@ -979,18 +979,18 @@ bool RendererCL::RunIter(size_t iterCount, size_t temporalSample, si size_t iterCountThisLaunch = iterCountPerKernel * IterGridKernelWidth() * IterGridKernelHeight(); //cout << "itersRemaining " << itersRemaining << ", iterCountPerKernel " << iterCountPerKernel << ", iterCountThisLaunch " << iterCountThisLaunch << endl; - if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, iterCountPerKernel))) { this->m_ErrorReport.push_back(loc); }//Number of iters for each thread to run. - if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, fuse))) { this->m_ErrorReport.push_back(loc); }//Number of iters to fuse. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_SeedsBufferName))) { this->m_ErrorReport.push_back(loc); }//Seeds. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_EmberBufferName))) { this->m_ErrorReport.push_back(loc); }//Ember. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_XformsBufferName))) { this->m_ErrorReport.push_back(loc); }//Xforms. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_ParVarsBufferName))) { this->m_ErrorReport.push_back(loc); }//Parametric variation parameters. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_DistBufferName))) { this->m_ErrorReport.push_back(loc); }//Xform distributions. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_CarToRasBufferName))) { this->m_ErrorReport.push_back(loc); }//Coordinate converter. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName))) { this->m_ErrorReport.push_back(loc); }//Histogram. - if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, histSuperSize))) { this->m_ErrorReport.push_back(loc); }//Histogram size. - if (b && !(b = wrapper.SetImageArg (kernelIndex, argIndex++, false, "Palette"))) { this->m_ErrorReport.push_back(loc); }//Palette. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_PointsBufferName))) { this->m_ErrorReport.push_back(loc); }//Random start points. + if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, iterCountPerKernel))) { AddToReport(loc); }//Number of iters for each thread to run. + if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, fuse))) { AddToReport(loc); }//Number of iters to fuse. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_SeedsBufferName))) { AddToReport(loc); }//Seeds. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_EmberBufferName))) { AddToReport(loc); }//Ember. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_XformsBufferName))) { AddToReport(loc); }//Xforms. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_ParVarsBufferName))) { AddToReport(loc); }//Parametric variation parameters. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_DistBufferName))) { AddToReport(loc); }//Xform distributions. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_CarToRasBufferName))) { AddToReport(loc); }//Coordinate converter. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName))) { AddToReport(loc); }//Histogram. + if (b && !(b = wrapper.SetArg (kernelIndex, argIndex++, histSuperSize))) { AddToReport(loc); }//Histogram size. + if (b && !(b = wrapper.SetImageArg (kernelIndex, argIndex++, false, "Palette"))) { AddToReport(loc); }//Palette. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_PointsBufferName))) { AddToReport(loc); }//Random start points. if (b && !(b = wrapper.RunKernel(kernelIndex, IterGridKernelWidth(),//Total grid dims. @@ -1002,7 +1002,7 @@ bool RendererCL::RunIter(size_t iterCount, size_t temporalSample, si { success = false; m_Abort = true; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); atomLaunchesRan.fetch_sub(1); break; } @@ -1073,7 +1073,7 @@ bool RendererCL::RunIter(size_t iterCount, size_t temporalSample, si { if (((TemporalSamples() == 1) || (temporalSample == TemporalSamples() - 1)) &&//If there are no temporal samples (not animating), or the current one is the last... ((m_LastIter + itersRan) >= ItersPerTemporalSample()))//...and the required number of iters for that sample have completed... - if (success && !(success = SumDeviceHist())) { this->m_ErrorReport.push_back(loc); }//...read the histogram from the secondary devices and sum them to the primary. + if (success && !(success = SumDeviceHist())) { AddToReport(loc); }//...read the histogram from the secondary devices and sum them to the primary. } //t2.Toc(__FUNCTION__); @@ -1107,20 +1107,20 @@ eRenderStatus RendererCL::RunLogScaleFilter() OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH); - if (b && !(b = wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, reinterpret_cast(&m_DensityFilterCL), sizeof(m_DensityFilterCL)))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, reinterpret_cast(&m_DensityFilterCL), sizeof(m_DensityFilterCL)))) { AddToReport(loc); } - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName))) { this->m_ErrorReport.push_back(loc); }//Histogram. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_AccumBufferName))) { this->m_ErrorReport.push_back(loc); }//Accumulator. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_DEFilterParamsBufferName))) { this->m_ErrorReport.push_back(loc); }//DensityFilterCL. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName))) { AddToReport(loc); }//Histogram. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_AccumBufferName))) { AddToReport(loc); }//Accumulator. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, m_DEFilterParamsBufferName))) { AddToReport(loc); }//DensityFilterCL. //t.Tic(); - if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { AddToReport(loc); } //t.Toc(loc); } else { b = false; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } if (b && m_Callback && m_LastIterPercent >= 99.0)//Only update progress if we've really reached the end, not via forced output. @@ -1178,7 +1178,7 @@ eRenderStatus RendererCL::RunDensityFilter() uint chunkSizeH = gapH + 1; double totalChunks = chunkSizeW * chunkSizeH; - if (b && !(b = wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, reinterpret_cast(&m_DensityFilterCL), sizeof(m_DensityFilterCL)))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, reinterpret_cast(&m_DensityFilterCL), sizeof(m_DensityFilterCL)))) { AddToReport(loc); } #ifdef ROW_ONLY_DE blockSizeW = 64;//These *must* both be divisible by 16 or else pixels will go missing. @@ -1198,7 +1198,7 @@ eRenderStatus RendererCL::RunDensityFilter() for (uint colChunk = 0; b && !m_Abort && colChunk < chunkSizeW; colChunk++) { //t2.Tic(); - if (b && !(b = RunDensityFilterPrivate(kernelIndex, gridW, gridH, blockSizeW, blockSizeH, chunkSizeW, chunkSizeH, colChunk, rowChunk))) { m_Abort = true; this->m_ErrorReport.push_back(loc); } + if (b && !(b = RunDensityFilterPrivate(kernelIndex, gridW, gridH, blockSizeW, blockSizeH, chunkSizeW, chunkSizeH, colChunk, rowChunk))) { m_Abort = true; AddToReport(loc); } //t2.Toc(loc); if (b && m_Callback) @@ -1221,7 +1221,7 @@ eRenderStatus RendererCL::RunDensityFilter() for (uint colChunk = 0; b && !m_Abort && colChunk < chunkSizeW; colChunk++) { //t2.Tic(); - if (b && !(b = RunDensityFilterPrivate(kernelIndex, gridW, gridH, blockSizeW, blockSizeH, chunkSizeW, chunkSizeH, colChunk, rowChunk))) { m_Abort = true; this->m_ErrorReport.push_back(loc); } + if (b && !(b = RunDensityFilterPrivate(kernelIndex, gridW, gridH, blockSizeW, blockSizeH, chunkSizeW, chunkSizeH, colChunk, rowChunk))) { m_Abort = true; AddToReport(loc); } //t2.Toc(loc); if (b && m_Callback) @@ -1244,7 +1244,7 @@ eRenderStatus RendererCL::RunDensityFilter() else { b = false; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } return m_Abort ? RENDER_ABORT : (b ? RENDER_OK : RENDER_ERROR); @@ -1277,8 +1277,8 @@ eRenderStatus RendererCL::RunFinalAccum() //This is needed with or without early clip. ConvertSpatialFilter(); - if (b && !(b = wrapper.AddAndWriteBuffer(m_SpatialFilterParamsBufferName, reinterpret_cast(&m_SpatialFilterCL), sizeof(m_SpatialFilterCL)))) { this->m_ErrorReport.push_back(loc); } - if (b && !(b = wrapper.AddAndWriteBuffer(m_CurvesCsaName, m_Csa.m_Entries.data(), SizeOf(m_Csa.m_Entries)))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_SpatialFilterParamsBufferName, reinterpret_cast(&m_SpatialFilterCL), sizeof(m_SpatialFilterCL)))) { AddToReport(loc); } + if (b && !(b = wrapper.AddAndWriteBuffer(m_CurvesCsaName, m_Csa.m_Entries.data(), SizeOf(m_Csa.m_Entries)))) { AddToReport(loc); } //Since early clip requires gamma correcting the entire accumulator first, //it can't be done inside of the normal final accumulation kernel, so @@ -1296,15 +1296,15 @@ eRenderStatus RendererCL::RunFinalAccum() gridH = m_SpatialFilterCL.m_SuperRasH; OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH); - if (b && !(b = wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_AccumBufferName))) { this->m_ErrorReport.push_back(loc); }//Accumulator. - if (b && !(b = wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_SpatialFilterParamsBufferName))) { this->m_ErrorReport.push_back(loc); }//SpatialFilterCL. + if (b && !(b = wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_AccumBufferName))) { AddToReport(loc); }//Accumulator. + if (b && !(b = wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_SpatialFilterParamsBufferName))) { AddToReport(loc); }//SpatialFilterCL. - if (b && !(b = wrapper.RunKernel(gammaCorrectKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.RunKernel(gammaCorrectKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { AddToReport(loc); } } else { b = false; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } } @@ -1315,30 +1315,30 @@ eRenderStatus RendererCL::RunFinalAccum() gridH = m_SpatialFilterCL.m_FinalRasH; OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH); - if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_AccumBufferName))) { this->m_ErrorReport.push_back(loc); }//Accumulator. - if (b && !(b = wrapper.SetImageArg(accumKernelIndex, argIndex++, wrapper.Shared(), m_FinalImageName))) { this->m_ErrorReport.push_back(loc); }//Final image. - if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterParamsBufferName))) { this->m_ErrorReport.push_back(loc); }//SpatialFilterCL. - if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterCoefsBufferName))) { this->m_ErrorReport.push_back(loc); }//Filter coefs. - if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_CurvesCsaName))) { this->m_ErrorReport.push_back(loc); }//Curve points. + if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_AccumBufferName))) { AddToReport(loc); }//Accumulator. + if (b && !(b = wrapper.SetImageArg(accumKernelIndex, argIndex++, wrapper.Shared(), m_FinalImageName))) { AddToReport(loc); }//Final image. + if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterParamsBufferName))) { AddToReport(loc); }//SpatialFilterCL. + if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterCoefsBufferName))) { AddToReport(loc); }//Filter coefs. + if (b && !(b = wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_CurvesCsaName))) { AddToReport(loc); }//Curve points. - if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, curvesSet))) { this->m_ErrorReport.push_back(loc); }//Do curves. - if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, bucketT(alphaBase)))) { this->m_ErrorReport.push_back(loc); }//Alpha base. - if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, bucketT(alphaScale)))) { this->m_ErrorReport.push_back(loc); }//Alpha scale. + if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, curvesSet))) { AddToReport(loc); }//Do curves. + if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, bucketT(alphaBase)))) { AddToReport(loc); }//Alpha base. + if (b && !(b = wrapper.SetArg (accumKernelIndex, argIndex++, bucketT(alphaScale)))) { AddToReport(loc); }//Alpha scale. if (b && wrapper.Shared()) - if (b && !(b = wrapper.EnqueueAcquireGLObjects(m_FinalImageName))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.EnqueueAcquireGLObjects(m_FinalImageName))) { AddToReport(loc); } - if (b && !(b = wrapper.RunKernel(accumKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.RunKernel(accumKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { AddToReport(loc); } if (b && wrapper.Shared()) - if (b && !(b = wrapper.EnqueueReleaseGLObjects(m_FinalImageName))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.EnqueueReleaseGLObjects(m_FinalImageName))) { AddToReport(loc); } //t.Toc((char*)loc); } else { b = false; - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } return b ? RENDER_OK : RENDER_ERROR; @@ -1375,14 +1375,14 @@ bool RendererCL::ClearBuffer(size_t device, const string& bufferName b = true; OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH); - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, bufferName))) { this->m_ErrorReport.push_back(loc); }//Buffer of byte. - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex++, width * elementSize))) { this->m_ErrorReport.push_back(loc); }//Width. - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex++, height))) { this->m_ErrorReport.push_back(loc); }//Height. - if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { this->m_ErrorReport.push_back(loc); } + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex++, bufferName))) { AddToReport(loc); }//Buffer of byte. + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex++, width * elementSize))) { AddToReport(loc); }//Width. + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex++, height))) { AddToReport(loc); }//Height. + if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { AddToReport(loc); } } else { - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } } @@ -1415,20 +1415,20 @@ bool RendererCL::RunDensityFilterPrivate(size_t kernelIndex, size_t { auto& wrapper = m_Devices[0]->m_Wrapper; - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_HistBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Histogram. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_AccumBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Accumulator. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DEFilterParamsBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//FlameDensityFilterCL. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DECoefsBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Coefs. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DEWidthsBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Widths. - if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DECoefIndicesBufferName))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Coef indices. - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkSizeW))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Chunk size width (gapW + 1). - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkSizeH))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Chunk size height (gapH + 1). - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkW))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Column chunk. - if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkH))) { this->m_ErrorReport.push_back(loc); } argIndex++;//Row chunk. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_HistBufferName))) { AddToReport(loc); } argIndex++;//Histogram. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_AccumBufferName))) { AddToReport(loc); } argIndex++;//Accumulator. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DEFilterParamsBufferName))) { AddToReport(loc); } argIndex++;//FlameDensityFilterCL. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DECoefsBufferName))) { AddToReport(loc); } argIndex++;//Coefs. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DEWidthsBufferName))) { AddToReport(loc); } argIndex++;//Widths. + if (b && !(b = wrapper.SetBufferArg(kernelIndex, argIndex, m_DECoefIndicesBufferName))) { AddToReport(loc); } argIndex++;//Coef indices. + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkSizeW))) { AddToReport(loc); } argIndex++;//Chunk size width (gapW + 1). + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkSizeH))) { AddToReport(loc); } argIndex++;//Chunk size height (gapH + 1). + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkW))) { AddToReport(loc); } argIndex++;//Column chunk. + if (b && !(b = wrapper.SetArg(kernelIndex, argIndex, chunkH))) { AddToReport(loc); } argIndex++;//Row chunk. //t.Toc(__FUNCTION__ " set args"); //t.Tic(); - if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { this->m_ErrorReport.push_back(loc); }//Method 7, accumulating to temp box area. + if (b && !(b = wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { AddToReport(loc); }//Method 7, accumulating to temp box area. //t.Toc(__FUNCTION__ " RunKernel()"); return b; @@ -1461,7 +1461,7 @@ int RendererCL::MakeAndGetDensityFilterProgram(size_t ss, uint filte if (wrapper.AddProgram(deEntryPoint, kernel, deEntryPoint, m_DoublePrecision)) kernelIndex = wrapper.FindKernelIndex(deEntryPoint);//Try to find it again, it will be present if successfully built. else - this->m_ErrorReport.push_back(string(loc) + "():\nBuilding the following program failed: \n" + kernel + "\n"); + AddToReport(string(loc) + "():\nBuilding the following program failed: \n" + kernel + "\n"); } } @@ -1493,7 +1493,7 @@ int RendererCL::MakeAndGetFinalAccumProgram(double& alphaBase, doubl if (wrapper.AddProgram(finalAccumEntryPoint, kernel, finalAccumEntryPoint, m_DoublePrecision)) kernelIndex = wrapper.FindKernelIndex(finalAccumEntryPoint);//Try to find it again, it will be present if successfully built. else - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } } @@ -1522,7 +1522,7 @@ int RendererCL::MakeAndGetGammaCorrectionProgram() if (b) kernelIndex = wrapper.FindKernelIndex(gammaEntryPoint);//Try to find it again, it will be present if successfully built. else - this->m_ErrorReport.push_back(loc); + AddToReport(loc); } return kernelIndex; @@ -1585,7 +1585,7 @@ bool RendererCL::SumDeviceHist() ostringstream os; os << loc << ": failed to sum histograms from the secondary device(s) to the primary device."; - this->m_ErrorReport.push_back(os.str()); + AddToReport(os.str()); } //t.Toc(loc); diff --git a/Source/EmberCL/RendererCL.h b/Source/EmberCL/RendererCL.h index 21c0caa..dbe60af 100644 --- a/Source/EmberCL/RendererCL.h +++ b/Source/EmberCL/RendererCL.h @@ -69,7 +69,7 @@ using EmberNs::Renderer::RendererBase::m_Rand; using EmberNs::Renderer::RendererBase::m_RenderTimer; using EmberNs::Renderer::RendererBase::m_IterTimer; using EmberNs::Renderer::RendererBase::m_ProgressTimer; -using EmberNs::Renderer::RendererBase::EmberReport::m_ErrorReport; +using EmberNs::Renderer::RendererBase::EmberReport::AddToReport; using EmberNs::Renderer::RendererBase::m_ResizeCs; using EmberNs::Renderer::RendererBase::m_ProcessAction; using EmberNs::Renderer::m_RotMat; diff --git a/Source/EmberCommon/EmberCommon.h b/Source/EmberCommon/EmberCommon.h index 0f641c7..e2548c3 100644 --- a/Source/EmberCommon/EmberCommon.h +++ b/Source/EmberCommon/EmberCommon.h @@ -112,10 +112,9 @@ template static bool InitPaletteList(const string& filename) { PaletteList paletteList;//Even though this is local, the members are static so they will remain. + bool added = paletteList.Add(filename); - paletteList.Add(filename); - - if (!paletteList.Size()) + if (!added || !paletteList.Size()) { cout << "Error parsing palette file " << filename << ". Reason: " << endl; cout << paletteList.ErrorReportString() << endl << "Returning without executing." << endl;