Report memory required in final render dialog.

Fix broken state of ember during failed render with strips.
This commit is contained in:
mfeemster
2014-12-09 00:24:28 -08:00
parent 9263906cb5
commit 3e70b8eec6
10 changed files with 112 additions and 42 deletions

View File

@ -116,12 +116,10 @@ void RendererBase::ChangeVal(std::function<void(void)> func, eProcessAction acti
}
/// <summary>
/// Return the amount of memory needed to render the current ember.
/// Optionally include the memory needed for the final output image.
/// Return the amount of memory needed for the histogram.
/// </summary>
/// <param name="includeFinal">If true include the memory needed for the final output image, else don't.</param>
/// <returns>The memory required to render the current ember</returns>
size_t RendererBase::MemoryRequired(size_t strips, bool includeFinal)
/// <returns>The memory required for the histogram to render the current ember</returns>
size_t RendererBase::HistMemoryRequired(size_t strips)
{
bool newFilterAlloc = false;
@ -130,9 +128,24 @@ size_t RendererBase::MemoryRequired(size_t strips, bool includeFinal)
ComputeBounds();
//Because ComputeBounds() was called, this includes gutter.
size_t histSize = (SuperSize() * HistBucketSize()) / strips;
return (SuperSize() * HistBucketSize()) / strips;
}
return (histSize * 2) + (includeFinal ? FinalBufferSize() : 0);//Multiply hist by 2 to account for the density filtering buffer which is the same size as the histogram.
/// <summary>
/// Return a pair whose first member contains the amount of memory needed for the histogram,
/// and whose second member contains the total the amount of memory needed to render the current ember.
/// Optionally include the memory needed for the final output image in pair.second.
/// </summary>
/// <param name="includeFinal">If true include the memory needed for the final output image, else don't.</param>
/// <returns>The histogram memory required in first, and the total memory required in second</returns>
pair<size_t, size_t> RendererBase::MemoryRequired(size_t strips, bool includeFinal)
{
pair<size_t, size_t> p;
p.first = HistMemoryRequired(strips);
p.second = (p.first * 2) + (includeFinal ? FinalBufferSize() : 0);//Multiply hist by 2 to account for the density filtering buffer which is the same size as the histogram.
return p;
}
/// <summary>

View File

@ -98,7 +98,8 @@ public:
//Non-virtual processing functions.
void ChangeVal(std::function<void(void)> func, eProcessAction action);
size_t MemoryRequired(size_t strips, bool includeFinal);
size_t HistMemoryRequired(size_t strips);
pair<size_t, size_t> MemoryRequired(size_t strips, bool includeFinal);
vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>> RandVec();
bool PrepFinalAccumVector(vector<byte>& pixels);