Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
AdaptiveSamplingRenderer.h
Go to the documentation of this file.
1#pragma once
2
7#include "Frame/TFrame.h"
10#include "Math/Color/Spectrum.h"
12
13#include <Common/primitive_type.h>
14
15#include <memory>
16#include <queue>
17#include <cstddef>
18#include <vector>
19#include <functional>
20
21namespace ph
22{
23
24class Scene;
25class Receiver;
26class FixedSizeThreadPool;
27
29{
30public:
31 void doUpdate(const CoreCookedUnit& cooked, const VisualWorld& world) override;
32 void doRender() override;
33 void retrieveFrame(std::size_t layerIndex, HdrRgbFrame& out_frame) override;
34
35 std::size_t asyncPollUpdatedRegions(TSpan<RenderRegionStatus> out_regions) override;
38 void asyncPeekFrame(
39 std::size_t layerIndex,
40 const Region& region,
41 HdrRgbFrame& out_frame) override;
42
44
45private:
47
48 constexpr static auto REFINE_MODE = DammertzDispatcher::ERefineMode::MIN_ERROR_DIFFERENCE;
49 //constexpr static auto REFINE_MODE = DammertzDispatcher::ERefineMode::MIDPOINT;
50
51 void asyncAddUpdatedRegion(const Region& region, bool isUpdating);
52 std::function<void()> createWork(FixedSizeThreadPool& workers, uint32 workerId);
53
54 const Scene* m_scene;
55 const Receiver* m_receiver;
56 SampleGenerator* m_sampleGenerator;
57 HdrRgbFilm m_allEffortFilm;
58 HdrRgbFilm m_halfEffortFilm;
59
60 std::vector<ReceiverSamplingWork> m_renderWorks;
61 std::vector<FilmEstimator> m_filmEstimators;
62
63 std::vector<MetaRecordingProcessor> m_metaRecorders;
64 HdrRgbFrame m_metaFrame;
65
66 DammertzDispatcher m_dispatcher;
67 std::vector<uint32> m_freeWorkerIds;
68 real m_precisionStandard;
69 std::size_t m_numInitialSamples;
70 HdrRgbFrame m_allEffortFrame;
71 HdrRgbFrame m_halfEffortFrame;
72 TAtomicQuasiQueue<RenderRegionStatus> m_updatedRegionQueue;
73
74 std::mutex m_rendererMutex;
75 std::atomic_uint64_t m_totalPaths;
76 std::atomic_uint32_t m_suppliedFractionBits;
77 std::atomic_uint32_t m_submittedFractionBits;
78 std::atomic_uint32_t m_numNoisyRegions;
79};
80
81}// end namespace ph
Definition AdaptiveSamplingRenderer.h:29
void asyncPeekFrame(std::size_t layerIndex, const Region &region, HdrRgbFrame &out_frame) override
Get the intermediate render result. This method is similar to retrieveFrame(), except that correctnes...
Definition AdaptiveSamplingRenderer.cpp:210
void doUpdate(const CoreCookedUnit &cooked, const VisualWorld &world) override
Perform necessary updates for rendering. No asynchronous operation is allowed during update.
Definition AdaptiveSamplingRenderer.cpp:24
RenderStats asyncQueryRenderStats() override
Get general information of the ongoing rendering process. More information can be provided by the imp...
Definition AdaptiveSamplingRenderer.cpp:262
void retrieveFrame(std::size_t layerIndex, HdrRgbFrame &out_frame) override
Get the rendered result.
Definition AdaptiveSamplingRenderer.cpp:240
std::size_t asyncPollUpdatedRegions(TSpan< RenderRegionStatus > out_regions) override
Get the rendering regions that have been updated. Status of a region will always transition to ERegio...
Definition AdaptiveSamplingRenderer.cpp:202
RenderProgress asyncQueryRenderProgress() override
Get progress of the ongoing rendering process. Implementation is advised to provide this information ...
Definition AdaptiveSamplingRenderer.cpp:283
RenderObservationInfo getObservationInfo() const override
Get information about available transient outputs of an ongoing render operation. This information wi...
Definition AdaptiveSamplingRenderer.cpp:304
void doRender() override
Perform rendering.
Definition AdaptiveSamplingRenderer.cpp:89
Definition CoreCookedUnit.h:19
Definition DammertzDispatcher.h:35
A thread pool where works are accessed concurrently by blocking other threads. A thread pool that con...
Definition FixedSizeThreadPool.h:21
A film that records RGB values internally. Although film samples are added as spectral values,...
Definition HdrRgbFilm.h:21
A target that can receive any physical quantity, typically electromagnetic energy....
Definition Receiver.h:22
Meta information for data related to ongoing render operation.
Definition RenderObservationInfo.h:15
Definition RenderProgress.h:12
Definition RenderStats.h:12
Generates samples in [0, 1]. Generators of different types produces samples with different properties...
Definition SampleGenerator.h:35
Definition SamplingRenderer.h:13
A unified interface for accessing cooked content in a visual world.
Definition Scene.h:27
A multi-producer, multi-consumer, lock-free concurrent queue-like structure. For single-thread uses,...
Definition TAtomicQuasiQueue.h:24
Definition TStepperReceiverMeasurementEstimator.h:14
A virtual world for image synthesis.
Definition VisualWorld.h:34
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< T, EXTENT > TSpan
A contiguous sequence of objects of type T. Effectively the same as std::span.
Definition TSpan.h:12