2014-07-08 03:11:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "FractoriumSettings.h"
|
|
|
|
#include "FractoriumEmberController.h"
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// FinalRenderEmberControllerBase and FinalRenderEmberController<T> classes.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// FractoriumEmberController and Fractorium need each other, but each can't include the other.
|
|
|
|
/// So Fractorium includes this file, and Fractorium is declared as a forward declaration here.
|
|
|
|
/// </summary>
|
|
|
|
class Fractorium;
|
|
|
|
class FractoriumFinalRenderDialog;
|
2014-12-11 00:50:15 -05:00
|
|
|
//class FractoriumEmberControllerBase;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Used to hold the options specified in the current state of the Gui for performing the final render.
|
|
|
|
/// </summary>
|
|
|
|
struct FinalRenderGuiState
|
|
|
|
{
|
|
|
|
bool m_EarlyClip;
|
2014-07-26 15:03:51 -04:00
|
|
|
bool m_YAxisUp;
|
2014-07-08 03:11:14 -04:00
|
|
|
bool m_AlphaChannel;
|
|
|
|
bool m_Transparency;
|
|
|
|
bool m_OpenCL;
|
|
|
|
bool m_Double;
|
|
|
|
bool m_SaveXml;
|
|
|
|
bool m_DoAll;
|
|
|
|
bool m_DoSequence;
|
|
|
|
bool m_KeepAspect;
|
|
|
|
eScaleType m_Scale;
|
|
|
|
QString m_Path;
|
2014-10-14 11:53:15 -04:00
|
|
|
QString m_Ext;
|
2014-07-08 03:11:14 -04:00
|
|
|
QString m_Prefix;
|
|
|
|
QString m_Suffix;
|
2014-12-06 00:05:09 -05:00
|
|
|
uint m_PlatformIndex;
|
|
|
|
uint m_DeviceIndex;
|
|
|
|
uint m_ThreadCount;
|
2015-06-17 23:05:53 -04:00
|
|
|
int m_ThreadPriority;
|
2014-10-14 11:53:15 -04:00
|
|
|
double m_WidthScale;
|
|
|
|
double m_HeightScale;
|
2014-07-20 20:16:23 -04:00
|
|
|
double m_Quality;
|
2014-12-06 00:05:09 -05:00
|
|
|
uint m_TemporalSamples;
|
|
|
|
uint m_Supersample;
|
|
|
|
uint m_Strips;
|
2014-07-08 03:11:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// FinalRenderEmberControllerBase serves as a non-templated base class with virtual
|
|
|
|
/// functions which will be overridden in a derived class that takes a template parameter.
|
|
|
|
/// Although not meant to be used as an interactive renderer, it derives from FractoriumEmberControllerBase
|
|
|
|
/// to access a few of its members to avoid having to redefine them here.
|
|
|
|
/// </summary>
|
|
|
|
class FinalRenderEmberControllerBase : public FractoriumEmberControllerBase
|
|
|
|
{
|
|
|
|
friend FractoriumFinalRenderDialog;
|
|
|
|
|
|
|
|
public:
|
2014-10-14 11:53:15 -04:00
|
|
|
FinalRenderEmberControllerBase(FractoriumFinalRenderDialog* finalRenderDialog);
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual ~FinalRenderEmberControllerBase() { }
|
|
|
|
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual void SyncCurrentToGui() { }
|
|
|
|
virtual void SyncGuiToEmbers(size_t widthOverride = 0, size_t heightOverride = 0) { }
|
|
|
|
virtual void SyncCurrentToSizeSpinners(bool scale, bool size) { }
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual void ResetProgress(bool total = true) { }
|
2014-12-09 03:24:28 -05:00
|
|
|
virtual tuple<size_t, size_t, size_t> SyncAndComputeMemory() { return tuple<size_t, size_t, size_t>(0, 0, 0); }
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual double OriginalAspect() { return 1; }
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual QString ComposePath(const QString& name) { return ""; }
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
void CancelRender();
|
|
|
|
bool CreateRendererFromGUI();
|
2014-10-14 11:53:15 -04:00
|
|
|
void Output(const QString& s);
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_Run;
|
|
|
|
bool m_PreviewRun;
|
2014-12-06 00:05:09 -05:00
|
|
|
uint m_ImageCount;
|
|
|
|
uint m_FinishedImageCount;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
QFuture<void> m_Result;
|
2014-08-03 19:16:10 -04:00
|
|
|
QFuture<void> m_FinalPreviewResult;
|
|
|
|
std::function<void (void)> m_FinalRenderFunc;
|
|
|
|
std::function<void (void)> m_FinalPreviewRenderFunc;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
FractoriumSettings* m_Settings;
|
2014-10-14 11:53:15 -04:00
|
|
|
FractoriumFinalRenderDialog* m_FinalRenderDialog;
|
2014-07-08 03:11:14 -04:00
|
|
|
FinalRenderGuiState m_GuiState;
|
|
|
|
OpenCLWrapper m_Wrapper;
|
|
|
|
CriticalSection m_PreviewCs;
|
|
|
|
Timing m_RenderTimer;
|
|
|
|
Timing m_TotalTimer;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Templated derived class which implements all interaction functionality between the embers
|
|
|
|
/// of a specific template type and the final render dialog;
|
|
|
|
/// </summary>
|
|
|
|
template<typename T>
|
|
|
|
class FinalRenderEmberController : public FinalRenderEmberControllerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FinalRenderEmberController(FractoriumFinalRenderDialog* finalRender);
|
|
|
|
virtual ~FinalRenderEmberController() { }
|
|
|
|
|
2014-10-14 11:53:15 -04:00
|
|
|
//Virtual functions overridden from FractoriumEmberControllerBase.
|
|
|
|
virtual void SetEmberFile(const EmberFile<float>& emberFile) override;
|
2015-01-14 08:15:23 -05:00
|
|
|
virtual void CopyEmberFile(EmberFile<float>& emberFile, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
|
2014-07-08 03:11:14 -04:00
|
|
|
#ifdef DO_DOUBLE
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual void SetEmberFile(const EmberFile<double>& emberFile) override;
|
2015-01-14 08:15:23 -05:00
|
|
|
virtual void CopyEmberFile(EmberFile<double>& emberFile, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
|
2014-07-08 03:11:14 -04:00
|
|
|
#endif
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual void SetEmber(size_t index) override;
|
|
|
|
virtual bool Render() override;
|
2014-12-06 00:05:09 -05:00
|
|
|
virtual bool CreateRenderer(eRendererType renderType, uint platform, uint device, bool shared = true) override;
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual int ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs) override;
|
|
|
|
virtual size_t Index() const override { return m_Ember->m_Index; }
|
2014-12-06 00:05:09 -05:00
|
|
|
virtual uint SizeOfT() const override { return sizeof(T); }
|
2014-10-14 11:53:15 -04:00
|
|
|
|
|
|
|
//Virtual functions overridden from FinalRenderEmberControllerBase.
|
|
|
|
virtual void SyncCurrentToGui() override;
|
|
|
|
virtual void SyncGuiToEmbers(size_t widthOverride = 0, size_t heightOverride = 0) override;
|
|
|
|
virtual void SyncCurrentToSizeSpinners(bool scale, bool size) override;
|
|
|
|
virtual void ResetProgress(bool total = true) override;
|
2014-12-09 03:24:28 -05:00
|
|
|
virtual tuple<size_t, size_t, size_t> SyncAndComputeMemory() override;
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual double OriginalAspect() override { return double(m_Ember->m_OrigFinalRasW) / m_Ember->m_OrigFinalRasH; }
|
|
|
|
virtual QString Name() const override { return QString::fromStdString(m_Ember->m_Name); }
|
|
|
|
virtual QString ComposePath(const QString& name) override;
|
|
|
|
|
2014-07-08 03:11:14 -04:00
|
|
|
protected:
|
2014-10-14 11:53:15 -04:00
|
|
|
void CancelPreviewRender();
|
|
|
|
void RenderComplete(Ember<T>& ember);
|
|
|
|
void SyncGuiToEmber(Ember<T>& ember, size_t widthOverride = 0, size_t heightOverride = 0);
|
2015-01-19 11:39:50 -05:00
|
|
|
void SetProgressComplete(int val);
|
2014-07-08 03:11:14 -04:00
|
|
|
|
2014-10-14 11:53:15 -04:00
|
|
|
Ember<T>* m_Ember;
|
2014-07-08 03:11:14 -04:00
|
|
|
Ember<T> m_PreviewEmber;
|
|
|
|
EmberFile<T> m_EmberFile;
|
|
|
|
EmberToXml<T> m_XmlWriter;
|
2014-10-18 17:07:07 -04:00
|
|
|
unique_ptr<EmberNs::Renderer<T, T>> m_FinalPreviewRenderer;
|
2014-07-08 03:11:14 -04:00
|
|
|
};
|
|
|
|
|