summaryrefslogtreecommitdiff
path: root/aa.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-20 00:48:44 +0800
committerKeuin <[email protected]>2022-04-20 00:48:44 +0800
commitba97aeb0a6ff52b79f43f883c639a55c8e3cf78d (patch)
tree8f8707eba7095a75c6d65d7265d1b8b8040c2194 /aa.h
parent3fa4d41e9cac75df7514c2ff8dd27842aaafc4a7 (diff)
Reserve vector thread_pool::tasks to speed up task initializing.
Diffstat (limited to 'aa.h')
-rw-r--r--aa.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/aa.h b/aa.h
index 3a4def4..9622696 100644
--- a/aa.h
+++ b/aa.h
@@ -50,6 +50,26 @@ public:
assert(samples >= 1);
}
+ aa_viewport(const vec3<V> &cxyz,
+ const vec3<V> &screen_center,
+ uint16_t image_width,
+ uint16_t image_height,
+ double fov_h,
+ hitlist &world,
+ unsigned samples,
+ int threads = -1) :
+ cxyz(cxyz),
+ screen_center(screen_center),
+ image_width(image_width),
+ image_height(image_height),
+ screen_hw{(cxyz - screen_center).norm() * tan((double) fov_h / 2.0)},
+ screen_hh{screen_hw * ((double) image_height / image_width)},
+ world(world),
+ samples(samples),
+ threads((threads > 0) ? threads : (int) std::thread::hardware_concurrency()) {
+ assert(samples >= 1);
+ }
+
bitmap<U> render() {
static constexpr auto seed = 123456789012345678ULL;
const unsigned thread_count = std::min((unsigned) threads, samples);
@@ -62,7 +82,7 @@ public:
uint64_t diffuse_seed;
};
- thread_pool<s_render_task, typeof(*this), typeof(images)> pool{thread_count, *this, images};
+ thread_pool<s_render_task, typeof(*this), typeof(images)> pool{thread_count, *this, images, samples};
timer tim{true};
std::cerr << "Seeding tasks..." << std::endl;